diff --git a/src/attributes/giveitem.c b/src/attributes/giveitem.c index b9ceb0f33..ed996ed93 100644 --- a/src/attributes/giveitem.c +++ b/src/attributes/giveitem.c @@ -95,11 +95,10 @@ static void a_finalizegive(struct attrib *a) static int a_giveitem(attrib * a) { give_data *gdata = (give_data *) a->data.v; - region *r; unit *u; + if (gdata->building == NULL || gdata->items == NULL) return 0; - r = gdata->building->region; u = building_owner(gdata->building); if (u == NULL) return 1; diff --git a/src/bindings/helpers.c b/src/bindings/helpers.c index b5eca0eb1..cb586cf9f 100644 --- a/src/bindings/helpers.c +++ b/src/bindings/helpers.c @@ -240,7 +240,7 @@ static int lua_callspell(castorder * co) } /** callback to initialize a familiar from lua. */ -static void lua_initfamiliar(unit * u) +static int lua_initfamiliar(unit * u) { lua_State *L = (lua_State *) global.vm_state; char fname[64]; @@ -269,6 +269,7 @@ static void lua_initfamiliar(unit * u) snprintf(fname, sizeof(fname), "%s_familiar", u->race->_name[0]); equip_unit(u, get_equipment(fname)); + return result; } static int @@ -447,11 +448,9 @@ static double lua_building_taxes(building * b, int level) lua_State *L = (lua_State *) global.vm_state; const char *fname = "building_taxes"; double result = 0.0F; - int type; lua_pushstring(L, fname); lua_rawget(L, LUA_GLOBALSINDEX); - type = lua_type(L, 1); if (lua_isfunction(L, 1)) { tolua_pushusertype(L, (void *)b, TOLUA_CAST "building"); tolua_pushnumber(L, level); @@ -498,7 +497,7 @@ static int lua_maintenance(const unit * u) return result; } -static void lua_equipmentcallback(const struct equipment *eq, unit * u) +static int lua_equipmentcallback(const struct equipment *eq, unit * u) { lua_State *L = (lua_State *) global.vm_state; char fname[64]; @@ -522,6 +521,7 @@ static void lua_equipmentcallback(const struct equipment *eq, unit * u) log_error("equip(%s) calling '%s': not a function.\n", unitname(u), fname); lua_pop(L, 1); } + return result; } /** callback for an item-use function written in lua. */ diff --git a/src/gamecode/economy.c b/src/gamecode/economy.c index e37123e93..11c0a9245 100644 --- a/src/gamecode/economy.c +++ b/src/gamecode/economy.c @@ -1432,7 +1432,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) { const item_type *itype = resource2item(rtype); region *r = u->region; - int busy = u->number; int dm = 0; allocation_list *alist; allocation *al; @@ -1555,8 +1554,6 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) if (want > 0 && want < amount) amount = want; - busy = (amount + skill - 1) / skill; /* wieviel leute tun etwas? */ - alist = allocations; while (alist && alist->type != rtype) alist = alist->next; diff --git a/src/gamecode/study.c b/src/gamecode/study.c index a317d4b4d..a25c56a52 100644 --- a/src/gamecode/study.c +++ b/src/gamecode/study.c @@ -276,7 +276,6 @@ int teach_cmd(unit * u, struct order *ord) plane *pl; region *r = u->region; int teaching, i, j, count, academy = 0; - unit *u2; skill_t sk = NOSKILL; if (gbdream_ct == 0) @@ -312,7 +311,6 @@ int teach_cmd(unit * u, struct order *ord) if (teaching == 0) return 0; - u2 = 0; count = 0; init_tokens(ord); diff --git a/src/gmtool.c b/src/gmtool.c index dfc48b1e2..57d715501 100644 --- a/src/gmtool.c +++ b/src/gmtool.c @@ -502,14 +502,13 @@ terraform_selection(selection * selected, const terrain_type * terrain) static faction *select_faction(state * st) { - list_selection *prev, *ilist = NULL, **iinsert; + list_selection *ilist = NULL, **iinsert; list_selection *selected = NULL; faction *f = factions; if (!f) return NULL; iinsert = &ilist; - prev = ilist; while (f) { char buffer[32]; @@ -530,14 +529,13 @@ static faction *select_faction(state * st) static const terrain_type *select_terrain(state * st, const terrain_type * default_terrain) { - list_selection *prev, *ilist = NULL, **iinsert; + list_selection *ilist = NULL, **iinsert; list_selection *selected = NULL; const terrain_type *terrain = terrains(); if (!terrain) return NULL; iinsert = &ilist; - prev = ilist; while (terrain) { insert_selection(iinsert, NULL, terrain->_name, (void *)terrain); diff --git a/src/kernel/build.c b/src/kernel/build.c index e718ff5b2..6b9746e24 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -847,7 +847,6 @@ void build_building(unit * u, const building_type * btype, int want, order * ord) { region *r = u->region; - boolean newbuilding = false; int n = want, built = 0, id; building *b = NULL; /* einmalige Korrektur */ @@ -983,7 +982,6 @@ build_building(unit * u, const building_type * btype, int want, order * ord) } #endif - newbuilding = true; } btname = LOC(lang, btype->_name); diff --git a/src/kernel/move.c b/src/kernel/move.c index 528e9da64..f43655a3a 100644 --- a/src/kernel/move.c +++ b/src/kernel/move.c @@ -1292,14 +1292,11 @@ static void make_route(unit * u, order * ord, region_list ** routep) } while (next != NULL) { - direction_t reldir; - if (current == next) { /* PAUSE */ break; } next = next_region(u, current, next); - reldir = reldirection(current, next); add_regionlist(iroute, next); iroute = &(*iroute)->next; @@ -1718,7 +1715,6 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep) const terrain_type *tthis = current_point->terrain; /* these values need to be updated if next_point changes (due to storms): */ const terrain_type *tnext = next_point->terrain; - direction_t dir = reldirection(current_point, next_point); assert(sh == u->ship || !"ship has sunk, but we didn't notice it"); @@ -1781,7 +1777,6 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep) next_point = rnext; /* these values need to be updated if next_point changes (due to storms): */ tnext = next_point->terrain; - dir = reldirection(current_point, next_point); } } } diff --git a/src/kernel/region.c b/src/kernel/region.c index 714180974..7b42495c0 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -787,21 +787,21 @@ void rsetroad(region * r, direction_t d, short val) short rroad(const region * r, direction_t d) { - int rval; connection *b; region *r2 = rconnect(r, d); - if (!r2) + if (!r2) { return 0; + } b = get_borders(r, r2); - while (b && b->type != &bt_road) + while (b && b->type != &bt_road) { b = b->next; - if (!b) + } + if (!b) { return 0; - rval = b->data.i; - if (r == b->from) - return b->data.sa[0]; - return b->data.sa[1]; + } + + return (r == b->from) ? b->data.sa[0] : b->data.sa[1]; } boolean r_isforest(const region * r) diff --git a/src/kernel/reports.c b/src/kernel/reports.c index 51855299b..6a7e4c81d 100644 --- a/src/kernel/reports.c +++ b/src/kernel/reports.c @@ -1744,7 +1744,6 @@ int reports(void) faction *f; FILE *mailit; time_t ltime = time(NULL); - const char *str; int retval = 0; char path[MAX_PATH]; @@ -1771,11 +1770,13 @@ int reports(void) if (mailit) fclose(mailit); free_seen(); - str = get_param(global.parameters, "globalreport"); #ifdef GLOBAL_REPORT - if (str != NULL) { - sprintf(path, "%s/%s.%u.cr", reportpath(), str, turn); - global_report(path); + { + const char *str = get_param(global.parameters, "globalreport"); + if (str != NULL) { + sprintf(path, "%s/%s.%u.cr", reportpath(), str, turn); + global_report(path); + } } #endif return retval; diff --git a/src/kernel/save.c b/src/kernel/save.c index 326e12188..65737396a 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -406,20 +406,19 @@ int readorders(const char *filename) while (b) { const struct locale *lang = f ? f->locale : default_locale; int p; - const char *s; - switch (igetparam(b, lang)) { - case P_LOCALE: - s = getstrtoken(); #undef LOCALE_CHANGE #ifdef LOCALE_CHANGE - if (f && find_locale(s)) { - f->locale = find_locale(s); + case P_LOCALE: + { + const char *s = getstrtoken(); + if (f && find_locale(s)) { + f->locale = find_locale(s); + } } -#endif - b = getbuf(F, enc_gamedata); break; +#endif case P_GAMENAME: case P_FACTION: f = factionorders(); @@ -1292,11 +1291,10 @@ faction *readfaction(struct storage * store) read_items(store, &f->items); } for (;;) { - int level; store->r_tok_buf(store, token, sizeof(token)); if (strcmp("end", token) == 0) break; - level = store->r_int(store); + store->r_int(store); /* there used to be a level here, which is now ignored */ } planes = store->r_int(store); while (--planes >= 0) { diff --git a/src/kernel/sqlite.c b/src/kernel/sqlite.c index d8194e421..6e6cc5014 100644 --- a/src/kernel/sqlite.c +++ b/src/kernel/sqlite.c @@ -38,12 +38,12 @@ static int cache_insert; static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) { - int i, res; + int i; for (i = 0; i != MAX_STMT_CACHE && cache[i].db; ++i) { if (cache[i].sql == sql && cache[i].db == db) { cache[i].inuse = 1; - res = sqlite3_reset(cache[i].stmt); + sqlite3_reset(cache[i].stmt); return cache[i].stmt; } } @@ -53,12 +53,12 @@ static sqlite3_stmt *stmt_cache_get(sqlite3 * db, const char *sql) cache_insert = (cache_insert + 1) & (MAX_STMT_CACHE - 1); } i = cache_insert; - res = sqlite3_finalize(cache[i].stmt); + sqlite3_finalize(cache[i].stmt); } cache[i].inuse = 1; cache[i].db = db; cache[i].sql = sql; - res = sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); + sqlite3_prepare_v2(db, sql, -1, &cache[i].stmt, NULL); return cache[i].stmt; } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index cbda7e261..3cf2d78ef 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -873,14 +873,11 @@ boolean can_survive(const unit * u, const region * r) void move_unit(unit * u, region * r, unit ** ulist) { - int maxhp = 0; assert(u && r); assert(u->faction || !"this unit is dead"); if (u->region == r) return; - if (u->region != NULL) - maxhp = unit_max_hp(u); if (!ulist) ulist = (&r->units); if (u->region) { @@ -904,8 +901,6 @@ void move_unit(unit * u, region * r, unit ** ulist) update_interval(u->faction, r); #endif u->region = r; - /* keine automatische hp reduzierung bei bewegung */ - /* if (maxhp>0) u->hp = u->hp * unit_max_hp(u) / maxhp; */ } /* ist mist, aber wegen nicht skalierender attribute notwendig: */ diff --git a/src/modules/autoseed.c b/src/modules/autoseed.c index 324eb98d8..d21ac4658 100644 --- a/src/modules/autoseed.c +++ b/src/modules/autoseed.c @@ -968,7 +968,6 @@ static void smooth_island(region_list * island) static void starting_region(region * r, region * rn[]) { - unit *u; int n; oceans_around(r, rn); @@ -978,8 +977,7 @@ static void starting_region(region * r, region * rn[]) } terraform_region(r, newterrain(T_PLAIN)); prepare_starting_region(r); - u = addplayer(r, addfaction("enno@eressea.de", itoa36(rng_int()), races, - default_locale, 0)); + addplayer(r, addfaction("enno@eressea.de", itoa36(rng_int()), races, default_locale, 0)); } /* E3A island generation */