Skip to content

Commit

Permalink
!BREAKING feat(World): properly implement CutscenePlayer in save-games
Browse files Browse the repository at this point in the history
Removes `CutscenePlayer::play_list_count` and replaces it with `CutscenePlayer::playlists`.
  • Loading branch information
lmichaelis committed Nov 1, 2024
1 parent 02087e0 commit adf9cb5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/zenkit/World.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ namespace phoenix {

namespace zenkit {
struct VNpc;
struct CutsceneContext;

struct CutscenePlayer : Object {
static constexpr ObjectType TYPE = ObjectType::oCCSPlayer;

int32_t last_process_day;
int32_t last_process_hour;
int32_t play_list_count;
std::vector<std::weak_ptr<CutsceneContext>> playlists;

[[nodiscard]] ObjectType get_object_type() const override {
return TYPE;
Expand Down
17 changes: 13 additions & 4 deletions src/World.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "zenkit/vobs/Misc.hh"

#include "Internal.hh"
#include "zenkit/CutsceneLibrary.hh"

namespace zenkit {
[[maybe_unused]] static constexpr uint32_t BSP_VERSION_G1 = 0x2090000;
Expand Down Expand Up @@ -273,16 +274,24 @@ namespace zenkit {
return 64513;
}

void CutscenePlayer::load(ReadArchive& r, GameVersion) {
void CutscenePlayer::load(ReadArchive& r, GameVersion version) {
this->last_process_day = r.read_int(); // lastProcessDay
this->last_process_hour = r.read_int(); // lastProcessHour
this->play_list_count = r.read_int(); // playListCount

auto play_list_count = r.read_int(); // playListCount
for (auto i = 0; i < play_list_count; ++i) {
playlists.push_back(r.read_object<CutsceneContext>(version));
}
}

void CutscenePlayer::save(WriteArchive& w, GameVersion) const {
void CutscenePlayer::save(WriteArchive& w, GameVersion version) const {
w.write_int("lastProcessDay", this->last_process_day);
w.write_int("lastProcessHour", this->last_process_hour);
w.write_int("playListCount", this->play_list_count);
w.write_int("playListCount", this->playlists.size());

for (auto i = 0; i < this->playlists.size(); ++i) {
w.write_object("playContext" + std::to_string(i), this->playlists[i].lock(), version);
}
}

void SkyController::load(ReadArchive& r, GameVersion version) {
Expand Down

0 comments on commit adf9cb5

Please sign in to comment.