reduce conversion warning to float only

This commit is contained in:
Enno Rehling 2015-05-15 13:32:22 +02:00
parent 94f373e43a
commit eac4ef7ddc
6 changed files with 37 additions and 22 deletions

View File

@ -13,7 +13,7 @@ include_directories (${BSON_INCLUDE_DIR})
include_directories (${INIPARSER_INCLUDE_DIR})
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wconversion -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wfloat-conversion -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL")
elseif(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /WX /MP")

View File

@ -79,7 +79,7 @@ typedef struct request {
struct request *next;
struct unit *unit;
struct order *ord;
int qty;
unsigned int qty;
int no;
union {
bool goblin; /* stealing */
@ -91,9 +91,9 @@ static int working;
static request entertainers[1024];
static request *nextentertainer;
static int entertaining;
static unsigned int entertaining;
static int norders;
static unsigned int norders;
static request *oa;
#define RECRUIT_MERGE 1
@ -123,13 +123,13 @@ int income(const unit * u)
}
}
static void scramble(void *data, int n, size_t width)
static void scramble(void *data, unsigned int n, size_t width)
{
int j;
unsigned int j;
char temp[64];
assert(width <= sizeof(temp));
for (j = 0; j != n; ++j) {
int k = rng_int() % n;
unsigned int k = rng_uint() % n;
if (k == j)
continue;
memcpy(temp, (char *)data + j * width, width);
@ -162,7 +162,7 @@ static void expandorders(region * r, request * requests)
oa = (request *)calloc(norders, sizeof(request));
for (o = requests; o; o = o->next) {
if (o->qty > 0) {
int j;
unsigned int j;
for (j = o->qty; j; j--) {
oa[i] = *o;
oa[i].unit->n = 0;
@ -297,7 +297,7 @@ static int horse_recruiters(const struct race *rc, int qty)
if (rc->ec_flags & ECF_REC_ETHEREAL)
return -1;
if (rc->ec_flags & ECF_REC_HORSES)
return (int)(qty * 2 * rc->recruit_multi);
return (int)(qty * 2.0 * rc->recruit_multi);
return -1;
}
@ -354,7 +354,7 @@ static int do_recruiting(recruitment * recruits, int available)
unit *u = req->unit;
const race *rc = u_race(u); /* race is set in recruit() */
int number, dec;
float multi = 2.0F * rc->recruit_multi;
double multi = 2.0 * rc->recruit_multi;
number = _min(req->qty, (int)(get / multi));
if (rc->recruitcost) {
@ -463,7 +463,6 @@ static int recruit_cost(const faction * f, const race * rc)
static void recruit(unit * u, struct order *ord, request ** recruitorders)
{
int n;
region *r = u->region;
plane *pl;
request *o;
@ -471,9 +470,14 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
const faction *f = u->faction;
const struct race *rc = u_race(u);
const char *str;
int n;
init_order(ord);
n = getuint();
n = getint();
if (n<=0) {
syntax_error(u, ord);
return;
}
if (u->number == 0) {
char token[128];
@ -1784,8 +1788,8 @@ static void buy(unit * u, request ** buyorders, struct order *ord)
kwd = init_order(ord);
assert(kwd == K_BUY);
n = getuint();
if (!n) {
n = getint();
if (n<=0) {
cmistake(u, ord, 26, MSG_COMMERCE);
return;
}
@ -2997,10 +3001,11 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders)
return;
}
max = getuint();
max = getint();
if (max == 0)
if (max <= 0) {
max = INT_MAX;
}
if (!playerrace(u_race(u))) {
u->wants = _min(income(u), max);
}
@ -3070,10 +3075,11 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders)
return;
}
max = getuint();
max = getint();
if (max == 0)
if (max <= 0) {
max = INT_MAX;
}
if (!playerrace(u_race(u))) {
u->wants = _min(income(u), max);
}

View File

@ -282,6 +282,14 @@ message * cmistake(const unit * u, struct order *ord, int mno, int mtype)
return result;
}
void syntax_error(const struct unit *u, struct order *ord)
{
message * result;
result = msg_error(u, ord, 10);
ADDMSG(&u->faction->msgs, result);
msg_release(result);
}
extern unsigned int new_hashstring(const char *s);
void free_messagelist(message_list * msgs)

View File

@ -56,6 +56,7 @@ extern "C" {
#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } }
void syntax_error(const struct unit *u, struct order *ord);
struct message * cmistake(const struct unit *u, struct order *ord, int mno, int mtype);
struct message * msg_error(const struct unit * u, struct order *ord, int mno);
#ifdef __cplusplus

View File

@ -123,9 +123,9 @@ extern "C" {
struct param *parameters;
char *_name;
float magres;
float maxaura; /* Faktor auf Maximale Aura */
float regaura; /* Faktor auf Regeneration */
float recruit_multi; /* Faktor für Bauernverbrauch */
double maxaura; /* Faktor auf Maximale Aura */
double regaura; /* Faktor auf Regeneration */
double recruit_multi; /* Faktor für Bauernverbrauch */
int index;
int recruitcost;
int maintenance;

View File

@ -509,7 +509,7 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
rnl(F);
}
void sparagraph(strlist ** SP, const char *s, int indent, char mark)
void sparagraph(strlist ** SP, const char *s, unsigned int indent, char mark)
{
/* Die Liste SP wird mit dem String s aufgefuellt, mit indent und einer