Move isqrt into hacklib, other minor fixage
This commit is contained in:
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