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) {}
void OnDestroy() override { if (actor) actor->Destroy(); actor = nullptr; }
virtual DCoreActor* GetActor() = 0;
void Serialize(FSerializer& arc) override;
};
extern DCorePlayer* PlayerArray[MAXPLAYERS];

View file

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

View file

@ -142,12 +142,15 @@ struct PlayerAngles
PrevLerpAngles = lerpAngles;
}
void resetCameraAngles()
{
if (pActor != nullptr)
{
// Apply any last remaining ticrate angle updates and reset variables.
CameraAngles += pActor->spr.Angles - PrevLerpAngles;
PrevLerpAngles = pActor->spr.Angles = CameraAngles;
PrevViewAngles = ViewAngles;
}
}
// Draw code helpers.
auto getCrosshairOffsets(const double interpfrac)

View file

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

View file

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

View file

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

View file

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

View file

@ -232,6 +232,7 @@ class DDukePlayer final : public DCorePlayer
DDukePlayer() = default;
public:
DDukePlayer(uint8_t p) : DCorePlayer(p) {}
void Serialize(FSerializer& arc) override;
DVector3 vel;
DVector2 bobpos;
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))
{
arc("health", w.nHealth)
("sprite", w.actor)
("mummy", w.bIsMummified)
("invincible", w.invincibility)
("air", w.nAir)
("item", w.nItem)
("maskamount", w.nMaskAmount)
("keys", w.keys)
("magic", w.nMagic)
.Array("items", w.items, countof(w.items))
.Array("ammo", w.nAmmo, countof(w.nAmmo))
("weapon", w.nCurrentWeapon)
("isfiring", w.bIsFiring)
("field3f", w.nWeapFrame)
("field38", w.nNextWeapon)
("field3a", w.nState)
("field3c", w.nLastWeapon)
("angles", w.Angles)
("lives", w.nLives)
("double", w.nDouble)
("invisible", w.nInvisible)
("torch", w.nTorch)
("breathtimer", w.nBreathTimer)
("playerswear", w.nPlayerSwear)
("pushsect", w.pPlayerPushSect)
("deathtype", w.nDeathType)
("score", w.nPlayerScore)
("color", w.nPlayerColor)
("pistolclip", w.nPistolClip)
("thrustx", w.nThrust.X)
("thrusty", w.nThrust.Y)
("dopplesprite", w.pDoppleSprite)
("oldweapon", w.nPlayerOldWeapon)
("clip", w.nPlayerClip)
("pushsound", w.nPlayerPushSound)
("taunttimer", w.nTauntTimer)
("weapons", w.nPlayerWeapons)
("viewsect", w.pPlayerViewSect)
("floorspr", w.pPlayerFloorSprite)
("save", w.sPlayerSave)
("totalvel", w.totalvel)
("grenade", w.pPlayerGrenade)
("bUnderwater", w.bUnderwater)
("actions", w.cmd.ucmd.actions)
.EndObject();
Super::Serialize(arc);
arc("health", nHealth)
("mummy", bIsMummified)
("invincible", invincibility)
("air", nAir)
("item", nItem)
("maskamount", nMaskAmount)
("keys", keys)
("magic", nMagic)
.Array("items", items, countof(items))
.Array("ammo", nAmmo, countof(nAmmo))
("weapon", nCurrentWeapon)
("isfiring", bIsFiring)
("field3f", nWeapFrame)
("field38", nNextWeapon)
("field3a", nState)
("field3c", nLastWeapon)
("angles", Angles)
("lives", nLives)
("double", nDouble)
("invisible", nInvisible)
("torch", nTorch)
("breathtimer", nBreathTimer)
("playerswear", nPlayerSwear)
("pushsect", pPlayerPushSect)
("deathtype", nDeathType)
("score", nPlayerScore)
("color", nPlayerColor)
("pistolclip", nPistolClip)
("thrustx", nThrust.X)
("thrusty", nThrust.Y)
("dopplesprite", pDoppleSprite)
("oldweapon", nPlayerOldWeapon)
("clip", nPlayerClip)
("pushsound", nPlayerPushSound)
("taunttimer", nTauntTimer)
("weapons", nPlayerWeapons)
("viewsect", pPlayerViewSect)
("floorspr", pPlayerFloorSprite)
("save", sPlayerSave)
("totalvel", totalvel)
("grenade", pPlayerGrenade)
("bUnderwater", bUnderwater)
("actions", cmd.ucmd.actions);
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)
@ -2174,8 +2169,6 @@ void SerializePlayer(FSerializer& arc)
("localplayer", nLocalPlayer)
("curstartsprite", nCurStartSprite)
.Array("netstartsprite", nNetStartSprite, kMaxPlayers);
#pragma message("Exhumed: Fix saving!")
//.Array("list", PlayerArray, PlayerCount);
arc.EndObject();
}

View file

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

View file

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