From d7328077460041f356813843086979640e8c4f4d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Feb 2004 00:59:49 +0000 Subject: [PATCH] =?UTF-8?q?autoalliance:=20-=20beschleunigung=20durch=20ei?= =?UTF-8?q?n=20flag=20an=20der=20partei,=20das=20nicht-gms=20schneller=20a?= =?UTF-8?q?usschlie=C3=9Fen=20hilft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wormhole: - ein assert zur sicherheit - angabe der korrekten region in der message --- src/common/kernel/eressea.c | 40 +++++++++++++++++++++++++---------- src/common/kernel/faction.h | 1 + src/common/modules/wormhole.c | 6 +++++- 3 files changed, 35 insertions(+), 12 deletions(-) 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;