The power of 2, faster.

This commit is contained in:
Enno Rehling 2007-02-12 23:08:32 +00:00
parent 8077027b42
commit 88b041880c
3 changed files with 9 additions and 9 deletions

View File

@ -70,7 +70,7 @@ createmonsters(void)
set_string(&f->email, "monsters@eressea.de");
set_string(&f->name, "Monster");
f->alive = 1;
f->options = (char) pow(2, O_REPORT);
f->options = (char)(1<<O_REPORT);
addlist(&factions, f);
fhash(f);
}

View File

@ -2094,12 +2094,12 @@ send_cmd(unit * u, struct order * ord)
if (option == O_COMPRESS || option == O_BZIP2) {
cmistake(u, ord, 305, MSG_EVENT);
} else {
u->faction->options = u->faction->options & ~((int)pow(2, option));
u->faction->options = u->faction->options & ~(1<<option);
}
} else {
u->faction->options = u->faction->options | ((int)pow(2, option));
if(option == O_COMPRESS) u->faction->options &= ~((int)pow(2, O_BZIP2));
if(option == O_BZIP2) u->faction->options &= ~((int)pow(2, O_COMPRESS));
u->faction->options = u->faction->options | (1<<option);
if(option == O_COMPRESS) u->faction->options &= ~(1<<O_BZIP2);
if(option == O_BZIP2) u->faction->options &= ~(1<<O_COMPRESS);
}
}
return 0;

View File

@ -1056,16 +1056,16 @@ farcasting(unit *magician, region *r)
int mult;
if (!r) {
return 1025;
return INT_MAX;
}
dist = koor_distance(r->x, r->y, magician->region->x, magician->region->y);
if (dist > 24) return 1025;
if (dist > 24) return INT_MAX;
mult = (int)pow(2.0,(double)dist);
mult = 1 << dist;
if (dist > 1) {
if (!path_exists(magician->region, r, dist*2, allowed_fly)) mult = 1025;
if (!path_exists(magician->region, r, dist*2, allowed_fly)) mult = INT_MAX;
}
return mult;