From e63f38833bd218494d993f2668e460d84a28da13 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 23 Feb 2008 07:48:32 +0100 Subject: [PATCH] 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. --- include/empobj.h | 2 +- src/lib/commands/miss.c | 2 +- src/lib/subs/empobj.c | 14 ++------------ src/lib/subs/unitsub.c | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/include/empobj.h b/include/empobj.h index 59df1367f..364f8e660 100644 --- a/include/empobj.h +++ b/include/empobj.h @@ -91,7 +91,7 @@ struct empobj_chr; extern char *obj_nameof(struct empobj *gp); 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 char *emp_obj_chr_name(struct empobj *gp); extern int get_empobj_mob_max(int type); diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index b60ff783a..d859d564f 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -321,7 +321,7 @@ mission(void) gp->mission = mission; gp->opx = x; gp->opy = y; - put_empobj(gp); + put_empobj(type, gp->uid, gp); } if (num == 0) { pr("No %s%s\n", ef_nameof(type), splur(num)); diff --git a/src/lib/subs/empobj.c b/src/lib/subs/empobj.c index 35a18d07f..2a1cca6b8 100644 --- a/src/lib/subs/empobj.c +++ b/src/lib/subs/empobj.c @@ -66,19 +66,9 @@ get_empobjp(int type, int id) } int -put_empobj(struct empobj *gp) +put_empobj(int type, int id, 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); - } + return ef_write(type, id, gp); } struct empobj_chr * diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c index ebc341c57..bc13c745a 100644 --- a/src/lib/subs/unitsub.c +++ b/src/lib/subs/unitsub.c @@ -118,7 +118,7 @@ unit_put(struct emp_qelem *list, natid actor) } if (ulp->unit.ef_type == EF_SHIP) 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; emp_remque(qp); free(qp); -- 2.43.0