Behebung einiger double->int conversion warnings (immer noch ein Haufen drin)

This commit is contained in:
Enno Rehling 2004-02-07 16:12:59 +00:00
parent f9a7ecb796
commit f3f8bd811d
2 changed files with 65 additions and 56 deletions

View File

@ -347,14 +347,14 @@ magicanalyse_ship(ship *sh, unit *mage, int force)
* 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.
*/ */
int double
destr_curse(curse* c, int cast_level, int force) 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 */
int chance; double chance;
/* pro Stufe Unterschied -20% */ /* pro Stufe Unterschied -20% */
chance = (10 + (cast_level - c->vigour)*2); chance = 0.1 + (cast_level - c->vigour)*0.2;
if(rand()%10 >= chance){ if (rand()%100 >= chance*100) {
force -= c->vigour; force -= c->vigour;
if (c->type->change_vigour){ if (c->type->change_vigour){
c->type->change_vigour(c, -(cast_level+1/2)); c->type->change_vigour(c, -(cast_level+1/2));
@ -377,8 +377,7 @@ destr_curse(curse* c, int cast_level, int force)
} }
int int
destroy_curse(attrib **alist, int cast_level, int force, destroy_curse(attrib **alist, int cast_level, double force, curse * c)
curse * c)
{ {
int succ = 0; int succ = 0;
/* attrib **a = a_find(*ap, &at_curse); */ /* attrib **a = a_find(*ap, &at_curse); */
@ -403,18 +402,16 @@ destroy_curse(attrib **alist, int cast_level, int force,
* auf alle Verzauberungen wirken. Ansonsten prüfe, ob der Curse vom * auf alle Verzauberungen wirken. Ansonsten prüfe, ob der Curse vom
* richtigen Typ ist. */ * richtigen Typ ist. */
if(!c || c==c1) { if(!c || c==c1) {
int n; double remain = destr_curse(c1, cast_level, force);
n = destr_curse(c1, cast_level, force); if (remain < force) {
if (n != force){
assert(n<force); /* force darf sich nur vermindert haben */
succ = cast_level; succ = cast_level;
force = n; force = remain;
} }
if(c1->vigour <= 0) { if (c1->vigour <= 0) {
a_remove(ap, a); a_remove(ap, a);
} }
} }
if(*ap) ap = &(*ap)->next; if (*ap) ap = &(*ap)->next;
} }
return succ; return succ;
} }
@ -731,7 +728,7 @@ sp_destroy_magic(castorder *co)
succ = destroy_curse(ap, cast_level, force, c); succ = destroy_curse(ap, cast_level, force, c);
if(succ) { if (succ) {
add_message(&mage->faction->msgs, new_message(mage->faction, add_message(&mage->faction->msgs, new_message(mage->faction,
"destroy_magic_effect%u:unit%r:region%s:command%i:succ%s:target", "destroy_magic_effect%u:unit%r:region%s:command%i:succ%s:target",
mage, mage->region, strdup(co->order), succ, strdup(ts))); mage, mage->region, strdup(co->order), succ, strdup(ts)));
@ -956,9 +953,9 @@ sp_summonent(castorder *co)
int ents; int ents;
#if GROWING_TREES #if GROWING_TREES
if(rtrees(r,2) == 0) { if (rtrees(r,2) == 0) {
#else #else
if(rtrees(r) == 0) { if (rtrees(r) == 0) {
#endif #endif
cmistake(mage, strdup(co->order), 204, MSG_EVENT); cmistake(mage, strdup(co->order), 204, MSG_EVENT);
/* nicht ohne bäume */ /* nicht ohne bäume */
@ -966,9 +963,9 @@ sp_summonent(castorder *co)
} }
#if GROWING_TREES #if GROWING_TREES
ents = min(power*power, rtrees(r,2)); ents = (int)min(power*power, rtrees(r,2));
#else #else
ents = min(power*power, rtrees(r)); ents = (int)min(power*power, rtrees(r));
#endif #endif
u = create_unit(r, mage->faction, ents, new_race[RC_TREEMAN], 0, LOC(mage->faction->locale, rc_name(new_race[RC_TREEMAN], ents!=1)), mage); u = create_unit(r, mage->faction, ents, new_race[RC_TREEMAN], 0, LOC(mage->faction->locale, rc_name(new_race[RC_TREEMAN], ents!=1)), mage);
@ -1067,7 +1064,7 @@ sp_maelstrom(castorder *co)
int cast_level = co->level; int cast_level = co->level;
curse * c; curse * c;
double power = co->force; double power = co->force;
int duration = power+1; int duration = (int)power+1;
if(rterrain(r) != T_OCEAN) { if(rterrain(r) != T_OCEAN) {
cmistake(mage, strdup(co->order), 205, MSG_MAGIC); cmistake(mage, strdup(co->order), 205, MSG_MAGIC);
@ -1078,7 +1075,7 @@ sp_maelstrom(castorder *co)
/* Attribut auf Region. /* Attribut auf Region.
* Existiert schon ein curse, so wird dieser verstärkt * Existiert schon ein curse, so wird dieser verstärkt
* (Max(Dauer), Max(Stärke))*/ * (Max(Dauer), Max(Stärke))*/
c = create_curse(mage, &mage->attribs, ct_find("maelstrom"), power, duration, power,0); c = create_curse(mage, &mage->attribs, ct_find("maelstrom"), power, duration, (int)power, 0);
curse_setflag(c, CURSE_ISNEW); curse_setflag(c, CURSE_ISNEW);
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
@ -1157,7 +1154,7 @@ sp_blessedharvest(castorder *co)
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = power+1; int duration = (int)power+1;
/* Attribut auf Region. /* Attribut auf Region.
* Existiert schon ein curse, so wird dieser verstärkt * Existiert schon ein curse, so wird dieser verstärkt
@ -1203,7 +1200,7 @@ sp_hain(castorder *co)
return 0; return 0;
} }
trees = lovar((int)(force * 10 * RESOURCE_QUANTITY)) + force; trees = lovar((int)(force * 10 * RESOURCE_QUANTITY)) + (int)force;
#if GROWING_TREES #if GROWING_TREES
rsettrees(r, 1, rtrees(r,1) + trees); rsettrees(r, 1, rtrees(r,1) + trees);
#else #else
@ -1250,7 +1247,7 @@ sp_mallornhain(castorder *co)
return 0; return 0;
} }
trees = lovar((int)(force * 10 * RESOURCE_QUANTITY)) + force; trees = lovar((int)(force * 10 * RESOURCE_QUANTITY)) + (int)force;
#if GROWING_TREES #if GROWING_TREES
rsettrees(r, 1, rtrees(r,1) + trees); rsettrees(r, 1, rtrees(r,1) + trees);
#else #else
@ -1282,7 +1279,7 @@ patzer_ents(castorder *co)
return; return;
} }
ents = force*10; ents = (int)(force*10);
u = create_unit(r, findfaction(MONSTER_FACTION), ents, new_race[RC_TREEMAN], 0, u = create_unit(r, findfaction(MONSTER_FACTION), ents, new_race[RC_TREEMAN], 0,
LOC(default_locale, rc_name(new_race[RC_TREEMAN], ents!=1)), NULL); LOC(default_locale, rc_name(new_race[RC_TREEMAN], ents!=1)), NULL);
@ -1341,28 +1338,28 @@ sp_rosthauch(castorder *co)
/* Eisenwaffen: I_SWORD, I_GREATSWORD, I_AXE, I_HALBERD (50% Chance)*/ /* Eisenwaffen: I_SWORD, I_GREATSWORD, I_AXE, I_HALBERD (50% Chance)*/
ironweapon = 0; ironweapon = 0;
i = min(get_item(u, I_SWORD), force); i = min(get_item(u, I_SWORD), (int)force);
if (i > 0){ if (i > 0) {
change_item(u, I_SWORD, -i); change_item(u, I_SWORD, -i);
change_item(u, I_RUSTY_SWORD, i); change_item(u, I_RUSTY_SWORD, i);
force -= i; force -= i;
ironweapon += i; ironweapon += i;
} }
i = min(get_item(u, I_GREATSWORD), force); i = min(get_item(u, I_GREATSWORD), (int)force);
if (i > 0){ if (i > 0){
change_item(u, I_GREATSWORD, -i); change_item(u, I_GREATSWORD, -i);
change_item(u, I_RUSTY_GREATSWORD, i); change_item(u, I_RUSTY_GREATSWORD, i);
force -= i; force -= i;
ironweapon += i; ironweapon += i;
} }
i = min(get_item(u, I_AXE), force); i = min(get_item(u, I_AXE), (int)force);
if (i > 0){ if (i > 0){
change_item(u, I_AXE, -i); change_item(u, I_AXE, -i);
change_item(u, I_RUSTY_AXE, i); change_item(u, I_RUSTY_AXE, i);
force -= i; force -= i;
ironweapon += i; ironweapon += i;
} }
i = min(get_item(u, I_HALBERD), force); i = min(get_item(u, I_HALBERD), (int)force);
if (i > 0){ if (i > 0){
if(rand()%100 < 50){ if(rand()%100 < 50){
change_item(u, I_HALBERD, -i); change_item(u, I_HALBERD, -i);
@ -1424,7 +1421,7 @@ sp_kaelteschutz(castorder *co)
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
double force = co->force; double force = co->force;
int duration = max(cast_level, force) + 1; int duration = max(cast_level, (int)force) + 1;
spellparameter *pa = co->par; spellparameter *pa = co->par;
@ -1442,7 +1439,7 @@ sp_kaelteschutz(castorder *co)
u = pa->param[n]->data.u; u = pa->param[n]->data.u;
if (force < u->number){ if (force < u->number){
men = force; men = (int)force;
} else { } else {
men = u->number; men = u->number;
} }
@ -1832,7 +1829,7 @@ sp_treewalkenter(castorder *co)
assert(rt != NULL); assert(rt != NULL);
remaining_cap = power * 500; remaining_cap = (int)(power * 500);
/* fuer jede Einheit */ /* fuer jede Einheit */
for (n = 0; n < pa->length; n++) { for (n = 0; n < pa->length; n++) {
@ -1930,7 +1927,7 @@ sp_treewalkexit(castorder *co)
return 0; return 0;
} }
remaining_cap = power * 500; remaining_cap = (int)(power * 500);
if(pa->param[0]->typ != SPP_REGION){ if(pa->param[0]->typ != SPP_REGION){
report_failure(mage, co->order); report_failure(mage, co->order);
@ -2160,7 +2157,7 @@ sp_drought(castorder *co)
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int duration = power+1; int duration = (int)power+1;
if(rterrain(r) == T_OCEAN ) { if(rterrain(r) == T_OCEAN ) {
cmistake(mage, strdup(co->order), 189, MSG_MAGIC); cmistake(mage, strdup(co->order), 189, MSG_MAGIC);
@ -2191,7 +2188,7 @@ sp_drought(castorder *co)
c = get_curse(r->attribs, ct_find("drought")); c = get_curse(r->attribs, ct_find("drought"));
if (c) { if (c) {
c->vigour = max(c->vigour, power); c->vigour = max(c->vigour, power);
c->duration = max(c->duration, power); c->duration = max(c->duration, (int)power);
} else { } else {
/* Baeume und Pferde sterben */ /* Baeume und Pferde sterben */
#if GROWING_TREES #if GROWING_TREES
@ -2230,14 +2227,14 @@ sp_fog_of_confusion(castorder *co)
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int range; double range;
int duration; int duration;
regionlist *rl,*rl2; regionlist *rl,*rl2;
range = (power-11)/3-1; range = (power-11)/3-1;
duration = ((power-11)/3)*2+1; duration = ((power-11)/3)*2+1;
rl = all_in_range(r, range); rl = all_in_range(r, (int)range);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
curse * c; curse * c;
@ -2786,7 +2783,6 @@ sp_summondragon(castorder *co)
faction *f; faction *f;
int time; int time;
int number; int number;
int range;
const race * race; const race * race;
f = findfaction(MONSTER_FACTION); f = findfaction(MONSTER_FACTION);
@ -2823,8 +2819,7 @@ sp_summondragon(castorder *co)
} }
} }
range = power; rl = all_in_range(r, (int)power);
rl = all_in_range(r, range);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
for(u = rl2->region->units; u; u = u->next) { for(u = rl2->region->units; u; u = u->next) {
@ -3016,7 +3011,7 @@ static void
wall_move(const border * b, struct unit * u, const struct region * from, const struct region * to) wall_move(const border * b, struct unit * u, const struct region * from, const struct region * to)
{ {
wall_data * fd = (wall_data*)b->data; wall_data * fd = (wall_data*)b->data;
int hp = dice(2, fd->force) * u->number; int hp = dice(3, fd->force) * u->number;
if (fd->active) { if (fd->active) {
hp = min (u->hp, hp); hp = min (u->hp, hp);
u->hp -= hp; u->hp -= hp;
@ -3055,6 +3050,7 @@ sp_firewall(castorder *co)
unit * u; unit * u;
border * b; border * b;
wall_data * fd; wall_data * fd;
attrib * a;
region *r = co->rt; region *r = co->rt;
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
@ -3076,13 +3072,28 @@ sp_firewall(castorder *co)
return 0; return 0;
} }
b = new_border(&bt_firewall, r, r2); b = get_borders(r, r2);
fd = (wall_data*)b->data; while (b!=NULL) {
fd->force = (force+1)/2; if (b->type == &bt_firewall) break;
fd->mage = mage; }
fd->active = false; if (b==NULL) {
b = new_border(&bt_firewall, r, r2);
fd = (wall_data*)b->data;
fd->force = (force+1)/2;
fd->mage = mage;
fd->active = false;
} else {
fd = (wall_data*)b->data;
fd->force = max(fd->force, (force+1)/2);
}
a_add(&b->attribs, a_new(&at_countdown))->data.i = cast_level; a = a_find(b->attribs, &at_countdown);
if (a==NULL) {
a = a_add(&b->attribs, a_new(&at_countdown));
a->data.i = cast_level;
} else {
a->data.i = max(a->data.i, cast_level);
}
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH); for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
@ -4974,14 +4985,12 @@ sp_dragonsong(castorder *co)
double power = co->force; double power = co->force;
regionlist *rl,*rl2; regionlist *rl,*rl2;
faction *f; faction *f;
int range;
/* TODO HP-Effekt */ /* TODO HP-Effekt */
f = findfaction(MONSTER_FACTION); f = findfaction(MONSTER_FACTION);
range = power; rl = all_in_range(r, (int)power);
rl = all_in_range(r, range);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
for(u = rl2->region->units; u; u = u->next) { for(u = rl2->region->units; u; u = u->next) {
@ -5544,10 +5553,10 @@ sp_dream_of_confusion(castorder *co)
unit *mage = (unit *)co->magician; unit *mage = (unit *)co->magician;
int cast_level = co->level; int cast_level = co->level;
double power = co->force; double power = co->force;
int range = (power-14)/2-1; double range = (power-14)/2-1;
int duration = ((power-14)/2)*2+1; int duration = ((power-14)/2)*2+1;
rl = all_in_range(r, range); rl = all_in_range(r, (int)range);
for(rl2 = rl; rl2; rl2 = rl2->next) { for(rl2 = rl; rl2; rl2 = rl2->next) {
curse * c; curse * c;
@ -5882,7 +5891,7 @@ sp_pullastral(castorder *co)
case 1: case 1:
rt = r; rt = r;
ro = pa->param[0]->data.r; ro = pa->param[0]->data.r;
rl = all_in_range(r_astral_to_standard(r),TP_RADIUS); rl = all_in_range(r_astral_to_standard(r), TP_RADIUS);
rl2 = rl; rl2 = rl;
while(rl2) { while(rl2) {
if(rl2->region->x == ro->x && rl2->region->y == ro->y) { if(rl2->region->x == ro->x && rl2->region->y == ro->y) {
@ -6013,7 +6022,7 @@ sp_leaveastral(castorder *co)
MSG_MAGIC, ML_MISTAKE); MSG_MAGIC, ML_MISTAKE);
return 0; return 0;
} }
rl = allinhab_in_range(r_astral_to_standard(r),TP_RADIUS); rl = allinhab_in_range(r_astral_to_standard(r), TP_RADIUS);
rl2 = rl; rl2 = rl;
while(rl2) { while(rl2) {
if(rl2->region == rt) break; if(rl2->region == rt) break;

View File

@ -223,7 +223,7 @@ int use_item_power(struct region * r, struct unit * u);
int use_item_regeneration(struct region * r, struct unit * u); int use_item_regeneration(struct region * r, struct unit * u);
void showspells(struct region *r, struct unit *u); void showspells(struct region *r, struct unit *u);
int sp_antimagiczone(struct castorder *co); int sp_antimagiczone(struct castorder *co);
int destr_curse(struct curse* c, int cast_level, int force); extern double destr_curse(struct curse* c, int cast_level, double force);