From 2fa895ae908df531a4b305ed76439ecfe46dad2c Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 29 Apr 2017 20:29:48 +0200 Subject: [PATCH] use fov and roll values of remote player during spectating spectfovremote 0|1 '1' uses fov and scopefov of the spectated player, '0' uses spectfov and the local scopefov, default is '0' maxrollremote sets the maximum roll to be shown during spectating DOCREF spectfovremote --- source/src/client.cpp | 4 ++++ source/src/clients2c.cpp | 7 +++++-- source/src/entity.h | 3 ++- source/src/rendergl.cpp | 8 ++++++-- source/src/server.cpp | 8 ++++++++ source/src/server.h | 2 ++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index 39bf0b65..34080850 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -564,6 +564,10 @@ void sendintro() connectrole = CR_DEFAULT; putint(p, player1->nextprimweap->type); loopi(2) putint(p, player1->skin(i)); + putint(p, player1->maxroll); + putint(p, player1->maxrolleffect); + putint(p, player1->ffov); + putint(p, player1->scopefov); sendpackettoserv(1, p.finalize()); } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index de4c7ffd..f12a02f1 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -621,6 +621,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) getstring(text, p); loopi(2) getint(p); getint(p); + loopi(4) getint(p); if(!demo || !watchingdemo || demoprotocol > 1132) getint(p); break; } @@ -641,8 +642,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) loopi(2) d->setskin(i, getint(p)); d->team = getint(p); -// d->maxroll = (float)clamp(getint(p), 0, ROLLMOVMAX); FIXME: uncomment on protocol bump + etc. -// d->maxrolleffect = (float)clamp(getint(p), 0, ROLLEFFMAX); FIXME: uncomment on protocol bump + d->maxroll = (float)clamp(getint(p), 0, ROLLMOVMAX); + d->maxrolleffect = (float)clamp(getint(p), 0, ROLLEFFMAX); + d->ffov = (float)clamp(getint(p), 75, 120); + d->scopefov = (float)clamp(getint(p), 5, 60); if(!demo || !watchingdemo || demoprotocol > 1132) d->address = getint(p); // partial IP address diff --git a/source/src/entity.h b/source/src/entity.h index 5061ce4b..9f3a809d 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -433,6 +433,7 @@ public: int spectatemode, followplayercn; int eardamagemillis; float maxroll, maxrolleffect, movroll, effroll; // roll added by movement and damage + int ffov, scopefov; bool allowmove() { return state!=CS_DEAD || spectatemode==SM_FLY; } weapon *weapons[NUMGUNS]; @@ -451,7 +452,7 @@ public: bool nocorpse; playerent() : curskin(0), clientnum(-1), lastupdate(0), plag(0), ping(0), address(0), lifesequence(0), frags(0), flagscore(0), deaths(0), points(0), tks(0), lastpain(0), lastvoicecom(0), lastdeath(0), clientrole(CR_DEFAULT), - team(TEAM_SPECT), spectatemode(SM_NONE), eardamagemillis(0), maxroll(ROLLMOVDEF), maxrolleffect(ROLLEFFDEF), movroll(0), effroll(0), + team(TEAM_SPECT), spectatemode(SM_NONE), eardamagemillis(0), maxroll(ROLLMOVDEF), maxrolleffect(ROLLEFFDEF), movroll(0), effroll(0), ffov(0), scopefov(0), prevweaponsel(NULL), weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), smoothmillis(-1), head(-1, -1, -1), ignored(false), muted(false), nocorpse(false) diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 975b534a..8120e1ec 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -469,18 +469,22 @@ void fovchanged(); FVARFP(fov, 75, 90, 120, fovchanged()); VARFP(scopefov, 5, 50, 60, fovchanged()); VARP(spectfov, 5, 110, 120); +VARP(spectfovremote, 0, 0, 1); // use spectfov or remote player's fov when spectating void fovchanged() { extern float autoscopesensscale; autoscopesensscale = tan(((float)scopefov)*0.5f*RAD)/tan(fov*0.5f*RAD); + player1->ffov = (int)fov; + player1->scopefov = scopefov; } float dynfov() { bool isscoped = player1->weaponsel->type == GUN_SNIPER && ((sniperrifle *)player1->weaponsel)->scoped; + bool useremote = spectfovremote && camera1 != player1 && camera1->type == ENT_PLAYER && ((playerent *)camera1)->ffov && ((playerent *)camera1)->scopefov; if(camera1 != player1 && camera1->type < ENT_CAMERA) isscoped = ((playerent *)camera1)->scoping; - if(isscoped) return (float)scopefov; - else if(player1->isspectating()) return (float)spectfov; + if(isscoped) return (float) (useremote ? ((playerent *)camera1)->scopefov : scopefov); + else if(player1->isspectating()) return (float)(useremote ? ((playerent *)camera1)->ffov : spectfov); else return (float)fov; } diff --git a/source/src/server.cpp b/source/src/server.cpp index de281d59..4928c6dd 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -2959,6 +2959,10 @@ void putinitclient(client &c, packetbuf &p) putint(p, c.skin[TEAM_CLA]); putint(p, c.skin[TEAM_RVSF]); putint(p, c.team); + putint(p, c.maxroll); + putint(p, c.maxrolleffect); + putint(p, c.ffov); + putint(p, c.scopefov); putint(p, c.ip_censored); } @@ -3260,6 +3264,10 @@ void process(ENetPacket *packet, int sender, int chan) int wantrole = getint(p), np = getint(p); cl->state.nextprimary = np > 0 && np < NUMGUNS ? np : GUN_ASSAULT; loopi(2) cl->skin[i] = getint(p); + cl->maxroll = getint(p); + cl->maxrolleffect = getint(p); + cl->ffov = getint(p); + cl->scopefov = getint(p); int bantype = getbantype(sender); bool banned = bantype > BAN_NONE; bool srvfull = numnonlocalclients() > scl.maxclients; diff --git a/source/src/server.h b/source/src/server.h index 91f5b858..3509e6f5 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -259,6 +259,7 @@ struct client // server side version of "dynent" type string servinforesponse; string name; int team; + int maxroll, maxrolleffect, ffov, scopefov; char lang[3]; int ping; int skin[2]; @@ -359,6 +360,7 @@ struct client // server side version of "dynent" type vita = NULL; bottomRTT = ping = 9999; team = TEAM_SPECT; + maxroll = maxrolleffect = ffov = scopefov = 0; state.state = CS_SPECTATE; loopi(2) skin[i] = 0; position.setsize(0);