enable stricter conversion checking for gcc < 4.9, fix code

This commit is contained in:
Enno Rehling 2015-05-15 20:35:36 +02:00
parent dd8449783a
commit df325b243a
24 changed files with 137 additions and 157 deletions

View file

@ -16,8 +16,9 @@ if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9)
message(STATUS "Version ${GCC_VERSION} >= 4.9")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wfloat-conversion")
else()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wno-sign-conversion")
endif()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")

View file

@ -1695,7 +1695,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
level = eff_skill(mage, SK_MAGIC, r);
if (level > 0) {
float power;
double power;
const spell *sp;
const struct locale *lang = mage->faction->locale;
order *ord;
@ -2497,14 +2497,14 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
static int loot_quota(const unit * src, const unit * dst,
const item_type * type, int n)
{
static float divisor = -1;
static double divisor = -1;
if (dst && src && src->faction != dst->faction) {
if (divisor < 0) {
divisor = get_param_flt(global.parameters, "rules.items.loot_divisor", 1);
assert(divisor == 0 || divisor >= 1);
}
if (divisor >= 1) {
double r = (float)n / divisor;
double r = n / divisor;
int x = (int)r;
r = r - x;

View file

@ -118,7 +118,7 @@ static int tolua_quicklist_iter(lua_State * L)
quicklist **qlp = (quicklist **)lua_touserdata(L, lua_upvalueindex(1));
quicklist *ql = *qlp;
if (ql != NULL) {
int index = lua_tointeger(L, lua_upvalueindex(2));
int index = (int)lua_tointeger(L, lua_upvalueindex(2));
const char *type = lua_tostring(L, lua_upvalueindex(3));
void *data = ql_get(ql, index);
tolua_pushusertype(L, data, TOLUA_CAST type);

View file

@ -62,7 +62,7 @@ without prior permission by the authors of Eressea.
#include <util/attrib.h>
#include <util/base36.h>
#include <util/crmessage.h>
#include <util/goodies.h>
#include <util/strings.h>
#include <util/language.h>
#include <util/log.h>
#include <util/message.h>

View file

@ -77,7 +77,7 @@ static WINDOW *hstatus;
static void init_curses(void)
{
short fg, bg;
int fg, bg;
initscr();
if (has_colors() || force_color) {
@ -93,7 +93,7 @@ static void init_curses(void)
#endif
for (fg = 0; fg != 8; ++fg) {
for (bg = 0; bg != 2; ++bg) {
init_pair(fg + 8 * bg, fg, bg ? hcol : bcol);
init_pair((short)(fg + 8 * bg), (short)fg, (short)(bg ? hcol : bcol));
}
}

View file

@ -174,7 +174,7 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f;
double rnd = (1 + rng_int() % 1000) / 1000.0;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {
@ -209,7 +209,7 @@ void equip_items(struct item **items, const struct equipment *eq)
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f;
double rnd = (1 + rng_int() % 1000) / 1000.0;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {

View file

@ -249,7 +249,7 @@ static order_data *create_data(keyword_t kwd, const char *sptr, int lindex)
return data;
}
static order *create_order_i(keyword_t kwd, const char *sptr, int persistent,
static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent,
const struct locale *lang)
{
order *ord = NULL;
@ -338,7 +338,7 @@ order *create_order(keyword_t kwd, const struct locale * lang,
else {
zBuffer[0] = 0;
}
return create_order_i(kwd, zBuffer, 0, lang);
return create_order_i(kwd, zBuffer, false, lang);
}
order *parse_order(const char *s, const struct locale * lang)
@ -351,11 +351,11 @@ order *parse_order(const char *s, const struct locale * lang)
if (*s != 0) {
keyword_t kwd;
const char *sptr;
int persistent = 0;
bool persistent = false;
const char * p;
while (*s == '@') {
persistent = 1;
persistent = true;
++s;
}
sptr = s;
@ -511,18 +511,15 @@ bool is_long(const order * ord)
bool is_persistent(const order * ord)
{
keyword_t kwd = ORD_KEYWORD(ord);
int persist = ord->_persistent != 0;
switch (kwd) {
case K_MOVE:
case NOKEYWORD:
/* lang, aber niemals persistent! */
return false;
case K_KOMMENTAR:
return true;
default:
return persist || is_repeated(ord);
return ord->_persistent || is_repeated(ord);
}
}

View file

@ -33,7 +33,7 @@ extern "C" {
struct order *next;
/* do not access this data: */
struct order_data *data;
int _persistent : 1;
bool _persistent;
} order;
/* constructor */

View file

@ -555,10 +555,10 @@ void rsetroad(region * r, direction_t d, int val)
b = new_border(&bt_road, r, r2);
}
if (r == b->from) {
b->data.sa[0] = val;
b->data.sa[0] = (short)val;
}
else {
b->data.sa[1] = val;
b->data.sa[1] = (short)val;
}
}

View file

@ -1008,7 +1008,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
* Spruchfunktionsroutine ermittelt.
*/
float
double
spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord)
{
curse *c;

View file

@ -131,7 +131,7 @@ extern "C" {
den Vertrauten gezaubert wird */
const struct spell *sp; /* Spruch */
int level; /* gewünschte Stufe oder Stufe des Magiers */
float force; /* Stärke des Zaubers */
double force; /* Stärke des Zaubers */
struct region *_rtarget; /* Zielregion des Spruchs */
int distance; /* Entfernung zur Zielregion */
struct order *order; /* Befehl */
@ -277,7 +277,7 @@ extern "C" {
/* verändert die maximalen Magiepunkte einer Einheit */
/* Zaubern */
extern float spellpower(struct region *r, struct unit *u, const struct spell * sp,
extern double spellpower(struct region *r, struct unit *u, const struct spell * sp,
int cast_level, struct order *ord);
/* ermittelt die Stärke eines Spruchs */
bool fumble(struct region *r, struct unit *u, const struct spell * sp,

View file

@ -71,12 +71,12 @@ static void test_regionid(CuTest * tc) {
memset(buffer, 0x7d, sizeof(buffer));
len = f_regionid(r, 0, buffer, sizeof(buffer));
CuAssertIntEquals(tc, 11, len);
CuAssertIntEquals(tc, 11, (int)len);
CuAssertStrEquals(tc, "plain (0,0)", buffer);
memset(buffer, 0x7d, sizeof(buffer));
len = f_regionid(r, 0, buffer, 11);
CuAssertIntEquals(tc, 10, len);
CuAssertIntEquals(tc, 10, (int)len);
CuAssertStrEquals(tc, "plain (0,0", buffer);
CuAssertIntEquals(tc, 0x7d, buffer[11]);
}

View file

@ -102,7 +102,7 @@
#include <attributes/hate.h>
/* ----------------------------------------------------------------------- */
static float zero_effect = 0.0F;
static double zero_effect = 0.0;
attrib_type at_wdwpyramid = {
"wdwpyramid", NULL, NULL, NULL, a_writevoid, a_readvoid
@ -636,7 +636,7 @@ static int sp_destroy_magic(castorder * co)
{
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
curse *c = NULL;
char ts[80];
@ -801,7 +801,7 @@ static int sp_goodwinds(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
int duration = cast_level + 1;
spellparameter *pa = co->par;
message *m;
@ -898,7 +898,7 @@ static int sp_summonent(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
unit *u;
attrib *a;
int ents;
@ -1124,7 +1124,7 @@ static int sp_hain(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
if (!r->land) {
cmistake(mage, co->order, 296, MSG_MAGIC);
@ -1170,7 +1170,7 @@ static int sp_mallornhain(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
if (!r->land) {
cmistake(mage, co->order, 296, MSG_MAGIC);
@ -1204,7 +1204,7 @@ static void fumble_ents(const castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
/* int cast_level = co->level; */
float force = co->force;
double force = co->force;
if (!r->land) {
cmistake(mage, co->order, 296, MSG_MAGIC);
@ -1368,10 +1368,10 @@ static int sp_kaelteschutz(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = _max(cast_level, (int)force) + 1;
spellparameter *pa = co->par;
float effect;
double effect;
force *= 10; /* 10 Personen pro Force-Punkt */
@ -1431,7 +1431,7 @@ static int sp_sparkle(castorder * co)
int cast_level = co->level;
spellparameter *pa = co->par;
int duration = cast_level + 1;
float effect;
double effect;
/* wenn kein Ziel gefunden, Zauber abbrechen */
if (pa->param[0]->flag == TARGET_NOTFOUND)
@ -1491,7 +1491,7 @@ static int sp_create_irongolem(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int number = lovar(force * 8 * RESOURCE_QUANTITY);
if (number < 1)
number = 1;
@ -1616,9 +1616,9 @@ static int sp_great_drought(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = 2;
float effect;
double effect;
if (fval(r->terrain, SEA_REGION)) {
cmistake(mage, co->order, 189, MSG_MAGIC);
@ -1743,7 +1743,7 @@ static int sp_treewalkenter(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
spellparameter *pa = co->par;
float power = co->force;
double power = co->force;
int cast_level = co->level;
region *rt;
int remaining_cap;
@ -1868,7 +1868,7 @@ static int sp_treewalkexit(castorder * co)
int erfolg = 0;
region *r = co_get_region(co);
unit *mage = co->magician.u;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
int cast_level = co->level;
@ -2007,7 +2007,7 @@ static int sp_holyground(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
message *msg = msg_message("sp_holyground_effect", "mage region", mage, r);
report_spell(mage, r, msg);
msg_release(msg);
@ -2042,8 +2042,8 @@ static int sp_homestone(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
float effect;
double force = co->force;
double effect;
message *msg;
if (!mage->building || mage->building->type != bt_find("castle")) {
cmistake(mage, co->order, 197, MSG_MAGIC);
@ -2101,7 +2101,7 @@ static int sp_drought(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
int duration = (int)power + 1;
message *msg;
@ -2126,7 +2126,7 @@ static int sp_drought(castorder * co)
c->duration = _max(c->duration, (int)power);
}
else {
float effect = 4.0;
double effect = 4.0;
/* Baeume und Pferde sterben */
rsettrees(r, 2, rtrees(r, 2) / 2);
rsettrees(r, 1, rtrees(r, 1) / 2);
@ -2222,7 +2222,7 @@ static int sp_stormwinds(castorder * co)
int erfolg = 0;
region *r = co_get_region(co);
unit *mage = co->magician.u;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
int n, force = (int)power;
message *m = NULL;
@ -2502,8 +2502,8 @@ static int sp_fumblecurse(castorder * co)
int duration;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
float effect;
double force = co->force;
double effect;
curse *c;
spellparameter *pa = co->par;
@ -2535,9 +2535,9 @@ void patzer_fumblecurse(const castorder * co)
{
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (cast_level / 2) + 1;
float effect;
double effect;
curse *c;
effect = force / 2;
@ -2574,7 +2574,7 @@ static int sp_summondragon(castorder * co)
unit *mage = co->magician.u;
unit *u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
region_list *rl, *rl2;
faction *f;
int time;
@ -2646,7 +2646,7 @@ static int sp_firewall(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
direction_t dir;
region *r2;
@ -2843,9 +2843,9 @@ static struct curse_type ct_deathcloud = {
NULL, dc_age
};
static curse *mk_deathcloud(unit * mage, region * r, float force, int duration)
static curse *mk_deathcloud(unit * mage, region * r, double force, int duration)
{
float effect;
double effect;
curse *c;
effect = force / 2;
@ -2878,7 +2878,7 @@ static int dc_read_compat(struct attrib *a, void *target, struct storage * store
r = findregion(rx, ry);
if (r != NULL) {
float effect;
double effect;
curse *c;
effect = strength;
@ -3024,7 +3024,7 @@ static int sp_summonshadow(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
unit *u;
int val, number = (int)(force * force);
@ -3065,7 +3065,7 @@ static int sp_summonshadowlords(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int amount = (int)(force * force);
u = create_unit(r, mage->faction, amount, get_race(RC_SHADOWLORD), 0,
@ -3192,8 +3192,8 @@ static int sp_magicboost(castorder * co)
curse *c;
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
float effect;
double power = co->force;
double effect;
trigger *tsummon;
static const curse_type *ct_auraboost;
static const curse_type *ct_magicboost;
@ -3425,7 +3425,7 @@ static int sp_analysesong_obj(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
obj = pa->param[0]->typ;
@ -3474,7 +3474,7 @@ static int sp_analysesong_unit(castorder * co)
unit *u;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -3559,7 +3559,7 @@ static int sp_charmingsong(castorder * co)
skill_t i;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
int resist_bonus = 0;
int tb = 0;
@ -3648,7 +3648,7 @@ static int sp_song_resistmagic(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
create_curse(mage, &r->attribs, ct_find("goodmagicresistancezone"),
@ -3677,7 +3677,7 @@ static int sp_song_susceptmagic(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
create_curse(mage, &r->attribs, ct_find("badmagicresistancezone"),
@ -3759,7 +3759,7 @@ static int sp_raisepeasantmob(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
faction *monsters = get_monsters();
message *msg;
@ -3883,7 +3883,7 @@ static int sp_song_of_peace(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = 2 + lovar(force / 2);
message *msg[2] = { NULL, NULL };
@ -3932,9 +3932,9 @@ static int sp_generous(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
float effect;
double effect;
message *msg[2] = { NULL, NULL };
if (is_cursed(r->attribs, C_DEPRESSION, 0)) {
@ -3990,7 +3990,7 @@ static int sp_recruit(castorder * co)
double n;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
faction *f = mage->faction;
const struct race *rc = f->race;
@ -4045,7 +4045,7 @@ static int sp_bigrecruit(castorder * co)
int n, maxp = rpeasants(r);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
faction *f = mage->faction;
message *msg;
@ -4168,7 +4168,7 @@ static int sp_seduce(castorder * co)
unit *mage = co->magician.u;
spellparameter *pa = co->par;
int cast_level = co->level;
float force = co->force;
double force = co->force;
/* wenn kein Ziel gefunden, Zauber abbrechen */
if (pa->param[0]->flag == TARGET_NOTFOUND)
@ -4244,8 +4244,8 @@ static int sp_calm_monster(castorder * co)
unit *mage = co->magician.u;
spellparameter *pa = co->par;
int cast_level = co->level;
float force = co->force;
float effect;
double force = co->force;
double effect;
message *msg;
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -4260,7 +4260,7 @@ static int sp_calm_monster(castorder * co)
return 0;
}
effect = (float)mage->faction->subscription;
effect = mage->faction->subscription;
c = create_curse(mage, &target->attribs, ct_find("calmmonster"), force,
(int)force, effect, 0);
if (c == NULL) {
@ -4352,7 +4352,7 @@ static int sp_raisepeasants(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
message *msg;
if (rpeasants(r) == 0) {
@ -4405,7 +4405,7 @@ static int sp_depression(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
message *msg;
@ -4472,7 +4472,7 @@ int sp_icastle(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
icastle_data *data;
const char *bname;
@ -4551,7 +4551,7 @@ int sp_illusionary_shapeshift(castorder * co)
const race *rc;
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
const race *irace;
@ -4689,7 +4689,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect)
int duration;
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
region *r = co_get_region(co);
curse *c;
@ -4699,7 +4699,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect)
duration = 2 + rng_int() % duration;
/* Nichts machen als ein entsprechendes Attribut in die Region legen. */
c = create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, (float)effect, 0);
c = create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, effect, 0);
/* Erfolg melden */
ADDMSG(&mage->faction->msgs, msg_message("regionmagic_effect",
@ -4759,7 +4759,7 @@ int sp_dreamreading(castorder * co)
unit *mage = co->magician.u;
int cast_level = co->level;
spellparameter *pa = co->par;
float power = co->force;
double power = co->force;
message *msg;
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -4810,7 +4810,7 @@ int sp_sweetdreams(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
int men, n;
int duration = (int)(power / 2) + 1;
@ -4820,7 +4820,7 @@ int sp_sweetdreams(castorder * co)
for (n = 0; n < pa->length; n++) {
curse *c;
unit *u;
float effect;
double effect;
message *msg;
/* sollte nie negativ werden */
if (opfer < 1)
@ -4860,9 +4860,9 @@ int sp_disturbingdreams(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
int duration = 1 + (int)(power / 6);
float effect;
double effect;
curse *c;
effect = 10;
@ -4950,7 +4950,7 @@ int sp_itemcloak(castorder * co)
unit *mage = co->magician.u;
spellparameter *pa = co->par;
int cast_level = co->level;
float power = co->force;
double power = co->force;
int duration = (int)_max(2.0, power + 1); /* works in the report, and ageing this round would kill it if it's <=1 */
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -4990,7 +4990,7 @@ int sp_resist_magic_bonus(castorder * co)
int duration = 6;
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
/* Pro Stufe koennen bis zu 5 Personen verzaubert werden */
double maxvictims = 5 * power;
@ -5050,7 +5050,7 @@ int sp_enterastral(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
switch (getplaneid(r)) {
@ -5165,7 +5165,7 @@ int sp_pullastral(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
switch (getplaneid(r)) {
@ -5307,7 +5307,7 @@ int sp_leaveastral(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
switch (getplaneid(r)) {
@ -5434,7 +5434,7 @@ int sp_fetchastral(castorder * co)
unit *mage = co->magician.u;
int cast_level = co->level;
spellparameter *pa = co->par;
float power = co->force;
double power = co->force;
int remaining_cap = (int)((power - 3) * 1500);
region_list *rtl = NULL;
region *rt = co_get_region(co); /* region to which we are fetching */
@ -5566,7 +5566,7 @@ int sp_showastral(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
switch (getplaneid(r)) {
case 0:
@ -5697,7 +5697,7 @@ int sp_disruptastral(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
int duration = (int)(power / 3) + 1;
switch (getplaneid(r)) {
@ -5722,7 +5722,7 @@ int sp_disruptastral(castorder * co)
for (rl2 = rl; rl2 != NULL; rl2 = rl2->next) {
attrib *a;
float effect;
double effect;
region *r2 = rl2->data;
spec_direction *sd;
int inhab_regions = 0;
@ -5806,7 +5806,7 @@ static int sp_eternizewall(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
message *msg;
@ -6011,7 +6011,7 @@ int sp_flying_ship(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
message *m = NULL;
int cno;
@ -6078,7 +6078,7 @@ int sp_stealaura(castorder * co)
unit *u;
unit *mage = co->magician.u;
int cast_level = co->level;
float power = co->force;
double power = co->force;
spellparameter *pa = co->par;
/* wenn kein Ziel gefunden, Zauber abbrechen */
@ -6143,12 +6143,12 @@ int sp_stealaura(castorder * co)
*/
int sp_antimagiczone(castorder * co)
{
float power;
float effect;
double power;
double effect;
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
int duration = (int)force + 1;
/* Haelt Sprueche bis zu einem summierten Gesamtlevel von power aus.
@ -6157,7 +6157,7 @@ int sp_antimagiczone(castorder * co)
power = force * 10;
/* Reduziert die Staerke jedes Spruchs um effect */
effect = (float)cast_level;
effect = cast_level;
create_curse(mage, &r->attribs, ct_find("antimagiczone"), power, duration,
effect, 0);
@ -6205,9 +6205,9 @@ static int sp_magicrunes(castorder * co)
int duration;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
float effect;
double effect;
duration = 3 + rng_int() % cast_level;
effect = 20;
@ -6265,14 +6265,14 @@ int sp_speed2(castorder * co)
unit *u;
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
maxmen = 2 * cast_level * cast_level;
dur = _max(1, cast_level / 2);
for (n = 0; n < pa->length; n++) {
float effect;
double effect;
/* sollte nie negativ werden */
if (maxmen < 1)
break;
@ -6326,7 +6326,7 @@ int sp_q_antimagie(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
const char *ts = NULL;
@ -6406,7 +6406,7 @@ int sp_break_curse(castorder * co)
region *r = co_get_region(co);
unit *mage = co->magician.u;
int cast_level = co->level;
float force = co->force;
double force = co->force;
spellparameter *pa = co->par;
const char *ts = NULL;

View file

@ -86,7 +86,7 @@ static int cw_read(attrib * a, void *target, storage * store)
* Was fuer eine Wirkung hat die?
*/
void wall_vigour(curse * c, float delta)
void wall_vigour(curse * c, double delta)
{
wallcurse *wc = (wallcurse *)c->data.v;
assert(wc->buddy->vigour == c->vigour);

View file

@ -908,11 +908,11 @@ int sp_strong_wall(struct castorder * co)
{
fighter * fi = co->magician.fig;
int level = co->level;
float power = co->force;
double power = co->force;
battle *b = fi->side->battle;
unit *mage = fi->unit;
building *burg;
float effect;
double effect;
static bool init = false;
message *msg;
static const curse_type *strongwall_ct;

View file

@ -121,7 +121,7 @@ static struct curse_type ct_shipspeedup = { "shipspeedup",
CURSETYP_NORM, 0, 0, cinfo_ship
};
curse *shipcurse_flyingship(ship * sh, unit * mage, float power, int duration)
curse *shipcurse_flyingship(ship * sh, unit * mage, double power, int duration)
{
static const curse_type *ct_flyingship = NULL;
if (!ct_flyingship) {
@ -146,7 +146,7 @@ curse *shipcurse_flyingship(ship * sh, unit * mage, float power, int duration)
}
}
int levitate_ship(ship * sh, unit * mage, float power, int duration)
int levitate_ship(ship * sh, unit * mage, double power, int duration)
{
curse *c = shipcurse_flyingship(sh, mage, power, duration);
if (c) {

View file

@ -29,8 +29,8 @@ extern "C" {
const struct curse *c, int self);
void register_shipcurse(void);
struct curse *shipcurse_flyingship(struct ship *sh, struct unit *mage,
float power, int duration);
int levitate_ship(struct ship *sh, struct unit *mage, float power,
double power, int duration);
int levitate_ship(struct ship *sh, struct unit *mage, double power,
int duration);
#ifdef __cplusplus

View file

@ -48,9 +48,9 @@ typedef struct createcurse_data {
struct unit *mage;
struct unit *target;
const curse_type *type;
float vigour;
double vigour;
int duration;
float effect;
double effect;
int men;
} createcurse_data;
@ -97,13 +97,15 @@ static int createcurse_read(trigger * t, struct storage *store)
{
createcurse_data *td = (createcurse_data *)t->data.v;
char zText[128];
float flt;
read_reference(&td->mage, store, read_unit_reference, resolve_unit);
read_reference(&td->target, store, read_unit_reference, resolve_unit);
READ_TOK(store, zText, sizeof(zText));
td->type = ct_find(zText);
READ_FLT(store, &td->vigour);
READ_FLT(store, &flt);
td->vigour = flt;
READ_INT(store, &td->duration);
if (global.data_version < CURSEFLOAT_VERSION) {
int n;
@ -111,7 +113,8 @@ static int createcurse_read(trigger * t, struct storage *store)
td->effect = (float)n;
}
else {
READ_FLT(store, &td->effect);
READ_FLT(store, &flt);
td->effect = flt;
}
READ_INT(store, &td->men);
return AT_READ_OK;
@ -127,7 +130,7 @@ trigger_type tt_createcurse = {
};
trigger *trigger_createcurse(struct unit * mage, struct unit * target,
const curse_type * ct, float vigour, int duration, float effect, int men)
const curse_type * ct, double vigour, int duration, double effect, int men)
{
trigger *t = t_new(&tt_createcurse);
createcurse_data *td = (createcurse_data *)t->data.v;

View file

@ -33,8 +33,8 @@ extern "C" {
extern struct trigger_type tt_createcurse;
struct trigger *trigger_createcurse(struct unit *mage,
struct unit *target, const struct curse_type *ct, float vigour,
int duration, float effect, int men);
struct unit *target, const struct curse_type *ct, double vigour,
int duration, double effect, int men);
#ifdef __cplusplus
}

View file

@ -9,15 +9,15 @@ static void test_strlcat(CuTest * tc)
memset(buffer, 0x7f, sizeof(buffer));
buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 4));
CuAssertIntEquals(tc, 4, (int)strlcat(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer);
buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8));
CuAssertIntEquals(tc, 4, (int)strlcat(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8));
CuAssertIntEquals(tc, 8, (int)strlcat(buffer, "derp", 8));
CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]);
}
@ -28,14 +28,14 @@ static void test_strlcpy(CuTest * tc)
memset(buffer, 0x7f, sizeof(buffer));
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 4));
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8));
CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8));
CuAssertIntEquals(tc, 8, (int)strlcpy(buffer, "herpderp", 8));
CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]);
}
@ -49,11 +49,11 @@ static void test_slprintf(CuTest * tc)
CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp") > 3);
CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, slprintf(buffer, 8, "%s", "herp"));
CuAssertIntEquals(tc, 4, (int)slprintf(buffer, 8, "%s", "herp"));
CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, slprintf(buffer, 8, "%s", "herpderp"));
CuAssertIntEquals(tc, 8, (int)slprintf(buffer, 8, "%s", "herpderp"));
CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]);
}

View file

@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef GOODIES_H
#define GOODIES_H
#include "strings.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -29,30 +32,6 @@ extern "C" {
extern int *intlist_add(int *i_p, int i);
extern int *intlist_find(int *i_p, int i);
extern unsigned int hashstring(const char *s);
extern const char *escape_string(const char *str, char *buffer,
unsigned int len);
extern unsigned int jenkins_hash(unsigned int a);
extern unsigned int wang_hash(unsigned int a);
/* benchmark for units:
* JENKINS_HASH: 5.25 misses/hit (with good cache behavior)
* WANG_HASH: 5.33 misses/hit (with good cache behavior)
* KNUTH_HASH: 1.93 misses/hit (with bad cache behavior)
* CF_HASH: fucking awful!
*/
#define KNUTH_HASH1(a, m) ((a) % m)
#define KNUTH_HASH2(a, m) (m - 2 - a % (m-2))
#define CF_HASH1(a, m) ((a) % m)
#define CF_HASH2(a, m) (8 - ((a) & 7))
#define JENKINS_HASH1(a, m) (jenkins_hash(a) % m)
#define JENKINS_HASH2(a, m) 1
#define WANG_HASH1(a, m) (wang_hash(a) % m)
#define WANG_HASH2(a, m) 1
#define HASH1 JENKINS_HASH1
#define HASH2 JENKINS_HASH2
#ifdef __cplusplus
}
#endif

View file

@ -32,7 +32,7 @@ unsigned int hashstring(const char *s)
}
const char *escape_string(const char *str, char *buffer,
unsigned int len)
size_t len)
{
const char *start = strchr(str, '\"');
if (!start) start = strchr(str, '\\');

View file

@ -2,7 +2,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "goodies.h"
#include "strings.h"
static void test_escape_string(CuTest * tc)
{

View file

@ -84,7 +84,7 @@ size_t * inlen)
if (op - out >= os - 1)
break;
*op++ = 0xC3;
*op++ = c - 64;
*op++ = (unsigned char)(c - 64);
}
else if (c > 0x7F) {
if (op - out >= os - 1)