From da39fd21820c3a78496d2dd1953b504fcbf31333 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 17 Feb 2001 14:47:43 +0000 Subject: [PATCH] at_gm fuer gm-parteien. ungetestet, aber eher nciht kritisch --- src/common/kernel/eressea.c | 14 +++++++++++--- src/common/kernel/plane.c | 30 +++++++++++++++++++++++++++++- src/common/kernel/plane.h | 9 +++++++-- src/eressea/korrektur.c | 14 +++++++++++++- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index cdae73b57..09895f8c2 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: eressea.c,v 1.15 2001/02/15 02:41:46 enno Exp $ + * $Id: eressea.c,v 1.16 2001/02/17 14:47:42 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -24,6 +24,7 @@ /* attributes includes */ #include +#include /* kernel includes */ #include "message.h" @@ -695,11 +696,18 @@ int isallied(const plane * pl, const faction * f, const faction * f2, int mode) { ally *sf; + attrib * a; - if (f == f2) - return mode; + if (f == f2) return mode; if (f2==NULL) return 0; + a = a_find(f->attribs, &at_gm); + while (a) { + plane * p = (plane*)a->data.v; + if (p==pl) return mode; + a=a->next; + } + if (pl && pl->flags & PFL_FRIENDLY) return mode; if (mode != HELP_GIVE && pl && (pl->flags & PFL_NOALLIANCES)) return 0; for (sf = f->allies; sf; sf = sf->next) diff --git a/src/common/kernel/plane.c b/src/common/kernel/plane.c index b1d8efa80..5226dfd15 100644 --- a/src/common/kernel/plane.c +++ b/src/common/kernel/plane.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: plane.c,v 1.2 2001/01/26 16:19:40 enno Exp $ + * $Id: plane.c,v 1.3 2001/02/17 14:47:42 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -27,6 +27,9 @@ #include "region.h" #include "faction.h" +/* util includes */ +#include + /* libc includes */ #include #include @@ -225,3 +228,28 @@ rel_to_abs(struct plane *pl, struct faction * f, int rel, unsigned char index) return (rel + ursprung_y(f,pl)); } + + +void * +resolve_plane(void * id) +{ + return getplanebyid((int)id); +} + +void +write_plane_reference(const plane * u, FILE * F) +{ + fprintf(F, "%d ", u?(u->id):0); +} + +void +read_plane_reference(plane ** up, FILE * F) +{ + int i; + fscanf(F, "%d", &i); + if (i==0) *up = NULL; + { + *up = getplanebyid(i); + if (*up==NULL) ur_add((void*)i, (void**)&up, resolve_plane); + } +} diff --git a/src/common/kernel/plane.h b/src/common/kernel/plane.h index 7dec16ebb..b3f3fcc50 100644 --- a/src/common/kernel/plane.h +++ b/src/common/kernel/plane.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: plane.h,v 1.3 2001/02/05 16:11:58 enno Exp $ + * $Id: plane.h,v 1.4 2001/02/17 14:47:42 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -44,7 +44,7 @@ typedef struct plane { char *name; int minx,maxx,miny,maxy; unsigned int flags; - attrib *attribs; + struct attrib *attribs; } plane; struct plane *planes; @@ -64,4 +64,9 @@ void set_ursprung(struct faction *f, int id, int x, int y); plane * create_new_plane(int id, const char *name, int minx, int maxx, int miny, int maxy, int flags); plane * getplanebyname(const char *); extern int rel_to_abs(struct plane *pl, struct faction * f, int rel, unsigned char index); + +extern void * resolve_plane(void * data); +extern void write_plane_reference(const plane * p, FILE * F); +extern void read_plane_reference(plane ** pp, FILE * F); + #endif diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 3f1dca4c2..1f3c0bcf4 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: korrektur.c,v 1.24 2001/02/13 18:43:54 katze Exp $ + * $Id: korrektur.c,v 1.25 2001/02/17 14:47:43 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -1945,6 +1945,17 @@ fix_baumringel(void) #include void setup_gm_faction(void); +#include +static void +set_atgm(faction * f) +{ + plane * p = planes; + if (!f) return; + while (p) { + a_add(&f->attribs, make_gm(p)); + } +} + void korrektur(void) { @@ -1952,6 +1963,7 @@ korrektur(void) setup_gm_faction(); #endif make_gms(); + do_once(atoi36("rrgm"), set_atgm(findfaction(atoi36("rr")))); /* Wieder entfernen! */ do_once(atoi36("trgr"), fix_targetregion_resolve()); verify_owners(false);