]> granicus.if.org Git - nethack/commitdiff
Move isqrt into hacklib, other minor fixage
authorPasi Kallinen <paxed@alt.org>
Wed, 1 Apr 2015 13:38:56 +0000 (16:38 +0300)
committerPasi Kallinen <paxed@alt.org>
Wed, 1 Apr 2015 13:38:56 +0000 (16:38 +0300)
include/extern.h
src/hacklib.c
src/sp_lev.c
src/spell.c

index 00d10a98f3a1f76d6fb0c3acca9be5a5d8487692..4e2780c6b6bca65bf7520eafd671a13bb6122c36 100644 (file)
@@ -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 ### */
 
index 4fdbceb8007be4953bc80eacd293aa7cdebca76c..a9c31d42dcf90967dece90edc764e1902bbc46d3 100644 (file)
@@ -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;
index 6e42b2c31a4bf9e0a5de9f0330d903c529abb877..09005a32e33039d05b1d46982bb73736d8e087dc 100644 (file)
@@ -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);
index 5ce0a6015e6754ad820be0ae3e0d8afdf361218c..2ccf7eea624e5a79fdfd4cdbdda5f13f068f7a04 100644 (file)
@@ -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;