Skip to content

Commit 8752b73

Browse files
committed
Dump the chunk bytes when it is "corrupted"
As this is forwarded to the Player log now this helps in analyzing modified chunks by Manics
1 parent 0734224 commit 8752b73

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/lcf/reader_lcf.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,18 @@ class LcfReader {
190190
* In debug builds, dumps the content of the
191191
* skipped chunk to stderr.
192192
*
193-
* @param chunk_info chunk that will be skipped.
193+
* @param chunk_info chunk that will be skipped and dumped.
194194
* @param where name of the caller that caused the skip, for finding unknown chunks
195195
*/
196196
void Skip(const struct LcfReader::Chunk& chunk_info, const char* where);
197197

198+
/**
199+
* Like Skip but only dumps the content of the skipped chunk on stderr.
200+
*
201+
* @chunk_Info chunk that will be skipped and dumped.
202+
*/
203+
void Dump(const struct LcfReader::Chunk& chunk_info);
204+
198205
/**
199206
* Encodes a string to UTF-8 using the set encoding
200207
* in the reader constructor.

src/reader_lcf.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ void LcfReader::Skip(const struct LcfReader::Chunk& chunk_info, const char* wher
282282
Log::Debug("Skipped Chunk %02X (%" PRIu32 " byte) in lcf at %" PRIX32 " (%s)",
283283
chunk_info.ID, chunk_info.length, Tell(), where);
284284

285+
Dump(chunk_info);
286+
}
287+
288+
void LcfReader::Dump(const struct LcfReader::Chunk& chunk_info) {
285289
std::stringstream ss;
286290
ss << std::hex;
287291

src/reader_struct_impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ void Struct<S>::ReadLcf(S& obj, LcfReader& stream) {
8181
if (bytes_read != chunk_info.length) {
8282
Log::Warning("%s: Corrupted Chunk 0x%02" PRIx32 " (size: %" PRIu32 ", pos: 0x%" PRIx32 "): %s : Read %" PRIu32 " bytes!",
8383
Struct<S>::name, chunk_info.ID, chunk_info.length, off, it->second->name, bytes_read);
84-
stream.Seek(off + chunk_info.length);
84+
stream.Seek(off);
85+
stream.Dump(chunk_info);
8586
}
8687
}
8788
else {

0 commit comments

Comments
 (0)