From 4e54590d98e2ed05e8216c569c1190bac38f240a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 2 Sep 2002 20:36:12 +0000 Subject: [PATCH] Vinyambar 3 implementation --- src/common/attributes/gm.h | 2 - src/common/gamecode/creport.c | 50 ++- src/common/gamecode/economy.c | 110 +++--- src/common/gamecode/economy.h | 3 - src/common/gamecode/gamecode.dsp | 2 +- src/common/gamecode/laws.c | 46 ++- src/common/gamecode/laws.h | 2 + src/common/gamecode/randenc.c | 2 +- src/common/gamecode/report.c | 49 ++- src/common/gamecode/study.c | 2 +- src/common/kernel/alliance.c | 169 ++++++++-- src/common/kernel/alliance.h | 6 + src/common/kernel/battle.c | 58 +--- src/common/kernel/border.c | 15 +- src/common/kernel/build.c | 8 +- src/common/kernel/building.c | 2 +- src/common/kernel/eressea.c | 117 +++---- src/common/kernel/eressea.h | 60 ++-- src/common/kernel/faction.c | 4 +- src/common/kernel/group.c | 8 +- src/common/kernel/item.c | 4 +- src/common/kernel/karma.c | 2 +- src/common/kernel/kernel.dsp | 2 +- src/common/kernel/magic.c | 4 +- src/common/kernel/movement.c | 14 +- src/common/kernel/plane.h | 2 - src/common/kernel/pool.c | 4 +- src/common/kernel/race.c | 2 +- src/common/kernel/region.c | 2 +- src/common/kernel/reports.c | 22 +- src/common/kernel/save.c | 429 +++++++----------------- src/common/kernel/ship.c | 2 +- src/common/kernel/spell.c | 32 +- src/common/kernel/unit.c | 6 +- src/common/kernel/unit.h | 2 - src/common/modules/alliance.c | 169 ++++++++-- src/common/modules/alliance.h | 6 + src/common/modules/gmcmd.c | 78 ++--- src/common/modules/infocmd.c | 70 ++-- src/common/modules/museum.c | 10 +- src/common/modules/museum.h | 8 +- src/common/settings-eressea.h | 47 +-- src/common/settings-tutorial.h | 1 - src/common/settings-vinyambar-3.h | 47 +++ src/common/settings-vinyambar-classic.h | 1 - src/common/settings-vinyambar-murder.h | 1 - src/common/settings-vinyambar.h | 1 - src/common/spells/buildingcurse.c | 2 +- src/common/spells/regioncurse.c | 10 +- src/common/spells/shipcurse.c | 4 +- src/common/util/base36.c | 19 +- src/common/util/command.c | 48 ++- src/common/util/command.h | 20 +- src/common/util/language.c | 12 +- src/common/util/language.h | 10 +- src/eressea/korrektur.c | 117 +++---- src/eressea/main.c | 12 +- src/mapper/map_units.c | 18 - src/mapper/mapper.c | 17 +- src/res/buildings.xml | 3 - src/res/de/messages.xml | 24 ++ src/res/de/strings.xml | 19 +- src/res/en/strings.xml | 3 - src/res/eressea.xml | 1 + src/res/eressea/temple.xml | 10 + src/res/vinyambar-3.xml | 23 ++ src/res/vinyambar/de/strings.xml | 7 +- src/res/vinyambar/stronghold.xml | 15 + 68 files changed, 1133 insertions(+), 944 deletions(-) create mode 100644 src/common/settings-vinyambar-3.h create mode 100644 src/res/eressea/temple.xml create mode 100644 src/res/vinyambar-3.xml create mode 100644 src/res/vinyambar/stronghold.xml diff --git a/src/common/attributes/gm.h b/src/common/attributes/gm.h index bf118ed84..030375bbc 100644 --- a/src/common/attributes/gm.h +++ b/src/common/attributes/gm.h @@ -12,8 +12,6 @@ * prior permission by the authors of Eressea. */ -/* this is an attribute used by the kernel (isallied) */ - struct plane; extern struct attrib_type at_gm; diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 6b92cbf15..e04154b86 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -22,6 +22,9 @@ /* modules include */ #include +#ifdef ALLIANCES +#include +#endif /* attributes include */ #include @@ -83,7 +86,7 @@ extern int quiet; static const char * crtag(const char * key) { - static const locale * lang = NULL; + static const struct locale * lang = NULL; if (!lang) lang = find_locale(TAG_LOCALE); return locale_string(lang, key); } @@ -347,6 +350,19 @@ cr_race(const void * v, char * buffer, const void * userdata) return 0; } +#ifdef ALLIANCES +static int +cr_alliance(const void * v, char * buffer, const void * userdata) +{ + const alliance * al = (const alliance *)v; + if (al!=NULL) { + sprintf(buffer, "%d", al->id); + } + unused(userdata); + return 0; +} +#endif + static int cr_skill(const void * v, char * buffer, const void * userdata) { @@ -373,6 +389,9 @@ creport_init(void) tsf_register("resource", &cr_resource); tsf_register("race", &cr_race); tsf_register("direction", &cr_int); +#ifdef ALLIANCES + tsf_register("alliance", &cr_alliance); +#endif } void @@ -709,11 +728,13 @@ cr_output_unit(FILE * F, const region * r, if (spt) { spell *sp; int i; + int t = effskill(u, SK_MAGIC); fprintf(F, "SPRUECHE\n"); for (;spt; spt = spt->next) { sp = find_spellbyid(spt->spellid); if (sp) { const char * name = sp->sname; + if (sp->level > t) continue; if (sp->info==NULL) { name = add_translation(mkname("spell", name), spell_name(sp, f->locale)); } @@ -789,12 +810,15 @@ cr_output_unit(FILE * F, const region * r, /* prints allies */ static void -show_allies(FILE * F, ally * sf) +show_allies(FILE * F, const faction * f, const ally * sf) { - for (; sf; sf = sf->next) if(sf->faction) { - fprintf(F, "ALLIANZ %d\n", sf->faction->no); - fprintf(F, "\"%s\";Parteiname\n", sf->faction->name); - fprintf(F, "%d;Status\n", sf->status); + for (; sf; sf = sf->next) if (sf->faction) { + int mode = alliedfaction(NULL, f, sf->faction, HELP_ALL); + if (mode!=0) { + fprintf(F, "ALLIANZ %d\n", sf->faction->no); + fprintf(F, "\"%s\";Parteiname\n", sf->faction->name); + fprintf(F, "%d;Status\n", mode); + } } } /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ @@ -827,6 +851,12 @@ cr_find_address(FILE * F, const faction * uf, const faction_list * addresses) fprintf(F, "\"%s\";Parteiname\n", f->name); fprintf(F, "\"%s\";email\n", f->email); fprintf(F, "\"%s\";banner\n", f->banner); +#ifdef ALLIANCES + if (f->alliance!=NULL) { + fprintf(F, "%d;alliance\n", f->alliance->id); + fprintf(F, "\"%s\";alliancename\n", f->alliance->name); + } +#endif } flist = flist->next; } @@ -889,7 +919,7 @@ encode_region(const faction * f, const region * r) { } static char * -report_resource(char * buf, const char * name, const locale * loc, int amount, int level) +report_resource(char * buf, const char * name, const struct locale * loc, int amount, int level) { buf += sprintf(buf, "RESOURCE %u\n", hashstring(name)); buf += sprintf(buf, "\"%s\";type\n", add_translation(name, LOC(loc, name))); @@ -970,7 +1000,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen, fprintf(F, "VERSION %d\n", C_REPORT_VERSION); fprintf(F, "\"%s\";locale\n", locale_name(f->locale)); - fprintf(F, "%d;noskillpoints\n", !SKILLPOINTS); + fprintf(F, "%d;noskillpoints\n", 1); fprintf(F, "%ld;date\n", report_time); fprintf(F, "\"%s\";Spiel\n", global.gamename); fprintf(F, "\"%s\";Konfiguration\n", "Standard"); @@ -1009,7 +1039,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen, for (i=0;i!=MAXOPTIONS;++i) { fprintf(F, "%d;%s\n", (f->options&want(i))?1:0, options[i]); } - show_allies(F, f->allies); + show_allies(F, f, f->allies); { group * g; for (g=f->groups;g;g=g->next) { @@ -1021,7 +1051,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen, const char * name = (const char*)a->data.v; fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name))); } - show_allies(F, g->allies); + show_allies(F, f, g->allies); } } diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index eb8ad362c..b4cbdbb7d 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -273,8 +273,8 @@ expandrecruit(region * r, request * recruitorders) if (rc->ec_flags & ECF_REC_HORSES) { /* recruit from horses if not all gone */ if (h <= 0) continue; - } else if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) { - /* recruit from peasants if any space left */ + } else { + /* recruit, watch peasants if any space left */ if (n - (uruks+1)/2 >= rfrac) continue; } } @@ -287,7 +287,7 @@ expandrecruit(region * r, request * recruitorders) else { if ((rc->ec_flags & ECF_REC_ETHEREAL)==0) { p--; /* use a peasant */ - if(rc == new_race[RC_URUK]) uruks++; + if (rc == new_race[RC_URUK]) uruks++; } n++; } @@ -467,7 +467,7 @@ recruit(region * r, unit * u, strlist * S, } /* ------------------------------------------------------------- */ - int +int count_max_migrants(faction * f) { int x = (int)(log10(count_all(f) / 50.0) * 20); @@ -476,7 +476,7 @@ count_max_migrants(faction * f) extern const char* resname(resource_t res, int i); - void +void add_give(unit * u, unit * u2, int n, const resource_type * rtype, const char * cmd, int error) { if (error) @@ -494,7 +494,7 @@ add_give(unit * u, unit * u2, int n, const resource_type * rtype, const char * c } } - void +void addgive(unit * u, unit * u2, int n, resource_t res, const char * cmd, int error) { add_give(u, u2, n, oldresourcetype[res], cmd, error); @@ -549,7 +549,7 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, const char #endif handle_event(&src->attribs, "give", dest); handle_event(&dest->attribs, "receive", src); -#if defined(MUSEUM_PLANE) && defined(TODO) +#if defined(MUSEUM_MODULE) && defined(TODO) TODO: Einen Trigger benutzen! if (a_find(dest->attribs, &at_warden)) { /* warden_add_give(src, dest, itype, n); */ @@ -565,7 +565,7 @@ TODO: Einen Trigger benutzen! return 0; } - void +void givemen(int n, unit * u, unit * u2, const char * cmd) { ship *sh; @@ -678,7 +678,7 @@ givemen(int n, unit * u, unit * u2, const char * cmd) addgive(u, u2, n, R_PERSON, cmd, error); } - void +void giveunit(region * r, unit * u, unit * u2, strlist * S) { int n = u->number; @@ -1049,7 +1049,7 @@ dogive(region * r, unit * u, strlist * S, boolean liefere, int mode) cmistake(u, S->s, 123, MSG_COMMERCE); } /* ------------------------------------------------------------- */ - void +void forgetskill(unit * u) { skill_t talent; @@ -1067,7 +1067,7 @@ forgetskill(unit * u) /* ------------------------------------------------------------- */ - void +void report_donations(void) { spende * sp; @@ -1083,7 +1083,7 @@ report_donations(void) } } - void +void add_spende(faction * f1, faction * f2, int betrag, region * r) { spende *sp; @@ -1107,7 +1107,7 @@ add_spende(faction * f1, faction * f2, int betrag, region * r) spenden = sp; } - static boolean +static boolean maintain(building * b, boolean first) /* first==false -> take money from wherever you can */ { @@ -1140,7 +1140,7 @@ maintain(building * b, boolean first) for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH); fset(u->faction, FL_DH); /* hat schon */ for (ua=r->units;ua;ua=ua->next) { - if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || allied(ua, u->faction, HELP_MONEY))) { + if (!fval(ua->faction, FL_DH) && (ua->faction == u->faction || alliedunit(ua, u->faction, HELP_MONEY))) { need -= new_get_pooled(ua, oldresourcetype[m->type], GET_SLACK|GET_RESERVE|GET_POOLED_SLACK|GET_POOLED_RESERVE|GET_POOLED_FORCE); fset(ua->faction, FL_DH); if (need<=0) break; @@ -1183,7 +1183,7 @@ maintain(building * b, boolean first) for (ua=r->units;ua;ua=ua->next) freset(ua->faction, FL_DH); fset(u->faction, FL_DH); /* hat schon */ for (ua=r->units;ua;ua=ua->next) { - if (!fval(ua->faction, FL_DH) && allied(ua, u->faction, HELP_MONEY)) { + if (!fval(ua->faction, FL_DH) && alliedunit(ua, u->faction, HELP_MONEY)) { int give = use_all(ua, m->type, cost); if (!give) continue; cost -= give; @@ -1204,7 +1204,7 @@ maintain(building * b, boolean first) return true; } - static void +static void gebaeude_stuerzt_ein(region * r, building * b) { unit *u; @@ -1258,7 +1258,7 @@ gebaeude_stuerzt_ein(region * r, building * b) destroy_building(b); } - void +void maintain_buildings(boolean crash) { region * r; @@ -1433,7 +1433,7 @@ typedef struct allocation_list { static allocation_list * allocations; - static void +static void allocate_resource(unit * u, const resource_type * rtype, int want) { const item_type * itype = resource2item(rtype); @@ -1479,7 +1479,7 @@ allocate_resource(unit * u, const resource_type * rtype, int want) && cansee(u2->faction,r,u,0) && !ucontact(u2, u) && !besieged(u2) - && !allied(u2, u->faction, HELP_GUARD) + && !alliedunit(u2, u->faction, HELP_GUARD) #ifdef WACH_WAFF && armedmen(u2) #endif @@ -1502,7 +1502,7 @@ allocate_resource(unit * u, const resource_type * rtype, int want) && !fval(u2, UFL_ISNEW) && u2->number && !ucontact(u2, u) - && !allied(u2, u->faction, HELP_GUARD)) + && !alliedunit(u2, u->faction, HELP_GUARD)) { add_message(&u->faction->msgs, msg_error(u, findorder(u, u->thisorder), "region_guarded", "guard", u2)); @@ -1617,7 +1617,7 @@ typedef struct allocator { static struct allocator * allocators; - static const allocator * +static const allocator * get_allocator(const struct resource_type * type) { const struct allocator * alloc = allocators; @@ -1625,7 +1625,7 @@ get_allocator(const struct resource_type * type) return alloc; } - static allocator * +static allocator * make_allocator(const struct resource_type * type, void (*allocate)(const struct allocator *, region *, allocation *)) { allocator * alloc = (allocator *)malloc(sizeof(allocator)); @@ -1634,7 +1634,7 @@ make_allocator(const struct resource_type * type, void (*allocate)(const struct return alloc; } - static void +static void add_allocator(allocator * alloc) { alloc->next = allocators; @@ -1646,7 +1646,7 @@ enum { AFL_LOWSKILL = 1<<1 }; - static int +static int required(int want, double save) { int norders = (int)(want * save); @@ -1655,7 +1655,7 @@ required(int want, double save) } #if NEW_RESOURCEGROWTH - static void +static void leveled_allocation(const allocator * self, region * r, allocation * alist) { const resource_type * rtype = self->type; @@ -1715,7 +1715,7 @@ leveled_allocation(const allocator * self, region * r, allocation * alist) } #endif - static void +static void attrib_allocation(const allocator * self, region * r, allocation * alist) { allocation * al; @@ -1755,7 +1755,7 @@ attrib_allocation(const allocator * self, region * r, allocation * alist) assert(avail==0 || norders==0); } - static void +static void split_allocations(region * r) { allocation_list ** p_alist=&allocations; @@ -1799,7 +1799,7 @@ split_allocations(region * r) allocations = NULL; } - static void +static void create_potion(unit * u, const potion_type * ptype, int want) { int built; @@ -1866,7 +1866,7 @@ create_item(unit * u, const item_type * itype, int want) } } - static void +static void make(region * r, unit * u) { char *s; @@ -1953,7 +1953,7 @@ const attrib_type at_luxuries = { "luxuries", NULL, NULL, NULL, NULL, NULL }; - static void +static void expandbuying(region * r, request * buyorders) { int max_products; @@ -2061,7 +2061,7 @@ attrib_type at_trades = { NO_READ }; - void +void buy(region * r, unit * u, request ** buyorders, const char * cmd) { int n, k; @@ -2156,7 +2156,7 @@ buy(region * r, unit * u, request ** buyorders, const char * cmd) static int tax_per_size[7] = {0, 6, 12, 18, 24, 30, 36}; - static void +static void expandselling(region * r, request * sellorders) { int money, price, j, max_products; @@ -2329,7 +2329,7 @@ expandselling(region * r, request * sellorders) } } - void +void sell(region * r, unit * u, request ** sellorders, const char * cmd) { const item_type * itype; @@ -2454,7 +2454,7 @@ sell(region * r, unit * u, request ** sellorders, const char * cmd) } /* ------------------------------------------------------------- */ - static void +static void expandstealing(region * r, request * stealorders) { int i; @@ -2499,7 +2499,7 @@ expandstealing(region * r, request * stealorders) } /* ------------------------------------------------------------- */ - void +void plant(region *r, unit *u, int raw) { int n, i, skill, planted = 0; @@ -2555,7 +2555,7 @@ plant(region *r, unit *u, int raw) } #if GROWING_TREES - static void +static void planttrees(region *r, unit *u, int raw) { int n, i, skill, planted = 0; @@ -2615,7 +2615,7 @@ planttrees(region *r, unit *u, int raw) } /* züchte bäume */ - void +void breedtrees(region *r, unit *u, int raw) { int n, i, skill, planted = 0; @@ -2674,7 +2674,7 @@ breedtrees(region *r, unit *u, int raw) #endif - void +void pflanze(region *r, unit *u) { int m; @@ -2720,7 +2720,7 @@ pflanze(region *r, unit *u) /* züchte pferde */ - void +void breedhorses(region *r, unit *u) { int n, c; @@ -2753,7 +2753,7 @@ breedhorses(region *r, unit *u) "raised%u:unit%i:amount", u, gezuechtet)); } - void +void zuechte(region *r, unit *u) { int m; @@ -2792,7 +2792,7 @@ zuechte(region *r, unit *u) } } - static const char * +static const char * rough_amount(int a, int m) { @@ -2810,7 +2810,7 @@ rough_amount(int a, int m) return "sehr viele"; } - static void +static void research(region *r, unit *u) { char *s; @@ -2844,7 +2844,7 @@ research(region *r, unit *u) } } - int +int wahrnehmung(region * r, faction * f) { unit *u; @@ -2853,7 +2853,7 @@ wahrnehmung(region * r, faction * f) for (u = r->units; u; u = u->next) { if (u->faction == f #ifdef HELFE_WAHRNEHMUNG - || allied(u, f, HELP_OBSERVE) + || alliedunit(u, f, HELP_OBSERVE) #endif ) { if (eff_skill(u, SK_OBSERVATION, r) > w) { @@ -2865,7 +2865,7 @@ wahrnehmung(region * r, faction * f) return w; } - void +void steal(region * r, unit * u, request ** stealorders) { int n, i, id; @@ -2973,7 +2973,7 @@ steal(region * r, unit * u, request ** stealorders) /* ------------------------------------------------------------- */ - int +int entertainmoney(const region *r) { int n; @@ -2991,7 +2991,7 @@ entertainmoney(const region *r) return n; } - static void +static void expandentertainment(region * r) { unit *u; @@ -3016,7 +3016,7 @@ expandentertainment(region * r) } } - void +void entertain(region * r, unit * u) { int max_e; @@ -3044,7 +3044,7 @@ entertain(region * r, unit * u) return; } - u->wants = u->number * effskill(u, SK_ENTERTAINMENT) * ENTERTAININCOME; + u->wants = u->number * (ENTERTAINBASE + effskill(u, SK_ENTERTAINMENT) * ENTERTAINPERLEVEL); if ((max_e = geti()) != 0) u->wants = min(u->wants,max_e); @@ -3057,7 +3057,7 @@ entertain(region * r, unit * u) /* ------------------------------------------------------------- */ - static void +static void expandwork(region * r) { int n, earnings; @@ -3113,7 +3113,7 @@ expandwork(region * r) rsetmoney(r, rmoney(r) + earnings); } - void +void work(region * r, unit * u) { request *o; @@ -3140,7 +3140,7 @@ work(region * r, unit * u) } /* ------------------------------------------------------------- */ - static void +static void expandtax(region * r, request * taxorders) { unit *u; @@ -3161,7 +3161,7 @@ expandtax(region * r, request * taxorders) add_income(u, IC_TAX, u->wants, u->n); } - void +void tax(region * r, unit * u, request ** taxorders) { /* Steuern werden noch vor der Forschung eingetrieben */ @@ -3217,7 +3217,7 @@ tax(region * r, unit * u, request ** taxorders) } /* ------------------------------------------------------------- */ - void +void produce(void) { region *r; @@ -3372,7 +3372,7 @@ produce(void) } } - void +void init_economy(void) { add_allocator(make_allocator(item2resource(olditemtype[I_HORSE]), attrib_allocation)); diff --git a/src/common/gamecode/economy.h b/src/common/gamecode/economy.h index 7d9496770..ed36e390a 100644 --- a/src/common/gamecode/economy.h +++ b/src/common/gamecode/economy.h @@ -25,9 +25,6 @@ /* Welchen Teil des Silbers die Bauern fuer Unterhaltung ausgeben (1/20), und * wiviel Silber ein Unterhalter pro Talentpunkt bekommt. */ -#define ENTERTAININCOME 20 -#define ENTERTAINFRACTION 20 - /* Wieviele Silbermuenzen jeweils auf einmal "getaxed" werden. */ #define TAXFRACTION 10 diff --git a/src/common/gamecode/gamecode.dsp b/src/common/gamecode/gamecode.dsp index 25a3c250a..f11f54dcb 100644 --- a/src/common/gamecode/gamecode.dsp +++ b/src/common/gamecode/gamecode.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /Za /W4 /GX /Z7 /O2 /I "../util" /I "../kernel" /I "../.." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /Za /W4 /GX /Z7 /O2 /I "../kernel" /I "../util" /I "../.." /I ".." /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE RSC /l 0x407 # ADD RSC /l 0x407 BSC32=bscmake.exe diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 437572866..7f69e6400 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -74,6 +74,9 @@ #include #include +#ifdef ALLIANCES +#include +#endif #ifdef AT_OPTION /* attributes includes */ @@ -98,7 +101,7 @@ extern int * age; boolean nobattle = false; /* ------------------------------------------------------------- */ -static void +void destroyfaction(faction * f) { region *rc; @@ -118,7 +121,7 @@ destroyfaction(faction * f) unit * unit; } * friends = NULL; for (au=r->units;au;au=au->next) if (au->faction!=f) { - if (allied(u, au->faction, HELP_ALL)) { + if (alliedunit(u, au->faction, HELP_ALL)) { struct friend * nf, ** fr = &friends; while (*fr && (*fr)->faction->nofaction->no) fr = &(*fr)->next; @@ -327,7 +330,7 @@ get_food(region *r) unit *v; for (v = r->units; need && v; v = v->next) - if (v->faction != u->faction && allied(v, u->faction, HELP_MONEY) + if (v->faction != u->faction && alliedunit(v, u->faction, HELP_MONEY) && !is_monstrous(v)) { int give = lifestyle(v); give = max(0, get_money(v) - give); @@ -1222,21 +1225,30 @@ quit(void) continue; } } -#if REMOVENMRNEWBIE puts(" - beseitige Spieler, die sich nach der Anmeldung nicht " "gemeldet haben..."); age = calloc(turn+1, sizeof(int)); - for (f = factions; f; f = f->next) if(!fval(f, FL_NOIDLEOUT)) { - if (f->age>=0 && f->age <= turn) ++age[f->age]; - if (f->age == 2 || f->age == 3) { - if (f->lastorders == turn - 2) { - destroyfaction(f); - ++dropouts[f->age-2]; + for (f = factions; f; f = f->next) if (f->no != MONSTER_FACTION) { +#if REMOVENMRNEWBIE + if(!fval(f, FL_NOIDLEOUT) && f!=) { + if (f->age>=0 && f->age <= turn) ++age[f->age]; + if (f->age == 2 || f->age == 3) { + if (f->lastorders == turn - 2) { + destroyfaction(f); + ++dropouts[f->age-2]; + continue; + } } } - } #endif +#if defined(ALLIANCES) && !defined(ALLIANCEJOIN) + if (f->alliance==NULL) { + destroyfaction(f); + continue; + } +#endif + } /* Clear away debris of destroyed factions */ puts(" - beseitige leere Einheiten und leere Parteien..."); @@ -3506,7 +3518,9 @@ processorders (void) puts(" - Defaults und Instant-Befehle..."); setdefaults(); instant_orders(); - +#ifdef ALLIANCES + alliancekick(); +#endif mail(); puts(" - Altern"); age_factions(); @@ -3517,6 +3531,11 @@ processorders (void) puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)"); do_misc(0); +#ifdef ALLIANCES + puts(" - Testen der Allianzbedingungen"); + alliancevictory(); +#endif + puts(" - GM Kommandos"); infocommands(); gmcommands(); @@ -3628,6 +3647,9 @@ processorders (void) #if 0 puts(" - Einheiten aus Gebäuden/Schiffen weisen"); evict(); +#endif +#ifdef ALLIANCEJOIN + alliancejoin(); #endif puts(" - Neue Nummern"); renumber(); diff --git a/src/common/gamecode/laws.h b/src/common/gamecode/laws.h index 18af73255..216267d1d 100644 --- a/src/common/gamecode/laws.h +++ b/src/common/gamecode/laws.h @@ -46,4 +46,6 @@ 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/gamecode/randenc.c b/src/common/gamecode/randenc.c index 36e4d7acf..1643a5d2b 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -1027,7 +1027,7 @@ godcurse(void) } } - if(rterrain(r) == T_OCEAN) { + if (rterrain(r) == T_OCEAN) { for (sh = r->ships; sh;) { shn = sh->next; damage_ship(sh, 0.10); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 2b3458ef3..abef6a749 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -20,6 +20,9 @@ /* modules includes */ #include +#ifdef ALLIANCES +#include +#endif /* attributes includes */ #include @@ -577,11 +580,11 @@ nmr_warnings(void) { faction *f,*fa; - +#define FRIEND (HELP_GUARD|HELP_MONEY) for(f=factions;f;f=f->next) { if(f->no != MONSTER_FACTION && (turn-f->lastorders) >= 2) { for(fa=factions;fa;fa=fa->next) { - if(isallied(NULL, f, fa, HELP_GUARD | HELP_MONEY) && isallied(NULL, fa,f,HELP_GUARD | HELP_MONEY)) { + if (alliedfaction(NULL, f, fa, FRIEND) && alliedfaction(NULL, fa, f, FRIEND)) { sprintf(buf, "Achtung: %s hat einige Zeit keine " "Züge eingeschickt und könnte dadurch in Kürze aus dem " "Spiel ausscheiden.", factionname(f)); @@ -1023,7 +1026,7 @@ see_border(const border * b, const faction * f, const region * r) } const char * -trailinto(const region * r, const locale * lang) +trailinto(const region * r, const struct locale * lang) { char ref[32]; const char * s; @@ -1049,8 +1052,8 @@ static void eval_trail(struct opstack ** stack, const void * userdata) /* (int, int) -> int */ { const struct faction * f = (const struct faction *)userdata; - locale * lang = opop(stack, locale*); - region * r = opop(stack, region*); + const struct locale * lang = opop(stack, const struct locale*); + const struct region * r = opop(stack, const struct region*); const char * trail = trailinto(r, lang); const char * rn = regionname(r, f); char * x = balloc(strlen(trail)+strlen(rn)); @@ -1630,20 +1633,20 @@ order_template(FILE * F, faction * f) } static void -alliances(ally * sf) +report_alliances(const faction * f, const ally * sf) { int allierte = 0; int i=0, h, hh = 0; int dh = 0; - ally * sff; + const ally * sff; for (sff = sf; sff; sff = sff->next) { - if (sff->status > 0 && sff->status <= HELP_ALL) { + if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sff->status > 0 && sff->status <= HELP_ALL) { allierte++; } } while (sf) { - if (sf->status > 0) { + if (alliedfaction(NULL, f, sf->faction, HELP_ALL) && sf->status > 0) { i++; if (dh) { if (i == allierte) @@ -1713,7 +1716,7 @@ allies(FILE * F, faction * f) } else { strcpy(buf, "Wir helfen den Parteien "); } - alliances(f->allies); + report_alliances(f, f->allies); scat("."); rparagraph(F, buf, 0, 0); rnl(F); @@ -1726,7 +1729,7 @@ allies(FILE * F, faction * f) } else { sprintf(buf, "%s hilft den Parteien ", g->name); } - alliances(g->allies); + report_alliances(f, g->allies); scat("."); rparagraph(F, buf, 0, 0); rnl(F); @@ -1822,7 +1825,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f int i; unit *u; attrib * a = a_find(b->attribs, &at_icastle); - const locale * lang = NULL; + const struct locale * lang = NULL; const building_type * type = b->type; if (f) lang = f->locale; @@ -1920,6 +1923,11 @@ report(FILE *F, faction * f, const faction_list * addresses, LOC(f->locale, rc_name(f->race, 1)), neue_gebiete[f->magiegebiet], f->email); centre(F, buf, true); +#ifdef ALLIANCES + if (f->alliance!=NULL) { + centre(F, alliancename(f->alliance), true); + } +#endif buf[0] = 0; dh = 0; @@ -3748,6 +3756,20 @@ eval_faction(struct opstack ** stack, const void * userdata) /* faction -> strin opush(stack, strcpy(balloc(len+1), c)); } +#ifdef ALLIANCES +static void +eval_alliance(struct opstack ** stack, const void * userdata) /* faction -> string */ +{ + const struct alliance * al = opop(stack, const struct alliance *); + const char * c = alliancename(al); + if (c!=NULL) { + size_t len = strlen(c); + opush(stack, strcpy(balloc(len+1), c)); + } + else opush(stack, NULL); +} +#endif + static void eval_region(struct opstack ** stack, const void * userdata) /* region -> string */ { @@ -3829,6 +3851,9 @@ eval_int36(struct opstack ** stack, const void * userdata) void report_init(void) { +#ifdef ALLIANCES + add_function("alliance", &eval_alliance); +#endif add_function("region", &eval_region); add_function("resource", &eval_resource); add_function("race", &eval_race); diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 4ff572be0..0dfca2847 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -300,7 +300,7 @@ teach(region * r, unit * u) } #if TEACH_FRIENDS while (teaching && student) { - if (student->faction != u->faction && !fval(student, FL_HUNGER) && allied(u, student->faction, HELP_GUARD)) { + if (student->faction != u->faction && !fval(student, FL_HUNGER) && alliedunit(u, student->faction, HELP_GUARD)) { if (igetkeyword(student->thisorder, student->faction->locale) == K_STUDY) { /* Input ist nun von student->thisorder !! */ sk = getskill(student->faction->locale); diff --git a/src/common/kernel/alliance.c b/src/common/kernel/alliance.c index c5636ee94..194b28ec7 100644 --- a/src/common/kernel/alliance.c +++ b/src/common/kernel/alliance.c @@ -16,13 +16,18 @@ #include "command.h" /* kernel includes */ +#include #include #include #include #include +/* gamecode includes */ +#include /* for destroyfaction */ + /* util includes */ #include +#include /* libc includes */ #include @@ -79,11 +84,12 @@ add_kick(attrib * a, const faction * f) } static void -alliance_kick(const char * str, void * data, const char * cmd) +alliance_kick(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; faction * f = findfaction(atoi36(igetstrtoken(str))); attrib * a; + unused(tnext); if (f==NULL || f->alliance!=u->faction->alliance) { /* does not belong to our alliance */ @@ -95,11 +101,12 @@ alliance_kick(const char * str, void * data, const char * cmd) } static void -alliance_join(const char * str, void * data, const char * cmd) +alliance_join(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; alliance * al = findalliance(atoi36(igetstrtoken(str))); - + unused(tnext); + if (u->faction->alliance!=NULL || al==NULL) { /* not found */ return; @@ -108,15 +115,8 @@ alliance_join(const char * str, void * data, const char * cmd) /* inform the rest? */ } -static tnode * g_keys; static void -alliance_command(const char * str, void * data, const char * cmd) -{ - do_command(g_keys, data, str); -} - -static void -execute(tnode * root) +execute(const struct syntaxtree * syntax) { region ** rp = ®ions; while (*rp) { @@ -124,9 +124,11 @@ execute(tnode * root) unit **up = &r->units; while (*up) { unit * u = *up; + const struct locale * lang = u->faction->locale; + tnode * root = stree_find(syntax, lang); strlist * order; for (order = u->orders; order; order = order->next) { - if (igetkeyword(order->s, u->faction->locale) == K_ALLIANCE) { + if (igetkeyword(order->s, lang) == K_ALLIANCE) { do_command(root, u, order->s); } } @@ -137,24 +139,139 @@ execute(tnode * root) } void -alliancejoin(void) +alliancekick(void) { - tnode root; - add_command(&root, "alliance", &alliance_command); - g_keys = calloc(1, sizeof(tnode)); - add_command(g_keys, "join", &alliance_join); - execute(&root); - free(g_keys); + static syntaxtree * stree = NULL; + faction * f = factions; + if (stree==NULL) { + syntaxtree * slang = stree = stree_create(); + while (slang) { + struct tnode * root = calloc(sizeof(tnode), 1); + struct tnode * leaf = calloc(sizeof(tnode), 1); + add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); + add_command(leaf, NULL, LOC(slang->lang, "kick"), &alliance_kick); + slang = slang->next; + } + } + execute(stree); + while (f) { + attrib * a = a_find(f->attribs, &at_kick); + if (a!=NULL) { + faction_list * flist = (faction_list*)a->data.v; + if (flist!=NULL) { + unsigned int votes = listlen(flist); + unsigned int size = listlen(f->alliance->members); + if (size<=votes*2) { + f->alliance = NULL; + /* tell him he's been kicked */ + for (flist=f->alliance->members;flist;flist=flist->next) { + ADDMSG(&flist->data->msgs, msg_message("alliance::kickedout", + "member alliance votes", f, f->alliance, votes)); + } + } else { + /* warn that he's been attempted to kick */ + for (flist=f->alliance->members;flist;flist=flist->next) { + ADDMSG(&flist->data->msgs, msg_message("alliance::kickattempt", + "member alliance votes", f, f->alliance, votes)); + } + } + } + } + f = f->next; + } + /* some may have been kicked, must remove f->alliance==NULL */ } void -alliancekick(void) +alliancejoin(void) { - tnode root; - add_command(&root, "alliance", &alliance_command); - g_keys = calloc(1, sizeof(tnode)); - add_command(g_keys, "kick", &alliance_kick); - execute(&root); - free(g_keys); + static syntaxtree * stree = NULL; + if (stree==NULL) { + syntaxtree * slang = stree = stree_create(); + while (slang) { + struct tnode * root = calloc(sizeof(tnode), 1); + struct tnode * leaf = calloc(sizeof(tnode), 1); + add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); + add_command(leaf, NULL, LOC(slang->lang, "join"), &alliance_join); + slang = slang->next; + } + } + execute(stree); } +void +setalliance(struct faction * f, alliance * al) +{ + if (f->alliance==al) return; + if (f->alliance!=NULL) { + faction_list ** flistp = &f->alliance->members; + while (*flistp) { + if ((*flistp)->data==f) { + *flistp = (*flistp)->next; + break; + } + flistp = &(*flistp)->next; + } + } + f->alliance = al; + if (al!=NULL) { + faction_list * flist = calloc(sizeof(faction_list), 1); + flist->next = al->members; + flist->data = f; + al->members = flist; + } +} + +const char * +alliancename(const alliance * al) +{ + typedef char name[OBJECTIDSIZE + 1]; + static name idbuf[8]; + static int nextbuf = 0; + + char *buf = idbuf[(++nextbuf) % 8]; + + if (al && al->name) { + sprintf(buf, "%s (%s)", strcheck(al->name, NAMESIZE), itoa36(al->id)); + } else { + return NULL; + } + return buf; +} + +void +alliancevictory(void) +{ + const struct building_type * btype = bt_find("stronghold"); + region * r = regions; + alliance * al = alliances; + while (r!=NULL) { + building * b = r->buildings; + while (b!=NULL) { + if (b->type==btype) { + unit * u = buildingowner(r, b); + if (u) { + fset(u->faction->alliance, FL_MARK); + } + } + b = b->next; + } + r=r->next; + } + while (al!=NULL) { + if (!fval(al, FL_MARK)) { + faction_list * flist = al->members; + while (flist!=0) { + faction * f = flist->data; + if (f->alliance==al) { + ADDMSG(&f->msgs, msg_message("alliance::lost", + "alliance", al)); + destroyfaction(f); + } + flist = flist->next; + } + } else { + freset(al, FL_MARK); + } + } +} diff --git a/src/common/kernel/alliance.h b/src/common/kernel/alliance.h index 4cf726832..e25a58358 100644 --- a/src/common/kernel/alliance.h +++ b/src/common/kernel/alliance.h @@ -17,9 +17,12 @@ struct attrib; struct unit; struct faction; struct region; +struct faction_list; typedef struct alliance { struct alliance * next; + struct faction_list * members; + unsigned int flags; int id; char * name; } alliance; @@ -27,8 +30,11 @@ typedef struct alliance { extern alliance * alliances; extern alliance * findalliance(int id); extern alliance * makealliance(int id, const char * name); +extern const char * alliancename(const struct alliance * al); +extern void setalliance(struct faction * f, alliance * al); extern void alliancejoin(void); extern void alliancekick(void); +extern void alliancevictory(void); /* execute commands */ diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 95b2b7047..3c83c9ad6 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -104,10 +104,6 @@ boolean nobattledebug = false; #define MINSPELLRANGE 1 #define MAXSPELLRANGE 7 -#ifndef COMBAT_TURNS -# define COMBAT_TURNS 10 -#endif - static const double EFFECT_PANIC_SPELL = 0.25; static const double TROLL_REGENERATION = 0.10; @@ -338,13 +334,15 @@ set_enemy(side * as, side * ds, boolean attacking) #ifdef ALLIANCES static int -allysfm(side * s, faction * f, int mode) +allysfm(const side * s, const faction * f, int mode) { - return isallied(s->battle->plane, s->faction, f, mode); + if (s->bf->faction==f) return true; + return alliedfaction(s->battle->plane, s->bf->faction, f, mode); } #else +extern int alliance(const ally * sf, const faction * f, int mode); static int -allysfm(side * s, faction * f, int mode) +allysfm(const side * s, const faction * f, int mode) { if (s->bf->faction==f) return true; if (s->group) return alliance(s->group->allies, f, mode); @@ -353,12 +351,11 @@ allysfm(side * s, faction * f, int mode) #endif static int -allysf(side * s, faction * f) +allysf(const side * s, const faction * f) { return allysfm(s, f, HELP_FIGHT); } - troop select_corpse(battle * b, fighter * af) /* Wählt eine Leiche aus, der af hilft. casualties ist die Anzahl der @@ -3234,15 +3231,15 @@ join_allies(battle * b) for (si = 0; si != size; ++si) { int se; side *s = b->sides.begin[si]; - /* Wenn alle attackierten noch FL_NOAIDF haben, dann kämpfe nicht mit. */ - if (fval(s->bf->faction, FL_NOAIDF)) continue; + /* Wenn alle attackierten noch FL_NOAID haben, dann kämpfe nicht mit. */ + if (fval(s->bf->faction, FL_NOAID)) continue; if (s->bf->faction!=f) { /* Wenn wir attackiert haben, kommt niemand mehr hinzu: */ if (s->bf->attacker) continue; /* Wenn alliierte attackiert haben, helfen wir nicht mit: */ if (s->bf->faction!=f && s->bf->attacker) continue; /* alliiert müssen wir schon sein, sonst ist's eh egal : */ - if (!allied(u, s->bf->faction, HELP_FIGHT)) continue; + if (!alliedunit(u, s->bf->faction, HELP_FIGHT)) continue; /* wenn die partei verborgen ist, oder gar eine andere * vorgespiegelt wird, und er sich uns gegenüber nicht zu * erkennen gibt, helfen wir ihm nicht */ @@ -3258,7 +3255,7 @@ join_allies(battle * b) for (se = 0; se != size; ++se) { side * evil = b->sides.begin[se]; if (u->faction==evil->bf->faction) continue; - if (allied(u, evil->bf->faction, HELP_FIGHT) && + if (alliedunit(u, evil->bf->faction, HELP_FIGHT) && !evil->bf->attacker) continue; if (enemy(s, evil)) break; } @@ -3463,38 +3460,9 @@ do_battle(void) list_continue(sl); } /* Fehler: "Die Einheit ist mit uns alliert" */ - /* alliances are dissolved */ - if (allied(u, u2->faction, HELP_FIGHT)) { - ally *sf, **sfp; - attrib * a = a_find(u->attribs, &at_group); - - if (a) { - sfp = &((group*)a->data.v)->allies; - } else { - sfp = &u->faction->allies; - } - - for(sf=*sfp; sf; sf = sf->next) { - if(sf->faction == u2->faction) { - removelist(sfp, sf); - break; - } - } - - a = a_find(u2->attribs, &at_group); - - if(a) { - sfp = &((group*)a->data.v)->allies; - } else { - sfp = &u2->faction->allies; - } - - for(sf=*sfp; sf; sf = sf->next) { - if(sf->faction == u->faction) { - removelist(sfp, sf); - break; - } - } + if (alliedunit(u, u2->faction, HELP_FIGHT)) { + cmistake(u, sl->s, 47, MSG_BATTLE); + list_continue(sl); } /* xmas */ if (u2->no==atoi36("xmas") && old_race(u2->irace)==RC_GNOME) { diff --git a/src/common/kernel/border.c b/src/common/kernel/border.c index dd55371cb..11edad2fc 100644 --- a/src/common/kernel/border.c +++ b/src/common/kernel/border.c @@ -103,12 +103,7 @@ read_borders(FILE * f) fscanf(f, "%s", zText); if (!strcmp(zText, "end")) break; - if (global.data_versionid = bid; assert(bid<=nextborder); if (type->read) type->read(b, f); - if (global.data_version>BORDER_VERSION) - a_read(f, &b->attribs); + a_read(f, &b->attribs); } } @@ -204,10 +198,7 @@ void b_read(border * b, FILE *f) { assert(sizeof(int)==sizeof(b->data)); - if (global.data_versiondata); - else - fscanf(f, "%x ", (unsigned int*)&b->data); + fscanf(f, "%x ", (unsigned int*)&b->data); } void diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index 5fed65b1d..3004ca798 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -119,7 +119,7 @@ can_contact(const region * r, const unit * u, const unit * u2) && slipthru(u->region, u2, u2->building)) return true; - if (allied(u, u2->faction, HELP_GIVE)) + if (alliedunit(u, u2->faction, HELP_GIVE)) return true; return false; @@ -285,7 +285,7 @@ destroy_road(unit *u, int n, const char *cmd) for (u2=r->units;u2;u2=u2->next) { if (u2->faction!=u->faction && getguard(u2)&GUARD_TAX && - !allied(u, u2->faction, HELP_GUARD)) { + !alliedunit(u, u2->faction, HELP_GUARD)) { cmistake(u, cmd, 70, MSG_EVENT); return; } @@ -1016,7 +1016,7 @@ mayenter(region * r, unit * u, building * b) u2 = buildingowner(r, b); if (u2==NULL || ucontact(u2, u) - || allied(u2, u->faction, HELP_GUARD)) return true; + || alliedunit(u2, u->faction, HELP_GUARD)) return true; return false; } @@ -1029,7 +1029,7 @@ mayboard(region * r, unit * u, ship * sh) return (!u2 || ucontact(u2, u) - || allied(u2, u->faction, HELP_GUARD)); + || alliedunit(u2, u->faction, HELP_GUARD)); } diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 747029c27..9cbae958b 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -291,7 +291,7 @@ building_type bt_castle = { static local_names * bnames; const building_type * -findbuildingtype(const char * name, const locale * lang) +findbuildingtype(const char * name, const struct locale * lang) { local_names * bn = bnames; void * i; diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 9ec14909f..c66c92117 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -238,7 +238,8 @@ const char *keywords[MAXKEYWORDS] = "SYNONYM", "PFLANZEN", "WERWESEN", - "XONTORMIA" + "XONTORMIA", + "ALLIANZ" }; const char *report_options[MAX_MSG] = @@ -725,50 +726,6 @@ unit_has_cursed_item(unit *u) return false; } -#ifdef ALLIANCES -int -allied(const unit * u, const faction * f2, int mode) -{ - if (u->faction->alliance==f2->alliance) return mode; - return 0; -} - -int -isallied(const plane * pl, const faction * f, const faction * f2, int mode) -{ - unused(pl); - if (f->alliance==f2->alliance) return mode; - return 0; -} - -#else - -/* f hat zu f2 HELFE mode gesetzt */ -int -isallied(const plane * pl, const faction * f, const faction * f2, int mode) -{ - ally *sf; - attrib * a; - - if (f == f2) return mode; - if (f2==NULL) return 0; - - a = a_find(f->attribs, &at_gm); - while (a) { - plane * p = (plane*)a->data.v; - if (p==pl) return mode; - a=a->next; - } - - if (pl && pl->flags & PFL_FRIENDLY) return mode; - if (mode != HELP_GIVE && pl && (pl->flags & PFL_NOALLIANCES)) return 0; - for (sf = f->allies; sf; sf = sf->next) - if (sf->faction == f2) - return (sf->status & mode); - - return 0; -} - static int alliance(const ally * sf, const faction * f, int mode) { @@ -780,37 +737,57 @@ alliance(const ally * sf, const faction * f, int mode) return 0; } +static int +autoalliance(const plane * pl, const faction * sf, const faction * f2) +{ + int mode = 0; + attrib * a = a_find(f2->attribs, &at_gm); + + /* if f2 is a gm in this plane, everyone has an auto-help to it */ + if (pl && pl->flags & PFL_FRIENDLY) return mode; + while (a) { + const plane * p = (const plane*)a->data.v; + if (p==pl) return HELP_ALL; + a=a->next; + } +#ifdef AUTOALLIANCE + if (sf->alliance==f2->alliance) mode |= AUTOALLIANCE; +#endif + + return mode; +} + +int +alliedfaction(const struct plane * pl, const faction * sf, const faction * f2, int mode) +{ +#ifdef ALLIANCES + if (sf->alliance!=f2->alliance) return 0; +#endif + return alliance(sf->allies, f2, mode) | (mode & autoalliance(pl, sf, f2)); +} + /* Die Gruppe von Einheit u hat helfe zu f2 gesetzt. */ int -allied(const unit * u, const faction * f2, int mode) +alliedunit(const unit * u, const faction * f2, int mode) { ally * sf; const attrib * a; - plane * pl; + const plane * pl = getplane(u->region); + int automode; if (u->faction == f2) return mode; if (u->faction == NULL || f2==NULL) return 0; + automode = mode & autoalliance(pl, u->faction, f2); + + if (pl!=NULL && (pl->flags & PFL_NOALLIANCES)) + mode = (mode & automode) | (mode & HELP_GIVE); + sf = u->faction->allies; - pl = getplane(u->region); - - if (pl && pl->flags & PFL_FRIENDLY) return mode; - - /* if f2 is a gm in this plane, everyone has an auto-help to it */ - a = a_find(f2->attribs, &at_gm); - while (a) { - plane * p = (plane*)a->data.v; - if (p==pl) return mode; - a=a->next; - } - - if (mode != HELP_GIVE && pl && (pl->flags & PFL_NOALLIANCES)) - return 0; a = a_find(u->attribs, &at_group); - if (a) sf = ((group*)a->data.v)->allies; - return alliance(sf, f2, mode); + if (a!=NULL) sf = ((group*)a->data.v)->allies; + return alliance(sf, f2, mode) | automode; } -#endif boolean seefaction(const faction * f, const region * r, const unit * u, int modifier) @@ -2078,7 +2055,7 @@ read_strings(FILE * F) char rbuf[8192]; while (fgets(rbuf, sizeof(rbuf), F)) { char * b = rbuf; - locale * lang; + struct locale * lang; char * key = b; char * language; const char * k; @@ -2111,7 +2088,7 @@ const char * strings[] = { NULL }; -const char * locales[] = { +const char * localenames[] = { "de", "en", NULL }; @@ -2192,12 +2169,12 @@ init_data(const char * filename) if (l) return l; /* old stuff, for removal: */ - for (l=0;locales[l];++l) { + for (l=0;localenames[l];++l) { char zText[MAX_PATH]; int i; for (i=0;strings[i];++i) { FILE * F; - sprintf(zText, strings[i], resourcepath(), locales[l]); + sprintf(zText, strings[i], resourcepath(), localenames[l]); F = fopen(zText, "r+"); if (F) { read_strings(F); @@ -2216,8 +2193,8 @@ void init_locales(void) { int l; - for (l=0;locales[l];++l) { - const struct locale * lang = find_locale(locales[l]); + for (l=0;localenames[l];++l) { + const struct locale * lang = find_locale(localenames[l]); if (lang) init_tokens(lang); } } diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 1384bb355..d5e1e8838 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -107,30 +107,32 @@ struct xml_stack; #define FUZZY_BASE36 /* Fuzzy- Behandlung von Gebäude- und Schiffsnummern */ #define FULL_BASE36 -#define RACES_VERSION 91 -#define MIN_VERSION RACES_VERSION -#define MAGIEGEBIET_VERSION 92 -#define FATTRIBS_VERSION 94 -#define ATNORD_VERSION 95 -#define NEWMAGIC 100 -#define MEMSAVE_VERSION 101 -#define BORDER_VERSION 102 -#define ATNAME_VERSION 103 -#define ATTRIBFIX_VERSION 104 -#define BORDERID_VERSION 105 -#define NEWROAD_VERSION 106 -#define GUARD_VERSION 107 -#define TIMEOUT_VERSION 108 -#define GUARDFIX_VERSION 109 -#define NEW_FACTIONID_VERSION 110 -#define ACTIONFIX1_VERSION 111 -#define SHIPTYPE_VERSION 112 -#define GROUPS_VERSION 113 -#define MSGLEVEL_VERSION 114 -#define DISABLE_ROADFIX 114 -#define FACTIONFLAGS_VERSION 114 /* speichern von struct faction::flags */ -#define KARMA_VERSION 114 -#define FULL_BASE36_VERSION 115 +/** + * heaps and heaps of unsupported versions: + #define RACES_VERSION 91 + #define MAGIEGEBIET_VERSION 92 + #define FATTRIBS_VERSION 94 + #define ATNORD_VERSION 95 + #define NEWMAGIC 100 + #define MEMSAVE_VERSION 101 + #define BORDER_VERSION 102 + #define ATNAME_VERSION 103 + #define ATTRIBFIX_VERSION 104 + #define BORDERID_VERSION 105 + #define NEWROAD_VERSION 106 + #define GUARD_VERSION 107 + #define TIMEOUT_VERSION 108 + #define GUARDFIX_VERSION 109 + #define NEW_FACTIONID_VERSION 110 + #define ACTIONFIX1_VERSION 111 + #define SHIPTYPE_VERSION 112 + #define GROUPS_VERSION 113 + #define MSGLEVEL_VERSION 114 + #define DISABLE_ROADFIX 114 + #define FACTIONFLAGS_VERSION 114 + #define KARMA_VERSION 114 + #define FULL_BASE36_VERSION 115 + **/ #define TYPES_VERSION 117 #define ITEMTYPE_VERSION 190 #define NOFOREST_VERSION 191 @@ -156,6 +158,7 @@ struct xml_stack; #define CURSETYPE_VERSION 312 #define ALLIANCES_VERSION 313 +#define MIN_VERSION TYPES_VERSION #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ #define RELEASE_VERSION ALLIANCES_VERSION @@ -317,7 +320,6 @@ extern void plagues(struct region * r, boolean ismagic); /* ist noch nicht fertig! */ #define ARENA_PLANE -#define MUSEUM_PLANE #undef UNDERWORLD_PLANE #define ORCIFICATION @@ -822,7 +824,7 @@ enum { #define HELP_GIVE 8 /* Dinge annehmen ohne KONTAKTIERE */ #define HELP_GUARD 16 /* Laesst Steuern eintreiben etc. */ #define HELP_FSTEALTH 32 /* Laesst Steuern eintreiben etc. */ -#define HELP_ALL 63-HELP_OBSERVE /* Alle "positiven" HELPs zusammen */ +#define HELP_ALL (63-HELP_OBSERVE) /* Alle "positiven" HELPs zusammen */ /* HELP_OBSERVE deaktiviert */ /* ------------------------------------------------------------- */ /* Prototypen */ @@ -1013,8 +1015,8 @@ struct unit *getunitg(const struct region * r, const struct faction * f); struct unit *getunit(const struct region * r, const struct faction * f); int read_unitid(const struct faction * f, const struct region * r); -int isallied(const struct plane * pl, const struct faction * f, const struct faction * f2, int mode); -int allied(const struct unit * u, const struct faction * f, int mode); +extern int alliedunit(const struct unit * u, const struct faction * f2, int mode); +extern int alliedfaction(const struct plane * pl, const struct faction * f, const struct faction * f2, int mode); struct faction *findfaction(int n); struct faction *findfaction_unique_id(int unique_id); @@ -1169,7 +1171,7 @@ extern void kernel_done(void); extern void reorder_owners(struct region * r); -extern const char *locales[]; +extern const char *localenames[]; #define FIRST_TURN 184 diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 066b65a5a..edfd46a8c 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -82,7 +82,7 @@ unused_faction_id(void) } unit * -addplayer(region *r, const char *email, const char * password, const struct race * frace, const locale *loc) +addplayer(region *r, const char *email, const char * password, const struct race * frace, const struct locale *loc) { int i; unit *u; @@ -110,7 +110,7 @@ addplayer(region *r, const char *email, const char * password, const struct race f->locale = loc; set_ursprung(f, 0, r->x, r->y); - f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL) | Pow(O_COMPUTER) | Pow(O_COMPRESS); + f->options = Pow(O_REPORT) | Pow(O_ZUGVORLAGE) | Pow(O_SILBERPOOL) | Pow(O_COMPUTER) | Pow(O_COMPRESS) | Pow(O_ADRESSEN) | Pow(O_STATISTICS); f->no = unused_faction_id(); register_faction_id(f->no); diff --git a/src/common/kernel/group.c b/src/common/kernel/group.c index 784b9d168..bc68a24d1 100644 --- a/src/common/kernel/group.c +++ b/src/common/kernel/group.c @@ -187,12 +187,8 @@ read_groups(FILE * F, faction * f) for (;;) { ally * a; int aid; - if (global.data_version >= FULL_BASE36_VERSION) { - fscanf(F, "%s ", buf); - aid = atoi36(buf); - } else { - fscanf(F, "%d ", &aid); - } + fscanf(F, "%s ", buf); + aid = atoi36(buf); if (aid==0) break; a = calloc(sizeof(ally), 1); *pa = a; diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 40bab7f87..9daa245e9 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -2323,7 +2323,7 @@ change_money(unit * u, int v) static local_names * rnames; const resource_type * -findresourcetype(const char * name, const locale * lang) +findresourcetype(const char * name, const struct locale * lang) { local_names * rn = rnames; void * i; @@ -2365,7 +2365,7 @@ attrib_type at_seenitem = { static local_names * inames; const item_type * -finditemtype(const char * name, const locale * lang) +finditemtype(const char * name, const struct locale * lang) { local_names * in = inames; void * i; diff --git a/src/common/kernel/karma.c b/src/common/kernel/karma.c index 992dfc494..cf13830df 100644 --- a/src/common/kernel/karma.c +++ b/src/common/kernel/karma.c @@ -600,7 +600,7 @@ jihad_attacks(void) if(sf->faction == u->faction) break; } - if(sf) sf->status = sf->status & (HELP_ALL - HELP_FIGHT); + if (sf) sf->status = sf->status & (HELP_ALL - HELP_FIGHT); sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_ATTACK]), unitid(u)); S = makestrlist(buf); diff --git a/src/common/kernel/kernel.dsp b/src/common/kernel/kernel.dsp index 7e4b9aaac..d8af0e325 100644 --- a/src/common/kernel/kernel.dsp +++ b/src/common/kernel/kernel.dsp @@ -280,7 +280,7 @@ SOURCE=.\alchemy.c # End Source File # Begin Source File -SOURCE=.\battle.c +SOURCE=".\battle.c" # End Source File # Begin Source File diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index db94c0a72..b243a13b6 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -1236,13 +1236,13 @@ magic_resistance(unit *target) if (mage!=NULL) { if (c->type == ct_find("goodmagicresistancezone")) { - if (allied(mage, target->faction, HELP_GUARD)) { + if (alliedunit(mage, target->faction, HELP_GUARD)) { chance += c->effect; break; } } else if (c->type == ct_find("badmagicresistancezone")) { - if (allied(mage, target->faction, HELP_GUARD)) { + if (alliedunit(mage, target->faction, HELP_GUARD)) { a = a->nexttype; continue; } diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 07b4a3581..57fb48bf3 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -643,7 +643,7 @@ caught_target(region * r, unit * u) if (!present(r, target)) { add_message(&u->faction->msgs, new_message(u->faction, "followfail%u:unit%u:follower", target, u)); - } else if (!allied(target, u->faction, HELP_ALL) + } else if (!alliedunit(target, u->faction, HELP_ALL) && cansee(target->faction, r, u, 0)) { add_message(&target->faction->msgs, new_message(target->faction, @@ -670,7 +670,7 @@ bewegung_blockiert_von(unit * reisender, region * r) !get_item(u, I_AMULET_OF_TRUE_SEEING)) continue; if (u->faction==reisender->faction || ucontact(u, reisender) - || allied(u, reisender->faction, HELP_GUARD)) + || alliedunit(u, reisender->faction, HELP_GUARD)) { contact = true; } else if (sk>=perception) { @@ -698,7 +698,7 @@ is_guardian(unit * u2, unit *u, unsigned int mask) && getguard(u2)&mask && u2->number && !ucontact(u2, u) && !besieged(u2) - && allied(u2, u->faction, HELP_GUARD) != HELP_GUARD + && alliedunit(u2, u->faction, HELP_GUARD) != HELP_GUARD #ifdef WACH_WAFF && armedmen(u2) #endif @@ -745,7 +745,7 @@ cycle_route(unit *u, int gereist) strcpy(neworder, locale_string(u->faction->locale, keywords[K_ROUTE])); for (cm=0;;++cm) { - const locale * lang = u->faction->locale; + const struct locale * lang = u->faction->locale; pause = false; token = getstrtoken(); d = finddirection(token, lang); @@ -1635,7 +1635,7 @@ sail(region * starting_point, unit * u, region * next_point, boolean move_on_lan assert(trans==NULL); for (u2 = current_point->units; u2; u2 = u2->next) { if (u2->ship == u->ship && - !allied(hafenmeister, u->faction, HELP_GUARD)) { + !alliedunit(hafenmeister, u->faction, HELP_GUARD)) { if (effskill(hafenmeister, SK_OBSERVATION) > effskill(u2, SK_STEALTH)) { @@ -1805,7 +1805,7 @@ piracy(unit *u) for(a = a_find(r->attribs, &at_piracy_direction); a; a=a->nexttype) { faction *f = findfaction(a->data.sa[0]); - if(allied(u, f, HELP_FIGHT) + if (alliedunit(u, f, HELP_FIGHT) && intlist_find(il, a->data.sa[1])) { target_dir = (direction_t)a->data.sa[1]; break; @@ -1827,7 +1827,7 @@ piracy(unit *u) for(sh2 = rc->ships; sh2; sh2 = sh2->next) { cap = shipowner(rc, sh2); - if(cap && !allied(u, cap->faction, HELP_FIGHT) + if (cap && !alliedunit(u, cap->faction, HELP_FIGHT) && (intlist_find(il, cap->faction->no) || all)) { aff[dir]++; } diff --git a/src/common/kernel/plane.h b/src/common/kernel/plane.h index b9fe8858d..e22135aa6 100644 --- a/src/common/kernel/plane.h +++ b/src/common/kernel/plane.h @@ -38,8 +38,6 @@ #define PFL_NOMONSTERS 16384 /* no monster randenc */ #define PFL_SEESPECIAL 32768 /* far seeing */ -#define PFL_MUSEUM PFL_NOMONSTERS | PFL_NOCOORDS | PFL_NORECRUITS | PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED - typedef struct watcher { struct watcher * next; struct faction * faction; diff --git a/src/common/kernel/pool.c b/src/common/kernel/pool.c index cfb655b33..ff2babb67 100644 --- a/src/common/kernel/pool.c +++ b/src/common/kernel/pool.c @@ -191,7 +191,7 @@ new_get_pooled(const unit * u, const resource_type * rtype, int mode) } mask = (mode >> 3) & (GET_SLACK|GET_RESERVE); } - else if (allied(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); + else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); else continue; use += new_get_pooled(v, rtype, mask); } @@ -238,7 +238,7 @@ new_use_pooled(unit * u, const resource_type * rtype, int mode, int count) } mask = (mode >> 3) & (GET_SLACK|GET_RESERVE); } - else if (allied(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); + else if (alliedunit(v, f, HELP_MONEY)) mask = (mode >> 6) & (GET_SLACK|GET_RESERVE); else continue; use -= new_use_pooled(v, rtype, mask, use); } diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index 5a9bb31a2..f2d651ff9 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -332,7 +332,7 @@ rc_name(const race * rc, int n) } const char * -racename(const locale *loc, const unit *u, const race * rc) +racename(const struct locale *loc, const unit *u, const race * rc) { static char lbuf[80]; attrib *a, *a2; diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 0586ec4ba..5853ed3ee 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -656,7 +656,7 @@ r_demand(const region * r, const luxury_type * ltype) } const char * -rname(const region * r, const locale * lang) { +rname(const region * r, const struct locale * lang) { if (r->land) return r->land->name; return locale_string(lang, terrain[rterrain(r)].name); diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index d60a7ff06..cb2618706 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -210,7 +210,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode) } else { scat(", "); if(a_otherfaction - && allied(u, f, HELP_FSTEALTH)) { + && alliedunit(u, f, HELP_FSTEALTH)) { scat(factionname(get_otherfaction(a_otherfaction))); scat(" ("); scat(factionname(u->faction)); @@ -365,13 +365,11 @@ bufunit(const faction * f, const unit * u, int indent, int mode) for (spt = get_mage(u)->spellptr;spt; spt = spt->next){ sp = find_spellbyid(spt->spellid); - if(sp->level > t){ - continue; - } - if (!dh){ + if (sp->level > t) continue; + if (!dh) { sprintf(buf+strlen(buf),", %s: ", LOC(f->locale, "nr_spells")); dh = 1; - }else{ + } else { scat(", "); } scat(spell_name(sp, f->locale)); @@ -433,13 +431,9 @@ bufunit(const faction * f, const unit * u, int indent, int mode) } dh=0; - if (!getarnt && f && f->allies) { - ally *sf; - - for (sf = f->allies; sf && !dh; sf = sf->next) { - if (sf->status > 0 && sf->status <= HELP_ALL && sf->faction == fv) { - dh = 1; - } + if (!getarnt && f) { + if (alliedfaction(getplane(u->region), f, fv, HELP_ALL)) { + dh = 1; } } return dh; @@ -848,7 +842,7 @@ ucansee(const struct faction *f, const struct unit *u, const struct unit *x) faction * visible_faction(const faction *f, const unit * u) { - if(!allied(u, f, HELP_FSTEALTH)) { + if(!alliedunit(u, f, HELP_FSTEALTH)) { attrib *a = a_find(u->attribs, &at_otherfaction); if (a) { faction *fv = get_otherfaction(a); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 3b576ce53..096fcd161 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -785,17 +785,8 @@ readgame(boolean backup) #endif turn = ri(F); /* read_dynamictypes(); */ - if (global.data_version < NEWMAGIC) { - max_unique_id = 0; - } else { - max_unique_id = ri(F); - } - - if (global.data_version < BORDERID_VERSION) { - nextborder = 0; - } else { - nextborder = ri(F); - } + max_unique_id = ri(F); + nextborder = ri(F); /* Planes */ planes = NULL; @@ -846,15 +837,11 @@ readgame(boolean backup) /* Benutzte Faction-Ids */ - if (global.data_version < NEW_FACTIONID_VERSION) { - init_used_faction_ids(); - } else { - no_used_faction_ids = ri(F); - /* used_faction_ids = gc_add(malloc(no_used_faction_ids*sizeof(int))); */ - used_faction_ids = malloc(no_used_faction_ids*sizeof(int)); - for(i=0; i < no_used_faction_ids; i++) { - used_faction_ids[i] = ri(F); - } + no_used_faction_ids = ri(F); + /* used_faction_ids = gc_add(malloc(no_used_faction_ids*sizeof(int))); */ + used_faction_ids = malloc(no_used_faction_ids*sizeof(int)); + for(i=0; i < no_used_faction_ids; i++) { + used_faction_ids[i] = ri(F); } /* Regionen */ @@ -906,10 +893,7 @@ readgame(boolean backup) while (--p >= 0) { b = (building *) calloc(1, sizeof(building)); - if (global.data_version>=FULL_BASE36_VERSION) - b->no = rid(F); - else - b->no = ri(F); + b->no = rid(F); bhash(b); rds(F, &b->name); rds(F, &b->display); @@ -935,37 +919,16 @@ readgame(boolean backup) sh = (ship *) calloc(1, sizeof(ship)); sh->region = r; - if (global.data_version>=FULL_BASE36_VERSION) - sh->no = rid(F); - else - sh->no = ri(F); + sh->no = rid(F); shash(sh); rds(F, &sh->name); rds(F, &sh->display); - if (global.data_version < SHIPTYPE_VERSION) { - assert(!"cannot read old datafile with xml ship support"); - } - else { - rs(F, buf); - sh->type = st_find(buf); - assert(sh->type || !"ship_type not registered!"); - } - if (global.data_version >= TYPES_VERSION) { - sh->size = ri(F); - sh->damage = ri(F); - } else if (global.data_version > 76) { - assert(sh->type->construction->improvement==NULL); /* sonst ist construction::size nicht ship_type::maxsize */ - sh->size = sh->type->construction->maxsize - ri(F); - sh->damage = DAMAGE_SCALE*sh->size*ri(F)/100; - } else { - int left = ri(F); - if (rterrain(r) == T_OCEAN) { - assert(sh->type->construction->improvement==NULL); /* sonst ist construction::size nicht ship_type::maxsize */ - sh->size = sh->type->construction->maxsize-left; - } - sh->damage = 0; - } + rs(F, buf); + sh->type = st_find(buf); + assert(sh->type || !"ship_type not registered!"); + sh->size = ri(F); + sh->damage = ri(F); /* Attribute rekursiv einlesen */ @@ -991,7 +954,7 @@ readgame(boolean backup) } printf("\n"); if (!dirtyload) { - if (global.data_version >= BORDER_VERSION) read_borders(F); + read_borders(F); #ifdef USE_UGROUPS if (global.data_version >= UGROUPS_VERSION) read_ugroups(F); #endif @@ -1143,12 +1106,12 @@ write_alliances(FILE * F) { alliance * al = alliances; while (al) { - ws(F, itoa36(al->id)); + wi36(F, al->id); ws(F, al->name); al = al->next; wnl(F); } - ws(F, "end"); + fprintf(F, "end"); wnl(F); } #endif @@ -1261,10 +1224,10 @@ writegame(char *path, char quiet) wi(F, RELEASE_VERSION); wnl(F); -#if RELEASE_VERSION >= GLOBAL_ATTRIB_VERSION + a_write(F, global.attribs); wnl(F); -#endif + wi(F, turn); wi(F, max_unique_id); wi(F, nextborder); @@ -1275,9 +1238,7 @@ writegame(char *path, char quiet) wnl(F); for(pl = planes; pl; pl=pl->next) { -#if RELEASE_VERSION >= WATCHERS_VERSION watcher * w; -#endif wi(F, pl->id); ws(F, pl->name); wi(F, pl->minx); @@ -1285,7 +1246,6 @@ writegame(char *path, char quiet) wi(F, pl->miny); wi(F, pl->maxy); wi(F, pl->flags); -#if RELEASE_VERSION >= WATCHERS_VERSION w = pl->watchers; while (w) { if (w->faction) { @@ -1295,7 +1255,6 @@ writegame(char *path, char quiet) w = w->next; } fputs("end ", F); -#endif a_write(F, pl->attribs); wnl(F); } @@ -1362,11 +1321,7 @@ writegame(char *path, char quiet) wi36(F, sh->no); ws(F, sh->name); ws(F, sh->display); -#if RELEASE_VERSION < SHIPTYPE_VERSION - wi(F, sh->type); -#else ws(F, sh->type->name[0]); -#endif wi(F, sh->size); wi(F, sh->damage); wi(F, sh->coast); @@ -1524,11 +1479,7 @@ read_faction_reference(faction ** f, FILE * F) void write_faction_reference(const faction * f, FILE * F) { -#if RELEASE_VERSION >= BASE36IDS_VERSION fprintf(F, "%s ", itoa36(f->no)); -#else - fprintf(F, "%d ", f->no); -#endif } unit * @@ -1555,22 +1506,14 @@ readunit(FILE * F) u->skill_size = 0; u_setfaction(u, NULL); } - if (global.data_version>=GUARD_VERSION) { + { faction * f; - if (global.data_version>=FULL_BASE36_VERSION) { - n = rid(F); - } else { - n = ri(F); - } + int n = rid(F); f = findfaction(n); if (f!=u->faction) u_setfaction(u, f); } rds(F, &u->name); rds(F, &u->display); - if (global.data_version < MEMSAVE_VERSION) { - rs(F, buf); - if (strlen(buf)) usetprivate(u, buf); - } number = ri(F); if (global.data_versionirace = rc_find(buf); else u->irace = u->race; } - if (global.data_versionfaction == NULL) { log_error(("unit %s has faction == NULL\n", unitname(u))); #if 0 @@ -1602,13 +1543,8 @@ readunit(FILE * F) u->faction->no_units++; } set_number(u, number); - if (global.data_version>=FULL_BASE36_VERSION) { - u->building = findbuilding(rid(F)); - u->ship = findship(rid(F)); - } else { - u->building = findbuilding(ri(F)); - u->ship = findship(ri(F)); - } + u->building = findbuilding(rid(F)); + u->ship = findship(rid(F)); if (global.data_version <= 73) { if (ri(F)) { @@ -1635,23 +1571,16 @@ readunit(FILE * F) } } else u->flags = ri(F) & ~UFL_DEBUG; - if (global.data_version < GUARD_VERSION) { -#if RELEASE_VERSION < GUARDFIX_VERSION - if (fval(u, 1)) guard(u, GUARD_ALL); -#endif - } /* Kurze persistente Befehle einlesen */ if (u->orders) { freestrlist(u->orders); u->orders = NULL; } - if (global.data_version >= MEMSAVE_VERSION) { + rs(F, buf); + while(*buf != 0) { + strlist *S = makestrlist(buf); + addlist(&u->orders,S); rs(F, buf); - while(*buf != 0) { - strlist *S = makestrlist(buf); - addlist(&u->orders,S); - rs(F, buf); - } } rds(F, &u->lastorder); set_string(&u->thisorder, ""); @@ -1702,35 +1631,26 @@ readunit(FILE * F) u->hp = ri(F); /* assert(u->hp >= u->number); */ if (global.data_version < MAGE_ATTRIB_VERSION) { - if (global.data_version < NEWMAGIC) { - if (has_skill(u, SK_MAGIC)) { - /* ist Magier und muss in neuen Magier konvertiert werden */ - create_mage(u, u->faction->magiegebiet); - /* bekommt anfangs soviel Aura wie er Magie kann */ - set_spellpoints(u, effskill(u, SK_MAGIC)); - } - } else { - int i = ri(F); - if (i != -1){ - attrib * a; - int csp = 0; + int i = ri(F); + if (i != -1){ + attrib * a; + int csp = 0; - sc_mage * mage = calloc(1, sizeof(sc_mage)); - mage->magietyp = (magic_t) i; - mage->spellpoints = ri(F); - mage->spchange = ri(F); - while ((i = ri(F)) != -1) { - mage->combatspell[csp] = (spellid_t) i; - mage->combatspelllevel[csp] = ri(F); - csp++; - } - while ((i = ri(F)) != -1) { - addspell(u, (spellid_t) i); - } - mage->spellcount = 0; - a = a_add(&u->attribs, a_new(&at_mage)); - a->data.v = mage; + sc_mage * mage = calloc(1, sizeof(sc_mage)); + mage->magietyp = (magic_t) i; + mage->spellpoints = ri(F); + mage->spchange = ri(F); + while ((i = ri(F)) != -1) { + mage->combatspell[csp] = (spellid_t) i; + mage->combatspelllevel[csp] = ri(F); + csp++; } + while ((i = ri(F)) != -1) { + addspell(u, (spellid_t) i); + } + mage->spellcount = 0; + a = a_add(&u->attribs, a_new(&at_mage)); + a->data.v = mage; } } a_read(F, &u->attribs); @@ -1755,19 +1675,10 @@ writeunit(FILE * F, const unit * u) wi36(F, u->building->no); else wi(F, 0); - if (u->ship) -#if RELEASE_VERSION>= FULL_BASE36_VERSION - wi36(F, u->ship->no); -#else - wi(F, u->ship->no); -#endif - else - wi(F, 0); + if (u->ship) wi36(F, u->ship->no); + else wi36(F, 0); wi(F, u->status); wi(F, u->flags & UFL_SAVEMASK); -#if RELEASE_VERSION < GUARDFIX_VERSION - wi(F, getguard(u)); -#endif for(S=u->orders; S; S=S->next) { if (is_persistent(S->s, u->faction->locale)) { ws(F, S->s); @@ -1775,9 +1686,6 @@ writeunit(FILE * F, const unit * u) } ws(F, ""); /* Abschluß der persistenten Befehle */ ws(F, u->lastorder); -#if RELEASE_VERSION < EFFSTEALTH_VERSION - wi(F, u_geteffstealth(u)); -#endif wnl(F); assert(u->number >= 0); @@ -1807,26 +1715,6 @@ writeunit(FILE * F, const unit * u) } wi(F, u->hp); wnl(F); -#if RELEASE_VERSION < MAGE_ATTRIB_VERSION - if (is_mage(u)) { - m = get_mage(u); - wi(F, m->magietyp); - wi(F, m->spellpoints); - wi(F, m->spchange); - for (i = 0; i != MAXCOMBATSPELLS; i++){ - wi(F, m->combatspell[i]); - wi(F, m->combatspelllevel[i]); - } - wi(F, -1); - wnl(F); - /* BUG: Endlosschleife! */ - for (sp = m->spellptr;sp;sp=sp->next){ - wi(F, sp->spellid); - } - } - wi(F, -1); - wnl(F); -#endif a_write(F, u->attribs); wnl(F); } @@ -1834,7 +1722,6 @@ writeunit(FILE * F, const unit * u) region * readregion(FILE * F, int x, int y) { - char * name = NULL; region * r = findregion(x, y); int ter; @@ -1854,41 +1741,24 @@ readregion(FILE * F, int x, int y) } r->land = 0; } - if (global.data_version < MEMSAVE_VERSION) { - rds(F, &name); - } rds(F, &r->display); ter = ri(F); if (global.data_version < NOFOREST_VERSION) { if (ter>T_PLAIN) --ter; } rsetterrain(r, (terrain_t)ter); - if (global.data_version >= MEMSAVE_VERSION) r->flags = (char) ri(F); + r->flags = (char) ri(F); if (global.data_version >= REGIONAGE_VERSION) r->age = (unsigned short) ri(F); else r->age = 0; - if (global.data_version < MEMSAVE_VERSION) { - ri(F); - } - if (global.data_version < MEMSAVE_VERSION) { - if (ri(F)) fset(r, RF_CHAOTIC); - else freset(r, RF_CHAOTIC); - } - - if (global.data_version < MEMSAVE_VERSION) { - if (landregion(rterrain(r))) { - r->land = calloc(1, sizeof(land_region)); - rsetname(r, name); - } - free(name); - } else if (landregion(rterrain(r))) { + if (landregion(rterrain(r))) { r->land = calloc(1, sizeof(land_region)); rds(F, &r->land->name); } - if (global.data_version < MEMSAVE_VERSION || r->land) { + if (r->land) { int i; #if GROWING_TREES if(global.data_version < GROWTREE_VERSION) { @@ -1951,7 +1821,7 @@ readregion(FILE * F, int x, int y) rsetherbtype(r, NULL); } rsetherbs(r, (short)ri(F)); - } else if (global.data_version>=MEMSAVE_VERSION) { + } else { int i = ri(F); terrain_t ter = rterrain(r); if (ter == T_ICEBERG || ter == T_ICEBERG_SLEEP) ter = T_GLACIER; @@ -1960,38 +1830,9 @@ readregion(FILE * F, int x, int y) else rsetherbtype(r, oldherbtype[(i-1)+3*(ter-1)]); rsetherbs(r, (short)ri(F)); - } else if (global.data_version0) { - a = a_find(r->attribs, &at_deathcount); - if (!a) a = a_add(&r->attribs, a_new(&at_deathcount)); - a->data.i = deathcount; - } - if (chaoscount>0) { - a = a_find(r->attribs, &at_chaoscount); - if (!a) a = a_add(&r->attribs, a_new(&at_chaoscount)); - a->data.i = chaoscount; - } } assert(rterrain(r) != NOTERRAIN); @@ -1999,7 +1840,7 @@ readregion(FILE * F, int x, int y) assert(rpeasants(r) >= 0); assert(rmoney(r) >= 0); - if (global.data_version < MEMSAVE_VERSION || r->land) { + if (r->land) { if (global.data_versionalliance!=f->alliance) return; +#endif + sf = calloc(1, sizeof(ally)); + sf->faction = af; + if (!sf->faction) ur_add((void*)aid, (void**)&sf->faction, resolve_faction); + sf->status = state; + sf->next = *sfp; + + *sfp = sf; +} + /** Reads a faction from a file. * This function requires no context, can be called in any state. The * faction may not already exist, however. @@ -2091,33 +1952,31 @@ writeregion(FILE * F, const region * r) faction * readfaction(FILE * F) { - ally *sf, **sfp; - int planes, i, p; - - faction * f; - - if (global.data_versionno = i; } else { - if (global.data_version < NEWMAGIC) { - f->unique_id = max_unique_id + 1; - max_unique_id++; - } f->warnings = NULL; /* mem leak */ f->allies = NULL; /* mem leak */ while (f->attribs) a_remove(&f->attribs, f->attribs); } - if (global.data_version >= NEWMAGIC) { - f->unique_id = ri(F); + f->unique_id = ri(F); +#ifdef ALLIANCES + if (global.data_version>=ALLIANCES_VERSION) { + int allianceid = rid(F); + if (allianceid!=0) f->alliance = findalliance(allianceid); + if (f->alliance) { + faction_list * flist = malloc(sizeof(faction_list)); + flist->data = f; + flist->next = f->alliance->members; + f->alliance->members = flist; + } } +#endif rds(F, &f->name); @@ -2157,29 +2016,16 @@ readfaction(FILE * F) f->race = rc_find(buf); assert(f->race); } - if (global.data_version >= MAGIEGEBIET_VERSION) - f->magiegebiet = (magic_t)ri(F); - else - f->magiegebiet = (magic_t)((rand() % 5)+1); - + f->magiegebiet = (magic_t)ri(F); if (!playerrace(f->race)) { f->lastorders = turn+1; } - if (global.data_version >= KARMA_VERSION) - f->karma = ri(F); - else - f->karma = 0; - - if (global.data_version >= FACTIONFLAGS_VERSION) - f->flags = ri(F); - else - f->flags = 0; + f->karma = ri(F); + f->flags = ri(F); freset(f, FFL_OVERRIDE); - if (global.data_version>=FATTRIBS_VERSION) - a_read(F, &f->attribs); - if (global.data_version>=MSGLEVEL_VERSION) - read_msglevels(&f->warnings, F); + a_read(F, &f->attribs); + read_msglevels(&f->warnings, F); planes = ri(F); while(--planes >= 0) { @@ -2197,55 +2043,35 @@ readfaction(FILE * F) f->options = f->options | Pow(O_REPORT) | Pow(O_ZUGVORLAGE); } - if (global.data_version= (HEX_VERSION-1)) { - int maxopt = ri(F); - for (i=0;i!=maxopt;++i) ri(F); - } else if (global.data_version > 77) { - for (i = 0; i != MAX_MSG; i++) ri(F); - } else { - for (i = 0; i != MAX_MSG - 1; i++) ri(F); - } - } - - if (global.data_version < 79) { /* showdata überspringen */ - assert(!"not implemented"); - } else { - if (global.data_version >= NEWMAGIC && global.data_version < TYPES_VERSION) { - int i, sk = ri(F); /* f->seenspell überspringen */ - for (i = 0; spelldaten[i].id != SPL_NOSPELL; i++) { - if (spelldaten[i].magietyp == f->magiegebiet && spelldaten[i].level <= sk) { - a_add(&f->attribs, a_new(&at_seenspell))->data.i = spelldaten[i].id; - } + if (global.data_version < TYPES_VERSION) { + int i, sk = ri(F); /* f->seenspell überspringen */ + for (i = 0; spelldaten[i].id != SPL_NOSPELL; i++) { + if (spelldaten[i].magietyp == f->magiegebiet && spelldaten[i].level <= sk) { + a_add(&f->attribs, a_new(&at_seenspell))->data.i = spelldaten[i].id; } } } - p = ri(F); sfp = &f->allies; - while (--p >= 0) { - int aid, state; - if (global.data_version>=FULL_BASE36_VERSION) { - aid = rid(F); - } else { - aid = ri(F); + if (global.data_version= 0) { + int aid = rid(F); + int state = ri(F); + addally(f, sfp, aid, state); + } + } else { + for (;;) { + rs(F, buf); + if (strcmp(buf, "end")==0) break; + else { + int aid = atoi36(buf); + int state = ri(F); + addally(f, sfp, aid, state); + } } - state = ri(F); - if (aid==0 || state==0) continue; - sf = (ally *) calloc(1, sizeof(ally)); - - sf->faction = findfaction(aid); - if (!sf->faction) ur_add((void*)aid, (void**)&sf->faction, resolve_faction); - sf->status = state; -#ifndef HELFE_WAHRNEHMUNG - sf->status = sf->status & ~HELP_OBSERVE; -#endif - - addlist2(sfp, sf); } - *sfp = 0; - - if (global.data_version>=GROUPS_VERSION) read_groups(F, f); + read_groups(F, f); return f; } @@ -2257,16 +2083,17 @@ writefaction(FILE * F, const faction * f) wi36(F, f->no); wi(F, f->unique_id); +#if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION + if (f->alliance) wi36(F, f->alliance->id); + else wi36(F, 0); +#endif + ws(F, f->name); ws(F, f->banner); ws(F, f->email); ws(F, f->passw); -#if RELEASE_VERSION>=OVERRIDE_VERSION ws(F, f->override); -#endif -#if RELEASE_VERSION>=LOCALE_VERSION ws(F, locale_name(f->locale)); -#endif wi(F, f->lastorders); wi(F, f->age); ws(F, f->race->_name[0]); @@ -2287,20 +2114,16 @@ writefaction(FILE * F, const faction * f) wnl(F); wi(F, f->options & ~Pow(O_DEBUG)); wnl(F); -#if RELEASE_VERSION < TYPES_VERSION - /* bis zu dieser Stufe sind die Sprüche bekannt */ - wi(F, 0); - wnl(F); -#endif - wi(F, listlen(f->allies)); for (sf = f->allies; sf; sf = sf->next) { int no = (sf->faction!=NULL)?sf->faction->no:0; - wi36(F, no); - wi(F, sf->status); + int status = alliedfaction(NULL, f, sf->faction, HELP_ALL); + if (status!=0) { + wi36(F, no); + wi(F, sf->status); + } } + fprintf(F, "end"); wnl(F); -#if RELEASE_VERSION>=GROUPS_VERSION write_groups(F, f->groups); -#endif } diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index b5103825b..b301c225a 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -38,7 +38,7 @@ ship_typelist *shiptypes = NULL; static local_names * snames; const ship_type * -findshiptype(const char * name, const locale * lang) +findshiptype(const char * name, const struct locale * lang) { local_names * sn = snames; void * i; diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 52037eba9..f52e21d46 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -126,11 +126,7 @@ report_failure(unit * mage, const char * sa) { void do_shock(unit *u, const char *reason) { -#if SKILLPOINTS - skill_t sk; -#else int i; -#endif if(u->number == 0) return; /* HP - Verlust */ @@ -4802,15 +4798,8 @@ sp_calm_monster(castorder *co) static int sp_headache(castorder *co) { -#if SKILLPOINTS - skill_t sk = 0; - skill_t i; - int sk_val = 0; - int days; -#else skill * smax = NULL; int i; -#endif unit *target; region *r = co->rt; unit *mage = (unit *)co->magician; @@ -4825,19 +4814,6 @@ sp_headache(castorder *co) target = pa->param[0]->data.u; /* Zieleinheit */ -#if SKILLPOINTS - /* finde das größte Talent: */ - for (i=0;inumber) * lovar(60); - change_skill(target, sk, -days); -#else /* finde das größte Talent: */ for (i=0;i!=target->skill_size;++i) { skill * sv = target->skills+i; @@ -4850,7 +4826,6 @@ sp_headache(castorder *co) int change = min(10, target->number) * (rand()%2+1) / target->number; reduce_skill(target, smax, change); } -#endif set_string(&target->thisorder, ""); sprintf(buf, "%s verschafft %s einige feuchtfröhliche Stunden mit heftigen " @@ -6229,6 +6204,7 @@ sp_fetchastral(castorder *co) int sp_showastral(castorder *co) { +#if 0 unit *u; region *rt; int n = 0; @@ -6239,8 +6215,6 @@ sp_showastral(castorder *co) int cast_level = co->level; int power = co->force; - return 0; - switch(getplaneid(r)) { case 0: rt = r_standard_to_astral(r); @@ -6314,6 +6288,10 @@ sp_showastral(castorder *co) free_regionlist(rl); return cast_level; +#else + unused(co); + return 0; +#endif } /* ------------------------------------------------------------- */ diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index a4703f89a..18ad842f3 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -420,7 +420,7 @@ ucontact(const unit * u, const unit * u2) attrib *ru; /* Alliierte kontaktieren immer */ - if (allied(u, u2->faction, HELP_GIVE) == HELP_GIVE) + if (alliedunit(u, u2->faction, HELP_GIVE) == HELP_GIVE) return true; /* Explizites KONTAKTIERE */ @@ -978,11 +978,11 @@ att_modification(const unit *u, skill_t sk) int mod = c->effect; unit * mage = c->magician; /* wir suchen jeweils den größten Bonus und den größten Malus */ - if (mod>0 && (mage==NULL || allied(mage, u->faction, HELP_GUARD))) + if (mod>0 && (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD))) { if (mod > bonus ) bonus = mod; } else if (mod < 0 && - (mage == NULL || !allied(mage, u->faction, HELP_GUARD))) + (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD))) { if (mod < malus ) malus = mod; } diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index 2ce19371e..2b47c93c7 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -150,9 +150,7 @@ extern void u_setfaction(struct unit * u, struct faction * f); /* vorsicht Sprüche können u->number == 0 (RS_FARVISION) haben! */ extern void set_number(struct unit * u, int count); -#if !SKILLPOINTS extern boolean learn_skill(struct unit * u, skill_t sk, double chance); -#endif extern int invisible(const unit *u); diff --git a/src/common/modules/alliance.c b/src/common/modules/alliance.c index c5636ee94..194b28ec7 100644 --- a/src/common/modules/alliance.c +++ b/src/common/modules/alliance.c @@ -16,13 +16,18 @@ #include "command.h" /* kernel includes */ +#include #include #include #include #include +/* gamecode includes */ +#include /* for destroyfaction */ + /* util includes */ #include +#include /* libc includes */ #include @@ -79,11 +84,12 @@ add_kick(attrib * a, const faction * f) } static void -alliance_kick(const char * str, void * data, const char * cmd) +alliance_kick(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; faction * f = findfaction(atoi36(igetstrtoken(str))); attrib * a; + unused(tnext); if (f==NULL || f->alliance!=u->faction->alliance) { /* does not belong to our alliance */ @@ -95,11 +101,12 @@ alliance_kick(const char * str, void * data, const char * cmd) } static void -alliance_join(const char * str, void * data, const char * cmd) +alliance_join(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; alliance * al = findalliance(atoi36(igetstrtoken(str))); - + unused(tnext); + if (u->faction->alliance!=NULL || al==NULL) { /* not found */ return; @@ -108,15 +115,8 @@ alliance_join(const char * str, void * data, const char * cmd) /* inform the rest? */ } -static tnode * g_keys; static void -alliance_command(const char * str, void * data, const char * cmd) -{ - do_command(g_keys, data, str); -} - -static void -execute(tnode * root) +execute(const struct syntaxtree * syntax) { region ** rp = ®ions; while (*rp) { @@ -124,9 +124,11 @@ execute(tnode * root) unit **up = &r->units; while (*up) { unit * u = *up; + const struct locale * lang = u->faction->locale; + tnode * root = stree_find(syntax, lang); strlist * order; for (order = u->orders; order; order = order->next) { - if (igetkeyword(order->s, u->faction->locale) == K_ALLIANCE) { + if (igetkeyword(order->s, lang) == K_ALLIANCE) { do_command(root, u, order->s); } } @@ -137,24 +139,139 @@ execute(tnode * root) } void -alliancejoin(void) +alliancekick(void) { - tnode root; - add_command(&root, "alliance", &alliance_command); - g_keys = calloc(1, sizeof(tnode)); - add_command(g_keys, "join", &alliance_join); - execute(&root); - free(g_keys); + static syntaxtree * stree = NULL; + faction * f = factions; + if (stree==NULL) { + syntaxtree * slang = stree = stree_create(); + while (slang) { + struct tnode * root = calloc(sizeof(tnode), 1); + struct tnode * leaf = calloc(sizeof(tnode), 1); + add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); + add_command(leaf, NULL, LOC(slang->lang, "kick"), &alliance_kick); + slang = slang->next; + } + } + execute(stree); + while (f) { + attrib * a = a_find(f->attribs, &at_kick); + if (a!=NULL) { + faction_list * flist = (faction_list*)a->data.v; + if (flist!=NULL) { + unsigned int votes = listlen(flist); + unsigned int size = listlen(f->alliance->members); + if (size<=votes*2) { + f->alliance = NULL; + /* tell him he's been kicked */ + for (flist=f->alliance->members;flist;flist=flist->next) { + ADDMSG(&flist->data->msgs, msg_message("alliance::kickedout", + "member alliance votes", f, f->alliance, votes)); + } + } else { + /* warn that he's been attempted to kick */ + for (flist=f->alliance->members;flist;flist=flist->next) { + ADDMSG(&flist->data->msgs, msg_message("alliance::kickattempt", + "member alliance votes", f, f->alliance, votes)); + } + } + } + } + f = f->next; + } + /* some may have been kicked, must remove f->alliance==NULL */ } void -alliancekick(void) +alliancejoin(void) { - tnode root; - add_command(&root, "alliance", &alliance_command); - g_keys = calloc(1, sizeof(tnode)); - add_command(g_keys, "kick", &alliance_kick); - execute(&root); - free(g_keys); + static syntaxtree * stree = NULL; + if (stree==NULL) { + syntaxtree * slang = stree = stree_create(); + while (slang) { + struct tnode * root = calloc(sizeof(tnode), 1); + struct tnode * leaf = calloc(sizeof(tnode), 1); + add_command(root, leaf, LOC(slang->lang, "alliance"), NULL); + add_command(leaf, NULL, LOC(slang->lang, "join"), &alliance_join); + slang = slang->next; + } + } + execute(stree); } +void +setalliance(struct faction * f, alliance * al) +{ + if (f->alliance==al) return; + if (f->alliance!=NULL) { + faction_list ** flistp = &f->alliance->members; + while (*flistp) { + if ((*flistp)->data==f) { + *flistp = (*flistp)->next; + break; + } + flistp = &(*flistp)->next; + } + } + f->alliance = al; + if (al!=NULL) { + faction_list * flist = calloc(sizeof(faction_list), 1); + flist->next = al->members; + flist->data = f; + al->members = flist; + } +} + +const char * +alliancename(const alliance * al) +{ + typedef char name[OBJECTIDSIZE + 1]; + static name idbuf[8]; + static int nextbuf = 0; + + char *buf = idbuf[(++nextbuf) % 8]; + + if (al && al->name) { + sprintf(buf, "%s (%s)", strcheck(al->name, NAMESIZE), itoa36(al->id)); + } else { + return NULL; + } + return buf; +} + +void +alliancevictory(void) +{ + const struct building_type * btype = bt_find("stronghold"); + region * r = regions; + alliance * al = alliances; + while (r!=NULL) { + building * b = r->buildings; + while (b!=NULL) { + if (b->type==btype) { + unit * u = buildingowner(r, b); + if (u) { + fset(u->faction->alliance, FL_MARK); + } + } + b = b->next; + } + r=r->next; + } + while (al!=NULL) { + if (!fval(al, FL_MARK)) { + faction_list * flist = al->members; + while (flist!=0) { + faction * f = flist->data; + if (f->alliance==al) { + ADDMSG(&f->msgs, msg_message("alliance::lost", + "alliance", al)); + destroyfaction(f); + } + flist = flist->next; + } + } else { + freset(al, FL_MARK); + } + } +} diff --git a/src/common/modules/alliance.h b/src/common/modules/alliance.h index 4cf726832..e25a58358 100644 --- a/src/common/modules/alliance.h +++ b/src/common/modules/alliance.h @@ -17,9 +17,12 @@ struct attrib; struct unit; struct faction; struct region; +struct faction_list; typedef struct alliance { struct alliance * next; + struct faction_list * members; + unsigned int flags; int id; char * name; } alliance; @@ -27,8 +30,11 @@ typedef struct alliance { extern alliance * alliances; extern alliance * findalliance(int id); extern alliance * makealliance(int id, const char * name); +extern const char * alliancename(const struct alliance * al); +extern void setalliance(struct faction * f, alliance * al); extern void alliancejoin(void); extern void alliancekick(void); +extern void alliancevictory(void); /* execute commands */ diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 27d6983dc..93e353d60 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -129,7 +129,7 @@ make_atgmcreate(const struct item_type * itype) } static void -gm_create(const char * str, void * data, const char * cmd) +gm_create(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; int i; @@ -165,7 +165,7 @@ has_permission(const attrib * permissions, unsigned int key) ** requires: permission-key "gmgate" **/ static void -gm_gate(const char * str, void * data, const char * cmd) +gm_gate(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -198,7 +198,7 @@ gm_gate(const char * str, void * data, const char * cmd) ** requires: permission-key "gmterf" **/ static void -gm_terraform(const char * str, void * data, const char * cmd) +gm_terraform(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -226,7 +226,7 @@ gm_terraform(const char * str, void * data, const char * cmd) ** requires: permission-key "gmtele" **/ static void -gm_teleport(const char * str, void * data, const char * cmd) +gm_teleport(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -256,7 +256,7 @@ gm_teleport(const char * str, void * data, const char * cmd) ** requires: permission-key "gmmsgr" **/ static void -gm_messageplane(const char * str, void * data, const char * cmd) +gm_messageplane(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -291,7 +291,7 @@ gm_messageplane(const char * str, void * data, const char * cmd) } static void -gm_messagefaction(const char * str, void * data, const char * cmd) +gm_messagefaction(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; int n = atoi36(igetstrtoken(str)); @@ -321,7 +321,7 @@ gm_messagefaction(const char * str, void * data, const char * cmd) ** requires: permission-key "gmmsgr" **/ static void -gm_messageregion(const char * str, void * data, const char * cmd) +gm_messageregion(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -349,7 +349,7 @@ gm_messageregion(const char * str, void * data, const char * cmd) ** requires: permission-key "gmkill" **/ static void -gm_killunit(const char * str, void * data, const char * cmd) +gm_killunit(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -380,7 +380,7 @@ gm_killunit(const char * str, void * data, const char * cmd) ** requires: permission-key "gmmsgr" **/ static void -gm_killfaction(const char * str, void * data, const char * cmd) +gm_killfaction(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; int n = atoi36(igetstrtoken(str)); @@ -415,7 +415,7 @@ gm_killfaction(const char * str, void * data, const char * cmd) ** requires: permission-key "gmmsgr" **/ static void -gm_messageunit(const char * str, void * data, const char * cmd) +gm_messageunit(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; const struct plane * p = rplane(u->region); @@ -451,7 +451,7 @@ gm_messageunit(const char * str, void * data, const char * cmd) ** requires: permission-key "gmgive" **/ static void -gm_give(const char * str, void * data, const char * cmd) +gm_give(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; unit * to = findunit(atoi36(igetstrtoken(str))); @@ -486,7 +486,7 @@ gm_give(const char * str, void * data, const char * cmd) ** requires: permission-key "gmtake" **/ static void -gm_take(const char * str, void * data, const char * cmd) +gm_take(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; unit * to = findunit(atoi36(igetstrtoken(str))); @@ -521,7 +521,7 @@ gm_take(const char * str, void * data, const char * cmd) ** requires: permission-key "gmskil" **/ static void -gm_skill(const char * str, void * data, const char * cmd) +gm_skill(const tnode * tnext, const char * str, void * data, const char * cmd) { unit * u = (unit*)data; unit * to = findunit(atoi36(igetstrtoken(str))); @@ -534,7 +534,7 @@ gm_skill(const char * str, void * data, const char * cmd) } else if (skill==NOSKILL || skill==SK_MAGIC || skill==SK_ALCHEMY) { /* unknown or not enough */ mistake(u, cmd, "Dieses Talent ist unbekannt, oder kann nicht erhöht werden.\n", 0); - } else if (num<0 || num>30+SKILLPOINTS*4970) { + } else if (num<0 || num>30) { /* sanity check failed */ mistake(u, cmd, "Der gewählte Wert ist nicht zugelassen.\n", 0); } else { @@ -554,45 +554,27 @@ static tnode g_root; static tnode g_tell; static tnode g_kill; -static void -gm_command(const char * str, void * data, const char * cmd) -{ - do_command(&g_keys, data, str); -} - -static void -gm_tell(const char * str, void * data, const char * cmd) -{ - do_command(&g_tell, data, str); -} - -static void -gm_kill(const char * str, void * data, const char * cmd) -{ - do_command(&g_kill, data, str); -} - void init_gmcmd(void) { at_register(&at_gmcreate); at_register(&at_permissions); - add_command(&g_root, "gm", &gm_command); - add_command(&g_keys, "terraform", &gm_terraform); - add_command(&g_keys, "create", &gm_create); - add_command(&g_keys, "gate", &gm_gate); - add_command(&g_keys, "give", &gm_give); - add_command(&g_keys, "take", &gm_take); - add_command(&g_keys, "teleport", &gm_teleport); - add_command(&g_keys, "skill", &gm_skill); - add_command(&g_keys, "tell", &gm_tell); - add_command(&g_tell, "region", &gm_messageregion); - add_command(&g_tell, "unit", &gm_messageunit); - add_command(&g_tell, "plane", &gm_messageplane); - add_command(&g_tell, "faction", &gm_messagefaction); - add_command(&g_keys, "kill", &gm_kill); - add_command(&g_kill, "unit", &gm_killunit); - add_command(&g_kill, "faction", &gm_killfaction); + add_command(&g_root, &g_keys, "gm", NULL); + add_command(&g_keys, NULL, "terraform", &gm_terraform); + add_command(&g_keys, NULL, "create", &gm_create); + add_command(&g_keys, NULL, "gate", &gm_gate); + add_command(&g_keys, NULL, "give", &gm_give); + add_command(&g_keys, NULL, "take", &gm_take); + add_command(&g_keys, NULL, "teleport", &gm_teleport); + add_command(&g_keys, NULL, "skill", &gm_skill); + add_command(&g_keys, &g_tell, "tell", NULL); + add_command(&g_tell, NULL, "region", &gm_messageregion); + add_command(&g_tell, NULL, "unit", &gm_messageunit); + add_command(&g_tell, NULL, "plane", &gm_messageplane); + add_command(&g_tell, NULL, "faction", &gm_messagefaction); + add_command(&g_keys, &g_kill, "kill", NULL); + add_command(&g_kill, NULL, "unit", &gm_killunit); + add_command(&g_kill, NULL, "faction", &gm_killfaction); } /* diff --git a/src/common/modules/infocmd.c b/src/common/modules/infocmd.c index 55302c220..09e68290c 100644 --- a/src/common/modules/infocmd.c +++ b/src/common/modules/infocmd.c @@ -33,7 +33,7 @@ #include static void -info_email(const char * str, void * data, const char * cmd) +info_email(const tnode * tnext, const char * str, void * data, const char * cmd) { unused(str); unused(data); @@ -41,14 +41,17 @@ info_email(const char * str, void * data, const char * cmd) } static void -info_name(const char * str, void * data, const char * cmd) +info_name(const tnode * tnext, const char * str, void * data, const char * cmd) { - unit * u = (unit*)data; - faction * f = u->faction; - const char * name = sqlquote(igetstrtoken(str)); - + unused(tnext); + unused(str); + unused(data); + unused(cmd); if (sqlstream!=NULL) { #ifdef SQLOUTPUT + unit * u = (unit*)data; + const char * name = sqlquote(igetstrtoken(str)); + faction * f = u->faction; fprintf(sqlstream, "UPDATE users SET firstname = '%s' WHERE id = %u;\n", name, f->unique_id); #endif @@ -56,14 +59,13 @@ info_name(const char * str, void * data, const char * cmd) } static void -info_address(const char * str, void * data, const char * cmd) +info_address(const tnode * tnext, const char * str, void * data, const char * cmd) { - unit * u = (unit*)data; - faction * f = u->faction; - const char * address = sqlquote(igetstrtoken(str)); - if (sqlstream!=NULL) { #ifdef SQLOUTPUT + unit * u = (unit*)data; + faction * f = u->faction; + const char * address = sqlquote(igetstrtoken(str)); fprintf(sqlstream, "UPDATE users SET address = '%s' WHERE id = %u;\n", address, f->unique_id); #endif @@ -71,14 +73,13 @@ info_address(const char * str, void * data, const char * cmd) } static void -info_phone(const char * str, void * data, const char * cmd) +info_phone(const tnode * tnext, const char * str, void * data, const char * cmd) { - unit * u = (unit*)data; - faction * f = u->faction; - const char * phone = sqlquote(igetstrtoken(str)); - if (sqlstream!=NULL) { #ifdef SQLOUTPUT + unit * u = (unit*)data; + faction * f = u->faction; + const char * phone = sqlquote(igetstrtoken(str)); fprintf(sqlstream, "UPDATE users SET phone = '%s' WHERE id = %u;\n", phone, f->unique_id); #endif @@ -86,19 +87,19 @@ info_phone(const char * str, void * data, const char * cmd) } static void -info_vacation(const char * str, void * data, const char * cmd) +info_vacation(const tnode * tnext, const char * str, void * data, const char * cmd) { - unit * u = (unit*)data; - faction * f = u->faction; - const char * email = sqlquote(igetstrtoken(str)); - int duration = atoi(getstrtoken()); - time_t start_time = time(NULL); - time_t end_time = start_time + 60*60*24*duration; - struct tm start = *localtime(&start_time); - struct tm end = *localtime(&end_time); if (sqlstream!=NULL) { #ifdef SQLOUTPUT + unit * u = (unit*)data; + faction * f = u->faction; + const char * email = sqlquote(igetstrtoken(str)); + int duration = atoi(getstrtoken()); + time_t start_time = time(NULL); + time_t end_time = start_time + 60*60*24*duration; + struct tm start = *localtime(&start_time); + struct tm end = *localtime(&end_time); fprintf(sqlstream, "UPDATE factions SET vacation = '%s' WHERE id = '%s';\n", email, itoa36(f->no)); fprintf(sqlstream, "UPDATE factions SET vacation_start = '%04d-%02d-%02d' WHERE id = '%s';\n", start.tm_year, start.tm_mon, start.tm_mday, itoa36(f->no)); @@ -109,6 +110,7 @@ info_vacation(const char * str, void * data, const char * cmd) } static tnode g_keys; +static tnode g_info; void infocommands(void) @@ -131,20 +133,14 @@ infocommands(void) fflush(sqlstream); } -static void -info_command(const char * str, void * data, const char * cmd) -{ - do_command(&g_keys, data, str); -} - void init_info(void) { - add_command(&g_keys, "info", &info_command); + add_command(&g_keys, &g_info, "info", NULL); - add_command(&g_keys, "email", &info_email); - add_command(&g_keys, "name", &info_name); - add_command(&g_keys, "adresse", &info_address); - add_command(&g_keys, "telefon", &info_phone); - add_command(&g_keys, "urlaub", &info_vacation); + add_command(&g_info, NULL, "email", &info_email); + add_command(&g_info, NULL, "name", &info_name); + add_command(&g_info, NULL, "adresse", &info_address); + add_command(&g_info, NULL, "telefon", &info_phone); + add_command(&g_info, NULL, "urlaub", &info_vacation); } diff --git a/src/common/modules/museum.c b/src/common/modules/museum.c index d006f4b4d..6f2422d8f 100644 --- a/src/common/modules/museum.c +++ b/src/common/modules/museum.c @@ -42,6 +42,11 @@ #include #include +#define PFL_MUSEUM PFL_NOMONSTERS | PFL_NOCOORDS | PFL_NORECRUITS | PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED + +static int use_museumticket(unit *, const struct item_type *, int, const char *); +static int use_museumexitticket(unit *, const struct item_type *, int, const char *); + resource_type rt_museumticket = { { "museumticket", "museumticket_p"}, { "museumticket", "museumticket_p"}, @@ -316,7 +321,7 @@ create_museum(void) } } -int +static int use_museumticket(unit *u, const struct item_type *itype, int amount, const char * cmd) { attrib *a; @@ -357,7 +362,7 @@ use_museumticket(unit *u, const struct item_type *itype, int amount, const char return 1; } -int +static int use_museumexitticket(unit *u, const struct item_type *itype, int amount, const char * cmd) { attrib *a; @@ -408,4 +413,3 @@ use_museumexitticket(unit *u, const struct item_type *itype, int amount, const c return 1; } - diff --git a/src/common/modules/museum.h b/src/common/modules/museum.h index 33ff3f61b..e3f91054f 100644 --- a/src/common/modules/museum.h +++ b/src/common/modules/museum.h @@ -27,9 +27,7 @@ typedef struct { struct item *items; } museumgiveback; -void warden_add_give(struct unit *src, struct unit *u, const struct item_type *itype, int n); -void init_museum(void); -void create_museum(void); -int use_museumticket(struct unit *u, const struct item_type *itype, int amount, const char *cmd); -int use_museumexitticket(struct unit *u, const struct item_type *itype, int amount, const char * cmd); +extern void warden_add_give(struct unit *src, struct unit *u, const struct item_type *itype, int n); +extern void init_museum(void); +extern void create_museum(void); diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index 4249c46f5..e8cd1b276 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -2,7 +2,7 @@ +-------------------+ Christian Schlittchen | | Enno Rehling | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2001 | Henning Peters + | (c) 1998 - 2002 | Henning Peters | | Ingo Wilken +-------------------+ Stefan Reich @@ -14,28 +14,33 @@ * Contains defines for the "free" game (Eressea) . * Include this file from settings.h to make eressea work. */ -#define GAME_ID 0 -#define IMMUN_GEGEN_ANGRIFF 8 -#define RESOURCE_CONVERSION 1 -#define NEW_RESOURCEGROWTH 1 -#define LARGE_CASTLES 1 -#define GROWING_TREES 1 -#define REMOVENMRNEWBIE 1 -#define NMRTIMEOUT 4 -#define HUNGER_DISABLES_LONGORDERS 1 -#define REDUCED_PEASANTGROWTH 1 -#define RACE_ADJUSTMENTS 1 -#define TEACHDIFFERENCE 2 -#define PEASANT_ADJUSTMENT 1 -#define SKILLPOINTS 0 -#define NEW_MIGRATION 1 -#define PEASANTS_DO_NOT_STARVE 0 -#define GUARD_DISABLES_RECRUIT 1 -#define GUARD_DISABLES_PRODUCTION 1 -#define RESOURCE_QUANTITY 0.5 -#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define CATAPULT_AMMUNITION 1 /* Gebaut werden kann sie auch mit 0! */ #define CHANGED_CROSSBOWS 1 #define COMBAT_TURNS 5 +#define ENTERTAINBASE 0 +#define ENTERTAINPERLEVEL 20 +#define ENTERTAINFRACTION 20 +#define GAME_ID 0 +#define GROWING_TREES 1 +#define GUARD_DISABLES_PRODUCTION 1 +#define GUARD_DISABLES_RECRUIT 1 +#define HUNGER_DISABLES_LONGORDERS 1 +#define IMMUN_GEGEN_ANGRIFF 8 +#define LARGE_CASTLES 1 +#define NEW_MIGRATION 1 +#define NEW_RESOURCEGROWTH 1 +#define NMRTIMEOUT 4 +#define PEASANTS_DO_NOT_STARVE 0 +#define PEASANT_ADJUSTMENT 1 +#define RACE_ADJUSTMENTS 1 +#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ +#define REDUCED_PEASANTGROWTH 1 +#define REMOVENMRNEWBIE 1 +#define RESOURCE_CONVERSION 1 +#define RESOURCE_QUANTITY 0.5 +#define TEACHDIFFERENCE 2 + +#define MUSEUM_MODULE +#define ARENA_MODULE #define MAILITPATH "/usr/sbin:$HOME/eressea/bin:/bin:/usr/bin:/usr/local/bin" diff --git a/src/common/settings-tutorial.h b/src/common/settings-tutorial.h index 70a1e448a..c1953df50 100644 --- a/src/common/settings-tutorial.h +++ b/src/common/settings-tutorial.h @@ -27,7 +27,6 @@ #define RACE_ADJUSTMENTS 1 #define TEACHDIFFERENCE 2 #define PEASANT_ADJUSTMENT 1 -#define SKILLPOINTS 0 #define NEW_MIGRATION 1 #define PEASANTS_DO_NOT_STARVE 0 #define GUARD_DISABLES_RECRUIT 0 diff --git a/src/common/settings-vinyambar-3.h b/src/common/settings-vinyambar-3.h new file mode 100644 index 000000000..0d1304fbf --- /dev/null +++ b/src/common/settings-vinyambar-3.h @@ -0,0 +1,47 @@ +/* vi: set ts=2: + +-------------------+ Christian Schlittchen + | | Enno Rehling + | Eressea PBEM host | Katja Zedel + | (c) 1998 - 2002 | Henning Peters + | | Ingo Wilken + +-------------------+ Stefan Reich + + This program may not be used, modified or distributed + without prior permission by the authors of Eressea. +*/ + +/* + * Contains defines for the "alliance" vinyambar game (V3). + * Include this file from settings.h to make eressea work. + */ +#define CATAPULT_AMMUNITION 1 /* Gebaut werden kann sie auch mit 0! */ +#define CHANGED_CROSSBOWS 1 +#define COMBAT_TURNS 5 +#define ENTERTAINBASE 15 +#define ENTERTAINPERLEVEL 5 +#define ENTERTAINFRACTION 20 +#define GAME_ID 3 +#define GROWING_TREES 1 +#define GUARD_DISABLES_PRODUCTION 1 +#define GUARD_DISABLES_RECRUIT 1 +#define HUNGER_DISABLES_LONGORDERS 1 +#define IMMUN_GEGEN_ANGRIFF 8 +#define LARGE_CASTLES 1 +#define NEW_MIGRATION 1 +#define NEW_RESOURCEGROWTH 1 +#define NMRTIMEOUT 5 +#define PEASANTS_DO_NOT_STARVE 0 +#define PEASANT_ADJUSTMENT 1 +#define RACE_ADJUSTMENTS 1 +#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ +#define REDUCED_PEASANTGROWTH 1 +#define REMOVENMRNEWBIE 0 +#define RESOURCE_CONVERSION 1 +#define RESOURCE_QUANTITY 0.5 +#define TEACHDIFFERENCE 2 + +#define ALLIANCES +#undef ALLIANCEJOIN +#define AUTOALLIANCE (HELP_FIGHT) + +#define MAILITPATH "/usr/sbin:$HOME/bin:/bin:/usr/bin:/usr/local/bin" diff --git a/src/common/settings-vinyambar-classic.h b/src/common/settings-vinyambar-classic.h index 1d7f182fd..8e8e62883 100644 --- a/src/common/settings-vinyambar-classic.h +++ b/src/common/settings-vinyambar-classic.h @@ -25,7 +25,6 @@ #define HUNGER_DISABLES_LONGORDERS 1 #define REDUCED_PEASANTGROWTH 0 #define RACE_ADJUSTMENTS 0 -#define SKILLPOINTS 1 #define TEACHDIFFERENCE 1 #define PEASANT_ADJUSTMENT 0 #define GUARD_DISABLES_RECRUIT 0 diff --git a/src/common/settings-vinyambar-murder.h b/src/common/settings-vinyambar-murder.h index 8216cee02..e23413513 100644 --- a/src/common/settings-vinyambar-murder.h +++ b/src/common/settings-vinyambar-murder.h @@ -27,7 +27,6 @@ #define RACE_ADJUSTMENTS 1 #define TEACHDIFFERENCE 2 #define PEASANT_ADJUSTMENT 1 -#define SKILLPOINTS 0 #define NEW_MIGRATION 1 #define PEASANTS_DO_NOT_STARVE 0 #define GUARD_DISABLES_RECRUIT 1 diff --git a/src/common/settings-vinyambar.h b/src/common/settings-vinyambar.h index 579ddb378..68e38b4d1 100644 --- a/src/common/settings-vinyambar.h +++ b/src/common/settings-vinyambar.h @@ -25,7 +25,6 @@ #define HUNGER_DISABLES_LONGORDERS 0 #define REDUCED_PEASANTGROWTH 0 #define RACE_ADJUSTMENTS 0 -#define SKILLPOINTS 1 #define TEACHDIFFERENCE 1 #define PEASANT_ADJUSTMENT 0 #define GUARD_DISABLES_RECRUIT 0 diff --git a/src/common/spells/buildingcurse.c b/src/common/spells/buildingcurse.c index daaaf96e7..be5bcc439 100644 --- a/src/common/spells/buildingcurse.c +++ b/src/common/spells/buildingcurse.c @@ -34,7 +34,7 @@ int -cinfo_building(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_building(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; diff --git a/src/common/spells/regioncurse.c b/src/common/spells/regioncurse.c index 36eb7968a..dc7f7e906 100644 --- a/src/common/spells/regioncurse.c +++ b/src/common/spells/regioncurse.c @@ -63,7 +63,7 @@ cinfo_region(const struct locale * lang, const void * obj, typ_t typ, struct cur * godcursezone */ static int -cinfo_cursed_by_the_gods(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_cursed_by_the_gods(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { region *r; message * msg; @@ -99,7 +99,7 @@ static struct curse_type ct_godcursezone = { * C_GBDREAM */ static int -cinfo_dreamcurse(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_dreamcurse(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; @@ -131,7 +131,7 @@ static struct curse_type ct_gbdream = { * erzeugt Straßennetz */ static int -cinfo_magicstreet(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_magicstreet(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; @@ -164,7 +164,7 @@ static struct curse_type ct_magicstreet = { /* --------------------------------------------------------------------- */ static int -cinfo_antimagiczone(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_antimagiczone(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; @@ -221,7 +221,7 @@ cansee_antimagiczone(const struct faction *viewer, curse *c, const void * obj, t /* --------------------------------------------------------------------- */ static int -cinfo_farvision(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_farvision(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; diff --git a/src/common/spells/shipcurse.c b/src/common/spells/shipcurse.c index 32d220553..596a6e2c9 100644 --- a/src/common/spells/shipcurse.c +++ b/src/common/spells/shipcurse.c @@ -33,7 +33,7 @@ int -cinfo_ship(const locale * lang, const void * obj, typ_t typ, curse *c, int self) +cinfo_ship(const struct locale * lang, const void * obj, typ_t typ, curse *c, int self) { message * msg; @@ -55,7 +55,7 @@ cinfo_ship(const locale * lang, const void * obj, typ_t typ, curse *c, int self) /* C_SHIP_NODRIFT */ static int -cinfo_shipnodrift(const locale * lang, void * obj, typ_t typ, curse *c, int self) +cinfo_shipnodrift(const struct locale * lang, void * obj, typ_t typ, curse *c, int self) { ship * sh; unused(typ); diff --git a/src/common/util/base36.c b/src/common/util/base36.c index 87bd1b28e..b55718afb 100644 --- a/src/common/util/base36.c +++ b/src/common/util/base36.c @@ -25,20 +25,12 @@ #include #include -int -atoi36(const char * s) -{ - char * p = NULL; - int i = (int)(strtol(s, &p, 36)); - if (*p || i<0) return -1; - return i; -} - -#if 0 #include int -atoi36(const char * s) +atoi36(const char * str) { + /* cannot use strtol, becuase invalid strings will cause crash */ + const unsigned char * s = (const unsigned char *)str; int i = 0; assert(s); if(!(*s)) return 0; @@ -48,13 +40,12 @@ atoi36(const char * s) if (isupper((int)*s)) i = i*36 + (*s)-'A' + 10; else if (islower((int)*s)) i=i*36 + (*s)-'a' + 10; else if (isdigit((int)*s)) i=i*36 + (*s)-'0'; - else return -1; + else return 0; ++s; } - if (i<0 || !isspace(*s) && *s!='0') return -1; + if (i<0 || (!isspace(*s) && *s!='\0')) return 0; return i; } -#endif const char* itoab(int i, int base) diff --git a/src/common/util/command.c b/src/common/util/command.c index 3ac282632..1eda997d4 100644 --- a/src/common/util/command.c +++ b/src/common/util/command.c @@ -11,29 +11,58 @@ */ #include - #include "command.h" #include "umlaut.h" +#include "language.h" /* libc includes */ +#include #include #include #include typedef struct command { - void(*fun)(const char*, void *, const char*); + parser fun; + struct tnode * nodes; } command; +tnode * +stree_find(const syntaxtree * stree, const struct locale * lang) +{ + while (stree) { + if (stree->lang==lang) return stree->root; + stree = stree->next; + } + return NULL; +} + +syntaxtree * +stree_create(void) +{ + syntaxtree * sroot = NULL; + const struct locale * lang = locales; + while (lang) { + syntaxtree * stree = malloc(sizeof(syntaxtree)); + stree->lang = lang; + stree->next = sroot; + sroot=stree; + lang=nextlocale(lang); + } + return sroot; +} + void -add_command(struct tnode * keys, const char * str, void(*fun)(const char*, void *, const char*)) +add_command(struct tnode * keys, struct tnode * tnext, + const char * str, parser fun) { command * cmd = malloc(sizeof(command)); cmd->fun = fun; + cmd->nodes = tnext; addtoken(keys, str, (void*)cmd); } -int +void do_command(const struct tnode * keys, void * u, const char * str) { int i; @@ -48,8 +77,13 @@ do_command(const struct tnode * keys, void * u, const char * str) strncpy(zText, str, i); zText[i]=0; if (findtoken(keys, zText, (void**)&cmd)==E_TOK_SUCCESS) { - cmd->fun(++c, u, str); - return 0; + if (cmd->nodes) { + assert(!cmd->fun); + do_command(cmd->nodes, u, ++c); + return; + } + assert(cmd->fun); + cmd->fun(cmd->nodes, ++c, u, str); } - return 1; + return; } diff --git a/src/common/util/command.h b/src/common/util/command.h index 19a1ecc1d..b494d880c 100644 --- a/src/common/util/command.h +++ b/src/common/util/command.h @@ -14,9 +14,23 @@ #define COMMAND_H struct tnode; +struct locale; -extern void add_command(struct tnode * keys, const char * str, - void(*fun)(const char*, void *, const char*)); -extern int do_command(const struct tnode * keys, void * u, const char * cmd); +typedef struct syntaxtree { + const struct locale * lang; + struct tnode * root; + struct syntaxtree * next; +} syntaxtree; + +typedef void (*parser)(const struct tnode *, const char*, void *, const char*); +extern void add_command(struct tnode * troot, + struct tnode * tnext, + const char * str, + parser fun); +extern void do_command(const struct tnode * troot, void * u, + const char * cmd); + +extern struct syntaxtree * stree_create(void); +extern struct tnode * stree_find(const struct syntaxtree * stree, const struct locale * lang); #endif diff --git a/src/common/util/language.c b/src/common/util/language.c index 2e789190b..413e90800 100644 --- a/src/common/util/language.c +++ b/src/common/util/language.c @@ -26,7 +26,7 @@ /** importing **/ -struct locale { +typedef struct locale { struct locale * next; unsigned int hashkey; const char * name; @@ -36,10 +36,10 @@ struct locale { char * str; char * key; } * strings[SMAXHASH]; -}; +} locale; locale * default_locale; -static locale * locales; +locale * locales; unsigned int locale_hashkey(const locale * lang) @@ -193,3 +193,9 @@ mkname(const char * space, const char * name) } return zBuffer; } + +locale * +nextlocale(const struct locale * lang) +{ + return lang->next; +} \ No newline at end of file diff --git a/src/common/util/language.h b/src/common/util/language.h index 8c0cfef0d..4e9bb4bb5 100644 --- a/src/common/util/language.h +++ b/src/common/util/language.h @@ -14,11 +14,11 @@ #ifndef MY_LOCALE_H #define MY_LOCALE_H -typedef struct locale locale; +struct locale; /** managing multiple locales: **/ -extern locale * find_locale(const char * name); -extern locale * make_locale(const char * key); +extern struct locale * find_locale(const char * name); +extern struct locale * make_locale(const char * key); /** operations on locales: **/ extern void locale_setstring(struct locale * lang, const char * key, const char * value); @@ -34,6 +34,8 @@ extern void debug_language(const char * log); #define LOC(lang, s) locale_string(lang, s) -extern locale * default_locale; +extern struct locale * default_locale; +extern struct locale * locales; +extern struct locale * nextlocale(const struct locale * lang); #endif diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 0bbd965d0..07f0c671e 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -23,12 +23,14 @@ /* misc includes */ #include -#include -#include -#include -#include #include #include +#include +#include +#include +#ifdef ALLIANCES +#include +#endif /* gamecode includes */ #include @@ -85,6 +87,48 @@ extern void reorder_owners(struct region * r); +#ifdef ALLIANCES +#define MAXALLIANCES 3 +static void +init_alliances(void) +{ + faction * f = factions; + alliance * aalliance[MAXALLIANCES]; + if (alliances==NULL) { + aalliance[0] = makealliance(atoi36("dark"), "Ritter der dunklen Sonne"); + aalliance[1] = makealliance(atoi36("deep"), "Monster aus der Tiefe"); + aalliance[2] = makealliance(atoi36("pope"), "Priester des Vatikan"); + } + while (f!=NULL) { + if (f->alliance==NULL && f->no!=MONSTER_FACTION) { + setalliance(f, aalliance[rand() % MAXALLIANCES]); + } + f=f->next; + } +} +#endif + +static int +curse_emptiness(void) +{ + const curse_type * ct = ct_find("godcursezone"); + region * r = regions; + while (r!=NULL) { + if (r->land && r->age>120 && !get_curse(r->attribs, ct)) { + unit * u = r->units; + while (u && u->faction->no!=MONSTER_FACTION) u=u->next; + if (u==NULL) { + curse * c = create_curse(NULL, &r->attribs, ct, + 100, 100, 0, 0); + curse_setflag(c, CURSE_ISNEW|CURSE_IMMUNE); + } + break; + } + r = r->next; + } + return 0; +} + static int convert_orders(void) { @@ -540,14 +584,6 @@ name_seaserpents(void) } #endif -static int -old_rroad(region * r) -{ - attrib * a = a_find(r->attribs, &at_road); - if (!a) return 0; - return a->data.i; -} - attrib_type at_roadfix = { "roadfix", DEFAULT_INIT, @@ -562,52 +598,6 @@ attrib_type at_roadfix = { ATF_UNIQUE }; -static void -newroads(void) -{ - region *r; - for(r=regions;r;r=r->next) if (terrain[rterrain(r)].roadreq>0) { - direction_t d; - int connections = 0; - int maxcon = MAXDIRECTIONS; - int stones = old_rroad(r); - if (stones<=0) continue; - for (d=0;d!=MAXDIRECTIONS;++d) { - region * r2 = rconnect(r, d); - if (r2 && old_rroad(r2)) ++connections; - else if (terrain[rterrain(r2)].roadreq<=0) --maxcon; - } - if (!connections) connections=maxcon; - else maxcon=0; - for (d=0;d!=MAXDIRECTIONS && connections;++d) { - region * r2 = rconnect(r, d); - int use = stones/connections; - if (!r2 || - terrain[rterrain(r2)].roadreq<=0 || - (old_rroad(r2)<=0 && !maxcon)) - continue; - if (use>terrain[rterrain(r)].roadreq) { - /* wenn etwas übrig bleibt (connections==1) kriegt es der regionserste */ - int give = use-terrain[rterrain(r)].roadreq; - unit * u = r->units; - use = terrain[rterrain(r)].roadreq; - if (u) change_item(u, I_STONE, give); - } - rsetroad(r, d, use); - stones = stones - use; - --connections; - if (old_rroad(r)==terrain[rterrain(r)].roadreq*2 && old_rroad(r2)==terrain[rterrain(r2)].roadreq*2) { - border * b = get_borders(r, r2); - attrib * a = a_find(b->attribs, &at_roadfix); - if (a) continue; - while (b && b->type!=&bt_road) b = b->next; - assert(b); - a = a_add(&b->attribs, a_new(&at_roadfix)); - } - } - } -} - /* ************************************************************ */ /* GANZ WICHTIG! ALLE GEÄNDERTEN SPRÜCHE NEU ANZEIGEN */ /* GANZ WICHTIG! FÜGT AUCH NEUE ZAUBER IN DIE LISTE DER BEKANNTEN EIN */ @@ -1116,7 +1106,8 @@ write_laenrepair(void) { #include "group.h" static void -fix_allies(void) { +fix_allies(void) +{ faction * f; for (f=factions;f;f=f->next) { group * g; @@ -2904,15 +2895,15 @@ korrektur(void) do_once("rest", fix_restart_flag()); warn_password(); fix_road_borders(); - + curse_emptiness(); +#ifdef ALLIANCES + init_alliances(); +#endif /* seems something fishy is going on, do this just * to be on the safe side: */ fix_demand(); /* trade_orders(); */ - if (global.data_version < NEWROAD_VERSION) { - newroads(); - } /* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich * Beschreibungen geändert haben */ diff --git a/src/eressea/main.c b/src/eressea/main.c index f03366ce9..2f480b192 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -36,13 +36,17 @@ #include /* modules includes */ -#include #include -#include #include #include #include #include +#ifdef MUSEUM_MODULE +#include +#endif +#ifdef ARENA_MODULE +#include +#endif /* gamecode includes */ #include @@ -173,8 +177,12 @@ game_init(void) init_info(); init_conversion(); +#ifdef MUSEUM_MODULE init_museum(); +#endif +#ifdef ARENA_MODULE init_arena(); +#endif init_xmas2000(); #ifdef REMOVE_THIS render_init(); diff --git a/src/mapper/map_units.c b/src/mapper/map_units.c index d869df972..9ee9aa27b 100644 --- a/src/mapper/map_units.c +++ b/src/mapper/map_units.c @@ -906,29 +906,11 @@ mapper_spunit(dbllist ** SP, unit * u, int indent) } dh = 0; -#if 0 - for (spell = 0; spell != MAXSPELLS; spell++) - if (get_spell(u, spell)) { - sncat(buf, ", ", BUFSIZE); - - if (!dh) { - sncat(buf, "Zauber: ", BUFSIZE); - dh = 1; - } - sncat(buf, spellnames[spell], BUFSIZE); - } -#endif if (u->lastorder[0]) { scat(", \""); sncat(buf, u->lastorder, BUFSIZE); scat("\""); } -#if 0 - if (u->combatspell != NOSPELL) { - sncat(buf, ", Kampfzauber: ", BUFSIZE); - sncat(buf, spellnames[u->combatspell], BUFSIZE); - } -#endif if (uprivate(u)) { sncat(buf, " (Bem: ", BUFSIZE); sncat(buf, uprivate(u), BUFSIZE); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 71c07d107..1cdc6fd73 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -31,11 +31,13 @@ #include #include -#include -#include #include - -#include +#ifdef MUSEUM_MODULE +#include +#endif +#ifdef ARENA_MODULE +#include +#endif /* kernel includes */ #include @@ -51,6 +53,9 @@ #include #include +/* util includes */ +#include + /* libc includes */ #include #include @@ -1572,8 +1577,12 @@ main(int argc, char *argv[]) init_rawmaterials(); #endif +#ifdef MUSEUM_MODULE init_museum(); +#endif +#ifdef ARENA_MODULE init_arena(); +#endif init_xmas2000(); init_gmcmd(); diff --git a/src/res/buildings.xml b/src/res/buildings.xml index f4079fa16..f1645ed50 100644 --- a/src/res/buildings.xml +++ b/src/res/buildings.xml @@ -1,6 +1,3 @@ - - - diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index 98d00e61a..f82c79eda 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -1,4 +1,28 @@ + + + + + + "$int($votes) Mitglieder von $alliance($alliance) haben versucht, Deine Partei aus der Allianz auszuschliessen." + "$int($votes) members of $alliance($alliance) tried to kick you out of the alliance." + + + + + + "$alliance($alliance) scheidet aus dem Spiel aus, nachdem alle Tempel verloren gingen." + "$alliance($alliance) has to leave the game after all their temples were lost." + + + + + + + + "$faction($member) ist mit $int($votes) Stimmen aus $alliance($alliance) ausgeschlossen worden." + "$faction($member) was kicked from $alliance($alliance) by $int($votes) of the alliance's members." + diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index a487bd9fa..fc208c356 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -604,11 +604,6 @@ Struktur - Testgebäude - - Tempel - - Testitem Zauberstab @@ -1691,12 +1686,15 @@ XETRANK + XEPOTION XEBALLON + XEBALLOON XELAEN + XELAEN Talente: @@ -1873,6 +1871,17 @@ NACH + + XONTORMIA + XONTORMIA + + + ALLIANZ + ALLIANCE + + + NACH + PFLANZEN diff --git a/src/res/en/strings.xml b/src/res/en/strings.xml index f4b6cfdb2..4232df974 100644 --- a/src/res/en/strings.xml +++ b/src/res/en/strings.xml @@ -218,9 +218,6 @@ portal - - temple - directions diff --git a/src/res/eressea.xml b/src/res/eressea.xml index 339a18abe..ff028839e 100644 --- a/src/res/eressea.xml +++ b/src/res/eressea.xml @@ -22,4 +22,5 @@ + diff --git a/src/res/eressea/temple.xml b/src/res/eressea/temple.xml new file mode 100644 index 000000000..81c6006c9 --- /dev/null +++ b/src/res/eressea/temple.xml @@ -0,0 +1,10 @@ + + + + + Tempel + temple + + + + diff --git a/src/res/vinyambar-3.xml b/src/res/vinyambar-3.xml new file mode 100644 index 000000000..6729acef6 --- /dev/null +++ b/src/res/vinyambar-3.xml @@ -0,0 +1,23 @@ + + German Localization + + + + English Localization + + + + + + + + + + Game specific + + + + + + + diff --git a/src/res/vinyambar/de/strings.xml b/src/res/vinyambar/de/strings.xml index 6615e7489..75b7fec68 100644 --- a/src/res/vinyambar/de/strings.xml +++ b/src/res/vinyambar/de/strings.xml @@ -1,11 +1,14 @@ - Bitte denke daran, deine Befehle an vinyambar@eressea.amber.kn-bremen.de zu senden. Am besten, du verwendest die Befehlsvorlage am Ende des Reports. + Bitte denke daran, deine Befehle an vinyambar@eressea.amber.kn-bremen.de zu senden. - Weitere Informationen über das Spil findest Du unter htpp://www.vinyambar.de/ + Weitere Informationen über das Spiel findest Du unter http://www.vinyambar.de/ Mit der ersten Auswertung bekommst du einen Computerreport, den du mit vielen der Tools auf http://www.eressea-pbem.de/download.html benutzen kannst. Wenn du ihn nicht bekommen möchtest, gib einer deiner Einheiten den Befehl OPTION COMPUTER NICHT. + + LERNE WAHRNEHMUNG + diff --git a/src/res/vinyambar/stronghold.xml b/src/res/vinyambar/stronghold.xml new file mode 100644 index 000000000..21f2b1173 --- /dev/null +++ b/src/res/vinyambar/stronghold.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + Tempel + temple + + +