"Einheiten produzieren kein Holz, Pferde, Steine"

Reihenfolge-Fix der zu Neu-AW gefuehrt hat.
This commit is contained in:
Enno Rehling 2007-02-04 13:13:48 +00:00
parent bb374629ba
commit 3e09fc0c7d
3 changed files with 80 additions and 93 deletions

View File

@ -1509,46 +1509,46 @@ get_allocator(const struct resource_type * rtype)
return NULL; return NULL;
} }
static void void
split_allocations(region * r) split_allocations(region * r)
{ {
allocation_list ** p_alist=&allocations; allocation_list ** p_alist=&allocations;
freset(r, RF_DH); freset(r, RF_DH);
while (*p_alist) { while (*p_alist) {
allocation_list * alist = *p_alist; allocation_list * alist = *p_alist;
const resource_type * rtype = alist->type; const resource_type * rtype = alist->type;
allocate_function alloc = get_allocator(rtype); allocate_function alloc = get_allocator(rtype);
const item_type * itype = resource2item(rtype); const item_type * itype = resource2item(rtype);
allocation ** p_al = &alist->data; allocation ** p_al = &alist->data;
freset(r, RF_DH); freset(r, RF_DH);
alloc(rtype, r, alist->data); alloc(rtype, r, alist->data);
while (*p_al) { while (*p_al) {
allocation * al = *p_al; allocation * al = *p_al;
if (al->get) { if (al->get) {
assert(itype || !"not implemented for non-items"); assert(itype || !"not implemented for non-items");
i_change(&al->unit->items, itype, al->get); i_change(&al->unit->items, itype, al->get);
produceexp(al->unit, itype->construction->skill, al->unit->number); produceexp(al->unit, itype->construction->skill, al->unit->number);
fset(r, RF_DH); fset(r, RF_DH);
} }
if (al->want==INT_MAX) al->want = al->get; if (al->want==INT_MAX) al->want = al->get;
if (fval(al, AFL_LOWSKILL)) { if (fval(al, AFL_LOWSKILL)) {
ADDMSG(&al->unit->faction->msgs, ADDMSG(&al->unit->faction->msgs,
msg_message("produce_lowskill", "unit region resource", msg_message("produce_lowskill", "unit region resource",
al->unit, al->unit->region, rtype)); al->unit, al->unit->region, rtype));
} else { } else {
ADDMSG(&al->unit->faction->msgs, msg_message("produce", ADDMSG(&al->unit->faction->msgs, msg_message("produce",
"unit region amount wanted resource", "unit region amount wanted resource",
al->unit, al->unit->region, al->get, al->want, rtype)); al->unit, al->unit->region, al->get, al->want, rtype));
} }
*p_al=al->next; *p_al=al->next;
free_allocation(al); free_allocation(al);
} }
*p_alist=alist->next; *p_alist=alist->next;
free(alist); free(alist);
} }
allocations = NULL; allocations = NULL;
} }
static void static void
@ -3171,7 +3171,6 @@ produce(void)
} }
} }
split_allocations(r);
/* Entertainment (expandentertainment) und Besteuerung (expandtax) vor den /* Entertainment (expandentertainment) und Besteuerung (expandtax) vor den
* Befehlen, die den Bauern mehr Geld geben, damit man aus den Zahlen der * Befehlen, die den Bauern mehr Geld geben, damit man aus den Zahlen der
* letzten Runde berechnen kann, wieviel die Bauern für Unterhaltung * letzten Runde berechnen kann, wieviel die Bauern für Unterhaltung

View File

@ -54,6 +54,7 @@ enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC
void maintain_buildings(struct region * r, boolean crash); void maintain_buildings(struct region * r, boolean crash);
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r); extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
extern int make_cmd(struct unit * u, struct order * ord); extern int make_cmd(struct unit * u, struct order * ord);
extern void split_allocations(struct region * r);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -3690,7 +3690,7 @@ claim_cmd(unit * u, struct order * ord)
typedef struct processor { typedef struct processor {
struct processor * next; struct processor * next;
int priority; int priority;
enum { PR_GLOBAL, PR_REGION, PR_UNIT, PR_ORDER } type; enum { PR_GLOBAL, PR_REGION_PRE, PR_UNIT, PR_ORDER, PR_REGION_POST } type;
union { union {
struct { struct {
keyword_t kword; keyword_t kword;
@ -3712,8 +3712,8 @@ typedef struct processor {
static processor * processors; static processor * processors;
void processor *
add_proc_order(int priority, keyword_t kword, int (*parser)(struct unit *, struct order *), boolean thisorder, const char * name) add_proc(int priority, const char * name, int type)
{ {
processor **pproc = &processors; processor **pproc = &processors;
processor *proc; processor *proc;
@ -3721,87 +3721,67 @@ add_proc_order(int priority, keyword_t kword, int (*parser)(struct unit *, struc
while (*pproc) { while (*pproc) {
proc = *pproc; proc = *pproc;
if (proc->priority>priority) break; if (proc->priority>priority) break;
else if (proc->priority==priority && proc->type>=PR_ORDER) break; else if (proc->priority==priority && proc->type>=type) break;
pproc = &proc->next; pproc = &proc->next;
} }
proc = malloc(sizeof(processor)); proc = malloc(sizeof(processor));
proc->priority = priority; proc->priority = priority;
proc->type = PR_ORDER; proc->type = type;
proc->data.per_order.process = parser;
proc->data.per_order.kword = kword;
proc->data.per_order.thisorder = thisorder;
proc->name = name; proc->name = name;
proc->next = *pproc; proc->next = *pproc;
*pproc = proc; *pproc = proc;
return proc;
}
void
add_proc_order(int priority, keyword_t kword, int (*parser)(struct unit *, struct order *), boolean thisorder, const char * name)
{
processor * proc = add_proc(priority, name, PR_ORDER);
if (proc) {
proc->data.per_order.process = parser;
proc->data.per_order.kword = kword;
proc->data.per_order.thisorder = thisorder;
}
} }
void void
add_proc_global(int priority, void (*process)(void), const char * name) add_proc_global(int priority, void (*process)(void), const char * name)
{ {
processor **pproc = &processors; processor * proc = add_proc(priority, name, PR_GLOBAL);
processor *proc; if (proc) {
proc->data.global.process = process;
while (*pproc) {
proc = *pproc;
if (proc->priority>priority) break;
else if (proc->priority==priority && proc->type>PR_GLOBAL) break;
pproc = &proc->next;
} }
proc = malloc(sizeof(processor));
proc->priority = priority;
proc->type = PR_GLOBAL;
proc->data.global.process = process;
proc->name = name;
proc->next = *pproc;
*pproc = proc;
} }
void void
add_proc_region(int priority, void (*process)(region *), const char * name) add_proc_region(int priority, void (*process)(region *), const char * name)
{ {
processor **pproc = &processors; processor * proc = add_proc(priority, name, PR_REGION_PRE);
processor *proc; if (proc) {
proc->data.per_region.process = process;
while (*pproc) {
proc = *pproc;
if (proc->priority>priority) break;
else if (proc->priority==priority && proc->type>PR_REGION) break;
pproc = &proc->next;
} }
}
proc = malloc(sizeof(processor)); void
proc->priority = priority; add_proc_postregion(int priority, void (*process)(region *), const char * name)
proc->type = PR_REGION; {
proc->data.per_region.process = process; processor * proc = add_proc(priority, name, PR_REGION_POST);
proc->name = name; if (proc) {
proc->next = *pproc; proc->data.per_region.process = process;
*pproc = proc; }
} }
void void
add_proc_unit(int priority, void (*process)(unit *), const char * name) add_proc_unit(int priority, void (*process)(unit *), const char * name)
{ {
processor **pproc = &processors; processor * proc = add_proc(priority, name, PR_UNIT);
processor *proc; if (proc) {
proc->data.per_unit.process = process;
while (*pproc) {
proc = *pproc;
if (proc->priority>priority) break;
else if (proc->priority==priority && proc->type>PR_UNIT) break;
pproc = &proc->next;
} }
proc = malloc(sizeof(processor));
proc->priority = priority;
proc->type = PR_UNIT;
proc->data.per_unit.process = process;
proc->name = name;
proc->next = *pproc;
*pproc = proc;
} }
/* per priority, execute processors in order from PR_GLOBAL down to PR_ORDER */
void void
process(void) process(void)
{ {
@ -3827,7 +3807,7 @@ process(void)
unit *u; unit *u;
processor *pregion = pglobal; processor *pregion = pglobal;
while (pregion && pregion->priority==prio && pregion->type==PR_REGION) { while (pregion && pregion->priority==prio && pregion->type==PR_REGION_PRE) {
pregion->data.per_region.process(r); pregion->data.per_region.process(r);
pregion = pregion->next; pregion = pregion->next;
} }
@ -3856,6 +3836,12 @@ process(void)
porder = porder->next; porder = porder->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;
} }
} }
} }
@ -3971,8 +3957,9 @@ processorders (void)
add_proc_order(p, K_STUDY, &learn_cmd, true, "Lernen"); add_proc_order(p, K_STUDY, &learn_cmd, true, "Lernen");
p+=10; p+=10;
add_proc_order(p, K_MAKE, &make_cmd, true, "Produktion");
add_proc_global(p, &produce, "Arbeiten, Handel, Rekruten"); add_proc_global(p, &produce, "Arbeiten, Handel, Rekruten");
add_proc_order(p, K_MAKE, &make_cmd, true, "Produktion");
add_proc_postregion(p, &split_allocations, "Produktion II");
p+=10; p+=10;
add_proc_region(p, &enter_2, "Kontaktieren & Betreten (3. Versuch)"); add_proc_region(p, &enter_2, "Kontaktieren & Betreten (3. Versuch)");