From a23727506362910464f4990d03a0e07dd30f9864 Mon Sep 17 00:00:00 2001 From: Dextinfire <> Date: Wed, 25 Dec 2024 15:44:03 -0800 Subject: [PATCH] Try to fix skip read --- profiles/cclcc/savedata.lua | 23 ----------------------- profiles/chlcc/savedata.lua | 2 -- src/games/cclcc/savesystem.cpp | 8 +++----- src/games/chlcc/savesystem.cpp | 8 +++----- src/vm/inst_dialogue.cpp | 5 ++--- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/profiles/cclcc/savedata.lua b/profiles/cclcc/savedata.lua index 4cb7a92a..f012a22d 100644 --- a/profiles/cclcc/savedata.lua +++ b/profiles/cclcc/savedata.lua @@ -1,29 +1,6 @@ root.SaveData = { Type = SaveDataType.CCLCC, SaveFilePath = "games/cclcc/savedata/SAVEDATA.DAT", - StoryScriptIDs = { - 0x07, 0x08, 0x09, 0x0A, - 0x0B, 0x0C, 0x0D, 0x0E, - 0x0F, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x15, 0x16, - 0x17, 0x18, 0x19, 0x1A, - 0x1B, 0x1C, 0x1D, 0x1E, - 0x1F, 0x20, 0x21, 0x22, - 0x23, 0x24, 0x25, 0x26, - 0x27, 0x28, 0x29, 0x2A, - 0x2B, 0x2C, 0x2D, 0x2E, - 0x2F, 0x30, 0x31, 0x32, - 0x33, 0x34, 0x35, 0x36, - 0x37, 0x38, 0x39, 0x3A, - 0x3B, 0x3C, 0x3D, 0x3E, - 0x3F, 0x40, 0x41, 0x42, - 0x43, 0x44, 0x45, 0x46, - 0x47, 0x48, 0x49, 0x4A, - 0x4B, 0x4C, 0x4D, 0x4E, - 0x4F, 0x50, 0x51, 0x52, - 0x53, 0x56, 0x57, 0x58, - 0x59, 0x5A, 0x5B, 0x5C - }, ScriptMessageData={ -- Pairs of line count and offset into read flags array {0x0, 0x0}, {0x6b, 0x0}, {0x8b, 0x6b}, {0x7e, 0xf6}, {0x144, 0x174}, {0x42, 0x2b8}, {0x0, 0x2fa}, {0xe3, 0x2fa}, {0x4b, 0x3dd}, {0x232, 0x428}, {0x78, 0x65a}, {0xb9, 0x6d2}, diff --git a/profiles/chlcc/savedata.lua b/profiles/chlcc/savedata.lua index 0c6f5c75..8e0f5d97 100644 --- a/profiles/chlcc/savedata.lua +++ b/profiles/chlcc/savedata.lua @@ -135,7 +135,5 @@ root.SaveData = { {{418, 417}}, {{419}} }, - - StoryScriptIDs = {}, ScriptMessageData = {} -- Pairs of line count and offset into read flags array }; \ No newline at end of file diff --git a/src/games/cclcc/savesystem.cpp b/src/games/cclcc/savesystem.cpp index a74ac6d9..790a8bc8 100644 --- a/src/games/cclcc/savesystem.cpp +++ b/src/games/cclcc/savesystem.cpp @@ -661,8 +661,7 @@ void SaveSystem::SetTipStatus(int tipId, bool isLocked, bool isUnread, void SaveSystem::SetLineRead(int scriptId, int lineId) { if (scriptId >= StoryScriptCount) return; - int offset = - ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; + int offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; if (offset == 0xFFFFFFFF) return; // TODO: update some ScrWorks (2003, 2005 & 2006) @@ -673,8 +672,7 @@ void SaveSystem::SetLineRead(int scriptId, int lineId) { bool SaveSystem::IsLineRead(int scriptId, int lineId) { if (scriptId >= StoryScriptCount) return false; - uint32_t offset = - ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; + uint32_t offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; uint8_t flbit = Flbit[offset & 0b111]; uint8_t viewed = MessageFlags[offset >> 3]; @@ -687,7 +685,7 @@ void SaveSystem::GetReadMessagesCount(int* totalMessageCount, *readMessageCount = 0; for (int scriptId = 0; scriptId < StoryScriptCount; scriptId++) { - ScriptMessageDataPair script = ScriptMessageData[StoryScriptIDs[scriptId]]; + ScriptMessageDataPair script = ScriptMessageData[scriptId]; *totalMessageCount += script.LineCount; for (int lineId = 0; lineId < script.LineCount; lineId++) { diff --git a/src/games/chlcc/savesystem.cpp b/src/games/chlcc/savesystem.cpp index fe904d92..f4676c3f 100644 --- a/src/games/chlcc/savesystem.cpp +++ b/src/games/chlcc/savesystem.cpp @@ -525,8 +525,7 @@ void SaveSystem::SetTipStatus(int tipId, bool isLocked, bool isUnread, void SaveSystem::SetLineRead(int scriptId, int lineId) { if (scriptId >= StoryScriptCount) return; - int offset = - ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; + int offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; if (offset == 0xFFFFFFFF) return; // TODO: update some ScrWorks (2003, 2005 & 2006) @@ -537,8 +536,7 @@ void SaveSystem::SetLineRead(int scriptId, int lineId) { bool SaveSystem::IsLineRead(int scriptId, int lineId) { if (scriptId >= StoryScriptCount) return false; - uint32_t offset = - ScriptMessageData[StoryScriptIDs[scriptId]].SaveDataOffset + lineId; + uint32_t offset = ScriptMessageData[scriptId].SaveDataOffset + lineId; uint8_t flbit = Flbit[offset & 0b111]; uint8_t viewed = MessageFlags[offset >> 3]; @@ -551,7 +549,7 @@ void SaveSystem::GetReadMessagesCount(int* totalMessageCount, *readMessageCount = 0; for (int scriptId = 0; scriptId < StoryScriptCount; scriptId++) { - ScriptMessageDataPair script = ScriptMessageData[StoryScriptIDs[scriptId]]; + ScriptMessageDataPair script = ScriptMessageData[scriptId]; *totalMessageCount += script.LineCount; for (int lineId = 0; lineId < script.LineCount; lineId++) { diff --git a/src/vm/inst_dialogue.cpp b/src/vm/inst_dialogue.cpp index ffed39c8..b66aeb6b 100644 --- a/src/vm/inst_dialogue.cpp +++ b/src/vm/inst_dialogue.cpp @@ -112,7 +112,7 @@ VmInstruction(InstMes) { StartInstruction; DialoguePage& dialoguePage = DialoguePages[thread->DialoguePageId]; - uint32_t scriptId = LoadedScriptMetas[dialoguePage.Id].Id; + uint32_t scriptId = LoadedScriptMetas[thread->ScriptBufferId].Id; // After loading a save we need to make sure the textbox is actually shown if (dialoguePage.FadeAnimation.IsOut() && @@ -609,8 +609,7 @@ VmInstruction(InstSetRevMes) { uint8_t* line = ScriptGetStrAddress(ScriptBuffers[thread->ScriptBufferId], lineId); - const DialoguePage& dialoguePage = DialoguePages[thread->DialoguePageId]; - uint32_t scriptId = LoadedScriptMetas[dialoguePage.Id].Id; + uint32_t scriptId = LoadedScriptMetas[thread->ScriptBufferId].Id; SaveSystem::SetLineRead(scriptId, lineId); UI::BacklogMenuPtr->AddMessage(line);