diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 9000093e1..054aefd09 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -101,143 +101,6 @@ extern int * age; boolean nobattle = false; /* ------------------------------------------------------------- */ -void -destroyfaction(faction * f) -{ - region *rc; - unit *u; - faction *ff; - - if( !f->alive ) return; - - for (u=f->units;u;u=u->nextF) { - region * r = u->region; - unit * au; - int number = 0; - struct friend { - struct friend * next; - int number; - faction * faction; - unit * unit; - } * friends = NULL; - for (au=r->units;au;au=au->next) if (au->faction!=f) { - if (alliedunit(u, au->faction, HELP_ALL)) { - struct friend * nf, ** fr = &friends; - - while (*fr && (*fr)->faction->nofaction->no) fr = &(*fr)->next; - nf = *fr; - if (nf==NULL || nf->faction!=au->faction) { - nf = calloc(sizeof(struct friend), 1); - nf->next = *fr; - nf->faction = au->faction; - nf->unit = au; - *fr = nf; - } - nf->number += au->number; - number += au->number; - } - } - if (friends && number) { - struct friend * nf = friends; - while (nf) { - unit * u2 = nf->unit; -#ifdef NEW_ITEMS - item * itm = u->items; - while(itm){ - const item_type * itype = itm->type; - item * itn = itm->next; - int n = itm->number; - n = n * nf->number / number; - if (n>0) { - i_change(&u->items, itype, -n); - i_change(&u2->items, itype, n); - } - itm = itn; - } -#else - resource_t res; - for (res = 0; res <= R_SILVER; ++res) { - int n = get_resource(u, res); - if (n<=0) continue; - n = n * nf->number / number; - if (n<=0) continue; - change_resource(u, res, -n); - change_resource(u2, res, n); - } -#endif - number -= nf->number; - nf = nf->next; - free(friends); - friends = nf; - } - friends = NULL; - } - if (rterrain(r) != T_OCEAN && !!playerrace(u->race)) { - const race * rc = u->race; - int p = rpeasants(u->region); - int m = rmoney(u->region); - int h = rhorses(u->region); - - /* Personen gehen nur an die Bauern, wenn sie auch von dort - * stammen */ - if ((rc->ec_flags & ECF_REC_UNLIMITED)==0) { - if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */ - h += u->number; - } else if (rc == new_race[RC_URUK]){ /* Orks zählen nur zur Hälfte */ - p += u->number/2; - } else { - p += u->number; - } - } - m += get_money(u); - h += get_item(u, I_HORSE); - rsetpeasants(r, p); - rsethorses(r, h); - rsetmoney(r, m); - - } - set_number(u, 0); - } - f->alive = 0; -/* no way! f->units = NULL; */ - handle_event(&f->attribs, "destroy", f); - for (ff = factions; ff; ff = ff->next) { - group *g; - ally *sf, *sfn; - - /* Alle HELFE für die Partei löschen */ - for (sf = ff->allies; sf; sf = sf->next) { - if (sf->faction == f) { - removelist(&ff->allies, sf); - break; - } - } - for(g=ff->groups; g; g=g->next) { - for (sf = g->allies; sf;) { - sfn = sf->next; - if (sf->faction == f) { - removelist(&g->allies, sf); - break; - } - sf = sfn; - } - } - } - - /* units of other factions that were disguised as this faction - * have their disguise replaced by ordinary faction hiding. */ - for(rc=regions; rc; rc=rc->next) { - for(u=rc->units; u; u=u->next) { - attrib *a = a_find(u->attribs, &at_otherfaction); - if(!a) continue; - if (get_otherfaction(a) == f) { - a_removeall(&u->attribs, &at_otherfaction); - fset(u, FL_PARTEITARNUNG); - } - } - } -} - static void restart(unit *u, const race * rc) { diff --git a/src/common/gamecode/laws.h b/src/common/gamecode/laws.h index 216267d1d..18af73255 100644 --- a/src/common/gamecode/laws.h +++ b/src/common/gamecode/laws.h @@ -46,6 +46,4 @@ extern int count_migrants (const struct faction * f); extern attrib_type at_germs; #endif -extern void destroyfaction(struct faction * f); - #endif diff --git a/src/common/kernel/alliance.c b/src/common/kernel/alliance.c index 0aacacf7d..87d0530b6 100644 --- a/src/common/kernel/alliance.c +++ b/src/common/kernel/alliance.c @@ -23,9 +23,6 @@ #include #include -/* gamecode includes */ -#include /* for destroyfaction */ - /* util includes */ #include #include diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index edfd46a8c..6ab04d24d 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -19,9 +19,14 @@ #include "race.h" #include "region.h" #include "plane.h" +#include "item.h" +#include "group.h" /* util includes */ #include +#include + +#include /* libc includes */ #include @@ -145,3 +150,141 @@ checkpasswd(const faction * f, const char * passwd) if (strcasecmp(f->override, passwd)==0) return true; return false; } + +void +destroyfaction(faction * f) +{ + region *rc; + unit *u; + faction *ff; + + if( !f->alive ) return; + + for (u=f->units;u;u=u->nextF) { + region * r = u->region; + unit * au; + int number = 0; + struct friend { + struct friend * next; + int number; + faction * faction; + unit * unit; + } * friends = NULL; + for (au=r->units;au;au=au->next) if (au->faction!=f) { + if (alliedunit(u, au->faction, HELP_ALL)) { + struct friend * nf, ** fr = &friends; + + while (*fr && (*fr)->faction->nofaction->no) fr = &(*fr)->next; + nf = *fr; + if (nf==NULL || nf->faction!=au->faction) { + nf = calloc(sizeof(struct friend), 1); + nf->next = *fr; + nf->faction = au->faction; + nf->unit = au; + *fr = nf; + } + nf->number += au->number; + number += au->number; + } + } + if (friends && number) { + struct friend * nf = friends; + while (nf) { + unit * u2 = nf->unit; +#ifdef NEW_ITEMS + item * itm = u->items; + while(itm){ + const item_type * itype = itm->type; + item * itn = itm->next; + int n = itm->number; + n = n * nf->number / number; + if (n>0) { + i_change(&u->items, itype, -n); + i_change(&u2->items, itype, n); + } + itm = itn; + } +#else + resource_t res; + for (res = 0; res <= R_SILVER; ++res) { + int n = get_resource(u, res); + if (n<=0) continue; + n = n * nf->number / number; + if (n<=0) continue; + change_resource(u, res, -n); + change_resource(u2, res, n); + } +#endif + number -= nf->number; + nf = nf->next; + free(friends); + friends = nf; + } + friends = NULL; + } + if (rterrain(r) != T_OCEAN && !!playerrace(u->race)) { + const race * rc = u->race; + int p = rpeasants(u->region); + int m = rmoney(u->region); + int h = rhorses(u->region); + + /* Personen gehen nur an die Bauern, wenn sie auch von dort + * stammen */ + if ((rc->ec_flags & ECF_REC_UNLIMITED)==0) { + if (rc->ec_flags & ECF_REC_HORSES) { /* Zentauren an die Pferde */ + h += u->number; + } else if (rc == new_race[RC_URUK]){ /* Orks zählen nur zur Hälfte */ + p += u->number/2; + } else { + p += u->number; + } + } + m += get_money(u); + h += get_item(u, I_HORSE); + rsetpeasants(r, p); + rsethorses(r, h); + rsetmoney(r, m); + + } + set_number(u, 0); + } + f->alive = 0; +/* no way! f->units = NULL; */ + handle_event(&f->attribs, "destroy", f); + for (ff = factions; ff; ff = ff->next) { + group *g; + ally *sf, *sfn; + + /* Alle HELFE für die Partei löschen */ + for (sf = ff->allies; sf; sf = sf->next) { + if (sf->faction == f) { + removelist(&ff->allies, sf); + break; + } + } + for(g=ff->groups; g; g=g->next) { + for (sf = g->allies; sf;) { + sfn = sf->next; + if (sf->faction == f) { + removelist(&g->allies, sf); + break; + } + sf = sfn; + } + } + } + + /* units of other factions that were disguised as this faction + * have their disguise replaced by ordinary faction hiding. */ + for(rc=regions; rc; rc=rc->next) { + for(u=rc->units; u; u=u->next) { + attrib *a = a_find(u->attribs, &at_otherfaction); + if(!a) continue; + if (get_otherfaction(a) == f) { + a_removeall(&u->attribs, &at_otherfaction); + fset(u, FL_PARTEITARNUNG); + } + } + } +} + diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index 84e603a27..da1f60e7b 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -85,5 +85,6 @@ extern const char * factionname(const struct faction * f); extern void * resolve_faction(void * data); extern struct unit * addplayer(struct region *r, const char *email, const char* password, const struct race * frace, const struct locale *loc); extern boolean checkpasswd(const faction * f, const char * passwd); +extern void destroyfaction(faction * f); #endif diff --git a/src/common/modules/alliance.c b/src/common/modules/alliance.c index 0aacacf7d..87d0530b6 100644 --- a/src/common/modules/alliance.c +++ b/src/common/modules/alliance.c @@ -23,9 +23,6 @@ #include #include -/* gamecode includes */ -#include /* for destroyfaction */ - /* util includes */ #include #include diff --git a/src/corwin.mk b/src/corwin.mk index 49d389cab..91d9a78e4 100644 --- a/src/corwin.mk +++ b/src/corwin.mk @@ -4,12 +4,12 @@ ifndef ERESSEA endif # Hier definieren, damit nicht '@gcc' -CC = gcc-3.0 -D_GNU_SOURCE -ansi -pedantic -DEPEND = @gcc-3.0 -MM -MG -r +CC = gcc-3.2 -D_GNU_SOURCE -ansi -pedantic +DEPEND = @gcc-3.2 -MM -MG -r # CC = gcc -D_GNU_SOURCE AR = ar CTAGS = ctags-exuberant -LD = gcc-3.0 +LD = gcc-3.2 INSTALL = cp CFLAGS += -march=athlon -minline-all-stringops diff --git a/src/mapper/Makefile b/src/mapper/Makefile index fa3057027..4d64a09c4 100644 --- a/src/mapper/Makefile +++ b/src/mapper/Makefile @@ -19,14 +19,13 @@ INCLUDES += \ LIBNAMES += \ e-triggers \ - e-modules \ e-kernel \ e-items \ e-spells \ e-races \ e-attributes \ - e-util \ - e-modules + e-modules \ + e-util LIBS += \ -L$(PUBLISH_DIR) \