Move isqrt into hacklib, other minor fixage
This commit is contained in:
@@ -828,6 +828,7 @@ E char *FDECL(sitoa, (int));
|
||||
E int FDECL(sgn, (int));
|
||||
E int FDECL(rounddiv, (long,int));
|
||||
E int FDECL(dist2, (int,int,int,int));
|
||||
E int FDECL(isqrt, (int));
|
||||
E int FDECL(distmin, (int,int,int,int));
|
||||
E boolean FDECL(online2, (int,int,int,int));
|
||||
E boolean FDECL(pmatch, (const char *,const char *));
|
||||
@@ -1138,7 +1139,7 @@ E void FDECL(dodoor, (int,int,struct mkroom *));
|
||||
E void FDECL(mktrap, (int,int,struct mkroom *,coord*));
|
||||
E void FDECL(mkstairs, (XCHAR_P,XCHAR_P,CHAR_P,struct mkroom *));
|
||||
E void NDECL(mkinvokearea);
|
||||
E void FDECL(mineralize, (int, int, int, int, boolean));
|
||||
E void FDECL(mineralize, (int, int, int, int, BOOLEAN_P));
|
||||
|
||||
/* ### mkmap.c ### */
|
||||
|
||||
|
||||
@@ -432,6 +432,14 @@ dist2(x0, y0, x1, y1) /* square of euclidean distance between pair of pts */
|
||||
return dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
/* Integer square root function without using floating point.
|
||||
* This could be replaced by a faster algorithm, but has not been because:
|
||||
* + the simple algorithm is easy to read
|
||||
* + this algorithm does not require 64-bit support
|
||||
* + in current usage, the values passed to isqrt() are not really that
|
||||
* large, so the performance difference is negligible
|
||||
* + isqrt() is used in only few places, which are not bottle-necks
|
||||
*/
|
||||
int
|
||||
isqrt(val)
|
||||
int val;
|
||||
|
||||
@@ -1303,6 +1303,7 @@ struct mkroom *croom;
|
||||
|
||||
if (mtmp) {
|
||||
x = mtmp->mx, y = mtmp->my; /* sanity precaution */
|
||||
m->x = x, m->y = y;
|
||||
/* handle specific attributes for some special monsters */
|
||||
if (m->name.str) mtmp = christen_monst(mtmp, m->name.str);
|
||||
|
||||
@@ -2067,7 +2068,6 @@ struct mkroom *mkr;
|
||||
{
|
||||
boolean okroom;
|
||||
struct mkroom *aroom;
|
||||
short i;
|
||||
xchar rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM;
|
||||
|
||||
if(mkr) {
|
||||
@@ -2915,7 +2915,6 @@ void
|
||||
spo_room(coder)
|
||||
struct sp_coder *coder;
|
||||
{
|
||||
int isbigrm = FALSE;
|
||||
if (coder->n_subroom > MAX_NESTED_ROOMS)
|
||||
panic("Too deeply nested rooms?!");
|
||||
else {
|
||||
@@ -2950,8 +2949,6 @@ spo_room(coder)
|
||||
/*tmproom.irregular = (OV_i(flags) & (1 << 1));*/
|
||||
tmproom.joined = !(OV_i(flags) & (1 << 2));
|
||||
|
||||
isbigrm = ((tmproom.w * tmproom.h) > 20);
|
||||
|
||||
opvar_free(x);
|
||||
opvar_free(y);
|
||||
opvar_free(w);
|
||||
@@ -4162,7 +4159,6 @@ spo_map(coder)
|
||||
struct opvar *mpxs, *mpys, *mpmap, *mpa, *mpkeepr, *mpzalign;
|
||||
xchar halign, valign;
|
||||
xchar tmpxstart, tmpystart, tmpxsize, tmpysize;
|
||||
int tryct = 0;
|
||||
unpacked_coord upc;
|
||||
|
||||
if (!OV_pop_i(mpxs) ||
|
||||
@@ -4172,8 +4168,6 @@ spo_map(coder)
|
||||
!OV_pop_i(mpzalign) ||
|
||||
!OV_pop_c(mpa)) return;
|
||||
|
||||
redo_maploc:
|
||||
|
||||
tmpmazepart.xsize = OV_i(mpxs);
|
||||
tmpmazepart.ysize = OV_i(mpys);
|
||||
tmpmazepart.zaligntyp = OV_i(mpzalign);
|
||||
@@ -4281,7 +4275,6 @@ redo_maploc:
|
||||
xsize = tmpxsize; ysize = tmpysize;
|
||||
}
|
||||
|
||||
skipmap:
|
||||
opvar_free(mpxs);
|
||||
opvar_free(mpys);
|
||||
opvar_free(mpmap);
|
||||
|
||||
24
src/spell.c
24
src/spell.c
@@ -42,7 +42,6 @@ STATIC_DCL int NDECL(throwspell);
|
||||
STATIC_DCL void NDECL(cast_protection);
|
||||
STATIC_DCL void FDECL(spell_backfire, (int));
|
||||
STATIC_DCL const char *FDECL(spelltypemnemonic, (int));
|
||||
STATIC_DCL int FDECL(isqrt, (int));
|
||||
|
||||
/* The roles[] table lists the role-specific values for tuning
|
||||
* percent_success().
|
||||
@@ -1433,29 +1432,6 @@ int *spell_no;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Integer square root function without using floating point.
|
||||
* This could be replaced by a faster algorithm, but has not been because:
|
||||
* + the simple algorithm is easy to read
|
||||
* + this algorithm does not require 64-bit support
|
||||
* + in current usage, the values passed to isqrt() are not really that
|
||||
* large, so the performance difference is negligible
|
||||
* + isqrt() is used in only one place
|
||||
* + that one place is not a bottle-neck
|
||||
*/
|
||||
STATIC_OVL int
|
||||
isqrt(val)
|
||||
int val;
|
||||
{
|
||||
int rt = 0;
|
||||
int odd = 1;
|
||||
while(val >= odd) {
|
||||
val = val-odd;
|
||||
odd = odd+2;
|
||||
rt = rt + 1;
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
STATIC_OVL int
|
||||
percent_success(spell)
|
||||
int spell;
|
||||
|
||||
Reference in New Issue
Block a user