Resolve some warnings
Format (mostly newlib-related)
Unused Parameters
MODIFY
src/ldb_equipment.cpp
src/ldb_equipment.cpp
@@ -25,7 +25,7 @@ struct RawStruct<RPG::Equipment> {
*/
void RawStruct<RPG::Equipment>::ReadLcf(RPG::Equipment& ref, LcfReader& stream, uint32_t length) {
if (length != 10) {
- fprintf(stderr, "Equipment has incorrect size %d (expected 10)\n", length);
+ fprintf(stderr, "Equipment has incorrect size %" PRIu32 " (expected 10)\n", length);
LcfReader::Chunk chunk_info;
chunk_info.ID = 0x33;

MODIFY
src/ldb_eventcommand.cpp
src/ldb_eventcommand.cpp
@@ -149,7 +149,7 @@ void RawStruct<std::vector<RPG::EventCommand> >::ReadLcf(
if (stream.Tell() >= endpos) {
stream.Seek(endpos, LcfReader::FromStart);
- fprintf(stderr, "Event command corrupted at %d\n", stream.Tell());
+ fprintf(stderr, "Event command corrupted at %" PRIu32 "\n", stream.Tell());
for (;;) {
// Try finding the real end of the event command (4 0-bytes)
int i = 0;

MODIFY
src/reader_lcf.cpp
src/reader_lcf.cpp
@@ -46,7 +46,7 @@ void LcfReader::Read(void *ptr, size_t size, size_t nmemb) {
Read0(ptr, size, nmemb);
#else
if (Read0(ptr, size, nmemb) != nmemb) {
- fprintf(stderr, "Read error at %d. The file is probably corrupted\n", Tell());
+ fprintf(stderr, "Read error at %" PRIu32 ". The file is probably corrupted\n", Tell());
}
#endif
}
@@ -91,7 +91,7 @@ int LcfReader::ReadInt() {
value |= temp & 0x7F;
if (loops > 5) {
- fprintf(stderr, "Invalid compressed integer at %d\n", Tell());
+ fprintf(stderr, "Invalid compressed integer at %" PRIu32 "\n", Tell());
}
++loops;
} while (temp & 0x80);
@@ -231,7 +231,7 @@ void LcfReader::SkipDebug(const struct LcfReader::Chunk& chunk_info, const char*
} else {
srcfilename++;
}
- fprintf(stderr, "Skipped Chunk %02X (%d byte) in lcf at %X (%s)\n",
+ fprintf(stderr, "Skipped Chunk %02X (%" PRIu32 " byte) in lcf at %" PRIX32 " (%s)\n",
chunk_info.ID, chunk_info.length, Tell(),
srcfilename);
for (uint32_t i = 0; i < chunk_info.length; ++i) {

MODIFY
src/reader_lcf.h
src/reader_lcf.h
#include <iosfwd>
#include <cstring>
#include <cassert>
+#include <cstdint>
+#include <cinttypes>
#include <memory>
-#include <stdint.h>
#include "lcf_options.h"
#include "reader_util.h"
#include "encoder.h"

MODIFY
src/reader_struct.h
src/reader_struct.h
#include <memory>
#include <cstring>
#include <cstdlib>
+#include <cinttypes>
#include "reader_lcf.h"
#include "writer_lcf.h"
#include "reader_xml.h"
@@ -149,7 +150,7 @@ struct Primitive {
// FIXME: Bug #174
if (length != LcfSizeT<T>::value) {
dif = length - LcfSizeT<T>::value;
- fprintf(stderr, "Reading Primitive of incorrect size %d (expected %d) at %X\n",
+ fprintf(stderr, "Reading Primitive of incorrect size %" PRIu32 " (expected %" PRIu32 ") at %" PRIX32 "\n",
length, LcfSizeT<T>::value, stream.Tell());
}
@@ -397,17 +398,17 @@ struct EmptyField : public Field<S> {
using Field<S>::Field;
- void ReadLcf(S& obj, LcfReader& stream, uint32_t length) const { }
- void WriteLcf(const S& obj, LcfWriter& stream) const { }
- int LcfSize(const S& obj, LcfWriter& stream) const {
+ void ReadLcf(S& /* obj */, LcfReader& /* stream */, uint32_t /* length */) const { }
+ void WriteLcf(const S& /* obj */, LcfWriter& /* stream */) const { }
+ int LcfSize(const S& /* obj */, LcfWriter& /* stream */) const {
//This is always an "empty block"
return 0;
}
- void WriteXml(const S& obj, XmlWriter& stream) const { }
- void BeginXml(S& obj, XmlReader& stream) const { }
- void ParseXml(S& obj, const std::string& data) const { }
+ void WriteXml(const S& /* obj */, XmlWriter& /* stream */) const { }
+ void BeginXml(S& /* obj */, XmlReader& /* stream */) const { }
+ void ParseXml(S& /* obj */, const std::string& /* data */) const { }
- bool IsDefault(const S& a, const S& b) const {
+ bool IsDefault(const S& /* a */, const S& /* b */) const {
return true;
}
@@ -464,7 +465,7 @@ struct CountField : public SizeField<S,T> {
int size = (obj.*(this->ref)).size();
TypeReader<int32_t>::WriteLcf(size, stream);
}
- int LcfSize(const S& obj, LcfWriter& stream) const {
+ int LcfSize(const S& obj, LcfWriter& /* stream */) const {
int size = (obj.*(this->ref)).size();
return LcfReader::IntSize(size);
}

MODIFY
src/reader_struct_impl.h
src/reader_struct_impl.h
@@ -69,13 +69,13 @@ void Struct<S>::ReadLcf(S& obj, LcfReader& stream) {
auto it = field_map.find(chunk_info.ID);
if (it != field_map.end()) {
#ifdef LCF_DEBUG_TRACE
- printf("0x%02x (size: %d, pos: 0x%x): %s\n", chunk_info.ID, chunk_info.length, stream.Tell(), it->second->name);
+ printf("0x%02x (size: %" PRIu32 ", pos: 0x%" PRIx32 "): %s\n", chunk_info.ID, chunk_info.length, stream.Tell(), it->second->name);
#endif
- const auto off = stream.Tell();
+ const uint32_t off = stream.Tell();
it->second->ReadLcf(obj, stream, chunk_info.length);
- const auto bytes_read = stream.Tell() - off;
+ const uint32_t bytes_read = stream.Tell() - off;
if (bytes_read != chunk_info.length) {
- fprintf(stderr, "Warning: Corrupted Chunk 0x%02x (size: %d, pos: 0x%x): %s : Read %d bytes! Reseting...\n",
+ fprintf(stderr, "Warning: Corrupted Chunk 0x%02" PRIx32 " (size: %" PRIu32 ", pos: 0x%" PRIx32 "): %s : Read %" PRIu32 " bytes! Reseting...\n",
chunk_info.ID, chunk_info.length, off, it->second->name, bytes_read);
stream.Seek(off + chunk_info.length);
}

MODIFY
src/rpg_setup.cpp
src/rpg_setup.cpp
@@ -198,10 +198,12 @@ void RPG::System::Init() {
}
void RPG::Parameters::Setup(int final_level) {
- if (maxhp.size() < final_level) maxhp.resize(final_level, 1);
- if (maxsp.size() < final_level) maxsp.resize(final_level, 0);
- if (attack.size() < final_level) attack.resize(final_level, 1);
- if (defense.size() < final_level) defense.resize(final_level, 1);
- if (spirit.size() < final_level) spirit.resize(final_level, 1);
- if (agility.size() < final_level) agility.resize(final_level, 1);
+ size_t level = 0;
+ if (final_level > 0) level = final_level;
+ if (maxhp.size() < level) maxhp.resize(level, 1);
+ if (maxsp.size() < level) maxsp.resize(level, 0);
+ if (attack.size() < level) attack.resize(level, 1);
+ if (defense.size() < level) defense.resize(level, 1);
+ if (spirit.size() < level) spirit.resize(level, 1);
+ if (agility.size() < level) agility.resize(level, 1);
}

Resolve some warnings
Format (mostly newlib-related)
Unused Parameters