mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-03-01 08:51:21 +00:00
Save+load SRB2 vars on ACS threads
This commit is contained in:
parent
8034fd326f
commit
38d3267cca
2 changed files with 51 additions and 0 deletions
|
|
@ -17,6 +17,13 @@ extern "C" {
|
|||
#include "../doomtype.h"
|
||||
#include "../doomdef.h"
|
||||
#include "../doomstat.h"
|
||||
|
||||
#include "../p_saveg.h"
|
||||
#include "../p_tick.h"
|
||||
#include "../p_local.h"
|
||||
#include "../r_defs.h"
|
||||
#include "../r_state.h"
|
||||
#include "../p_polyobj.h"
|
||||
}
|
||||
|
||||
#include <ACSVM/Code.hpp>
|
||||
|
|
@ -28,6 +35,7 @@ extern "C" {
|
|||
#include <ACSVM/Script.hpp>
|
||||
#include <ACSVM/Serial.hpp>
|
||||
#include <ACSVM/Thread.hpp>
|
||||
#include <ACSVM/BinaryIO.hpp>
|
||||
#include <Util/Floats.hpp>
|
||||
|
||||
using namespace srb2::acs;
|
||||
|
|
@ -55,3 +63,42 @@ void Thread::stop()
|
|||
ACSVM::Thread::stop();
|
||||
info = {};
|
||||
}
|
||||
|
||||
void Thread::saveState(ACSVM::Serial &serial) const
|
||||
{
|
||||
ACSVM::Thread::saveState(serial);
|
||||
|
||||
ACSVM::WriteVLN<size_t>(serial, (info.mo != nullptr && P_MobjWasRemoved(info.mo) == false) ? (info.mo->mobjnum) : 0);
|
||||
ACSVM::WriteVLN<size_t>(serial, (info.line != nullptr) ? ((info.line - lines) + 1) : 0);
|
||||
ACSVM::WriteVLN<size_t>(serial, info.side);
|
||||
ACSVM::WriteVLN<size_t>(serial, (info.sector != nullptr) ? ((info.sector - sectors) + 1) : 0);
|
||||
ACSVM::WriteVLN<size_t>(serial, (info.po != nullptr) ? ((info.po - PolyObjects) + 1) : 0);
|
||||
}
|
||||
|
||||
void Thread::loadState(ACSVM::Serial &serial)
|
||||
{
|
||||
ACSVM::Thread::loadState(serial);
|
||||
|
||||
UINT32 temp = static_cast<UINT32>(ACSVM::ReadVLN<size_t>(serial));
|
||||
|
||||
if (temp != 0)
|
||||
{
|
||||
info.mo = nullptr;
|
||||
|
||||
if (P_SetTarget(&info.mo, P_FindNewPosition(temp)) == nullptr)
|
||||
{
|
||||
CONS_Debug(DBG_GAMELOGIC, "info.mo not found for ACS thread\n"); // todo: identify which thread
|
||||
}
|
||||
}
|
||||
|
||||
size_t lineIndex = ACSVM::ReadVLN<size_t>(serial);
|
||||
info.line = (lineIndex != 0) ? (&lines[lineIndex - 1]) : nullptr;
|
||||
|
||||
info.side = static_cast<UINT8>(ACSVM::ReadVLN<size_t>(serial));
|
||||
|
||||
size_t sectorIndex = ACSVM::ReadVLN<size_t>(serial);
|
||||
info.sector = (sectorIndex != 0) ? (§ors[sectorIndex - 1]) : nullptr;
|
||||
|
||||
size_t polyIndex = ACSVM::ReadVLN<size_t>(serial);
|
||||
info.po = (polyIndex != 0) ? (&PolyObjects[polyIndex - 1]) : nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,10 @@ public:
|
|||
);
|
||||
|
||||
virtual void stop();
|
||||
|
||||
virtual void loadState(ACSVM::Serial &serial);
|
||||
|
||||
virtual void saveState(ACSVM::Serial &serial) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue