spectator mode during demoplayback

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1435 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-11-17 16:57:48 +00:00
parent ca1406a955
commit 3bdd0129f7
8 changed files with 35 additions and 21 deletions
+1 -1
View File
@@ -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;
+4
View File
@@ -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()
+1 -1
View File
@@ -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
+21 -14
View File
@@ -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;
+1 -1
View File
@@ -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);
+2 -1
View File
@@ -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);
+2 -2
View File
@@ -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.version<DEMO_VERSION ? "older" : "newer");
else if(hdr.protocol!=PROTOCOL_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of Sauerbraten", file, hdr.protocol<PROTOCOL_VERSION ? "older" : "newer");
if(hdr.version!=DEMO_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.version<DEMO_VERSION ? "older" : "newer");
else if(hdr.protocol!=PROTOCOL_VERSION) s_sprintf(msg)("demo \"%s\" requires an %s version of AssaultCube", file, hdr.protocol<PROTOCOL_VERSION ? "older" : "newer");
}
if(msg[0])
{
+3 -1
View File
@@ -696,7 +696,7 @@ void spreadandrecoil(vec &from, vec &to, playerent *d)
rcl = rcl / 3;
}
if(d->gunselect!=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;