diff --git a/source/src/entities.cpp b/source/src/entities.cpp index b3afef2e..f4146711 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -382,20 +382,11 @@ void flagstolen(int flag, int action, int act) void flagdropped(int flag, int action, short x, short y, short z) { flaginfo &f = flaginfos[flag]; - sqr *dropplace = S_SECURE(x, y); - if(!dropplace) return; - - z -= 4; - float floor = (float) dropplace->floor; - if(z > hdr.waterlevel) // above water - { - if(floor < hdr.waterlevel) z = hdr.waterlevel; // avoid dropping into water - else z = (short) floor; - } - - f.flag->x = x; - f.flag->y = y; - f.flag->z = z; + if(OUTBORD(x, y)) return; + f.flag->x = x; + f.flag->y = y; + f.flag->z = (short)floor(x, y); + if(f.flag->z < hdr.waterlevel) f.flag->z = (short) hdr.waterlevel; f.flag->spawned = true; f.ack = true; flagmsg(flag, action); diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 29c1cea8..c23fe04f 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -212,6 +212,12 @@ bool collide(physent *d, bool spawn, float drop, float rise) return true; } +float floor(short x, short y) +{ + sqr *s = S(x, y); + return s->type == FHF ? s->floor-(s->vdelta+S(x+1,y)->vdelta+S(x,y+1)->vdelta+S(x+1,y+1)->vdelta)/16.0f : s->floor; +} + VARP(maxroll, 0, 0, 20); // main physics routine, moves a player/monster for a curtime step @@ -264,7 +270,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) d.x = (float)(move*cosf(RAD*(pl->yaw-90))); d.y = (float)(move*sinf(RAD*(pl->yaw-90))); - d.z = (float)pl->type==ENT_BOUNCE ? pl->vel.z : 0; + d.z = 0.0f; if(floating || water) { diff --git a/source/src/protos.h b/source/src/protos.h index c9bd8d47..8043fcad 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -240,6 +240,7 @@ extern void entinmap(physent *d); extern void physicsframe(); extern void mousemove(int dx, int dy); extern void fixcamerarange(physent *cam = camera1); +extern float floor(short x, short y); // sound extern void playsound(int n, vec *loc = 0); diff --git a/source/src/world.h b/source/src/world.h index ff428b13..0a414e37 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -50,7 +50,6 @@ struct header // map file format header #define SWS(w,x,y,s) (&(w)[(y)*(s)+(x)]) #define SW(w,x,y) SWS(w,x,y,ssize) #define S(x,y) SW(world,x,y) // convenient lookup of a lowest mip cube -#define S_SECURE(x, y) ((y)*ssize+(x)<=mipsize ? S(x,y) : NULL) // same as above, but validates coords #define SMALLEST_FACTOR 6 // determines number of mips there can be #define DEFAULT_FACTOR 8 #define LARGEST_FACTOR 11 // 10 is already insane