Merge pull request #661 from ennorehling/develop

pedantic gcc compilation
This commit is contained in:
Enno Rehling 2017-02-18 22:07:12 +01:00 committed by GitHub
commit 27f9490ec1
91 changed files with 292 additions and 289 deletions

View file

@ -765,7 +765,7 @@
</race>
<race name="ghast" magres="60" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="nameghoul"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>
@ -803,7 +803,7 @@
</race>
<race name="juju-zombie" magres="50" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="namezombie"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>
@ -836,7 +836,7 @@
</race>
<race name="skeletonlord" magres="30" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="nameskeleton"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>

View file

@ -1038,7 +1038,7 @@
<attack type="1" damage="1d4"/>
</race>
<race name="ghast" magres="60" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="nameghoul"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>
@ -1074,7 +1074,7 @@
<attack type="2" damage="1d30"/>
</race>
<race name="juju-zombie" magres="50" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="namezombie"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>
@ -1105,7 +1105,7 @@
<attack type="1" damage="1d7"/>
</race>
<race name="skeletonlord" magres="30" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes">
<ai splitsize="2000" aggression="0.02" killpeasants="yes" moverandom="yes"/>
<ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
<function name="name" value="nameskeleton"/>
<skill name="crossbow" modifier="1"/>
<skill name="bow" modifier="1"/>

View file

@ -25,9 +25,8 @@ IF (CMAKE_COMPILER_IS_GNUCC)
ENDIF()
IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
# SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
add_definitions(-DHAVE__BOOL)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-compare -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89")
ELSEIF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG

View file

@ -172,8 +172,7 @@ static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) {
static int potion_truth(unit *u) {
UNUSED_ARG(u);
// TODO: this potion does nothing!
// fset(u, UFL_DISBELIEVES);
/* TODO: this potion does nothing! */
return 1;
}
@ -297,7 +296,7 @@ static void a_initeffect(attrib * a)
a->data.v = calloc(sizeof(effect_data), 1);
}
static void a_finalizeeffect(attrib * a) //-V524
static void a_finalizeeffect(attrib * a) /*-V524 */
{
free(a->data.v);
}
@ -328,7 +327,7 @@ static int a_readeffect(attrib * a, void *owner, struct gamedata *data)
return AT_READ_FAIL;
}
if (rtype->ptype==oldpotiontype[P_HEAL]) {
// healing potions used to have long-term effects
/* healing potions used to have long-term effects */
return AT_READ_FAIL;
}
edata->type = rtype->ptype;

View file

@ -20,7 +20,7 @@ struct attrib;
extern "C" {
#endif
extern struct attrib_type at_dict; // DEPRECATED: at_dict has been replaced with at_keys
extern struct attrib_type at_dict; /* DEPRECATED: at_dict has been replaced with at_keys */
void dict_set(struct attrib * a, const char * name, int value);

View file

@ -134,7 +134,7 @@ void key_set(attrib ** alist, int key, int val)
n = keys[0];
}
keys = realloc(keys, sizeof(int) *(2 * n + 3));
// TODO: does insertion sort pay off here? prob. not.
/* TODO: does insertion sort pay off here? prob. not. */
keys[0] = n + 1;
keys[2 * n + 1] = key;
keys[2 * n + 2] = val;

View file

@ -26,7 +26,7 @@ extern "C" {
#endif
struct attrib;
struct attrib_type;
extern struct attrib_type at_key; // DEPRECATED: at_key has been replaced with at_keys
extern struct attrib_type at_key; /* DEPRECATED: at_key has been replaced with at_keys */
extern struct attrib_type at_keys;
void key_set(struct attrib **alist, int key, int value);

View file

@ -1111,7 +1111,7 @@ int calculate_armor(troop dt, const weapon_type *dwtype, const weapon_type *awty
ar += am;
if (magres) {
// calculate damage multiplier for magical damage
/* calculate damage multiplier for magical damage */
double res = 1.0 - magic_resistance(du);
if (u_race(du)->battle_flags & BF_EQUIPMENT) {
@ -1302,10 +1302,10 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
if (oldpotiontype[P_HEAL] && !fval(&df->person[dt.index], FL_HEALING_USED)) {
if (i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0) {
i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1);
message *m = msg_message("battle::potionsave", "unit", du);
message_faction(b, du->faction, m);
msg_release(m);
i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1);
fset(&df->person[dt.index], FL_HEALING_USED);
df->person[dt.index].hp = u_race(du)->hitpoints * 5; /* give the person a buffer */
return false;

View file

@ -433,9 +433,9 @@ static void test_battle_skilldiff(CuTest *tc)
td.fighter->person[0].flags |= FL_SLEEPING;
CuAssertIntEquals(tc, 3, skilldiff(ta, td, 0));
// TODO: unarmed halfling vs. dragon: +5
// TODO: rule_goblin_bonus
// TODO: weapon modifiers, missiles, skill_formula
/* TODO: unarmed halfling vs. dragon: +5 */
/* TODO: rule_goblin_bonus */
/* TODO: weapon modifiers, missiles, skill_formula */
free_battle(b);
test_cleanup();

View file

@ -381,7 +381,7 @@ static int tolua_faction_get_origin(lua_State * L)
static int tolua_faction_destroy(lua_State * L)
{
faction **fp, *f = (faction *)tolua_tousertype(L, 1, 0);
// TODO: this loop is slow af, but what can we do?
/* TODO: this loop is slow af, but what can we do? */
for (fp = &factions; *fp; fp = &(*fp)->next) {
if (*fp == f) {
destroyfaction(fp);

View file

@ -100,8 +100,9 @@ static int tolua_storage_tostring(lua_State * L)
{
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
char name[64];
// safe to use sprintf here, because:
// %p is at most 16 characters, %d 20, text is 16, comes to 53 with \0
/* safe to use sprintf here, because:
* %p is at most 16 characters, %d 20, text is 16,
* comes to 53 with \0 */
sprintf(name, "<gamedata %p ver=%d>", (void *)data, data->version);
lua_pushstring(L, name);
return 1;

View file

@ -857,13 +857,15 @@ static int tolua_unit_create(lua_State * L)
{
faction *f = (faction *)tolua_tousertype(L, 1, 0);
region *r = (region *)tolua_tousertype(L, 2, 0);
unit *u;
const char *rcname = tolua_tostring(L, 4, NULL);
int num = (int)tolua_tonumber(L, 3, 1);
const race *rc;
assert(f && r);
rc = rcname ? rc_find(rcname) : f->race;
assert(rc);
unit *u = create_unit(r, f, num, rc, 0, NULL, NULL);
u = create_unit(r, f, num, rc, 0, NULL, NULL);
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}

View file

@ -508,7 +508,6 @@ static void reset_game(void)
for (f = factions; f; f = f->next) {
f->flags &= FFL_SAVEMASK;
}
// init_locales();
}
static int tolua_process_orders(lua_State * L)
@ -1178,7 +1177,6 @@ int eressea_run(lua_State *L, const char *luafile)
lua_remove(L, -2);
/* try to run configuration scripts: */
// err = run_script(L, "config.lua");
err = run_script(L, "custom.lua");
/* run the main script */

View file

@ -286,7 +286,7 @@ cr_output_curses(struct stream *out, const faction * viewer, const void *obj, ob
}
static void cr_output_curses_compat(FILE *F, const faction * viewer, const void *obj, objtype_t typ) {
// TODO: eliminate this function
/* TODO: eliminate this function */
stream strm;
fstream_init(&strm, F);
cr_output_curses(&strm, viewer, obj, typ);
@ -718,7 +718,7 @@ static void cr_output_spells(stream *out, const unit * u, int maxlevel)
for (ql = book->spells, qi = 0; ql; selist_advance(&ql, &qi, 1)) {
spellbook_entry * sbe = (spellbook_entry *)selist_get(ql, qi);
if (sbe->level <= maxlevel) {
// TODO: no need to deref spref here, spref->name == sp->sname
/* TODO: no need to deref spref here, spref->name == sp->sname */
spell * sp = sbe->sp;
const char *name = translate(mkname("spell", sp->sname), spell_name(sp, f->locale));
if (!header) {
@ -752,7 +752,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
const char *prefix;
assert(u && u->number);
assert(u->region == r); // TODO: if this holds true, then why did we pass in r?
assert(u->region == r); /* TODO: if this holds true, then why did we pass in r? */
if (fval(u_race(u), RCF_INVISIBLE))
return;
@ -990,7 +990,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
static void cr_output_unit_compat(FILE * F, const region * r, const faction * f,
const unit * u, int mode)
{
// TODO: eliminate this function
/* TODO: eliminate this function */
stream strm;
fstream_init(&strm, F);
cr_output_unit(&strm, r, f, u, mode);

View file

@ -1753,7 +1753,7 @@ static void expandselling(region * r, request * sellorders, int limit)
int i;
int use = 0;
for (i = 0, search = luxurytypes; search != ltype; search = search->next) {
// TODO: this is slow and lame!
/* TODO: this is slow and lame! */
++i;
}
if (counter[i] >= limit)
@ -2444,8 +2444,8 @@ static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
f = u2->faction;
}
else {
// TODO: is this really necessary? it's the only time we use faction.c/deadhash
// it allows stealing from a unit in a dead faction, but why?
/* TODO: is this really necessary? it's the only time we use faction.c/deadhash
* it allows stealing from a unit in a dead faction, but why? */
f = dfindhash(id);
}

View file

@ -266,7 +266,7 @@ static void test_maintain_buildings(CuTest *tc) {
b->size = btype->maxsize;
u_set_building(u, b);
// this building has no upkeep, it just works:
/* this building has no upkeep, it just works: */
b->flags = 0;
maintain_buildings(r);
CuAssertIntEquals(tc, BLD_MAINTAINED, fval(b, BLD_MAINTAINED));
@ -278,7 +278,7 @@ static void test_maintain_buildings(CuTest *tc) {
req[0].rtype = itype->rtype;
btype->maintenance = req;
// we cannot afford to pay:
/* we cannot afford to pay: */
b->flags = 0;
maintain_buildings(r);
CuAssertIntEquals(tc, 0, fval(b, BLD_MAINTAINED));
@ -287,7 +287,7 @@ static void test_maintain_buildings(CuTest *tc) {
test_clear_messagelist(&f->msgs);
test_clear_messagelist(&r->msgs);
// we can afford to pay:
/* we can afford to pay: */
i_change(&u->items, itype, 100);
b->flags = 0;
maintain_buildings(r);
@ -298,7 +298,7 @@ static void test_maintain_buildings(CuTest *tc) {
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "maintenance"));
test_clear_messagelist(&f->msgs);
// this building has no owner, it doesn't work:
/* this building has no owner, it doesn't work: */
u_set_building(u, NULL);
b->flags = 0;
maintain_buildings(r);

View file

@ -70,8 +70,8 @@ static bool can_give(const unit * u, const unit * u2, const item_type * itype, i
{
if (u2) {
if (u2->number==0 && !fval(u2, UFL_ISNEW)) {
// https://bugs.eressea.de/view.php?id=2230
// cannot give anything to dead units
/* https://bugs.eressea.de/view.php?id=2230
* cannot give anything to dead units */
return false;
} else if (u->faction != u2->faction) {
int rule = rule_give();
@ -258,7 +258,7 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
message * msg;
int maxt = max_transfers();
assert(u2); // use disband_men for GIVE 0
assert(u2); /* use disband_men for GIVE 0 */
if (!can_give_men(u, u2, ord, &msg)) {
return msg;

View file

@ -393,7 +393,7 @@ static void test_give_new_unit(CuTest * tc) {
}
static void test_give_invalid_target(CuTest *tc) {
// bug https://bugs.eressea.de/view.php?id=1685
/* bug https://bugs.eressea.de/view.php?id=1685 */
struct give env = { 0 };
order *ord;

View file

@ -184,7 +184,7 @@ map_region *mr_get(const view * vi, int xofs, int yofs)
static point *coor2point(const coordinate * c, point * p)
{
assert(c && p);
p->x = c->x * TWIDTH + c->y * TWIDTH / 2; //-V537
p->x = c->x * TWIDTH + c->y * TWIDTH / 2; /*-V537 */
p->y = c->y * THEIGHT;
return p;
}
@ -262,7 +262,7 @@ static chtype mr_tile(const map_region * mr, int highlight)
const region *r = mr->r;
switch (r->terrain->_name[0]) {
case 'o':
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; //-V525
return '.' | COLOR_PAIR(hl + COLOR_CYAN) | A_BOLD; /*-V525 */
case 'd':
return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
case 't':

View file

@ -34,7 +34,7 @@ static void test_is_guarded(CuTest *tc) {
}
static void test_guard_unskilled(CuTest * tc)
// TODO: it would be better to test armedmen()
/* TODO: it would be better to test armedmen() */
{
unit *u, *ug;
region *r;

View file

@ -67,13 +67,13 @@ int json_export(stream * out, int flags) {
cJSON *json, *root = cJSON_CreateObject();
assert(out && out->api);
if (regions && (flags & EXPORT_REGIONS)) {
char id[32]; // TODO: static_assert(INT_MAX < 10^32)
char id[32]; /* TODO: static_assert(INT_MAX < 10^32) */
region * r;
plane * p;
cJSON_AddItemToObject(root, "planes", json = cJSON_CreateObject());
for (p = planes; p; p = p->next) {
cJSON *data;
sprintf(id, "%d", p->id); // safe, unless int is bigger than 64 bit
sprintf(id, "%d", p->id); /* safe, unless int is bigger than 64 bit */
cJSON_AddItemToObject(json, id, data = cJSON_CreateObject());
cJSON_AddNumberToObject(data, "x", p->minx);
cJSON_AddNumberToObject(data, "y", p->miny);
@ -85,7 +85,7 @@ int json_export(stream * out, int flags) {
cJSON_AddItemToObject(root, "regions", json = cJSON_CreateObject());
for (r = regions; r; r = r->next) {
cJSON *data;
sprintf(id, "%d", r->uid); // safe, unless int is bigger than 64 bit
sprintf(id, "%d", r->uid); /* safe, unless int is bigger than 64 bit */
cJSON_AddItemToObject(json, id, data = cJSON_CreateObject());
cJSON_AddNumberToObject(data, "x", r->x);
cJSON_AddNumberToObject(data, "y", r->y);

View file

@ -16,7 +16,7 @@
static char *strip(char *str) {
char *s = str, *b = str, *e = str;
// b is where text begins, e where it ends, s where we insert it.
/* b is where text begins, e where it ends, s where we insert it. */
for (; *b && isspace(*b); ++b) {};
for (e = b; *e && !isspace(*e); ++e) {};
while (*b) {

View file

@ -200,7 +200,7 @@ static void test_build_with_potion(CuTest *tc) {
CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20));
CuAssertIntEquals(tc, 2, get_effect(u, ptype));
set_level(u, SK_ARMORER, bf.cons.minskill);
scale_number(u, 2); // OBS: this scales the effects, too:
scale_number(u, 2); /* OBS: this scales the effects, too: */
CuAssertIntEquals(tc, 4, get_effect(u, ptype));
CuAssertIntEquals(tc, 4, build(u, &bf.cons, 0, 20));
CuAssertIntEquals(tc, 2, get_effect(u, ptype));

View file

@ -461,8 +461,8 @@ void remove_building(building ** blist, building * b)
bunhash(b);
/* Falls Karawanserei, Damm oder Tunnel einst<73>rzen, wird die schon
* gebaute Stra<EFBFBD>e zur H<EFBFBD>lfte vernichtet */
// TODO: caravan, tunnel, dam modularization ? is_building_type ?
* gebaute Strasse zur Haelfte vernichtet */
/* TODO: caravan, tunnel, dam modularization ? is_building_type ? */
if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) {
region *r = b->region;
int d;
@ -605,10 +605,11 @@ static unit *building_owner_ex(const building * bld, const struct faction * last
unit *building_owner(const building * bld)
{
unit *owner;
if (!bld) {
return NULL;
}
unit *owner = bld->_owner;
owner = bld->_owner;
if (!owner || (owner->building != bld || owner->number <= 0)) {
unit * heir = building_owner_ex(bld, owner ? owner->faction : 0);
return (heir && heir->number > 0) ? heir : 0;

View file

@ -55,8 +55,8 @@ extern "C" {
typedef enum {
DEFENSE_BONUS,
CLOSE_COMBAT_ATTACK_BONUS, // TODO: only DEFENSE_BONUS is in use?
RANGED_ATTACK_BONUS,
CLOSE_COMBAT_ATTACK_BONUS, /* TODO: only DEFENSE_BONUS is in use? */
RANGED_ATTACK_BONUS
} building_bonus;
typedef struct building_type {

View file

@ -275,7 +275,6 @@ unit *getnewunit(const region * r, const faction * f)
/* -- Erschaffung neuer Einheiten ------------------------------ */
static const char *forbidden[] = { "t", "te", "tem", "temp", NULL };
// PEASANT: "b", "ba", "bau", "baue", "p", "pe", "pea", "peas"
static int *forbidden_ids;
int forbiddenid(int id)
@ -491,19 +490,19 @@ int check_param(const struct param *p, const char *key, const char *searchvalue)
{
int result = 0;
const char *value = get_param(p, key);
char *v, *p_value;
if (!value) {
return 0;
}
char *p_value = strdup(value);
const char *delimiter = " ,;";
char *v = strtok(p_value, delimiter);
p_value = strdup(value);
v = strtok(p_value, " ,;");
while (v != NULL) {
if (strcmp(v, searchvalue) == 0) {
result = 1;
break;
}
v = strtok(NULL, delimiter);
v = strtok(NULL, " ,;");
}
free(p_value);
return result;
@ -836,7 +835,7 @@ const char * game_name(void)
const char * game_name_upper(void)
{
static char result[32]; // FIXME: static result
static char result[32]; /* FIXME: static result */
char *r = result;
const char *param = game_name();
const char *c = param;

View file

@ -61,8 +61,8 @@ extern "C" {
int newcontainerid(void);
bool rule_region_owners(void);
bool rule_stealth_other(void); // units can pretend to be another faction, TARNE PARTEI <no>
bool rule_stealth_anon(void); // units can anonymize their faction, TARNE PARTEI [NICHT]
bool rule_stealth_other(void); /* units can pretend to be another faction, TARNE PARTEI <no> */
bool rule_stealth_anon(void); /* units can anonymize their faction, TARNE PARTEI [NICHT] */
int rule_alliance_limit(void);
int rule_faction_limit(void);
#define HARVEST_WORK 0x00

View file

@ -51,7 +51,7 @@ static void test_read_unitid(CuTest *tc) {
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
free_order(ord);
// bug https://bugs.eressea.de/view.php?id=1685
/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "##");
init_order(ord);
CuAssertIntEquals(tc, -1, read_unitid(u->faction, u->region));
@ -98,14 +98,14 @@ static void test_getunit(CuTest *tc) {
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);
// bug https://bugs.eressea.de/view.php?id=1685
/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "TEMP ##");
init_order(ord);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2));
CuAssertPtrEquals(tc, NULL, u2);
free_order(ord);
// bug https://bugs.eressea.de/view.php?id=1685
/* bug https://bugs.eressea.de/view.php?id=1685 */
ord = create_order(K_GIVE, lang, "##");
init_order(ord);
CuAssertIntEquals(tc, GET_NOTFOUND, getunit(u->region, u->faction, &u2));

View file

@ -640,7 +640,7 @@ int read_borders(gamedata *data)
if (!to || !from) {
log_error("%s connection %d has missing regions", zText, bid);
if (type->read) {
// skip ahead
/* skip ahead */
connection dummy;
type->read(&dummy, data);
}

View file

@ -696,7 +696,7 @@ void transfer_curse(unit * u, unit * u2, int n)
int curse_cansee(const curse *c, const faction *viewer, objtype_t typ, const void *obj, int self) {
if (self < 3 && c->magician && c->magician->faction == viewer) {
// magicians can see their own curses better than anybody, no exceptions
/* magicians can see their own curses better than anybody, no exceptions */
self = 3;
}
else if (c->type->cansee) {

View file

@ -55,7 +55,6 @@ static void setup_curse(curse_fixture *fix, const char *name) {
}
static void cleanup_curse(curse_fixture *fix) {
// destroy_curse(fix->c);
test_cleanup();
}

View file

@ -253,7 +253,7 @@ void equipment_done(void) {
free(eq->items);
eq->items = next;
}
// TODO: subsets, skills
/* TODO: subsets, skills */
for (i=0;i!=MAXSKILLS;++i) {
free(eq->skills[i]);
}

View file

@ -449,7 +449,7 @@ void destroyfaction(faction ** fp)
/* units of other factions that were disguised as this faction
* have their disguise replaced by ordinary faction hiding. */
if (rule_stealth_other()) {
// TODO: f.alive should be tested for in get_otherfaction
/* TODO: f.alive should be tested for in get_otherfaction */
region *rc;
for (rc = regions; rc; rc = rc->next) {
for (u = rc->units; u; u = u->next) {
@ -553,7 +553,6 @@ void faction_setbanner(faction * self, const char *banner)
void faction_setpassword(faction * f, const char *pwhash)
{
assert(pwhash);
// && pwhash[0] == '$');
free(f->_password);
f->_password = strdup(pwhash);
}

View file

@ -38,11 +38,11 @@ extern "C" {
extern struct attrib_type at_maxmagicians;
/* faction flags */
#define FFL_NEWID (1<<0) // Die Partei hat bereits einmal ihre no gewechselt
#define FFL_NEWID (1<<0) /* Die Partei hat bereits einmal ihre no gewechselt */
#define FFL_ISNEW (1<<1)
#define FFL_PWMSG (1<<2) // received a "new password" message
#define FFL_PWMSG (1<<2) /* received a "new password" message */
#define FFL_QUIT (1<<3)
#define FFL_CURSED (1<<4) // you're going to have a bad time
#define FFL_CURSED (1<<4) /* you're going to have a bad time */
#define FFL_DEFENDER (1<<10)
#define FFL_SELECT (1<<18) /* ehemals f->dh, u->dh, r->dh, etc... */
#define FFL_NOAID (1<<21) /* Hilfsflag Kampf */

View file

@ -155,7 +155,7 @@ const char *resourcename(const resource_type * rtype, int flags)
}
}
if (flags & NMF_PLURAL) {
static char name[64]; // FIXME: static return value
static char name[64]; /* FIXME: static return value */
size_t len = strlen(rtype->_name);
assert(len <= sizeof(name) - 3);
memcpy(name, rtype->_name, len);
@ -638,11 +638,14 @@ static const char *resourcenames[MAX_RESOURCES] = {
const resource_type *get_resourcetype(resource_t type) {
static int update;
static struct resource_type * rtypes[MAX_RESOURCES];
const resource_type *rtype = NULL;
if (update != num_resources) {
memset(rtypes, 0, sizeof(rtypes));
update = num_resources;
}
const resource_type *rtype = rtypes[type];
else {
rtype = rtypes[type];
}
if (!rtype) {
rtype = rtypes[type] = rt_find(resourcenames[type]);
}
@ -975,27 +978,23 @@ void init_resources(void)
{
resource_type *rtype;
rt_get_or_create(resourcenames[R_PERSON]); // lousy hack
rt_get_or_create(resourcenames[R_PERSON]); /* lousy hack */
rtype = rt_get_or_create(resourcenames[R_PEASANT]);
rtype->uchange = res_changepeasants;
// R_SILVER
rtype = rt_get_or_create(resourcenames[R_SILVER]);
rtype->flags |= RTF_ITEM | RTF_POOLED;
rtype->uchange = res_changeitem;
rtype->itype = it_get_or_create(rtype);
rtype->itype->give = give_money;
// R_PERMAURA
rtype = rt_get_or_create(resourcenames[R_PERMAURA]);
rtype->uchange = res_changepermaura;
// R_LIFE
rtype = rt_get_or_create(resourcenames[R_LIFE]);
rtype->uchange = res_changehp;
// R_AURA
rtype = rt_get_or_create(resourcenames[R_AURA]);
rtype->uchange = res_changeaura;

View file

@ -19,7 +19,7 @@ static void test_resourcename_no_appearance(CuTest *tc) {
const resource_type *rtype;
test_cleanup();
init_resources(); // creates R_SILVER
init_resources(); /* creates R_SILVER */
rtype = get_resourcetype(R_SILVER);
assert(rtype && rtype->itype);
assert(rtype->itype->_appearance[0] == 0);

View file

@ -146,6 +146,8 @@ static void json_maintenance(cJSON *json, maintenance **mtp) {
static void json_construction(cJSON *json, construction **consp) {
cJSON *child;
construction * cons;
if (json->type == cJSON_Array) {
int size = 0;
for (child = json->child; child; child = child->next) {
@ -164,7 +166,7 @@ static void json_construction(cJSON *json, construction **consp) {
log_error("construction %s is not a json object: %d", json->string, json->type);
return;
}
construction * cons = (construction *)calloc(sizeof(construction), 1);
cons = (construction *)calloc(sizeof(construction), 1);
for (child = json->child; child; child = child->next) {
switch (child->type) {
case cJSON_Object:
@ -191,8 +193,8 @@ static void json_construction(cJSON *json, construction **consp) {
}
static void json_terrain_production(cJSON *json, terrain_production *prod) {
assert(json->type == cJSON_Object);
cJSON *child;
assert(json->type == cJSON_Object);
for (child = json->child; child; child = child->next) {
char **dst = 0;
switch (child->type) {
@ -490,7 +492,7 @@ static void json_race(cJSON *json, race *rc) {
else if (strcmp(child->string, "ac") == 0) {
rc->armor = child->valueint;
}
// TODO: studyspeed (orcs only)
/* TODO: studyspeed (orcs only) */
break;
case cJSON_Array:
if (strcmp(child->string, "flags") == 0) {

View file

@ -75,7 +75,7 @@ static void test_settings(CuTest * tc)
cJSON *json = cJSON_Parse(data);
test_cleanup();
config_set("game.id", "42"); // should not be replaced
config_set("game.id", "42"); /* should not be replaced */
json_config(json);
CuAssertStrEquals(tc, "42", config_get("game.id"));
CuAssertStrEquals(tc, "1", config_get("true"));
@ -488,7 +488,7 @@ static void test_terrains(CuTest * tc)
CuAssertPtrEquals(tc, rt_get_or_create("h0"), ter->herbs[0]->rtype);
CuAssertPtrEquals(tc, rt_get_or_create("h1"), ter->herbs[1]->rtype);
CuAssertPtrEquals(tc, 0, (void *)ter->herbs[2]);
CuAssertPtrNotNull(tc, ter->name); // anything named "plain" uses plain_name()
CuAssertPtrNotNull(tc, ter->name); /* anything named "plain" uses plain_name() */
CuAssertPtrNotNull(tc, ter->production);
CuAssertPtrEquals(tc, rt_get_or_create("stone"), (resource_type *)ter->production[0].type);
CuAssertDblEquals(tc, 0.1, ter->production[0].chance, 0.01);

View file

@ -39,7 +39,7 @@ void test_message(CuTest *tc) {
static void test_merge_split(CuTest *tc) {
message_list *mlist = 0, *append = 0;
struct mlist **split; // TODO: why is this a double asterisk?
struct mlist **split; /* TODO: why is this a double asterisk? */
message_type *mtype = mt_new("custom", NULL);
message *msg;

View file

@ -86,12 +86,12 @@ typedef struct rcoption {
enum {
RCO_NONE,
RCO_SCARE, // races that scare and eat peasants
RCO_OTHER, // may recruit from another race
RCO_STAMINA, // every n levels of stamina add +1 RC
RCO_HUNGER, // custom hunger.damage override (char *)
RCO_SCARE, /* races that scare and eat peasants */
RCO_OTHER, /* may recruit from another race */
RCO_STAMINA, /* every n levels of stamina add +1 RC */
RCO_HUNGER, /* custom hunger.damage override (char *) */
RCO_TRADELUX,
RCO_TRADEHERB,
RCO_TRADEHERB
};
static void rc_setoption(race *rc, int k, const char *value) {
@ -476,7 +476,7 @@ const char* rc_name(const race * rc, name_t n, char *name, size_t size) {
const char *rc_name_s(const race * rc, name_t n)
{
static char name[64]; // FIXME: static return value
static char name[64]; /* FIXME: static return value */
return rc_name(rc, n, name, sizeof(name));
}
@ -497,7 +497,7 @@ const char *racename(const struct locale *loc, const unit * u, const race * rc)
const char *str, *prefix = raceprefix(u);
if (prefix != NULL) {
static char lbuf[80]; // FIXME: static return value
static char lbuf[80]; /* FIXME: static return value */
char *bufp = lbuf;
size_t size = sizeof(lbuf) - 1;
int ch, bytes;

View file

@ -130,7 +130,6 @@ extern "C" {
int capacity;
int income;
float speed;
float aggression; /* chance that a monster will attack */
int hitpoints;
char *def_damage;
int armor;
@ -152,7 +151,7 @@ extern "C" {
struct item *(*itemdrop) (const struct race *, int size);
void(*init_familiar) (struct unit *);
struct rcoption *options; // rarely used properties
struct rcoption *options; /* rarely used properties */
const struct race *familiars[MAXMAGIETYP];
struct race *next;

View file

@ -1132,7 +1132,7 @@ void terraform_region(region * r, const terrain_type * terrain)
}
}
if (!nb) {
// TODO: this is really lame
/* TODO: this is really lame */
int i = get_maxluxuries();
if (i > 0) {
i = rng_int() % i;

View file

@ -94,7 +94,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* exported symbols symbols */
int firstx = 0, firsty = 0;
// TODO: is this still important?
/* TODO: is this still important? */
int enc_gamedata = ENCODING_UTF8;
/* local symbols */
@ -467,7 +467,7 @@ void read_planes(gamedata *data) {
}
}
read_attribs(data, &pl->attribs, pl);
if (pl->id != 1094969858) { // Regatta
if (pl->id != 1094969858) { /* Regatta */
addlist(&planes, pl);
}
}
@ -1206,7 +1206,7 @@ static void read_password(gamedata *data, faction *f) {
char * pass = getpasswd(f->no);
if (pass) {
faction_setpassword(f, password_encode(pass, PASSWORD_DEFAULT));
free(pass); // TODO: remove this allocation!
free(pass); /* TODO: remove this allocation! */
}
else {
log_error("data version is BADCRYPT but %s not in password.txt", itoa36(f->no));
@ -1542,7 +1542,7 @@ struct building *read_building(gamedata *data) {
b->type = bt_find(name);
read_attribs(data, &b->attribs, b);
// repairs, bug 2221:
/* repairs, bug 2221: */
if (b->type->maxsize>0 && b->size>b->type->maxsize) {
log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize);
b->size = b->type->maxsize;

View file

@ -40,7 +40,7 @@ extern "C" {
/* Nach MAX_INPUT_SIZE brechen wir das Einlesen der Zeile ab und nehmen an,
* dass hier ein Fehler (fehlende ") vorliegt */
// TODO: is this *really* still in use?
/* TODO: is this *really* still in use? */
extern int enc_gamedata;
int readorders(const char *filename);

View file

@ -78,7 +78,7 @@ static void test_readwrite_unit(CuTest * tc)
mstream_done(&data.strm);
gamedata_done(&data);
move_unit(u, r, NULL); // this makes sure that u doesn't leak
move_unit(u, r, NULL); /* this makes sure that u doesn't leak */
test_cleanup();
}

View file

@ -114,7 +114,7 @@ terrain_type * get_or_create_terrain(const char *name) {
terrain->next = registered_terrains;
registered_terrains = terrain;
if (strcmp("plain", name) == 0) {
// TODO: this is awful, it belongs in config
/* TODO: this is awful, it belongs in config */
terrain->name = &plain_name;
}
}

View file

@ -120,7 +120,7 @@ unit *findunitr(const region * r, int n)
return (u && u->region == r) ? u : 0;
}
// TODO: deprecated, replace with findunit(n)
/* TODO: deprecated, replace with findunit(n) */
unit *findunitg(int n, const region * hint)
{
UNUSED_ARG(hint);
@ -366,7 +366,7 @@ int gift_items(unit * u, int flags)
static unit *deleted_units = NULL;
#define DMAXHASH 7919
#undef DMAXHASH // TODO: makes dfindhash slow!
#undef DMAXHASH /* TODO: makes dfindhash slow! */
#ifdef DMAXHASH
typedef struct dead {
struct dead *nexthash;
@ -455,7 +455,6 @@ int remove_unit(unit ** ulist, unit * u)
#ifdef DMAXHASH
dhash(u->no, u->faction);
#endif
// u_setfaction(u, NULL);
u->region = NULL;

View file

@ -260,7 +260,7 @@ static void test_skillmod(CuTest *tc) {
CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER, 0));
a_remove(&u->attribs, a);
a_add(&u->attribs, a = make_skillmod(NOSKILL, SMF_ALWAYS, 0, 2.0, 0)); // NOSKILL means any skill
a_add(&u->attribs, a = make_skillmod(NOSKILL, SMF_ALWAYS, 0, 2.0, 0)); /* NOSKILL means any skill */
CuAssertIntEquals(tc, 10, effskill(u, SK_ARMORER, 0));
a_remove(&u->attribs, a);
@ -296,7 +296,7 @@ static void test_skill_familiar(CuTest *tc) {
test_cleanup();
// setup two units
/* setup two units */
mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
set_level(fam, SK_PERCEPTION, 6);
@ -304,14 +304,14 @@ static void test_skill_familiar(CuTest *tc) {
set_level(mag, SK_PERCEPTION, 6);
CuAssertIntEquals(tc, 6, effskill(mag, SK_PERCEPTION, 0));
// make them mage and familiar to each other
/* make them mage and familiar to each other */
CuAssertIntEquals(tc, true, create_newfamiliar(mag, fam));
// when they are in the same region, the mage gets half their skill as a bonus
/* when they are in the same region, the mage gets half their skill as a bonus */
CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION, 0));
CuAssertIntEquals(tc, 9, effskill(mag, SK_PERCEPTION, 0));
// when they are further apart, divide bonus by distance
/* when they are further apart, divide bonus by distance */
r = test_create_region(3, 0, 0);
move_unit(fam, r, &r->units);
CuAssertIntEquals(tc, 7, effskill(mag, SK_PERCEPTION, 0));
@ -323,7 +323,6 @@ static void test_age_familiar(CuTest *tc) {
test_cleanup();
// setup two units
mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
CuAssertPtrEquals(tc, 0, get_familiar(mag));
@ -426,28 +425,28 @@ static void test_remove_unit(CuTest *tc) {
remove_unit(&r->units, u1);
CuAssertIntEquals(tc, 0, u1->number);
CuAssertPtrEquals(tc, 0, u1->region);
// money is given to a survivor:
/* money is given to a survivor: */
CuAssertPtrEquals(tc, 0, u1->items);
CuAssertIntEquals(tc, 0, region_getresource(r, rtype));
CuAssertIntEquals(tc, 100, i_get(u2->items, rtype->itype));
// unit is removed from f->units:
/* unit is removed from f->units: */
CuAssertPtrEquals(tc, 0, u1->nextF);
CuAssertPtrEquals(tc, u2, f->units);
CuAssertPtrEquals(tc, 0, u2->nextF);
CuAssertPtrEquals(tc, 0, u2->prevF);
// unit is no longer in r->units:
/* unit is no longer in r->units: */
CuAssertPtrEquals(tc, u2, r->units);
CuAssertPtrEquals(tc, 0, u2->next);
// unit is in deleted_units:
/* unit is in deleted_units: */
CuAssertPtrEquals(tc, 0, findunit(uno));
CuAssertPtrEquals(tc, f, dfindhash(uno));
remove_unit(&r->units, u2);
// no survivor, give money to peasants:
/* no survivor, give money to peasants: */
CuAssertIntEquals(tc, 100, region_getresource(r, rtype));
// there are now no more units:
/* there are now no more units: */
CuAssertPtrEquals(tc, 0, r->units);
CuAssertPtrEquals(tc, 0, f->units);
test_cleanup();

View file

@ -4,7 +4,7 @@
#include <stdio.h>
#ifndef ERESSEA_VERSION
// the version number, if it was not passed to make with -D
/* the version number, if it was not passed to make with -D */
#define ERESSEA_VERSION "3.11.0"
#endif

View file

@ -659,7 +659,7 @@ static weapon_type *xml_readweapon(xmlXPathContextPtr xpath, item_type * itype)
xmlFree(propValue);
propValue = xmlGetProp(node, BAD_CAST "value");
wtype->damage[pos] = strdup((const char *)propValue); // TODO: this is a memory leak
wtype->damage[pos] = strdup((const char *)propValue); /* TODO: this is a memory leak */
if (k == 0)
wtype->damage[1 - pos] = wtype->damage[pos];
xmlFree(propValue);
@ -1043,7 +1043,7 @@ static int parse_resources(xmlDocPtr doc)
else if (strcmp((const char *)propValue, "material") == 0) {
int g, num, den = 100;
double fval = xml_fvalue(node, "value", 0);
// TODO: extract into a function for reading fractions?
/* TODO: extract into a function for reading fractions? */
num = (int)(fval * den + 0.5);
g = gcd(num, den);
num /= g;
@ -1595,7 +1595,6 @@ static void parse_ai(race * rc, xmlNodePtr node)
xmlFree(propValue);
}
rc->splitsize = xml_ivalue(node, "splitsize", 0);
rc->aggression = (float)xml_fvalue(node, "aggression", 0.04);
if (xml_bvalue(node, "killpeasants", false))
rc->flags |= RCF_KILLPEASANTS;
if (xml_bvalue(node, "moverandom", false))
@ -1636,8 +1635,8 @@ static int parse_races(xmlDocPtr doc)
xmlFree(propValue);
rc->magres = xml_ivalue(node, "magres", rc->magres);
rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); // TODO: store as int in XML
rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); // TODO: store as int in XML
rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); /* TODO: store as int in XML */
rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); /* TODO: store as int in XML */
rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura);
rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost);
rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance);
@ -1723,7 +1722,7 @@ static int parse_races(xmlDocPtr doc)
rc->ec_flags |= ECF_REC_UNLIMITED;
if (xml_bvalue(node, "equipment", false))
rc->battle_flags |= BF_EQUIPMENT; // TODO: invert this flag, so rc_get_or_create gets simpler
rc->battle_flags |= BF_EQUIPMENT; /* TODO: invert this flag, so rc_get_or_create gets simpler */
if (xml_bvalue(node, "noblock", false))
rc->battle_flags |= BF_NOBLOCK;
if (xml_bvalue(node, "invinciblenonmagic", false))

View file

@ -13,7 +13,7 @@
const char * keyword(keyword_t kwd)
{
static char result[32]; // FIXME: static return value
static char result[32]; /* FIXME: static return value */
if (kwd==NOKEYWORD) {
return NULL;
}

View file

@ -84,7 +84,6 @@ extern "C"
bool keyword_disabled(keyword_t kwd);
void enable_keyword(keyword_t kwd, bool enabled);
const char *keyword(keyword_t kwd);
// #define keyword(kwd) mkname("keyword", keywords[kwd])
#ifdef __cplusplus
#endif

View file

@ -736,8 +736,8 @@ growing_herbs(region * r, const int current_season, const int last_weeks_season)
void immigration(void)
{
region *r;
log_info(" - Einwanderung...");
int repopulate = config_get_int("rules.economy.repopulate_maximum", 90);
log_info(" - Einwanderung...");
for (r = regions; r; r = r->next) {
if (r->land && r->land->newpeasants) {
int rp = rpeasants(r) + r->land->newpeasants;
@ -2124,10 +2124,11 @@ int mail_cmd(unit * u, struct order *ord)
int banner_cmd(unit * u, struct order *ord)
{
init_order(ord);
const char * s = getstrtoken();
const char * s;
free(u->faction->banner);
init_order(ord);
s = getstrtoken();
u->faction->banner = s ? strdup(s) : 0;
add_message(&u->faction->msgs, msg_message("changebanner", "value",
u->faction->banner));
@ -2414,12 +2415,12 @@ static void reshow_other(unit * u, struct order *ord, const char *s) {
rc = findrace(s, u->faction->locale);
if (itype) {
// if this is a potion, we need the right alchemy skill
/* if this is a potion, we need the right alchemy skill */
int i = i_get(u->items, itype);
err = 36; // we do not have this item?
err = 36; /* we do not have this item? */
if (i <= 0) {
// we don't have the item, but it may be a potion that we know
/* we don't have the item, but it may be a potion that we know */
const potion_type *ptype = resource2potion(item2resource(itype));
if (ptype) {
if (2 * ptype->level > effskill(u, SK_ALCHEMY, 0)) {
@ -2724,13 +2725,13 @@ void sinkships(struct region * r)
if (!sh->type->construction || sh->size >= sh->type->construction->maxsize) {
if (fval(r->terrain, SEA_REGION)) {
if (!enoughsailors(sh, crew_skill(sh))) {
// ship is at sea, but not enough people to control it
/* ship is at sea, but not enough people to control it */
double dmg = config_get_flt("rules.ship.damage.nocrewocean", 0.3);
damage_ship(sh, dmg);
}
}
else if (!ship_owner(sh)) {
// any ship lying around without an owner slowly rots
/* any ship lying around without an owner slowly rots */
double dmg = config_get_flt("rules.ship.damage.nocrew", 0.05);
damage_ship(sh, dmg);
}
@ -2971,7 +2972,7 @@ static void ageing(void)
a_age(&u->attribs, u);
if (u == *up)
handle_event(u->attribs, "timer", u);
if (u == *up) //-V581
if (u == *up) /*-V581 */
up = &(*up)->next;
}
@ -2981,7 +2982,7 @@ static void ageing(void)
a_age(&s->attribs, s);
if (s == *sp)
handle_event(s->attribs, "timer", s);
if (s == *sp) //-V581
if (s == *sp) /*-V581 */
sp = &(*sp)->next;
}
@ -3109,7 +3110,7 @@ void new_units(void)
}
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
if (name != NULL)
free(name); // TODO: use a buffer on the stack instead?
free(name); /* TODO: use a buffer on the stack instead? */
fset(u2, UFL_ISNEW);
a_add(&u2->attribs, a_new(&at_alias))->data.i = alias;
@ -3158,10 +3159,10 @@ void update_long_order(unit * u)
free_orders(&u->old_orders);
}
// hungry units do not get long orders:
/* hungry units do not get long orders: */
if (hunger) {
if (u->old_orders) {
// keep looking for repeated orders that might clear the old_orders
/* keep looking for repeated orders that might clear the old_orders */
continue;
}
break;
@ -3169,8 +3170,8 @@ void update_long_order(unit * u)
if (is_long(kwd)) {
if (thiskwd == NOKEYWORD) {
// we have found the (first) long order
// some long orders can have multiple instances:
/* we have found the (first) long order
* some long orders can have multiple instances: */
switch (kwd) {
/* Wenn gehandelt wird, darf kein langer Befehl ausgeführt
* werden. Da Handel erst nach anderen langen Befehlen kommt,
@ -3179,9 +3180,9 @@ void update_long_order(unit * u)
case K_BUY:
case K_SELL:
case K_CAST:
// non-exclusive orders can be used with others. BUY can be paired with SELL,
// CAST with other CAST orders. compatibility is checked once the second
// long order is analyzed (below).
/* non-exclusive orders can be used with others. BUY can be paired with SELL,
* CAST with other CAST orders. compatibility is checked once the second
* long order is analyzed (below). */
exclusive = false;
break;
@ -3192,8 +3193,8 @@ void update_long_order(unit * u)
thiskwd = kwd;
}
else {
// we have found a second long order. this is okay for some, but not all commands.
// u->thisorder is already set, and should not have to be updated.
/* we have found a second long order. this is okay for some, but not all commands.
* u->thisorder is already set, and should not have to be updated. */
switch (kwd) {
case K_CAST:
if (thiskwd != K_CAST) {
@ -3214,9 +3215,8 @@ void update_long_order(unit * u)
}
break;
default:
// TODO: decide https://bugs.eressea.de/view.php?id=2080#c6011
if (kwd > thiskwd) {
// swap out thisorder for the new one
/* swap out thisorder for the new one */
cmistake(u, u->thisorder, 52, MSG_EVENT);
set_order(&u->thisorder, copy_order(ord));
}
@ -3229,11 +3229,11 @@ void update_long_order(unit * u)
}
}
if (hunger) {
// Hungernde Einheiten führen NUR den default-Befehl aus
/* Hungernde Einheiten führen NUR den default-Befehl aus */
set_order(&u->thisorder, default_order(u->faction->locale));
}
else if (!exclusive) {
// Wenn die Einheit handelt oder zaubert, muss der Default-Befehl gelöscht werden.
/* Wenn die Einheit handelt oder zaubert, muss der Default-Befehl gelöscht werden. */
set_order(&u->thisorder, NULL);
}
}
@ -3377,7 +3377,7 @@ void defaultorders(void)
free_order(ord);
if (!neworders) {
/* lange Befehle aus orders und old_orders löschen zu gunsten des neuen */
// TODO: why only is_exclusive, not is_long? what about CAST, BUY, SELL?
/* TODO: why only is_exclusive, not is_long? what about CAST, BUY, SELL? */
remove_exclusive(&u->orders);
remove_exclusive(&u->old_orders);
neworders = true;
@ -3522,7 +3522,7 @@ int use_cmd(unit * u, struct order *ord)
cmistake(u, ord, 50, MSG_PRODUCE);
break;
default:
// no error
/* no error */
break;
}
return err;
@ -3534,12 +3534,13 @@ int pay_cmd(unit * u, struct order *ord)
cmistake(u, ord, 6, MSG_EVENT);
}
else {
building *b = NULL;
param_t p;
int id;
init_order(ord);
p = getparam(u->faction->locale);
id = getid();
building *b = NULL;
if (p == P_NOT) {
unit *owner = building_owner(u->building);
/* If the unit is not the owner of the building: error */

View file

@ -758,8 +758,9 @@ static void test_peasant_luck_effect(CuTest *tc) {
static void test_luck_message(CuTest *tc) {
region* r;
attrib *a;
test_cleanup();
test_setup();
r = test_create_region(0, 0, NULL);
rsetpeasants(r, 1);
@ -767,7 +768,7 @@ static void test_luck_message(CuTest *tc) {
CuAssertPtrEquals_Msg(tc, "unexpected message", (void *)NULL, r->msgs);
attrib *a = (attrib *)a_find(r->attribs, &at_peasantluck);
a = (attrib *)a_find(r->attribs, &at_peasantluck);
if (!a)
a = a_add(&r->attribs, a_new(&at_peasantluck));
a->data.i += 10;
@ -782,7 +783,7 @@ static void test_luck_message(CuTest *tc) {
static unit * setup_name_cmd(void) {
faction *f;
test_cleanup();
test_setup();
f = test_create_faction(0);
return test_create_unit(f, test_create_region(0, 0, 0));
}
@ -886,7 +887,7 @@ static void test_name_ship(CuTest *tc) {
}
static void test_long_order_normal(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
order *ord;
@ -906,7 +907,7 @@ static void test_long_order_normal(CuTest *tc) {
}
static void test_long_order_none(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -918,7 +919,7 @@ static void test_long_order_none(CuTest *tc) {
}
static void test_long_order_cast(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -932,7 +933,7 @@ static void test_long_order_cast(CuTest *tc) {
}
static void test_long_order_buy_sell(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -947,7 +948,7 @@ static void test_long_order_buy_sell(CuTest *tc) {
}
static void test_long_order_multi_long(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -961,7 +962,7 @@ static void test_long_order_multi_long(CuTest *tc) {
}
static void test_long_order_multi_buy(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -975,7 +976,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
}
static void test_long_order_multi_sell(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -990,7 +991,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
}
static void test_long_order_buy_cast(CuTest *tc) {
// TODO: write more tests
/* TODO: write more tests */
unit *u;
test_cleanup();
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -1473,7 +1474,7 @@ static void test_demon_hunger(CuTest * tc)
}
static void test_armedmen(CuTest *tc) {
// TODO: test RCF_NOWEAPONS and SK_WEAPONLESS
/* TODO: test RCF_NOWEAPONS and SK_WEAPONLESS */
unit *u;
item_type *it_sword;
weapon_type *wtype;

View file

@ -173,7 +173,7 @@ static void a_initicastle(struct attrib *a)
a->data.v = calloc(sizeof(icastle_data), 1);
}
static void a_finalizeicastle(struct attrib *a) //-V524
static void a_finalizeicastle(struct attrib *a) /*-V524 */
{
free(a->data.v);
}
@ -475,14 +475,14 @@ void pick_random_spells(faction * f, int level, spellbook * book, int num_spells
spellno = rng_int() % maxspell;
sbe = commonspells[spellno];
if (sbe->level > f->max_spelllevel) {
// not going to pick it in this round, move it to the end for later
/* not going to pick it in this round, move it to the end for later */
commonspells[spellno] = commonspells[--maxspell];
commonspells[maxspell] = sbe;
sbe = 0;
}
else {
if (f->spellbook && spellbook_get(f->spellbook, sbe->sp)) {
// already have this spell, remove it from the list of candidates
/* already have this spell, remove it from the list of candidates */
commonspells[spellno] = commonspells[--numspells];
if (maxspell > numspells) {
maxspell = numspells;
@ -2945,7 +2945,7 @@ const char *spell_info(const spell * sp, const struct locale *lang)
return LOC(lang, mkname("spellinfo", sp->sname));
}
// TODO: should take the name, not the spell (spellref optimizations)
/* TODO: should take the name, not the spell (spellref optimizations) */
const char *spell_name(const spell * sp, const struct locale *lang)
{
return LOC(lang, mkname("spell", sp->sname));
@ -2987,7 +2987,7 @@ spell *unit_getspell(struct unit *u, const char *name, const struct locale * lan
if (sb) {
select_spellbook(&tokens, sb, lang);
}
#if 0 // TODO: some familiars can cast spells from the mage's spellbook?
#if 0 /* TODO: some familiars can cast spells from the mage's spellbook? */
u = get_familiar_mage(u);
if (u) {
sb = unit_get_spellbook(u);

View file

@ -59,7 +59,7 @@ extern "C" {
sppobj_t typ;
int flag;
union {
struct region *r; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
struct region *r;
struct unit *u;
struct building *b;
struct ship *sh;

View file

@ -443,7 +443,7 @@ static void test_max_spellpoints(CuTest *tc) {
CuAssertIntEquals(tc, 3, max_spellpoints(u->region, u));
set_level(u, SK_MAGIC, 2);
CuAssertIntEquals(tc, 9, max_spellpoints(u->region, u));
// permanent aura loss:
/* permanent aura loss: */
CuAssertIntEquals(tc, 7, change_maxspellpoints(u, -2));
CuAssertIntEquals(tc, 7, max_spellpoints(u->region, u));
test_cleanup();

View file

@ -223,11 +223,11 @@ static int parse_args(int argc, char **argv, int *exitcode)
}
}
// open logfile on disk:
/* open logfile on disk: */
log_flags = verbosity_to_flags(log_flags);
log_open(logfile, log_flags);
// also log to stderr:
/* also log to stderr: */
log_stderr = verbosity_to_flags(verbosity);
if (log_stderr) {
log_to_file(log_stderr | LOG_FLUSH | LOG_BRIEF, stderr);

View file

@ -216,7 +216,7 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted)
/* falls genug geld in der region ist, treiben wir steuern ein. */
if (rmoney(r) >= wanted) {
/* 5% chance, dass der drache aus einer laune raus attackiert */
if (!attacks || chance(1.0 - u_race(udragon)->aggression)) {
if (!attacks) {
/* Drachen haben in E3 und E4 keine Einnahmen. Neuer Befehl Pluendern erstmal nur fuer Monster?*/
return create_order(K_LOOT, default_locale, NULL);
}
@ -673,7 +673,7 @@ static order *plan_dragon(unit * u)
}
if (tr != NULL) {
assert(long_order == NULL);
// TODO: per-race planning functions?
/* TODO: per-race planning functions? */
if (rc == rc_wyrm) {
long_order = make_movement_order(u, tr, 1, allowed_dragon);
}

View file

@ -90,7 +90,7 @@ static void test_monsters_attack_ocean(CuTest * tc)
unit *u, *m;
create_monsters(&f, &f2, &u, &m);
r = findregion(-1, 0); // ocean
r = findregion(-1, 0); /* ocean */
u = test_create_unit(u->faction, r);
unit_setid(u, 2);
m = test_create_unit(m->faction, r);
@ -125,7 +125,7 @@ static void test_seaserpent_piracy(CuTest * tc)
race *rc;
create_monsters(&f, &f2, &u, &m);
r = findregion(-1, 0); // ocean
r = findregion(-1, 0); /* ocean */
u = test_create_unit(u->faction, r);
unit_setid(u, 2);
m = test_create_unit(m->faction, r);
@ -198,7 +198,7 @@ static void test_dragon_moves(CuTest * tc)
create_monsters(&f, &f2, &u, &m);
rsetmoney(findregion(1, 0), 1000);
r = findregion(0, 0); // plain
r = findregion(0, 0); /* plain */
rsetpeasants(r, 0);
rsetmoney(r, 0);

View file

@ -509,10 +509,10 @@ static double overload(const region * r, ship * sh)
else {
int n = 0, p = 0;
int mcabins = sh->type->cabins;
double ovl;
getshipweight(sh, &n, &p);
double ovl = n / (double)sh->type->cargo;
ovl = n / (double)sh->type->cargo;
if (mcabins)
ovl = MAX(ovl, p / (double)mcabins);
return ovl;
@ -801,7 +801,7 @@ region * drift_target(ship *sh) {
if (rn != NULL && check_ship_allowed(sh, rn) >= 0) {
rnext = rn;
if (!fval(rnext->terrain, SEA_REGION)) {
// prefer drifting towards non-ocean regions
/* prefer drifting towards non-ocean regions */
break;
}
}
@ -952,8 +952,8 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
if ((u->faction == reisender->faction) || (ucontact(u, reisender)) || (alliedunit(u, reisender->faction, HELP_GUARD)))
guard_count = guard_count - u->number;
else if (sk >= stealth) {
guard_count += u->number;
double prob_u = (sk - stealth) * skill_prob;
guard_count += u->number;
/* amulet counts at most once */
prob_u += MIN(1, MIN(u->number, i_get(u->items, ramulet->itype))) * amulet_prob;
if (u->building && (u->building->type == castle_bt) && u == building_owner(u->building))
@ -1406,7 +1406,7 @@ static int movement_speed(unit * u)
return BP_DRAGON;
}
switch (old_race(u_race(u))) {
case RC_BIRTHDAYDRAGON: // FIXME: catdragon has RCF_DRAGON, so this cannot happen
case RC_BIRTHDAYDRAGON: /* FIXME: catdragon has RCF_DRAGON, so this cannot happen */
case RC_SONGDRAGON:
mp = BP_DRAGON;
break;
@ -1473,9 +1473,9 @@ static arg_regions *var_copy_regions(const region_list * begin, int size)
if (size > 0) {
int i = 0;
arg_regions *dst;
assert(size > 0);
arg_regions *dst =
(arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size);
dst = (arg_regions *)malloc(sizeof(arg_regions) + sizeof(region *) * (size_t)size);
assert_alloc(dst);
dst->nregions = size;
dst->regions = (region **)(dst + 1);
@ -1840,7 +1840,7 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting)
}
}
}
} // storms_enabled
} /* storms_enabled */
if (!fval(tthis, SEA_REGION)) {
if (!fval(tnext, SEA_REGION)) {
/* check that you're not traveling from one land region to another. */

View file

@ -434,8 +434,9 @@ static void test_follow_ship_msg(CuTest * tc) {
order *ord;
traveldir *td = NULL;
attrib *a;
void *p;
test_cleanup();
test_setup();
test_create_world();
f = test_create_faction(0);
r = findregion(0, 0);
@ -467,7 +468,7 @@ static void test_follow_ship_msg(CuTest * tc) {
follow_ship(u, ord);
CuAssertPtrNotNull(tc, msg = test_find_messagetype(u->faction->msgs, "error18"));
void *p = msg->parameters[2].v;
p = msg->parameters[2].v;
CuAssertPtrNotNull(tc, p);
CuAssertIntEquals(tc, K_FOLLOW, getkeyword((order *)p));

View file

@ -280,7 +280,7 @@ static void dragon_name(unit * u)
if (u->number > 1) {
const char *no_article = strchr((const char *)str, ' ');
assert(no_article);
// TODO: localization
/* TODO: localization */
sprintf(name, "Die %sn von %s", no_article + 1, rname(u->region,
default_locale));
}

View file

@ -149,8 +149,8 @@ void piracy_cmd(unit * u)
region *rc = rconnect(r, dir);
aff[dir].value = 0;
aff[dir].target = 0;
// TODO this could still result in an illegal movement order (through a wall or whatever)
// which will be prevented by move_cmd below
/* TODO this could still result in an illegal movement order (through a wall or whatever)
* which will be prevented by move_cmd below */
if (rc &&
((sh && !fval(rc->terrain, FORBIDDEN_REGION) && can_takeoff(sh, r, rc))
|| (canswim(u) && fval(rc->terrain, SWIM_INTO) && fval(rc->terrain, SEA_REGION)))) {
@ -161,7 +161,8 @@ void piracy_cmd(unit * u)
faction *f = visible_faction(cap->faction, cap);
if (alliedunit(u, f, HELP_FIGHT))
continue;
if (!il || intlist_find(il, cap->faction->no)) { // TODO: shouldn't this be f->no?
if (!il || intlist_find(il, cap->faction->no)) {
/* TODO: shouldn't this be f->no? */
++aff[dir].value;
if (rng_int() % aff[dir].value == 0) {
aff[dir].target = f;
@ -202,8 +203,8 @@ void piracy_cmd(unit * u)
"ship unit region dir", sh, u, r, target_dir));
/* Befehl konstruieren */
// TODO: why change u->thisorder?
// FIXME: when u->thisorder == ord, set_order calls free, destroys both.
/* TODO: why change u->thisorder? */
/* FIXME: when u->thisorder == ord, set_order calls free, destroys both. */
ord = create_order(K_MOVE, u->faction->locale, "%s", LOC(u->faction->locale, directions[target_dir]));
/* Bewegung ausführen */

View file

@ -97,7 +97,7 @@ static void test_piracy_cmd(CuTest * tc) {
CuAssertTrue(tc, u->region != r);
CuAssertPtrEquals(tc, u2->region, u->region);
CuAssertPtrEquals(tc, u2->region, u->ship->region);
CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); // FIXME: this is testing implementation, not interface
CuAssertPtrNotNullMsg(tc, "successful PIRACY sets attribute", r->attribs); /* FIXME: this is testing implementation, not interface */
CuAssertPtrNotNullMsg(tc, "successful PIRACY message", test_find_messagetype(f->msgs, "piratesawvictim"));
CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(f->msgs, "shipsail"));
@ -183,14 +183,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
t_plain = get_or_create_terrain("plain");
stype = test_create_shiptype("boat");
// create a target:
/* create a target: */
r = test_create_region(0, 0, t_plain);
f = test_create_faction(0);
u = test_create_unit(f, r);
u->ship = test_create_ship(r, stype);
target = f->no;
// create a pirate:
/* create a pirate: */
r = test_create_region(1, 0, t_plain);
f = test_create_faction(0);
u = test_create_unit(f, r);

View file

@ -15,6 +15,11 @@
#pragma warning(disable: 4456) // declaration hides previous
#pragma warning(disable: 4457) // declaration hides function parameter
#pragma warning(disable: 4459) // declaration hides global
#else /* assume gcc */
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# define va_copy(a,b) __va_copy(a,b)
#endif
#endif
#define _POSIX_C_SOURCE 200809L

View file

@ -8,7 +8,7 @@ extern "C" {
#endif
int add_raceprefix(const char *);
char **race_prefixes; // zero-terminated array of valid prefixes
char **race_prefixes; /* zero-terminated array of valid prefixes */
void free_prefixes(void);
#ifdef __cplusplus

View file

@ -100,7 +100,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdlib.h>
#if defined(_MSC_VER) && _MSC_VER >= 1900
# pragma warning(disable: 4774) // TODO: remove this
# pragma warning(disable: 4774) /* TODO: remove this */
#endif
extern int *storms;
@ -120,7 +120,7 @@ static void check_errno(const char * file, int line) {
static char *gamedate_season(const struct locale *lang)
{
static char buf[256]; // FIXME: static return value
static char buf[256]; /* FIXME: static return value */
gamedate gd;
get_gamedate(turn, &gd);
@ -1195,7 +1195,7 @@ static void describe(struct stream *out, const region * r, faction * f)
bufp = buf;
size = sizeof(buf) - 1;
// this localization might not work for every language but is fine for de and en
/* this localization might not work for every language but is fine for de and en */
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_schemes_prefix"), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1237,7 +1237,7 @@ static void describe(struct stream *out, const region * r, faction * f)
for (d = 0; d != MAXDIRECTIONS; ++d) {
if (!e->exist[d])
continue;
// this localization might not work for every language but is fine for de and en
/* this localization might not work for every language but is fine for de and en */
if (first)
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_prefix"), size);
else if (e->lastd == d)
@ -1251,8 +1251,8 @@ static void describe(struct stream *out, const region * r, faction * f)
WARN_STATIC_BUFFER();
first = false;
}
// TODO name is localized? Works for roads anyway...
// TODO: creating messages during reporting makes them not show up in CR?
/* TODO name is localized? Works for roads anyway... */
/* TODO: creating messages during reporting makes them not show up in CR? */
msg = msg_message("nr_borderlist_postfix", "transparent object",
e->transparent, e->name);
bytes = (int)nr_render(msg, f->locale, bufp, size, f);
@ -1987,7 +1987,7 @@ static void cb_write_travelthru(region *r, unit *u, void *cbdata) {
}
}
if (len >= size || data->counter == data->maxtravel) {
// buffer is full
/* buffer is full */
*writep = 0;
paragraph(data->out, data->start, 0, 0, 0);
data->writep = data->start;
@ -2332,7 +2332,6 @@ report_plaintext(const char *filename, report_context * ctx,
/* Nachrichten an REGION in der Region */
if (r->seen.mode == seen_unit || r->seen.mode == seen_travel) {
// TODO: Bug 2073
message_list *mlist = r_getmessages(r, f);
if (mlist) {
struct mlist **split = merge_messages(mlist, r->msgs);

View file

@ -77,7 +77,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "move.h"
#if defined(_MSC_VER) && _MSC_VER >= 1900
# pragma warning(disable: 4774) // TODO: remove this
# pragma warning(disable: 4774) /* TODO: remove this */
#endif
#define SCALEWEIGHT 100 /* Faktor, um den die Anzeige von Gewichten skaliert wird */
@ -680,7 +680,7 @@ size_t size)
if (wrptr(&bufp, &size, result) != 0) {
WARN_STATIC_BUFFER();
}
// TODO: no need to deref the spellref here (spref->name is good)
/* TODO: no need to deref the spellref here (spref->name is good) */
bufp = STRLCPY(bufp, spell_name(sbe->sp, f->locale), size);
}
}
@ -851,7 +851,7 @@ const struct unit * u, struct skill * sv, int *dh, int days)
void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned int width, char mark)
{
bool firstline;
static char buf[REPORTWIDTH + 1]; // FIXME: static buffer, artificial limit
static char buf[REPORTWIDTH + 1]; /* FIXME: static buffer, artificial limit */
size_t len = strlen(s);
assert(width <= REPORTWIDTH);
@ -882,7 +882,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
}
memcpy(buf + indent, s, cut - s);
buf[indent + (cut - s)] = 0;
addstrlist(SP, buf); // TODO: too much string copying, cut out this function
addstrlist(SP, buf); /* TODO: too much string copying, cut out this function */
while (*cut == ' ') {
++cut;
}
@ -1017,7 +1017,7 @@ static void cb_add_address(region *r, unit *ut, void *cbdata) {
}
static void add_travelthru_addresses(region *r, faction *f, selist **flist, int stealthmod) {
// for each traveling unit: add the faction of any unit is can see
/* for each traveling unit: add the faction of any unit is can see */
address_data cbdata = { 0 };
cbdata.f = f;
cbdata.flist = flist;
@ -1338,7 +1338,7 @@ void prepare_report(report_context *ctx, faction *f)
if (f->age<=2) {
if ((f->flags&FFL_PWMSG)==0) {
// TODO: this assumes unencrypted passwords
/* TODO: this assumes unencrypted passwords */
f->flags |= FFL_PWMSG;
ADDMSG(&f->msgs, msg_message("changepasswd", "value", f->_password));
}
@ -1348,7 +1348,7 @@ void prepare_report(report_context *ctx, faction *f)
ctx->report_time = time(NULL);
ctx->addresses = NULL;
ctx->userdata = NULL;
// [first,last) interval of regions with a unit in it:
/* [first,last) interval of regions with a unit in it: */
ctx->first = firstregion(f);
ctx->last = lastregion(f);
@ -1388,9 +1388,9 @@ void prepare_report(report_context *ctx, faction *f)
travelthru_map(r, cb_add_seen, f);
}
}
// [fast,last) interval of seen regions (with lighthouses and travel)
// TODO: what about neighbours? when are they included? do we need
// them outside of the CR?
/* [fast,last) interval of seen regions (with lighthouses and travel)
* TODO: what about neighbours? when are they included? do we need
* them outside of the CR? */
ctx->first = firstregion(f);
ctx->last = lastregion(f);
}
@ -1582,7 +1582,7 @@ static void var_free_resources(variant x)
x.v = 0;
}
static void var_free_regions(variant x) //-V524
static void var_free_regions(variant x) /*-V524 */
{
free(x.v);
}
@ -1630,7 +1630,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size)
static char *f_regionid_s(const region * r, const faction * f)
{
static char buf[NAMESIZE + 20]; // FIXME: static return value
static char buf[NAMESIZE + 20]; /* FIXME: static return value */
f_regionid(r, f, buf, sizeof(buf));
return buf;
@ -1689,11 +1689,10 @@ static void eval_spell(struct opstack **stack, const void *userdata)
const struct spell *sp = (const struct spell *)opop(stack).v;
const char *c =
sp ? spell_name(sp, f->locale) : LOC(f->locale, "an_unknown_spell");
assert(c || !"spell without description!");
size_t len = strlen(c);
variant var;
var.v = strcpy(balloc(len + 1), c);
assert(c || !"spell without description!");
var.v = strcpy(balloc(strlen(c) + 1), c);
opush(stack, var);
}
@ -1703,11 +1702,10 @@ static void eval_curse(struct opstack **stack, const void *userdata)
const struct curse_type *sp = (const struct curse_type *)opop(stack).v;
const char *c =
sp ? curse_name(sp, f->locale) : LOC(f->locale, "an_unknown_curse");
assert(c || !"spell effect without description!");
size_t len = strlen(c);
variant var;
var.v = strcpy(balloc(len + 1), c);
assert(c || !"spell effect without description!");
var.v = strcpy(balloc(strlen(c) + 1), c);
opush(stack, var);
}
@ -1947,7 +1945,7 @@ static void eval_regions(struct opstack **stack, const void *userdata)
const char *get_mailcmd(const struct locale *loc)
{
static char result[64]; // FIXME: static return buffer
static char result[64]; /* FIXME: static return buffer */
snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd"));
return result;
}
@ -2057,12 +2055,12 @@ int stream_printf(struct stream * out, const char *format, ...) {
int result;
char buffer[4096];
size_t bytes = sizeof(buffer);
// TODO: should be in storage/stream.c (doesn't exist yet)
/* TODO: should be in storage/stream.c (doesn't exist yet) */
va_start(args, format);
result = vsnprintf(buffer, bytes, format, args);
if (result >= 0 && (size_t)result < bytes) {
bytes = (size_t)result;
// TODO: else = buffer too small
/* TODO: else = buffer too small */
}
out->api->write(out->handle, buffer, bytes);
va_end(args);

View file

@ -4194,7 +4194,7 @@ static int sp_seduce(castorder * co)
{
const resource_type *rsilver = get_resourcetype(R_SILVER);
unit *target;
item **itmp, *items = 0;;
item **itmp, *items = 0;
unit *mage = co->magician.u;
spellparameter *pa = co->par;
int cast_level = co->level;

View file

@ -25,8 +25,9 @@ static void test_good_dreams(CuTest *tc) {
unit *u1, *u2;
int level;
castorder co;
curse *curse;
test_cleanup();
test_setup();
test_create_world();
r = findregion(0, 0);
f1 = test_create_faction(0);
@ -38,7 +39,7 @@ static void test_good_dreams(CuTest *tc) {
level = sp_gooddreams(&co);
CuAssertIntEquals(tc, 10, level);
curse *curse = get_curse(r->attribs, ct_find("gbdream"));
curse = get_curse(r->attribs, ct_find("gbdream"));
CuAssertTrue(tc, curse && curse->duration > 1);
CuAssertTrue(tc, curse->effect == 1);
@ -81,8 +82,9 @@ static void test_bad_dreams(CuTest *tc) {
unit *u1, *u2;
int level;
castorder co;
curse *curse;
test_cleanup();
test_setup();
test_create_world();
r = findregion(0, 0);
f1 = test_create_faction(0);
@ -94,7 +96,7 @@ static void test_bad_dreams(CuTest *tc) {
level = sp_baddreams(&co);
CuAssertIntEquals(tc, 10, level);
curse *curse = get_curse(r->attribs, ct_find("gbdream"));
curse = get_curse(r->attribs, ct_find("gbdream"));
CuAssertTrue(tc, curse && curse->duration > 1);
CuAssertTrue(tc, curse->effect == -1);

View file

@ -47,8 +47,9 @@
#define EFFECT_HEALING_SPELL 5
// Some spells with a fixed, known ID (in XML).
// TODO: this method of identifying spells is error-prone, do not use it for new spells.
/* Some spells with a fixed, known ID (in XML).
* TODO: this method of identifying spells is error-prone,
* do not use it for new spells. */
enum {
SPL_FIREBALL = 4,
SPL_HAGEL = 5,

View file

@ -303,9 +303,9 @@ int setstealth_cmd(unit * u, struct order *ord)
}
if (rule_stealth_other()) {
if (get_keyword(s, u->faction->locale) == K_NUMBER) {
s = gettoken(token, sizeof(token));
int nr = -1;
s = gettoken(token, sizeof(token));
if (s) {
nr = atoi36(s);
}

View file

@ -60,6 +60,7 @@ static void set_factionstealth(unit *u, faction *f) {
static void test_all_spy_message(CuTest *tc) {
spy_fixture fix;
item_type *itype;
setup_spy(&fix);
@ -69,7 +70,6 @@ static void test_all_spy_message(CuTest *tc) {
create_mage(fix.victim, M_DRAIG);
set_factionstealth(fix.victim, fix.spy->faction);
item_type *itype;
itype = it_get_or_create(rt_get_or_create("sword"));
new_weapontype(itype, 0, 0.0, NULL, 0, 0, 0, SK_MELEE, 2);
i_change(&fix.victim->items, itype, 1);

View file

@ -303,7 +303,7 @@ static void test_demon_skillchanges(CuTest *tc) {
CuAssertPtrNotNull(tc, u);
set_level(u, SK_CROSSBOW, 1);
demon_skillchange(u);
// TODO: sensing here
/* TODO: sensing here */
test_cleanup();
}

View file

@ -52,9 +52,12 @@ void RunTests(CuSuite * suite, const char *name) {
bool list = false;
#define ADD_SUITE(name) \
do { \
CuSuite *get_##name##_suite(void); \
if (list) printf("%s\n", #name); \
if (!list || argc>0) add_suite(get_##name##_suite, #name, argc, argv)
if (!list || argc>0) add_suite(get_##name##_suite, #name, argc, argv); \
} while (0)
int RunAllTests(int argc, char *argv[])
{

View file

@ -92,7 +92,6 @@ static int changefaction_read(trigger * t, gamedata *data)
return AT_READ_FAIL;
}
ur_add(var, &td->faction, resolve_faction);
// read_reference(&td->faction, store, read_faction_reference, resolve_faction);
return AT_READ_OK;
}

View file

@ -102,7 +102,6 @@ static int createunit_read(trigger * t, gamedata *data)
else {
result = AT_READ_FAIL;
}
// read_reference(&td->f, store, read_faction_reference, resolve_faction);
read_reference(&td->r, data, read_region_reference,
RESOLVE_REGION(data->version));

View file

@ -35,7 +35,7 @@ void test_upkeep_default(CuTest * tc)
config_set("rules.food.flags", "0");
i_change(&u1->items, i_silver, 20);
get_food(r);
// since u1 and u2 are not allied, u1 should not help u2 with upkeep
/* since u1 and u2 are not allied, u1 should not help u2 with upkeep */
CuAssertIntEquals(tc, 10, i_get(u1->items, i_silver));
CuAssertIntEquals(tc, 0, fval(u1, UFL_HUNGER));
CuAssertIntEquals(tc, UFL_HUNGER, fval(u2, UFL_HUNGER));
@ -63,7 +63,7 @@ void test_upkeep_hunger_damage(CuTest * tc)
config_set("rules.food.flags", "0");
u1->hp = 100;
get_food(r);
// since u1 and u2 are not allied, u1 should not help u2 with upkeep
/* since u1 and u2 are not allied, u1 should not help u2 with upkeep */
CuAssertTrue(tc, u1->hp < 100);
test_cleanup();
@ -152,7 +152,7 @@ void test_upkeep_free(CuTest * tc)
u = test_create_unit(test_create_faction(test_create_race("human")), r);
assert(r && u);
config_set("rules.food.flags", "4"); // FOOD_IS_FREE
config_set("rules.food.flags", "4"); /* FOOD_IS_FREE */
get_food(r);
CuAssertIntEquals(tc, 0, i_get(u->items, i_silver));
CuAssertIntEquals(tc, 0, fval(u, UFL_HUNGER));

View file

@ -153,7 +153,7 @@ static unsigned int __at_hashkey(const char *s)
while (i > 0) {
key = (s[--i] + key * 37);
}
return key & 0x7fffffff; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 0x7fffffff used: return key & 0x7fffffff;.
return key & 0x7fffffff;
}
void at_register(attrib_type * at)
@ -161,7 +161,7 @@ void at_register(attrib_type * at)
attrib_type *find;
if (at->read == NULL) {
log_warning("registering non-persistent attribute %s.\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type.
log_warning("registering non-persistent attribute %s.\n", at->name);
}
at->hashkey = __at_hashkey(at->name);
find = at_hash[at->hashkey % MAXATHASH];
@ -169,7 +169,7 @@ void at_register(attrib_type * at)
find = find->nexthash;
}
if (find && find == at) {
log_warning("attribute '%s' was registered more than once\n", at->name); //TODO: V111 http://www.viva64.com/en/V111 Call of function 'log_warning' with variable number of arguments. Second argument has memsize type.
log_warning("attribute '%s' was registered more than once\n", at->name);
return;
}
else {

View file

@ -32,14 +32,14 @@ extern "C" {
typedef struct attrib {
const struct attrib_type *type;
union {
afun f; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
void *v; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
afun f;
void *v;
int i;
float flt;
char c;
short s;
short sa[2];
char ca[4]; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 4 used: char ca[4];.
char ca[4];
} data;
/* internal data, do not modify: */
struct attrib *next; /* next attribute in the list */

View file

@ -13,7 +13,7 @@ int wrptr(char **ptr, size_t * size, int result)
{
size_t bytes = (size_t)result;
if (result < 0) {
// buffer was too small
/* buffer was too small */
if (*size > 0) {
**ptr = 0;
*size = 0;

View file

@ -32,7 +32,7 @@ static void test_strlcpy(CuTest * tc)
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); //-V666
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8)); /*-V666 */
CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]);

View file

@ -239,7 +239,7 @@ char *mkname_buf(const char *space, const char *name, char *buffer)
const char *mkname(const char *space, const char *name)
{
static char zBuffer[128]; // FIXME: static return value
static char zBuffer[128]; /* FIXME: static return value */
return mkname_buf(space, name, zBuffer);
}
@ -272,7 +272,7 @@ void add_translation(struct critbit_tree **cbp, const char *key, int i) {
if (str) {
size_t len = strlen(str);
if (!cb) {
// TODO: this will leak, because we do not know how to clean it up */
/* TODO: this will leak, because we do not know how to clean it up */
*cbp = cb = (struct critbit_tree *)calloc(1, sizeof(struct critbit_tree));
}
len = cb_new_kv(str, len, &i, sizeof(int), buffer);
@ -292,7 +292,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
assert(maxstrings > 0);
tokens = get_translations(lang, ut);
for (i = 0; i != maxstrings; ++i) {
// TODO: swap the name of s and key
/* TODO: swap the name of s and key */
const char * s = string_cb(i);
if (s) {
const char * key = locale_string(lang, s, false);
@ -349,7 +349,7 @@ void free_locales(void) {
for (i = UT_PARAMS; i != UT_RACES; ++i) {
struct critbit_tree ** cb = (struct critbit_tree **)get_translations(locales, i);
if (*cb) {
// TODO: this crashes?
/* TODO: this crashes? */
cb_clear(*cb);
free(*cb);
}
@ -373,5 +373,5 @@ void free_locales(void) {
free(locales);
locales = next;
}
memset(lstrs, 0, sizeof(lstrs)); // TODO: does this data need to be free'd?
memset(lstrs, 0, sizeof(lstrs)); /* TODO: does this data need to be free'd? */
}

View file

@ -137,7 +137,7 @@ static int check_dupe(const char *format, int level)
static char last_message[32]; /* STATIC_XCALL: used across calls */
static int dupes = 0; /* STATIC_XCALL: used across calls */
if (strncmp(last_message, format, sizeof(last_message)) == 0) {
// TODO: C6054: String 'last_message' might not be zero - terminated.
/* TODO: C6054: String 'last_message' might not be zero - terminated. */
++dupes;
return 1;
}
@ -197,18 +197,18 @@ static void log_write(int flags, const char *module, const char *format, va_list
int level = flags & LOG_LEVELS;
if (lg->flags & level) {
int dupe = 0;
va_list copy;
va_copy(copy, args);
if (lg->flags & LOG_BRIEF) {
dupe = check_dupe(format, level);
}
if (dupe == 0) {
va_list copy;
va_copy(copy, args);
lg->log(lg->data, level, NULL, format, copy);
}
va_end(copy);
}
}
}
}
@ -220,7 +220,7 @@ void log_fatal(const char *format, ...)
va_end(args);
}
void log_error(const char *format, ...) //-V524
void log_error(const char *format, ...) /*-V524 */
{
va_list args;
va_start(args, format);

View file

@ -49,11 +49,11 @@ static void test_parse_token_limit_utf8(CuTest *tc) {
tok = parse_token(&str, lbuf, sizeof(lbuf));
CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str);
CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); // just three letters fit, 6 bytes long
CuAssertStrEquals(tc, tok, "\xc3\xa4\xc3\xb6\xc3\xbc"); /* just three letters fit, 6 bytes long */
tok = parse_token(&str, lbuf, sizeof(lbuf));
CuAssertPtrEquals(tc, NULL, (void *)tok);
str = orig; // now with an extra byte in the front, maxing out lbuf exactly
str = orig; /* now with an extra byte in the front, maxing out lbuf exactly */
tok = parse_token(&str, lbuf, sizeof(lbuf));
CuAssertPtrEquals(tc, (void *)(orig + strlen(orig)), (void *)str);
CuAssertStrEquals(tc, tok, "a\xc3\xa4\xc3\xb6\xc3\xbc");

View file

@ -4,9 +4,9 @@
#define PASSWORD_PLAINTEXT 0
#define PASSWORD_DEFAULT PASSWORD_PLAINTEXT
#define VERIFY_OK 0 // password matches hash
#define VERIFY_FAIL 1 // password is wrong
#define VERIFY_UNKNOWN 2 // hashing algorithm not supported
#define VERIFY_OK 0
#define VERIFY_FAIL 1
#define VERIFY_UNKNOWN 2
int password_verify(const char *hash, const char *passwd);
const char * password_encode(const char *passwd, int algo);
bool password_is_implemented(int algo);

View file

@ -168,7 +168,7 @@ void addtoken(tnode ** root, const char *str, variant id)
next = next->nexthash;
if (!next) {
tref *ref;
tnode *node = mknode(); // TODO: what is the reason for this empty node to exist?
tnode *node = mknode(); /* TODO: what is the reason for this empty node to exist? */
if (ucs < 'a' || ucs > 'z') {
lcs = towlower((wint_t)ucs);

View file

@ -47,7 +47,7 @@ static void test_unicode_tolower(CuTest * tc)
static void test_unicode_utf8_to_other(CuTest *tc)
{
const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; // &Oslash;&Yuml;&#157;l
const unsigned char uchar_str[] = { 0xc3, 0x98, 0xc5, 0xb8, 0xc2, 0x9d, 'l', 0 }; /* &Oslash;&Yuml;&#157;l */
utf8_t *utf8_str = (utf8_t *)uchar_str;
unsigned char ch;
size_t sz;
@ -111,7 +111,7 @@ static void test_unicode_bug2262(CuTest *tc) {
CuAssertIntEquals(tc, 'u', ucs);
CuAssertIntEquals(tc, 0, unicode_utf8_trim(name));
name[0] = -4; // latin1: &uuml; should fail to decode
name[0] = -4; /* latin1: &uuml; should fail to decode */
CuAssertIntEquals(tc, EILSEQ, unicode_utf8_to_ucs4(&ucs, name, &sz));
CuAssertIntEquals(tc, EILSEQ, unicode_utf8_trim(name));
}

View file

@ -5,12 +5,12 @@ extern "C" {
#endif
typedef union variant {
void *v; //TODO: V117 http://www.viva64.com/en/V117 Memsize type is used in the union.
void *v;
int i;
char c;
short s;
short sa[2];
char ca[4]; //TODO: V112 http://www.viva64.com/en/V112 Dangerous magic number 4 used: char ca[4];.
char ca[4];
float f;
} variant;

View file

@ -291,10 +291,10 @@ void volcano_update(void)
r->terrain = t_volcano;
}
else if (r->uid == 1246051340 || outbreak_chance()) {
// HACK: a fixed E4-only region-uid in Code.
// FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst.
// da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch?
// das sollte bestimmt rn betreffen?
/* HACK: a fixed E4-only region-uid in Code.
* FIXME: In E4 gibt es eine Ebene #1246051340, die Smalland heisst.
* da das kein aktiver Vulkan ist, ist dieser Test da nicht idiotisch?
* das sollte bestimmt rn betreffen? */
region *rn;
rn = rrandneighbour(r);
volcano_outbreak(r, rn);