diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index b9d1468f8..f5f0a417a 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -64,6 +64,7 @@ #include #include #include +#include #include /* libc includes */ @@ -821,7 +822,19 @@ show_allies(FILE * F, const faction * f, const ally * sf) } } } -/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ + +#ifdef REGIONOWNERS +static void +show_enemies(FILE * F, const faction_list* flist) +{ + for (;flist!=NULL;flist=flist->next) { + if (flist->data) { + int fno = flist->data->no; + fprintf(F, "ENEMY %u\n%d;partei\n", fno); + } + } +} +#endif /* prints all visible spells in a region */ static void @@ -1039,6 +1052,9 @@ 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]); } +#ifdef REGIONOWNERS + show_enemies(F, f->enemies); +#endif show_allies(F, f, f->allies); { group * g; @@ -1101,6 +1117,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen, const char * tname; unsigned char seemode = sd->mode; const region * r = sd->r; + unit * owner = region_owner(r); sd = sd->next; if (!rplane(r)) fprintf(F, "REGION %d %d\n", region_x(r, f), region_y(r, f)); @@ -1132,6 +1149,9 @@ report_computer(FILE * F, faction * f, const seen_region * seen, fputs("\"travel\";visibility\n", F); break; } + if (owner) { + fprintf(F, "%d;owner\n", owner->faction->no); + } if (seemode == see_neighbour) { cr_borders(r, f, seemode, F); } else { diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 31d424449..9c8a785b0 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2740,6 +2740,63 @@ evict(void) } #endif +#ifdef REGIONOWNERS +static void +declare_war(void) +{ + region *r; + for (r=regions;r;r=r->next) { + unit * u; + for (u=r->units;u;u=u->next) { + strlist *S; + faction * f = u->faction; + for (S = u->orders; S; S = S->next) { + switch (igetkeyword(S->s, f->locale)) { + case K_WAR: + for (;;) { + const char * s = getstrtoken(); + if (s[0]==0) break; + else { + faction * enemy = findfaction(atoi36(s)); + if (enemy) { + if (!is_enemy(f, enemy)) { + add_enemy(f, enemy); + ADDMSG(&enemy->msgs, msg_message("war_notify", "enemy", f)); + ADDMSG(&f->msgs, msg_message("war_confirm", "enemy", enemy)); + } + } else { + ADDMSG(&f->msgs, msg_message("error66", "unit region command", u, r, S->s)); + } + } + } + break; + case K_PEACE: + for (;;) { + const char * s = getstrtoken(); + if (s[0]==0) break; + else { + faction * enemy = findfaction(atoi36(s)); + if (enemy) { + if (is_enemy(f, enemy)) { + remove_enemy(f, enemy); + ADDMSG(&enemy->msgs, msg_message("peace_notify", "enemy", f)); + ADDMSG(&f->msgs, msg_message("peace_confirm", "enemy", enemy)); + } + } else { + ADDMSG(&f->msgs, msg_message("error66", "unit region command", u, r, S->s)); + } + } + } + break; + default: + break; + } + } + } + } +} +#endif + static void renumber(void) { @@ -2749,7 +2806,7 @@ renumber(void) unit * u; int i; - for (r=regions;r;r=r->next) { + for (r=regions;r;r=r->next) { for (u=r->units;u;u=u->next) { faction * f = u->faction; for (S = u->orders; S; S = S->next) if (igetkeyword(S->s, u->faction->locale)==K_NUMBER) { @@ -3520,6 +3577,10 @@ processorders (void) #endif #ifdef ALLIANCEJOIN alliancejoin(); +#endif +#ifdef REGIONOWNERS + puts(" - Krieg & Frieden"); + declare_war(); #endif puts(" - Neue Nummern"); renumber(); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index c70489b8c..5e30dc348 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1279,7 +1279,16 @@ describe(FILE * F, const region * r, int partial, faction * f) scat("."); } - if (!is_cursed(r->attribs, C_REGCONF, 0)) { + { + const unit * u = region_owner(r); + if (u) { + scat(" Die Region ist im Besitz von "); + scat(factionname(u->faction)); + scat("."); + } + } + + if (!is_cursed(r->attribs, C_REGCONF, 0)) { attrib *a_do = a_find(r->attribs, &at_overrideroads); if(a_do) { scat(" "); @@ -1716,9 +1725,9 @@ show_allies(const faction * f, const ally * allies) } static void -allies(FILE * F, faction * f) +allies(FILE * F, const faction * f) { - group * g = f->groups; + const group * g = f->groups; if (f->allies) { if (!f->allies->next) { strcpy(buf, "Wir helfen der Partei "); @@ -1747,6 +1756,28 @@ allies(FILE * F, faction * f) } } +#ifdef REGIONOWNERS +static void +enemies(FILE * F, const faction * f) +{ + faction_list * flist = f->enemies; + if (flist!=NULL) { + strcpy(buf, "Wir liegen im Krieg mit "); + for (;flist!=NULL;flist = flist->next) { + const faction * enemy = flist->data; + scat(factionname(enemy)); + if (flist->next) { + scat(", "); + } else { + scat("."); + } + } + rparagraph(F, buf, 0, 0); + rnl(F); + } +} +#endif + static void guards(FILE * F, const region * r, const faction * see) { /* die Partei see sieht dies; wegen @@ -1762,7 +1793,7 @@ guards(FILE * F, const region * r, const faction * see) boolean tarned = false; /* Bewachung */ - for (u = r->units; u; u = u->next) + for (u = r->units; u; u = u->next) { if (getguard(u)) { faction *f = u->faction; faction *fv = visible_faction(see, u); @@ -1780,21 +1811,25 @@ guards(FILE * F, const region * r, const faction * see) } } } - if (!nextguard && !tarned) return; - - strcpy(buf, "Die Region wird von "); + } + if (nextguard || tarned) { + strcpy(buf, "Die Region wird von "); + } else { + return; + } + for (i = 0; i!=nextguard+(tarned?1:0); ++i) { if (i!=0) { - if (i == nextguard-(tarned?0:1)) - scat(" und "); - else - scat(", "); - } - if (ilocale, "nr_alliances"), false); rnl(F); +#ifdef REGIONOWNERS + enemies(F, f); +#endif allies(F, f); rpline(F); @@ -2159,19 +2197,20 @@ report(FILE *F, faction * f, const faction_list * addresses, guards(F, r, f); durchreisende(F, r, f); } - else if (sd->mode==see_far) { - describe(F, r, 3, f); - guards(F, r, f); - durchreisende(F, r, f); - } - else if (turm_sieht_region) { - describe(F, r, 2, f); - durchreisende(F, r, f); - } else { - describe(F, r, 1, f); - durchreisende(F, r, f); - } - + else { + if (sd->mode==see_far) { + describe(F, r, 3, f); + guards(F, r, f); + durchreisende(F, r, f); + } + else if (turm_sieht_region) { + describe(F, r, 2, f); + durchreisende(F, r, f); + } else { + describe(F, r, 1, f); + durchreisende(F, r, f); + } + } /* Statistik */ if (wants_stats && unit_in_region == 1) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 248affb3d..fd81a4f50 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -197,6 +197,8 @@ const char *keywords[MAXKEYWORDS] = "ENDE", "FAHREN", "NUMMER", + "KRIEG", + "FRIEDEN", "FOLGEN", "FORSCHEN", "GIB", diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index dd349a2d5..dda40b01d 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -398,6 +398,8 @@ enum { K_END, K_DRIVE, K_NUMBER, + K_WAR, + K_PEACE, K_FOLLOW, K_RESEARCH, K_GIVE, diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 36f9eb2bf..b873de151 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -300,8 +300,8 @@ is_enemy(const struct faction * f, const struct faction * enemy) return false; } -void -add_enemy(struct faction * f, struct faction * enemy) +static void +add_enemy_i(struct faction * f, struct faction * enemy) { if (!is_enemy(f, enemy)) { struct faction_list * flist = malloc(sizeof(faction_list)); @@ -312,7 +312,14 @@ add_enemy(struct faction * f, struct faction * enemy) } void -remove_enemy(struct faction * f, const struct faction * enemy) +add_enemy(struct faction * f, struct faction * enemy) +{ + add_enemy_i(f, enemy); +/* add_enemy_i(enemy, f); */ +} + +static void +remove_enemy_i(struct faction * f, const struct faction * enemy) { struct faction_list **pflist = &f->enemies; while (*pflist!=NULL) { @@ -325,4 +332,12 @@ remove_enemy(struct faction * f, const struct faction * enemy) } } } + +void +remove_enemy(struct faction * f, struct faction * enemy) +{ + remove_enemy_i(f, enemy); +/* remove_enemy_i(enemy, f); */ +} + #endif diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index 334c52594..53a6fc263 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -92,7 +92,7 @@ extern void destroyfaction(faction * f); #ifdef REGIONOWNERS extern boolean is_enemy(const struct faction * f, const struct faction * enemy); extern void add_enemy(struct faction * f, struct faction * enemy); -extern void remove_enemy(struct faction * f, const struct faction * enemy); +extern void remove_enemy(struct faction * f, struct faction * enemy); #endif #endif diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index 9ab5cfc0b..2612b9789 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -5402,6 +5402,38 @@ "$unit($unit) konnte nicht von $region($region) nach $region($target) reisen, da der Besitzer der Region es verhinderte." + + + + + "$faction($faction) hat uns den Krieg erklärt." + "$faction($faction) has declared war on us." + + + + + + + "Wir haben $faction($faction) den Krieg erklärt." + "We declared war on $faction($faction)." + + + + + + + "$faction($faction) hat den Krieg mit uns beendet." + "$faction($faction) has declared peace with us." + + + + + + + "Wir haben den Krieg mit $faction($faction) beendet." + "We declared peace with $faction($faction)." + + diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 324432002..66a56945f 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -1839,6 +1839,14 @@ NUMMER + + FRIEDEN + PEACE + + + KRIEG + WAR + FOLGEN