From 3fb3e7b2010e9fde1d12a2af83440c6b4717219a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 25 Feb 2006 00:12:48 +0000 Subject: [PATCH] New way of storing attrib-lists should make it faster to find a specific one and jump over entire classes of attribs. --- src/common/attributes/key.c | 4 +- src/common/attributes/variable.c | 55 +++++------ src/common/gamecode/creport.c | 10 +- src/common/gamecode/laws.c | 10 +- src/common/gamecode/report.c | 14 +-- src/common/gamecode/study.c | 6 +- src/common/kernel/alchemy.c | 36 +++---- src/common/kernel/battle.c | 9 +- src/common/kernel/build.c | 13 +-- src/common/kernel/curse.c | 6 +- src/common/kernel/eressea.c | 21 ++-- src/common/kernel/karma.c | 10 +- src/common/kernel/kernel.vcproj | 100 ------------------- src/common/kernel/magic.c | 21 ++-- src/common/kernel/movement.c | 18 ++-- src/common/kernel/region.c | 4 +- src/common/kernel/reports.c | 2 +- src/common/kernel/skill.c | 2 +- src/common/kernel/unit.c | 14 +-- src/common/modules/gmcmd.c | 2 +- src/common/modules/museum.c | 14 +-- src/common/spells/spells.c | 16 +-- src/common/util/attrib.c | 161 ++++++++++++++++++++----------- src/common/util/attrib.h | 2 +- src/common/util/cvector.c | 1 + src/common/util/event.c | 31 +++--- src/common/util/util.vcproj | 3 + src/eressea.sln | 49 ---------- src/eressea/korrektur.c | 6 +- src/eressea/lua/objects.cpp | 15 ++- src/mapper/mapper.vcproj | 122 ----------------------- 31 files changed, 281 insertions(+), 496 deletions(-) diff --git a/src/common/attributes/key.c b/src/common/attributes/key.c index 27f6b0013..f63cc5a9d 100644 --- a/src/common/attributes/key.c +++ b/src/common/attributes/key.c @@ -48,7 +48,9 @@ attrib * find_key(attrib * alist, int key) { attrib * a = a_find(alist, &at_key); - while (a && a->data.i != key) a = a->nexttype; + while (a && a->type==&at_key && a->data.i != key) { + a = a->next; + } return a; } diff --git a/src/common/attributes/variable.c b/src/common/attributes/variable.c index 49e15a0b0..0859ff24f 100644 --- a/src/common/attributes/variable.c +++ b/src/common/attributes/variable.c @@ -69,16 +69,14 @@ attrib_type at_variable = { const char * get_variable(attrib *a, const char *key) { - attrib *ap; + attrib *ap = a_find(a, &at_variable);; - for(ap = a_find(a, &at_variable); ap; ap=ap->nexttype) { - if(strcmp(key, ((variable *)ap->data.v)->key) == 0) { - break; + while (ap && ap->type==&at_variable) { + variable * var = (variable *)ap->data.v; + if (strcmp(key, var->key) == 0) { + return var->value; } - } - - if(ap) { - return ((variable *)ap->data.v)->value; + ap = ap->next; } return NULL; @@ -87,42 +85,41 @@ get_variable(attrib *a, const char *key) void set_variable(attrib **app, const char *key, const char *value) { - attrib *ap; + attrib *ap = a_find(*app, &at_variable); assert(value); - for(ap = a_find(*app, &at_variable); ap; ap=ap->nexttype) { - if(strcmp(key, ((variable *)ap->data.v)->key) == 0) { - break; + while (ap && ap->type==&at_variable) { + variable * var = (variable *)ap->data.v; + if (strcmp(key, var->key) == 0) { + free(var->value); + var->value = strdup(value); + return; } + ap = ap->next; } - if(ap) { - free(((variable *)ap->data.v)->value); - ((variable *)ap->data.v)->value = strdup(value); - } else { - ap = a_add(app, a_new(&at_variable)); - ((variable *)ap->data.v)->key = strdup(key); - ((variable *)ap->data.v)->value = strdup(value); - } + ap = a_add(app, a_new(&at_variable)); + ((variable *)ap->data.v)->key = strdup(key); + ((variable *)ap->data.v)->value = strdup(value); } void delete_variable(attrib **app, const char *key) { - attrib *ap; + attrib *ap = a_find(*app, &at_variable); - for(ap = a_find(*app, &at_variable); ap; ap=ap->nexttype) { - if(strcmp(key, ((variable *)ap->data.v)->key) == 0) { - break; + while (ap && ap->type==&at_variable) { + variable * var = (variable *)ap->data.v; + if (strcmp(key, var->key) == 0) { + free(var->key); + free(var->value); + a_remove(app, ap); + break; } + ap = ap->next; } - if(ap) { - free(((variable *)ap->data.v)->key); - free(((variable *)ap->data.v)->value); - a_remove(app, ap); - } } void diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 42f369870..ea9c4e64b 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -1202,12 +1202,12 @@ report_computer(const char * filename, report_context * ctx) cr_find_address(F, f, ctx->addresses); a = a_find(f->attribs, &at_reportspell); - while (a) { + while (a && a->type==&at_reportspell) { spell *sp = (spell *)a->data.v; cr_reportspell(F, sp, f->locale); - a = a->nexttype; + a = a->next; } - for (a=a_find(f->attribs, &at_showitem);a;a=a->nexttype) { + for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) { const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype); requirement * m; const char * ch, * description = NULL; @@ -1396,7 +1396,7 @@ report_computer(const char * filename, report_context * ctx) boolean seeunits = false, seeships = false; const attrib * ru; /* show units pulled through region */ - for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) { + for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type==&at_travelunit; ru = ru->next) { unit * u = (unit*)ru->data.v; if (cansee_durchgezogen(f, r, u, 0) && r!=u->region) { if (!u->ship || !fval(u, UFL_OWNER)) continue; @@ -1405,7 +1405,7 @@ report_computer(const char * filename, report_context * ctx) fprintf(F, "\"%s\"\n", shipname(u->ship)); } } - for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) { + for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type==&at_travelunit; ru = ru->next) { unit * u = (unit*)ru->data.v; if (cansee_durchgezogen(f, r, u, 0) && r!=u->region) { if (u->ship) continue; diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index b33ed0866..480050b88 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -2474,7 +2474,7 @@ reshow(unit * u, struct order * ord, const char * s, param_t p) sp = get_spellfromtoken(u, s, u->faction->locale); if (sp!=NULL && has_spell(u, sp)) { attrib *a = a_find(u->faction->attribs, &at_seenspell); - while (a!=NULL && a->data.v!=sp) a = a->nexttype; + while (a!=NULL && a->type==&at_seenspell && a->data.v!=sp) a = a->next; if (a!=NULL) a_remove(&u->faction->attribs, a); break; } @@ -2688,16 +2688,16 @@ instant_orders(void) for (f = factions; f; f = f->next) { attrib *a; a = a_find(f->attribs, &at_showitem); - while(a!=NULL) { + while (a!=NULL && a->type==&at_showitem) { const item_type * itype = (const item_type *)a->data.v; const potion_type * ptype = resource2potion(itype->rtype); + attrib * an = a->next; if (ptype!=NULL) { - attrib * n = a->nexttype; /* potions werden separat behandelt */ display_item(f, NULL, (const item_type *)a->data.v); a_remove(&f->attribs, a); - a = n; - } else a = a->nexttype; + } + a = an; } } diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index cc63b2953..ac3b08183 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -982,7 +982,7 @@ describe(FILE * F, const region * r, int partial, faction * f) } } /* Spezielle Richtungen */ - for (a = a_find(r->attribs, &at_direction);a;a = a->nexttype) { + for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) { spec_direction * d = (spec_direction *)(a->data.v); strcpy(bufp++, " "); bufp += strxcpy(bufp, d->desc); @@ -1155,7 +1155,7 @@ durchreisende(FILE * F, const region * r, const faction * f) /* Wieviele sind aufzulisten? Für die Grammatik. */ if (fval(r, RF_TRAVELUNIT)) { - for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) { + for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type!=&at_travelunit; ru = ru->next) { unit * u = (unit*)ru->data.v; if (cansee_durchgezogen(f, r, u, 0) > 0 && r!=u->region) { if (u->ship && !fval(u, UFL_OWNER)) @@ -1173,7 +1173,7 @@ durchreisende(FILE * F, const region * r, const faction * f) buf[0] = 0; rnl(F); - for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) { + for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type==&at_travelunit; ru = ru->next) { unit * u = (unit*)ru->data.v; if (cansee_durchgezogen(f, r, u, 0) > 0 && r!=u->region) { if (u->ship && !fval(u, UFL_OWNER)) @@ -1778,7 +1778,7 @@ report_plaintext(const char * filename, report_context * ctx) #ifdef KARMA_MODULE buf[0] = 0; dh = 0; - for (a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) { + for (a=a_find(f->attribs, &at_faction_special); a && a->type==&at_faction_special; a=a->next) { char buf2[80]; dh++; if (fspecials[a->data.sa[0]].maxlevel != 100) { @@ -1930,15 +1930,15 @@ report_plaintext(const char * filename, report_context * ctx) if (a) { rnl(F); centre(F, LOC(f->locale, "section_newspells"), true); - while (a) { + while (a && a->type==&at_reportspell) { spell *sp = (spell *)a->data.v; report_spell(F, sp, f->locale); - a = a->nexttype; + a = a->next; } } ch = 0; - for (a=a_find(f->attribs, &at_showitem);a;a=a->nexttype) { + for (a=a_find(f->attribs, &at_showitem);a && a->type==&at_showitem;a=a->next) { const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype); const char * description = NULL; requirement * m; diff --git a/src/common/gamecode/study.c b/src/common/gamecode/study.c index 58d352a0d..8e148c4a9 100644 --- a/src/common/gamecode/study.c +++ b/src/common/gamecode/study.c @@ -668,7 +668,7 @@ learn(void) teach->value += u->number * 10; } - if (is_cursed(r->attribs,C_BADLEARN,0)) { + if (is_cursed(r->attribs, C_BADLEARN,0)) { teach->value -= u->number * 10; } @@ -724,8 +724,8 @@ learn(void) for (ptype=potiontypes; ptype; ptype=ptype->next) { if (skill == ptype->level * 2) { attrib * a = a_find(f->attribs, &at_showitem); - while (a && a->data.v != ptype) a=a->nexttype; - if (!a) { + while (a && a->type==&at_showitem && a->data.v != ptype) a=a->next; + if (a==NULL || a->type!=&at_showitem) { a = a_add(&f->attribs, a_new(&at_showitem)); a->data.v = (void*) ptype->itype; } diff --git a/src/common/kernel/alchemy.c b/src/common/kernel/alchemy.c index 375ddc63d..eb8e96b5f 100644 --- a/src/common/kernel/alchemy.c +++ b/src/common/kernel/alchemy.c @@ -200,7 +200,7 @@ int get_effect(const unit * u, const potion_type * effect) { const attrib * a; - for (a=a_find(u->attribs, &at_effect); a!=NULL; a=a->nexttype) { + for (a=a_find(u->attribs, &at_effect); a!=NULL && a->type==&at_effect; a=a->next) { const effect_data * data = (const effect_data *)a->data.v; if (data->type==effect) return data->value; } @@ -210,27 +210,27 @@ get_effect(const unit * u, const potion_type * effect) int change_effect (unit * u, const potion_type * effect, int delta) { - attrib ** ap = &u->attribs, * a; + attrib * a = a_find(u->attribs, &at_effect); effect_data * data = NULL; assert(delta!=0); - while (*ap && (*ap)->type!=&at_effect) ap=&(*ap)->next; - a = *ap; - while (a) { + while (a && a->type==&at_effect) { data = (effect_data *)a->data.v; - if (data->type==effect) break; - a=a->nexttype; - } - if (a!=NULL && data->value+delta==0) { - a_remove(&u->attribs, a); - return 0; - } else if (a!=NULL) { - data->value += delta; - } else { - attrib * an = a_add(ap, a_new(&at_effect)); - data = (effect_data*)an->data.v; - data->type = effect; - data->value = delta; + if (data->type==effect) { + if (data->value+delta==0) { + a_remove(&u->attribs, a); + return 0; + } else { + data->value += delta; + return data->value; + } + } + a = a->next; } + + a = a_add(&u->attribs, a_new(&at_effect)); + data = (effect_data*)a->data.v; + data->type = effect; + data->value = delta; return data->value; } diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 3ea8c4fc2..d44c7d6b4 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -2355,12 +2355,13 @@ aftermath(battle * b) int dead = du->number - df->alive - df->run.number; int pr_mercy = 0; #ifdef KARMA_MODULE - const attrib *a; + const attrib *a= a_find(du->attribs, &at_prayer_effect); - for (a = a_find(du->attribs, &at_prayer_effect); a; a = a->nexttype) { + while (a && a->type==&at_prayer_effect) { if (a->data.sa[0] == PR_MERCY) { pr_mercy = a->data.sa[1]; } + a = a->next; } #endif /* KARMA_MODULE */ @@ -2914,8 +2915,8 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack) strongmen = min(fig->unit->number, get_item(u, I_TROLLBELT)); #ifdef KARMA_MODULE - for (a = a_find(u->attribs, &at_prayer_effect); a; a = a->nexttype) { - if (a->data.sa[0] == PR_AID) { + for (a = a_find(u->attribs, &at_prayer_effect); a && a->type==&at_prayer_effect; a = a->next) { + if (a->data.sa[0] == PR_AID) { pr_aid = true; break; } diff --git a/src/common/kernel/build.c b/src/common/kernel/build.c index bc2f13a66..2e66177c7 100644 --- a/src/common/kernel/build.c +++ b/src/common/kernel/build.c @@ -593,7 +593,7 @@ required(int size, int msize, int maxneed) static int matmod(const attrib * a, const unit * u, const resource_type * material, int value) { - for (a=a_find((attrib*)a, &at_matmod);a;a=a->nexttype) { + for (a=a_find((attrib*)a, &at_matmod);a && a->type==&at_matmod;a=a->next) { mm_fun fun = (mm_fun)a->data.f; value = fun(u, material, value); if (value<0) return value; /* pass errors to caller */ @@ -1110,15 +1110,16 @@ void remove_contacts(void) { region *r; - unit *u; - attrib *a; for (r = regions; r; r = r->next) { + unit *u; + for (u = r->units; u; u = u->next) { - a = (attrib *)a_find(u->attribs, &at_contact); - while(a != NULL) { + attrib * a = (attrib *)a_find(u->attribs, &at_contact); + + while (a!=NULL &&a->type==&at_contact) { attrib * ar = a; - a = a->nexttype; + a = a->next; a_remove(&u->attribs, ar); } } diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c index 5cf6d85b5..9f8fb8398 100644 --- a/src/common/kernel/curse.c +++ b/src/common/kernel/curse.c @@ -352,7 +352,7 @@ remove_allcurse(attrib **ap, const void * data, boolean(*compare)(const attrib * { attrib * a = a_select(*ap, data, compare); while (a) { - attrib * next = a->nexttype; + attrib * next = a->next; a_remove(ap, a); a = a_select(next, data, compare); } @@ -618,10 +618,10 @@ transfer_curse(unit * u, unit * u2, int n) attrib * a; a = a_find(u->attribs, &at_curse); - while (a) { + while (a && a->type==&at_curse) { curse *c = (curse*)a->data.v; do_transfer_curse(c, u, u2, n); - a = a->nexttype; + a = a->next; } } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 6294dade7..fd582c685 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -607,9 +607,9 @@ shipspeed (const ship * sh, const unit * u) } a = a_find(sh->attribs, &at_speedup); - while (a != NULL) { + while (a != NULL && a->type==&at_speedup) { k += a->data.sa[0]; - a = a->nexttype; + a = a->next; } c = get_curse(sh->attribs, ct_find("shipspeedup")); @@ -887,7 +887,7 @@ scale_number (unit * u, int n) remain = 0; u->hp = 0; } - for (a = a_find(u->attribs, &at_effect);a;a=a->nexttype) { + for (a = a_find(u->attribs, &at_effect);a && a->type==&at_effect;a=a->next) { effect_data * data = (effect_data *)a->data.v; int snew = data->value / u->number * n; if (n) { @@ -1191,10 +1191,10 @@ update_lighthouse(building * lh) if (!fval(r2->terrain, SEA_REGION)) continue; if (distance(r, r2) > d) continue; a = a_find(r2->attribs, &at_lighthouse); - while (a) { + while (a && a->type==&at_lighthouse) { building * b = (building*)a->data.v; if (b==lh) break; - a=a->nexttype; + a = a->next; } if (!a) { a = a_add(&r2->attribs, a_new(&at_lighthouse)); @@ -2022,7 +2022,7 @@ get_lighthouses(const region * r) if (!fval(r->terrain, SEA_REGION)) return NULL; - for (a = a_find(r->attribs, &at_lighthouse);a;a=a->nexttype) { + for (a = a_find(r->attribs, &at_lighthouse);a && a->type==&at_lighthouse;a=a->next) { building *b = (building *)a->data.v; region *r2 = b->region; @@ -2081,7 +2081,7 @@ check_leuchtturm(region * r, faction * f) if (!fval(r->terrain, SEA_REGION)) return false; - for (a = a_find(r->attribs, &at_lighthouse);a;a=a->nexttype) { + for (a = a_find(r->attribs, &at_lighthouse);a && a->type==&at_lighthouse;a=a->next) { building *b = (building *)a->data.v; region *r2 = b->region; @@ -2130,16 +2130,17 @@ lastregion (faction * f) /* we continue from the best region and look for travelthru etc. */ for (r = f->last->next; r; r = r->next) { plane * p = rplane(r); - attrib *ru; /* search the region for travelthru-attributes: */ if (fval(r, RF_TRAVELUNIT)) { - for (ru = a_find(r->attribs, &at_travelunit); ru; ru = ru->nexttype) { + attrib * ru = a_find(r->attribs, &at_travelunit); + while (ru && ru->type==&at_travelunit) { u = (unit*)ru->data.v; if (u->faction == f) { f->last = r; break; } + ru = ru->next; } } if (f->last == r) continue; @@ -2844,7 +2845,7 @@ findspecialdirection(const region *r, const char *token) spec_direction *d; if (strlen(token)==0) return NULL; - for (a = a_find(r->attribs, &at_direction);a;a=a->nexttype) { + for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) { d = (spec_direction *)(a->data.v); if (d->active && strncasecmp(d->keyword, token, strlen(token)) == 0) { diff --git a/src/common/kernel/karma.c b/src/common/kernel/karma.c index adaf50d6c..29060f857 100644 --- a/src/common/kernel/karma.c +++ b/src/common/kernel/karma.c @@ -318,7 +318,7 @@ buy_special(unit *u, struct order * ord, fspecial_t special) /* Kosten berechnen */ - for(a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) { + for(a=a_find(f->attribs, &at_faction_special); a && a->type==&at_faction_special; a=a->next) { count += a->data.sa[1]; if(a->data.sa[0] == special) a2 = a; } @@ -356,7 +356,7 @@ fspecial(const faction *f, fspecial_t special) { attrib *a; - for (a=a_find(f->attribs, &at_faction_special); a; a=a->nexttype) { + for (a=a_find(f->attribs, &at_faction_special); a && a->type==&at_faction_special; a=a->next) { if(a->data.sa[0] == special) return a->data.sa[1]; } return 0; @@ -498,7 +498,7 @@ jihad_cmd(unit * u, struct order * ord) attrib *a; const char *s; - for (a = a_find(f->attribs, &at_jihad); a; a = a->nexttype) { + for (a = a_find(f->attribs, &at_jihad); a && a->type==&at_jihad; a = a->next) { has += a->data.sa[1]; } @@ -524,7 +524,7 @@ jihad_cmd(unit * u, struct order * ord) return 0; } - for (a = a_find(f->attribs, &at_jihad); a; a = a->nexttype) { + for (a = a_find(f->attribs, &at_jihad); a && a->type==&at_jihad; a = a->next) { if (a->data.sa[0] == jrt) break; } @@ -546,7 +546,7 @@ jihad(faction *f, const race * rc) attrib *a; race_t jrt = old_race(rc); - for(a = a_find(f->attribs, &at_jihad); a; a = a->nexttype) { + for(a = a_find(f->attribs, &at_jihad); a && a->type==&at_jihad; a = a->next) { if(a->data.sa[0] == jrt) return a->data.sa[1]; } return 0; diff --git a/src/common/kernel/kernel.vcproj b/src/common/kernel/kernel.vcproj index 44bb07cf7..372593fe3 100644 --- a/src/common/kernel/kernel.vcproj +++ b/src/common/kernel/kernel.vcproj @@ -167,106 +167,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index 7fd579887..abd0ca129 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -401,7 +401,7 @@ already_seen(const faction * f, const spell * sp) { attrib *a; - for (a = a_find(f->attribs, &at_seenspell); a; a=a->nexttype) { + for (a = a_find(f->attribs, &at_seenspell); a && a->type==&at_seenspell; a=a->next) { if (a->data.v==sp) return true; } return false; @@ -1101,7 +1101,7 @@ magic_resistance(unit *target) /* Auswirkungen von Zaubern auf der Region */ a = a_find(target->region->attribs, &at_curse); - while (a) { + while (a && a->type==&at_curse) { curse *c = (curse*)a->data.v; unit *mage = c->magician; @@ -1114,12 +1114,13 @@ magic_resistance(unit *target) } else if (c->type == ct_find("badmagicresistancezone")) { if (alliedunit(mage, target->faction, HELP_GUARD)) { - a = a->nexttype; + /* TODO: hier sollte doch sicher was passieren? */ + a = a->next; continue; } } } - a = a->nexttype; + a = a->next; } /* Bonus durch Artefakte */ /* TODO (noch gibs keine)*/ @@ -2116,10 +2117,10 @@ set_familiar(unit * mage, unit * familiar) { /* if the skill modifier for the mage does not yet exist, add it */ attrib * a = a_find(mage->attribs, &at_skillmod); - while (a) { + while (a && a->type==&at_skillmod) { skillmod_data * smd = (skillmod_data *)a->data.v; if (smd->special==sm_familiar) break; - a = a->nexttype; + a = a->next; } if (a==NULL) { attrib * an = a_add(&mage->attribs, a_new(&at_skillmod)); @@ -2151,8 +2152,8 @@ remove_familiar(unit *mage) a_remove(&mage->attribs, a); a = a_find(mage->attribs, &at_skillmod); - while (a) { - an = a->nexttype; + while (a && a->type==&at_skillmod) { + an = a->next; smd = (skillmod_data *)a->data.v; if (smd->special==sm_familiar) a_remove(&mage->attribs, a); a = an; @@ -2164,10 +2165,10 @@ create_newfamiliar(unit * mage, unit * familiar) { /* if the skill modifier for the mage does not yet exist, add it */ attrib * a = a_find(mage->attribs, &at_skillmod); - while (a) { + while (a && a->type==&at_skillmod) { skillmod_data * smd = (skillmod_data *)a->data.v; if (smd->special==sm_familiar) break; - a = a->nexttype; + a = a->next; } if (a==NULL) { attrib * an = a_add(&mage->attribs, a_new(&at_skillmod)); diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 8ed53c550..f82d02054 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -539,10 +539,10 @@ leave_trail(ship * sh, region * from, region_list *route) traveldir * td = NULL; attrib * a = a_find(r->attribs, &at_shiptrail); - while (a!=NULL) { + while (a!=NULL && a->type==&at_shiptrail) { td = (traveldir *)a->data.v; if (td->no == sh->no) break; - a = a->nexttype; + a = a->next; } if (a == NULL) { @@ -2112,7 +2112,7 @@ piracy_cmd(unit *u, struct order * ord) } } - for (a = a_find(r->attribs, &at_piracy_direction); a; a=a->nexttype) { + for (a = a_find(r->attribs, &at_piracy_direction); a && a->type==&at_piracy_direction; a=a->next) { piracy_data * data = a->data.v; const faction * p = data->pirate; const faction * t = data->target; @@ -2196,15 +2196,13 @@ age_traveldir(region *r) { attrib *a = a_find(r->attribs, &at_traveldir); - while(a) { + while(a && a->type==&at_traveldir) { + attrib *an = a->next; a->data.ca[3]--; if(a->data.ca[3] <= 0) { - attrib *an = a->nexttype; a_remove(&r->attribs, a); - a = an; - } else { - a = a->nexttype; } + a = an; } } @@ -2213,10 +2211,10 @@ hunted_dir(attrib *at, int id) { attrib *a = a_find(at, &at_shiptrail); - while (a!=NULL) { + while (a!=NULL && a->type==&at_shiptrail) { traveldir *t = (traveldir *)(a->data.v); if (t->no == id) return t->dir; - a = a->nexttype; + a = a->next; } return NODIRECTION; diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 3de2be0ca..c031a04a5 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -386,10 +386,10 @@ special_direction(const region * from, const region * to) { const attrib *a = a_findc(from->attribs, &at_direction); - while (a!=NULL) { + while (a!=NULL && a->type==&at_direction) { spec_direction * sd = (spec_direction *)a->data.v; if (sd->x==to->x && sd->y==to->y) return sd; - a = a->nexttype; + a = a->next; } return NULL; } diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 9e56c7889..eae0832ce 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -1292,7 +1292,7 @@ prepare_report(faction * f) } if (modeattribs, &at_travelunit); ru; ru = ru->nexttype) { + for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type==&at_travelunit; ru = ru->next) { unit * u = (unit*)ru->data.v; if (u->faction == f) { mode = see_travel; diff --git a/src/common/kernel/skill.c b/src/common/kernel/skill.c index e70f5129c..3cd15136b 100644 --- a/src/common/kernel/skill.c +++ b/src/common/kernel/skill.c @@ -154,7 +154,7 @@ make_skillmod(skill_t sk, unsigned int flags, skillmod_fun special, double multi int skillmod(const attrib * a, const unit * u, const region * r, skill_t sk, int value, int flags) { - for (a = a_find((attrib*)a, &at_skillmod); a; a=a->nexttype) { + for (a = a_find((attrib*)a, &at_skillmod); a && a->type==&at_skillmod; a=a->next) { skillmod_data * smd = (skillmod_data *)a->data.v; if (smd->skill!=NOSKILL && smd->skill!=sk) continue; if (flags!=SMF_ALWAYS && (smd->flags & flags) == 0) continue; diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index 8a826f51e..6400285ee 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -481,8 +481,8 @@ void usetcontact(unit * u, const unit * u2) { attrib * a = a_find(u->attribs, &at_contact); - while (a && a->data.v!=u2) a = a->nexttype; - if (a) return; + while (a && a->type==&at_contact && a->data.v!=u2) a = a->next; + if (a && a->type==&at_contact) return; a_add(&u->attribs, a_new(&at_contact))->data.v = (void*)u2; } @@ -494,7 +494,7 @@ ucontact(const unit * u, const unit * u2) if (u->faction==u2->faction) return true; /* Explizites KONTAKTIERE */ - for (ru = a_find(u->attribs, &at_contact); ru; ru = ru->nexttype) + for (ru = a_find(u->attribs, &at_contact); ru && ru->type==&at_contact; ru = ru->next) if (((unit*)ru->data.v) == u2) return true; @@ -828,10 +828,10 @@ transfermen(unit * u, unit * u2, int n) } } a = a_find(u->attribs, &at_effect); - while (a) { + while (a && a->type==&at_effect) { effect_data * olde = (effect_data*)a->data.v; if (olde->value) change_effect(u2, olde->type, olde->value); - a = a->nexttype; + a = a->next; } if (fval(u, UFL_LONGACTION)) fset(u2, UFL_LONGACTION); if (u->attribs) { @@ -845,8 +845,8 @@ transfermen(unit * u, unit * u2, int n) u2->hp += hp; /* TODO: Das ist schnarchlahm! und gehört ncht hierhin */ a = a_find(u2->attribs, &at_effect); - while (a) { - attrib * an = a->nexttype; + while (a && a->type==&at_effect) { + attrib * an = a->next; effect_data * olde = (effect_data*)a->data.v; int e = get_effect(u, olde->type); if (e!=0) change_effect(u2, olde->type, -e); diff --git a/src/common/modules/gmcmd.c b/src/common/modules/gmcmd.c index 11b544561..c0de84196 100644 --- a/src/common/modules/gmcmd.c +++ b/src/common/modules/gmcmd.c @@ -154,7 +154,7 @@ gm_create(const tnode * tnext, const char * str, void * data, struct order * ord } else { attrib * a = a_find(permissions, &at_gmcreate); - while (a && a->data.v!=(void*)itype) a=a->nexttype; + while (a && a->type==&at_gmcreate && a->data.v!=(void*)itype) a=a->next; if (a) i_change(&u->items, itype, i); else mistake(u, ord, "Diesen Gegenstand darf deine Partei nicht machen.", 0); } diff --git a/src/common/modules/museum.c b/src/common/modules/museum.c index 8d576c0b1..326843165 100644 --- a/src/common/modules/museum.c +++ b/src/common/modules/museum.c @@ -142,12 +142,12 @@ warden_add_give(unit *src, unit *u, const item_type *itype, int n) attrib *a; /* has the giver a cookie corresponding to the warden */ - for(a = a_find(src->attribs, &at_museumgivebackcookie); a; a=a->nexttype) { + for(a = a_find(src->attribs, &at_museumgivebackcookie); a && a->type==&at_museumgivebackcookie; a=a->next) { if(((museumgivebackcookie *)(a->data.v))->warden_no == u->no) break; } /* if not give it one */ - if(!a) { + if (a==NULL || a->type!=&at_museumgivebackcookie) { a = a_add(&src->attribs, a_new(&at_museumgivebackcookie)); gbc = (museumgivebackcookie *)a->data.v; gbc->warden_no = u->no; @@ -159,15 +159,15 @@ warden_add_give(unit *src, unit *u, const item_type *itype, int n) } /* now we search for the warden's corresponding item list */ - for(a = a_find(u->attribs, &at_museumgiveback); a; a=a->nexttype) { + for (a = a_find(u->attribs, &at_museumgiveback); a && a->type==&at_museumgiveback; a=a->next) { gb = (museumgiveback *)a->data.v; - if(gb->cookie == gbc->cookie) { + if (gb->cookie == gbc->cookie) { break; } } /* if there's none, give it one */ - if(!gb) { + if (!gb) { a = a_add(&u->attribs, a_new(&at_museumgiveback)); gb = (museumgiveback *)a->data.v; gb->cookie = gbc->cookie; @@ -309,10 +309,10 @@ use_museumexitticket(unit *u, const struct item_type *itype, int amount, order * a_remove(&u->attribs, a); if(a) { - for(a = a_find(warden->attribs, &at_museumgiveback); a; a = a->nexttype) { + for(a = a_find(warden->attribs, &at_museumgiveback); a && a->type==&at_museumgiveback; a = a->next) { if(((museumgiveback *)(a->data.v))->cookie == unit_cookie) break; } - if(a) { + if (a && a->type==&at_museumgiveback) { museumgiveback *gb = (museumgiveback *)(a->data.v); item *it; diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 37560096b..3365639a4 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -2816,18 +2816,18 @@ resolve_buddy(variant data) curse * c = (curse*)a->data.v; wallcurse * wc = (wallcurse*)c->data.v; if (wc->wall->id==br->id) break; - a = a->nexttype; + a = a->next; } - if (!a) { + if (!a || a->type!=&at_cursewall) { a = a_find(b->to->attribs, &at_cursewall); - while (a && a->data.v!=br->self) { + while (a && a->type==&at_cursewall && a->data.v!=br->self) { curse * c = (curse*)a->data.v; wallcurse * wc = (wallcurse*)c->data.v; if (wc->wall->id==br->id) break; - a = a->nexttype; + a = a->next; } } - if (a) { + if (a && a->type==&at_cursewall) { curse * c = (curse*)a->data.v; free(br); return c; @@ -6271,7 +6271,7 @@ sp_disruptastral(castorder *co) rl = all_in_range(rt, (short)(power/5), NULL); for (rl2=rl; rl2!=NULL; rl2=rl2->next) { - attrib *a, *a2; + attrib *a; variant effect; region * r2 = rl2->data; spec_direction *sd; @@ -6290,8 +6290,8 @@ sp_disruptastral(castorder *co) /* Nicht-Permanente Tore zerstören */ a = a_find(r->attribs, &at_direction); - while (a!=NULL) { - a2 = a->nexttype; + while (a!=NULL && a->type==&at_direction) { + attrib * a2 = a->next; sd = (spec_direction *)(a->data.v); if (sd->duration != -1) a_remove(&r->attribs, a); a = a2; diff --git a/src/common/util/attrib.c b/src/common/util/attrib.c index c2e487dbd..fad6f8610 100644 --- a/src/common/util/attrib.c +++ b/src/common/util/attrib.c @@ -88,91 +88,142 @@ a_select(attrib * a, const void * data, boolean(*compare)(const attrib *, const attrib * a_find(attrib * a, const attrib_type * at) { - while (a && a->type!=at) a = a->next; + while (a && a->type!=at) a = a->nexttype; return a; } const attrib * a_findc(const attrib * a, const attrib_type * at) { - while (a && a->type!=at) a = a->next; + while (a && a->type!=at) a = a->nexttype; return a; } +static attrib * +a_insert(attrib * head, attrib * a) +{ + attrib ** pa=&head->next; + + assert(!(a->type->flags & ATF_UNIQUE)); + assert(head && head->type==a->type); + + while (*pa && (*pa)->type==a->type) { + pa = &(*pa)->next; + } + a->next = *pa; + return *pa = a; +} + attrib * a_add(attrib ** pa, attrib * a) { - attrib ** find = pa; + attrib * first = *pa; assert(a->next==NULL && a->nexttype==NULL); - while (*find && (*find)->type!=a->type) find = &(*find)->next; - if (a->type->flags & ATF_PRESERVE) { - while (*find) find = &(*find)->nexttype; - } - if (a->type->flags & ATF_UNIQUE && *find) { - if ((*find)->type == a->type) { - log_error(("duplicate attribute: %s\n", a->type->name)); - return a; - } - } - if (*find) { - attrib ** last = find; - while (*last) last = &(*last)->nexttype; - *last = a; - while (*find && (*find)->type==a->type) find = &(*find)->next; - } - a->next = *find; - *find = a; - return a; + + if (first==NULL) return *pa = a; + if (first->type==a->type) { + return a_insert(first, a); + } + for (;;) { + attrib * next = first->nexttype; + if (next==NULL) { + /* the type is not in the list, append it behind the last type */ + attrib ** insert = &first->next; + first->nexttype = a; + while (*insert) insert = &(*insert)->next; + *insert = a; + break; + } + if (next->type==a->type) { + return a_insert(next, a); + } + first = next; + } + return a; } void -a_free(attrib * a) { +a_free(attrib * a) +{ const attrib_type * at = a->type; if (at->finalize) at->finalize(a); free(a); } static int -a_unlink(attrib ** p, attrib * a) { - attrib ** pa = p; - while (*pa && *pa!=a) pa = &(*pa)->next; - if (*pa) { - attrib ** pnt; - for (pnt=p;*pnt;pnt=&(*pnt)->next) - if ((*pnt)->nexttype == a) { - (*pnt)->nexttype = a->nexttype; - break; - } - *pa = (*pa)->next; - return 1; - } - return 0; +a_unlink(attrib ** pa, attrib * a) +{ + attrib ** pnexttype = pa; + attrib ** pnext = NULL; + + while (*pnexttype) { + attrib * next = *pnexttype; + if (next->type==a->type) break; + pnexttype = &next->nexttype; + pnext = &next->next; + } + if (*pnexttype && (*pnexttype)->type==a->type) { + if (*pnexttype==a) { + *pnexttype = a->next; + if (a->next!=a->nexttype) { + a->next->nexttype = a->nexttype; + } + if (pnext==NULL) return 1; + while (*pnext && (*pnext)->type!=a->type) pnext = &(*pnext)->next; + } else { + pnext = &(*pnexttype)->next; + } + while (*pnext && (*pnext)->type==a->type) { + if (*pnext==a) { + *pnext = a->next; + return 1; + } + pnext = &(*pnext)->next; + } + } + return 0; } int -a_remove(attrib ** p, attrib * a) { +a_remove(attrib ** pa, attrib * a) +{ int ok; - ok = a_unlink(p, a); - if( ok ) a_free(a); + ok = a_unlink(pa, a); + if (ok) a_free(a); return ok; } void -a_removeall(attrib **p, const attrib_type * at) +a_removeall(attrib **pa, const attrib_type * at) { - attrib *find = *p, *findnext; - if (find && find->type != at){ - find = a_find(find, at); - } - while(find && find->type == at) { - findnext = find->next; - a_remove(p, find); - find = findnext; - } + attrib ** pnexttype = pa; + attrib ** pnext = NULL; + + while (*pnexttype) { + attrib * next = *pnexttype; + if (next->type==at) break; + pnexttype = &next->nexttype; + pnext = &next->next; + } + if (*pnexttype && (*pnexttype)->type==at) { + attrib * a = *pnexttype; + + *pnexttype = a->nexttype; + if (pnext) { + while (*pnext && (*pnext)->type!=at) pnext = &(*pnext)->next; + *pnext = a->nexttype; + } + while (a && a->type==at) { + attrib * ra = a; + a = a->next; + a_free(ra); + } + } } attrib * -a_new(const attrib_type * at) { +a_new(const attrib_type * at) +{ attrib * a = (attrib*)calloc(1, sizeof(attrib)); assert(at!=NULL); a->type = at; @@ -189,7 +240,7 @@ a_age(attrib ** p) while(*ap) { attrib * a = *ap; if (a->type->age && a->type->age(a)==0) a_remove(p, a); - else ap=&a->next; + else ap = &a->next; } return (*p!=NULL); } @@ -248,8 +299,10 @@ a_write(FILE * f, const attrib * attribs) assert(na->type->hashkey || !"attribute not registered"); fprintf(f, "%s ", na->type->name); na->type->write(na, f); - } - na = na->next; + na = na->next; + } else { + na = na->nexttype; + } } fprintf(f, "end "); } diff --git a/src/common/util/attrib.h b/src/common/util/attrib.h index bab2ab0ed..16c39ee2c 100644 --- a/src/common/util/attrib.h +++ b/src/common/util/attrib.h @@ -34,7 +34,7 @@ typedef struct attrib { } data; /* internal data, do not modify: */ struct attrib * next; /* next attribute in the list */ - struct attrib * nexttype; /* next attribute of same type */ + struct attrib * nexttype; /* skip to attribute of a different type */ } attrib; #define ATF_UNIQUE (1<<0) /* only one per attribute-list */ diff --git a/src/common/util/cvector.c b/src/common/util/cvector.c index bbf037883..520f59e59 100644 --- a/src/common/util/cvector.c +++ b/src/common/util/cvector.c @@ -26,6 +26,7 @@ #include #include #include +#include void cv_init(cvector * cv) diff --git a/src/common/util/event.c b/src/common/util/event.c index 75c16667e..4a8be46e8 100644 --- a/src/common/util/event.c +++ b/src/common/util/event.c @@ -165,15 +165,14 @@ get_triggers(struct attrib * ap, const char * eventname) { handler_info * td = NULL; attrib * a = a_find(ap, &at_eventhandler); - while (a!=NULL) { + while (a!=NULL && a->type==&at_eventhandler) { td = (handler_info *)a->data.v; - if (!strcmp(td->event, eventname)) { - break; + if (strcmp(td->event, eventname)==0) { + return &td->triggers; } - a = a->nexttype; + a = a->next; } - if (!a) return NULL; - return &td->triggers; + return NULL; } void @@ -183,14 +182,14 @@ add_trigger(struct attrib ** ap, const char * eventname, struct trigger * t) handler_info * td = NULL; attrib * a = a_find(*ap, &at_eventhandler); assert(t->next==NULL); - while (a!=NULL) { + while (a!=NULL && a->type==&at_eventhandler) { td = (handler_info *)a->data.v; if (!strcmp(td->event, eventname)) { break; } - a = a->nexttype; + a = a->next; } - if (!a) { + if (a==NULL || a->type!=&at_eventhandler) { a = a_add(ap, a_new(&at_eventhandler)); td = (handler_info *)a->data.v; td->event = strdup(eventname); @@ -207,14 +206,14 @@ handle_event(attrib ** attribs, const char * eventname, void * data) if ((*attribs)->type==&at_eventhandler) break; attribs = &(*attribs)->next; } - while (*attribs) { + while (*attribs && (*attribs)->type==&at_eventhandler) { handler_info * tl = (handler_info*)(*attribs)->data.v; - if (!strcmp(tl->event, eventname)) break; - attribs = &(*attribs)->nexttype; - } - if (*attribs) { - handler_info * tl = (handler_info*)(*attribs)->data.v; - handle_triggers(&tl->triggers, data); + if (!strcmp(tl->event, eventname)) { + handler_info * tl = (handler_info*)(*attribs)->data.v; + handle_triggers(&tl->triggers, data); + break; + } + attribs = &(*attribs)->next; } } diff --git a/src/common/util/util.vcproj b/src/common/util/util.vcproj index 03310bb49..1bfa97bab 100644 --- a/src/common/util/util.vcproj +++ b/src/common/util/util.vcproj @@ -441,6 +441,9 @@ + + diff --git a/src/eressea.sln b/src/eressea.sln index 4a0b6e6ab..1b2548def 100644 --- a/src/eressea.sln +++ b/src/eressea.sln @@ -76,129 +76,80 @@ EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug - Debug64 = Debug64 Profile = Profile Release = Release - Release64 = Release64 EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Debug.ActiveCfg = Debug|Win32 {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Debug.Build.0 = Debug|Win32 - {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Debug64.ActiveCfg = Debug64|Win32 - {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Debug64.Build.0 = Debug64|Win32 {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Profile.ActiveCfg = Profile|Win32 {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Profile.Build.0 = Profile|Win32 {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Release.ActiveCfg = Release|Win32 {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Release.Build.0 = Release|Win32 - {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Release64.ActiveCfg = Release64|Win32 - {330712B5-8B27-4B17-B3CF-7A02CC0F93C3}.Release64.Build.0 = Release64|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Debug.ActiveCfg = Debug|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Debug.Build.0 = Debug|Win32 - {B859D542-781E-4647-BCAB-3FE5ED077366}.Debug64.ActiveCfg = Debug64|Win32 - {B859D542-781E-4647-BCAB-3FE5ED077366}.Debug64.Build.0 = Debug64|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Profile.ActiveCfg = Profile|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Profile.Build.0 = Profile|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Release.ActiveCfg = Release|Win32 {B859D542-781E-4647-BCAB-3FE5ED077366}.Release.Build.0 = Release|Win32 - {B859D542-781E-4647-BCAB-3FE5ED077366}.Release64.ActiveCfg = Release64|Win32 - {B859D542-781E-4647-BCAB-3FE5ED077366}.Release64.Build.0 = Release64|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Debug.ActiveCfg = Debug|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Debug.Build.0 = Debug|Win32 - {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Debug64.ActiveCfg = Debug64|Win32 - {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Debug64.Build.0 = Debug64|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Profile.ActiveCfg = Profile|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Profile.Build.0 = Profile|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Release.ActiveCfg = Release|Win32 {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Release.Build.0 = Release|Win32 - {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Release64.ActiveCfg = Release64|Win32 - {79659D44-EC28-42B9-9475-6C0D62D0AAE0}.Release64.Build.0 = Release64|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Debug.ActiveCfg = Debug|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Debug.Build.0 = Debug|Win32 - {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Debug64.ActiveCfg = Debug64|Win32 - {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Debug64.Build.0 = Debug64|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Profile.ActiveCfg = Profile|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Profile.Build.0 = Profile|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Release.ActiveCfg = Release|Win32 {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Release.Build.0 = Release|Win32 - {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Release64.ActiveCfg = Release64|Win32 - {C14E3D2B-8189-4570-A4E3-9010C873E4FD}.Release64.Build.0 = Release64|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Debug.ActiveCfg = Debug|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Debug.Build.0 = Debug|Win32 - {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Debug64.ActiveCfg = Debug64|Win32 - {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Debug64.Build.0 = Debug64|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Profile.ActiveCfg = Profile|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Profile.Build.0 = Profile|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Release.ActiveCfg = Release|Win32 {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Release.Build.0 = Release|Win32 - {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Release64.ActiveCfg = Release64|Win32 - {EDB0DE67-8215-4AF7-ACA1-F23CB11FF211}.Release64.Build.0 = Release64|Win32 {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Debug.ActiveCfg = Debug|Win32 {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Debug.Build.0 = Debug|Win32 - {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Debug64.ActiveCfg = Debug64|Win32 - {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Debug64.Build.0 = Debug64|Win32 {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Profile.ActiveCfg = Profile|Win32 {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Release.ActiveCfg = Release|Win32 - {17F83AAB-352D-4F68-ADA6-09F36D86826F}.Release64.ActiveCfg = Release64|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Debug.ActiveCfg = Debug|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Debug.Build.0 = Debug|Win32 - {601CF164-F483-4DE7-8014-64BDD30680B5}.Debug64.ActiveCfg = Debug64|Win32 - {601CF164-F483-4DE7-8014-64BDD30680B5}.Debug64.Build.0 = Debug64|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Profile.ActiveCfg = Profile|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Profile.Build.0 = Profile|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Release.ActiveCfg = Release|Win32 {601CF164-F483-4DE7-8014-64BDD30680B5}.Release.Build.0 = Release|Win32 - {601CF164-F483-4DE7-8014-64BDD30680B5}.Release64.ActiveCfg = Release64|Win32 - {601CF164-F483-4DE7-8014-64BDD30680B5}.Release64.Build.0 = Release64|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Debug.ActiveCfg = Debug|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Debug.Build.0 = Debug|Win32 - {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Debug64.ActiveCfg = Debug64|Win32 - {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Debug64.Build.0 = Debug64|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Profile.ActiveCfg = Profile|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Profile.Build.0 = Profile|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Release.ActiveCfg = Release|Win32 {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Release.Build.0 = Release|Win32 - {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Release64.ActiveCfg = Release64|Win32 - {4C837BEC-A428-4287-84B3-8F8F9DE7FA00}.Release64.Build.0 = Release64|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Debug.ActiveCfg = Debug|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Debug.Build.0 = Debug|Win32 - {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Debug64.ActiveCfg = Debug64|Win32 - {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Debug64.Build.0 = Debug64|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Profile.ActiveCfg = Profile|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Profile.Build.0 = Profile|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Release.ActiveCfg = Release|Win32 {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Release.Build.0 = Release|Win32 - {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Release64.ActiveCfg = Release64|Win32 - {0EE778AB-8445-40DB-8F65-6BE378A91B97}.Release64.Build.0 = Release64|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Debug.ActiveCfg = Debug|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Debug.Build.0 = Debug|Win32 - {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Debug64.ActiveCfg = Debug64|Win32 - {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Debug64.Build.0 = Debug64|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Profile.ActiveCfg = Profile|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Profile.Build.0 = Profile|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Release.ActiveCfg = Release|Win32 {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Release.Build.0 = Release|Win32 - {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Release64.ActiveCfg = Release64|Win32 - {EF495253-2EEC-4F83-B6C0-D651F88B2198}.Release64.Build.0 = Release64|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Debug.ActiveCfg = Debug|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Debug.Build.0 = Debug|Win32 - {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Debug64.ActiveCfg = Debug64|Win32 - {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Debug64.Build.0 = Debug64|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Profile.ActiveCfg = Profile|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Profile.Build.0 = Profile|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Release.ActiveCfg = Release|Win32 {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Release.Build.0 = Release|Win32 - {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Release64.ActiveCfg = Release64|Win32 - {1D80D05F-BCF5-4971-8F06-D9581FD3B1F4}.Release64.Build.0 = Release64|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Debug.ActiveCfg = Debug|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Debug.Build.0 = Debug|Win32 - {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Debug64.ActiveCfg = Debug64|Win32 - {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Debug64.Build.0 = Debug64|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Profile.ActiveCfg = Profile|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Profile.Build.0 = Profile|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release.ActiveCfg = Release|Win32 {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release.Build.0 = Release|Win32 - {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release64.ActiveCfg = Release64|Win32 - {749A2F7C-B9C3-4CEB-B1B2-1D4587E68719}.Release64.Build.0 = Release64|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index 300bbc025..3b63d3499 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -934,10 +934,10 @@ fix_chaosgates(void) for (r = regions; r; r=r->next) { const attrib *a = a_findc(r->attribs, &at_direction); - while (a!=NULL) { + while (a!=NULL && a->type==&at_direction) { spec_direction * sd = (spec_direction *)a->data.v; region * r2 = findregion(sd->x, sd->y); - if (r2!=NULL) { + if (r2!=NULL) { border * b = get_borders(r, r2); while (b) { if (b->type==&bt_chaosgate) break; @@ -947,7 +947,7 @@ fix_chaosgates(void) b = new_border(&bt_chaosgate, r, r2); } } - a = a->nexttype; + a = a->next; } } return 0; diff --git a/src/eressea/lua/objects.cpp b/src/eressea/lua/objects.cpp index ba233b034..330889cda 100644 --- a/src/eressea/lua/objects.cpp +++ b/src/eressea/lua/objects.cpp @@ -24,7 +24,7 @@ namespace eressea { objects::get(const char * name) { lua_State * L = (lua_State *)global.vm_state; attrib * a = a_find(*mAttribPtr, &at_object); - for (;a;a=a->nexttype) { + for (;a && a->type==&at_object;a=a->next) { if (strcmp(object_name(a), name)==0) { variant val; object_type type; @@ -61,14 +61,13 @@ namespace eressea { static void set_object(attrib **attribs, const char * name, object_type type, variant val) { attrib * a = a_find(*attribs, &at_object); - for (;a;a=a->nexttype) { - if (strcmp(object_name(a), name)==0) break; - } - if (a==NULL) { - a = a_add(attribs, object_create(name, type, val)); - } else { - object_set(a, type, val); + for (;a && a->type==&at_object;a=a->next) { + if (strcmp(object_name(a), name)==0) { + object_set(a, type, val); + return; + } } + a = a_add(attribs, object_create(name, type, val)); } template<> void diff --git a/src/mapper/mapper.vcproj b/src/mapper/mapper.vcproj index fa1a864e2..a6754a09e 100644 --- a/src/mapper/mapper.vcproj +++ b/src/mapper/mapper.vcproj @@ -200,128 +200,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -