Fix put_empobj() for types other than units

put_empobj() used struct empobj member uid, which is valid only for
units.  Existing users pass only units, fortunately.  Fix by making it
take type and uid parameters.
This commit is contained in:
Markus Armbruster 2008-02-23 07:48:32 +01:00
parent 3117ef9c7a
commit e63f38833b
4 changed files with 5 additions and 15 deletions

View file

@ -91,7 +91,7 @@ struct empobj_chr;
extern char *obj_nameof(struct empobj *gp); extern char *obj_nameof(struct empobj *gp);
extern struct empobj *get_empobjp(int type, int id); extern struct empobj *get_empobjp(int type, int id);
extern int put_empobj(struct empobj *gp); extern int put_empobj(int, int, struct empobj *gp);
extern struct empobj_chr *get_empobj_chr(struct empobj *gp); extern struct empobj_chr *get_empobj_chr(struct empobj *gp);
extern char *emp_obj_chr_name(struct empobj *gp); extern char *emp_obj_chr_name(struct empobj *gp);
extern int get_empobj_mob_max(int type); extern int get_empobj_mob_max(int type);

View file

@ -321,7 +321,7 @@ mission(void)
gp->mission = mission; gp->mission = mission;
gp->opx = x; gp->opx = x;
gp->opy = y; gp->opy = y;
put_empobj(gp); put_empobj(type, gp->uid, gp);
} }
if (num == 0) { if (num == 0) {
pr("No %s%s\n", ef_nameof(type), splur(num)); pr("No %s%s\n", ef_nameof(type), splur(num));

View file

@ -66,19 +66,9 @@ get_empobjp(int type, int id)
} }
int int
put_empobj(struct empobj *gp) put_empobj(int type, int id, struct empobj *gp)
{ {
switch (gp->ef_type) return ef_write(type, id, gp);
{
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);
}
} }
struct empobj_chr * struct empobj_chr *

View file

@ -118,7 +118,7 @@ unit_put(struct emp_qelem *list, natid actor)
} }
if (ulp->unit.ef_type == EF_SHIP) if (ulp->unit.ef_type == EF_SHIP)
ulp->unit.ship.shp_mobil = (int)ulp->mobil; ulp->unit.ship.shp_mobil = (int)ulp->mobil;
put_empobj(&ulp->unit.gen); put_empobj(ulp->unit.gen.ef_type, ulp->unit.gen.uid, &ulp->unit.gen);
newqp = qp->q_back; newqp = qp->q_back;
emp_remque(qp); emp_remque(qp);
free(qp); free(qp);