fix saving.

This commit is contained in:
Christoph Oelckers 2023-10-02 21:38:58 +02:00
parent dd2ea96d6c
commit d815eff5d1
12 changed files with 461 additions and 469 deletions

View file

@ -28,6 +28,7 @@ public:
DCorePlayer(uint8_t p) : pnum(p) {} DCorePlayer(uint8_t p) : pnum(p) {}
void OnDestroy() override { if (actor) actor->Destroy(); actor = nullptr; } void OnDestroy() override { if (actor) actor->Destroy(); actor = nullptr; }
virtual DCoreActor* GetActor() = 0; virtual DCoreActor* GetActor() = 0;
void Serialize(FSerializer& arc) override;
}; };
extern DCorePlayer* PlayerArray[MAXPLAYERS]; extern DCorePlayer* PlayerArray[MAXPLAYERS];

View file

@ -604,11 +604,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngles& w, P
("spin", w.YawSpin) ("spin", w.YawSpin)
("actor", w.pActor) ("actor", w.pActor)
.EndObject(); .EndObject();
if (arc.isReading())
{
w.resetCameraAngles();
}
} }
return arc; return arc;
} }

View file

@ -143,10 +143,13 @@ struct PlayerAngles
} }
void resetCameraAngles() void resetCameraAngles()
{ {
// Apply any last remaining ticrate angle updates and reset variables. if (pActor != nullptr)
CameraAngles += pActor->spr.Angles - PrevLerpAngles; {
PrevLerpAngles = pActor->spr.Angles = CameraAngles; // Apply any last remaining ticrate angle updates and reset variables.
PrevViewAngles = ViewAngles; CameraAngles += pActor->spr.Angles - PrevLerpAngles;
PrevLerpAngles = pActor->spr.Angles = CameraAngles;
PrevViewAngles = ViewAngles;
}
} }
// Draw code helpers. // Draw code helpers.

View file

@ -64,6 +64,7 @@
#include "serialize_obj.h" #include "serialize_obj.h"
#include "games/blood/src/mapstructs.h" #include "games/blood/src/mapstructs.h"
#include "texinfo.h" #include "texinfo.h"
#include "coreplayer.h"
#include <miniz.h> #include <miniz.h>
#include "buildtiles.h" #include "buildtiles.h"
@ -172,6 +173,12 @@ bool ReadSavegame(const char* name)
arc.Close(); arc.Close();
info->Unlock(); info->Unlock();
delete savereader; delete savereader;
// this can only be done after the load is complete
for (auto pl : PlayerArray)
{
pl->Angles.resetCameraAngles();
}
ResetStatusBar(); ResetStatusBar();
return true; return true;
} }
@ -622,6 +629,17 @@ FSerializer& Serialize(FSerializer& arc, const char* key, ActorStatList& c, Acto
return arc; return arc;
} }
void DCorePlayer::Serialize(FSerializer& arc)
{
Super::Serialize(arc);
arc("pnum", pnum)
("actor", actor)
("angles", Angles)
//("cmd", cmd)
//("lastcmd", lastcmd)
;
}
void DCoreActor::Serialize(FSerializer& arc) void DCoreActor::Serialize(FSerializer& arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
@ -682,6 +700,7 @@ void SerializeMap(FSerializer& arc)
arc("maplocals", Level) arc("maplocals", Level)
// everything here should move into MapLocals as well later. // everything here should move into MapLocals as well later.
.Array("statlist", statList, MAXSTATUS) .Array("statlist", statList, MAXSTATUS)
.Array("players",PlayerArray, MAXPLAYERS)
("sectors", sector, sectorbackup) ("sectors", sector, sectorbackup)
("walls", wall, wallbackup) ("walls", wall, wallbackup)

View file

@ -176,6 +176,7 @@ class DBloodPlayer final : public DCorePlayer
DBloodPlayer() = default; DBloodPlayer() = default;
public: public:
DBloodPlayer(uint8_t p) : DCorePlayer(p) {} DBloodPlayer(uint8_t p) : DCorePlayer(p) {}
void Serialize(FSerializer& arc) override;
void Clear() void Clear()
{ {
Super::Clear(); Super::Clear();

View file

@ -2395,103 +2395,97 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, POSTURE& w, POSTUR
return arc; return arc;
} }
FSerializer& Serialize(FSerializer& arc, const char* keyname, DBloodPlayer& w, DBloodPlayer* def) void DBloodPlayer::Serialize(FSerializer& arc)
{ {
if (arc.BeginObject(keyname)) arc
{ ("newweapon", newWeapon)
arc("spritenum", w.actor) ("weaponqav", weaponQav)
("angles", w.Angles) ("qavcallback", qavCallback)
("newweapon", w.newWeapon) ("isrunning", isRunning)
("weaponqav", w.weaponQav) ("posture", posture)
("qavcallback", w.qavCallback) ("sceneqav", sceneQav)
("isrunning", w.isRunning) ("bobphase", bobPhase)
("posture", w.posture) ("bobamp", bobAmp)
("sceneqav", w.sceneQav) ("bobheight", bobHeight)
("bobphase", w.bobPhase) ("bobwidth", bobWidth)
("bobamp", w.bobAmp) ("swayamp", swayAmp)
("bobheight", w.bobHeight) ("swayheight", swayHeight)
("bobwidth", w.bobWidth) ("swaywidth", swayWidth)
("swayamp", w.swayAmp) ("lifemode", lifeMode)
("swayheight", w.swayHeight) ("zview", zView)
("swaywidth", w.swayWidth) ("zviewvel", zViewVel)
("nplayer", w.pnum) ("zweapon", zWeapon)
("lifemode", w.lifeMode) ("zweaponvel", zWeaponVel)
("zview", w.zView) ("slope", slope)
("zviewvel", w.zViewVel) ("underwater", isUnderwater)
("zweapon", w.zWeapon) .Array("haskey", hasKey, 8)
("zweaponvel", w.zWeaponVel) ("hasflag", hasFlag)
("slope", w.slope) .Array("ctfflagstate", ctfFlagState, 2)
("underwater", w.isUnderwater) .Array("dmgcontrol", damageControl, 7)
.Array("haskey", w.hasKey, 8) ("curweapon", curWeapon)
("hasflag", w.hasFlag) ("nextweapon", nextWeapon)
.Array("ctfflagstate", w.ctfFlagState, 2) ("weapontimer", weaponTimer)
.Array("dmgcontrol", w.damageControl, 7) ("weaponstate", weaponState)
("curweapon", w.curWeapon) ("weaponammo", weaponAmmo)
("nextweapon", w.nextWeapon) .Array("hasweapon", hasWeapon, countof(hasWeapon))
("weapontimer", w.weaponTimer) .Array("weaponmode", weaponMode, countof(weaponMode))
("weaponstate", w.weaponState) .Array("weaponorder", &weaponOrder[0][kWeapNone], +kWeapMax * 2)
("weaponammo", w.weaponAmmo) .Array("ammocount", ammoCount, countof(ammoCount))
.Array("hasweapon", w.hasWeapon, countof(w.hasWeapon)) ("qavloop", qavLoop)
.Array("weaponmode", w.weaponMode, countof(w.weaponMode)) ("qavlastTick", qavLastTick)
.Array("weaponorder", &w.weaponOrder[0][kWeapNone], +kWeapMax * 2) ("qavtimer", qavTimer)
.Array("ammocount", w.ammoCount, countof(w.ammoCount)) ("fusetime", fuseTime)
("qavloop", w.qavLoop) ("throwtime", throwTime)
("qavlastTick", w.qavLastTick) ("throwpower", throwPower)
("qavtimer", w.qavTimer) ("aim", aim)
("fusetime", w.fuseTime) ("relaim", relAim)
("throwtime", w.throwTime) ("aimtarget", aimTarget)
("throwpower", w.throwPower) ("aimtargetscount", aimTargetsCount)
("aim", w.aim) .Array("aimtargets", aimTargets, countof(aimTargets))
("relaim", w.relAim) ("deathtime", deathTime)
("aimtarget", w.aimTarget) .Array("pwuptime", pwUpTime, countof(pwUpTime))
("aimtargetscount", w.aimTargetsCount) ("fragcount", fragCount)
.Array("aimtargets", w.aimTargets, countof(w.aimTargets)) .Array("fraginfo", fragInfo, countof(fragInfo))
("deathtime", w.deathTime) ("teamid", teamId)
.Array("pwuptime", w.pwUpTime, countof(w.pwUpTime)) ("fraggerid", fragger)
("fragcount", w.fragCount) ("undserwatertime", underwaterTime)
.Array("fraginfo", w.fragInfo, countof(w.fragInfo)) ("bubbletime", bubbleTime)
("teamid", w.teamId) ("resttime", restTime)
("fraggerid", w.fragger) ("kickpower", kickPower)
("undserwatertime", w.underwaterTime) ("laughcount", laughCount)
("bubbletime", w.bubbleTime) ("godmode", godMode)
("resttime", w.restTime) ("fallscream", fallScream)
("kickpower", w.kickPower) ("cantjump", cantJump)
("laughcount", w.laughCount) ("packitemtime", packItemTime)
("godmode", w.godMode) ("packitemid", packItemId)
("fallscream", w.fallScream) .Array("packslots", packSlots, countof(packSlots))
("cantjump", w.cantJump) .Array("armor", armor, countof(armor))
("packitemtime", w.packItemTime) ("voodootarget", voodooTarget)
("packitemid", w.packItemId) ("voodootargets", voodooTargets)
.Array("packslots", w.packSlots, countof(w.packSlots)) ("voodoovar1", voodooVar1)
.Array("armor", w.armor, countof(w.armor)) ("voodoovar2", vodooVar2)
("voodootarget", w.voodooTarget) ("flickereffect", flickerEffect)
("voodootargets", w.voodooTargets) ("tilteffect", tiltEffect)
("voodoovar1", w.voodooVar1) ("visibility", visibility)
("voodoovar2", w.vodooVar2) ("paineffect", painEffect)
("flickereffect", w.flickerEffect) ("blindeffect", blindEffect)
("tilteffect", w.tiltEffect) ("chokeeffect", chokeEffect)
("visibility", w.visibility) ("handtime", handTime)
("paineffect", w.painEffect) ("hand", hand)
("blindeffect", w.blindEffect) ("pickupeffect", pickupEffect)
("chokeeffect", w.chokeEffect) ("flasheffect", flashEffect)
("handtime", w.handTime) ("quakeeffect", quakeEffect)
("hand", w.hand) ("player_par", player_par)
("pickupeffect", w.pickupEffect) ("waterpal", nWaterPal)
("flasheffect", w.flashEffect) ("actions", cmd.ucmd.actions)
("quakeeffect", w.quakeEffect) .Array("posturedata", &pPosture[0][0], &gPostureDefaults[0][0], kModeMax * kPostureMax) // only save actual changes in this.
("player_par", w.player_par) ;
("waterpal", w.nWaterPal)
("actions", w.cmd.ucmd.actions)
.Array("posturedata", &w.pPosture[0][0], &gPostureDefaults[0][0], kModeMax * kPostureMax) // only save actual changes in this.
.EndObject();
if (arc.isReading()) if (arc.isReading())
{ {
playerResetPosture(&w); playerResetPosture(this);
w.cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve. cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve.
}
} }
return arc;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2527,8 +2521,6 @@ void SerializePlayers(FSerializer& arc)
{ {
arc("numplayers", gNetPlayers) arc("numplayers", gNetPlayers)
.Array("teamscore", team_score, gNetPlayers) .Array("teamscore", team_score, gNetPlayers)
#pragma message("Blood: Fix saving!")
//.Array("players", PlayerArray, gNetPlayers)
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
.Array("playerctrl", gPlayerCtrl, gNetPlayers) .Array("playerctrl", gPlayerCtrl, gNetPlayers)
#endif #endif

View file

@ -103,180 +103,175 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_orig& w, pl
return arc; return arc;
} }
FSerializer& Serialize(FSerializer& arc, const char* keyname, DDukePlayer& w, DDukePlayer* def) void DDukePlayer::Serialize(FSerializer& arc)
{ {
if (arc.BeginObject(keyname)) Super::Serialize(arc);
{ arc("angles", Angles)
arc("angles", w.Angles) .Array("gotweapon", gotweapon, MAX_WEAPONS)
.Array("gotweapon", w.gotweapon, MAX_WEAPONS) ("pals", pals)
("pals", w.pals) ("fricx", fric.X)
("fricx", w.fric.X) ("fricy", fric.Y)
("fricy", w.fric.Y) ("exitx", Exit.X)
("exitx", w.Exit.X) ("exity", Exit.Y)
("exity", w.Exit.Y) ("numloogs", numloogs)
("numloogs", w.numloogs) ("loogcnt", loogcnt)
("loogcnt", w.loogcnt) .Array("loogie", loogie, numloogs)
.Array("loogie", w.loogie, w.numloogs) ("bobposx", bobpos.X)
("bobposx", w.bobpos.X) ("bobposy", bobpos.Y)
("bobposy", w.bobpos.Y) ("pyoff", pyoff)
("pyoff", w.pyoff) ("posxv", vel.X)
("posxv", w.vel.X) ("posyv", vel.Y)
("posyv", w.vel.Y) ("poszv", vel.Z)
("poszv", w.vel.Z) ("last_pissed_time", last_pissed_time)
("last_pissed_time", w.last_pissed_time) ("truefz", truefz)
("truefz", w.truefz) ("truecz", truecz)
("truecz", w.truecz) ("player_par", player_par)
("player_par", w.player_par) ("visibility", visibility)
("visibility", w.visibility) ("bobcounter", bobcounter)
("bobcounter", w.bobcounter) ("weapon_sway", weapon_sway)
("weapon_sway", w.weapon_sway) ("randomflamex", randomflamex)
("randomflamex", w.randomflamex) ("crack_time", crack_time)
("crack_time", w.crack_time) ("aim.mode", aim_mode)
("aim.mode", w.aim_mode) ("psectlotag", psectlotag)
("psectlotag", w.psectlotag) ("cursectnum", cursector)
("cursectnum", w.cursector) ("last_extra", last_extra)
("last_extra", w.last_extra) ("subweapon", subweapon)
("subweapon", w.subweapon) .Array("ammo_count", ammo_amount, MAX_WEAPONS)
.Array("ammo_count", w.ammo_amount, MAX_WEAPONS) ("wackedbyactor", wackedbyactor)
("wackedbyactor", w.wackedbyactor) ("frag", frag)
("frag", w.frag) ("fraggedself", fraggedself)
("fraggedself", w.fraggedself) ("curr_weapon", curr_weapon)
("curr_weapon", w.curr_weapon) ("last_weapon", last_weapon)
("last_weapon", w.last_weapon) ("tipincs", tipincs)
("tipincs", w.tipincs) ("wantweaponfire", wantweaponfire)
("wantweaponfire", w.wantweaponfire) ("holoduke_amount", holoduke_amount)
("holoduke_amount", w.holoduke_amount) ("newowner", newOwner)
("newowner", w.newOwner) ("hurt_delay", hurt_delay)
("hurt_delay", w.hurt_delay) ("hbomb_hold_delay", hbomb_hold_delay)
("hbomb_hold_delay", w.hbomb_hold_delay) ("jumping_counter", jumping_counter)
("jumping_counter", w.jumping_counter) ("airleft", airleft)
("airleft", w.airleft) ("knee_incs", knee_incs)
("knee_incs", w.knee_incs) ("access_incs", access_incs)
("access_incs", w.access_incs) ("ftq", ftq)
("ftq", w.ftq) ("access_wallnum", access_wall)
("access_wallnum", w.access_wall) ("access_spritenum", access_spritenum)
("access_spritenum", w.access_spritenum) ("kickback_pic", kickback_pic)
("kickback_pic", w.kickback_pic) ("got_access", got_access)
("got_access", w.got_access) ("weapon_ang", weapon_ang)
("weapon_ang", w.weapon_ang) ("firstaid_amount", firstaid_amount)
("firstaid_amount", w.firstaid_amount) ("somethingonplayer", somethingonplayer)
("somethingonplayer", w.somethingonplayer) ("on_crane", on_crane)
("on_crane", w.on_crane) ("one_parallax_sectnum", one_parallax_sectnum)
("i", w.actor) ("over_shoulder_on", over_shoulder_on)
("one_parallax_sectnum", w.one_parallax_sectnum) ("random_club_frame", random_club_frame)
("over_shoulder_on", w.over_shoulder_on) ("fist_incs", fist_incs)
("random_club_frame", w.random_club_frame) ("dummyplayersprite", dummyplayersprite)
("fist_incs", w.fist_incs) ("extra_extra8", extra_extra8)
("dummyplayersprite", w.dummyplayersprite) ("quick_kick", quick_kick)
("extra_extra8", w.extra_extra8) ("last_quick_kick", last_quick_kick)
("quick_kick", w.quick_kick) ("heat_amount", heat_amount)
("last_quick_kick", w.last_quick_kick) ("actorsqu", actorsqu)
("heat_amount", w.heat_amount) ("timebeforeexit", timebeforeexit)
("actorsqu", w.actorsqu) ("customexitsound", customexitsound)
("timebeforeexit", w.timebeforeexit) ("weapreccnt", weapreccnt)
("customexitsound", w.customexitsound) .Array("weaprecs", weaprecs, weapreccnt)
("weapreccnt", w.weapreccnt) ("interface_toggle_flag", interface_toggle_flag)
.Array("weaprecs", w.weaprecs, w.weapreccnt) ("dead_flag", dead_flag)
("interface_toggle_flag", w.interface_toggle_flag) ("show_empty_weapon", show_empty_weapon)
("dead_flag", w.dead_flag) ("scuba_amount", scuba_amount)
("show_empty_weapon", w.show_empty_weapon) ("jetpack_amount", jetpack_amount)
("scuba_amount", w.scuba_amount) ("steroids_amount", steroids_amount)
("jetpack_amount", w.jetpack_amount) ("shield_amount", shield_amount)
("steroids_amount", w.steroids_amount) ("holoduke_on", holoduke_on)
("shield_amount", w.shield_amount) ("pycount", pycount)
("holoduke_on", w.holoduke_on) ("weapon_pos", weapon_pos)
("pycount", w.pycount) ("frag_ps", frag_ps)
("weapon_pos", w.weapon_pos) ("transporter_hold", transporter_hold)
("frag_ps", w.frag_ps) ("last_full_weapon", last_full_weapon)
("transporter_hold", w.transporter_hold) ("footprintshade", footprintshade)
("last_full_weapon", w.last_full_weapon) ("boot_amount", boot_amount)
("footprintshade", w.footprintshade) ("on_warping_sector", on_warping_sector)
("boot_amount", w.boot_amount) ("footprintcount", footprintcount)
("on_warping_sector", w.on_warping_sector) ("hbomb_on", hbomb_on)
("footprintcount", w.footprintcount) ("jumping_toggle", jumping_toggle)
("hbomb_on", w.hbomb_on) ("rapid_fire_hold", rapid_fire_hold)
("jumping_toggle", w.jumping_toggle) ("on_ground", on_ground)
("rapid_fire_hold", w.rapid_fire_hold) .Array("name", name, 32)
("on_ground", w.on_ground) ("inven_icon", inven_icon)
.Array("name", w.name, 32) ("buttonpalette", buttonpalette)
("inven_icon", w.inven_icon) ("jetpack_on", jetpack_on)
("buttonpalette", w.buttonpalette) ("spritebridge", spritebridge)
("jetpack_on", w.jetpack_on) ("lastrandomspot", lastrandomspot)
("spritebridge", w.spritebridge) ("scuba_on", scuba_on)
("lastrandomspot", w.lastrandomspot) ("footprintpal", footprintpal)
("scuba_on", w.scuba_on) ("heat_on", heat_on)
("footprintpal", w.footprintpal) ("holster_weapon", holster_weapon)
("heat_on", w.heat_on) ("falling_counter", falling_counter)
("holster_weapon", w.holster_weapon) ("refresh_inventory", refresh_inventory)
("falling_counter", w.falling_counter) ("toggle_key_flag", toggle_key_flag)
("refresh_inventory", w.refresh_inventory) ("knuckle_incs", knuckle_incs)
("toggle_key_flag", w.toggle_key_flag) ("walking_snd_toggle", walking_snd_toggle)
("knuckle_incs", w.knuckle_incs) ("palookup", palookup)
("walking_snd_toggle", w.walking_snd_toggle) ("hard_landing", hard_landing)
("palookup", w.palookup) // RR from here on
("hard_landing", w.hard_landing) ("stairs", stairs)
// RR from here on ("detonate_count", detonate_count)
("stairs", w.stairs) ("noise.X", noise.X)
("detonate_count", w.detonate_count) ("noise.Y", noise.Y)
("noise.X", w.noise.X) ("noise_radius", noise_radius)
("noise.Y", w.noise.Y) ("drink_timer", drink_timer)
("noise_radius", w.noise_radius) ("eat_timer", eat_timer)
("drink_timer", w.drink_timer) ("slotwin", SlotWin)
("eat_timer", w.eat_timer) ("recoil", recoil)
("slotwin", w.SlotWin) ("detonate_time", detonate_time)
("recoil", w.recoil) ("yehaa_timer", yehaa_timer)
("detonate_time", w.detonate_time) ("drink_amt", drink_amt)
("yehaa_timer", w.yehaa_timer) ("eat", eat)
("drink_amt", w.drink_amt) ("drunkang", drunkang)
("eat", w.eat) ("eatang", eatang)
("drunkang", w.drunkang) .Array("shotgun_state", shotgun_state, 2)
("eatang", w.eatang) ("donoise", donoise)
.Array("shotgun_state", w.shotgun_state, 2) .Array("keys", keys, 5)
("donoise", w.donoise) // RRRA from here on
.Array("keys", w.keys, 5) ("drug_aspect", drug_aspect)
// RRRA from here on ("drug_timer", drug_timer)
("drug_aspect", w.drug_aspect) ("seasick", SeaSick)
("drug_timer", w.drug_timer) ("mamaend", MamaEnd)
("seasick", w.SeaSick) ("motospeed", MotoSpeed)
("mamaend", w.MamaEnd) ("moto_drink", moto_drink)
("motospeed", w.MotoSpeed) ("tiltstatus", TiltStatus)
("moto_drink", w.moto_drink) ("vbumpnow", VBumpNow)
("tiltstatus", w.TiltStatus) ("vbumptarget", VBumpTarget)
("vbumpnow", w.VBumpNow) ("turbcount", TurbCount)
("vbumptarget", w.VBumpTarget) .Array("drug_stat", drug_stat, 3)
("turbcount", w.TurbCount) ("drugmode", DrugMode)
.Array("drug_stat", w.drug_stat, 3) ("lotag800kill", lotag800kill)
("drugmode", w.DrugMode) ("sea_sick_stat", sea_sick_stat)
("lotag800kill", w.lotag800kill) ("hurt_delay2", hurt_delay2)
("sea_sick_stat", w.sea_sick_stat) ("nocheat", nocheat)
("hurt_delay2", w.hurt_delay2) ("onmotorcycle", OnMotorcycle)
("nocheat", w.nocheat) ("onboat", OnBoat)
("onmotorcycle", w.OnMotorcycle) ("moto_underwater", moto_underwater)
("onboat", w.OnBoat) ("notonwater", NotOnWater)
("moto_underwater", w.moto_underwater) ("motoonground", MotoOnGround)
("notonwater", w.NotOnWater) ("moto_do_bump", moto_do_bump)
("motoonground", w.MotoOnGround) ("moto_bump_fast", moto_bump_fast)
("moto_do_bump", w.moto_do_bump) ("moto_on_oil", moto_on_oil)
("moto_bump_fast", w.moto_bump_fast) ("moto_on_mud", moto_on_mud)
("moto_on_oil", w.moto_on_oil) // new stuff
("moto_on_mud", w.moto_on_mud) ("actions", cmd.ucmd.actions)
// new stuff .Array("frags", frags, MAXPLAYERS)
("actions", w.cmd.ucmd.actions) ("uservars", uservars)
.Array("frags", w.frags, MAXPLAYERS) ("fistsign", fistsign);
("uservars", w.uservars)
("fistsign", w.fistsign)
.EndObject();
if (arc.isReading()) if (arc.isReading())
{ {
w.invdisptime = 0; invdisptime = 0;
w.GetActor()->backuploc(); GetActor()->backuploc();
w.opyoff = w.pyoff; opyoff = pyoff;
w.backupweapon(); backupweapon();
w.cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve. cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve.
}
} }
return arc;
} }
@ -415,8 +410,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
("rtsplaying", rtsplaying) ("rtsplaying", rtsplaying)
//("tempwallptr", tempwallptr) //("tempwallptr", tempwallptr)
("joe9000", ud.joe9000) ("joe9000", ud.joe9000)
#pragma message("Duke: Fix saving!")
//.Array("players", PlayerArray, ud.multimode)
("spriteqamount", spriteqamount) ("spriteqamount", spriteqamount)
("lastvisinc", lastvisinc) ("lastvisinc", lastvisinc)
("numanimwalls", numanimwalls) ("numanimwalls", numanimwalls)

View file

@ -232,6 +232,7 @@ class DDukePlayer final : public DCorePlayer
DDukePlayer() = default; DDukePlayer() = default;
public: public:
DDukePlayer(uint8_t p) : DCorePlayer(p) {} DDukePlayer(uint8_t p) : DCorePlayer(p) {}
void Serialize(FSerializer& arc) override;
DVector3 vel; DVector3 vel;
DVector2 bobpos; DVector2 bobpos;
DVector2 fric; DVector2 fric;

View file

@ -2095,62 +2095,57 @@ void AIPlayer::Tick(RunListEvent* ev)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
FSerializer& Serialize(FSerializer& arc, const char* keyname, DExhumedPlayer& w, DExhumedPlayer* def) void DExhumedPlayer::Serialize(FSerializer& arc)
{ {
if (arc.BeginObject(keyname)) Super::Serialize(arc);
{ arc("health", nHealth)
arc("health", w.nHealth) ("mummy", bIsMummified)
("sprite", w.actor) ("invincible", invincibility)
("mummy", w.bIsMummified) ("air", nAir)
("invincible", w.invincibility) ("item", nItem)
("air", w.nAir) ("maskamount", nMaskAmount)
("item", w.nItem) ("keys", keys)
("maskamount", w.nMaskAmount) ("magic", nMagic)
("keys", w.keys) .Array("items", items, countof(items))
("magic", w.nMagic) .Array("ammo", nAmmo, countof(nAmmo))
.Array("items", w.items, countof(w.items)) ("weapon", nCurrentWeapon)
.Array("ammo", w.nAmmo, countof(w.nAmmo)) ("isfiring", bIsFiring)
("weapon", w.nCurrentWeapon) ("field3f", nWeapFrame)
("isfiring", w.bIsFiring) ("field38", nNextWeapon)
("field3f", w.nWeapFrame) ("field3a", nState)
("field38", w.nNextWeapon) ("field3c", nLastWeapon)
("field3a", w.nState) ("angles", Angles)
("field3c", w.nLastWeapon) ("lives", nLives)
("angles", w.Angles) ("double", nDouble)
("lives", w.nLives) ("invisible", nInvisible)
("double", w.nDouble) ("torch", nTorch)
("invisible", w.nInvisible) ("breathtimer", nBreathTimer)
("torch", w.nTorch) ("playerswear", nPlayerSwear)
("breathtimer", w.nBreathTimer) ("pushsect", pPlayerPushSect)
("playerswear", w.nPlayerSwear) ("deathtype", nDeathType)
("pushsect", w.pPlayerPushSect) ("score", nPlayerScore)
("deathtype", w.nDeathType) ("color", nPlayerColor)
("score", w.nPlayerScore) ("pistolclip", nPistolClip)
("color", w.nPlayerColor) ("thrustx", nThrust.X)
("pistolclip", w.nPistolClip) ("thrusty", nThrust.Y)
("thrustx", w.nThrust.X) ("dopplesprite", pDoppleSprite)
("thrusty", w.nThrust.Y) ("oldweapon", nPlayerOldWeapon)
("dopplesprite", w.pDoppleSprite) ("clip", nPlayerClip)
("oldweapon", w.nPlayerOldWeapon) ("pushsound", nPlayerPushSound)
("clip", w.nPlayerClip) ("taunttimer", nTauntTimer)
("pushsound", w.nPlayerPushSound) ("weapons", nPlayerWeapons)
("taunttimer", w.nTauntTimer) ("viewsect", pPlayerViewSect)
("weapons", w.nPlayerWeapons) ("floorspr", pPlayerFloorSprite)
("viewsect", w.pPlayerViewSect) ("save", sPlayerSave)
("floorspr", w.pPlayerFloorSprite) ("totalvel", totalvel)
("save", w.sPlayerSave) ("grenade", pPlayerGrenade)
("totalvel", w.totalvel) ("bUnderwater", bUnderwater)
("grenade", w.pPlayerGrenade) ("actions", cmd.ucmd.actions);
("bUnderwater", w.bUnderwater)
("actions", w.cmd.ucmd.actions)
.EndObject();
if (arc.isReading()) if (arc.isReading())
{ {
w.cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve. cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve.
}
} }
return arc;
} }
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerSave& w, PlayerSave* def) FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerSave& w, PlayerSave* def)
@ -2174,8 +2169,6 @@ void SerializePlayer(FSerializer& arc)
("localplayer", nLocalPlayer) ("localplayer", nLocalPlayer)
("curstartsprite", nCurStartSprite) ("curstartsprite", nCurStartSprite)
.Array("netstartsprite", nNetStartSprite, kMaxPlayers); .Array("netstartsprite", nNetStartSprite, kMaxPlayers);
#pragma message("Exhumed: Fix saving!")
//.Array("list", PlayerArray, PlayerCount);
arc.EndObject(); arc.EndObject();
} }

View file

@ -54,6 +54,7 @@ class DExhumedPlayer final : public DCorePlayer
DExhumedPlayer() = default; DExhumedPlayer() = default;
public: public:
DExhumedPlayer(uint8_t p) : DCorePlayer(p) {} DExhumedPlayer(uint8_t p) : DCorePlayer(p) {}
void Serialize(FSerializer& arc) override;
void Clear() void Clear()
{ {
Super::Clear(); Super::Clear();

View file

@ -1690,6 +1690,7 @@ public:
} }
DSWPlayer(uint8_t p) : DCorePlayer(p) {} DSWPlayer(uint8_t p) : DCorePlayer(p) {}
void Serialize(FSerializer& arc) override;
TObjPtr<DSWActor*> lowActor, highActor; TObjPtr<DSWActor*> lowActor, highActor;
TObjPtr<DSWActor*> remoteActor; TObjPtr<DSWActor*> remoteActor;
TObjPtr<DSWActor*> PlayerUnderActor; TObjPtr<DSWActor*> PlayerUnderActor;

View file

@ -431,147 +431,141 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DSWPlayer*& w, DSW
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
FSerializer& Serialize(FSerializer& arc, const char* keyname, DSWPlayer& w, DSWPlayer* def) void DSWPlayer::Serialize(FSerializer& arc)
{ {
if (arc.BeginObject(keyname)) Super::Serialize(arc);
{ arc("lv_sectnum", lv_sector)
arc("lv_sectnum", w.lv_sector) ("lv_x", lv.X)
("lv_x", w.lv.X) ("lv_y", lv.Y)
("lv_y", w.lv.Y) ("lv_z", lv.Z)
("lv_z", w.lv.Z) ("remote_sprite", remoteActor)
("remote_sprite", w.remoteActor) ("remote", remote)
("remote", w.remote) ("sop_remote", sop_remote)
("sop_remote", w.sop_remote) ("sop", sop)
("sop", w.sop) ("jump_count", jump_count)
("jump_count", w.jump_count) ("jump_speed", jump_speed)
("jump_speed", w.jump_speed) ("z_speed", z_speed)
("z_speed", w.z_speed) ("climb_ndx", climb_ndx)
("climb_ndx", w.climb_ndx) ("hiz", hiz)
("hiz", w.hiz) ("loz", loz)
("loz", w.loz) ("ceiling_dist", p_ceiling_dist)
("ceiling_dist", w.p_ceiling_dist) ("floor_dist", p_floor_dist)
("floor_dist", w.p_floor_dist) ("hi_sectp", hi_sectp)
("hi_sectp", w.hi_sectp) ("lo_sectp", lo_sectp)
("lo_sectp", w.lo_sectp) ("hi_sp", highActor)
("hi_sp", w.highActor) ("lo_sp", lowActor)
("lo_sp", w.lowActor) ("last_camera_sp", last_camera_act)
("last_camera_sp", w.last_camera_act) ("circle_camera_dist", circle_camera_dist)
("circle_camera_dist", w.circle_camera_dist) ("six", si.X)
("six", w.si.X) ("siy", si.Y)
("siy", w.si.Y) ("siz", si.Z)
("siz", w.si.Z) ("xvect", vect.X)
("xvect", w.vect.X) ("yvect", vect.Y)
("yvect", w.vect.Y) ("friction", friction)
("friction", w.friction) ("slide_xvect", slide_vect.X)
("slide_xvect", w.slide_vect.X) ("slide_yvect", slide_vect.Y)
("slide_yvect", w.slide_vect.Y) ("slide_ang", slide_ang)
("slide_ang", w.slide_ang) ("slide_dec", slide_dec)
("slide_dec", w.slide_dec) ("drive_avel", drive_avel)
("drive_avel", w.drive_avel) ("circle_camera_ang", circle_camera_ang)
("circle_camera_ang", w.circle_camera_ang) ("camera_check_time_delay", camera_check_time_delay)
("camera_check_time_delay", w.camera_check_time_delay) ("cursectnum", cursector)
("cursectnum", w.cursector) ("lastcursectnum", lastcursector)
("lastcursectnum", w.lastcursector) ("angles", Angles)
("angles", w.Angles) ("recoil_amt", recoil_amt)
("recoil_amt", w.recoil_amt) ("recoil_speed", recoil_speed)
("recoil_speed", w.recoil_speed) ("recoil_ndx", recoil_ndx)
("recoil_ndx", w.recoil_ndx) ("recoil_horizoff", recoil_horizoff)
("recoil_horizoff", w.recoil_horizoff) ("recoil_ohorizoff", recoil_ohorizoff)
("recoil_ohorizoff", w.recoil_ohorizoff) ("revolvex", Revolve.X)
("revolvex", w.Revolve.X) ("revolvey", Revolve.Y)
("revolvey", w.Revolve.Y) ("RevolveDeltaAng", RevolveDeltaAng)
("RevolveDeltaAng", w.RevolveDeltaAng) ("RevolveAng", RevolveAng)
("RevolveAng", w.RevolveAng) ("PlayerUnderSprite", PlayerUnderActor)
("PlayerSprite", w.actor) ("LadderSector", LadderSector)
("PlayerUnderSprite", w.PlayerUnderActor) ("lx", LadderPosition.X)
("pnum", w.pnum) ("ly", LadderPosition.Y)
("LadderSector", w.LadderSector) ("JumpDuration", JumpDuration)
("lx", w.LadderPosition.X) ("WadeDepth", WadeDepth)
("ly", w.LadderPosition.Y) ("bob_amt", pbob_amt)
("JumpDuration", w.JumpDuration) ("bob_ndx", bob_ndx)
("WadeDepth", w.WadeDepth) ("bcnt", bcnt)
("bob_amt", w.pbob_amt) ("bob_z", bob_z)
("bob_ndx", w.bob_ndx) ("playerreadyflag", playerreadyflag)
("bcnt", w.bcnt) ("Flags", Flags)
("bob_z", w.bob_z) ("Flags2", Flags2)
("playerreadyflag", w.playerreadyflag) ("sop_control", sop_control)
("Flags", w.Flags) ("sop_riding", sop_riding)
("Flags2", w.Flags2) .Array("HasKey", HasKey, countof(HasKey))
("sop_control", w.sop_control) ("SwordAng", SwordAng)
("sop_riding", w.sop_riding) ("WpnGotOnceFlags", WpnGotOnceFlags)
.Array("HasKey", w.HasKey, countof(w.HasKey)) ("WpnFlags", WpnFlags)
("SwordAng", w.SwordAng) .Array("WpnAmmo", WpnAmmo, countof(WpnAmmo))
("WpnGotOnceFlags", w.WpnGotOnceFlags) ("WpnNum", WpnNum)
("WpnFlags", w.WpnFlags) ("pnum", pnum)
.Array("WpnAmmo", w.WpnAmmo, countof(w.WpnAmmo)) ("panelnext", PanelSpriteList.Next)
("WpnNum", w.WpnNum) ("panelprev", PanelSpriteList.Prev)
("pnum", w.pnum) ("curwpn", CurWpn)
("panelnext", w.PanelSpriteList.Next) .Array("wpn", Wpn, countof(Wpn))
("panelprev", w.PanelSpriteList.Prev) ("WpnRocketType", WpnRocketType)
("curwpn", w.CurWpn) ("WpnRocketHeat", WpnRocketHeat)
.Array("wpn", w.Wpn, countof(w.Wpn)) ("WpnRocketNuke", WpnRocketNuke)
("WpnRocketType", w.WpnRocketType) ("WpnFlameType", WpnFlameType)
("WpnRocketHeat", w.WpnRocketHeat) ("WpnFirstType", WpnFirstType)
("WpnRocketNuke", w.WpnRocketNuke) ("WeaponType", WeaponType)
("WpnFlameType", w.WpnFlameType) ("FirePause", FirePause)
("WpnFirstType", w.WpnFirstType) ("InventoryNum", InventoryNum)
("WeaponType", w.WeaponType) ("InventoryBarTics", InventoryBarTics)
("FirePause", w.FirePause) .Array("InventoryTics", InventoryTics, countof(InventoryTics))
("InventoryNum", w.InventoryNum) .Array("InventoryPercent", InventoryPercent, countof(InventoryPercent))
("InventoryBarTics", w.InventoryBarTics) .Array("InventoryAmount", InventoryAmount, countof(InventoryAmount))
.Array("InventoryTics", w.InventoryTics, countof(w.InventoryTics)) .Array("InventoryActive", InventoryActive, countof(InventoryActive))
.Array("InventoryPercent", w.InventoryPercent, countof(w.InventoryPercent)) ("DiveTics", DiveTics)
.Array("InventoryAmount", w.InventoryAmount, countof(w.InventoryAmount)) ("DiveDamageTics", DiveDamageTics)
.Array("InventoryActive", w.InventoryActive, countof(w.InventoryActive)) ("DeathType", DeathType)
("DiveTics", w.DiveTics) ("Killer", KillerActor)
("DiveDamageTics", w.DiveDamageTics) .Array("KilledPlayer", KilledPlayer, countof(KilledPlayer))
("DeathType", w.DeathType) ("Armor", Armor)
("Killer", w.KillerActor) ("MaxHealth", MaxHealth)
.Array("KilledPlayer", w.KilledPlayer, countof(w.KilledPlayer)) ("UziShellLeftAlt", UziShellLeftAlt)
("Armor", w.Armor) ("UziShellRightAlt", UziShellRightAlt)
("MaxHealth", w.MaxHealth) ("TeamColor", TeamColor)
("UziShellLeftAlt", w.UziShellLeftAlt) ("FadeTics", FadeTics)
("UziShellRightAlt", w.UziShellRightAlt) ("FadeAmt", FadeAmt)
("TeamColor", w.TeamColor) ("NightVision", NightVision)
("FadeTics", w.FadeTics) ("IsAI", IsAI)
("FadeAmt", w.FadeAmt) ("NumFootPrints", NumFootPrints)
("NightVision", w.NightVision) ("WpnUziType", WpnUziType)
("IsAI", w.IsAI) ("WpnShotgunType", WpnShotgunType)
("NumFootPrints", w.NumFootPrints) ("WpnShotgunAuto", WpnShotgunAuto)
("WpnUziType", w.WpnUziType) ("WpnShotgunLastShell", WpnShotgunLastShell)
("WpnShotgunType", w.WpnShotgunType) ("WpnRailType", WpnRailType)
("WpnShotgunAuto", w.WpnShotgunAuto) ("Bloody", Bloody)
("WpnShotgunLastShell", w.WpnShotgunLastShell) ("InitingNuke", InitingNuke)
("WpnRailType", w.WpnRailType) ("TestNukeInit", TestNukeInit)
("Bloody", w.Bloody) ("NukeInitialized", NukeInitialized)
("InitingNuke", w.InitingNuke) ("FistAng", FistAng)
("TestNukeInit", w.TestNukeInit) ("WpnKungFuMove", WpnKungFuMove)
("NukeInitialized", w.NukeInitialized) ("HitBy", HitBy)
("FistAng", w.FistAng) ("Reverb", Reverb)
("WpnKungFuMove", w.WpnKungFuMove) ("Heads", Heads)
("HitBy", w.HitBy) ("PlayerVersion", PlayerVersion)
("Reverb", w.Reverb) ("cookieTime", cookieTime)
("Heads", w.Heads) ("WpnReloadState", WpnReloadState)
("PlayerVersion", w.PlayerVersion) ("keypressbits", KeyPressBits)
("cookieTime", w.cookieTime) ("chops", Chops);
("WpnReloadState", w.WpnReloadState)
("keypressbits", w.KeyPressBits)
("chops", w.Chops);
SerializeCodePtr(arc, "DoPlayerAction", (void**)&w.DoPlayerAction); SerializeCodePtr(arc, "DoPlayerAction", (void**)&DoPlayerAction);
arc.EndObject();
}
if (arc.isReading()) if (arc.isReading())
{ {
w.ovect = w.vect; ovect = vect;
w.obob_z = w.bob_z; obob_z = bob_z;
w.cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve. cmd.ucmd.actions &= SB_CENTERVIEW|SB_CROUCH; // these are the only bits we need to preserve.
memset(w.cookieQuote, 0, sizeof(w.cookieQuote)); // no need to remember this. memset(cookieQuote, 0, sizeof(cookieQuote)); // no need to remember this.
w.StartColor = 0; StartColor = 0;
} }
return arc;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -1100,8 +1094,6 @@ void GameInterface::SerializeGameState(FSerializer& arc)
preSerializePanelSprites(arc); preSerializePanelSprites(arc);
so_serializeinterpolations(arc); so_serializeinterpolations(arc);
arc("numplayers", numplayers) arc("numplayers", numplayers)
#pragma message("SW: Fix saving!")
//.Array("players", PlayerArray, numplayers)
("skill", Skill) ("skill", Skill)
("screenpeek", screenpeek) ("screenpeek", screenpeek)
.Array("sop", SectorObject, countof(SectorObject)) .Array("sop", SectorObject, countof(SectorObject))