forked from github/server
compiling with -pedantic on linux
This commit is contained in:
parent
04b3d7ff45
commit
b4c5607747
16 changed files with 1850 additions and 1837 deletions
|
@ -20,6 +20,7 @@ without prior permission by the authors of Eressea.
|
|||
#include <kernel/binarystore.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
|
|
@ -683,7 +683,6 @@ static int tolua_set_alliance_name(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <util/functions.h>
|
||||
#include <util/xml.h>
|
||||
|
@ -970,8 +969,7 @@ static int tolua_settings_set(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_inifile(lua_State * L, dictionary * d, const char *section)
|
||||
static void parse_inifile(lua_State * L, dictionary * d, const char *section)
|
||||
{
|
||||
int i;
|
||||
size_t len = strlen(section);
|
||||
|
@ -1029,7 +1027,8 @@ int tolua_eressea_open(lua_State * L)
|
|||
NULL);
|
||||
tolua_function(L, TOLUA_CAST "create", tolua_alliance_create);
|
||||
} 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_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);
|
||||
|
||||
/* scripted monsters */
|
||||
tolua_function(L, TOLUA_CAST "spawn_braineaters",
|
||||
tolua_spawn_braineaters);
|
||||
tolua_function(L, TOLUA_CAST "spawn_braineaters", tolua_spawn_braineaters);
|
||||
|
||||
tolua_function(L, TOLUA_CAST "update_guards", tolua_update_guards);
|
||||
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 "dice_roll", tolua_dice_rand);
|
||||
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 "update_subscriptions", tolua_update_subscriptions);
|
||||
tolua_function(L, TOLUA_CAST "remove_empty_units",
|
||||
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_owners", tolua_update_owners);
|
||||
tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill);
|
||||
|
|
|
@ -130,9 +130,10 @@ int income(const unit * u)
|
|||
return 1000 * u->number;
|
||||
case RC_WYRM:
|
||||
return 5000 * u->number;
|
||||
}
|
||||
default:
|
||||
return 20 * u->number;
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
if (rc->recruitcost) {
|
||||
int afford =
|
||||
get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
number * rc->recruitcost) / rc->recruitcost;
|
||||
number = MIN(number, afford);
|
||||
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
|
@ -1340,30 +1340,24 @@ void economics(region * r)
|
|||
boolean destroyed = false;
|
||||
if (u->number > 0) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
switch (get_keyword(ord)) {
|
||||
case K_DESTROY:
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
if (kwd == K_DESTROY) {
|
||||
if (!destroyed) {
|
||||
if (destroy_cmd(u, ord) != 0)
|
||||
ord = NULL;
|
||||
destroyed = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case K_GIVE:
|
||||
case K_LIEFERE:
|
||||
} else if (kwd == K_GIVE || kwd == K_LIEFERE) {
|
||||
give_cmd(u, ord);
|
||||
break;
|
||||
|
||||
case K_FORGET:
|
||||
} else if (kwd == K_FORGET) {
|
||||
forget_cmd(u, ord);
|
||||
break;
|
||||
|
||||
}
|
||||
if (u->orders == NULL)
|
||||
if (u->orders == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* RECRUIT orders */
|
||||
|
||||
if (rules_recruit < 0)
|
||||
|
@ -2875,8 +2869,7 @@ static void breed_cmd(unit * u, struct order *ord)
|
|||
breedtrees(r, u, m);
|
||||
break;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -3446,17 +3439,15 @@ void produce(struct region *r)
|
|||
}
|
||||
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
switch (get_keyword(ord)) {
|
||||
case K_BUY:
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
if (kwd == K_BUY) {
|
||||
buy(u, &buyorders, ord);
|
||||
trader = true;
|
||||
break;
|
||||
case K_SELL:
|
||||
} else if (kwd == K_SELL) {
|
||||
/* sell returns true if the sale is not limited
|
||||
* by the region limit */
|
||||
limited &= !sell(u, &sellorders, ord);
|
||||
trader = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (trader) {
|
||||
|
|
|
@ -135,8 +135,8 @@ static int RemoveNMRNewbie(void)
|
|||
static void restart_race(unit * u, const race * rc)
|
||||
{
|
||||
faction *oldf = u->faction;
|
||||
faction *f =
|
||||
addfaction(oldf->email, oldf->passw, rc, oldf->locale, oldf->subscription);
|
||||
faction *f = addfaction(oldf->email, oldf->passw, rc, oldf->locale,
|
||||
oldf->subscription);
|
||||
unit *nu = addplayer(u->region, f);
|
||||
order **ordp = &u->orders;
|
||||
f->subscription = u->faction->subscription;
|
||||
|
@ -306,7 +306,8 @@ static void get_food(region * r)
|
|||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -419,8 +420,8 @@ static void age_unit(region * r, unit * u)
|
|||
if ((itm->type->flags & ITF_NOTLOST) == 0) {
|
||||
if (itm->type->flags & (ITF_BIG | ITF_ANIMAL | ITF_CURSED)) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("itemcrumble",
|
||||
"unit region item amount", u, u->region, itm->type->rtype,
|
||||
itm->number));
|
||||
"unit region item amount",
|
||||
u, u->region, itm->type->rtype, itm->number));
|
||||
i_free(i_remove(itemp, itm));
|
||||
continue;
|
||||
}
|
||||
|
@ -1056,8 +1057,7 @@ static void transfer_faction(faction * f, faction * f2)
|
|||
for (u = f->units; u;) {
|
||||
un = u->nextF;
|
||||
if (!unit_has_cursed_item(u)
|
||||
&& !has_skill(u, SK_MAGIC)
|
||||
&& !has_skill(u, SK_ALCHEMY)) {
|
||||
&& !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY)) {
|
||||
u_setfaction(u, f2);
|
||||
}
|
||||
u = un;
|
||||
|
@ -1669,10 +1669,12 @@ rename_building(unit * u, order * ord, building * b, const char *name)
|
|||
|
||||
if (owner) {
|
||||
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));
|
||||
} else {
|
||||
ADDMSG(&owner->faction->msgs, msg_message("renamed_building_notseen",
|
||||
ADDMSG(&owner->faction->msgs,
|
||||
msg_message("renamed_building_notseen",
|
||||
"building region", b, u->region));
|
||||
}
|
||||
}
|
||||
|
@ -1738,8 +1740,7 @@ static int name_cmd(unit * u, struct order *ord)
|
|||
for (; lang; lang = nextlocale(lang)) {
|
||||
const char *fdname = LOC(lang, "factiondefault");
|
||||
size_t fdlen = strlen(fdname);
|
||||
if (strlen(f->name) >= fdlen
|
||||
&& strncmp(f->name, fdname, fdlen) == 0) {
|
||||
if (strlen(f->name) >= fdlen && strncmp(f->name, fdname, fdlen) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1749,8 +1750,8 @@ static int name_cmd(unit * u, struct order *ord)
|
|||
}
|
||||
}
|
||||
if (cansee(f, r, u, 0)) {
|
||||
ADDMSG(&f->msgs, msg_message("renamed_faction_seen", "unit region", u,
|
||||
r));
|
||||
ADDMSG(&f->msgs,
|
||||
msg_message("renamed_faction_seen", "unit region", u, r));
|
||||
} else {
|
||||
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);
|
||||
if (uo) {
|
||||
if (cansee(uo->faction, r, u, 0)) {
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_seen",
|
||||
"ship renamer region", sh, u, r));
|
||||
ADDMSG(&uo->faction->msgs,
|
||||
msg_message("renamed_ship_seen", "ship renamer region", sh, u, r));
|
||||
} else {
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_notseen",
|
||||
"ship region", sh, r));
|
||||
ADDMSG(&uo->faction->msgs,
|
||||
msg_message("renamed_ship_notseen", "ship region", sh, r));
|
||||
}
|
||||
}
|
||||
s = &sh->name;
|
||||
|
@ -1898,10 +1899,11 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
|||
u = NULL;
|
||||
}
|
||||
if (!receiver) { /* BOTSCHAFT an PARTEI */
|
||||
ADDMSG(&f->msgs, msg_message("regionmessage", "region sender string", r, u,
|
||||
s));
|
||||
ADDMSG(&f->msgs,
|
||||
msg_message("regionmessage", "region sender string", r, u, s));
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
|
@ -1917,8 +1919,8 @@ mailunit(region * r, unit * u, int n, struct order *ord, const char *s)
|
|||
} else {
|
||||
/* Immer eine Meldung - sonst könnte man so getarnte EHs enttarnen:
|
||||
* 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;
|
||||
break;
|
||||
}
|
||||
} while (cont);
|
||||
}
|
||||
while (cont);
|
||||
cmistake(u, ord, 149, MSG_MESSAGE);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2126,8 +2129,8 @@ static int email_cmd(unit * u, struct order *ord)
|
|||
} else {
|
||||
faction *f = u->faction;
|
||||
if (set_email(&f->email, (const char *)s) != 0) {
|
||||
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no),
|
||||
s));
|
||||
log_error(("Invalid email address for faction %s: %s\n",
|
||||
itoa36(f->no), s));
|
||||
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
|
||||
} else {
|
||||
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) {
|
||||
case AT_STANDARD:
|
||||
bytes =
|
||||
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"),
|
||||
rc->def_damage);
|
||||
snprintf(bufp, size, "%s (%s)",
|
||||
LOC(f->locale, "attack_standard"), rc->def_damage);
|
||||
break;
|
||||
case AT_NATURAL:
|
||||
bytes =
|
||||
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"),
|
||||
rc->attack[a].data.dice);
|
||||
snprintf(bufp, size, "%s (%s)",
|
||||
LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
|
||||
break;
|
||||
case AT_SPELL:
|
||||
case AT_COMBATSPELL:
|
||||
|
@ -2388,8 +2391,8 @@ static boolean display_race(faction * f, unit * u, const race * rc)
|
|||
break;
|
||||
case AT_STRUCTURAL:
|
||||
bytes =
|
||||
snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"),
|
||||
rc->attack[a].data.dice);
|
||||
snprintf(bufp, size, "%s (%s)",
|
||||
LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
|
||||
break;
|
||||
default:
|
||||
bytes = 0;
|
||||
|
@ -2482,7 +2485,8 @@ static int promotion_cmd(unit * u, struct order *ord)
|
|||
}
|
||||
|
||||
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)));
|
||||
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);
|
||||
|
||||
if (people > money) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "heroes_cost", "cost have",
|
||||
people, money));
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "heroes_cost", "cost have", people, money));
|
||||
return 0;
|
||||
}
|
||||
use_pooled(u, i_silver->rtype, GET_ALL, people);
|
||||
|
@ -2710,7 +2714,8 @@ static int guard_on_cmd(unit * u, struct order *ord)
|
|||
} else {
|
||||
if (fval(u, UFL_MOVED)) {
|
||||
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);
|
||||
} else {
|
||||
/* 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)
|
||||
|| get_captain(sh) == NULL)) {
|
||||
/* Schiff nicht seetüchtig */
|
||||
float dmg =
|
||||
get_param_flt(global.parameters, "rules.ship.damage.nocrewocean",
|
||||
float dmg = get_param_flt(global.parameters,
|
||||
"rules.ship.damage.nocrewocean",
|
||||
0.30F);
|
||||
damage_ship(sh, dmg);
|
||||
}
|
||||
if (shipowner(sh) == NULL) {
|
||||
float dmg =
|
||||
get_param_flt(global.parameters, "rules.ship.damage.nocrew", 0.05F);
|
||||
float dmg = get_param_flt(global.parameters, "rules.ship.damage.nocrew",
|
||||
0.05F);
|
||||
damage_ship(sh, dmg);
|
||||
}
|
||||
}
|
||||
|
@ -2872,6 +2877,8 @@ static void reorder(void)
|
|||
*up = u->next;
|
||||
u->next = v->next;
|
||||
v->next = u;
|
||||
fset(u, UFL_MARK);
|
||||
sorted = true;
|
||||
break;
|
||||
case P_BEFORE:
|
||||
if (fval(v, UFL_OWNER)) {
|
||||
|
@ -2884,10 +2891,13 @@ static void reorder(void)
|
|||
*up = u->next;
|
||||
u->next = v;
|
||||
}
|
||||
break;
|
||||
}
|
||||
fset(u, UFL_MARK);
|
||||
sorted = true;
|
||||
break;
|
||||
default:
|
||||
/* TODO: syntax error message? */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2898,11 +2908,12 @@ static void reorder(void)
|
|||
}
|
||||
if (sorted) {
|
||||
unit *u;
|
||||
for (u = r->units; u; u = u->next)
|
||||
for (u = r->units; u; u = u->next) {
|
||||
freset(u, UFL_MARK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Aus Gebäude weisen, VERBANNE */
|
||||
|
@ -3118,8 +3129,8 @@ static building *age_building(building * b)
|
|||
}
|
||||
if (unicorns) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("scunicorn",
|
||||
"unit amount rtype", u, unicorns,
|
||||
olditemtype[I_ELVENHORSE]->rtype));
|
||||
"unit amount rtype",
|
||||
u, unicorns, olditemtype[I_ELVENHORSE]->rtype));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3141,8 +3152,8 @@ static building *age_building(building * b)
|
|||
/* the mage reactivates the circle */
|
||||
c = create_curse(mage, &rt->attribs, ct_astralblock,
|
||||
(float)MAX(1, sk), MAX(1, sk / 2), effect, 0);
|
||||
ADDMSG(&r->msgs, msg_message("astralshield_activate",
|
||||
"region unit", r, mage));
|
||||
ADDMSG(&r->msgs,
|
||||
msg_message("astralshield_activate", "region unit", r, mage));
|
||||
}
|
||||
} else if (mage != NULL) {
|
||||
int sk = effskill(mage, SK_MAGIC);
|
||||
|
@ -3364,13 +3375,15 @@ static void new_units(void)
|
|||
|
||||
if (err) {
|
||||
if (err == 1) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, makeord,
|
||||
"too_many_units_in_alliance", "allowed",
|
||||
maxunits(u->faction)));
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, makeord,
|
||||
"too_many_units_in_alliance",
|
||||
"allowed", maxunits(u->faction)));
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, makeord,
|
||||
"too_many_units_in_faction", "allowed",
|
||||
maxunits(u->faction)));
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, makeord,
|
||||
"too_many_units_in_faction",
|
||||
"allowed", maxunits(u->faction)));
|
||||
}
|
||||
ordp = &makeord->next;
|
||||
|
||||
|
@ -3527,13 +3540,15 @@ static void setdefaults(unit * u)
|
|||
/* Wird je diese Ausschliesslichkeit aufgehoben, muss man aufpassen
|
||||
* mit der Reihenfolge von Kaufen, Verkaufen etc., damit es Spielern
|
||||
* nicht moeglich ist, Schulden zu machen. */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hunger)
|
||||
if (hunger) {
|
||||
return;
|
||||
|
||||
}
|
||||
/* Wenn die Einheit handelt, muß der Default-Befehl gelöscht
|
||||
* werden. */
|
||||
|
||||
|
@ -3590,6 +3605,8 @@ static double heal_factor(const unit * u)
|
|||
return elf_regen;
|
||||
}
|
||||
return 1.0;
|
||||
default:
|
||||
return 1.0;
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
@ -3630,8 +3647,8 @@ static void monthly_healing(void)
|
|||
if (fval(u, UFL_HUNGER))
|
||||
continue;
|
||||
|
||||
if (fval(r->terrain, SEA_REGION) && u->ship == NULL && !(canswim(u)
|
||||
|| canfly(u))) {
|
||||
if (fval(r->terrain, SEA_REGION) && u->ship == NULL
|
||||
&& !(canswim(u) || canfly(u))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,9 +104,7 @@ boolean is_migrant(unit * u)
|
|||
/* ------------------------------------------------------------- */
|
||||
boolean magic_lowskill(unit * u)
|
||||
{
|
||||
if (u->race == new_race[RC_TOAD])
|
||||
return true;
|
||||
return false;
|
||||
return (u->race == new_race[RC_TOAD]) ? true : false;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -121,23 +119,22 @@ int study_cost(unit * u, skill_t sk)
|
|||
sprintf(buffer, "skills.cost.%s", skillnames[sk]);
|
||||
cost[sk] = get_param_int(global.parameters, buffer, -1);
|
||||
}
|
||||
if (cost[sk] >= 0)
|
||||
if (cost[sk] >= 0) {
|
||||
return cost[sk];
|
||||
|
||||
}
|
||||
switch (sk) {
|
||||
case SK_SPY:
|
||||
return 100;
|
||||
break;
|
||||
case SK_TACTICS:
|
||||
case SK_HERBALISM:
|
||||
case SK_ALCHEMY:
|
||||
return 200;
|
||||
break;
|
||||
case SK_MAGIC: /* Die Magiekosten betragen 50+Summe(50*Stufe) */
|
||||
/* 'Stufe' ist dabei die nächste zu erreichende Stufe */
|
||||
stufe = 1 + get_level(u, SK_MAGIC);
|
||||
return k * (1 + ((stufe + 1) * stufe / 2));
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1324,10 +1324,9 @@ void do_misc(region * r, boolean lasttry)
|
|||
for (uc = r->units; uc; uc = uc->next) {
|
||||
order *ord;
|
||||
for (ord = uc->orders; ord; ord = ord->next) {
|
||||
switch (get_keyword(ord)) {
|
||||
case K_CONTACT:
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
if (kwd == K_CONTACT) {
|
||||
contact_cmd(uc, ord, lasttry);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -587,15 +587,11 @@ int skill_limit(faction * f, skill_t sk)
|
|||
return fl;
|
||||
}
|
||||
}
|
||||
switch (sk) {
|
||||
case SK_MAGIC:
|
||||
if (sk == SK_MAGIC) {
|
||||
m = max_magicians(f);
|
||||
break;
|
||||
case SK_ALCHEMY:
|
||||
m =
|
||||
get_param_int(global.parameters, "rules.maxskills.alchemy",
|
||||
} else if (sk == SK_ALCHEMY) {
|
||||
m = get_param_int(global.parameters, "rules.maxskills.alchemy",
|
||||
MAXALCHEMISTS);
|
||||
break;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
@ -607,10 +603,11 @@ int count_skill(faction * f, skill_t sk)
|
|||
|
||||
for (u = f->units; u; u = u->nextF) {
|
||||
if (has_skill(u, sk)) {
|
||||
if (!is_familiar(u))
|
||||
if (!is_familiar(u)) {
|
||||
n += u->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
const char *s = getstrtoken();
|
||||
param_t param;
|
||||
|
||||
/* 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
|
||||
* nummer suchen, doch dort steht bei temp-units nur "temp" drinnen! */
|
||||
|
||||
switch (findparam(s, f->locale)) {
|
||||
case P_TEMP:
|
||||
param = findparam(s, f->locale);
|
||||
if (param == P_TEMP) {
|
||||
return read_newunitid(f, r);
|
||||
}
|
||||
if (!s || *s == 0)
|
||||
|
@ -2502,6 +2500,9 @@ unsigned int guard_flags(const unit * u)
|
|||
case RC_IRONKEEPER:
|
||||
flags = GUARD_MINING;
|
||||
break;
|
||||
default:
|
||||
/* TODO: This should be configuration variables, all of it */
|
||||
break;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
|
|
@ -1694,8 +1694,7 @@ verify_targets(castorder * co, int *invalid, int *resist, int *success)
|
|||
spobj->flag = TARGET_RESISTS;
|
||||
++*resist;
|
||||
ADDMSG(&mage->faction->msgs, msg_message("spellunitresists",
|
||||
"unit region command target",
|
||||
mage, mage->region, co->order, u));
|
||||
"unit region command target", mage, mage->region, co->order, u));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2485,6 +2484,8 @@ static boolean is_moving_ship(const region * r, const ship * sh)
|
|||
case K_MOVE:
|
||||
case K_FOLLOW:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1334,6 +1334,8 @@ static int movement_speed(unit * u)
|
|||
case RC_BIRTHDAYDRAGON:
|
||||
case RC_SONGDRAGON:
|
||||
return BP_DRAGON;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!init) {
|
||||
|
@ -2565,9 +2567,7 @@ void movement(void)
|
|||
}
|
||||
kword = get_keyword(u->thisorder);
|
||||
|
||||
switch (kword) {
|
||||
case K_ROUTE:
|
||||
case K_MOVE:
|
||||
if (kword == K_ROUTE || kword == K_MOVE) {
|
||||
/* after moving, the unit has no thisorder. this prevents
|
||||
* it from moving twice (or getting error messages twice).
|
||||
* UFL_NOTMOVING is set in combat if the unit is not allowed
|
||||
|
@ -2602,7 +2602,6 @@ void movement(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (u->region == r) {
|
||||
/* not moved, use next unit */
|
||||
|
|
|
@ -396,8 +396,6 @@ boolean is_repeated(const order * ord)
|
|||
case K_TEACH:
|
||||
case K_BREED:
|
||||
case K_PIRACY:
|
||||
return true;
|
||||
|
||||
case K_PLANT:
|
||||
return true;
|
||||
|
||||
|
@ -428,6 +426,8 @@ boolean is_repeated(const order * ord)
|
|||
if (param != P_TEMP)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -464,8 +464,6 @@ boolean is_exclusive(const order * ord)
|
|||
case K_TEACH:
|
||||
case K_BREED:
|
||||
case K_PIRACY:
|
||||
return true;
|
||||
|
||||
case K_PLANT:
|
||||
return true;
|
||||
|
||||
|
@ -496,6 +494,8 @@ boolean is_exclusive(const order * ord)
|
|||
if (param != P_TEMP)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -534,8 +534,6 @@ boolean is_long(const order * ord)
|
|||
case K_TEACH:
|
||||
case K_BREED:
|
||||
case K_PIRACY:
|
||||
return true;
|
||||
|
||||
case K_PLANT:
|
||||
return true;
|
||||
|
||||
|
@ -566,6 +564,8 @@ boolean is_long(const order * ord)
|
|||
if (param != P_TEMP)
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -593,9 +593,11 @@ boolean is_persistent(const order * ord)
|
|||
case K_KOMMENTAR:
|
||||
case K_LIEFERE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return persist || is_repeated(ord);
|
||||
}
|
||||
|
||||
return persist || is_repeated(ord);
|
||||
}
|
||||
|
||||
char *write_order(const order * ord, char *buffer, size_t size)
|
||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#ifndef H_KRNL_REPORTS
|
||||
#define H_KRNL_REPORTS
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
|
@ -175,13 +175,11 @@ int freadstr(FILE * F, int encoding, char *start, size_t size)
|
|||
char inbuf = (char)c;
|
||||
size_t inbytes = 1;
|
||||
size_t outbytes = size - (str - start);
|
||||
int ret =
|
||||
unicode_latin1_to_utf8(str, &outbytes, &inbuf, &inbytes);
|
||||
int ret = unicode_latin1_to_utf8(str, &outbytes, &inbuf, &inbytes);
|
||||
if (ret > 0)
|
||||
str += ret;
|
||||
else {
|
||||
log_error(
|
||||
("input data was not iso-8859-1! assuming utf-8\n"));
|
||||
log_error(("input data was not iso-8859-1! assuming utf-8\n"));
|
||||
encoding = XML_CHAR_ENCODING_ERROR;
|
||||
*str++ = (char)c;
|
||||
}
|
||||
|
@ -314,9 +312,14 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
|
|||
} else {
|
||||
quit = false;
|
||||
}
|
||||
}
|
||||
if (quit)
|
||||
break;
|
||||
default:
|
||||
/* TODO: syntax error message */
|
||||
break;
|
||||
}
|
||||
if (quit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Nun wird der Befehl erzeut und eingehängt */
|
||||
*ordp = parse_order(s, u->faction->locale);
|
||||
|
|
|
@ -223,13 +223,15 @@ int rc_skillmod(const struct race *rc, const region * r, skill_t sk)
|
|||
{
|
||||
int mods;
|
||||
|
||||
if (!skill_enabled[sk])
|
||||
if (!skill_enabled[sk]) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef FASTER_SKILLMOD
|
||||
unsigned int index = hashstring(rc->_name[0]) % RCMODMAXHASH;
|
||||
struct skillmods **imods = &modhash[index];
|
||||
while (*imods && (*imods)->race != rc)
|
||||
while (*imods && (*imods)->race != rc) {
|
||||
imods = &(*imods)->next;
|
||||
}
|
||||
if (*imods == NULL) {
|
||||
*imods = init_skills(rc);
|
||||
}
|
||||
|
@ -237,21 +239,19 @@ int rc_skillmod(const struct race *rc, const region * r, skill_t sk)
|
|||
#else
|
||||
mods = skill_mod(rc, sk, r->terrain);
|
||||
#endif
|
||||
if (rc == new_race[RC_ELF] && r_isforest(r))
|
||||
switch (sk) {
|
||||
case SK_PERCEPTION:
|
||||
if (rc == new_race[RC_ELF] && r_isforest(r)) {
|
||||
if (sk == SK_PERCEPTION) {
|
||||
++mods;
|
||||
break;
|
||||
case SK_STEALTH:
|
||||
if (r_isforest(r))
|
||||
} else if (sk == SK_STEALTH) {
|
||||
if (r_isforest(r)) {
|
||||
++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;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ enum {
|
|||
XMLSPL_WDWPYRAMID_ASTRAL = 185,
|
||||
XMLSPL_WDWPYRAMID_DRUIDE = 186,
|
||||
XMLSPL_WDWPYRAMID_BARDE = 187,
|
||||
XMLSPL_WDWPYRAMID_CHAOS = 188,
|
||||
XMLSPL_WDWPYRAMID_CHAOS = 188
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -60,7 +60,7 @@ static int txt_w_flt(struct storage *store, float arg)
|
|||
static float txt_r_flt(struct storage *store)
|
||||
{
|
||||
double result;
|
||||
fscanf((FILE *) store->userdata, "%f", &result);
|
||||
fscanf((FILE *) store->userdata, "%lf", &result);
|
||||
return (float)result;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,18 +89,17 @@ int xecmd(unit * u, order * ord)
|
|||
|
||||
if (a_find(f->attribs, &at_xontormiaexpress)) {
|
||||
if (get_keyword(ord) == K_XE) {
|
||||
param_t param;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
switch (findparam(getstrtoken(), f->locale)) {
|
||||
case P_XEPOTION:
|
||||
param = findparam(getstrtoken(), f->locale);
|
||||
if (param == P_XEPOTION) {
|
||||
xe_givepotion(u, ord);
|
||||
break;
|
||||
case P_XEBALLOON:
|
||||
} else if (param == P_XEBALLOON) {
|
||||
xe_giveballon(u, ord);
|
||||
break;
|
||||
case P_XELAEN:
|
||||
} else if (param == P_XELAEN) {
|
||||
xe_givelaen(u, ord);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue