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 <math.h>
#include <stdio.h>
#include <lua.h>
#include <tolua.h>

View file

@ -77,8 +77,8 @@ int log_lua_error(lua_State * L)
int tolua_orderlist_next(lua_State * L)
{
order ** order_ptr = (order **) lua_touserdata(L, lua_upvalueindex(1));
order * ord = *order_ptr;
order **order_ptr = (order **) lua_touserdata(L, lua_upvalueindex(1));
order *ord = *order_ptr;
if (ord != NULL) {
char cmd[8192];
write_order(ord, cmd, sizeof(cmd));
@ -91,8 +91,8 @@ int tolua_orderlist_next(lua_State * L)
static int tolua_quicklist_iter(lua_State * L)
{
quicklist ** qlp = (quicklist **) lua_touserdata(L, lua_upvalueindex(1));
quicklist * ql = *qlp;
quicklist **qlp = (quicklist **) lua_touserdata(L, lua_upvalueindex(1));
quicklist *ql = *qlp;
if (ql != NULL) {
int index = lua_tointeger(L, lua_upvalueindex(2));
const char *type = lua_tostring(L, lua_upvalueindex(3));
@ -110,7 +110,7 @@ int tolua_quicklist_push(struct lua_State *L, const char *list_type,
const char *elem_type, struct quicklist *list)
{
if (list) {
quicklist ** qlist_ptr =
quicklist **qlist_ptr =
(quicklist **) lua_newuserdata(L, sizeof(quicklist *));
*qlist_ptr = list;
luaL_getmetatable(L, list_type);
@ -126,8 +126,8 @@ int tolua_quicklist_push(struct lua_State *L, const char *list_type,
int tolua_itemlist_next(lua_State * L)
{
item ** item_ptr = (item **) lua_touserdata(L, lua_upvalueindex(1));
item * itm = *item_ptr;
item **item_ptr = (item **) lua_touserdata(L, lua_upvalueindex(1));
item *itm = *item_ptr;
if (itm != NULL) {
tolua_pushstring(L, itm->type->rtype->_name[0]);
*item_ptr = itm->next;
@ -140,7 +140,7 @@ static int tolua_autoseed(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
int new_island = tolua_toboolean(L, 2, 0);
newfaction * players = read_newfactions(filename);
newfaction *players = read_newfactions(filename);
if (players != NULL) {
while (players) {
int n = listlen(players);
@ -159,7 +159,7 @@ static int tolua_getkey(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
int flag = atoi36(name);
attrib * a = find_key(global.attribs, flag);
attrib *a = find_key(global.attribs, flag);
lua_pushboolean(L, a != NULL);
return 1;
}
@ -182,7 +182,7 @@ static int tolua_setkey(lua_State * L)
const char *name = tolua_tostring(L, 1, 0);
int value = tolua_toboolean(L, 2, 0);
int flag = atoi36(name);
attrib * a = find_key(global.attribs, flag);
attrib *a = find_key(global.attribs, flag);
if (a == NULL && value) {
add_key(&global.attribs, flag);
} else if (a != NULL && !value) {
@ -207,8 +207,8 @@ static int tolua_read_orders(lua_State * L)
static int tolua_message_unit(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
unit * target = (unit *) tolua_tousertype(L, 2, 0);
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
unit *target = (unit *) tolua_tousertype(L, 2, 0);
const char *str = tolua_tostring(L, 3, 0);
if (!target)
tolua_error(L, TOLUA_CAST "target is nil", NULL);
@ -220,8 +220,8 @@ static int tolua_message_unit(lua_State * L)
static int tolua_message_faction(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
faction * target = (faction *) tolua_tousertype(L, 2, 0);
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
faction *target = (faction *) tolua_tousertype(L, 2, 0);
const char *str = tolua_tostring(L, 3, 0);
if (!target)
tolua_error(L, TOLUA_CAST "target is nil", NULL);
@ -233,7 +233,7 @@ static int tolua_message_faction(lua_State * L)
static int tolua_message_region(lua_State * L)
{
unit * sender = (unit *) tolua_tousertype(L, 1, 0);
unit *sender = (unit *) tolua_tousertype(L, 1, 0);
const char *str = tolua_tostring(L, 2, 0);
if (!sender)
tolua_error(L, TOLUA_CAST "sender is nil", NULL);
@ -309,23 +309,23 @@ static int tolua_get_season(lua_State * L)
static int tolua_create_curse(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
unit *u = (unit *) tolua_tousertype(L, 1, 0);
tolua_Error tolua_err;
attrib ** ap = NULL;
attrib **ap = NULL;
if (tolua_isusertype(L, 2, TOLUA_CAST "unit", 0, &tolua_err)) {
unit * target = (unit *) tolua_tousertype(L, 2, 0);
unit *target = (unit *) tolua_tousertype(L, 2, 0);
if (target)
ap = &target->attribs;
} else if (tolua_isusertype(L, 2, TOLUA_CAST "region", 0, &tolua_err)) {
region * target = (region *) tolua_tousertype(L, 2, 0);
region *target = (region *) tolua_tousertype(L, 2, 0);
if (target)
ap = &target->attribs;
} else if (tolua_isusertype(L, 2, TOLUA_CAST "ship", 0, &tolua_err)) {
ship * target = (ship *) tolua_tousertype(L, 2, 0);
ship *target = (ship *) tolua_tousertype(L, 2, 0);
if (target)
ap = &target->attribs;
} else if (tolua_isusertype(L, 2, TOLUA_CAST "building", 0, &tolua_err)) {
building * target = (building *) tolua_tousertype(L, 2, 0);
building *target = (building *) tolua_tousertype(L, 2, 0);
if (target)
ap = &target->attribs;
}
@ -337,7 +337,7 @@ static int tolua_create_curse(lua_State * L)
int duration = (int)tolua_tonumber(L, 5, 0);
double effect = tolua_tonumber(L, 6, 0);
int men = (int)tolua_tonumber(L, 7, 0); /* optional */
curse * c = create_curse(u, ap, ctype, vigour, duration, effect, men);
curse *c = create_curse(u, ap, ctype, vigour, duration, effect, men);
if (c) {
tolua_pushboolean(L, true);
return 1;
@ -350,7 +350,7 @@ static int tolua_create_curse(lua_State * L)
static int tolua_learn_skill(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
unit *u = (unit *) tolua_tousertype(L, 1, 0);
const char *skname = tolua_tostring(L, 2, 0);
float chances = (float)tolua_tonumber(L, 3, 0);
skill_t sk = sk_find(skname);
@ -368,7 +368,7 @@ static int tolua_update_scores(lua_State * L)
static int tolua_update_owners(lua_State * L)
{
region * r;
region *r;
for (r = regions; r; r = r->next) {
update_owners(r);
}
@ -403,7 +403,7 @@ static int tolua_get_nmrs(lua_State * L)
static int tolua_equipunit(lua_State * L)
{
unit * u = (unit *) tolua_tousertype(L, 1, 0);
unit *u = (unit *) tolua_tousertype(L, 1, 0);
const char *eqname = tolua_tostring(L, 2, 0);
equip_unit(u, get_equipment(eqname));
return 0;
@ -442,7 +442,7 @@ static int tolua_init_reports(lua_State * L)
static int tolua_write_report(lua_State * L)
{
faction * f = (faction *) tolua_tousertype(L, 1, 0);
faction *f = (faction *) tolua_tousertype(L, 1, 0);
time_t ltime = time(0);
int result = write_reports(f, ltime);
tolua_pushnumber(L, (lua_Number) result);
@ -460,11 +460,11 @@ static int tolua_write_reports(lua_State * L)
static void reset_game(void)
{
region * r;
faction * f;
region *r;
faction *f;
for (r = regions; r; r = r->next) {
unit * u;
building * b;
unit *u;
building *b;
r->flags &= RF_SAVEMASK;
for (u = r->units; u; u = u->next) {
u->flags &= UFL_SAVEMASK;
@ -473,7 +473,7 @@ static void reset_game(void)
b->flags &= BLD_SAVEMASK;
}
if (r->land && r->land->ownership && r->land->ownership->owner) {
faction * owner = r->land->ownership->owner;
faction *owner = r->land->ownership->owner;
if (owner == get_monsters()) {
/* some compat-fix, i believe. */
owner = update_owners(r);
@ -571,7 +571,7 @@ static int tolua_read_turn(lua_State * L)
static int tolua_get_faction(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
faction * f = findfaction(no);
faction *f = findfaction(no);
tolua_pushusertype(L, f, TOLUA_CAST "faction");
return 1;
}
@ -580,7 +580,7 @@ static int tolua_get_region(lua_State * L)
{
int x = (int)tolua_tonumber(L, 1, 0);
int y = (int)tolua_tonumber(L, 2, 0);
region * r;
region *r;
assert(!pnormalize(&x, &y, findplane(x, y)));
r = findregion(x, y);
tolua_pushusertype(L, r, TOLUA_CAST "region");
@ -590,7 +590,7 @@ static int tolua_get_region(lua_State * L)
static int tolua_get_region_byid(lua_State * L)
{
int uid = (int)tolua_tonumber(L, 1, 0);
region * r = findregionbyid(uid);
region *r = findregionbyid(uid);
tolua_pushusertype(L, r, TOLUA_CAST "region");
return 1;
}
@ -598,7 +598,7 @@ static int tolua_get_region_byid(lua_State * L)
static int tolua_get_building(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
building * b = findbuilding(no);
building *b = findbuilding(no);
tolua_pushusertype(L, b, TOLUA_CAST "building");
return 1;
}
@ -606,7 +606,7 @@ static int tolua_get_building(lua_State * L)
static int tolua_get_ship(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
ship * sh = findship(no);
ship *sh = findship(no);
tolua_pushusertype(L, sh, TOLUA_CAST "ship");
return 1;
}
@ -614,7 +614,7 @@ static int tolua_get_ship(lua_State * L)
static int tolua_get_alliance(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
alliance * f = findalliance(no);
alliance *f = findalliance(no);
tolua_pushusertype(L, f, TOLUA_CAST "alliance");
return 1;
}
@ -622,7 +622,7 @@ static int tolua_get_alliance(lua_State * L)
static int tolua_get_unit(lua_State * L)
{
int no = tolua_toid(L, 1, 0);
unit * u = findunit(no);
unit *u = findunit(no);
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}
@ -631,14 +631,14 @@ static int tolua_alliance_create(lua_State * L)
{
int id = (int)tolua_tonumber(L, 1, 0);
const char *name = tolua_tostring(L, 2, 0);
alliance * alli = makealliance(id, name);
alliance *alli = makealliance(id, name);
tolua_pushusertype(L, alli, TOLUA_CAST "alliance");
return 1;
}
static int tolua_get_regions(lua_State * L)
{
region ** region_ptr = (region **) lua_newuserdata(L, sizeof(region *));
region **region_ptr = (region **) lua_newuserdata(L, sizeof(region *));
luaL_getmetatable(L, "region");
lua_setmetatable(L, -2);
*region_ptr = regions;
@ -648,7 +648,7 @@ static int tolua_get_regions(lua_State * L)
static int tolua_get_factions(lua_State * L)
{
faction ** faction_ptr = (faction **) lua_newuserdata(L, sizeof(faction *));
faction **faction_ptr = (faction **) lua_newuserdata(L, sizeof(faction *));
luaL_getmetatable(L, "faction");
lua_setmetatable(L, -2);
*faction_ptr = factions;
@ -658,32 +658,31 @@ static int tolua_get_factions(lua_State * L)
static int tolua_get_alliance_factions(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
return tolua_quicklist_push(L, "faction_list", "faction", self->members);
}
static int tolua_get_alliance_id(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
tolua_pushnumber(L, (lua_Number) self->id);
return 1;
}
static int tolua_get_alliance_name(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
tolua_pushstring(L, self->name);
return 1;
}
static int tolua_set_alliance_name(lua_State * L)
{
alliance * self = (alliance *) tolua_tousertype(L, 1, 0);
alliance *self = (alliance *) tolua_tousertype(L, 1, 0);
alliance_setname(self, tolua_tostring(L, 2, 0));
return 0;
}
#include <libxml/tree.h>
#include <util/functions.h>
#include <util/xml.h>
@ -694,10 +693,10 @@ static int tolua_write_spells(lua_State * L)
const char *filename = "magic.xml";
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
xmlNodePtr root = xmlNewNode(NULL, BAD_CAST "spells");
quicklist * ql;
quicklist *ql;
int qi;
for (ql = spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spell * sp = (spell *) ql_get(ql, qi);
spell *sp = (spell *) ql_get(ql, qi);
if (sp->sp_function != fun) {
int combat = 0;
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "spell");
@ -711,7 +710,7 @@ static int tolua_write_spells(lua_State * L)
if (sp->parameter)
xmlNewProp(node, BAD_CAST "parameters", BAD_CAST sp->parameter);
if (sp->components) {
spell_component * comp = sp->components;
spell_component *comp = sp->components;
for (; comp->type != 0; ++comp) {
static const char *costs[] = { "fixed", "level", "linear" };
xmlNodePtr cnode = xmlNewNode(NULL, BAD_CAST "resource");
@ -758,11 +757,11 @@ static int tolua_write_spells(lua_State * L)
static int config_get_ships(lua_State * L)
{
quicklist * ql;
quicklist *ql;
int qi, i = 0;
lua_createtable(L, ql_length(shiptypes), 0);
for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) {
ship_type * stype = (ship_type *) ql_get(ql, qi);
ship_type *stype = (ship_type *) ql_get(ql, qi);
tolua_pushstring(L, TOLUA_CAST stype->name[0]);
lua_rawseti(L, -2, ++i);
}
@ -827,21 +826,21 @@ static int config_get_resource(lua_State * L)
static int tolua_get_spell_text(lua_State * L)
{
const struct locale *loc = default_locale;
spell * self = (spell *) tolua_tousertype(L, 1, 0);
spell *self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, spell_info(self, loc));
return 1;
}
static int tolua_get_spell_school(lua_State * L)
{
spell * self = (spell *) tolua_tousertype(L, 1, 0);
spell *self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, magic_school[self->magietyp]);
return 1;
}
static int tolua_get_spell_level(lua_State * L)
{
spell * self = (spell *) tolua_tousertype(L, 1, 0);
spell *self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushnumber(L, self->level);
return 1;
}
@ -849,7 +848,7 @@ static int tolua_get_spell_level(lua_State * L)
static int tolua_get_spell_name(lua_State * L)
{
const struct locale *lang = default_locale;
spell * self = (spell *) tolua_tousertype(L, 1, 0);
spell *self = (spell *) tolua_tousertype(L, 1, 0);
lua_pushstring(L, spell_name(self, lang));
return 1;
}
@ -875,7 +874,7 @@ int tolua_process_markets(lua_State * L)
int tolua_process_produce(lua_State * L)
{
region * r;
region *r;
for (r = regions; r; r = r->next) {
produce(r);
}
@ -895,8 +894,8 @@ static void args_free(void *udata)
static void event_cb(void *sender, const char *event, void *udata)
{
lua_State * L = (lua_State *) global.vm_state;
event_args * args = (event_args *) udata;
lua_State *L = (lua_State *) global.vm_state;
event_args *args = (event_args *) udata;
int nargs = 2;
lua_rawgeti(L, LUA_REGISTRYINDEX, args->hfunction);
if (sender && args->sendertype) {
@ -922,7 +921,7 @@ static int tolua_eventbus_register(lua_State * L)
{
void *sender = tolua_tousertype(L, 1, 0);
const char *event = tolua_tostring(L, 2, 0);
event_args * args = malloc(sizeof(event_args));
event_args *args = malloc(sizeof(event_args));
args->sendertype = sender ? tolua_typename(L, 1) : NULL;
lua_pushvalue(L, 3);
args->hfunction = luaL_ref(L, LUA_REGISTRYINDEX);
@ -948,8 +947,8 @@ static int tolua_eventbus_fire(lua_State * L)
static int tolua_report_unit(lua_State * L)
{
char buffer[512];
unit * u = (unit *) tolua_tousertype(L, 1, 0);
faction * f = (faction *) tolua_tousertype(L, 2, 0);
unit *u = (unit *) tolua_tousertype(L, 1, 0);
faction *f = (faction *) tolua_tousertype(L, 2, 0);
bufunit(f, u, 0, see_unit, buffer, sizeof(buffer));
tolua_pushstring(L, buffer);
return 1;
@ -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);

View file

@ -130,8 +130,9 @@ 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) {

View file

@ -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,10 +2908,11 @@ 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
@ -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;
}

View file

@ -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;
}

View file

@ -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;
}
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 */

View file

@ -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)

View file

@ -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

View file

@ -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);

View file

@ -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;
}

View file

@ -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

View file

@ -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;
}
@ -154,7 +154,7 @@ static int txt_open(struct storage *store, const char *filename, int mode)
store->version = atoi(token);
}
} else if (store->encoding == XML_CHAR_ENCODING_UTF8) {
fputs((const char*)utf8_bom, F);
fputs((const char *)utf8_bom, F);
fprintf(F, "%d\n", RELEASE_VERSION);
}
}

View file

@ -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;
}
}
}