From d8c4cc82657ceee7392de822cfbccd0c50817e35 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 26 Aug 2024 01:03:30 +0200 Subject: [PATCH 1/3] Remove typeid call from warning message Prevents no-rtti option. Was the only location where we used this. --- src/reader_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reader_struct.h b/src/reader_struct.h index 05551e46..c26dfda0 100644 --- a/src/reader_struct.h +++ b/src/reader_struct.h @@ -196,7 +196,7 @@ struct Primitive { if (dif != 0) { // Fix incorrect read pointer position - Log::Warning("Invalid %s at %" PRIX32 "", typeid(T).name(), stream.Tell()); + Log::Warning("Invalid Primitive at %" PRIX32 "", stream.Tell()); stream.Seek(dif, LcfReader::FromCurrent); } } From 7518676824c60c070a3fac29706441a62a289a82 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 26 Aug 2024 01:05:19 +0200 Subject: [PATCH 2/3] Do not warn about primitives of size 0. Otherwise this shows a warning for every RPG Maker 2003 English database which contains a 0-byte version field. This issue always existed but was hidden behind LCF_DEBUG_TRACE. --- src/reader_struct.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/reader_struct.h b/src/reader_struct.h index c26dfda0..d247714a 100644 --- a/src/reader_struct.h +++ b/src/reader_struct.h @@ -267,13 +267,17 @@ struct Primitive { ref = stream.ReadInt(); #ifdef LCF_DEBUG_TRACE fprintf(stderr, " %d\n", ref); +#endif + } else if (length == 0) { + ref = 0; +#ifdef LCF_DEBUG_TRACE + fprintf(stderr, " %d\n", ref); #endif } else { ref = 0; Log::Warning("Invalid integer at %X", stream.Tell()); stream.Seek(length, LcfReader::FromCurrent); } - } static void WriteLcf(const int32_t& ref, LcfWriter& stream) { stream.WriteInt(ref); From daaf2d624db7286288bdd8252ba28a78a7d2039a Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 26 Aug 2024 01:11:04 +0200 Subject: [PATCH 3/3] Fix unused parameter warnings --- src/dbstring_struct.cpp | 2 +- src/ldb_equipment.cpp | 2 +- src/ldb_eventcommand.cpp | 2 +- src/ldb_parameters.cpp | 2 +- src/lmt_rect.cpp | 2 +- src/lmu_movecommand.cpp | 2 +- src/reader_flags.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dbstring_struct.cpp b/src/dbstring_struct.cpp index fbe5b8d3..2adbe3a6 100644 --- a/src/dbstring_struct.cpp +++ b/src/dbstring_struct.cpp @@ -66,7 +66,7 @@ class DbStringXmlHandler : public XmlHandler { public: DbStringXmlHandler(DBString& ref) : ref(ref) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* /* name */, const char** /* atts */) { // no-op } void EndElement(XmlReader& /* stream */, const char* /* name */) { diff --git a/src/ldb_equipment.cpp b/src/ldb_equipment.cpp index b5e39687..f94b1336 100644 --- a/src/ldb_equipment.cpp +++ b/src/ldb_equipment.cpp @@ -74,7 +74,7 @@ class EquipmentXmlHandler : public XmlHandler { int16_t* field; public: EquipmentXmlHandler(rpg::Equipment& ref) : ref(ref), field(NULL) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { if (strcmp(name, "weapon_id") == 0) field = &ref.weapon_id; else if (strcmp(name, "shield_id") == 0) diff --git a/src/ldb_eventcommand.cpp b/src/ldb_eventcommand.cpp index 2f292f22..e53f67bd 100644 --- a/src/ldb_eventcommand.cpp +++ b/src/ldb_eventcommand.cpp @@ -99,7 +99,7 @@ class EventCommandXmlHandler : public XmlHandler { } field; public: EventCommandXmlHandler(rpg::EventCommand& ref) : ref(ref), field(None) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { if (strcmp(name, "code") == 0) field = Code; else if (strcmp(name, "indent") == 0) diff --git a/src/ldb_parameters.cpp b/src/ldb_parameters.cpp index 28b8c83f..964f6c41 100644 --- a/src/ldb_parameters.cpp +++ b/src/ldb_parameters.cpp @@ -65,7 +65,7 @@ class ParametersXmlHandler : public XmlHandler { std::vector* field; public: ParametersXmlHandler(rpg::Parameters& ref) : ref(ref), field(NULL) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { if (strcmp(name, "maxhp") == 0) field = &ref.maxhp; else if (strcmp(name, "maxsp") == 0) diff --git a/src/lmt_rect.cpp b/src/lmt_rect.cpp index 12ec5c5f..c8885be0 100644 --- a/src/lmt_rect.cpp +++ b/src/lmt_rect.cpp @@ -60,7 +60,7 @@ class RectXmlHandler : public XmlHandler { uint32_t* field; public: RectXmlHandler(rpg::Rect& ref) : ref(ref), field(NULL) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { if (strcmp(name, "l") == 0) field = &ref.l; else if (strcmp(name, "t") == 0) diff --git a/src/lmu_movecommand.cpp b/src/lmu_movecommand.cpp index 3d532d84..1efd2925 100644 --- a/src/lmu_movecommand.cpp +++ b/src/lmu_movecommand.cpp @@ -146,7 +146,7 @@ class MoveCommandXmlHandler : public XmlHandler { public: MoveCommandXmlHandler(rpg::MoveCommand& ref) : ref(ref), field(NULL), parameter_string(false) {} - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { if (strcmp(name, "command_id") == 0) field = &ref.command_id; else if (strcmp(name, "parameter_a") == 0) diff --git a/src/reader_flags.cpp b/src/reader_flags.cpp index ace0190b..79327ef7 100644 --- a/src/reader_flags.cpp +++ b/src/reader_flags.cpp @@ -115,7 +115,7 @@ class FlagsXmlHandler : public XmlHandler { FlagsXmlHandler(S& obj) : obj(obj), field(NULL) { } - void StartElement(XmlReader& stream, const char* name, const char** /* atts */) { + void StartElement(XmlReader& /* stream */, const char* name, const char** /* atts */) { const auto idx = Flags::idx(name); if (idx < 0) { Log::Error("XML: Unrecognized field '%s'", name);