diff --git a/src/common/attributes/key.c b/src/common/attributes/key.c index bdc487ef8..964072134 100644 --- a/src/common/attributes/key.c +++ b/src/common/attributes/key.c @@ -26,6 +26,14 @@ attrib_type at_key = { a_readdefault, }; +attrib * +add_key(attrib ** alist, int key) +{ + attrib * a = find_key(*alist, key); + if (a==NULL) a = a_add(alist, make_key(key)); + return a; +} + attrib * make_key(int key) { diff --git a/src/common/attributes/key.h b/src/common/attributes/key.h index 97b716df9..14d76abe7 100644 --- a/src/common/attributes/key.h +++ b/src/common/attributes/key.h @@ -16,4 +16,5 @@ extern struct attrib_type at_key; extern struct attrib * make_key(int key); extern struct attrib * find_key(struct attrib * alist, int key); +extern struct attrib * add_key(struct attrib ** alist, int key); extern void init_key(void); diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 425dc65f4..07ce7ff59 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -38,6 +38,7 @@ #include "race.h" #include "region.h" #include "render.h" +#include "spell.h" #include "ship.h" #include "skill.h" #include "unit.h" @@ -1020,13 +1021,16 @@ travel(region * first, unit * u, region * next, int flucht) while (b) { if (b->type==&bt_wisps) { - region * rl = rconnect(current, (direction_t)((dir+MAXDIRECTIONS-1)%MAXDIRECTIONS)); - region * rr = rconnect(current, (direction_t)((dir+1)%MAXDIRECTIONS)); - int j = rand() % 3; - if (j==0) break; - else if (j==1 && rl && landregion(rterrain(rl))==landregion(rterrain(next))) next = rl; - else if (j==2 && rr && landregion(rterrain(rr))==landregion(rterrain(next))) next = rr; - break; + wall_data * wd = (wall_data*)b->data; + if (wd->active) { + region * rl = rconnect(current, (direction_t)((dir+MAXDIRECTIONS-1)%MAXDIRECTIONS)); + region * rr = rconnect(current, (direction_t)((dir+1)%MAXDIRECTIONS)); + int j = rand() % 3; + if (j==0) break; + else if (j==1 && rl && landregion(rterrain(rl))==landregion(rterrain(next))) next = rl; + else if (j==2 && rr && landregion(rterrain(rr))==landregion(rterrain(next))) next = rr; + break; + } } if (b->type->move) b->type->move(b, u, current, next); b = b->next; diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 5abdebd5e..a99ed79a3 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -678,14 +678,14 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag /* generic permissions */ a = a_add(&f->attribs, a_new(&at_permissions)); - a_add((attrib**)&a->data.v, make_key(atoi36("gmterf"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmgate"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtele"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmgive"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmskil"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtake"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgr"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgu"))); + add_key((attrib**)&a->data.v, atoi36("gmterf")); + add_key((attrib**)&a->data.v, atoi36("gmtele")); + add_key((attrib**)&a->data.v, atoi36("gmgive")); + add_key((attrib**)&a->data.v, atoi36("gmskil")); + add_key((attrib**)&a->data.v, atoi36("gmtake")); + add_key((attrib**)&a->data.v, atoi36("gmmsgr")); + add_key((attrib**)&a->data.v, atoi36("gmmsgu")); + add_key((attrib**)&a->data.v, atoi36("gmgate")); a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver))); @@ -716,7 +716,7 @@ gm_addfaction(const char * email, plane * p, region * r) assert(p!=NULL); /* GM faction */ - a_add(&f->attribs, make_key(atoi36("quest"))); + add_key(&f->attribs, atoi36("quest")); f->banner = strdup("Questenpartei"); f->passw = strdup(itoa36(rand())); f->email = strdup(email); @@ -740,14 +740,14 @@ gm_addfaction(const char * email, plane * p, region * r) /* generic permissions */ a = a_add(&f->attribs, a_new(&at_permissions)); - a_add((attrib**)&a->data.v, make_key(atoi36("gmterf"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmgate"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtele"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmgive"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmskil"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtake"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgr"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgu"))); + add_key((attrib**)&a->data.v, atoi36("gmterf")); + add_key((attrib**)&a->data.v, atoi36("gmtele")); + add_key((attrib**)&a->data.v, atoi36("gmgive")); + add_key((attrib**)&a->data.v, atoi36("gmskil")); + add_key((attrib**)&a->data.v, atoi36("gmtake")); + add_key((attrib**)&a->data.v, atoi36("gmmsgr")); + add_key((attrib**)&a->data.v, atoi36("gmmsgu")); + add_key((attrib**)&a->data.v, atoi36("gmgate")); a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver))); @@ -809,39 +809,3 @@ gm_addplane(int radius, unsigned int flags, const char * name) } return p; } - -#ifdef TEST_GM_COMMANDS -void -setup_gm_faction(void) -{ - int i = atoi36("gms")-1; - faction * f = factions; - unit * newunit; - region * r = regions; - attrib * a; - - do { - f = findfaction(++i); - } while (f); - - f = (faction *) calloc(1, sizeof(faction)); - f->no = i; - set_string(&f->email, "gms@eressea-pbem.de"); - set_string(&f->passw, "geheim"); - set_string(&f->name, "GMs"); - f->alive = 1; - f->options |= (1 << O_REPORT); - f->options |= (1 << O_COMPUTER); - addlist(&factions, f); - - a = a_add(&f->attribs, a_new(&at_permissions)); - a_add((attrib**)&a->data.v, make_atgmcreate(&it_demonseye)); - a_add((attrib**)&a->data.v, make_key(atoi36("gmtf"))); - - while (r && !r->land) r=r->next; - newunit = createunit(r, f, 1, RC_DAEMON); - set_string(&newunit->name, "Flamdring, Gott des Feuers"); - set_money(newunit, 100); - fset(newunit, FL_ISNEW); -} -#endif diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 0cd07dd1a..0af139c35 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1064,9 +1064,7 @@ update_gms(void) int k; item_t i; for (k=0;keys[k];++k) { - if (!find_key((attrib*)permissions->data.v, atoi36(keys[k]))) { - a_add((attrib**)&permissions->data.v, make_key(atoi36(keys[k]))); - } + add_key((attrib**)&permissions->data.v, atoi36(keys[k])); } for (i=I_GREATSWORD;i!=I_KEKS;++i) { attrib * a = a_find(permissions, &at_gmcreate); @@ -1940,30 +1938,6 @@ test_gmquest(void) } #endif -#if 0 -static int -create_xe(void) -{ - attrib *a; - plane * p = gm_addplane(4, PFL_NOCOORDS | PFL_NORECRUITS | - PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | - PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED, - "Xontormia-Expreß"); - region * center = findregion(p->minx+(p->maxx-p->minx)/2, p->miny+(p->maxy-p->miny)/2); - faction * f = gm_addfaction("abeer@gmx.de", p, center); - - log_printf("Xe-Partei %s\n", factionname(f)); - - a = a_find(f->attribs, &at_permissions); - a_remove(&f->attribs, a); - a = a_add(&f->attribs, a_new(&at_permissions)); - a_add((attrib**)&a->data.v, make_key(atoi36("gmterf"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgr"))); - a_add((attrib**)&a->data.v, make_key(atoi36("gmmsgu"))); - return 0; -} -#endif - #define TEST_LOCALES 0 #if TEST_LOCALES static void