Move isqrt into hacklib, other minor fixage
This commit is contained in:
+2
-1
@@ -828,6 +828,7 @@ E char *FDECL(sitoa, (int));
|
|||||||
E int FDECL(sgn, (int));
|
E int FDECL(sgn, (int));
|
||||||
E int FDECL(rounddiv, (long,int));
|
E int FDECL(rounddiv, (long,int));
|
||||||
E int FDECL(dist2, (int,int,int,int));
|
E int FDECL(dist2, (int,int,int,int));
|
||||||
|
E int FDECL(isqrt, (int));
|
||||||
E int FDECL(distmin, (int,int,int,int));
|
E int FDECL(distmin, (int,int,int,int));
|
||||||
E boolean FDECL(online2, (int,int,int,int));
|
E boolean FDECL(online2, (int,int,int,int));
|
||||||
E boolean FDECL(pmatch, (const char *,const char *));
|
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(mktrap, (int,int,struct mkroom *,coord*));
|
||||||
E void FDECL(mkstairs, (XCHAR_P,XCHAR_P,CHAR_P,struct mkroom *));
|
E void FDECL(mkstairs, (XCHAR_P,XCHAR_P,CHAR_P,struct mkroom *));
|
||||||
E void NDECL(mkinvokearea);
|
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 ### */
|
/* ### mkmap.c ### */
|
||||||
|
|
||||||
|
|||||||
@@ -432,6 +432,14 @@ dist2(x0, y0, x1, y1) /* square of euclidean distance between pair of pts */
|
|||||||
return dx * dx + dy * dy;
|
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
|
int
|
||||||
isqrt(val)
|
isqrt(val)
|
||||||
int val;
|
int val;
|
||||||
|
|||||||
+1
-8
@@ -1303,6 +1303,7 @@ struct mkroom *croom;
|
|||||||
|
|
||||||
if (mtmp) {
|
if (mtmp) {
|
||||||
x = mtmp->mx, y = mtmp->my; /* sanity precaution */
|
x = mtmp->mx, y = mtmp->my; /* sanity precaution */
|
||||||
|
m->x = x, m->y = y;
|
||||||
/* handle specific attributes for some special monsters */
|
/* handle specific attributes for some special monsters */
|
||||||
if (m->name.str) mtmp = christen_monst(mtmp, m->name.str);
|
if (m->name.str) mtmp = christen_monst(mtmp, m->name.str);
|
||||||
|
|
||||||
@@ -2067,7 +2068,6 @@ struct mkroom *mkr;
|
|||||||
{
|
{
|
||||||
boolean okroom;
|
boolean okroom;
|
||||||
struct mkroom *aroom;
|
struct mkroom *aroom;
|
||||||
short i;
|
|
||||||
xchar rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM;
|
xchar rtype = (!r->chance || rn2(100) < r->chance) ? r->rtype : OROOM;
|
||||||
|
|
||||||
if(mkr) {
|
if(mkr) {
|
||||||
@@ -2915,7 +2915,6 @@ void
|
|||||||
spo_room(coder)
|
spo_room(coder)
|
||||||
struct sp_coder *coder;
|
struct sp_coder *coder;
|
||||||
{
|
{
|
||||||
int isbigrm = FALSE;
|
|
||||||
if (coder->n_subroom > MAX_NESTED_ROOMS)
|
if (coder->n_subroom > MAX_NESTED_ROOMS)
|
||||||
panic("Too deeply nested rooms?!");
|
panic("Too deeply nested rooms?!");
|
||||||
else {
|
else {
|
||||||
@@ -2950,8 +2949,6 @@ spo_room(coder)
|
|||||||
/*tmproom.irregular = (OV_i(flags) & (1 << 1));*/
|
/*tmproom.irregular = (OV_i(flags) & (1 << 1));*/
|
||||||
tmproom.joined = !(OV_i(flags) & (1 << 2));
|
tmproom.joined = !(OV_i(flags) & (1 << 2));
|
||||||
|
|
||||||
isbigrm = ((tmproom.w * tmproom.h) > 20);
|
|
||||||
|
|
||||||
opvar_free(x);
|
opvar_free(x);
|
||||||
opvar_free(y);
|
opvar_free(y);
|
||||||
opvar_free(w);
|
opvar_free(w);
|
||||||
@@ -4162,7 +4159,6 @@ spo_map(coder)
|
|||||||
struct opvar *mpxs, *mpys, *mpmap, *mpa, *mpkeepr, *mpzalign;
|
struct opvar *mpxs, *mpys, *mpmap, *mpa, *mpkeepr, *mpzalign;
|
||||||
xchar halign, valign;
|
xchar halign, valign;
|
||||||
xchar tmpxstart, tmpystart, tmpxsize, tmpysize;
|
xchar tmpxstart, tmpystart, tmpxsize, tmpysize;
|
||||||
int tryct = 0;
|
|
||||||
unpacked_coord upc;
|
unpacked_coord upc;
|
||||||
|
|
||||||
if (!OV_pop_i(mpxs) ||
|
if (!OV_pop_i(mpxs) ||
|
||||||
@@ -4172,8 +4168,6 @@ spo_map(coder)
|
|||||||
!OV_pop_i(mpzalign) ||
|
!OV_pop_i(mpzalign) ||
|
||||||
!OV_pop_c(mpa)) return;
|
!OV_pop_c(mpa)) return;
|
||||||
|
|
||||||
redo_maploc:
|
|
||||||
|
|
||||||
tmpmazepart.xsize = OV_i(mpxs);
|
tmpmazepart.xsize = OV_i(mpxs);
|
||||||
tmpmazepart.ysize = OV_i(mpys);
|
tmpmazepart.ysize = OV_i(mpys);
|
||||||
tmpmazepart.zaligntyp = OV_i(mpzalign);
|
tmpmazepart.zaligntyp = OV_i(mpzalign);
|
||||||
@@ -4281,7 +4275,6 @@ redo_maploc:
|
|||||||
xsize = tmpxsize; ysize = tmpysize;
|
xsize = tmpxsize; ysize = tmpysize;
|
||||||
}
|
}
|
||||||
|
|
||||||
skipmap:
|
|
||||||
opvar_free(mpxs);
|
opvar_free(mpxs);
|
||||||
opvar_free(mpys);
|
opvar_free(mpys);
|
||||||
opvar_free(mpmap);
|
opvar_free(mpmap);
|
||||||
|
|||||||
-24
@@ -42,7 +42,6 @@ STATIC_DCL int NDECL(throwspell);
|
|||||||
STATIC_DCL void NDECL(cast_protection);
|
STATIC_DCL void NDECL(cast_protection);
|
||||||
STATIC_DCL void FDECL(spell_backfire, (int));
|
STATIC_DCL void FDECL(spell_backfire, (int));
|
||||||
STATIC_DCL const char *FDECL(spelltypemnemonic, (int));
|
STATIC_DCL const char *FDECL(spelltypemnemonic, (int));
|
||||||
STATIC_DCL int FDECL(isqrt, (int));
|
|
||||||
|
|
||||||
/* The roles[] table lists the role-specific values for tuning
|
/* The roles[] table lists the role-specific values for tuning
|
||||||
* percent_success().
|
* percent_success().
|
||||||
@@ -1433,29 +1432,6 @@ int *spell_no;
|
|||||||
return FALSE;
|
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
|
STATIC_OVL int
|
||||||
percent_success(spell)
|
percent_success(spell)
|
||||||
int spell;
|
int spell;
|
||||||
|
|||||||
Reference in New Issue
Block a user