autoalliance:

- beschleunigung durch ein flag an der partei, das nicht-gms schneller ausschließen hilft

wormhole:
- ein assert zur sicherheit
- angabe der korrekten region in der message
This commit is contained in:
Enno Rehling 2004-02-22 00:59:49 +00:00
parent a0cf754775
commit d732807746
3 changed files with 35 additions and 12 deletions

View File

@ -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

View File

@ -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;

View File

@ -28,6 +28,7 @@
#include <util/attrib.h>
/* libc includes */
#include <assert.h>
#include <stdlib.h>
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;