more frequent use util/macros.h instead of platform.h

This commit is contained in:
Enno Rehling 2017-12-28 18:55:45 +01:00
parent 5d45b0f99b
commit f82fe6e963
14 changed files with 65 additions and 40 deletions

View file

@ -78,7 +78,8 @@ void herbsearch(unit * u, int max)
max = rherbs(r); max = rherbs(r);
herbsfound = ntimespprob(effsk * u->number, herbsfound = ntimespprob(effsk * u->number,
(double)rherbs(r) / 100.0F, -0.01F); (double)rherbs(r) / 100.0F, -0.01F);
herbsfound = MIN(herbsfound, max);
if (herbsfound > max) herbsfound = max;
rsetherbs(r, (short) (rherbs(r) - herbsfound)); rsetherbs(r, (short) (rherbs(r) - herbsfound));
if (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) { 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; return amount;
} }

View file

@ -10,7 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_building.h" #include "bind_building.h"
#include "bind_unit.h" #include "bind_unit.h"
@ -21,6 +20,7 @@ without prior permission by the authors of Eressea.
#include <util/log.h> #include <util/log.h>
#include <util/language.h> #include <util/language.h>
#include <util/macros.h>
#include <util/strings.h> #include <util/strings.h>
#include <tolua.h> #include <tolua.h>

View file

@ -10,7 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_faction.h" #include "bind_faction.h"
#include "bind_unit.h" #include "bind_unit.h"
#include "bindings.h" #include "bindings.h"
@ -31,6 +30,7 @@ without prior permission by the authors of Eressea.
#include <util/base36.h> #include <util/base36.h>
#include <util/language.h> #include <util/language.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <util/password.h> #include <util/password.h>
#include <tolua.h> #include <tolua.h>

View file

@ -1,4 +1,3 @@
#include <platform.h>
#include <curses.h> #include <curses.h>
#include "bind_gmtool.h" #include "bind_gmtool.h"
@ -9,6 +8,7 @@
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <modules/autoseed.h> #include <modules/autoseed.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <tolua.h> #include <tolua.h>
@ -16,6 +16,7 @@
static int tolua_run_mapper(lua_State * L) static int tolua_run_mapper(lua_State * L)
{ {
UNUSED_ARG(L);
run_mapper(); run_mapper();
return 0; return 0;
} }
@ -24,6 +25,7 @@ static int tolua_highlight_region(lua_State * L)
{ {
region *r = (region *)tolua_tousertype(L, 1, 0); region *r = (region *)tolua_tousertype(L, 1, 0);
int select = tolua_toboolean(L, 2, 0); int select = tolua_toboolean(L, 2, 0);
UNUSED_ARG(L);
highlight_region(r, select); highlight_region(r, select);
return 0; return 0;
} }
@ -41,6 +43,7 @@ static int tolua_select_coordinate(lua_State * L)
int nx = (int)tolua_tonumber(L, 1, 0); int nx = (int)tolua_tonumber(L, 1, 0);
int ny = (int)tolua_tonumber(L, 2, 0); int ny = (int)tolua_tonumber(L, 2, 0);
int select = tolua_toboolean(L, 3, 0); int select = tolua_toboolean(L, 3, 0);
UNUSED_ARG(L);
if (current_state) { if (current_state) {
select_coordinate(current_state->selected, nx, ny, select); 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) if (!end)
break; break;
else { else {
size_t len = end - str; int bytes = (int)(end - str);
int bytes = MIN((int)len, size); if (bytes < size) bytes = size;
mvwaddnstr(win, line++, 1, str, bytes); mvwaddnstr(win, line++, 1, str, bytes);
wclrtoeol(win); wclrtoeol(win);
str = end + 1; str = end + 1;

View file

@ -1,4 +1,3 @@
#include <platform.h>
#include "spells.h" #include "spells.h"
/* kernel includes */ /* kernel includes */
@ -10,6 +9,7 @@
/* util includes */ /* util includes */
#include <util/language.h> #include <util/language.h>
#include <util/macros.h>
#include <util/message.h> #include <util/message.h>
#include <util/nrmessage.h> #include <util/nrmessage.h>

View file

@ -1,4 +1,3 @@
#include <platform.h>
#include "spells/shipcurse.h" #include "spells/shipcurse.h"
#include "monsters.h" #include "monsters.h"
@ -11,6 +10,8 @@
#include <kernel/spellbook.h> #include <kernel/spellbook.h>
#include <kernel/unit.h> #include <kernel/unit.h>
#include <util/macros.h>
#include <tolua.h> #include <tolua.h>
#include <stdlib.h> #include <stdlib.h>
@ -40,6 +41,7 @@ static int tolua_planmonsters(lua_State * L)
static int tolua_spawn_dragons(lua_State * L) static int tolua_spawn_dragons(lua_State * L)
{ {
UNUSED_ARG(L);
spawn_dragons(); spawn_dragons();
return 0; return 0;
} }
@ -52,6 +54,7 @@ static int tolua_get_monsters(lua_State * L)
static int tolua_spawn_undead(lua_State * L) static int tolua_spawn_undead(lua_State * L)
{ {
UNUSED_ARG(L);
spawn_undead(); spawn_undead();
return 0; return 0;
} }

View file

@ -1,8 +1,7 @@
#include <platform.h>
/* kernel includes */ /* kernel includes */
#include <kernel/order.h> #include <kernel/order.h>
#include <util/parser.h> #include <util/parser.h>
#include <util/macros.h>
/* lua includes */ /* lua includes */
#include <tolua.h> #include <tolua.h>

View file

@ -10,7 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_region.h" #include "bind_region.h"
#include "bind_unit.h" #include "bind_unit.h"
#include "bind_ship.h" #include "bind_ship.h"
@ -39,6 +38,7 @@ without prior permission by the authors of Eressea.
#include <util/base36.h> #include <util/base36.h>
#include <util/language.h> #include <util/language.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <util/strings.h> #include <util/strings.h>
#include <critbit.h> #include <critbit.h>

View file

@ -10,14 +10,15 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_unit.h" #include "bind_unit.h"
#include "bindings.h" #include "bindings.h"
#include <kernel/config.h> #include <kernel/config.h> /* for game_id */
#include <util/macros.h>
#include <sqlite3.h> #include <sqlite3.h>
#include <tolua.h> #include <tolua.h>
#include <stdbool.h>
#define LTYPE_DB TOLUA_CAST "db" #define LTYPE_DB TOLUA_CAST "db"

View file

@ -10,13 +10,13 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_storage.h" #include "bind_storage.h"
#include <kernel/save.h> #include <kernel/save.h>
#include <util/gamedata.h> #include <util/gamedata.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <storage.h> #include <storage.h>
#include <stream.h> #include <stream.h>

View file

@ -10,8 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bind_unit.h" #include "bind_unit.h"
#include "alchemy.h" #include "alchemy.h"
#include "bindings.h" #include "bindings.h"
@ -46,6 +44,8 @@ without prior permission by the authors of Eressea.
#include <util/event.h> #include <util/event.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <selist.h> #include <selist.h>
#include <tolua.h> #include <tolua.h>

View file

@ -10,7 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "bindings.h" #include "bindings.h"
#include "bind_unit.h" #include "bind_unit.h"
#include "bind_storage.h" #include "bind_storage.h"
@ -65,11 +64,12 @@ without prior permission by the authors of Eressea.
#include <util/language.h> #include <util/language.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>
#include <selist.h> #include <util/macros.h>
#include <util/rand.h> #include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
#include <util/xml.h> #include <util/xml.h>
#include <selist.h>
#include <storage.h> #include <storage.h>
#include <iniparser.h> #include <iniparser.h>
@ -273,6 +273,7 @@ static int tolua_message_region(lua_State * L)
static int tolua_update_guards(lua_State * L) static int tolua_update_guards(lua_State * L)
{ {
UNUSED_ARG(L);
update_guards(); update_guards();
return 0; return 0;
} }
@ -377,6 +378,7 @@ static int tolua_learn_skill(lua_State * L)
static int tolua_update_scores(lua_State * L) static int tolua_update_scores(lua_State * L)
{ {
UNUSED_ARG(L);
score(); score();
return 0; return 0;
} }
@ -384,6 +386,7 @@ static int tolua_update_scores(lua_State * L)
static int tolua_update_owners(lua_State * L) static int tolua_update_owners(lua_State * L)
{ {
region *r; region *r;
UNUSED_ARG(L);
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
update_owners(r); update_owners(r);
} }
@ -392,12 +395,14 @@ static int tolua_update_owners(lua_State * L)
static int tolua_update_subscriptions(lua_State * L) static int tolua_update_subscriptions(lua_State * L)
{ {
UNUSED_ARG(L);
update_subscriptions(); update_subscriptions();
return 0; return 0;
} }
static int tolua_remove_empty_units(lua_State * L) static int tolua_remove_empty_units(lua_State * L)
{ {
UNUSED_ARG(L);
remove_empty_units(); remove_empty_units();
return 0; return 0;
} }
@ -482,24 +487,28 @@ static int tolua_write_reports(lua_State * L)
static int tolua_process_orders(lua_State * L) static int tolua_process_orders(lua_State * L)
{ {
UNUSED_ARG(L);
processorders(); processorders();
return 0; return 0;
} }
static int tolua_turn_begin(lua_State * L) static int tolua_turn_begin(lua_State * L)
{ {
UNUSED_ARG(L);
turn_begin(); turn_begin();
return 0; return 0;
} }
static int tolua_turn_process(lua_State * L) static int tolua_turn_process(lua_State * L)
{ {
UNUSED_ARG(L);
turn_process(); turn_process();
return 0; return 0;
} }
static int tolua_turn_end(lua_State * L) static int tolua_turn_end(lua_State * L)
{ {
UNUSED_ARG(L);
turn_end(); turn_end();
return 0; return 0;
} }
@ -514,12 +523,14 @@ static int tolua_write_passwords(lua_State * L)
static struct summary *sum_begin = 0; static struct summary *sum_begin = 0;
static int tolua_init_summary(lua_State * L) static int tolua_init_summary(lua_State * L)
{ {
UNUSED_ARG(L);
sum_begin = make_summary(); sum_begin = make_summary();
return 0; return 0;
} }
static int tolua_write_summary(lua_State * L) static int tolua_write_summary(lua_State * L)
{ {
UNUSED_ARG(L);
if (sum_begin) { if (sum_begin) {
struct summary *sum_end = make_summary(); struct summary *sum_end = make_summary();
report_summary(sum_end, sum_begin, false); report_summary(sum_end, sum_begin, false);

View file

@ -10,7 +10,6 @@ This program may not be used, modified or distributed
without prior permission by the authors of Eressea. without prior permission by the authors of Eressea.
*/ */
#include <platform.h>
#include "helpers.h" #include "helpers.h"
#include "vortex.h" #include "vortex.h"
#include "alchemy.h" #include "alchemy.h"
@ -21,6 +20,7 @@ without prior permission by the authors of Eressea.
#include <util/functions.h> #include <util/functions.h>
#include <util/gamedata.h> #include <util/gamedata.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <util/parser.h> #include <util/parser.h>
#include <util/resolve.h> #include <util/resolve.h>
@ -54,6 +54,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o
int result = -1, len; int result = -1, len;
const char *iname = itype->rtype->_name; const char *iname = itype->rtype->_name;
UNUSED_ARG(ord);
assert(s != NULL); assert(s != NULL);
len = snprintf(fname, sizeof(fname), "%s_give", iname); len = snprintf(fname, sizeof(fname), "%s_give", iname);
if (len > 0 && (size_t)len < sizeof(fname)) { 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; struct storage *store = data->store;
UNUSED_ARG(owner);
UNUSED_ARG(a);
if (data->version < ATTRIBOWNER_VERSION) { if (data->version < ATTRIBOWNER_VERSION) {
READ_INT(data->store, NULL); READ_INT(data->store, NULL);
} }

View file

@ -66,6 +66,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/language.h> #include <util/language.h>
#include <util/lists.h> #include <util/lists.h>
#include <util/log.h> #include <util/log.h>
#include <util/macros.h>
#include <util/parser.h> #include <util/parser.h>
#include <util/rand.h> #include <util/rand.h>
#include <util/resolve.h> #include <util/resolve.h>
@ -142,7 +143,7 @@ static int a_readicastle(attrib * a, void *owner, struct gamedata *data)
icastle_data *idata = (icastle_data *)a->data.v; icastle_data *idata = (icastle_data *)a->data.v;
char token[32]; char token[32];
(void)owner; UNUSED_ARG(owner);
READ_TOK(store, token, sizeof(token)); READ_TOK(store, token, sizeof(token));
if (data->version < ATTRIBOWNER_VERSION) { if (data->version < ATTRIBOWNER_VERSION) {
READ_INT(store, NULL); READ_INT(store, NULL);
@ -156,7 +157,7 @@ static void
a_writeicastle(const attrib * a, const void *owner, struct storage *store) a_writeicastle(const attrib * a, const void *owner, struct storage *store)
{ {
icastle_data *data = (icastle_data *)a->data.v; icastle_data *data = (icastle_data *)a->data.v;
(void)owner; UNUSED_ARG(owner);
WRITE_TOK(store, data->type->_name); WRITE_TOK(store, data->type->_name);
WRITE_INT(store, data->time); 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; sc_mage *mage = (sc_mage *)a->data.v;
char spname[64]; char spname[64];
(void)owner; UNUSED_ARG(owner);
READ_INT(store, &mtype); READ_INT(store, &mtype);
mage->magietyp = (magic_t)mtype; mage->magietyp = (magic_t)mtype;
READ_INT(store, &mage->spellpoints); READ_INT(store, &mage->spellpoints);
@ -302,7 +303,7 @@ write_mage(const attrib * a, const void *owner, struct storage *store)
int i; int i;
sc_mage *mage = (sc_mage *)a->data.v; sc_mage *mage = (sc_mage *)a->data.v;
(void)owner; UNUSED_ARG(owner);
WRITE_INT(store, mage->magietyp); WRITE_INT(store, mage->magietyp);
WRITE_INT(store, mage->spellpoints); WRITE_INT(store, mage->spellpoints);
WRITE_INT(store, mage->spchange); WRITE_INT(store, mage->spchange);
@ -364,7 +365,7 @@ static int read_seenspell(attrib * a, void *owner, struct gamedata *data)
spell *sp = 0; spell *sp = 0;
char token[32]; char token[32];
(void)owner; UNUSED_ARG(owner);
READ_TOK(store, token, sizeof(token)); READ_TOK(store, token, sizeof(token));
if (data->version < UNIQUE_SPELLS_VERSION) { if (data->version < UNIQUE_SPELLS_VERSION) {
READ_INT(store, 0); /* ignore mtype */ READ_INT(store, 0); /* ignore mtype */
@ -382,7 +383,7 @@ static void
write_seenspell(const attrib * a, const void *owner, struct storage *store) write_seenspell(const attrib * a, const void *owner, struct storage *store)
{ {
const spell *sp = (const spell *)a->data.v; const spell *sp = (const spell *)a->data.v;
(void)owner; UNUSED_ARG(owner);
WRITE_TOK(store, sp->sname); 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) bool knowsspell(const region * r, const unit * u, const spell * sp)
{ {
(void)r; UNUSED_ARG(r);
assert(sp); assert(sp);
/* steht der Spruch in der Spruchliste? */ /* steht der Spruch in der Spruchliste? */
return u_hasspell(u, sp) != 0; 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); int fumble_enabled = config_get_int("magic.fumble.enable", 1);
sc_mage * mage; sc_mage * mage;
(void)sp; UNUSED_ARG(sp);
if (effsk <= 0 || !fumble_enabled) { if (effsk <= 0 || !fumble_enabled) {
return false; return false;
} }
@ -2177,7 +2178,7 @@ static void
a_write_unit(const attrib * a, const void *owner, struct storage *store) a_write_unit(const attrib * a, const void *owner, struct storage *store)
{ {
unit *u = (unit *)a->data.v; unit *u = (unit *)a->data.v;
(void)owner; UNUSED_ARG(owner);
write_unit_reference(u, store); write_unit_reference(u, store);
} }
@ -2280,7 +2281,7 @@ void create_newfamiliar(unit * mage, unit * fam)
} }
static void * resolve_familiar(int id, void *data) { static void * resolve_familiar(int id, void *data) {
(void)id; UNUSED_ARG(id);
if (data) { if (data) {
unit *familiar = (unit *)data; unit *familiar = (unit *)data;
attrib *a = a_find(familiar->attribs, &at_familiarmage); 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) 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) { if (read_unit_reference(data, (unit **)&a->data.v, resolve_familiar) <= 0) {
return AT_READ_FAIL; return AT_READ_FAIL;
} }
@ -2361,7 +2362,7 @@ unit *has_clone(unit * mage)
} }
static void * resolve_clone(int id, void *data) { static void * resolve_clone(int id, void *data) {
(void)id; UNUSED_ARG(id);
if (data) { if (data) {
unit *clone = (unit *)data; unit *clone = (unit *)data;
attrib *a = a_find(clone->attribs, &at_clonemage); 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) 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) { if (read_unit_reference(data, (unit **)&a->data.v, resolve_clone) <= 0) {
return AT_READ_FAIL; return AT_READ_FAIL;
} }
@ -2384,7 +2385,7 @@ static int read_clone(attrib * a, void *owner, struct gamedata *data)
/* mages */ /* mages */
static void * resolve_mage(int id, void *data) { static void * resolve_mage(int id, void *data) {
(void)id; UNUSED_ARG(id);
if (data) { if (data) {
unit *mage = (unit *)data; unit *mage = (unit *)data;
attrib *a = a_find(mage->attribs, &at_familiar); 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) 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) { if (read_unit_reference(data, (unit **)&a->data.v, resolve_mage) <= 0) {
return AT_READ_FAIL; 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 */ /* if unit is gone or dead, remove the attribute */
{ {
unit *u = (unit *)a->data.v; unit *u = (unit *)a->data.v;
(void)owner; UNUSED_ARG(owner);
return (u != NULL && u->number > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; 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) { static int free_spellbook_cb(const void *match, const void *key, size_t keylen, void *data) {
const sb_entry *ent = (const sb_entry *)match; const sb_entry *ent = (const sb_entry *)match;
(void)data; UNUSED_ARG(data);
(void)keylen; UNUSED_ARG(keylen);
(void)key; UNUSED_ARG(key);
free_spellbook(ent->value); free_spellbook(ent->value);
return 0; return 0;
} }