- added serializers for PlayerAngle and PlayerHorizon.

This commit is contained in:
Christoph Oelckers 2020-10-11 16:55:12 +02:00
parent 1757ef2aa6
commit cb8d2eb94c
3 changed files with 46 additions and 11 deletions

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "gamecontrol.h"
#include "gameinput.h"
#include "gamestruct.h"
#include "serializer.h"
CVARD(Bool, invertmousex, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert horizontal mouse movement")
CVARD(Bool, invertmouse, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "invert vertical mouse movement")
@ -325,3 +326,42 @@ void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double
}
}
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def)
{
if (arc.BeginObject(keyname))
{
arc("ang", w.ang)
("lookang", w.look_ang)
("rotscrnang", w.rotscrnang)
("spin", w.spin)
.EndObject();
if (arc.isReading())
{
w.oang = w.ang;
w.olook_ang = w.look_ang;
w.orotscrnang = w.rotscrnang;
w.resetadjustment();
}
}
return arc;
}
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def)
{
if (arc.BeginObject(keyname))
{
arc("horiz", w.horiz)
("horizoff", w.horizoff)
.EndObject();
if (arc.isReading())
{
w.ohoriz = w.horiz;
w.ohorizoff = w.horizoff;
w.resetadjustment();
w.settarget(0);
}
}
return arc;
}

View file

@ -179,6 +179,10 @@ struct PlayerAngle
}
};
class FSerializer;
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
void sethorizon(fixedhoriz* horiz, float const horz, ESyncBits* actions, double const scaleAdjust);
void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double const scaleAdjust, bool const crouching);

View file

@ -113,12 +113,8 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
arc("posx", w.posx)
("posy", w.posy)
("posz", w.posz)
("ang", w.angle.ang)
("look_ang", w.angle.look_ang)
("rotscrnang", w.angle.rotscrnang)
("horiz", w.horizon.horiz)
("horizoff", w.horizon.horizoff)
("spin", w.angle.spin)
("angle", w.angle)
("horizon", w.horizon)
("gotweapon", w.gotweapon)
("palette", w.palette)
("pals", w.pals)
@ -284,11 +280,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
.EndObject();
w.invdisptime = 0;
w.angle.oang = w.angle.ang;
w.angle.olook_ang = w.angle.look_ang;
w.angle.orotscrnang = w.angle.rotscrnang;
w.horizon.ohoriz = w.horizon.horiz;
w.horizon.ohorizoff = w.horizon.horizoff;
w.oposx = w.posx;
w.oposy = w.posy;
w.oposz = w.posz;