diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 3ebf2d7aa..88b4393be 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -807,24 +807,42 @@ unit_has_cursed_item(unit *u) return false; } +static void +init_gms(void) +{ + faction * f; + + for (f=factions;f;f=f->next) { + const attrib * a = a_findc(f->attribs, &at_gm); + + if (a!=NULL) fset(f, FFL_GM); + } +} + static int autoalliance(const plane * pl, const faction * sf, const faction * f2) { - int mode = 0; - attrib * a = a_find(f2->attribs, &at_gm); + boolean init = false; + if (!init) { + init_gms(); + init = true; + } + if (pl && (pl->flags & PFL_FRIENDLY)) return HELP_ALL; + /* if f2 is a gm in this plane, everyone has an auto-help to it */ + if (fval(f2, FFL_GM)) { + 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; - } + 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; + if (sf->alliance==f2->alliance) return AUTOALLIANCE; #endif - return mode; + return 0; } static int diff --git a/src/common/kernel/faction.h b/src/common/kernel/faction.h index af9fcb37e..f3af85133 100644 --- a/src/common/kernel/faction.h +++ b/src/common/kernel/faction.h @@ -35,6 +35,7 @@ typedef struct shortpwd { #define FFL_OVERRIDE (1<<27) /* Override-Passwort wurde benutzt */ #define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */ #define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */ +#define FFL_GM (1<<30) /* eine Partei mit Sonderrechten */ typedef struct faction { struct faction *next; diff --git a/src/common/modules/wormhole.c b/src/common/modules/wormhole.c index c29ae4c51..8c41d9f4d 100644 --- a/src/common/modules/wormhole.c +++ b/src/common/modules/wormhole.c @@ -28,6 +28,7 @@ #include /* libc includes */ +#include #include static boolean @@ -85,13 +86,16 @@ wormhole_age(struct attrib * a) move_unit(u, data->exit->region, NULL); maxtransport -= u->number; - m = msg_message("wormhole_exit", "unit region", u, r); + m = msg_message("wormhole_exit", "unit region", u, data->exit->region); add_message(&data->exit->region->msgs, m); add_message(&u->faction->msgs, m); msg_release(m); } + /* it's important that destroy_building doesn't change b->region, because + * otherwise the tunnel would no longer be bi-directional after this */ destroy_building(data->entry); + assert(data->entry->region==r); /* age returns 0 if the attribute needs to be removed, !=0 otherwise */ return -1;