diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index d4f77d909..3885dae54 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -22,9 +22,6 @@ /* modules include */ #include -#ifdef ALLIANCES -#include -#endif /* attributes include */ #include @@ -39,6 +36,7 @@ /* kernel includes */ #include +#include #include #include #include @@ -353,7 +351,6 @@ 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) { @@ -364,7 +361,6 @@ cr_alliance(const void * v, char * buffer, const void * userdata) unused(userdata); return 0; } -#endif static int cr_skill(const void * v, char * buffer, const void * userdata) @@ -416,9 +412,7 @@ 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 @@ -898,12 +892,10 @@ 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 && f->alliance==uf->alliance) { fprintf(F, "%d;alliance\n", f->alliance->id); fprintf(F, "\"%s\";alliancename\n", f->alliance->name); } -#endif #ifdef SHORTPWDS if (f->shortpwds) { shortpwd * spwd = f->shortpwds; diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index bdf1754c3..12480196d 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -2559,12 +2559,10 @@ steal_cmd(unit * u, struct order * ord, request ** stealorders) return; } -#ifdef ALLIANCES - if(u->faction->alliance == u2->faction->alliance) { + if (u->faction->alliance!=NULL && u->faction->alliance == u2->faction->alliance) { cmistake(u, ord, 47, MSG_INCOME); return; } -#endif assert(u->region==u2->region); if (!can_contact(r, u, u2)) { diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 337cd38c8..2e76f2dfb 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -36,30 +36,31 @@ #include "study.h" /* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef USE_UGROUPS -# include +# include #endif /* attributes includes */ @@ -76,9 +77,6 @@ #include #include -#ifdef ALLIANCES -#include -#endif #ifdef AT_OPTION /* attributes includes */ @@ -1049,7 +1047,6 @@ inactivefaction(faction * f) fclose(inactiveFILE); } -#ifdef ENHANCED_QUIT static void transfer_faction(faction *f, faction *f2) { @@ -1065,7 +1062,6 @@ transfer_faction(faction *f, faction *f2) u = un; } } -#endif static int restart(unit * u, struct order * ord) @@ -1112,6 +1108,17 @@ restart(unit * u, struct order * ord) return 0; } +static boolean +EnhancedQuit() +{ + static int value = -1; + if (value<0) { + const char * str = get_param(global.parameters, "alliance.transferquit"); + value = (str!=0 && strcmp(str, "true")==0); + } + return value; +} + static int quit(unit * u, struct order * ord) { @@ -1119,35 +1126,30 @@ quit(unit * u, struct order * ord) skip_token(); /* skip keyword */ if (checkpasswd(u->faction, getstrtoken(), false)) { -#ifdef ENHANCED_QUIT - int f2_id = getid(); + if (EnhancedQuit()) { + int f2_id = getid(); - if(f2_id > 0) { - faction *f2 = findfaction(f2_id); - faction * f = u->faction; + if (f2_id > 0) { + faction *f2 = findfaction(f2_id); + faction * f = u->faction; - if(f2 == NULL) { - cmistake(u, ord, 66, MSG_EVENT); - } else if(f == f2) { - cmistake(u, ord, 8, MSG_EVENT); -#ifdef ALLIANCES - } else if(u->faction->alliance != f2->alliance) { - cmistake(u, ord, 315, MSG_EVENT); -#else -#error ENHANCED_QUIT defined without ALLIANCES -#endif - } else if(!alliedfaction(NULL, f, f2, HELP_MONEY)) { - cmistake(u, ord, 316, MSG_EVENT); + if(f2 == NULL) { + cmistake(u, ord, 66, MSG_EVENT); + } else if(f == f2) { + cmistake(u, ord, 8, MSG_EVENT); + } else if (!u->faction->alliance || u->faction->alliance != f2->alliance) { + cmistake(u, ord, 315, MSG_EVENT); + } else if(!alliedfaction(NULL, f, f2, HELP_MONEY)) { + cmistake(u, ord, 316, MSG_EVENT); + } else { + transfer_faction(f,f2); + destroyfaction(f); + } } else { - transfer_faction(f,f2); - destroyfaction(f); + destroyfaction(u->faction); } - } else { - destroyfaction(u->faction); } -#else destroyfaction(u->faction); -#endif return -1; } else { cmistake(u, ord, 86, MSG_EVENT); @@ -1237,7 +1239,7 @@ parse_quit(void) } } } -#if defined(ALLIANCES) && !defined(ALLIANCEJOIN) +#ifndef ALLIANCEJOIN if (f->alliance==NULL) { /* destroyfaction(f); */ continue; @@ -3539,9 +3541,12 @@ defaultorders (void) while (*ordp!=NULL) { order * ord = *ordp; if (get_keyword(ord)==K_DEFAULT) { + char * cmd; init_tokens(ord); skip_token(); /* skip the keyword */ - set_order(&u->lastorder, parse_order(getstrtoken(), u->faction->locale)); + cmd = strdup(getstrtoken()); + set_order(&u->lastorder, parse_order(cmd, u->faction->locale)); + free(cmd); free_order(u->lastorder); /* parse_order & set_order have both increased the refcount */ *ordp = ord->next; ord->next = NULL; @@ -3629,10 +3634,10 @@ processorders (void) puts(" - Defaults und Instant-Befehle..."); setdefaults(); instant_orders(); -#ifdef ALLIANCES - alliancekick(); -#endif - parse(K_MAIL, mail_cmd, false); + + if (alliances!=NULL) alliancekick(); + + parse(K_MAIL, mail_cmd, false); puts(" - Altern"); age_factions(); @@ -3642,10 +3647,10 @@ processorders (void) puts(" - Kontaktieren, Betreten von Schiffen und Gebäuden (1.Versuch)"); do_misc(false); -#ifdef ALLIANCES - puts(" - Testen der Allianzbedingungen"); - alliancevictory(); -#endif + if (alliances!=NULL) { + puts(" - Testen der Allianzbedingungen"); + alliancevictory(); + } puts(" - GM Kommandos"); #ifdef INFOCMD_MODULE diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index eb74a3358..12b3f49da 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -19,9 +19,6 @@ /* modules includes */ #include -#ifdef ALLIANCES -#include -#endif /* attributes includes */ #include @@ -39,6 +36,7 @@ /* kernel includes */ #include +#include #include #include #include @@ -1675,17 +1673,11 @@ show_allies(const faction * f, const ally * allies) const ally * sf; for (sf = allies; sf; sf = sf->next) { int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL); -#ifdef ALLIANCES - if (f->alliance!=sf->faction->alliance) continue; -#endif if (mode > 0) ++allierte; } for (sf = allies; sf; sf = sf->next) { int mode = alliedgroup(NULL, f, sf->faction, sf, HELP_ALL); -#ifdef ALLIANCES - if (f->alliance!=sf->faction->alliance) continue; -#endif if (mode <= 0) continue; i++; if (dh) { @@ -2001,11 +1993,9 @@ 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; @@ -3267,18 +3257,18 @@ writeturn(void) static void out_faction(FILE *file, faction *f) { -#ifdef ALLIANCES - fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", - f->name, itoa36(f->no), f->alliance?f->alliance->id:0, - LOC(default_locale, rc_name(f->race, 0)), neue_gebiete[f->magiegebiet], - f->no_units, f->number, f->money, turn - f->lastorders, - turn - f->lastorders != 1 ? "NMRs" : "NMR "); -#else - fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", - factionname(f), LOC(default_locale, rc_name(f->race, 0)), - neue_gebiete[f->magiegebiet], f->no_units, f->number, f->money, - turn - f->lastorders, turn - f->lastorders != 1 ? "NMRs" : "NMR "); -#endif + if (alliances!=NULL) { + fprintf(file, "%s (%s/%d) (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", + f->name, itoa36(f->no), f->alliance?f->alliance->id:0, + LOC(default_locale, rc_name(f->race, 0)), neue_gebiete[f->magiegebiet], + f->no_units, f->number, f->money, turn - f->lastorders, + turn - f->lastorders != 1 ? "NMRs" : "NMR "); + } else { + fprintf(file, "%s (%.3s/%.3s), %d Einh., %d Pers., $%d, %d %s\n", + factionname(f), LOC(default_locale, rc_name(f->race, 0)), + neue_gebiete[f->magiegebiet], f->no_units, f->number, f->money, + turn - f->lastorders, turn - f->lastorders != 1 ? "NMRs" : "NMR "); + } } void @@ -3505,7 +3495,6 @@ 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 */ { @@ -3517,7 +3506,6 @@ eval_alliance(struct opstack ** stack, const void * userdata) /* faction -> stri } else opush(stack, NULL); } -#endif static void eval_region(struct opstack ** stack, const void * userdata) /* region -> string */ @@ -3614,9 +3602,7 @@ 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 1bebcc286..1f43e2e52 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -55,17 +55,6 @@ #define TEACHNUMBER 10 -static boolean -ExpensiveMigrants(void) -{ - int value = -1; - if (value<0) { - const char * str = get_param(global.parameters, "study.expensivemigrants"); - value = str?atoi(str):0; - } - return value; -} - static skill_t getskill(const struct locale * lang) { diff --git a/src/common/kernel/Jamfile b/src/common/kernel/Jamfile index 7bb58e314..04c521b70 100644 --- a/src/common/kernel/Jamfile +++ b/src/common/kernel/Jamfile @@ -8,6 +8,7 @@ SubDirHdrs $(XMLHDRS) ; SOURCES = alchemy.c + alliance.c battle.c border.c build.c diff --git a/src/common/kernel/alliance.c b/src/common/kernel/alliance.c index 422f2be1a..fa7c9c8a7 100644 --- a/src/common/kernel/alliance.c +++ b/src/common/kernel/alliance.c @@ -11,11 +11,8 @@ */ #include -#include - -#ifdef ALLIANCES +#include "eressea.h" #include "alliance.h" -#include "command.h" #include @@ -29,8 +26,9 @@ #include /* util includes */ -#include -#include +#include +#include +#include /* libc includes */ #include @@ -329,6 +327,3 @@ victorycondition(const alliance * al, const char * name) } return -1; } - - -#endif diff --git a/src/common/kernel/alliance.h b/src/common/kernel/alliance.h index 568dc8bd1..a8b6ed8d6 100644 --- a/src/common/kernel/alliance.h +++ b/src/common/kernel/alliance.h @@ -11,15 +11,12 @@ * This program may not be used, modified or distributed without * prior permission by the authors of Eressea. */ -#ifndef H_MOD_ALLIANCE -#define H_MOD_ALLIANCE +#ifndef H_KRNL_ALLIANCE +#define H_KRNL_ALLIANCE #ifdef __cplusplus extern "C" { #endif -#ifndef ALLIANCES -#error "must define ALLIANCES to use this module" -#endif struct plane; struct attrib; struct unit; diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index cabc303c9..56a55adaa 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -33,13 +33,15 @@ typedef enum combatmagic { #include "eressea.h" #include "battle.h" -#include "item.h" #include "alchemy.h" +#include "alliance.h" #include "build.h" #include "building.h" #include "curse.h" #include "faction.h" #include "goodies.h" +#include "group.h" +#include "item.h" #include "karma.h" #include "magic.h" #include "message.h" @@ -54,7 +56,6 @@ typedef enum combatmagic { #include "skill.h" #include "spell.h" #include "unit.h" -#include "group.h" /* attributes includes */ #include @@ -66,11 +67,6 @@ typedef enum combatmagic { /* items includes */ #include -/* modules includes */ -#ifdef ALLIANCES -#include -#endif - /* util includes */ #include #include @@ -354,14 +350,6 @@ set_enemy(side * as, side * ds, boolean attacking) if (attacking) as->enemy[ds->index] |= E_ATTACKING; } -#ifdef ALLIANCES -static int -allysfm(const side * s, const faction * f, int mode) -{ - if (s->bf->faction==f) return true; - return alliedfaction(s->battle->plane, s->bf->faction, f, mode); -} -#else static int allysfm(const side * s, const faction * f, int mode) { @@ -371,7 +359,6 @@ allysfm(const side * s, const faction * f, int mode) } return alliedfaction(s->battle->plane, s->bf->faction, f, mode); } -#endif static int allysf(const side * s, const faction * f) @@ -2755,13 +2742,13 @@ print_stats(battle * b) buf[77] = (char)0; for (k = buf; *k; ++k) *k = '-'; battlerecord(b, buf); - if(side->bf->faction) { -#ifdef ALLIANCES - sprintf(buf, "##### %s (%s/%d)", side->bf->faction->name, itoa36(side->bf->faction->no), - side->bf->faction->alliance?side->bf->faction->alliance->id:0); -#else - sprintf(buf, "##### %s (%s)", side->bf->faction->name, itoa36(side->bf->faction->no)); -#endif + if (side->bf->faction) { + if (side->bf->faction->alliance) { + sprintf(buf, "##### %s (%s/%d)", side->bf->faction->name, itoa36(side->bf->faction->no), + side->bf->faction->alliance?side->bf->faction->alliance->id:0); + } else { + sprintf(buf, "##### %s (%s)", side->bf->faction->name, itoa36(side->bf->faction->no)); + } battledebug(buf); } print_fighters(b, &side->fighters); diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 733dcbf3d..07267a83f 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -23,9 +23,6 @@ /* modules includes */ #include -#ifdef ALLIANCES -# include -#endif /* attributes includes */ #include @@ -34,6 +31,7 @@ #include /* kernel includes */ +#include "alliance.h" #include "alchemy.h" #include "battle.h" #include "border.h" @@ -118,6 +116,69 @@ MaxAge(void) { return value; } + +static int +ally_flag(const char * s) +{ + if (strcmp(s, "money")==0) return HELP_MONEY; + if (strcmp(s, "fight")==0) return HELP_FIGHT; + if (strcmp(s, "observe")==0) return HELP_OBSERVE; + if (strcmp(s, "give")==0) return HELP_GIVE; + if (strcmp(s, "guard")==0) return HELP_GUARD; + if (strcmp(s, "stealth")==0) return HELP_FSTEALTH; + if (strcmp(s, "travel")==0) return HELP_TRAVEL; + return 0; +} + +boolean +ExpensiveMigrants(void) +{ + int value = -1; + if (value<0) { + const char * str = get_param(global.parameters, "study.expensivemigrants"); + value = str?atoi(str):0; + } + return value; +} + +int +AllianceAuto(void) +{ + static int value = -1; + if (value<0) { + char * str = strdup(get_param(global.parameters, "alliance.auto")); + value = 0; + if (str!=NULL) { + char * tok = strtok(str, " "); + while (tok) { + value |= ally_flag(tok); + tok = strtok(NULL, " "); + } + free(str); + } + } + return value; +} + +int +AllianceRestricted(void) +{ + static int value = -1; + if (value<0) { + char * str = strdup(get_param(global.parameters, "alliance.restricted")); + value = 0; + if (str!=NULL) { + char * tok = strtok(str, " "); + while (tok) { + value |= ally_flag(tok); + tok = strtok(NULL, " "); + } + free(str); + } + } + return value; +} + int FirstTurn(void) { @@ -378,8 +439,7 @@ const char *options[MAXOPTIONS] = "SHOWSKCHANGE" }; -#ifdef ALLIANCE_LIMITS -int +static int allied_skillcount(const faction * f, skill_t sk) { int num = 0; @@ -392,29 +452,33 @@ allied_skillcount(const faction * f, skill_t sk) return num; } -int +static int allied_skilllimit(const faction * f, skill_t sk) { - const char * str = get_param(global.parameters, "allied.skilllimit"); - return str?atoi(str):0; + static int value = -1; + if (value<0) { + const char * str = get_param(global.parameters, "alliance.skilllimit"); + value = str?atoi(str):0; + } + return value; } -#endif int max_skill(faction * f, skill_t sk) { int m = INT_MAX; -#ifdef ALLIANCE_LIMITS - if (sk!=SK_ALCHEMY && sk!=SK_MAGIC) return INT_MAX; - if (f->alliance!=NULL) { - int ac = listlen(f->alliance->members); /* number of factions */ - int al = allied_skilllimit(f, sk); /* limit per alliance */ - int fl = (al+ac-1)/ac; /* faction limit */ - int sc = al - allied_skillcount(f, sk); - if (sc==0) return count_skill(f, sk); - return fl; + + if (allied_skilllimit(f, sk)) { + if (sk!=SK_ALCHEMY && sk!=SK_MAGIC) return INT_MAX; + if (f->alliance!=NULL) { + int ac = listlen(f->alliance->members); /* number of factions */ + int al = allied_skilllimit(f, sk); /* limit per alliance */ + int fl = (al+ac-1)/ac; /* faction limit */ + int sc = al - allied_skillcount(f, sk); + if (sc==0) return count_skill(f, sk); + return fl; + } } -#endif switch (sk) { case SK_MAGIC: m = MAXMAGICIANS; @@ -855,9 +919,10 @@ autoalliance(const plane * pl, const faction * sf, const faction * f2) a=a->next; } } -#ifdef AUTOALLIANCE - if (sf->alliance==f2->alliance) return AUTOALLIANCE; -#endif + + if (sf->alliance && AllianceAuto()) { + if (sf->alliance==f2->alliance) return AllianceAuto(); + } return 0; } @@ -878,15 +943,9 @@ alliedgroup(const struct plane * pl, const struct faction * f, mode = mode & autoalliance(pl, f, f2); } mode = ally_mode(sf, mode) | (mode & autoalliance(pl, f, f2)); -#ifdef ALLIANCES - if (f->alliance!=f2->alliance) { -# ifdef ALLIES_ONLY - mode &= ~ALLIES_ONLY; -# else - mode = 0; -# endif + if (AllianceRestricted() && f->alliance!=f2->alliance) { + mode &= ~AllianceRestricted(); } -#endif return mode; } diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index d55f024fe..a5bf766a4 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -88,11 +88,7 @@ struct building_type; #include #define AT_PERSISTENT -#ifdef ALLIANCES -# define ALLIED(f1, f2) (f1->alliance && f1->alliance==f2->alliance) -#else -# define ALLIED(f1, f2) (f1==f2) -#endif +#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance)) /* eressea-defined attribute-type flags */ #define ATF_CURSE ATF_USER_DEFINED @@ -167,16 +163,16 @@ struct building_type; #define DBLINK_VERSION 314 #define CURSEVIGOURISFLOAT_VERSION 315 #define SAVEXMLNAME_VERSION 316 - -#define REGIONOWNERS_VERSION 317 +#define SAVEALLIANCE_VERSION 317 #define MIN_VERSION ALLIANCES_VERSION -#define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ +#define REGIONOWNERS_VERSION 400 +#define UGROUPS_VERSION 500 /* nicht aktivieren, nicht fertig */ #ifdef REGIONOWNERS # define RELEASE_VERSION REGIONOWNERS_VERSION #else -# define RELEASE_VERSION SAVEXMLNAME_VERSION +# define RELEASE_VERSION SAVEALLIANCE_VERSION #endif #if RESOURCE_CONVERSION @@ -1173,12 +1169,14 @@ extern const char * dbrace(const struct race * rc); extern void set_param(struct param ** p, const char * name, const char * data); extern const char* get_param(const struct param * p, const char * name); +extern boolean ExpensiveMigrants(void); extern int FirstTurn(void); extern int NMRTimeout(void); extern int LongHunger(void); extern boolean TradeDisabled(void); extern int SkillCap(skill_t sk); - +extern int AllianceAuto(void); /* flags that allied factions get automatically */ +extern int AllianceRestricted(void); /* flags restricted to allied factions */ extern struct order * default_order(const struct locale * lang); extern int entertainmoney(const struct region * r); diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index 0074060b4..aa6dc2a35 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -82,9 +82,7 @@ typedef struct faction { int number; /* enno: unterschied zu num_people ? */ int money; int score; -#ifdef ALLIANCES struct alliance * alliance; -#endif #ifdef VICTORY_DELAY unsigned char victory_delay; #endif diff --git a/src/common/kernel/kernel.vcproj b/src/common/kernel/kernel.vcproj index b9ca32427..d463de41a 100644 --- a/src/common/kernel/kernel.vcproj +++ b/src/common/kernel/kernel.vcproj @@ -297,6 +297,12 @@ + + + + diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index c10664e72..353202683 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -887,8 +887,8 @@ get_addresses(faction * f) u = u->next; } } -#ifdef ALLIANCES - if(f->alliance != NULL) { + + if (f->alliance != NULL) { faction *f2; for(f2 = factions; f2; f2 = f2->next) { if(f2->alliance != NULL && f2->alliance == f->alliance) { @@ -905,7 +905,6 @@ get_addresses(faction * f) } } } -#endif return flist; } diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index c219124ea..3ff16114f 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -22,6 +22,7 @@ #include "eressea.h" #include "save.h" +#include "alliance.h" #include "alchemy.h" #include "attrib.h" #include "border.h" @@ -50,11 +51,6 @@ #include #endif -/* modules include */ -#ifdef ALLIANCES -# include -#endif - /* attributes includes */ #include @@ -792,19 +788,22 @@ read_ugroups(FILE *file) } #endif -#ifdef ALLIANCES -void +static void read_alliances(FILE * F) { - char pbuf[32]; - rs(F, pbuf); + char pbuf[32]; + + if (global.data_versionalliance!=f->alliance) state &= ~ALLIES_ONLY;; -# else -# endif - if (af!=NULL && af->alliance!=f->alliance) return sfp; -#endif + + if (af==NULL) return sfp; + if (f->alliance==NULL || f->alliance!=af->alliance) state &= ~AllianceRestricted(); + if (f->alliance==NULL || f->alliance==af->alliance) state |= AllianceAuto(); if (state==0) return sfp; sf = calloc(1, sizeof(ally)); @@ -1513,8 +1507,8 @@ readfaction(FILE * F) while (f->attribs) a_remove(&f->attribs, f->attribs); } f->subscription = ri(F); -#ifdef ALLIANCES - if (global.data_version>=ALLIANCES_VERSION) { + + if (alliances!=NULL) { int allianceid = rid(F); if (allianceid!=0) f->alliance = findalliance(allianceid); if (f->alliance) { @@ -1524,7 +1518,6 @@ readfaction(FILE * F) f->alliance->members = flist; } } -#endif rds(F, &f->name); @@ -1641,10 +1634,10 @@ writefaction(FILE * F, const faction * f) wi36(F, f->no); wi(F, f->subscription); -#if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION - if (f->alliance) wi36(F, f->alliance->id); - else wi36(F, 0); -#endif + if (alliances!=NULL) { + if (f->alliance) wi36(F, f->alliance->id); + else wi36(F, 0); + } ws(F, f->name); ws(F, f->banner); @@ -1782,11 +1775,9 @@ readgame(const char * filename, int backup) } /* Read factions */ -#ifdef ALLIANCES if (global.data_version>=ALLIANCES_VERSION) { read_alliances(F); } -#endif n = ri(F); printf(" - Einzulesende Parteien: %d\n", n); fp = &factions; @@ -2076,10 +2067,10 @@ writegame(const char *filename, char quiet) /* Write factions */ -#if defined(ALLIANCES) && RELEASE_VERSION>=ALLIANCES_VERSION +#if RELEASE_VERSION>=ALLIANCES_VERSION write_alliances(F); #endif - n=listlen(factions); + n = listlen(factions); wi(F, n); wnl(F); diff --git a/src/common/kernel/study.h b/src/common/kernel/study.h index 0751aa66d..b23dec595 100644 --- a/src/common/kernel/study.h +++ b/src/common/kernel/study.h @@ -15,6 +15,5 @@ void teaching(void); void learn(void); -magic_t getmagicskill(void); +extern magic_t getmagicskill(void); extern boolean is_migrant(struct unit *u); - diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index a63242c0f..7003f8b8a 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -943,7 +943,7 @@ item_modification(const unit *u, skill_t sk, int val) val = val * 2; } else if(sk == SK_STEALTH) { #if NEWATSROI == 1 - if(get_item(u, I_RING_OF_INVISIBILITY) + if (get_item(u, I_RING_OF_INVISIBILITY) + 100 * get_item(u, I_SPHERE_OF_INVISIBILITY) >= u->number) { val += ROIBONUS; } diff --git a/src/common/modules/alliance.c b/src/common/modules/alliance.c deleted file mode 100644 index 422f2be1a..000000000 --- a/src/common/modules/alliance.c +++ /dev/null @@ -1,334 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -#include -#include - -#ifdef ALLIANCES -#include "alliance.h" -#include "command.h" - -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include - -/* libc includes */ -#include -#include -#include - -alliance * alliances = NULL; - -alliance * -makealliance(int id, const char * name) -{ - alliance * al = calloc(1, sizeof(alliance)); - al->id=id; - al->name=strdup(name); - al->next=alliances; - return alliances=al; -} - -alliance * -findalliance(int id) -{ - alliance * al; - for (al=alliances;al;al=al->next) { - if (al->id==id) return al; - } - return NULL; -} - -void destroy_kick(struct attrib * a) -{ - faction_list * flist = (faction_list*)a->data.v; - freelist(flist); -} - -const attrib_type at_kick = { "kick", - DEFAULT_INIT, destroy_kick -}; - -static attrib * -make_kick(void) -{ - return a_new(&at_kick); -} - -void -add_kick(attrib * a, const faction * f) -{ - faction_list * flist = (faction_list*)a->data.v; - while (flist && flist->data!=f) flist = flist->next; - if (flist) return; - flist = calloc(1, sizeof(faction_list)); - flist->data = (void*)f; - flist->next = (faction_list*)a->data.v; - a->data.v = flist; -} - -static void -alliance_kick(const tnode * tnext, const char * str, void * data, struct order * ord) -{ - 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 */ - return; - } - a = a_find(f->attribs, &at_kick); - if (a==NULL) a = a_add(&f->attribs, make_kick()); - add_kick(a, f); -} - -static void -alliance_join(const tnode * tnext, const char * str, void * data, struct order * ord) -{ - unit * u = (unit*)data; - alliance * al = findalliance(atoi36(igetstrtoken(str))); - unused(tnext); - - if (u->faction->alliance!=NULL || al==NULL) { - /* not found */ - return; - } - u->faction->alliance = al; - /* inform the rest? */ -} - -static void -execute(const struct syntaxtree * syntax) -{ - region ** rp = ®ions; - while (*rp) { - region * r = *rp; - unit **up = &r->units; - while (*up) { - unit * u = *up; - const struct locale * lang = u->faction->locale; - tnode * root = stree_find(syntax, lang); - order * ord; - for (ord = u->orders; ord; ord = ord->next) { - if (get_keyword(ord) == K_ALLIANCE) { - do_command(root, u, ord); - } - } - if (u==*up) up = &u->next; - } - if (*rp==r) rp = &r->next; - } -} - -void -alliancekick(void) -{ - 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 -alliancejoin(void) -{ - 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; - if (btype==NULL) return; - 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); - } - al = al->next; - } -} - -int -victorycondition(const alliance * al, const char * name) -{ - const char * gems[] = { "opal", "diamond", "zaphire", "topaz", "beryl", "agate", "garnet", "emerald", NULL }; - if (strcmp(name, "gems")==0) { - const char ** igem = gems; - - for (;*igem;++igem) { - const struct item_type * itype = it_find(*igem); - faction_list * flist = al->members; - boolean found = false; - - assert(itype!=NULL); - for (;flist && !found;flist=flist->next) { - unit * u = flist->data->units; - - for (;u;u=u->nextF) { - if (i_get(u->items, itype)>0) { - found = true; - break; - } - } - } - if (!found) return 0; - } - return 1; - } else if (strcmp(name, "phoenix")==0) { - faction_list * flist = al->members; - for (;flist;flist=flist->next) { - faction * f = flist->data; - if (find_key(f->attribs, atoi36("phnx"))) { - return 1; - } - } - return 0; - } else if (strcmp(name, "pyramid")==0) { - faction_list * flist = al->members; - for (;flist;flist=flist->next) { - faction * f = flist->data; - if (find_key(f->attribs, atoi36("pyra"))) { - return 1; - } - } - return 0; - } - return -1; -} - - -#endif diff --git a/src/common/modules/alliance.h b/src/common/modules/alliance.h deleted file mode 100644 index 568dc8bd1..000000000 --- a/src/common/modules/alliance.h +++ /dev/null @@ -1,54 +0,0 @@ -/* vi: set ts=2: - * - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ -#ifndef H_MOD_ALLIANCE -#define H_MOD_ALLIANCE -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ALLIANCES -#error "must define ALLIANCES to use this module" -#endif -struct plane; -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; - -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); - -extern int victorycondition(const alliance * al, const char * name); -/* execute commands */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/common/modules/modules.vcproj b/src/common/modules/modules.vcproj index e5ece7a33..d921cf504 100644 --- a/src/common/modules/modules.vcproj +++ b/src/common/modules/modules.vcproj @@ -120,9 +120,6 @@ - - @@ -154,9 +151,6 @@ RelativePath=".\xmas.h"> - - diff --git a/src/common/modules/score.c b/src/common/modules/score.c index 118c9d00e..efece1e11 100644 --- a/src/common/modules/score.c +++ b/src/common/modules/score.c @@ -22,11 +22,8 @@ #include #include "eressea.h" -#ifdef ALLIANCES -#include "alliance.h" -#endif - /* kernel includes */ +#include #include #include #include @@ -255,8 +252,7 @@ score(void) } fclose(scoreFP); -#ifdef ALLIANCES - { + if (alliances!=NULL) { alliance *a; const item_type * token = it_find("conquesttoken"); @@ -292,7 +288,6 @@ score(void) } fclose(scoreFP); } -#endif } diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index 4bcc70fa1..43996a0be 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -30,16 +30,13 @@ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define CATAPULT_AMMUNITION 1 /* Gebaut werden kann sie auch mit 0! */ #define CHANGED_CROSSBOWS 1 -#define NEWATSROI 0 #define COMBAT_TURNS 5 #define PEASANTS_DO_NOT_STARVE 0 #define NEW_MIGRATION 1 #define ASTRAL_HUNGER -#undef SHORTPWDS -#define ZEROFOKS_QUESTMASTER "eressea@zerofoks.net" +#define NEWATSROI 0 -#undef DUNGEON_MODULE #define MUSEUM_MODULE #define ARENA_MODULE #define WORMHOLE_MODULE diff --git a/src/common/settings-vinyambar-3.h b/src/common/settings-vinyambar-3.h index 94819091c..e142ace16 100644 --- a/src/common/settings-vinyambar-3.h +++ b/src/common/settings-vinyambar-3.h @@ -40,9 +40,4 @@ #define ROIBONUS 4 #endif -#define ENHANCED_QUIT -#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-wdw.h b/src/common/settings-wdw.h index 909e6aec7..b83a1fa40 100644 --- a/src/common/settings-wdw.h +++ b/src/common/settings-wdw.h @@ -11,7 +11,7 @@ */ /* - * Contains defines for the "alliance" vinyambar game (V3). + * Contains defines for the "alliance" vinyambar game (wdw). * Include this file from settings.h to make eressea work. */ #define ENTERTAINFRACTION 20 @@ -30,24 +30,24 @@ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define CATAPULT_AMMUNITION 1 /* Gebaut werden kann sie auch mit 0! */ #define CHANGED_CROSSBOWS 1 -#define NEWATSROI 1 #define COMBAT_TURNS 5 #define PEASANTS_DO_NOT_STARVE 0 #define NEW_MIGRATION 1 #define ASTRAL_HUNGER +#define NEWATSROI 1 #if NEWATSROI == 1 #define ATSBONUS 2 #define ROIBONUS 4 #endif -#define ENHANCED_QUIT -#define ALLIANCES -#define ALLIES_ONLY (HELP_FIGHT|HELP_GUARD|HELP_FSTEALTH|HELP_MONEY) #undef ALLIANCEJOIN -#define ALLIANCE_LIMITS -#define AUTOALLIANCE (HELP_FIGHT) +#undef DUNGEON_MODULE +#undef MUSEUM_MODULE +#undef ARENA_MODULE +#undef WORMHOLE_MODULE +#undef XECMD_MODULE #define WDW_PHOENIX #define WDW_PYRAMIDSPELL #define NEW_STARTEQUIPMENT diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 9958baa78..0aadd97c5 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -26,37 +26,35 @@ #include #include #include -#ifdef ALLIANCES -#include -#endif /* gamecode includes */ -#include +#include +#include /* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* util includes */ #include @@ -224,29 +222,29 @@ kor_teure_talente(unit *u) static void no_teurefremde(boolean convert) { - region *r; - unit *u; + region *r; - for(r=regions;r;r=r->next) { - for(u=r->units;u;u=u->next) { - if (u->faction->no != MONSTER_FACTION - && playerrace(u->faction->race) - && is_migrant(u) - && kor_teure_talente(u)) - { - log_printf("* Warnung, teurer Migrant: %s %s\n", - unitname(u), factionname(u->faction)); - if(convert) { - u->race = u->faction->race; - u->irace = u->faction->race; - u->faction->num_migrants -= u->number; - sprintf(buf, "Die Götter segnen %s mit der richtigen Rasse", - unitname(u)); - addmessage(0, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT); - } - } - } - } + for(r=regions;r;r=r->next) { + unit *u; + + for(u=r->units;u;u=u->next) { + if (u->faction->no != MONSTER_FACTION + && playerrace(u->faction->race) + && is_migrant(u) && kor_teure_talente(u)) + { + log_warning(("Teurer Migrant: %s, Partei %s\n", + unitname(u), factionname(u->faction))); + if (convert) { + u->race = u->faction->race; + u->irace = u->faction->race; + u->faction->num_migrants -= u->number; + sprintf(buf, "Die Götter segnen %s mit der richtigen Rasse", + unitname(u)); + addmessage(0, u->faction, buf, MSG_MESSAGE, ML_IMPORTANT); + } + } + } + } } attrib_type at_roadfix = { @@ -1166,12 +1164,10 @@ korrektur(void) update_gms(); verify_owners(false); /* fix_herbtypes(); */ - /* In Vin3 können Parteien komplett übergeben werden. */ -#ifdef ENHANCED_QUIT - no_teurefremde(0); -#else - no_teurefremde(1); -#endif + /* In Vin 3+ können Parteien komplett übergeben werden. */ + if (!ExpensiveMigrants()) { + no_teurefremde(true); + } fix_allies(); update_gmquests(); /* test gm quests */ /* fix_unitrefs(); */ @@ -1179,9 +1175,6 @@ korrektur(void) warn_password(); fix_road_borders(); if (turn>1000) curse_emptiness(); /*** disabled ***/ -#ifdef ALLIANCES - /* init_alliances(); */ -#endif /* seems something fishy is going on, do this just * to be on the safe side: */ diff --git a/src/eressea/lua/alliance.cpp b/src/eressea/lua/alliance.cpp index c792e36f3..c831d76a7 100644 --- a/src/eressea/lua/alliance.cpp +++ b/src/eressea/lua/alliance.cpp @@ -1,13 +1,12 @@ #include #include -#ifdef ALLIANCES #include "list.h" // kernel includes #include #include -#include +#include // lua includes #include @@ -53,4 +52,3 @@ bind_alliance(lua_State * L) .property("factions", &alliance_factions, return_stl_iterator) ]; } -#endif diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index 7d0d0838d..3fd23a068 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -3,9 +3,6 @@ #include "script.h" -#ifdef ALLIANCES -# include -#endif #include // gamecode includes @@ -13,6 +10,7 @@ #include // kernel includes +#include #include #include #include diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp index 993a4a854..4baf9d62d 100644 --- a/src/eressea/lua/faction.cpp +++ b/src/eressea/lua/faction.cpp @@ -3,11 +3,9 @@ #include "list.h" // kernel includes +#include #include #include -#ifdef ALLIANCES -# include -#endif // util includes #include @@ -49,7 +47,6 @@ faction_units(const faction& f) return eressea::list(f.units); } -#ifdef ALLIANCES static void faction_setalliance(faction& f, alliance * team) { @@ -61,7 +58,6 @@ faction_getalliance(const faction& f) { return f.alliance; } -#endif const char * faction_locale(const faction& f) @@ -146,8 +142,6 @@ bind_faction(lua_State * L) .def_readwrite("lastturn", &faction::lastorders) .property("locale", &faction_locale) .property("units", &faction_units, return_stl_iterator) -#ifdef ALLIANCES .property("alliance", &faction_getalliance, &faction_setalliance) -#endif ]; } diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 4386961c6..ea268bd74 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -277,9 +277,7 @@ lua_init(void) luabind::open(luaState); bind_eressea(luaState); bind_spell(luaState); -#ifdef ALLIANCES bind_alliance(luaState); -#endif bind_region(luaState); bind_item(luaState); bind_faction(luaState); diff --git a/src/mapper/autoseed.c b/src/mapper/autoseed.c index 28aed5807..e7976c52d 100644 --- a/src/mapper/autoseed.c +++ b/src/mapper/autoseed.c @@ -259,9 +259,7 @@ autoseed(struct region_list * rlist) while (*nfp!=nf) nfp=&(*nfp)->next; u = addplayer(seeds[i].region, addfaction(nf->email, nf->password, nf->race, nf->lang, nf->subscription)); -#ifdef ALLIANCES u->faction->alliance = nf->allies; -#endif ++numnewbies; *nfp = nf->next; free(nf); @@ -360,9 +358,7 @@ mkisland(int nsize) ++isize; u = addplayer(r, addfaction(nextf->email, nextf->password, nextf->race, nextf->lang, nextf->subscription)); -#ifdef ALLIANCES u->faction->alliance = nextf->allies; -#endif /* remove duplicate email addresses */ nfp=&newfactions; diff --git a/src/mapper/autoseed.h b/src/mapper/autoseed.h index 040f724be..af02ffa06 100644 --- a/src/mapper/autoseed.h +++ b/src/mapper/autoseed.h @@ -25,9 +25,7 @@ typedef struct newfaction { int bonus; int subscription; boolean oldregions; -#ifdef ALLIANCES struct alliance * allies; -#endif } newfaction; extern newfaction * newfactions; diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c index 423f70a61..f617d75e9 100644 --- a/src/mapper/map_partei.c +++ b/src/mapper/map_partei.c @@ -20,21 +20,17 @@ #include "autoseed.h" /* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* modules */ -#ifdef ALLIANCES -#include -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* util includes */ #include @@ -211,9 +207,7 @@ seed_dropouts(void) if (nf->race==drop->race && !nf->bonus) { unit * u = addplayer(r, addfaction(nf->email, nf->password, nf->race, nf->lang, nf->subscription)); -#ifdef ALLIANCES u->faction->alliance = nf->allies; -#endif ++numnewbies; if (nf->bonus) give_latestart_bonus(r, u, nf->bonus); found=true; @@ -241,14 +235,15 @@ read_newfactions(const char * filename) char race[20], email[64], lang[8], password[16]; newfaction *nf; int bonus, subscription; -#ifdef ALLIANCES - int alliance; - /* email;race;locale;startbonus;subscription;alliance */ - if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break; -#else - /* email;race;locale;startbonus;subscription */ - if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus, &subscription, password)<=0) break; -#endif + + if (alliances!=NULL) { + int alliance; + /* email;race;locale;startbonus;subscription;alliance */ + if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break; + } else { + /* email;race;locale;startbonus;subscription */ + if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus, &subscription, password)<=0) break; + } while (f) { if (strcmp(f->email, email)==0 && f->subscription) { break; @@ -265,8 +260,7 @@ read_newfactions(const char * filename) nf->password = strdup(password); nf->race = rc_find(race); nf->subscription = subscription; -#ifdef ALLIANCES - { + if (alliances!=NULL) { struct alliance * al = findalliance(alliance); if (al==NULL) { char zText[64]; @@ -274,8 +268,9 @@ read_newfactions(const char * filename) al = makealliance(alliance, zText); } nf->allies = al; - } -#endif + } else { + nf->allies = NULL; + } if (nf->race==NULL) nf->race = findrace(race, default_locale); nf->lang = find_locale(lang); nf->bonus = bonus; @@ -301,11 +296,11 @@ select_newfaction(const struct race * rc) while (player) { if (rc==NULL || player->race==rc) { char str[80]; -#ifdef ALLIANCES - snprintf(str, 70, "%s %d %s %s", player->bonus?"!":" ", player->allies?player->allies->id:0, locale_string(default_locale, rc_name(player->race, 0)), player->email); -#else - snprintf(str, 70, "%s %s %s", player->bonus?"!":" ", locale_string(default_locale, rc_name(player->race, 0)), player->email); -#endif + if (alliances!=NULL) { + snprintf(str, 70, "%s %d %s %s", player->bonus?"!":" ", player->allies?player->allies->id:0, locale_string(default_locale, rc_name(player->race, 0)), player->email); + } else { + snprintf(str, 70, "%s %s %s", player->bonus?"!":" ", locale_string(default_locale, rc_name(player->race, 0)), player->email); + } insert_selection(iinsert, prev, strdup(str), (void*)player); prev = *iinsert; iinsert = &prev->next; diff --git a/src/mapper/map_region.c b/src/mapper/map_region.c index e2c63cad0..dd07ad159 100644 --- a/src/mapper/map_region.c +++ b/src/mapper/map_region.c @@ -19,21 +19,19 @@ #include "mapper.h" /* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* modules includes */ -#ifdef ALLIANCES -# include -#endif /* util includes */ #include @@ -370,15 +368,13 @@ showregion(region * r, char full) } for (f = factions; f; f = f->next) if (f->no_units) { -#ifdef ALLIANCES - if(f->alliance != NULL) { - sprintf(buf, " %-26.26s (%s/%d)", f->name, factionid(f), f->alliance->id); - } else { - sprintf(buf, " %-26.26s (%s/-)", f->name, factionid(f)); - } -#else - sprintf(buf, " %-29.29s (%s)", f->name, factionid(f)); -#endif + if (alliances==NULL) { + sprintf(buf, " %-29.29s (%s)", f->name, factionid(f)); + } else if (f->alliance != NULL) { + sprintf(buf, " %-26.26s (%s/%d)", f->name, factionid(f), f->alliance->id); + } else { + sprintf(buf, " %-26.26s (%s/-)", f->name, factionid(f)); + } adddbllist(®list, buf); sprintf(buf, " Einheiten: %d; Leute: %d %c", f->no_units, f->num_people, Tchar[old_race(f->race)]); diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index 03f817b0e..4198397f8 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -32,9 +32,6 @@ #include #include -#ifdef ALLIANCES -#include -#endif #ifdef MUSEUM_MODULE #include #endif @@ -46,20 +43,21 @@ #endif /* kernel includes */ -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include /* util includes */ #include @@ -189,9 +187,7 @@ init_win(int x, int y) { /* --------------------------------------------------------------------- */ static int hl; -#ifdef ALLIANCES static int hl_alliance; -#endif int politkarte = 0; @@ -316,7 +312,6 @@ factionhere(region * r, int f) return false; } -#ifdef ALLIANCES static boolean alliancehere(region * r, int allied) { @@ -326,7 +321,6 @@ alliancehere(region * r, int allied) return true; return false; } -#endif #if NEW_RESOURCEGROWTH static boolean @@ -397,9 +391,7 @@ highlight_region(region *r) (hl == -8 && get_curse(r->attribs, ct_find("godcursezone"))) || (hl == -9 && newbie_region(r)) || (hl == -10 && dropout_region(r)) || -#ifdef ALLIANCES (hl == -11 && alliancehere(r, hl_alliance)) || -#endif (hl >= 0 && factionhere(r, hl))) { return true; } @@ -453,11 +445,9 @@ drawmap(boolean maponly) { case -10: addstr("Dropouts "); break; -#ifdef ALLIANCES case -11: printw((NCURSES_CONST char*)"Allianz %d ", hl_alliance); break; -#endif default: printw((NCURSES_CONST char*)"Partei %d ", hl); } @@ -773,11 +763,7 @@ SetHighlight(void) wmove(win, 2, 2); wAddstr(" A)nfängern, L)aen, C)haos, G)odcurse"); wmove(win, 3, 2); -#ifdef ALLIANCES wAddstr(" D)ropouts, Allian(Z) oder N)ichts?"); -#else - wAddstr(" D)ropouts oder N)ichts?"); -#endif wrefresh(win); c = tolower(getch()); switch (c) { @@ -785,12 +771,10 @@ SetHighlight(void) fac_nr36 = my_input(win, 2, 2, "Partei-Nummer: ", NULL); hl = atoi36(fac_nr36); break; -#ifdef ALLIANCES case 'z': hl_alliance = map_input(win, 2, 2, "Allianz-Nummer: ", 0, 999, 0); hl = -11; break; -#endif case 'e': hl = -2; break; diff --git a/src/res/vinyambar-3.xml b/src/res/vinyambar-3.xml index d91386fc7..42cc6c670 100644 --- a/src/res/vinyambar-3.xml +++ b/src/res/vinyambar-3.xml @@ -24,6 +24,9 @@ + + + diff --git a/src/res/vinyambar-wdw.xml b/src/res/vinyambar-wdw.xml index 62ffef1b8..119e86226 100644 --- a/src/res/vinyambar-wdw.xml +++ b/src/res/vinyambar-wdw.xml @@ -25,7 +25,6 @@ - @@ -33,6 +32,10 @@ + + + +