split some code into separate files
new .h files: hacklib.h selvar.h stairs.h
new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
strutil.c, wizcmds.c
cleanup of hacklib.c and mdlib.c
hacklib contains functions that do not have to link with the core
relocate wiz commands from cmd.c to wizcmds.c
relocate CRASHREPORT stuff to report.c
relocate getpos stuff from do_name.c to getpos.c
remove temporary struct definition from extern.h
cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370
Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates
Unix sys/unix/Makefile.src, sys/unix/Makefile.utl
populate selvar.c and selvar.h
build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)
vms updates for above (untested)
This commit is contained in:
28
src/hack.c
28
src/hack.c
@@ -4,6 +4,7 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "hack.h"
|
||||
#include "extern.h"
|
||||
|
||||
/* #define DEBUG */ /* uncomment for debugging */
|
||||
|
||||
@@ -4184,4 +4185,31 @@ spot_checks(coordxy x, coordxy y, schar old_typ)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate x/y, rounding as appropriate */
|
||||
int
|
||||
rounddiv(long x, int y)
|
||||
{
|
||||
int r, m;
|
||||
int divsgn = 1;
|
||||
|
||||
if (y == 0)
|
||||
panic("division by zero in rounddiv");
|
||||
else if (y < 0) {
|
||||
divsgn = -divsgn;
|
||||
y = -y;
|
||||
}
|
||||
if (x < 0) {
|
||||
divsgn = -divsgn;
|
||||
x = -x;
|
||||
}
|
||||
r = (int) (x / y);
|
||||
m = x % y;
|
||||
if (2 * m >= y)
|
||||
r++;
|
||||
|
||||
return divsgn * r;
|
||||
}
|
||||
|
||||
|
||||
/*hack.c*/
|
||||
|
||||
Reference in New Issue
Block a user