diff --git a/src/alchemy.c b/src/alchemy.c index ca110d397..c933d3fa3 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -78,7 +78,8 @@ void herbsearch(unit * u, int max) max = rherbs(r); herbsfound = ntimespprob(effsk * u->number, (double)rherbs(r) / 100.0F, -0.01F); - herbsfound = MIN(herbsfound, max); + + if (herbsfound > max) herbsfound = max; rsetherbs(r, (short) (rherbs(r) - herbsfound)); if (herbsfound) { @@ -156,7 +157,9 @@ static int potion_water_of_life(unit * u, region *r, int amount) { } static int potion_healing(unit * u, int amount) { - u->hp = MIN(unit_max_hp(u) * u->number, u->hp + 400 * amount); + int maxhp = unit_max_hp(u) * u->number; + u->hp = u->hp + 400 * amount; + if (u->hp > maxhp) u->hp = maxhp; return amount; } diff --git a/src/bind_building.c b/src/bind_building.c index 026bc7ee8..42b92fc07 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -10,7 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "bind_building.h" #include "bind_unit.h" @@ -21,6 +20,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #include diff --git a/src/bind_faction.c b/src/bind_faction.c index f9321f6b5..6b02f13b9 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -10,7 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "bind_faction.h" #include "bind_unit.h" #include "bindings.h" @@ -31,6 +30,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index 18efbd994..43f4138fa 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -1,4 +1,3 @@ -#include #include #include "bind_gmtool.h" @@ -9,6 +8,7 @@ #include #include #include +#include #include @@ -16,6 +16,7 @@ static int tolua_run_mapper(lua_State * L) { + UNUSED_ARG(L); run_mapper(); return 0; } @@ -24,6 +25,7 @@ static int tolua_highlight_region(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); int select = tolua_toboolean(L, 2, 0); + UNUSED_ARG(L); highlight_region(r, select); return 0; } @@ -41,6 +43,7 @@ static int tolua_select_coordinate(lua_State * L) int nx = (int)tolua_tonumber(L, 1, 0); int ny = (int)tolua_tonumber(L, 2, 0); int select = tolua_toboolean(L, 3, 0); + UNUSED_ARG(L); if (current_state) { select_coordinate(current_state->selected, nx, ny, select); } @@ -186,8 +189,8 @@ static void lua_paint_info(struct window *wnd, const struct state *st) if (!end) break; else { - size_t len = end - str; - int bytes = MIN((int)len, size); + int bytes = (int)(end - str); + if (bytes < size) bytes = size; mvwaddnstr(win, line++, 1, str, bytes); wclrtoeol(win); str = end + 1; diff --git a/src/bind_message.c b/src/bind_message.c index a3ab95d39..c553d3e67 100644 --- a/src/bind_message.c +++ b/src/bind_message.c @@ -1,4 +1,3 @@ -#include #include "spells.h" /* kernel includes */ @@ -10,6 +9,7 @@ /* util includes */ #include +#include #include #include diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 082d940ae..7c7a50940 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -1,4 +1,3 @@ -#include #include "spells/shipcurse.h" #include "monsters.h" @@ -11,6 +10,8 @@ #include #include +#include + #include #include @@ -40,6 +41,7 @@ static int tolua_planmonsters(lua_State * L) static int tolua_spawn_dragons(lua_State * L) { + UNUSED_ARG(L); spawn_dragons(); return 0; } @@ -52,6 +54,7 @@ static int tolua_get_monsters(lua_State * L) static int tolua_spawn_undead(lua_State * L) { + UNUSED_ARG(L); spawn_undead(); return 0; } diff --git a/src/bind_order.c b/src/bind_order.c index cfbe51d16..624e4f92e 100644 --- a/src/bind_order.c +++ b/src/bind_order.c @@ -1,8 +1,7 @@ -#include - /* kernel includes */ #include #include +#include /* lua includes */ #include diff --git a/src/bind_region.c b/src/bind_region.c index 10feded1d..41cff035f 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -10,7 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "bind_region.h" #include "bind_unit.h" #include "bind_ship.h" @@ -39,6 +38,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c index e8c9b7565..ee2d58666 100644 --- a/src/bind_sqlite.c +++ b/src/bind_sqlite.c @@ -10,14 +10,15 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include - #include "bind_unit.h" #include "bindings.h" -#include +#include /* for game_id */ +#include + #include #include +#include #define LTYPE_DB TOLUA_CAST "db" diff --git a/src/bind_storage.c b/src/bind_storage.c index 68ac36179..ce35ad2f0 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -10,13 +10,13 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "bind_storage.h" #include #include #include +#include #include #include diff --git a/src/bind_unit.c b/src/bind_unit.c index f48965bfc..3d455f3a9 100644 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -10,8 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include - #include "bind_unit.h" #include "alchemy.h" #include "bindings.h" @@ -46,6 +44,8 @@ without prior permission by the authors of Eressea. #include #include #include +#include + #include #include diff --git a/src/bindings.c b/src/bindings.c index 14f0c96f3..f5acdb1e9 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -10,7 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "bindings.h" #include "bind_unit.h" #include "bind_storage.h" @@ -65,11 +64,12 @@ without prior permission by the authors of Eressea. #include #include #include -#include +#include #include #include #include +#include #include #include @@ -273,6 +273,7 @@ static int tolua_message_region(lua_State * L) static int tolua_update_guards(lua_State * L) { + UNUSED_ARG(L); update_guards(); return 0; } @@ -377,6 +378,7 @@ static int tolua_learn_skill(lua_State * L) static int tolua_update_scores(lua_State * L) { + UNUSED_ARG(L); score(); return 0; } @@ -384,6 +386,7 @@ static int tolua_update_scores(lua_State * L) static int tolua_update_owners(lua_State * L) { region *r; + UNUSED_ARG(L); for (r = regions; r; r = r->next) { update_owners(r); } @@ -392,12 +395,14 @@ static int tolua_update_owners(lua_State * L) static int tolua_update_subscriptions(lua_State * L) { + UNUSED_ARG(L); update_subscriptions(); return 0; } static int tolua_remove_empty_units(lua_State * L) { + UNUSED_ARG(L); remove_empty_units(); return 0; } @@ -482,24 +487,28 @@ static int tolua_write_reports(lua_State * L) static int tolua_process_orders(lua_State * L) { + UNUSED_ARG(L); processorders(); return 0; } static int tolua_turn_begin(lua_State * L) { + UNUSED_ARG(L); turn_begin(); return 0; } static int tolua_turn_process(lua_State * L) { + UNUSED_ARG(L); turn_process(); return 0; } static int tolua_turn_end(lua_State * L) { + UNUSED_ARG(L); turn_end(); return 0; } @@ -514,12 +523,14 @@ static int tolua_write_passwords(lua_State * L) static struct summary *sum_begin = 0; static int tolua_init_summary(lua_State * L) { + UNUSED_ARG(L); sum_begin = make_summary(); return 0; } static int tolua_write_summary(lua_State * L) { + UNUSED_ARG(L); if (sum_begin) { struct summary *sum_end = make_summary(); report_summary(sum_end, sum_begin, false); diff --git a/src/helpers.c b/src/helpers.c index 6924dbf61..983750173 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -10,7 +10,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. */ -#include #include "helpers.h" #include "vortex.h" #include "alchemy.h" @@ -21,6 +20,7 @@ without prior permission by the authors of Eressea. #include #include #include +#include #include #include @@ -54,6 +54,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o int result = -1, len; const char *iname = itype->rtype->_name; + UNUSED_ARG(ord); assert(s != NULL); len = snprintf(fname, sizeof(fname), "%s_give", iname); if (len > 0 && (size_t)len < sizeof(fname)) { @@ -305,6 +306,9 @@ static int building_action_read(struct attrib *a, void *owner, gamedata *data) { struct storage *store = data->store; + UNUSED_ARG(owner); + UNUSED_ARG(a); + if (data->version < ATTRIBOWNER_VERSION) { READ_INT(data->store, NULL); } diff --git a/src/magic.c b/src/magic.c index 812045eef..3b4a8d331 100644 --- a/src/magic.c +++ b/src/magic.c @@ -66,6 +66,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include +#include #include #include #include @@ -142,7 +143,7 @@ static int a_readicastle(attrib * a, void *owner, struct gamedata *data) icastle_data *idata = (icastle_data *)a->data.v; char token[32]; - (void)owner; + UNUSED_ARG(owner); READ_TOK(store, token, sizeof(token)); if (data->version < ATTRIBOWNER_VERSION) { READ_INT(store, NULL); @@ -156,7 +157,7 @@ static void a_writeicastle(const attrib * a, const void *owner, struct storage *store) { icastle_data *data = (icastle_data *)a->data.v; - (void)owner; + UNUSED_ARG(owner); WRITE_TOK(store, data->type->_name); WRITE_INT(store, data->time); } @@ -256,7 +257,7 @@ static int read_mage(attrib * a, void *owner, struct gamedata *data) sc_mage *mage = (sc_mage *)a->data.v; char spname[64]; - (void)owner; + UNUSED_ARG(owner); READ_INT(store, &mtype); mage->magietyp = (magic_t)mtype; READ_INT(store, &mage->spellpoints); @@ -302,7 +303,7 @@ write_mage(const attrib * a, const void *owner, struct storage *store) int i; sc_mage *mage = (sc_mage *)a->data.v; - (void)owner; + UNUSED_ARG(owner); WRITE_INT(store, mage->magietyp); WRITE_INT(store, mage->spellpoints); WRITE_INT(store, mage->spchange); @@ -364,7 +365,7 @@ static int read_seenspell(attrib * a, void *owner, struct gamedata *data) spell *sp = 0; char token[32]; - (void)owner; + UNUSED_ARG(owner); READ_TOK(store, token, sizeof(token)); if (data->version < UNIQUE_SPELLS_VERSION) { READ_INT(store, 0); /* ignore mtype */ @@ -382,7 +383,7 @@ static void write_seenspell(const attrib * a, const void *owner, struct storage *store) { const spell *sp = (const spell *)a->data.v; - (void)owner; + UNUSED_ARG(owner); WRITE_TOK(store, sp->sname); } @@ -919,7 +920,7 @@ void pay_spell(unit * u, const spell * sp, int cast_level, int range) */ bool knowsspell(const region * r, const unit * u, const spell * sp) { - (void)r; + UNUSED_ARG(r); assert(sp); /* steht der Spruch in der Spruchliste? */ return u_hasspell(u, sp) != 0; @@ -1328,7 +1329,7 @@ bool fumble(region * r, unit * u, const spell * sp, int cast_grade) int fumble_enabled = config_get_int("magic.fumble.enable", 1); sc_mage * mage; - (void)sp; + UNUSED_ARG(sp); if (effsk <= 0 || !fumble_enabled) { return false; } @@ -2177,7 +2178,7 @@ static void a_write_unit(const attrib * a, const void *owner, struct storage *store) { unit *u = (unit *)a->data.v; - (void)owner; + UNUSED_ARG(owner); write_unit_reference(u, store); } @@ -2280,7 +2281,7 @@ void create_newfamiliar(unit * mage, unit * fam) } static void * resolve_familiar(int id, void *data) { - (void)id; + UNUSED_ARG(id); if (data) { unit *familiar = (unit *)data; attrib *a = a_find(familiar->attribs, &at_familiarmage); @@ -2294,7 +2295,7 @@ static void * resolve_familiar(int id, void *data) { static int read_familiar(attrib * a, void *owner, struct gamedata *data) { - (void)owner; + UNUSED_ARG(owner); if (read_unit_reference(data, (unit **)&a->data.v, resolve_familiar) <= 0) { return AT_READ_FAIL; } @@ -2361,7 +2362,7 @@ unit *has_clone(unit * mage) } static void * resolve_clone(int id, void *data) { - (void)id; + UNUSED_ARG(id); if (data) { unit *clone = (unit *)data; attrib *a = a_find(clone->attribs, &at_clonemage); @@ -2375,7 +2376,7 @@ static void * resolve_clone(int id, void *data) { static int read_clone(attrib * a, void *owner, struct gamedata *data) { - (void)owner; + UNUSED_ARG(owner); if (read_unit_reference(data, (unit **)&a->data.v, resolve_clone) <= 0) { return AT_READ_FAIL; } @@ -2384,7 +2385,7 @@ static int read_clone(attrib * a, void *owner, struct gamedata *data) /* mages */ static void * resolve_mage(int id, void *data) { - (void)id; + UNUSED_ARG(id); if (data) { unit *mage = (unit *)data; attrib *a = a_find(mage->attribs, &at_familiar); @@ -2398,7 +2399,7 @@ static void * resolve_mage(int id, void *data) { static int read_magician(attrib * a, void *owner, struct gamedata *data) { - (void)owner; + UNUSED_ARG(owner); if (read_unit_reference(data, (unit **)&a->data.v, resolve_mage) <= 0) { return AT_READ_FAIL; } @@ -2409,7 +2410,7 @@ static int age_unit(attrib * a, void *owner) /* if unit is gone or dead, remove the attribute */ { unit *u = (unit *)a->data.v; - (void)owner; + UNUSED_ARG(owner); return (u != NULL && u->number > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } @@ -3057,9 +3058,9 @@ void free_spellbook(spellbook *sb) { static int free_spellbook_cb(const void *match, const void *key, size_t keylen, void *data) { const sb_entry *ent = (const sb_entry *)match; - (void)data; - (void)keylen; - (void)key; + UNUSED_ARG(data); + UNUSED_ARG(keylen); + UNUSED_ARG(key); free_spellbook(ent->value); return 0; }