diff --git a/src/kernel/build.c b/src/kernel/build.c index 677cf96fc..60ac94e53 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -472,16 +472,15 @@ static int count_materials(unit *u, const construction *type, int n, int complet int c; for (c = 0; n > 0 && type->materials[c].number; c++) { const struct resource_type *rtype = type->materials[c].rtype; - int need, prebuilt; int canuse = get_pooled(u, rtype, GET_DEFAULT, INT_MAX); canuse = matmod(u, rtype, canuse); assert(canuse >= 0); if (type->reqsize > 1) { - prebuilt = + int prebuilt = required(completed, type->reqsize, type->materials[c].number); for (; n;) { - need = + int need = required(completed + n, type->reqsize, type->materials[c].number); if (need - prebuilt <= canuse) break; diff --git a/src/kernel/config.c b/src/kernel/config.c index 9a5ba0104..2895ed70a 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -147,39 +147,6 @@ const char *parameters[MAXPARAMS] = { "ALLIANZ" }; -FILE *debug; - -void -parse(keyword_t kword, int(*dofun) (unit *, struct order *), bool thisorder) -{ - region *r; - - for (r = regions; r; r = r->next) { - unit **up = &r->units; - while (*up) { - unit *u = *up; - order **ordp = &u->orders; - if (thisorder) - ordp = &u->thisorder; - while (*ordp) { - order *ord = *ordp; - if (getkeyword(ord) == kword) { - if (dofun(u, ord) != 0) - break; - if (u->orders == NULL) - break; - } - if (thisorder) - break; - if (*ordp == ord) - ordp = &ord->next; - } - if (*up == u) - up = &u->next; - } - } -} - int findoption(const char *s, const struct locale *lang) { void **tokens = get_translations(lang, UT_OPTIONS); diff --git a/src/kernel/connection.c b/src/kernel/connection.c index 516cb6ead..6f73c94f2 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -225,7 +225,7 @@ border_type *find_bordertype(const char *name) void b_read(connection * b, gamedata * data) { storage * store = data->store; - int n, result = 0; + int n; switch (b->type->datatype) { case VAR_NONE: case VAR_INT: @@ -240,9 +240,7 @@ void b_read(connection * b, gamedata * data) case VAR_VOIDPTR: default: assert(!"invalid variant type in connection"); - result = 0; } - assert(result >= 0 || "EOF encountered?"); } void b_write(const connection * b, storage * store) diff --git a/src/kernel/order.c b/src/kernel/order.c index 8defd05c9..807541ac1 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -242,10 +242,10 @@ order *create_order(keyword_t kwd, const struct locale * lang, va_start(marker, params); sbs_init(&sbs, zBuffer, sizeof(zBuffer)); while (*params) { - int i; const char *s; tok = strchr(params, '%'); if (tok) { + int i; if (tok != params) { sbs_strncat(&sbs, params, tok - params); } diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index 5a46b7fe7..6a5b4652d 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -71,12 +71,12 @@ bool terrain_changed(int *cache) { void free_terrains(void) { while (registered_terrains) { - int n; terrain_type * t = registered_terrains; registered_terrains = t->next; free(t->_name); free(t->herbs); if (t->production) { + int n; for (n = 0; t->production[n].type; ++n) { free(t->production[n].base); free(t->production[n].divisor); diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 71aa6aae4..374b6379c 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -807,9 +807,9 @@ static void smooth_island(region_list * island) region_list *rlist = NULL; for (rlist = island; rlist; rlist = rlist->next) { region *r = rlist->data; - int n, nland = 0; if (r->land) { + int n, nland = 0; get_neighbours(r, rn); for (n = 0; n != MAXDIRECTIONS && nland <= 1; ++n) { if (rn[n]->land) { diff --git a/src/modules/museum.c b/src/modules/museum.c index d854d1763..9daa623ef 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -301,7 +301,6 @@ order * ord) attrib *a; region *r; unit *warden = findunit(atoi36("mwar")); - int unit_cookie; UNUSED_ARG(amount); @@ -316,11 +315,11 @@ order * ord) r = findregion(a->data.sa[0], a->data.sa[1]); assert(r); a_remove(&u->attribs, a); - /* Übergebene Gegenstände zurückgeben */ + /* Ãœbergebene Gegenstände zurückgeben */ a = a_find(u->attribs, &at_museumgivebackcookie); if (a) { - unit_cookie = a->data.i; + int unit_cookie = a->data.i; a_remove(&u->attribs, a); for (a = a_find(warden->attribs, &at_museumgiveback); diff --git a/src/races/zombies.c b/src/races/zombies.c index 74bf53a76..de3d81972 100644 --- a/src/races/zombies.c +++ b/src/races/zombies.c @@ -43,7 +43,6 @@ void make_undead_unit(unit * u) void age_undead(unit * u) { region *r = u->region; - int n = 0; /* untote, die einer partei angehoeren, koennen sich * absplitten, anstatt sich zu vermehren. monster @@ -51,10 +50,9 @@ void age_undead(unit * u) if (u->number > UNDEAD_MIN && !is_monsters(u->faction) && rng_int() % 100 < UNDEAD_BREAKUP) { - int m; + int m, n = 0; unit *u2; - n = 0; for (m = u->number; m; m--) { if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION) ++n; diff --git a/src/triggers/changerace.c b/src/triggers/changerace.c index 5ab56b346..0f644c47b 100644 --- a/src/triggers/changerace.c +++ b/src/triggers/changerace.c @@ -111,7 +111,7 @@ trigger *trigger_changerace(struct unit * u, const struct race * prace, trigger *t = t_new(&tt_changerace); changerace_data *td = (changerace_data *)t->data.v; - assert(u_race(u) == u_irace(u) || "!changerace-triggers cannot stack!"); + assert(u_race(u) == u_irace(u) || !"changerace-triggers cannot stack!"); td->u = u; td->race = prace; td->irace = irace; diff --git a/src/util/language.c b/src/util/language.c index 689ccfcd7..cf76dc4de 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -257,8 +257,9 @@ static lstr lstrs[MAXLOCALES]; void ** get_translations(const struct locale *lang, int index) { assert(lang); - assert(lang->index < MAXLOCALES - || "you have to increase MAXLOCALES and recompile"); + if (lang->index >= MAXLOCALES) { + log_fatal("you have to increase MAXLOCALES and recompile"); + } if (lang->index < MAXLOCALES) { return lstrs[lang->index].tokens + index; } diff --git a/src/util/unicode.c b/src/util/unicode.c index 10d43f947..85a341ddf 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -108,9 +108,6 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) } } - if (outlen <= 0) { - return ENOMEM; - } *op = 0; return 0; }