Skip to content

Commit

Permalink
Merge pull request #96 from CommitteeOfZero/fix-skip-read
Browse files Browse the repository at this point in the history
  • Loading branch information
Dextinfire committed Dec 26, 2024
2 parents 5f2a5a1 + a237275 commit 470ebc5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 38 deletions.
23 changes: 0 additions & 23 deletions profiles/cclcc/savedata.lua
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
2 changes: 0 additions & 2 deletions profiles/chlcc/savedata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,5 @@ root.SaveData = {
{{418, 417}},
{{419}}
},

StoryScriptIDs = {},
ScriptMessageData = {} -- Pairs of line count and offset into read flags array
};
8 changes: 3 additions & 5 deletions src/games/cclcc/savesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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];

Expand All @@ -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++) {
Expand Down
8 changes: 3 additions & 5 deletions src/games/chlcc/savesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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];

Expand All @@ -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++) {
Expand Down
5 changes: 2 additions & 3 deletions src/vm/inst_dialogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() &&
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 470ebc5

Please sign in to comment.