diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 0fe50242a..38e58ef3d 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -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; +} diff --git a/source/core/gameinput.h b/source/core/gameinput.h index f7ede18fa..b5bdd194b 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -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); diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index 998fb26a5..97b736819 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -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;