From 98c2524e891dfa211716885f8780b4539f32e065 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 4 Feb 2007 15:47:10 +0000 Subject: [PATCH] processing changes fixed again. --- src/common/gamecode/laws.c | 74 ++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index da99122dd..2fe6b5cd5 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -3789,7 +3789,7 @@ process(void) while (proc) { int prio = proc->priority; region *r; - processor *pnext = proc; + processor *pglobal = proc; printf("- Step %u\n", prio); while (proc && proc->priority==prio) { @@ -3797,48 +3797,62 @@ process(void) proc = proc->next; } - while (pnext && pnext->priority==prio && pnext->type==PR_GLOBAL) { - pnext->data.global.process(); - pnext = pnext->next; + while (pglobal && pglobal->priority==prio && pglobal->type==PR_GLOBAL) { + pglobal->data.global.process(); + pglobal = pglobal->next; } - if (pnext==NULL || pnext->priority!=prio) continue; + if (pglobal==NULL || pglobal->priority!=prio) continue; for (r = regions; r; r = r->next) { unit *u; + processor *pregion = pglobal; - while (pnext && pnext->priority==prio && pnext->type==PR_REGION_PRE) { - pnext->data.per_region.process(r); - pnext = pnext->next; + while (pregion && pregion->priority==prio && pregion->type==PR_REGION_PRE) { + pregion->data.per_region.process(r); + pregion = pregion->next; } - if (pnext==NULL || pnext->priority!=prio) continue; + if (pregion==NULL || pregion->priority!=prio) continue; - for (u=r->units;u;u=u->next) { + if (r->units) { + for (u=r->units;u;u=u->next) { + processor *porder, *punit = pregion; - while (pnext && pnext->priority==prio && pnext->type==PR_UNIT) { - pnext->data.per_unit.process(u); - pnext = pnext->next; - } - if (pnext==NULL || pnext->priority!=prio) continue; - - while (pnext && pnext->priority==prio && pnext->type==PR_ORDER) { - order ** ordp = &u->orders; - if (pnext->data.per_order.thisorder) ordp = &u->thisorder; - while (*ordp) { - order * ord = *ordp; - if (get_keyword(ord) == pnext->data.per_order.kword) { - pnext->data.per_order.process(u, ord); - } - if (*ordp==ord) ordp=&ord->next; + while (punit && punit->priority==prio && punit->type==PR_UNIT) { + punit->data.per_unit.process(u); + punit = punit->next; } - pnext = pnext->next; + if (punit==NULL || punit->priority!=prio) continue; + + porder = punit; + while (porder && porder->priority==prio && porder->type==PR_ORDER) { + order ** ordp = &u->orders; + if (porder->data.per_order.thisorder) ordp = &u->thisorder; + while (*ordp) { + order * ord = *ordp; + if (get_keyword(ord) == porder->data.per_order.kword) { + porder->data.per_order.process(u, ord); + } + if (*ordp==ord) ordp=&ord->next; + } + porder = porder->next; + } + + /* this is where the region post-processig will start: */ + pregion = porder; + } + } else { + /* in case there weren't any units, move the pregion pointer over the unit/order tasks */ + while (pregion && pregion->priority==prio && pregion->type!=PR_REGION_POST) { + pregion = pregion->next; } } - if (pnext==NULL || pnext->priority!=prio) continue; - while (pnext && pnext->priority==prio && pnext->type==PR_REGION_POST) { - pnext->data.per_region.process(r); - pnext = pnext->next; + while (pregion && pregion->priority==prio && pregion->type==PR_REGION_POST) { + pregion->data.per_region.process(r); + pregion = pregion->next; } + if (pregion==NULL || pregion->priority!=prio) continue; + } } }