compiling with -pedantic on linux

This commit is contained in:
Enno Rehling 2011-03-08 08:44:20 +01:00
parent 04b3d7ff45
commit b4c5607747
16 changed files with 1850 additions and 1837 deletions

View file

@ -20,6 +20,7 @@ without prior permission by the authors of Eressea.
#include <kernel/binarystore.h> #include <kernel/binarystore.h>
#include <math.h> #include <math.h>
#include <stdio.h>
#include <lua.h> #include <lua.h>
#include <tolua.h> #include <tolua.h>

View file

@ -683,7 +683,6 @@ static int tolua_set_alliance_name(lua_State * L)
return 0; return 0;
} }
#include <libxml/tree.h> #include <libxml/tree.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/xml.h> #include <util/xml.h>
@ -970,8 +969,7 @@ static int tolua_settings_set(lua_State * L)
return 0; return 0;
} }
static void static void parse_inifile(lua_State * L, dictionary * d, const char *section)
parse_inifile(lua_State * L, dictionary * d, const char *section)
{ {
int i; int i;
size_t len = strlen(section); size_t len = strlen(section);
@ -1029,7 +1027,8 @@ int tolua_eressea_open(lua_State * L)
NULL); NULL);
tolua_function(L, TOLUA_CAST "create", tolua_alliance_create); tolua_function(L, TOLUA_CAST "create", tolua_alliance_create);
} tolua_endmodule(L); } tolua_endmodule(L);
tolua_cclass(L, TOLUA_CAST "spell", TOLUA_CAST "spell", TOLUA_CAST "", NULL); tolua_cclass(L, TOLUA_CAST "spell", TOLUA_CAST "spell", TOLUA_CAST "",
NULL);
tolua_beginmodule(L, TOLUA_CAST "spell"); tolua_beginmodule(L, TOLUA_CAST "spell");
{ {
tolua_function(L, TOLUA_CAST "__tostring", tolua_get_spell_name); tolua_function(L, TOLUA_CAST "__tostring", tolua_get_spell_name);
@ -1090,8 +1089,7 @@ int tolua_eressea_open(lua_State * L)
tolua_function(L, TOLUA_CAST "message_region", tolua_message_region); tolua_function(L, TOLUA_CAST "message_region", tolua_message_region);
/* scripted monsters */ /* scripted monsters */
tolua_function(L, TOLUA_CAST "spawn_braineaters", tolua_function(L, TOLUA_CAST "spawn_braineaters", tolua_spawn_braineaters);
tolua_spawn_braineaters);
tolua_function(L, TOLUA_CAST "update_guards", tolua_update_guards); tolua_function(L, TOLUA_CAST "update_guards", tolua_update_guards);
tolua_function(L, TOLUA_CAST "set_turn", &tolua_set_turn); tolua_function(L, TOLUA_CAST "set_turn", &tolua_set_turn);
@ -1104,8 +1102,10 @@ int tolua_eressea_open(lua_State * L)
tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36); tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36);
tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand); tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand);
tolua_function(L, TOLUA_CAST "get_nmrs", tolua_get_nmrs); tolua_function(L, TOLUA_CAST "get_nmrs", tolua_get_nmrs);
tolua_function(L, TOLUA_CAST "remove_empty_units", tolua_remove_empty_units); tolua_function(L, TOLUA_CAST "remove_empty_units",
tolua_function(L, TOLUA_CAST "update_subscriptions", tolua_update_subscriptions); tolua_remove_empty_units);
tolua_function(L, TOLUA_CAST "update_subscriptions",
tolua_update_subscriptions);
tolua_function(L, TOLUA_CAST "update_scores", tolua_update_scores); tolua_function(L, TOLUA_CAST "update_scores", tolua_update_scores);
tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners); tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners);
tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill); tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill);

View file

@ -130,9 +130,10 @@ int income(const unit * u)
return 1000 * u->number; return 1000 * u->number;
case RC_WYRM: case RC_WYRM:
return 5000 * u->number; return 5000 * u->number;
} default:
return 20 * u->number; return 20 * u->number;
} }
}
static void scramble(void *data, int n, size_t width) static void scramble(void *data, int n, size_t width)
{ {
@ -356,8 +357,7 @@ static int do_recruiting(recruitment * recruits, int available)
number = MIN(req->qty, (int)(get / multi)); number = MIN(req->qty, (int)(get / multi));
if (rc->recruitcost) { if (rc->recruitcost) {
int afford = int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
number * rc->recruitcost) / rc->recruitcost; number * rc->recruitcost) / rc->recruitcost;
number = MIN(number, afford); number = MIN(number, afford);
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
@ -1340,30 +1340,24 @@ void economics(region * r)
boolean destroyed = false; boolean destroyed = false;
if (u->number > 0) { if (u->number > 0) {
for (ord = u->orders; ord; ord = ord->next) { for (ord = u->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) { keyword_t kwd = get_keyword(ord);
case K_DESTROY: if (kwd == K_DESTROY) {
if (!destroyed) { if (!destroyed) {
if (destroy_cmd(u, ord) != 0) if (destroy_cmd(u, ord) != 0)
ord = NULL; ord = NULL;
destroyed = true; destroyed = true;
} }
break; } else if (kwd == K_GIVE || kwd == K_LIEFERE) {
case K_GIVE:
case K_LIEFERE:
give_cmd(u, ord); give_cmd(u, ord);
break; } else if (kwd == K_FORGET) {
case K_FORGET:
forget_cmd(u, ord); forget_cmd(u, ord);
break;
} }
if (u->orders == NULL) if (u->orders == NULL) {
break; break;
} }
} }
} }
}
/* RECRUIT orders */ /* RECRUIT orders */
if (rules_recruit < 0) if (rules_recruit < 0)
@ -2875,8 +2869,7 @@ static void breed_cmd(unit * u, struct order *ord)
breedtrees(r, u, m); breedtrees(r, u, m);
break; break;
} else if (rtype != oldresourcetype[R_HORSE]) { } else if (rtype != oldresourcetype[R_HORSE]) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_cannotmake", ""));
""));
break; break;
} }
} }
@ -3446,17 +3439,15 @@ void produce(struct region *r)
} }
for (ord = u->orders; ord; ord = ord->next) { for (ord = u->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) { keyword_t kwd = get_keyword(ord);
case K_BUY: if (kwd == K_BUY) {
buy(u, &buyorders, ord); buy(u, &buyorders, ord);
trader = true; trader = true;
break; } else if (kwd == K_SELL) {
case K_SELL:
/* sell returns true if the sale is not limited /* sell returns true if the sale is not limited
* by the region limit */ * by the region limit */
limited &= !sell(u, &sellorders, ord); limited &= !sell(u, &sellorders, ord);
trader = true; trader = true;
break;
} }
} }
if (trader) { if (trader) {

View file

@ -135,8 +135,8 @@ static int RemoveNMRNewbie(void)
static void restart_race(unit * u, const race * rc) static void restart_race(unit * u, const race * rc)
{ {
faction *oldf = u->faction; faction *oldf = u->faction;
faction *f = faction *f = addfaction(oldf->email, oldf->passw, rc, oldf->locale,
addfaction(oldf->email, oldf->passw, rc, oldf->locale, oldf->subscription); oldf->subscription);
unit *nu = addplayer(u->region, f); unit *nu = addplayer(u->region, f);
order **ordp = &u->orders; order **ordp = &u->orders;
f->subscription = u->faction->subscription; f->subscription = u->faction->subscription;
@ -306,7 +306,8 @@ static void get_food(region * r)
} }
} }
for (v = r->units; need && v; v = v->next) { for (v = r->units; need && v; v = v->next) {
if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) { if (v->faction != f && alliedunit(v, f, HELP_MONEY)
&& help_money(v)) {
help_feed(v, u, &need); help_feed(v, u, &need);
} }
} }
@ -419,8 +420,8 @@ static void age_unit(region * r, unit * u)
if ((itm->type->flags & ITF_NOTLOST) == 0) { if ((itm->type->flags & ITF_NOTLOST) == 0) {
if (itm->type->flags & (ITF_BIG | ITF_ANIMAL | ITF_CURSED)) { if (itm->type->flags & (ITF_BIG | ITF_ANIMAL | ITF_CURSED)) {
ADDMSG(&u->faction->msgs, msg_message("itemcrumble", ADDMSG(&u->faction->msgs, msg_message("itemcrumble",
"unit region item amount", u, u->region, itm->type->rtype, "unit region item amount",
itm->number)); u, u->region, itm->type->rtype, itm->number));
i_free(i_remove(itemp, itm)); i_free(i_remove(itemp, itm));
continue; continue;
} }
@ -1056,8 +1057,7 @@ static void transfer_faction(faction * f, faction * f2)
for (u = f->units; u;) { for (u = f->units; u;) {
un = u->nextF; un = u->nextF;
if (!unit_has_cursed_item(u) if (!unit_has_cursed_item(u)
&& !has_skill(u, SK_MAGIC) && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY)) {
&& !has_skill(u, SK_ALCHEMY)) {
u_setfaction(u, f2); u_setfaction(u, f2);
} }
u = un; u = un;
@ -1669,10 +1669,12 @@ rename_building(unit * u, order * ord, building * b, const char *name)
if (owner) { if (owner) {
if (cansee(owner->faction, u->region, u, 0)) { if (cansee(owner->faction, u->region, u, 0)) {
ADDMSG(&owner->faction->msgs, msg_message("renamed_building_seen", ADDMSG(&owner->faction->msgs,
msg_message("renamed_building_seen",
"building renamer region", b, u, u->region)); "building renamer region", b, u, u->region));
} else { } else {
ADDMSG(&owner->faction->msgs, msg_message("renamed_building_notseen", ADDMSG(&owner->faction->msgs,
msg_message("renamed_building_notseen",
"building region", b, u->region)); "building region", b, u->region));
} }
} }
@ -1738,8 +1740,7 @@ static int name_cmd(unit * u, struct order *ord)
for (; lang; lang = nextlocale(lang)) { for (; lang; lang = nextlocale(lang)) {
const char *fdname = LOC(lang, "factiondefault"); const char *fdname = LOC(lang, "factiondefault");
size_t fdlen = strlen(fdname); size_t fdlen = strlen(fdname);
if (strlen(f->name) >= fdlen if (strlen(f->name) >= fdlen && strncmp(f->name, fdname, fdlen) == 0) {
&& strncmp(f->name, fdname, fdlen) == 0) {
break; break;
} }
} }
@ -1749,8 +1750,8 @@ static int name_cmd(unit * u, struct order *ord)
} }
} }
if (cansee(f, r, u, 0)) { if (cansee(f, r, u, 0)) {
ADDMSG(&f->msgs, msg_message("renamed_faction_seen", "unit region", u, ADDMSG(&f->msgs,
r)); msg_message("renamed_faction_seen", "unit region", u, r));
} else { } else {
ADDMSG(&f->msgs, msg_message("renamed_faction_notseen", "", r)); ADDMSG(&f->msgs, msg_message("renamed_faction_notseen", "", r));
} }
@ -1794,11 +1795,11 @@ static int name_cmd(unit * u, struct order *ord)
uo = shipowner(sh); uo = shipowner(sh);
if (uo) { if (uo) {
if (cansee(uo->faction, r, u, 0)) { if (cansee(uo->faction, r, u, 0)) {
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_seen", ADDMSG(&uo->faction->msgs,
"ship renamer region", sh, u, r)); msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
} else { } else {
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_notseen", ADDMSG(&uo->faction->msgs,
"ship region", sh, r)); msg_message("renamed_ship_notseen", "ship region", sh, r));
} }
} }
s = &sh->name; s = &sh->name;
@ -1898,10 +1899,11 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
u = NULL; u = NULL;
} }
if (!receiver) { /* BOTSCHAFT an PARTEI */ if (!receiver) { /* BOTSCHAFT an PARTEI */
ADDMSG(&f->msgs, msg_message("regionmessage", "region sender string", r, u, ADDMSG(&f->msgs,
s)); msg_message("regionmessage", "region sender string", r, u, s));
} else { /* BOTSCHAFT an EINHEIT */ } else { /* BOTSCHAFT an EINHEIT */
ADDMSG(&f->msgs, msg_message("unitmessage", "region unit sender string", r, ADDMSG(&f->msgs,
msg_message("unitmessage", "region unit sender string", r,
receiver, u, s)); receiver, u, s));
} }
} }
@ -1917,8 +1919,8 @@ mailunit(region * r, unit * u, int n, struct order *ord, const char *s)
} else { } else {
/* Immer eine Meldung - sonst könnte man so getarnte EHs enttarnen: /* Immer eine Meldung - sonst könnte man so getarnte EHs enttarnen:
* keine Meldung -> EH hier. */ * keine Meldung -> EH hier. */
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ADDMSG(&u->faction->msgs,
"")); msg_feedback(u, ord, "feedback_unit_not_found", ""));
} }
} }
@ -2093,7 +2095,8 @@ static int mail_cmd(unit * u, struct order *ord)
cont = 1; cont = 1;
break; break;
} }
} while (cont); }
while (cont);
cmistake(u, ord, 149, MSG_MESSAGE); cmistake(u, ord, 149, MSG_MESSAGE);
return 0; return 0;
} }
@ -2126,8 +2129,8 @@ static int email_cmd(unit * u, struct order *ord)
} else { } else {
faction *f = u->faction; faction *f = u->faction;
if (set_email(&f->email, (const char *)s) != 0) { if (set_email(&f->email, (const char *)s) != 0) {
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), log_error(("Invalid email address for faction %s: %s\n",
s)); itoa36(f->no), s));
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s)); ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
} else { } else {
ADDMSG(&f->msgs, msg_message("changemail", "value", f->email)); ADDMSG(&f->msgs, msg_message("changemail", "value", f->email));
@ -2372,13 +2375,13 @@ static boolean display_race(faction * f, unit * u, const race * rc)
switch (rc->attack[a].type) { switch (rc->attack[a].type) {
case AT_STANDARD: case AT_STANDARD:
bytes = bytes =
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"), snprintf(bufp, size, "%s (%s)",
rc->def_damage); LOC(f->locale, "attack_standard"), rc->def_damage);
break; break;
case AT_NATURAL: case AT_NATURAL:
bytes = bytes =
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"), snprintf(bufp, size, "%s (%s)",
rc->attack[a].data.dice); LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
break; break;
case AT_SPELL: case AT_SPELL:
case AT_COMBATSPELL: case AT_COMBATSPELL:
@ -2388,8 +2391,8 @@ static boolean display_race(faction * f, unit * u, const race * rc)
break; break;
case AT_STRUCTURAL: case AT_STRUCTURAL:
bytes = bytes =
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"), snprintf(bufp, size, "%s (%s)",
rc->attack[a].data.dice); LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
break; break;
default: default:
bytes = 0; bytes = 0;
@ -2482,7 +2485,8 @@ static int promotion_cmd(unit * u, struct order *ord)
} }
if (maxheroes(u->faction) < countheroes(u->faction) + u->number) { if (maxheroes(u->faction) < countheroes(u->faction) + u->number) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_maxed", "max count", ADDMSG(&u->faction->msgs,
msg_feedback(u, ord, "heroes_maxed", "max count",
maxheroes(u->faction), countheroes(u->faction))); maxheroes(u->faction), countheroes(u->faction)));
return 0; return 0;
} }
@ -2495,8 +2499,8 @@ static int promotion_cmd(unit * u, struct order *ord)
money = get_pooled(u, i_silver->rtype, GET_ALL, people); money = get_pooled(u, i_silver->rtype, GET_ALL, people);
if (people > money) { if (people > money) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_cost", "cost have", ADDMSG(&u->faction->msgs,
people, money)); msg_feedback(u, ord, "heroes_cost", "cost have", people, money));
return 0; return 0;
} }
use_pooled(u, i_silver->rtype, GET_ALL, people); use_pooled(u, i_silver->rtype, GET_ALL, people);
@ -2710,7 +2714,8 @@ static int guard_on_cmd(unit * u, struct order *ord)
} else { } else {
if (fval(u, UFL_MOVED)) { if (fval(u, UFL_MOVED)) {
cmistake(u, ord, 187, MSG_EVENT); cmistake(u, ord, 187, MSG_EVENT);
} else if (fval(u->race, RCF_ILLUSIONARY) || u->race == new_race[RC_SPELL]) { } else if (fval(u->race, RCF_ILLUSIONARY)
|| u->race == new_race[RC_SPELL]) {
cmistake(u, ord, 95, MSG_EVENT); cmistake(u, ord, 95, MSG_EVENT);
} else { } else {
/* Monster der Monsterpartei dürfen immer bewachen */ /* Monster der Monsterpartei dürfen immer bewachen */
@ -2744,14 +2749,14 @@ static void sinkships(region * r)
if (fval(r->terrain, SEA_REGION) && (!enoughsailors(sh, r) if (fval(r->terrain, SEA_REGION) && (!enoughsailors(sh, r)
|| get_captain(sh) == NULL)) { || get_captain(sh) == NULL)) {
/* Schiff nicht seetüchtig */ /* Schiff nicht seetüchtig */
float dmg = float dmg = get_param_flt(global.parameters,
get_param_flt(global.parameters, "rules.ship.damage.nocrewocean", "rules.ship.damage.nocrewocean",
0.30F); 0.30F);
damage_ship(sh, dmg); damage_ship(sh, dmg);
} }
if (shipowner(sh) == NULL) { if (shipowner(sh) == NULL) {
float dmg = float dmg = get_param_flt(global.parameters, "rules.ship.damage.nocrew",
get_param_flt(global.parameters, "rules.ship.damage.nocrew", 0.05F); 0.05F);
damage_ship(sh, dmg); damage_ship(sh, dmg);
} }
} }
@ -2872,6 +2877,8 @@ static void reorder(void)
*up = u->next; *up = u->next;
u->next = v->next; u->next = v->next;
v->next = u; v->next = u;
fset(u, UFL_MARK);
sorted = true;
break; break;
case P_BEFORE: case P_BEFORE:
if (fval(v, UFL_OWNER)) { if (fval(v, UFL_OWNER)) {
@ -2884,10 +2891,13 @@ static void reorder(void)
*up = u->next; *up = u->next;
u->next = v; u->next = v;
} }
break;
}
fset(u, UFL_MARK); fset(u, UFL_MARK);
sorted = true; sorted = true;
break;
default:
/* TODO: syntax error message? */
break;
}
} }
break; break;
} }
@ -2898,11 +2908,12 @@ static void reorder(void)
} }
if (sorted) { if (sorted) {
unit *u; unit *u;
for (u = r->units; u; u = u->next) for (u = r->units; u; u = u->next) {
freset(u, UFL_MARK); freset(u, UFL_MARK);
} }
} }
} }
}
#if 0 #if 0
/* Aus Gebäude weisen, VERBANNE */ /* Aus Gebäude weisen, VERBANNE */
@ -3118,8 +3129,8 @@ static building *age_building(building * b)
} }
if (unicorns) { if (unicorns) {
ADDMSG(&u->faction->msgs, msg_message("scunicorn", ADDMSG(&u->faction->msgs, msg_message("scunicorn",
"unit amount rtype", u, unicorns, "unit amount rtype",
olditemtype[I_ELVENHORSE]->rtype)); u, unicorns, olditemtype[I_ELVENHORSE]->rtype));
} }
} }
} }
@ -3141,8 +3152,8 @@ static building *age_building(building * b)
/* the mage reactivates the circle */ /* the mage reactivates the circle */
c = create_curse(mage, &rt->attribs, ct_astralblock, c = create_curse(mage, &rt->attribs, ct_astralblock,
(float)MAX(1, sk), MAX(1, sk / 2), effect, 0); (float)MAX(1, sk), MAX(1, sk / 2), effect, 0);
ADDMSG(&r->msgs, msg_message("astralshield_activate", ADDMSG(&r->msgs,
"region unit", r, mage)); msg_message("astralshield_activate", "region unit", r, mage));
} }
} else if (mage != NULL) { } else if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC);
@ -3364,13 +3375,15 @@ static void new_units(void)
if (err) { if (err) {
if (err == 1) { if (err == 1) {
ADDMSG(&u->faction->msgs, msg_feedback(u, makeord, ADDMSG(&u->faction->msgs,
"too_many_units_in_alliance", "allowed", msg_feedback(u, makeord,
maxunits(u->faction))); "too_many_units_in_alliance",
"allowed", maxunits(u->faction)));
} else { } else {
ADDMSG(&u->faction->msgs, msg_feedback(u, makeord, ADDMSG(&u->faction->msgs,
"too_many_units_in_faction", "allowed", msg_feedback(u, makeord,
maxunits(u->faction))); "too_many_units_in_faction",
"allowed", maxunits(u->faction)));
} }
ordp = &makeord->next; ordp = &makeord->next;
@ -3527,13 +3540,15 @@ static void setdefaults(unit * u)
/* Wird je diese Ausschliesslichkeit aufgehoben, muss man aufpassen /* Wird je diese Ausschliesslichkeit aufgehoben, muss man aufpassen
* mit der Reihenfolge von Kaufen, Verkaufen etc., damit es Spielern * mit der Reihenfolge von Kaufen, Verkaufen etc., damit es Spielern
* nicht moeglich ist, Schulden zu machen. */ * nicht moeglich ist, Schulden zu machen. */
default:
break;
} }
} }
} }
if (hunger) if (hunger) {
return; return;
}
/* Wenn die Einheit handelt, muß der Default-Befehl gelöscht /* Wenn die Einheit handelt, muß der Default-Befehl gelöscht
* werden. */ * werden. */
@ -3590,6 +3605,8 @@ static double heal_factor(const unit * u)
return elf_regen; return elf_regen;
} }
return 1.0; return 1.0;
default:
return 1.0;
} }
return 1.0; return 1.0;
} }
@ -3630,8 +3647,8 @@ static void monthly_healing(void)
if (fval(u, UFL_HUNGER)) if (fval(u, UFL_HUNGER))
continue; continue;
if (fval(r->terrain, SEA_REGION) && u->ship == NULL && !(canswim(u) if (fval(r->terrain, SEA_REGION) && u->ship == NULL
|| canfly(u))) { && !(canswim(u) || canfly(u))) {
continue; continue;
} }

View file

@ -104,9 +104,7 @@ boolean is_migrant(unit * u)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
boolean magic_lowskill(unit * u) boolean magic_lowskill(unit * u)
{ {
if (u->race == new_race[RC_TOAD]) return (u->race == new_race[RC_TOAD]) ? true : false;
return true;
return false;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -121,23 +119,22 @@ int study_cost(unit * u, skill_t sk)
sprintf(buffer, "skills.cost.%s", skillnames[sk]); sprintf(buffer, "skills.cost.%s", skillnames[sk]);
cost[sk] = get_param_int(global.parameters, buffer, -1); cost[sk] = get_param_int(global.parameters, buffer, -1);
} }
if (cost[sk] >= 0) if (cost[sk] >= 0) {
return cost[sk]; return cost[sk];
}
switch (sk) { switch (sk) {
case SK_SPY: case SK_SPY:
return 100; return 100;
break;
case SK_TACTICS: case SK_TACTICS:
case SK_HERBALISM: case SK_HERBALISM:
case SK_ALCHEMY: case SK_ALCHEMY:
return 200; return 200;
break;
case SK_MAGIC: /* Die Magiekosten betragen 50+Summe(50*Stufe) */ case SK_MAGIC: /* Die Magiekosten betragen 50+Summe(50*Stufe) */
/* 'Stufe' ist dabei die nächste zu erreichende Stufe */ /* 'Stufe' ist dabei die nächste zu erreichende Stufe */
stufe = 1 + get_level(u, SK_MAGIC); stufe = 1 + get_level(u, SK_MAGIC);
return k * (1 + ((stufe + 1) * stufe / 2)); return k * (1 + ((stufe + 1) * stufe / 2));
break; default:
return 0;
} }
return 0; return 0;
} }

View file

@ -1324,10 +1324,9 @@ void do_misc(region * r, boolean lasttry)
for (uc = r->units; uc; uc = uc->next) { for (uc = r->units; uc; uc = uc->next) {
order *ord; order *ord;
for (ord = uc->orders; ord; ord = ord->next) { for (ord = uc->orders; ord; ord = ord->next) {
switch (get_keyword(ord)) { keyword_t kwd = get_keyword(ord);
case K_CONTACT: if (kwd == K_CONTACT) {
contact_cmd(uc, ord, lasttry); contact_cmd(uc, ord, lasttry);
break;
} }
} }
} }

View file

@ -587,15 +587,11 @@ int skill_limit(faction * f, skill_t sk)
return fl; return fl;
} }
} }
switch (sk) { if (sk == SK_MAGIC) {
case SK_MAGIC:
m = max_magicians(f); m = max_magicians(f);
break; } else if (sk == SK_ALCHEMY) {
case SK_ALCHEMY: m = get_param_int(global.parameters, "rules.maxskills.alchemy",
m =
get_param_int(global.parameters, "rules.maxskills.alchemy",
MAXALCHEMISTS); MAXALCHEMISTS);
break;
} }
return m; return m;
} }
@ -607,10 +603,11 @@ int count_skill(faction * f, skill_t sk)
for (u = f->units; u; u = u->nextF) { for (u = f->units; u; u = u->nextF) {
if (has_skill(u, sk)) { if (has_skill(u, sk)) {
if (!is_familiar(u)) if (!is_familiar(u)) {
n += u->number; n += u->number;
} }
} }
}
return n; return n;
} }
@ -1585,13 +1582,14 @@ static int read_newunitid(const faction * f, const region * r)
int read_unitid(const faction * f, const region * r) int read_unitid(const faction * f, const region * r)
{ {
const char *s = getstrtoken(); const char *s = getstrtoken();
param_t param;
/* Da s nun nur einen string enthaelt, suchen wir ihn direkt in der /* Da s nun nur einen string enthaelt, suchen wir ihn direkt in der
* paramliste. machen wir das nicht, dann wird getnewunit in s nach der * paramliste. machen wir das nicht, dann wird getnewunit in s nach der
* nummer suchen, doch dort steht bei temp-units nur "temp" drinnen! */ * nummer suchen, doch dort steht bei temp-units nur "temp" drinnen! */
switch (findparam(s, f->locale)) { param = findparam(s, f->locale);
case P_TEMP: if (param == P_TEMP) {
return read_newunitid(f, r); return read_newunitid(f, r);
} }
if (!s || *s == 0) if (!s || *s == 0)
@ -2502,6 +2500,9 @@ unsigned int guard_flags(const unit * u)
case RC_IRONKEEPER: case RC_IRONKEEPER:
flags = GUARD_MINING; flags = GUARD_MINING;
break; break;
default:
/* TODO: This should be configuration variables, all of it */
break;
} }
return flags; return flags;
} }

View file

@ -1694,8 +1694,7 @@ verify_targets(castorder * co, int *invalid, int *resist, int *success)
spobj->flag = TARGET_RESISTS; spobj->flag = TARGET_RESISTS;
++*resist; ++*resist;
ADDMSG(&mage->faction->msgs, msg_message("spellunitresists", ADDMSG(&mage->faction->msgs, msg_message("spellunitresists",
"unit region command target", "unit region command target", mage, mage->region, co->order, u));
mage, mage->region, co->order, u));
break; break;
} }
@ -2485,6 +2484,8 @@ static boolean is_moving_ship(const region * r, const ship * sh)
case K_MOVE: case K_MOVE:
case K_FOLLOW: case K_FOLLOW:
return true; return true;
default:
return false;
} }
return false; return false;
} }

View file

@ -1334,6 +1334,8 @@ static int movement_speed(unit * u)
case RC_BIRTHDAYDRAGON: case RC_BIRTHDAYDRAGON:
case RC_SONGDRAGON: case RC_SONGDRAGON:
return BP_DRAGON; return BP_DRAGON;
default:
break;
} }
if (!init) { if (!init) {
@ -2565,9 +2567,7 @@ void movement(void)
} }
kword = get_keyword(u->thisorder); kword = get_keyword(u->thisorder);
switch (kword) { if (kword == K_ROUTE || kword == K_MOVE) {
case K_ROUTE:
case K_MOVE:
/* after moving, the unit has no thisorder. this prevents /* after moving, the unit has no thisorder. this prevents
* it from moving twice (or getting error messages twice). * it from moving twice (or getting error messages twice).
* UFL_NOTMOVING is set in combat if the unit is not allowed * UFL_NOTMOVING is set in combat if the unit is not allowed
@ -2602,7 +2602,6 @@ void movement(void)
} }
} }
} }
break;
} }
if (u->region == r) { if (u->region == r) {
/* not moved, use next unit */ /* not moved, use next unit */

View file

@ -396,8 +396,6 @@ boolean is_repeated(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
return true;
case K_PLANT: case K_PLANT:
return true; return true;
@ -428,6 +426,8 @@ boolean is_repeated(const order * ord)
if (param != P_TEMP) if (param != P_TEMP)
return true; return true;
break; break;
default:
return false;
} }
return false; return false;
} }
@ -464,8 +464,6 @@ boolean is_exclusive(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
return true;
case K_PLANT: case K_PLANT:
return true; return true;
@ -496,6 +494,8 @@ boolean is_exclusive(const order * ord)
if (param != P_TEMP) if (param != P_TEMP)
return true; return true;
break; break;
default:
return false;
} }
return false; return false;
} }
@ -534,8 +534,6 @@ boolean is_long(const order * ord)
case K_TEACH: case K_TEACH:
case K_BREED: case K_BREED:
case K_PIRACY: case K_PIRACY:
return true;
case K_PLANT: case K_PLANT:
return true; return true;
@ -566,6 +564,8 @@ boolean is_long(const order * ord)
if (param != P_TEMP) if (param != P_TEMP)
return true; return true;
break; break;
default:
return false;
} }
return false; return false;
} }
@ -593,9 +593,11 @@ boolean is_persistent(const order * ord)
case K_KOMMENTAR: case K_KOMMENTAR:
case K_LIEFERE: case K_LIEFERE:
return true; return true;
default:
return persist || is_repeated(ord);
} }
return persist || is_repeated(ord);
} }
char *write_order(const order * ord, char *buffer, size_t size) char *write_order(const order * ord, char *buffer, size_t size)

View file

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_REPORTS #ifndef H_KRNL_REPORTS
#define H_KRNL_REPORTS #define H_KRNL_REPORTS
#include <time.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View file

@ -175,13 +175,11 @@ int freadstr(FILE * F, int encoding, char *start, size_t size)
char inbuf = (char)c; char inbuf = (char)c;
size_t inbytes = 1; size_t inbytes = 1;
size_t outbytes = size - (str - start); size_t outbytes = size - (str - start);
int ret = int ret = unicode_latin1_to_utf8(str, &outbytes, &inbuf, &inbytes);
unicode_latin1_to_utf8(str, &outbytes, &inbuf, &inbytes);
if (ret > 0) if (ret > 0)
str += ret; str += ret;
else { else {
log_error( log_error(("input data was not iso-8859-1! assuming utf-8\n"));
("input data was not iso-8859-1! assuming utf-8\n"));
encoding = XML_CHAR_ENCODING_ERROR; encoding = XML_CHAR_ENCODING_ERROR;
*str++ = (char)c; *str++ = (char)c;
} }
@ -314,9 +312,14 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
} else { } else {
quit = false; quit = false;
} }
}
if (quit)
break; break;
default:
/* TODO: syntax error message */
break;
}
if (quit) {
break;
}
} }
/* Nun wird der Befehl erzeut und eingehängt */ /* Nun wird der Befehl erzeut und eingehängt */
*ordp = parse_order(s, u->faction->locale); *ordp = parse_order(s, u->faction->locale);

View file

@ -223,13 +223,15 @@ int rc_skillmod(const struct race *rc, const region * r, skill_t sk)
{ {
int mods; int mods;
if (!skill_enabled[sk]) if (!skill_enabled[sk]) {
return 0; return 0;
}
#ifdef FASTER_SKILLMOD #ifdef FASTER_SKILLMOD
unsigned int index = hashstring(rc->_name[0]) % RCMODMAXHASH; unsigned int index = hashstring(rc->_name[0]) % RCMODMAXHASH;
struct skillmods **imods = &modhash[index]; struct skillmods **imods = &modhash[index];
while (*imods && (*imods)->race != rc) while (*imods && (*imods)->race != rc) {
imods = &(*imods)->next; imods = &(*imods)->next;
}
if (*imods == NULL) { if (*imods == NULL) {
*imods = init_skills(rc); *imods = init_skills(rc);
} }
@ -237,21 +239,19 @@ int rc_skillmod(const struct race *rc, const region * r, skill_t sk)
#else #else
mods = skill_mod(rc, sk, r->terrain); mods = skill_mod(rc, sk, r->terrain);
#endif #endif
if (rc == new_race[RC_ELF] && r_isforest(r)) if (rc == new_race[RC_ELF] && r_isforest(r)) {
switch (sk) { if (sk == SK_PERCEPTION) {
case SK_PERCEPTION:
++mods; ++mods;
break; } else if (sk == SK_STEALTH) {
case SK_STEALTH: if (r_isforest(r)) {
if (r_isforest(r))
++mods; ++mods;
break;
case SK_TACTICS:
if (r_isforest(r))
mods += 2;
break;
} }
} else if (sk == SK_TACTICS) {
if (r_isforest(r)) {
mods += 2;
}
}
}
return mods; return mods;
} }

View file

@ -170,7 +170,7 @@ enum {
XMLSPL_WDWPYRAMID_ASTRAL = 185, XMLSPL_WDWPYRAMID_ASTRAL = 185,
XMLSPL_WDWPYRAMID_DRUIDE = 186, XMLSPL_WDWPYRAMID_DRUIDE = 186,
XMLSPL_WDWPYRAMID_BARDE = 187, XMLSPL_WDWPYRAMID_BARDE = 187,
XMLSPL_WDWPYRAMID_CHAOS = 188, XMLSPL_WDWPYRAMID_CHAOS = 188
}; };
#endif #endif

View file

@ -60,7 +60,7 @@ static int txt_w_flt(struct storage *store, float arg)
static float txt_r_flt(struct storage *store) static float txt_r_flt(struct storage *store)
{ {
double result; double result;
fscanf((FILE *) store->userdata, "%f", &result); fscanf((FILE *) store->userdata, "%lf", &result);
return (float)result; return (float)result;
} }

View file

@ -89,18 +89,17 @@ int xecmd(unit * u, order * ord)
if (a_find(f->attribs, &at_xontormiaexpress)) { if (a_find(f->attribs, &at_xontormiaexpress)) {
if (get_keyword(ord) == K_XE) { if (get_keyword(ord) == K_XE) {
param_t param;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
switch (findparam(getstrtoken(), f->locale)) { param = findparam(getstrtoken(), f->locale);
case P_XEPOTION: if (param == P_XEPOTION) {
xe_givepotion(u, ord); xe_givepotion(u, ord);
break; } else if (param == P_XEBALLOON) {
case P_XEBALLOON:
xe_giveballon(u, ord); xe_giveballon(u, ord);
break; } else if (param == P_XELAEN) {
case P_XELAEN:
xe_givelaen(u, ord); xe_givelaen(u, ord);
break;
} }
} }
} }