Merge pull request #191 from badgerman/feature-warn-conversion

enable most conversion warnings on gcc < 4.9
This commit is contained in:
Enno Rehling 2015-05-15 21:13:37 +02:00
commit 13bccdc659
40 changed files with 292 additions and 257 deletions

View File

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

@ -25,6 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <storage.h> #include <storage.h>
#include <limits.h>
#include <assert.h>
static void static void
write_movement(const attrib * a, const void *owner, struct storage *store) write_movement(const attrib * a, const void *owner, struct storage *store)
{ {
@ -65,7 +68,9 @@ void set_movement(attrib ** alist, int type)
static int age_speedup(attrib * a) static int age_speedup(attrib * a)
{ {
if (a->data.sa[0] > 0) { if (a->data.sa[0] > 0) {
a->data.sa[0] = a->data.sa[0] - a->data.sa[1]; assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN);
assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX);
a->data.sa[0] = (short)(a->data.sa[0] - a->data.sa[1]);
} }
return (a->data.sa[0] > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; return (a->data.sa[0] > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
} }

View File

@ -1695,7 +1695,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
level = eff_skill(mage, SK_MAGIC, r); level = eff_skill(mage, SK_MAGIC, r);
if (level > 0) { if (level > 0) {
float power; double power;
const spell *sp; const spell *sp;
const struct locale *lang = mage->faction->locale; const struct locale *lang = mage->faction->locale;
order *ord; order *ord;
@ -1771,7 +1771,7 @@ void do_combatmagic(battle * b, combatmagic_t was)
} }
} }
static int cast_combatspell(troop at, const spell * sp, int level, float force) static int cast_combatspell(troop at, const spell * sp, int level, double force)
{ {
castorder co; castorder co;
@ -1794,7 +1794,7 @@ static void do_combatspell(troop at)
region *r = b->region; region *r = b->region;
quicklist *ql; quicklist *ql;
int level, qi; int level, qi;
float power; double power;
int fumblechance = 0; int fumblechance = 0;
order *ord; order *ord;
int sl; int sl;
@ -1867,7 +1867,7 @@ static void do_extra_spell(troop at, const att * a)
log_error("spell '%s' has no function.\n", sp->sname); log_error("spell '%s' has no function.\n", sp->sname);
} }
else { else {
float force = (float)a->level * MagicPower(); double force = a->level * MagicPower();
assert(a->level > 0); assert(a->level > 0);
cast_combatspell(at, sp, a->level, force); cast_combatspell(at, sp, a->level, force);
} }
@ -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, static int loot_quota(const unit * src, const unit * dst,
const item_type * type, int n) const item_type * type, int n)
{ {
static float divisor = -1; static double divisor = -1;
if (dst && src && src->faction != dst->faction) { if (dst && src && src->faction != dst->faction) {
if (divisor < 0) { if (divisor < 0) {
divisor = get_param_flt(global.parameters, "rules.items.loot_divisor", 1); divisor = get_param_flt(global.parameters, "rules.items.loot_divisor", 1);
assert(divisor == 0 || divisor >= 1); assert(divisor == 0 || divisor >= 1);
} }
if (divisor >= 1) { if (divisor >= 1) {
double r = (float)n / divisor; double r = n / divisor;
int x = (int)r; int x = (int)r;
r = r - x; 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 **qlp = (quicklist **)lua_touserdata(L, lua_upvalueindex(1));
quicklist *ql = *qlp; quicklist *ql = *qlp;
if (ql != NULL) { 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)); const char *type = lua_tostring(L, lua_upvalueindex(3));
void *data = ql_get(ql, index); void *data = ql_get(ql, index);
tolua_pushusertype(L, data, TOLUA_CAST type); 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/attrib.h>
#include <util/base36.h> #include <util/base36.h>
#include <util/crmessage.h> #include <util/crmessage.h>
#include <util/goodies.h> #include <util/strings.h>
#include <util/language.h> #include <util/language.h>
#include <util/log.h> #include <util/log.h>
#include <util/message.h> #include <util/message.h>

View File

@ -79,7 +79,7 @@ typedef struct request {
struct request *next; struct request *next;
struct unit *unit; struct unit *unit;
struct order *ord; struct order *ord;
unsigned int qty; int qty;
int no; int no;
union { union {
bool goblin; /* stealing */ bool goblin; /* stealing */
@ -91,7 +91,7 @@ static int working;
static request entertainers[1024]; static request entertainers[1024];
static request *nextentertainer; static request *nextentertainer;
static unsigned int entertaining; static int entertaining;
static unsigned int norders; static unsigned int norders;
static request *oa; static request *oa;
@ -1657,7 +1657,7 @@ static void expandbuying(region * r, request * buyorders)
int multi; int multi;
} trades[MAXLUXURIES], *trade; } trades[MAXLUXURIES], *trade;
static int ntrades = 0; static int ntrades = 0;
int i, j; int i;
const luxury_type *ltype; const luxury_type *ltype;
if (ntrades == 0) { if (ntrades == 0) {
@ -1686,6 +1686,7 @@ static void expandbuying(region * r, request * buyorders)
* Güter pro Monat ist. j sind die Befehle, i der Index des * Güter pro Monat ist. j sind die Befehle, i der Index des
* gehandelten Produktes. */ * gehandelten Produktes. */
if (max_products > 0) { if (max_products > 0) {
unsigned int j;
expandorders(r, buyorders); expandorders(r, buyorders);
if (!norders) if (!norders)
return; return;
@ -1884,7 +1885,8 @@ static int tax_per_size[7] = { 0, 6, 12, 18, 24, 30, 36 };
static void expandselling(region * r, request * sellorders, int limit) static void expandselling(region * r, request * sellorders, int limit)
{ {
int money, price, j, max_products; int money, price, max_products;
unsigned int j;
/* int m, n = 0; */ /* int m, n = 0; */
int maxsize = 0, maxeffsize = 0; int maxsize = 0, maxeffsize = 0;
int taxcollected = 0; int taxcollected = 0;
@ -2220,7 +2222,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord)
static void expandstealing(region * r, request * stealorders) static void expandstealing(region * r, request * stealorders)
{ {
const resource_type *rsilver = get_resourcetype(R_SILVER); const resource_type *rsilver = get_resourcetype(R_SILVER);
int i; unsigned int j;
assert(rsilver); assert(rsilver);
@ -2233,8 +2235,8 @@ static void expandstealing(region * r, request * stealorders)
* u ist die beklaute unit. oa.unit ist die klauende unit. * u ist die beklaute unit. oa.unit ist die klauende unit.
*/ */
for (i = 0; i != norders && oa[i].unit->n <= oa[i].unit->wants; i++) { for (j = 0; j != norders && oa[j].unit->n <= oa[j].unit->wants; j++) {
unit *u = findunitg(oa[i].no, r); unit *u = findunitg(oa[j].no, r);
int n = 0; int n = 0;
if (u && u->region == r) { if (u && u->region == r) {
n = get_pooled(u, rsilver, GET_ALL, INT_MAX); n = get_pooled(u, rsilver, GET_ALL, INT_MAX);
@ -2258,15 +2260,15 @@ static void expandstealing(region * r, request * stealorders)
n = 10; n = 10;
} }
if (n > 0) { if (n > 0) {
n = _min(n, oa[i].unit->wants); n = _min(n, oa[j].unit->wants);
use_pooled(u, rsilver, GET_ALL, n); use_pooled(u, rsilver, GET_ALL, n);
oa[i].unit->n = n; oa[j].unit->n = n;
change_money(oa[i].unit, n); change_money(oa[j].unit, n);
ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount", ADDMSG(&u->faction->msgs, msg_message("stealeffect", "unit region amount",
u, u->region, n)); u, u->region, n));
} }
add_income(oa[i].unit, IC_STEAL, oa[i].unit->wants, oa[i].unit->n); add_income(oa[j].unit, IC_STEAL, oa[j].unit->wants, oa[j].unit->n);
fset(oa[i].unit, UFL_LONGACTION | UFL_NOTMOVING); fset(oa[j].unit, UFL_LONGACTION | UFL_NOTMOVING);
} }
free(oa); free(oa);
} }
@ -2909,7 +2911,7 @@ static int do_work(unit * u, order * ord, request * o)
static void expandloot(region * r, request * lootorders) static void expandloot(region * r, request * lootorders)
{ {
unit *u; unit *u;
int i; unsigned int i;
int looted = 0; int looted = 0;
int startmoney = rmoney(r); int startmoney = rmoney(r);
@ -2946,7 +2948,7 @@ static void expandloot(region * r, request * lootorders)
static void expandtax(region * r, request * taxorders) static void expandtax(region * r, request * taxorders)
{ {
unit *u; unit *u;
int i; unsigned int i;
expandorders(r, taxorders); expandorders(r, taxorders);
if (!norders) if (!norders)

View File

@ -131,7 +131,7 @@ static bool limited_give(const item_type * type)
int give_quota(const unit * src, const unit * dst, const item_type * type, int give_quota(const unit * src, const unit * dst, const item_type * type,
int n) int n)
{ {
float divisor; double divisor;
if (!limited_give(type)) { if (!limited_give(type)) {
return n; return n;

View File

@ -77,7 +77,7 @@ static WINDOW *hstatus;
static void init_curses(void) static void init_curses(void)
{ {
short fg, bg; int fg, bg;
initscr(); initscr();
if (has_colors() || force_color) { if (has_colors() || force_color) {
@ -93,7 +93,7 @@ static void init_curses(void)
#endif #endif
for (fg = 0; fg != 8; ++fg) { for (fg = 0; fg != 8; ++fg) {
for (bg = 0; bg != 2; ++bg) { 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

@ -81,7 +81,7 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount,
struct order *ord) struct order *ord)
{ {
curse *c; curse *c;
float effect; double effect;
ship *sh = u->ship; ship *sh = u->ship;
if (!sh) { if (!sh) {
cmistake(u, ord, 20, MSG_MOVE); cmistake(u, ord, 20, MSG_MOVE);
@ -120,7 +120,7 @@ struct order *ord)
} }
for (i = 0; i != amount; ++i) { for (i = 0; i != amount; ++i) {
int effect, duration = 2; int effect, duration = 2;
float force; double force;
spell *sp = find_spell("antimagiczone"); spell *sp = find_spell("antimagiczone");
attrib **ap = &r->attribs; attrib **ap = &r->attribs;
unused_arg(ord); unused_arg(ord);
@ -132,7 +132,7 @@ struct order *ord)
/* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus. /* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus.
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone * Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
* um seine Stufe */ * um seine Stufe */
force = (float)effect * 20; /* Stufe 5 =~ 100 */ force = effect * 20; /* Stufe 5 =~ 100 */
/* Regionszauber auflösen */ /* Regionszauber auflösen */
while (*ap && force > 0) { while (*ap && force > 0) {
@ -163,8 +163,8 @@ struct order *ord)
} }
if (force > 0) { if (force > 0) {
create_curse(u, &r->attribs, ct_find("antimagiczone"), (float)force, duration, create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration,
(float)effect, 0); effect, 0);
} }
} }
use_pooled(u, rt_crystal, GET_DEFAULT, amount); use_pooled(u, rt_crystal, GET_DEFAULT, amount);

View File

@ -101,7 +101,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
else { else {
unit *u2; unit *u2;
region *r = u->region; region *r = u->region;
short road, n = (short)nmax; int road, n = nmax;
if (nmax > SHRT_MAX) { if (nmax > SHRT_MAX) {
n = SHRT_MAX; n = SHRT_MAX;
@ -131,7 +131,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
if (willdo > SHRT_MAX) if (willdo > SHRT_MAX)
road = 0; road = 0;
else else
road = road - (short)willdo; road = (short)(road - willdo);
rsetroad(r, d, road); rsetroad(r, d, road);
ADDMSG(&u->faction->msgs, msg_message("destroy_road", ADDMSG(&u->faction->msgs, msg_message("destroy_road",
"unit from to", u, r, r2)); "unit from to", u, r, r2));
@ -360,7 +360,7 @@ void build_road(region * r, unit * u, int size, direction_t d)
/* n is now modified by several special effects, so we have to /* n is now modified by several special effects, so we have to
* minimize it again to make sure the road will not grow beyond * minimize it again to make sure the road will not grow beyond
* maximum. */ * maximum. */
rsetroad(r, d, rroad(r, d) + (short)n); rsetroad(r, d, rroad(r, d) + n);
if (u_race(u) == get_race(RC_STONEGOLEM)) { if (u_race(u) == get_race(RC_STONEGOLEM)) {
int golemsused = n / GOLEM_STONE; int golemsused = n / GOLEM_STONE;

View File

@ -853,7 +853,7 @@ int forbiddenid(int id)
++len; ++len;
forbid = calloc(len, sizeof(int)); forbid = calloc(len, sizeof(int));
for (i = 0; i != len; ++i) { for (i = 0; i != len; ++i) {
forbid[i] = strtol(forbidden[i], NULL, 36); forbid[i] = atoi36(forbidden[i]);
} }
} }
for (i = 0; i != len; ++i) for (i = 0; i != len; ++i)

View File

@ -392,15 +392,13 @@ bool remove_curse(attrib ** ap, const curse * c)
/* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie /* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie
* oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und * oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und
* damit der gegen Antimagie wirkende Widerstand einer Verzauberung */ * damit der gegen Antimagie wirkende Widerstand einer Verzauberung */
static float get_cursevigour(const curse * c) static double get_cursevigour(const curse * c)
{ {
if (c) return c ? c->vigour : 0;
return c->vigour;
return 0;
} }
/* setzt die Stärke der Verzauberung auf i */ /* setzt die Stärke der Verzauberung auf i */
static void set_cursevigour(curse * c, float vigour) static void set_cursevigour(curse * c, double vigour)
{ {
assert(c && vigour > 0); assert(c && vigour > 0);
c->vigour = vigour; c->vigour = vigour;
@ -410,7 +408,7 @@ static void set_cursevigour(curse * c, float vigour)
* Stärke zurück. Sollte die Zauberstärke unter Null sinken, löst er * Stärke zurück. Sollte die Zauberstärke unter Null sinken, löst er
* sich auf. * sich auf.
*/ */
float curse_changevigour(attrib ** ap, curse * c, float vigour) double curse_changevigour(attrib ** ap, curse * c, double vigour)
{ {
vigour += get_cursevigour(c); vigour += get_cursevigour(c);
@ -426,7 +424,7 @@ float curse_changevigour(attrib ** ap, curse * c, float vigour)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
float curse_geteffect(const curse * c) double curse_geteffect(const curse * c)
{ {
if (c == NULL) if (c == NULL)
return 0; return 0;
@ -437,7 +435,7 @@ float curse_geteffect(const curse * c)
int curse_geteffect_int(const curse * c) int curse_geteffect_int(const curse * c)
{ {
float effect = curse_geteffect(c); double effect = curse_geteffect(c);
if (effect - (int)effect != 0) { if (effect - (int)effect != 0) {
log_error("curse has an integer attribute with float value: '%s' = %lf", log_error("curse has an integer attribute with float value: '%s' = %lf",
c->type->cname, effect); c->type->cname, effect);
@ -491,7 +489,7 @@ static void set_cursedmen(curse * c, int cursedmen)
* dieses Typs geben, gibt es den bestehenden zurück. * dieses Typs geben, gibt es den bestehenden zurück.
*/ */
static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct, static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct,
float vigour, int duration, float effect, int men) double vigour, int duration, double effect, int men)
{ {
curse *c; curse *c;
attrib *a; attrib *a;
@ -528,7 +526,7 @@ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct,
* passenden Typ verzweigt und die relevanten Variablen weitergegeben. * passenden Typ verzweigt und die relevanten Variablen weitergegeben.
*/ */
curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct, curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
float vigour, int duration, float effect, int men) double vigour, int duration, double effect, int men)
{ {
curse *c; curse *c;
@ -785,7 +783,7 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c,
* die Kraft des Curse um die halbe Stärke der Antimagie reduziert. * die Kraft des Curse um die halbe Stärke der Antimagie reduziert.
* Zurückgegeben wird der noch unverbrauchte Rest von force. * Zurückgegeben wird der noch unverbrauchte Rest von force.
*/ */
float destr_curse(curse * c, int cast_level, float force) double destr_curse(curse * c, int cast_level, double force)
{ {
if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */ if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */
double probability = 0.1 + (cast_level - c->vigour) * 0.2; double probability = 0.1 + (cast_level - c->vigour) * 0.2;
@ -793,7 +791,7 @@ float destr_curse(curse * c, int cast_level, float force)
if (chance(probability)) { if (chance(probability)) {
force -= c->vigour; force -= c->vigour;
if (c->type->change_vigour) { if (c->type->change_vigour) {
c->type->change_vigour(c, -((float)cast_level + 1) / 2); c->type->change_vigour(c, -(cast_level + 1) / 2);
} }
else { else {
c->vigour -= cast_level + 1 / 2; c->vigour -= cast_level + 1 / 2;

View File

@ -194,9 +194,9 @@ extern "C" {
const struct curse_type *type; /* Zeiger auf ein curse_type-struct */ const struct curse_type *type; /* Zeiger auf ein curse_type-struct */
int flags; /* WARNING: these are XORed with type->flags! */ int flags; /* WARNING: these are XORed with type->flags! */
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */ int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */
float vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */
struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
float effect; double effect;
variant data; /* pointer auf spezielle curse-unterstructs */ variant data; /* pointer auf spezielle curse-unterstructs */
} curse; } curse;
@ -211,7 +211,7 @@ extern "C" {
int mergeflags; int mergeflags;
struct message *(*curseinfo) (const void *, objtype_t, const struct curse *, struct message *(*curseinfo) (const void *, objtype_t, const struct curse *,
int); int);
void(*change_vigour) (curse *, float); void(*change_vigour) (curse *, double);
int(*read) (struct storage * store, curse * c, void *target); int(*read) (struct storage * store, curse * c, void *target);
int(*write) (struct storage * store, const struct curse * c, int(*write) (struct storage * store, const struct curse * c,
const void *target); const void *target);
@ -238,7 +238,7 @@ extern "C" {
*/ */
curse *create_curse(struct unit *magician, struct attrib **ap, curse *create_curse(struct unit *magician, struct attrib **ap,
const curse_type * ctype, float vigour, int duration, float ceffect, const curse_type * ctype, double vigour, int duration, double ceffect,
int men); int men);
/* Verzweigt automatisch zum passenden struct-typ. Sollte es schon /* Verzweigt automatisch zum passenden struct-typ. Sollte es schon
* einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die * einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die
@ -260,10 +260,10 @@ extern "C" {
* gesetzt. Gibt immer den ersten Treffer von ap aus zurück. * gesetzt. Gibt immer den ersten Treffer von ap aus zurück.
*/ */
int curse_geteffect_int(const struct curse *c); int curse_geteffect_int(const struct curse *c);
float curse_geteffect(const struct curse *c); double curse_geteffect(const struct curse *c);
/* verändert die Stärke der Verzauberung um i */ /* verändert die Stärke der Verzauberung um i */
float curse_changevigour(struct attrib **ap, curse * c, float i); double curse_changevigour(struct attrib **ap, curse * c, double delta);
/* gibt bei Personenbeschränkten Verzauberungen die Anzahl der /* gibt bei Personenbeschränkten Verzauberungen die Anzahl der
* betroffenen Personen zurück. Ansonsten wird 0 zurückgegeben. */ * betroffenen Personen zurück. Ansonsten wird 0 zurückgegeben. */
@ -297,7 +297,7 @@ extern "C" {
void curse_done(struct attrib *a); void curse_done(struct attrib *a);
int curse_age(struct attrib *a); int curse_age(struct attrib *a);
float destr_curse(struct curse *c, int cast_level, float force); double destr_curse(struct curse *c, int cast_level, double force);
int resolve_curse(variant data, void *address); int resolve_curse(variant data, void *address);
bool is_cursed_with(const struct attrib *ap, const struct curse *c); bool is_cursed_with(const struct attrib *ap, const struct curse *c);

View File

@ -174,7 +174,7 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
int i; int i;
for (i = 0; eq->subsets[i].sets; ++i) { for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) { if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f; double rnd = (1 + rng_int() % 1000) / 1000.0;
int k; int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) { for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) { if (rnd <= eq->subsets[i].sets[k].chance) {
@ -209,7 +209,7 @@ void equip_items(struct item **items, const struct equipment *eq)
int i; int i;
for (i = 0; eq->subsets[i].sets; ++i) { for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) { if (chance(eq->subsets[i].chance)) {
float rnd = (1 + rng_int() % 1000) / 1000.0f; double rnd = (1 + rng_int() % 1000) / 1000.0;
int k; int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) { for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) { 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; 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) const struct locale *lang)
{ {
order *ord = NULL; order *ord = NULL;
@ -338,7 +338,7 @@ order *create_order(keyword_t kwd, const struct locale * lang,
else { else {
zBuffer[0] = 0; 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) 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) { if (*s != 0) {
keyword_t kwd; keyword_t kwd;
const char *sptr; const char *sptr;
int persistent = 0; bool persistent = false;
const char * p; const char * p;
while (*s == '@') { while (*s == '@') {
persistent = 1; persistent = true;
++s; ++s;
} }
sptr = s; sptr = s;
@ -511,18 +511,15 @@ bool is_long(const order * ord)
bool is_persistent(const order * ord) bool is_persistent(const order * ord)
{ {
keyword_t kwd = ORD_KEYWORD(ord); keyword_t kwd = ORD_KEYWORD(ord);
int persist = ord->_persistent != 0;
switch (kwd) { switch (kwd) {
case K_MOVE: case K_MOVE:
case NOKEYWORD: case NOKEYWORD:
/* lang, aber niemals persistent! */ /* lang, aber niemals persistent! */
return false; return false;
case K_KOMMENTAR: case K_KOMMENTAR:
return true; return true;
default: default:
return persist || is_repeated(ord); return ord->_persistent || is_repeated(ord);
} }
} }

View File

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

View File

@ -537,11 +537,12 @@ attrib_type at_travelunit = {
NO_READ NO_READ
}; };
void rsetroad(region * r, direction_t d, short val) void rsetroad(region * r, direction_t d, int val)
{ {
connection *b; connection *b;
region *r2 = rconnect(r, d); region *r2 = rconnect(r, d);
assert(val>=SHRT_MIN && val<=SHRT_MAX);
if (!r2) { if (!r2) {
return; return;
} }
@ -554,14 +555,14 @@ void rsetroad(region * r, direction_t d, short val)
b = new_border(&bt_road, r, r2); b = new_border(&bt_road, r, r2);
} }
if (r == b->from) { if (r == b->from) {
b->data.sa[0] = val; b->data.sa[0] = (short)val;
} }
else { else {
b->data.sa[1] = val; b->data.sa[1] = (short)val;
} }
} }
short rroad(const region * r, direction_t d) int rroad(const region * r, direction_t d)
{ {
connection *b; connection *b;
region *r2 = rconnect(r, d); region *r2 = rconnect(r, d);

View File

@ -187,8 +187,8 @@ extern "C" {
void setluxuries(struct region *r, const struct luxury_type *sale); void setluxuries(struct region *r, const struct luxury_type *sale);
int get_maxluxuries(void); int get_maxluxuries(void);
short rroad(const struct region *r, direction_t d); int rroad(const struct region *r, direction_t d);
void rsetroad(struct region *r, direction_t d, short value); void rsetroad(struct region *r, direction_t d, int value);
bool is_coastregion(struct region *r); bool is_coastregion(struct region *r);

View File

@ -98,7 +98,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h> #include <limits.h>
/* chance that a peasant dies of starvation: */ /* chance that a peasant dies of starvation: */
#define PEASANT_STARVATION_CHANCE 0.9F #define PEASANT_STARVATION_CHANCE 0.9
/* Pferdevermehrung */ /* Pferdevermehrung */
#define HORSEGROWTH 4 #define HORSEGROWTH 4
/* Wanderungschance pro Pferd */ /* Wanderungschance pro Pferd */
@ -257,7 +257,7 @@ static void calculate_emigration(region * r)
} }
static float peasant_growth_factor(void) static double peasant_growth_factor(void)
{ {
return get_param_flt(global.parameters, "rules.peasants.growth.factor", 0.0001F * PEASANTGROWTH); return get_param_flt(global.parameters, "rules.peasants.growth.factor", 0.0001F * PEASANTGROWTH);
} }
@ -265,7 +265,7 @@ static float peasant_growth_factor(void)
#ifdef SLOWLUCK #ifdef SLOWLUCK
int peasant_luck_effect(int peasants, int luck, int maxp, double variance) { int peasant_luck_effect(int peasants, int luck, int maxp, double variance) {
int n, births=0; int n, births=0;
float factor = peasant_growth_factor(); double factor = peasant_growth_factor();
for (n = peasants; n && luck; --n) { for (n = peasants; n && luck; --n) {
int chances = 0; int chances = 0;
@ -287,7 +287,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) {
return births; return births;
} }
#else #else
static float peasant_luck_factor(void) static double peasant_luck_factor(void)
{ {
return get_param_flt(global.parameters, "rules.peasants.peasantluck.factor", PEASANTLUCK); return get_param_flt(global.parameters, "rules.peasants.peasantluck.factor", PEASANTLUCK);
} }
@ -296,12 +296,10 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance)
{ {
int births = 0; int births = 0;
double mean; double mean;
if (luck == 0) return 0; if (luck == 0) return 0;
mean = _min(luck, peasants) * peasant_luck_factor() mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants);
* peasant_growth_factor() * ((peasants / (double)maxp < .9) ? 1 : mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE);
PEASANTFORCE);
births = RAND_ROUND(normalvariate(mean, variance * mean)); births = RAND_ROUND(normalvariate(mean, variance * mean));
if (births <= 0) if (births <= 0)
@ -349,7 +347,7 @@ static void peasants(region * r)
/* Es verhungert maximal die unterernährten Bevölkerung. */ /* Es verhungert maximal die unterernährten Bevölkerung. */
n = _min(peasants - satiated, rpeasants(r)); n = _min(peasants - satiated, rpeasants(r));
dead += (int)(0.5F + n * PEASANT_STARVATION_CHANCE); dead += (int)(0.5 + n * PEASANT_STARVATION_CHANCE);
if (dead > 0) { if (dead > 0) {
message *msg = add_message(&r->msgs, msg_message("phunger", "dead", dead)); message *msg = add_message(&r->msgs, msg_message("phunger", "dead", dead));
@ -433,7 +431,7 @@ static void horses(region * r)
horses = rhorses(r); horses = rhorses(r);
if (horses > 0) { if (horses > 0) {
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) { if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
rsethorses(r, (int)(horses * 0.9F)); rsethorses(r, (int)(horses * 0.9));
} }
else if (maxhorses) { else if (maxhorses) {
int i; int i;
@ -445,7 +443,7 @@ static void horses(region * r)
if (a_find(r->attribs, &at_horseluck)) if (a_find(r->attribs, &at_horseluck))
growth *= 2; growth *= 2;
/* printf("Horses: <%d> %d -> ", growth, horses); */ /* printf("Horses: <%d> %d -> ", growth, horses); */
i = (int)(0.5F + (horses * 0.0001F) * growth); i = (int)(0.5 + (horses * 0.0001) * growth);
/* printf("%d\n", horses); */ /* printf("%d\n", horses); */
rsethorses(r, horses + i); rsethorses(r, horses + i);
} }
@ -2281,7 +2279,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
int a, at_count; int a, at_count;
char buf[2048], *bufp = buf; char buf[2048], *bufp = buf;
size_t size = sizeof(buf) - 1; size_t size = sizeof(buf) - 1;
int bytes; size_t bytes;
if (u && u_race(u) != rc) if (u && u_race(u) != rc)
return false; return false;
@ -2297,7 +2295,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
info = LOC(f->locale, mkname("raceinfo", "no_info")); info = LOC(f->locale, mkname("raceinfo", "no_info"));
} }
bytes = (int)strlcpy(bufp, info, size); bytes = strlcpy(bufp, info, size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -2345,28 +2343,28 @@ static bool display_race(faction * f, unit * u, const race * rc)
} }
} }
if (rc->battle_flags & BF_EQUIPMENT) { if (rc->battle_flags & BF_EQUIPMENT) {
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment")); bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_PIERCE) { if (rc->battle_flags & BF_RES_PIERCE) {
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce")); bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_CUT) { if (rc->battle_flags & BF_RES_CUT) {
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut")); bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_BASH) { if (rc->battle_flags & BF_RES_BASH) {
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash")); bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
bytes = bytes =
_snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (size_t)_snprintf(bufp, size, " %d %s", at_count, LOC(f->locale,
(at_count == 1) ? "stat_attack" : "stat_attacks")); (at_count == 1) ? "stat_attack" : "stat_attacks"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -2374,21 +2372,21 @@ static bool display_race(faction * f, unit * u, const race * rc)
for (a = 0; a < RACE_ATTACKS; a++) { for (a = 0; a < RACE_ATTACKS; a++) {
if (rc->attack[a].type != AT_NONE) { if (rc->attack[a].type != AT_NONE) {
if (a != 0) if (a != 0)
bytes = (int)strlcpy(bufp, ", ", size); bytes = strlcpy(bufp, ", ", size);
else else
bytes = (int)strlcpy(bufp, ": ", size); bytes = strlcpy(bufp, ": ", size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
switch (rc->attack[a].type) { switch (rc->attack[a].type) {
case AT_STANDARD: case AT_STANDARD:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_standard"), rc->def_damage); LOC(f->locale, "attack_standard"), rc->def_damage);
break; break;
case AT_NATURAL: case AT_NATURAL:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
break; break;
case AT_SPELL: case AT_SPELL:
@ -2396,11 +2394,11 @@ static bool display_race(faction * f, unit * u, const race * rc)
case AT_DRAIN_ST: case AT_DRAIN_ST:
case AT_DRAIN_EXP: case AT_DRAIN_EXP:
case AT_DAZZLE: case AT_DAZZLE:
bytes = _snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); bytes = (size_t)_snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical"));
break; break;
case AT_STRUCTURAL: case AT_STRUCTURAL:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
break; break;
default: default:
@ -3130,7 +3128,7 @@ static building *age_building(building * b)
else if (mage != NULL) { else if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC);
c->duration = _max(c->duration, sk / 2); c->duration = _max(c->duration, sk / 2);
c->vigour = _max(c->vigour, sk); c->vigour = _max(c->vigour, (float)sk);
} }
} }
} }

View File

@ -117,12 +117,12 @@ static float MagicRegeneration(void)
return value; return value;
} }
float MagicPower(void) double MagicPower(void)
{ {
static float value = -1.0; static double value = -1.0;
if (value < 0) { if (value < 0) {
const char *str = get_param(global.parameters, "magic.power"); const char *str = get_param(global.parameters, "magic.power");
value = str ? (float)atof(str) : 1.0f; value = str ? atof(str) : 1.0;
} }
return value; return value;
} }
@ -1008,11 +1008,11 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
* Spruchfunktionsroutine ermittelt. * Spruchfunktionsroutine ermittelt.
*/ */
float double
spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord) spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord)
{ {
curse *c; curse *c;
float force = (float)cast_level; double force = cast_level;
int elf_power; int elf_power;
const struct resource_type *rtype; const struct resource_type *rtype;
@ -1041,7 +1041,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
if (curse_active(c)) { if (curse_active(c)) {
unit *mage = c->magician; unit *mage = c->magician;
force -= curse_geteffect(c); force -= curse_geteffect(c);
curse_changevigour(&r->attribs, c, (float)-cast_level); curse_changevigour(&r->attribs, c, -cast_level);
cmistake(u, ord, 185, MSG_MAGIC); cmistake(u, ord, 185, MSG_MAGIC);
if (mage != NULL && mage->faction != NULL) { if (mage != NULL && mage->faction != NULL) {
if (force > 0) { if (force > 0) {
@ -1340,7 +1340,7 @@ static void do_fumble(castorder * co)
const spell *sp = co->sp; const spell *sp = co->sp;
int level = co->level; int level = co->level;
int duration; int duration;
float effect; double effect;
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("patzer", "unit region spell", u, r, sp)); msg_message("patzer", "unit region spell", u, r, sp));
@ -1382,8 +1382,8 @@ static void do_fumble(castorder * co)
case 2: case 2:
/* temporary skill loss */ /* temporary skill loss */
duration = _max(rng_int() % level / 2, 2); duration = _max(rng_int() % level / 2, 2);
effect = -(float)level / 2; effect = level / -2.0;
c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, c = create_curse(u, &u->attribs, ct_find("skillmod"), level,
duration, effect, 1); duration, effect, 1);
c->data.i = SK_MAGIC; c->data.i = SK_MAGIC;
ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r)); ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r));
@ -2067,7 +2067,7 @@ struct region * co_get_region(const struct castorder * co) {
} }
castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const spell * sp, region * r, castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const spell * sp, region * r,
int lev, float force, int range, struct order * ord, spellparameter * p) int lev, double force, int range, struct order * ord, spellparameter * p)
{ {
if (!co) co = (castorder*)calloc(1, sizeof(castorder)); if (!co) co = (castorder*)calloc(1, sizeof(castorder));

View File

@ -131,7 +131,7 @@ extern "C" {
den Vertrauten gezaubert wird */ den Vertrauten gezaubert wird */
const struct spell *sp; /* Spruch */ const struct spell *sp; /* Spruch */
int level; /* gewünschte Stufe oder Stufe des Magiers */ 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 */ struct region *_rtarget; /* Zielregion des Spruchs */
int distance; /* Entfernung zur Zielregion */ int distance; /* Entfernung zur Zielregion */
struct order *order; /* Befehl */ struct order *order; /* Befehl */
@ -277,7 +277,7 @@ extern "C" {
/* verändert die maximalen Magiepunkte einer Einheit */ /* verändert die maximalen Magiepunkte einer Einheit */
/* Zaubern */ /* 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); int cast_level, struct order *ord);
/* ermittelt die Stärke eines Spruchs */ /* ermittelt die Stärke eines Spruchs */
bool fumble(struct region *r, struct unit *u, const struct spell * sp, bool fumble(struct region *r, struct unit *u, const struct spell * sp,
@ -291,7 +291,7 @@ extern "C" {
struct castorder *create_castorder(struct castorder * co, struct unit *caster, struct castorder *create_castorder(struct castorder * co, struct unit *caster,
struct unit * familiar, const struct spell * sp, struct region * r, struct unit * familiar, const struct spell * sp, struct region * r,
int lev, float force, int range, struct order * ord, struct spellparameter * p); int lev, double force, int range, struct order * ord, struct spellparameter * p);
void free_castorder(struct castorder *co); void free_castorder(struct castorder *co);
/* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */ /* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */
void add_castorder(struct spellrank *cll, struct castorder *co); void add_castorder(struct spellrank *cll, struct castorder *co);
@ -360,7 +360,7 @@ extern "C" {
extern void write_spells(struct quicklist *slist, struct storage *store); extern void write_spells(struct quicklist *slist, struct storage *store);
extern void read_spells(struct quicklist **slistp, magic_t mtype, extern void read_spells(struct quicklist **slistp, magic_t mtype,
struct storage *store); struct storage *store);
extern float MagicPower(void); extern double MagicPower(void);
extern struct spellbook * get_spellbook(const char * name); extern struct spellbook * get_spellbook(const char * name);
extern void free_spellbooks(void); extern void free_spellbooks(void);

View File

@ -161,8 +161,8 @@ void score(void)
if (f->num_total != 0) { if (f->num_total != 0) {
fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n", fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n",
f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1), f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1),
((float)f->score / (float)allscores) * 100.0, ((double)f->score / allscores) * 100,
(float)f->score / f->num_total, (double)f->score / f->num_total,
f->name, LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), factionid(f), f->name, LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), factionid(f),
f->age); f->age);
} }

View File

@ -1189,7 +1189,7 @@ void plagues(region * r)
int dead = 0; int dead = 0;
peasants = rpeasants(r); peasants = rpeasants(r);
dead = (int)(0.5F + PLAGUE_VICTIMS * peasants); dead = (int)(0.5 + PLAGUE_VICTIMS * peasants);
for (i = dead; i != 0; i--) { for (i = dead; i != 0; i--) {
if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) { if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) {
rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST); rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST);

View File

@ -25,9 +25,9 @@ extern "C" {
struct region; struct region;
/** Plagues **/ /** Plagues **/
#define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */ #define PLAGUE_CHANCE 0.1 /* Seuchenwahrscheinlichkeit (siehe plagues()) */
#define PLAGUE_VICTIMS 0.2F /* % Betroffene */ #define PLAGUE_VICTIMS 0.2 /* % Betroffene */
#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCHANCE 0.25 /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */ #define PLAGUE_HEALCOST 30 /* Heilkosten */
void plagues(struct region *r); void plagues(struct region *r);
void encounters(void); void encounters(void);

View File

@ -516,7 +516,7 @@ void sparagraph(strlist ** SP, const char *s, unsigned int indent, char mark)
* mark, falls angegeben. SP wurde also auf 0 gesetzt vor dem Aufruf. * mark, falls angegeben. SP wurde also auf 0 gesetzt vor dem Aufruf.
* Vgl. spunit (). */ * Vgl. spunit (). */
int i, j, width; unsigned int width;
int firstline; int firstline;
static char buf[REPORTWIDTH + 1]; // FIXME: static return value static char buf[REPORTWIDTH + 1]; // FIXME: static return value
@ -524,10 +524,9 @@ void sparagraph(strlist ** SP, const char *s, unsigned int indent, char mark)
firstline = 1; firstline = 1;
for (;;) { for (;;) {
i = 0; unsigned int j = 0, i;
do { for (i=0; s[j]; j=i) {
j = i;
while (s[j] && s[j] != ' ') while (s[j] && s[j] != ' ')
j++; j++;
if (j > width) { if (j > width) {

View File

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

View File

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

View File

@ -908,11 +908,11 @@ int sp_strong_wall(struct castorder * co)
{ {
fighter * fi = co->magician.fig; fighter * fi = co->magician.fig;
int level = co->level; int level = co->level;
float power = co->force; double power = co->force;
battle *b = fi->side->battle; battle *b = fi->side->battle;
unit *mage = fi->unit; unit *mage = fi->unit;
building *burg; building *burg;
float effect; double effect;
static bool init = false; static bool init = false;
message *msg; message *msg;
static const curse_type *strongwall_ct; 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 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; static const curse_type *ct_flyingship = NULL;
if (!ct_flyingship) { 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); curse *c = shipcurse_flyingship(sh, mage, power, duration);
if (c) { if (c) {

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ int wrptr(char **ptr, size_t * size, size_t bytes)
*size = 0; *size = 0;
return EINVAL; return EINVAL;
} }
if (bytes <= *(int *)size) { if (bytes <= *size) {
*ptr += bytes; *ptr += bytes;
*size -= bytes; *size -= bytes;
return 0; return 0;

View File

@ -9,15 +9,15 @@ static void test_strlcat(CuTest * tc)
memset(buffer, 0x7f, sizeof(buffer)); memset(buffer, 0x7f, sizeof(buffer));
buffer[0] = '\0'; buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 4)); CuAssertIntEquals(tc, 4, (int)strlcat(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer); CuAssertStrEquals(tc, "her", buffer);
buffer[0] = '\0'; buffer[0] = '\0';
CuAssertIntEquals(tc, 4, strlcat(buffer, "herp", 8)); CuAssertIntEquals(tc, 4, (int)strlcat(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]); CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, strlcat(buffer, "derp", 8)); CuAssertIntEquals(tc, 8, (int)strlcat(buffer, "derp", 8));
CuAssertStrEquals(tc, "herpder", buffer); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]); CuAssertIntEquals(tc, 0x7f, buffer[8]);
} }
@ -28,14 +28,14 @@ static void test_strlcpy(CuTest * tc)
memset(buffer, 0x7f, sizeof(buffer)); memset(buffer, 0x7f, sizeof(buffer));
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 4)); CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 4));
CuAssertStrEquals(tc, "her", buffer); CuAssertStrEquals(tc, "her", buffer);
CuAssertIntEquals(tc, 4, strlcpy(buffer, "herp", 8)); CuAssertIntEquals(tc, 4, (int)strlcpy(buffer, "herp", 8));
CuAssertStrEquals(tc, "herp", buffer); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]); CuAssertIntEquals(tc, 0x7f, buffer[5]);
CuAssertIntEquals(tc, 8, strlcpy(buffer, "herpderp", 8)); CuAssertIntEquals(tc, 8, (int)strlcpy(buffer, "herpderp", 8));
CuAssertStrEquals(tc, "herpder", buffer); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]); CuAssertIntEquals(tc, 0x7f, buffer[8]);
} }
@ -49,11 +49,11 @@ static void test_slprintf(CuTest * tc)
CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp") > 3); CuAssertTrue(tc, slprintf(buffer, 4, "%s", "herpderp") > 3);
CuAssertStrEquals(tc, "her", buffer); 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); CuAssertStrEquals(tc, "herp", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[5]); 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); CuAssertStrEquals(tc, "herpder", buffer);
CuAssertIntEquals(tc, 0x7f, buffer[8]); 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 #ifndef GOODIES_H
#define GOODIES_H #define GOODIES_H
#include "strings.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -29,30 +32,6 @@ extern "C" {
extern int *intlist_add(int *i_p, int i); extern int *intlist_add(int *i_p, int i);
extern int *intlist_find(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 #ifdef __cplusplus
} }
#endif #endif

View File

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

52
src/util/strings.h Normal file
View File

@ -0,0 +1,52 @@
/*
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef STRINGS_H
#define STRINGS_H
#ifdef __cplusplus
extern "C" {
#endif
extern unsigned int hashstring(const char *s);
extern const char *escape_string(const char *str, char *buffer,
size_t 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
#endif /* STRINGS_H */

View File

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

View File

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