diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 7377cdea..ae679520 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -331,15 +331,10 @@ void audiomanager::updateplayerfootsteps(playerent *p) { // play footsteps - int grounddist; - if( ((int)p->o.x) >= 0 && ((int)p->o.y) >= 0 && ((int)p->o.x) < ssize && ((int)p->o.y) < ssize) { // sam's fix to the sound crash - grounddist = hdr.waterlevel-S((int)p->o.x, (int)p->o.y)->floor; - }else{ - grounddist = 0; - } -// int grounddist = hdr.waterlevel-S((int)p->o.x, (int)p->o.y)->floor; - bool water = p->o.z-p->eyeheight+0.25fp->eyeheight) return; // don't play step sound when jumping into water + float grounddist = 0; + if(!((int(p->o.x) | int(p->o.y)) & ~(ssize - 1))) grounddist = waterlevel - S((int)p->o.x, (int)p->o.y)->floor; + bool water = p->o.z - p->eyeheight+0.25f < waterlevel; + if(water && grounddist > p->eyeheight) return; // don't play step sound when jumping into water int stepsound; if(p->crouching) stepsound = water ? S_WATERFOOTSTEPSCROUCH : S_FOOTSTEPSCROUCH; // crouch @@ -573,7 +568,7 @@ void audiomanager::updateaudio() } // water - bool underwater = /*alive &&*/ firstperson && hdr.waterlevel>player1->o.z+player1->aboveeye; + bool underwater = /*alive &&*/ firstperson && waterlevel > player1->o.z + player1->aboveeye; updateloopsound(S_UNDERWATER, underwater); // tinnitus diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index 1ded4097..c1850b1e 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -1744,7 +1744,7 @@ bool CBot::WaterNav() if (UnderWater(v)) continue; // Skip, cube is underwater - if (hdr.waterlevel < (v.z - 2.0f)) continue; // Cube is too high + if (waterlevel < (v.z - 2.0f)) continue; // Cube is too high // Check if the bot 'can fit' on the cube(no near obstacles) bool small_ = false; diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h index 2a50f563..e1be0b83 100644 --- a/source/src/bot/bot_util.h +++ b/source/src/bot/bot_util.h @@ -17,8 +17,8 @@ bool FileIsOlder(const char *szFileName1, const char *szFileName2); vec PredictPos(vec pos, vec vel, float Time); vec Normalize(vec v); inline void makevec(vec *v, float x, float y, float z) { v->x=x; v->y=y; v->z=z; } -inline bool UnderWater(const vec &o) { return hdr.waterlevel>o.z-0.5f; } -inline bool InWater(const vec &o) { return hdr.waterlevel>=o.z; } +inline bool UnderWater(const vec &o) { return waterlevel > o.z - 0.5f; } +inline bool InWater(const vec &o) { return waterlevel >= o.z; } float GetYawDiff(float curyaw, vec v1, vec v2); vec CrossProduct(const vec &a, const vec &b); int GetDirection(const vec &angles, const vec &v1, const vec &v2); diff --git a/source/src/cube.h b/source/src/cube.h index 80d86d24..aa419f01 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -60,6 +60,7 @@ extern hashtable mapinfo; extern int hwtexsize, hwmaxaniso; extern int numspawn[3], maploaded, numflagspawn[2]; extern int verbose; +extern float waterlevel; #define AC_VERSION 1202 #define AC_MASTER_URI "ms.cubers.net" diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 0fa95f8e..d22fea93 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -898,7 +898,7 @@ void movemap(int xo, int yo, int zo) // move whole map S(x,y)->floor = max(-128, S(x,y)->floor + zo); S(x,y)->ceil = min(127, S(x,y)->ceil + zo); } - setvar("waterlevel", (hdr.waterlevel += zo)); + setfvar("waterlevel", waterlevel + zo, true); } loopv(ents) { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 3d02e3c5..efde1907 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -588,7 +588,7 @@ void flagdropped(int flag, float x, float y, float z) f.pos.x = round(p.o.x); f.pos.y = round(p.o.y); f.pos.z = round(p.o.z); - if(f.pos.z < hdr.waterlevel) f.pos.z = (short) hdr.waterlevel; + if(f.pos.z < waterlevel) f.pos.z = waterlevel; f.flagent->spawned = true; f.ack = true; } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 58ff1ce5..87395c7e 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -328,7 +328,7 @@ void resizephysent(physent *pl, int moveres, int curtime, float min, float max) { if(pl->eyeheightvel==0.0f) return; - const bool water = hdr.waterlevel>pl->o.z; + const bool water = waterlevel > pl->o.z; const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); float h = pl->eyeheightvel * speed / moveres; @@ -391,7 +391,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) if(pl->type==ENT_BOUNCE) { bounceent* bounce = (bounceent *) pl; - water = hdr.waterlevel>pl->o.z; + water = waterlevel > pl->o.z; const float speed = curtime*pl->maxspeed/(water ? 2000.0f : 1000.0f); const float friction = water ? 20.0f : (pl->onfloor || isfly ? 6.0f : 30.0f); @@ -423,7 +423,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) { const int timeinair = pl->timeinair; int move = pl->onladder && !pl->onfloor && pl->move == -1 ? 0 : pl->move; // movement on ladder - if(!editfly) water = hdr.waterlevel>pl->o.z-0.5f; + if(!editfly) water = waterlevel > pl->o.z - 0.5f; float chspeed = 0.4f; if(!(pl->onfloor || pl->onladder)) chspeed = 1.0f; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 9fe1ed8a..fb2fa568 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -840,7 +840,7 @@ void drawminimap(int w, int h) renderzones(mapdims.maxceil); //renderentities();// IMHO better done by radar itself, if at all resettmu(0); - float hf = hdr.waterlevel-0.3f; + float hf = waterlevel - 0.3f; renderwater(hf, 0, 0); //draw a black border to prevent the minimap texture edges from bleeding in radarview @@ -1001,7 +1001,7 @@ void gl_drawframe(int w, int h, float changelod, float curfps) aspect = float(w)/h; fovy = 2*atan2(tan(float(dynfov())/2*RAD), aspect)/RAD; - float hf = hdr.waterlevel-0.3f; + float hf = waterlevel - 0.3f; bool underwater = camera1->o.zo.dist(camera1->o) <= sz*1.25f; //1.25 is max wobble scale vec oc(p->o); oc.sub(camera1->o); - if(reflecting && !refracting) oc.z = p->o.z - (hdr.waterlevel-0.3f); + if(reflecting && !refracting) oc.z = p->o.z - (waterlevel - 0.3f); glRotatef(inside ? camera1->yaw - 180 : atan2(oc.y, oc.x)/RAD - 90, 0, 0, 1); glRotatef((inside ? camera1->pitch : asin(oc.z/oc.magnitude())/RAD) - 90, 1, 0, 0); @@ -641,7 +641,7 @@ bool addbullethole(dynent *d, const vec &from, const vec &to, float radius, bool //newparticle(o, surface, bulletholettl, 7); if(noisy && bulletbouncesound && bulletbouncesoundrad && d!=player1 && o.dist(camera1->o) <= bulletbouncesoundrad) { - audiomgr.playsound(o.z= 0) { float x = p.x / p.w, y = p.y / p.w; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 5d5acabf..923f5001 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -567,7 +567,7 @@ void addgib(playerent *d) p->o = d->o; p->o.z -= d->aboveeye; - p->inwater = hdr.waterlevel>p->o.z; + p->inwater = waterlevel > p->o.z; p->yaw = (float)rnd(360); p->pitch = (float)rnd(360); @@ -1037,7 +1037,7 @@ void grenadeent::_throw(const vec &from, const vec &vel) this->vel = vel; this->o = from; this->resetinterp(); - inwater = hdr.waterlevel>o.z; + inwater = waterlevel > o.z; if(local) { addmsg(SV_THROWNADE, "ri7", int(o.x*DMF), int(o.y*DMF), int(o.z*DMF), int(vel.x*DMF), int(vel.y*DMF), int(vel.z*DMF), lastmillis-millis); @@ -1050,7 +1050,7 @@ void grenadeent::moveoutsidebbox(const vec &direction, playerent *boundingbox) { vel = direction; o = boundingbox->o; - inwater = hdr.waterlevel>o.z; + inwater = waterlevel > o.z; boundingbox->cancollide = false; loopi(10) moveplayer(this, 10, true, 10); diff --git a/source/src/world.cpp b/source/src/world.cpp index 602c221c..86c8bc2a 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -613,7 +613,8 @@ bool empty_world(int factor, bool force) // main empty world creation routine memset(&hdr, 0, sizeof(header)); mapconfigdata.clear(); formatstring(hdr.maptitle)("Untitled Map by %s", player1->name); - setvar("waterlevel", (hdr.waterlevel = -100000)); + setfvar("waterlevel", -10000); + hdr.waterlevel = waterlevel * WATERLEVELSCALING; setwatercolor(); loopk(3) loopi(256) hdr.texlists[k][i] = i; ents.shrink(0); diff --git a/source/src/world.h b/source/src/world.h index cbdf3628..09ab1367 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -115,6 +115,7 @@ struct mapdim #define MAXMAREA 10000 #define MAXHHITS 50000 // was 6000, which denied my fav. maps - jamz, 2012-06-12; 15000 denies sane map too - lucas #define MINFF 2500 +#define WATERLEVELSCALING 10 struct block { int x, y, xs, ys, h; short p[5]; }; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 16c0d143..eb7fd83c 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -691,7 +691,8 @@ bool load_world(char *mname) // still supports all map formats that have hdr.waterlevel = -100000; hdr.ambient = 0; } - setvar("waterlevel", hdr.waterlevel); + if(hdr.version < 10) hdr.waterlevel *= WATERLEVELSCALING; + setfvar("waterlevel", float(hdr.waterlevel) / WATERLEVELSCALING); ents.shrink(0); loopi(3) numspawn[i] = 0; loopi(2) numflagspawn[i] = 0; @@ -945,7 +946,7 @@ struct xmap clearheaderextras(); resetmap(true); curmaprevision = hdr.maprevision; - setvar("waterlevel", hdr.waterlevel); + setfvar("waterlevel", float(hdr.waterlevel) / WATERLEVELSCALING); ::ents.shrink(0); loopv(ents) restoreent(i); delete[] ::world; diff --git a/source/src/worldrender.cpp b/source/src/worldrender.cpp index 8fd31045..3ccd6d9c 100644 --- a/source/src/worldrender.cpp +++ b/source/src/worldrender.cpp @@ -165,14 +165,14 @@ void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs, { sqr *v = SWS(s,0,1,mfactor); render_flat(s->ftex, xx<floor, s, s + 1, v + 1, v, false); - if(s->floorfloor < waterlevel && !reflecting) addwaterquad(xx<ftex, xx<floor-s->vdelta/4.0ffloor - s->vdelta/4.0f < waterlevel && !reflecting) addwaterquad(xx<