(put_empobj): New. Put generic empobj into the appropriate data file.

(get_empobj_chr): New.  Get characteristics for empobj.
(mission, build_mission_list_type): Switch to use new
functions put_empobj() and get_empobj_chr().
This commit is contained in:
Ron Koenderink 2006-07-20 14:12:35 +00:00
parent 8e7199c338
commit a62989d4a3
4 changed files with 50 additions and 22 deletions

View file

@ -55,3 +55,49 @@ obj_nameof(struct empobj *gp)
CANT_HAPPEN("unsupported TYPE");
return "";
}
int
put_empobj(struct empobj *gp)
{
switch (gp->ef_type)
{
case EF_SECTOR:
return ef_write(gp->ef_type, sctoff(gp->x, gp->y), gp);
case EF_NATION:
case EF_BMAP:
case EF_MAP:
return ef_write(gp->ef_type, gp->own, gp);
default:
return ef_write(gp->ef_type, gp->uid, gp);
}
}
void *
get_empobj_chr(struct empobj *gp)
{
void *cp;
switch (gp->ef_type) {
case EF_LAND:
cp = &lchr[(int)gp->type];
break;
case EF_SHIP:
cp = &mchr[(int)gp->type];
break;
case EF_PLANE:
cp = &plchr[(int)gp->type];
break;
case EF_NUKE:
cp = &nchr[(int)gp->type];
break;
case EF_SECTOR:
cp = &dchr[(int)gp->type];
break;
default:
CANT_HAPPEN("unsupported TYPE");
cp = NULL;
break;
}
return cp;
}