Index: src/Monster.m ================================================================== --- src/Monster.m +++ src/Monster.m @@ -196,11 +196,11 @@ return false; float x = lx; float y = ly; int i = 0; for (;;) { - struct sqr *s = S(fast_f2nat(x), fast_f2nat(y)); + struct sqr *s = S((int)x, (int)y); if (SOLID(s)) break; float floor = s->floor; if (s->type == FHF) floor -= s->vdelta / 4.0f; Index: src/physics.m ================================================================== --- src/physics.m +++ src/physics.m @@ -98,14 +98,14 @@ // figure out integer cube rectangle this entity covers in map const float fx1 = d.origin.x - d.radius; const float fy1 = d.origin.y - d.radius; const float fx2 = d.origin.x + d.radius; const float fy2 = d.origin.y + d.radius; - const int x1 = fast_f2nat(fx1); - const int y1 = fast_f2nat(fy1); - const int x2 = fast_f2nat(fx2); - const int y2 = fast_f2nat(fy2); + const int x1 = fx1; + const int y1 = fy1; + const int x2 = fx2; + const int y2 = fy2; float hi = 127, lo = -128; // big monsters are afraid of heights, unless angry :) float minfloor = ([d isKindOfClass:Monster.class] && !spawn && d.health > 100 ? d.origin.z - d.eyeHeight - 4.5f Index: src/tools.h ================================================================== --- src/tools.h +++ src/tools.h @@ -34,12 +34,10 @@ #ifndef OF_WINDOWS # define __cdecl #endif -#define fast_f2nat(val) ((int)(val)) - #ifdef __cplusplus extern "C" { #endif extern void endianswap(void *, int, int); #ifdef __cplusplus Index: src/worldlight.m ================================================================== --- src/worldlight.m +++ src/worldlight.m @@ -29,13 +29,12 @@ int x = (int)(lx * PRECF); int y = (int)(ly * PRECF); int l = light.attr2 << PRECBITS; int stepx = (int)(dx / (float)steps * PRECF); int stepy = (int)(dy / (float)steps * PRECF); - int stepl = - fast_f2nat(l / (float)steps); // incorrect: light will fade quicker - // if near edge of the world + // incorrect: light will fade quicker if near edge of the world + int stepl = l / (float)steps; if (hasoverbright) { l /= lightscale; stepl /= lightscale; @@ -52,13 +51,13 @@ if (OUTBORD(x >> PRECBITS, y >> PRECBITS)) return; int g = light.attr3 << PRECBITS; - int stepg = fast_f2nat(g / (float)steps); + int stepg = g / (float)steps; int b = light.attr4 << PRECBITS; - int stepb = fast_f2nat(b / (float)steps); + int stepb = b / (float)steps; g /= lightscale; stepg /= lightscale; b /= lightscale; stepb /= lightscale; for (int i = 0; i < steps; i++) { Index: src/worldocull.m ================================================================== --- src/worldocull.m +++ src/worldocull.m @@ -33,19 +33,16 @@ float byaw = (player1.yaw - 90 + af) / 360 * PI2; float syaw = (player1.yaw - 90 - af) / 360 * PI2; for (int i = 0; i < NUMRAYS; i++) { float angle = i * PI2 / NUMRAYS; - if ((apitch > 45 // must be bigger if fov>120 - || (angle < byaw && angle > syaw) || + // try to avoid tracing ray if outside of frustrum + // apitch must be bigger if fov > 120 + if ((apitch > 45 || (angle < byaw && angle > syaw) || (angle < byaw - PI2 && angle > syaw - PI2) || (angle < byaw + PI2 && angle > syaw + PI2)) && - !OUTBORD(vx, vy) && - !SOLID(S(fast_f2nat(vx), - fast_f2nat(vy)))) // try to avoid tracing ray if outside - // of frustrum - { + !OUTBORD(vx, vy) && !SOLID(S((int)vx, (int)vy))) { float ray = i * 8 / (float)NUMRAYS; float dx, dy; if (ray > 1 && ray < 3) { dx = -(ray - 2); dy = 1; @@ -64,11 +61,11 @@ for (;;) { sx += dx; sy += dy; // 90% of time spend in this function is on this // line - if (SOLID(S(fast_f2nat(sx), fast_f2nat(sy)))) { + if (SOLID(S((int)sx, (int)sy))) { rdist[i] = (float)(fabs(sx - vx) + fabs(sy - vy)); break; } } @@ -181,13 +178,13 @@ } else { h = ca(cx + csize - vx, cy - vy); l = ca(cx - vx, cy + csize - vy); } // H } - int si = fast_f2nat(h * (NUMRAYS / 8)) + - NUMRAYS; // get indexes into occlusion map from angles - int ei = fast_f2nat(l * (NUMRAYS / 8)) + NUMRAYS + 1; + // get indexes into occlusion map from angles + int si = h * (NUMRAYS / 8) + NUMRAYS; + int ei = l * (NUMRAYS / 8) + NUMRAYS + 1; if (ei <= si) ei += NUMRAYS; for (int i = si; i <= ei; i++) { if (dist < rdist[i & (NUMRAYS - 1)])