diff --git a/src/common/gamecode/creation.h b/src/common/gamecode/creation.h index d848bc464..f30bfe219 100644 --- a/src/common/gamecode/creation.h +++ b/src/common/gamecode/creation.h @@ -31,6 +31,5 @@ void listnames(void); void writemap(FILE * F, int mode); void regionspells(void); -void moveunit(void); #endif diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index a2bcde1ce..31d424449 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1182,7 +1182,14 @@ set_ally(unit * u, strlist * S) sf->status = HELP_ALL; break; - case P_GIB: + case P_TRAVEL: + if (not_kw == P_NOT) + sf->status = sf->status & (HELP_ALL - HELP_TRAVEL); + else + sf->status = sf->status | HELP_TRAVEL; + break; + + case P_GIB: if (not_kw == P_NOT) sf->status = sf->status & (HELP_ALL - HELP_GIVE); else diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 95fe74f54..c70489b8c 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -12,7 +12,6 @@ * prior permission by the authors of Eressea. */ -#define FAST_SEEN 0 #define INDENT 0 #include @@ -1672,6 +1671,10 @@ show_allies(const faction * f, const ally * allies) for (h = 1; h < HELP_ALL; h *= 2) { if ((mode & h) == h) switch (h) { + case HELP_TRAVEL: + scat("Durchreise"); + hh = 1; + break; case HELP_MONEY: scat("Silber"); hh = 1; @@ -2574,52 +2577,6 @@ seen_done(void) } } -#if FAST_SEEN -static void -init_intervals() -{ - region * r; - for (r=regions;r;r=r->next) { - unit * u; - attrib * a; - for (a=a_find(r->attribs, &at_travelunit);a;a=a->nexttype) { - unit * v = (unit*)a->data.v; - faction * f = v->faction; - if (!f) continue; - if (!f->first) - { - assert(!f->last); - f->first = r; - } - f->last = r->next; - } - for (a=a_find(r->attribs, &at_lighthouse);a;a=a->nexttype) { - building * b = (building*)a->data.v; - region * br = b->region; - if (!b->region) continue; - for (u=br->units;u;u=u->next) { - faction * f = u->faction; - if (!f->first) - { - assert(!f->last); - f->first = r; - } - f->last = r->next; - } - } - for (u=r->units;u;u=u->next) { - faction * f = u->faction; - if (!f->first) - { - assert(!f->last); - f->first = r; - } - f->last = r->next; - } - } -} -#endif - seen_region * find_seen(const region * r) { @@ -2919,9 +2876,6 @@ reports(void) printf("\n"); report_donations(); -#if FAST_SEEN - init_intervals(); -#endif remove_empty_units(); log_printf("Report timestamp - %s\n", pzTime); for (f = factions; f; f = f->next) { diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 1be341ee2..248affb3d 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -151,6 +151,7 @@ const char *parameters[MAXPARAMS] = "GEBÄUDE", "GIB", /* Für HELFE */ "KÄMPFE", + "DURCHREISE", "BEWACHE", "ZAUBER", "PAUSE", @@ -478,9 +479,6 @@ stripfaction (faction * f) free(f->passw); free(f->override); free(f->name); -#ifndef FAST_REGION - vset_destroy(&f->regions); -#endif while (f->attribs) a_remove (&f->attribs, f->attribs); freelist(f->ursprung); funhash(f); diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index 9d54cc002..dd349a2d5 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -163,10 +163,16 @@ struct xml_stack; #define CURSETYPE_VERSION 312 #define ALLIANCES_VERSION 313 #define DBLINK_VERSION 314 +#define REGIONOWNERS_VERSION 315 #define MIN_VERSION TYPES_VERSION #define UGROUPS_VERSION 400 /* nicht aktivieren, nicht fertig */ -#define RELEASE_VERSION ALLIANCES_VERSION + +#ifdef REGIONOWNERS +# define RELEASE_VERSION REGIONOWNERS_VERSION +#else +# define RELEASE_VERSION DBLINK_VERSION +#endif /* #if RELEASE_VERSION >= UGROUPS_VERSION @@ -495,6 +501,7 @@ enum { P_GEBAEUDE, P_GIB, P_KAEMPFE, + P_TRAVEL, P_GUARD, P_ZAUBER, P_PAUSE, @@ -828,8 +835,9 @@ enum { #define HELP_OBSERVE 4 /* Bei Wahrnehmung mithelfen */ #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_FSTEALTH 32 /* Parteitarnung anzeigen. */ +#define HELP_TRAVEL 64 /* Laesst Regionen betreten. */ +#define HELP_ALL (127-HELP_OBSERVE) /* Alle "positiven" HELPs zusammen */ /* HELP_OBSERVE deaktiviert */ /* ------------------------------------------------------------- */ /* Prototypen */ diff --git a/src/common/kernel/faction.c b/src/common/kernel/faction.c index 0bfb7595c..36f9eb2bf 100644 --- a/src/common/kernel/faction.c +++ b/src/common/kernel/faction.c @@ -289,3 +289,40 @@ destroyfaction(faction * f) } } +#ifdef REGIONOWNERS +boolean +is_enemy(const struct faction * f, const struct faction * enemy) +{ + struct faction_list * flist = f->enemies; + for (;flist!=NULL;flist=flist->next) { + if (flist->data==enemy) return true; + } + return false; +} + +void +add_enemy(struct faction * f, struct faction * enemy) +{ + if (!is_enemy(f, enemy)) { + struct faction_list * flist = malloc(sizeof(faction_list)); + flist->next = f->enemies; + flist->data = enemy; + f->enemies = flist; + } +} + +void +remove_enemy(struct faction * f, const struct faction * enemy) +{ + struct faction_list **pflist = &f->enemies; + while (*pflist!=NULL) { + struct faction_list * flist = *pflist; + if (flist->data==enemy) { + *pflist = flist->next; + free(flist); + } else { + pflist = &flist->next; + } + } +} +#endif diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index 8d4a47a44..334c52594 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -61,13 +61,13 @@ typedef struct faction { #endif #ifdef VICTORY_DELAY unsigned char victory_delay; -#endif -#ifndef FAST_REGION - vset regions; #endif struct unit * units; struct attrib *attribs; struct message_list * msgs; +#ifdef REGIONOWNERS + struct faction_list * enemies; +#endif struct bmsg { struct bmsg * next; struct region * r; @@ -89,4 +89,10 @@ extern struct unit * addplayer(struct region *r, const char *email, extern boolean checkpasswd(const faction * f, const char * passwd); 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); +#endif + #endif diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index d358f4503..108e99ade 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -143,6 +143,19 @@ static attrib_type at_driveweight = { "driveweight", NULL, NULL, NULL, NULL, NULL }; +static boolean +entrance_allowed(const struct unit * u, const struct region * r) +{ +#ifdef REGIONOWNERS + unit * owner = region_owner(r); + if (owner==NULL || u->faction==owner->faction) return true; + if (alliedunit(owner, u->faction, HELP_TRAVEL)) return true; + if (is_enemy(u->faction, owner->faction)) return true; + return false; +#endif + return true; +} + int personcapacity(const unit *u) { @@ -1073,6 +1086,11 @@ travel(region * first, unit * u, region * next, int flucht) ADDMSG(&u->faction->msgs, msg_message("leavefail", "unit region", u, next)); } + if (!entrance_allowed(u, next)) { + ADDMSG(&u->faction->msgs, msg_message("regionowned", + "unit region target", u, current, next)); + break; + } if ((wache = bewegung_blockiert_von(u, current)) != (unit *) NULL && gereist != 0) { diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 5853ed3ee..99b8b033d 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -25,6 +25,7 @@ /* kernel includes */ #include "border.h" +#include "building.h" #include "curse.h" #include "faction.h" #include "item.h" @@ -32,6 +33,7 @@ #include "plane.h" #include "region.h" #include "resources.h" +#include "unit.h" /* util includes */ #include @@ -1090,4 +1092,24 @@ r_addmessage(struct region * r, const struct faction * viewer, struct message * return add_message(&imsg->msgs, msg); } - +struct unit * +region_owner(const struct region * r) +{ +#ifdef REGIONOWNERS + struct unit * owner = NULL; + int maxsize = 0; + building * b = r->buildings; + for (;b!=NULL;b=b->next) { + if (b->size>maxsize) { + unit * u = buildingowner(r, b); + if (u) { + owner = u; + maxsize=b->size; + } + } + } + return owner; +#else + return NULL; +#endif +} diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index 6259c4cff..d0b12ebbc 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -218,4 +218,6 @@ extern int production(const struct region *r); extern int read_region_reference(struct region ** r, FILE * F); extern void write_region_reference(const struct region * r, FILE * F); +extern struct unit * region_owner(const struct region * r); + #endif /* _REGION_H */ diff --git a/src/common/kernel/reports.h b/src/common/kernel/reports.h index 47370f520..c1dc25d0f 100644 --- a/src/common/kernel/reports.h +++ b/src/common/kernel/reports.h @@ -56,14 +56,6 @@ char *translate_regions(const char *st, const struct faction * f); char *replace_global_coords(const char *s, const struct faction * f); -#ifdef USE_MERIAN -#ifdef FAST_REGION -void merian(FILE * out, struct faction *f); -#else -void merian(FILE * out, vset* regs, struct faction *f); -#endif -#endif - char *f_regionid(const struct region *r, const struct faction *f); /* für fast_region und neuen CR: */ diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 0b9b1dd1d..fcc5f0c74 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -434,6 +434,38 @@ getbuf(FILE * F) return buf; } +#ifdef REGIONOWNERS +static void +read_enemies(FILE * F, faction * f) +{ + if (global.data_versionenemies = NULL; + for (;;) { + char zText[32]; + fscanf(F, "%s", zText); + if (strcmp(zText, "end")==0) break; + else { + int fno = atoi36(zText); + faction_list * flist = malloc(sizeof(faction_list)); + flist->next = f->enemies; + f->enemies = flist; + ur_add((void*)fno, (void**)&flist->data, resolve_faction); + } + } +} + +static void +write_enemies(FILE * F, const faction_list * flist) +{ +#if RELEASE_VERSION>=REGIONOWNERS_VERSION + while (flist) { + fprintf(F, "%s ", itoa36(flist->data->no)); + } + fputs("end\n", F); +#endif +} +#endif + static unit * unitorders(FILE * F, struct faction * f) { @@ -2188,6 +2220,9 @@ readfaction(FILE * F) } } read_groups(F, f); +#ifdef REGIONOWNERS + read_enemies(F, f); +#endif return f; } @@ -2242,4 +2277,7 @@ writefaction(FILE * F, const faction * f) fprintf(F, "end"); wnl(F); write_groups(F, f->groups); +#ifdef REGIONOWNERS + write_enemies(F, f->enemies); +#endif } diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index f22e7fec5..a100188ba 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -43,6 +43,7 @@ #define NEWATSROI 0 #define CHECK_OVERLOAD_ON_ENTER +#undef REGIONOWNERS #define MUSEUM_MODULE #define ARENA_MODULE diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index 96cba0aee..9ab5cfc0b 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -5393,17 +5393,22 @@ - + + + + + + + "$unit($unit) konnte nicht von $region($region) nach $region($target) reisen, da der Besitzer der Region es verhinderte." + + + - - - "$unit($unit) wurde in $region($region) von $unit($guard) aufgehalten." - - + "$unit($unit) wurde in $region($region) von $unit($guard) aufgehalten." @@ -7730,20 +7735,12 @@ "($int36($id))" - + - - - "$unit($mage) läßt einen Teil seiner selbst in die Erde fliessen. Die Bäume, die Transformation überlebt haben, erscheinen nun viel kräftiger." - - - - - "The power of $unit($mage) flows into the region and the trees which survived the spell appear stronger now." - - + "$unit($mage) läßt einen Teil seiner selbst in die Erde fliessen. Die Bäume, die Transformation überlebt haben, erscheinen nun viel kräftiger." + "The power of $unit($mage) flows into the region and the trees which survived the spell appear stronger now." diff --git a/src/res/de/strings.xml b/src/res/de/strings.xml index 18d6d163a..324432002 100644 --- a/src/res/de/strings.xml +++ b/src/res/de/strings.xml @@ -1626,6 +1626,10 @@ KRÄUTER + + DURCHREISE + TRAVEL + KÄMPFE