From: Markus Armbruster Date: Sat, 2 Jan 2010 08:14:55 +0000 (+0100) Subject: Simplify ask_olist and get_dlist() not to re-read land units X-Git-Tag: v4.3.24~31 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=ec75a407c75b3ed7407ce3c3f39953e0991e8aed Simplify ask_olist and get_dlist() not to re-read land units getland() is obviously redundant in get_dlist(), because the land unit can't have changed since the previous read. What's up with ask_olist() is less obvious. For each capable land unit, ask_olist() asks the player whether to attack with it. If it attacks, it gets copied into olist. Since asking the player yields the processor, these copies can become stale. However, re-reading fixes that just for the last one. Moreover, the code copes with stale copies just fine: ask_olist() is always directly followed by att_get_offense() or att_move_in_off(), and both replace the potentially stale copy in olist. --- diff --git a/src/lib/subs/attsub.c b/src/lib/subs/attsub.c index ebf3f65a0..dcf62b992 100644 --- a/src/lib/subs/attsub.c +++ b/src/lib/subs/attsub.c @@ -1107,7 +1107,7 @@ ask_olist(int combat_mode, struct combat *off, struct combat *def, memset(llp, 0, sizeof(struct ulist)); emp_insque(&llp->queue, olist); llp->mobil = mobcost; - getland(land.lnd_uid, &llp->unit.land); + llp->unit.land = land; llp->x = llp->unit.land.lnd_x; llp->y = llp->unit.land.lnd_y; llp->chrp = (struct empobj_chr *)&lchr[(int)llp->unit.land.lnd_type]; @@ -1237,7 +1237,7 @@ get_dlist(struct combat *def, struct emp_qelem *list, int a_spy, memset(llp, 0, sizeof(struct ulist)); emp_insque(&llp->queue, list); llp->supplied = lnd_supply_all(&land); - getland(land.lnd_uid, &llp->unit.land); + llp->unit.land = land; llp->x = llp->unit.land.lnd_x; llp->y = llp->unit.land.lnd_y; llp->chrp = (struct empobj_chr *)&lchr[(int)llp->unit.land.lnd_type];