Saveload: Change result type of ChunkSaveLoadSpecialProc

This commit is contained in:
Jonathan G Rennison
2023-03-21 18:11:11 +00:00
parent 6cdf67f38a
commit b4f32e44d9
2 changed files with 12 additions and 8 deletions

View File

@@ -2139,7 +2139,7 @@ inline void SlRIFFSpringPPCheck(size_t len)
static void SlLoadChunk(const ChunkHandler &ch)
{
if (ch.special_proc != nullptr) {
if (ch.special_proc(ch.id, CSLSO_PRE_LOAD)) return;
if (ch.special_proc(ch.id, CSLSO_PRE_LOAD) == CSLSOR_LOAD_CHUNK_CONSUMED) return;
}
byte m = SlReadByte();
@@ -2206,7 +2206,7 @@ static void SlLoadChunk(const ChunkHandler &ch)
static void SlLoadCheckChunk(const ChunkHandler *ch)
{
if (ch && ch->special_proc != nullptr) {
if (ch->special_proc(ch->id, CSLSO_PRE_LOADCHECK)) return;
if (ch->special_proc(ch->id, CSLSO_PRE_LOADCHECK) == CSLSOR_LOAD_CHUNK_CONSUMED) return;
}
byte m = SlReadByte();

View File

@@ -86,7 +86,11 @@ enum ChunkSaveLoadSpecialOp {
CSLSO_PRE_LOAD,
CSLSO_PRE_LOADCHECK,
};
typedef bool ChunkSaveLoadSpecialProc(uint32, ChunkSaveLoadSpecialOp);
enum ChunkSaveLoadSpecialOpResult {
CSLSOR_NONE,
CSLSOR_LOAD_CHUNK_CONSUMED,
};
typedef ChunkSaveLoadSpecialOpResult ChunkSaveLoadSpecialProc(uint32, ChunkSaveLoadSpecialOp);
/** Type of a chunk. */
enum ChunkType {
@@ -141,22 +145,22 @@ namespace upstream_sl {
SlUnreachablePlaceholder,
CH_UPSTREAM_SAVE
};
ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> bool {
ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult {
assert(id == chunk_id);
switch (op) {
case CSLSO_PRE_LOAD:
SlExecWithSlVersion(F::GetLoadVersion(), []() {
SlLoadChunkByID(id);
});
break;
return CSLSOR_LOAD_CHUNK_CONSUMED;
case CSLSO_PRE_LOADCHECK:
SlExecWithSlVersion(F::GetLoadVersion(), []() {
SlLoadCheckChunkByID(id);
});
break;
return CSLSOR_LOAD_CHUNK_CONSUMED;
default:
return CSLSOR_NONE;
}
return true; // chunk has been consumed
};
return ch;
}