compiling with -pedantic on linux

This commit is contained in:
Enno 2011-03-08 08:42:31 +01:00
parent d940f29a6c
commit b95f663087
3 changed files with 119 additions and 111 deletions

View File

@ -7,7 +7,7 @@ if (${CMAKE_C_COMPILER} MATCHES ".*tcc")
endif(${CMAKE_C_COMPILER} MATCHES ".*tcc") endif(${CMAKE_C_COMPILER} MATCHES ".*tcc")
if (${CMAKE_C_COMPILER} MATCHES ".*gcc") if (${CMAKE_C_COMPILER} MATCHES ".*gcc")
set(CMAKE_C_FLAGS "-g -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts") set(CMAKE_C_FLAGS "-g -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
endif(${CMAKE_C_COMPILER} MATCHES ".*gcc") endif(${CMAKE_C_COMPILER} MATCHES ".*gcc")
if (WIN32) if (WIN32)

View File

@ -359,17 +359,17 @@ static order *monster_move(region * r, unit * u)
if (monster_is_waiting(u)) if (monster_is_waiting(u))
return NULL; return NULL;
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_FIREDRAGON: case RC_FIREDRAGON:
case RC_DRAGON: case RC_DRAGON:
case RC_WYRM: case RC_WYRM:
d = richest_neighbour(r, u->faction, 1); d = richest_neighbour(r, u->faction, 1);
break; break;
case RC_TREEMAN: case RC_TREEMAN:
d = treeman_neighbour(r); d = treeman_neighbour(r);
break; break;
default: default:
d = random_neighbour(r, u); d = random_neighbour(r, u);
break; break;
} }
/* falls kein geld gefunden wird, zufaellig verreisen, aber nicht in /* falls kein geld gefunden wird, zufaellig verreisen, aber nicht in
@ -379,8 +379,8 @@ static order *monster_move(region * r, unit * u)
return NULL; return NULL;
reduce_weight(u); reduce_weight(u);
return create_order(K_MOVE, u->faction->locale, "%s", LOC(u->faction->locale, return create_order(K_MOVE, u->faction->locale, "%s",
directions[d])); LOC(u->faction->locale, directions[d]));
} }
static int dragon_affinity_value(region * r, unit * u) static int dragon_affinity_value(region * r, unit * u)
@ -461,8 +461,8 @@ static order *make_movement_order(unit * u, const region * target, int moves,
return NULL; return NULL;
bytes = bytes =
(int)strlcpy(bufp, (const char *)LOC(u->faction->locale, keywords[K_MOVE]), (int)strlcpy(bufp,
size); (const char *)LOC(u->faction->locale, keywords[K_MOVE]), size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -476,8 +476,8 @@ static order *make_movement_order(unit * u, const region * target, int moves,
--size; --size;
} }
bytes = bytes =
(int)strlcpy(bufp, (const char *)LOC(u->faction->locale, directions[dir]), (int)strlcpy(bufp,
size); (const char *)LOC(u->faction->locale, directions[dir]), size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
@ -501,11 +501,11 @@ static order *monster_seeks_target(region * r, unit * u)
*/ */
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_ALP: case RC_ALP:
target = alp_target(u); target = alp_target(u);
break; break;
default: default:
assert(!"Seeker-Monster gibt kein Ziel an"); assert(!"Seeker-Monster gibt kein Ziel an");
} }
/* TODO: prüfen, ob target überhaupt noch existiert... */ /* TODO: prüfen, ob target überhaupt noch existiert... */
@ -540,8 +540,8 @@ static order *monster_seeks_target(region * r, unit * u)
} }
assert(d != NODIRECTION); assert(d != NODIRECTION);
return create_order(K_MOVE, u->faction->locale, "%s", LOC(u->faction->locale, return create_order(K_MOVE, u->faction->locale, "%s",
directions[d])); LOC(u->faction->locale, directions[d]));
} }
#endif #endif
@ -563,16 +563,16 @@ static void monster_attacks(unit * u)
static const char *random_growl(void) static const char *random_growl(void)
{ {
switch (rng_int() % 5) { switch (rng_int() % 5) {
case 0: case 0:
return "Groammm"; return "Groammm";
case 1: case 1:
return "Roaaarrrr"; return "Roaaarrrr";
case 2: case 2:
return "Chhhhhhhhhh"; return "Chhhhhhhhhh";
case 3: case 3:
return "Tschrrrkk"; return "Tschrrrkk";
case 4: case 4:
return "Schhhh"; return "Schhhh";
} }
return ""; return "";
} }
@ -702,23 +702,28 @@ static order *plan_dragon(unit * u)
if (tr != NULL) { if (tr != NULL) {
assert(long_order == NULL); assert(long_order == NULL);
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_FIREDRAGON: case RC_FIREDRAGON:
long_order = make_movement_order(u, tr, 4, allowed_dragon); long_order = make_movement_order(u, tr, 4, allowed_dragon);
break; break;
case RC_DRAGON: case RC_DRAGON:
long_order = make_movement_order(u, tr, 3, allowed_dragon); long_order = make_movement_order(u, tr, 3, allowed_dragon);
break; break;
case RC_WYRM: case RC_WYRM:
long_order = make_movement_order(u, tr, 1, allowed_dragon); long_order = make_movement_order(u, tr, 1, allowed_dragon);
break; break;
default:
break;
} }
if (rng_int() % 100 < 15) { if (rng_int() % 100 < 15) {
const struct locale *lang = u->faction->locale; const struct locale *lang = u->faction->locale;
/* do a growl */ /* do a growl */
if (rname(tr, lang)) { if (rname(tr, lang)) {
addlist(&u->orders, create_order(K_MAIL, lang, "%s '%s... %s %s %s'", addlist(&u->orders,
LOC(lang, parameters[P_REGION]), random_growl(), create_order(K_MAIL, lang, "%s '%s... %s %s %s'",
u->number == 1 ? "Ich rieche" : "Wir riechen", LOC(lang, parameters[P_REGION]),
random_growl(),
u->number ==
1 ? "Ich rieche" : "Wir riechen",
"etwas in", rname(tr, u->faction->locale))); "etwas in", rname(tr, u->faction->locale)));
} }
} }
@ -797,8 +802,8 @@ void plan_monsters(faction * f)
if (ta && !monster_is_waiting(u)) { if (ta && !monster_is_waiting(u)) {
unit *tu = (unit *) ta->data.v; unit *tu = (unit *) ta->data.v;
if (tu && tu->region == r) { if (tu && tu->region == r) {
addlist(&u->orders, create_order(K_ATTACK, u->faction->locale, "%i", addlist(&u->orders,
tu->no)); create_order(K_ATTACK, u->faction->locale, "%i", tu->no));
} else if (tu) { } else if (tu) {
tu = findunitg(ta->data.i, NULL); tu = findunitg(ta->data.i, NULL);
if (tu != NULL) { if (tu != NULL) {
@ -833,8 +838,8 @@ void plan_monsters(faction * f)
if (u->race->bonus[SK_WEAPONLESS] != -99) { if (u->race->bonus[SK_WEAPONLESS] != -99) {
if (eff_skill(u, SK_WEAPONLESS, u->region) < 1) { if (eff_skill(u, SK_WEAPONLESS, u->region) < 1) {
long_order = long_order =
create_order(K_STUDY, f->locale, "'%s'", skillname(SK_WEAPONLESS, create_order(K_STUDY, f->locale, "'%s'",
f->locale)); skillname(SK_WEAPONLESS, f->locale));
} }
} }
} }
@ -847,24 +852,24 @@ void plan_monsters(faction * f)
} }
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_SEASERPENT: case RC_SEASERPENT:
long_order = create_order(K_PIRACY, f->locale, NULL); long_order = create_order(K_PIRACY, f->locale, NULL);
break; break;
#ifdef TODO_ALP #ifdef TODO_ALP
case RC_ALP: case RC_ALP:
long_order = monster_seeks_target(r, u); long_order = monster_seeks_target(r, u);
break; break;
#endif #endif
case RC_FIREDRAGON: case RC_FIREDRAGON:
case RC_DRAGON: case RC_DRAGON:
case RC_WYRM: case RC_WYRM:
long_order = plan_dragon(u); long_order = plan_dragon(u);
break; break;
default: default:
if (u->race->flags & RCF_LEARN) { if (u->race->flags & RCF_LEARN) {
long_order = monster_learn(u); long_order = monster_learn(u);
} }
break; break;
} }
} }
if (long_order) { if (long_order) {
@ -891,7 +896,8 @@ static int nrand(int start, int sub)
if (rng_int() % 100 < start) if (rng_int() % 100 < start)
res++; res++;
start -= sub; start -= sub;
} while (start > 0); }
while (start > 0);
return res; return res;
} }
@ -925,8 +931,8 @@ void spawn_dragons(void)
if (verbosity >= 2) { if (verbosity >= 2) {
log_printf("%d %s in %s.\n", u->number, log_printf("%d %s in %s.\n", u->number,
LOC(default_locale, rc_name(u->race, u->number != 1)), regionname(r, LOC(default_locale,
NULL)); rc_name(u->race, u->number != 1)), regionname(r, NULL));
} }
name_unit(u); name_unit(u);
@ -970,15 +976,15 @@ void spawn_undead(void)
continue; continue;
switch (rng_int() % 3) { switch (rng_int() % 3) {
case 0: case 0:
rc = new_race[RC_SKELETON]; rc = new_race[RC_SKELETON];
break; break;
case 1: case 1:
rc = new_race[RC_ZOMBIE]; rc = new_race[RC_ZOMBIE];
break; break;
default: default:
rc = new_race[RC_GHOUL]; rc = new_race[RC_GHOUL];
break; break;
} }
u = createunit(r, monsters, undead, rc); u = createunit(r, monsters, undead, rc);
@ -1000,8 +1006,8 @@ void spawn_undead(void)
if (verbosity >= 2) { if (verbosity >= 2) {
log_printf("%d %s in %s.\n", u->number, log_printf("%d %s in %s.\n", u->number,
LOC(default_locale, rc_name(u->race, u->number != 1)), regionname(r, LOC(default_locale,
NULL)); rc_name(u->race, u->number != 1)), regionname(r, NULL));
} }
{ {

View File

@ -56,38 +56,40 @@ static void equip_newunits(const struct equipment *eq, struct unit *u)
struct region *r = u->region; struct region *r = u->region;
switch (old_race(u->race)) { switch (old_race(u->race)) {
case RC_ELF: case RC_ELF:
set_show_item(u->faction, I_FEENSTIEFEL); set_show_item(u->faction, I_FEENSTIEFEL);
break; break;
case RC_GOBLIN: case RC_GOBLIN:
set_show_item(u->faction, I_RING_OF_INVISIBILITY); set_show_item(u->faction, I_RING_OF_INVISIBILITY);
set_number(u, 10); set_number(u, 10);
break; break;
case RC_HUMAN: case RC_HUMAN:
if (u->building == NULL) { if (u->building == NULL) {
const building_type *btype = bt_find("castle"); const building_type *btype = bt_find("castle");
if (btype != NULL) { if (btype != NULL) {
building *b = new_building(btype, r, u->faction->locale); building *b = new_building(btype, r, u->faction->locale);
b->size = 10; b->size = 10;
u->building = b; u->building = b;
fset(u, UFL_OWNER); fset(u, UFL_OWNER);
}
} }
break;
case RC_CAT:
set_show_item(u->faction, I_RING_OF_INVISIBILITY);
break;
case RC_AQUARIAN:
{
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
sh->size = sh->type->construction->maxsize;
u->ship = sh;
fset(u, UFL_OWNER);
} }
break; break;
case RC_CENTAUR: case RC_CAT:
rsethorses(r, 250 + rng_int() % 51 + rng_int() % 51); set_show_item(u->faction, I_RING_OF_INVISIBILITY);
break; break;
case RC_AQUARIAN:
{
ship *sh = new_ship(st_find("boat"), u->faction->locale, r);
sh->size = sh->type->construction->maxsize;
u->ship = sh;
fset(u, UFL_OWNER);
}
break;
case RC_CENTAUR:
rsethorses(r, 250 + rng_int() % 51 + rng_int() % 51);
break;
default:
break;
} }
} }