diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index da6d4fff..484390ed 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -603,7 +603,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_DEMOPLAYBACK: { int on = getint(p); - if(on) {} // player1->state = CS_SPECTATOR; // fixme,ah + if(on) { player1->state = CS_SPECTATE; } // player1->state = CS_SPECTATOR; // fixme,ah //else stopdemo(); else callvote(SA_STOPDEMO); demoplayback = on!=0; diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 1afc87b7..c609ee66 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -54,6 +54,10 @@ void toggleedit() addmsg(SV_EDITMODE, "ri", editing); } +// fixme! +void spec() { player1->state = CS_SPECTATE; } +COMMAND(spec, ARG_NONE); + COMMANDN(edittoggle, toggleedit, ARG_NONE); char *editinfo() diff --git a/source/src/entity.h b/source/src/entity.h index 84483b52..30c951d1 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -83,7 +83,7 @@ static inline int kick_back(int gun) { return guns[gun].mdl_kick_back; } #define team_opposite(o) ((o) == TEAM_CLA ? TEAM_RVSF : TEAM_CLA) enum { ENT_PLAYER = 0, ENT_BOT, ENT_CAMERA, ENT_BOUNCE }; -enum { CS_ALIVE = 0, CS_DEAD, CS_SPAWNING, CS_LAGGED, CS_EDITING }; +enum { CS_ALIVE = 0, CS_DEAD, CS_SPAWNING, CS_LAGGED, CS_EDITING, CS_SPECTATE }; enum { CR_DEFAULT, CR_MASTER, CR_ADMIN }; struct physent diff --git a/source/src/physics.cpp b/source/src/physics.cpp index c129b20e..0ca3b203 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -231,10 +231,11 @@ VARP(maxroll, 0, 0, 20); void moveplayer(physent *pl, int moveres, bool local, int curtime) { const bool water = hdr.waterlevel>pl->o.z-0.5f; - const bool floating = (editmode && local) || pl->state==CS_EDITING; + const bool editfly = (editmode && local) || pl->state==CS_EDITING; + const bool specfly = local && pl->state == CS_SPECTATE; const float speed = curtime/(water ? 2000.0f : 1000.0f)*(pl->crouching ? pl->maxspeed/2.0f : pl->maxspeed); - const float friction = water ? 20.0f : (pl->onfloor || floating ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); + const float friction = water ? 20.0f : (pl->onfloor || editfly || specfly ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); const float fpsfric = friction/curtime*20.0f; vec d; // vector of direction we ideally want to move in @@ -277,7 +278,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) d.y = (float)(move*sinf(RAD*(pl->yaw-90))); d.z = 0.0f; - if(floating || water) + if(editfly || specfly || water) { d.x *= (float)cosf(RAD*(pl->pitch)); d.y *= (float)cosf(RAD*(pl->pitch)); @@ -298,11 +299,17 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) pl->pitchvel *= fpsfric-3; pl->pitchvel /= fpsfric; - if(floating) // just apply velocity + if(editfly) // just apply velocity { pl->o.add(d); if(pl->jumpnext) { pl->jumpnext = false; pl->vel.z = 2; } } + if(specfly) + { + drop = 0.0f; + rise = speed/moveres/1.2f; + if(pl->jumpnext) { pl->jumpnext = false; pl->vel.z = 2; } + } else // apply velocity with collisions { if(pl->onladder) @@ -342,19 +349,19 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) int sound = timeinair > 800 ? S_HARDLAND : S_SOFTLAND; if(local) playsoundc(sound); else playsound(sound, pl); } + + const float gravity = 20.0f; + float dropf = (gravity-1)+pl->timeinair/15.0f; // incorrect, but works fine + if(water) { dropf = 5; pl->timeinair = 0; } // float slowly down in water + if(pl->onladder) { dropf = 0; pl->timeinair = 0; } + + drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast + rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs + if(pl->maxspeed-16>0.5f) pl += 0xF0F0; } - - const float gravity = 20.0f; - float dropf = (gravity-1)+pl->timeinair/15.0f; // incorrect, but works fine - if(water) { dropf = 5; pl->timeinair = 0; } // float slowly down in water - if(pl->onladder) { dropf = 0; pl->timeinair = 0; } - - drop = dropf*curtime/gravity/100/moveres; // at high fps, gravity kicks in too fast - rise = speed/moveres/1.2f; // extra smoothness when lifting up stairs - if(pl->maxspeed-16>0.5f) pl += 0xF0F0; } - if(!floating) loopi(moveres) // discrete steps collision detection & sliding + if(!editfly) loopi(moveres) // discrete steps collision detection & sliding { const float f = 1.0f/moveres; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 7f717ecc..aa3f701b 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -525,7 +525,7 @@ void drawhudgun(int w, int h, float aspect, int farplane) gluPerspective((float)100.0f*h/w, aspect, 0.3f, farplane); // fov fixed at 100° glMatrixMode(GL_MODELVIEW); - if(player1->state!=CS_DEAD) renderhudgun(); + if(player1->state==CS_ALIVE) renderhudgun(); rendermenumdl(); glMatrixMode(GL_PROJECTION); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 390a1d09..b43861fe 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -182,6 +182,7 @@ void drawradar(int w, int h) float coordtrans = radarsize/worldsize; float overlaysize = radarviewsize*4.0f/3.25f; + glColor3f(1.0f, 1.0f, 1.0f); glPushMatrix(); if(showmap) glTranslatef(VIRTW/2-radarviewsize/2, 0, 0); @@ -312,7 +313,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat else if((player1->gunselect!=GUN_SNIPER || drawteamwarning)) drawcrosshair(drawteamwarning); } - drawequipicons(); + if(player1->state==CS_ALIVE) drawequipicons(); glMatrixMode(GL_MODELVIEW); if(!menu && !hideradar) drawradar(w, h); diff --git a/source/src/server.cpp b/source/src/server.cpp index c02acf6e..f6bcd64c 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -724,8 +724,8 @@ void setupdemoplayback() { endianswap(&hdr.version, sizeof(int), 1); endianswap(&hdr.protocol, sizeof(int), 1); - if(hdr.version!=DEMO_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of Sauerbraten", file, hdr.versiongunselect!=GUN_SHOTGUN) //no spread on shotgun + if(d->gunselect!=GUN_SHOTGUN) // no spread on shotgun { #define RNDD (rnd(spd)-spd/2)*f vec r(RNDD, RNDD, RNDD); @@ -729,6 +729,8 @@ bool akimboside = false; void shoot(playerent *d, vec &targ) { + if(d->state != CS_ALIVE) return; + int attacktime = lastmillis-d->lastaction; vec from = d->o;