Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fmt errors. #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ add_library(athena-sakura EXCLUDE_FROM_ALL
include/athena/SpritePart.hpp
)

target_include_directories(athena-sakura PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/extern/fmt/include>
)

add_library(athena-wiisave EXCLUDE_FROM_ALL
src/athena/WiiBanner.cpp
src/athena/WiiFile.cpp
Expand Down Expand Up @@ -154,6 +159,10 @@ if(NOT MSVC AND NOT GEKKO AND NOT NX)
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
endif()

target_include_directories(athena-wiisave PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/extern/fmt/include>
)

add_library(athena-zelda EXCLUDE_FROM_ALL
src/athena/ALTTPFile.cpp
Expand Down Expand Up @@ -190,6 +199,11 @@ add_library(athena-zelda EXCLUDE_FROM_ALL
include/athena/ZQuestFileWriter.hpp
)

target_include_directories(athena-zelda PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/extern/fmt/include>
)

# Icon
set(ATHENA_ICO ${CMAKE_CURRENT_SOURCE_DIR}/Athena.ico)

Expand Down
4 changes: 2 additions & 2 deletions src/athena/ALTTPFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ALTTPFile::ALTTPFile(std::vector<ALTTPQuest*> quests, std::vector<ALTTPQuest*> b

void ALTTPFile::setQuest(atUint32 id, ALTTPQuest* val) {
if (id > m_quests.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand All @@ -19,7 +19,7 @@ void ALTTPFile::setQuest(atUint32 id, ALTTPQuest* val) {
std::vector<ALTTPQuest*> ALTTPFile::questList() const { return m_quests; }
ALTTPQuest* ALTTPFile::quest(atUint32 id) const {
if (id > m_quests.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion src/athena/ALTTPFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ ALTTPDungeonItemFlags ALTTPFileReader::readDungeonFlags() {
flags.HyruleCastle = (flagsByte >> 6) & 1;
flags.SewerPassage = (flagsByte >> 7) & 1;

atDebug("{:x} {:x}", flags.flags1, flags.flags2);
atDebug(fmt("{:x} {:x}"), flags.flags1, flags.flags2);
return flags;
}

Expand Down
20 changes: 10 additions & 10 deletions src/athena/ALTTPQuest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ std::vector<ALTTPOverworldEvent*> ALTTPQuest::overworldEvents() const { return m

ALTTPOverworldEvent* ALTTPQuest::overworldEvent(atUint32 id) const {
if (id > m_overworldEvents.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return nullptr;
}

Expand Down Expand Up @@ -126,7 +126,7 @@ void ALTTPQuest::setDungeonKeys(std::vector<atUint8> val) { m_dungeonKeys = val;

void ALTTPQuest::setDungeonKeys(atUint32 id, atUint8 val) {
if (id > m_dungeonKeys.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand All @@ -135,7 +135,7 @@ void ALTTPQuest::setDungeonKeys(atUint32 id, atUint8 val) {

atUint8 ALTTPQuest::dungeonKeys(atUint32 id) const {
if (id > m_dungeonKeys.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return 0;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ void ALTTPQuest::setOldManFlags(std::vector<atUint8> flags) { m_oldManFlags = fl

void ALTTPQuest::setOldManFlag(atUint32 id, atUint8 val) {
if (id > m_oldManFlags.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand All @@ -185,7 +185,7 @@ void ALTTPQuest::setOldManFlag(atUint32 id, atUint8 val) {

atUint8 ALTTPQuest::oldManFlag(atUint32 id) {
if (id > m_oldManFlags.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return 0;
}
return m_oldManFlags[id];
Expand All @@ -201,7 +201,7 @@ void ALTTPQuest::setUnknown1(std::vector<atUint8> flags) { m_unknown1 = flags; }

void ALTTPQuest::setUnknown1(atUint32 id, atUint8 val) {
if (id > m_unknown1.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand All @@ -210,7 +210,7 @@ void ALTTPQuest::setUnknown1(atUint32 id, atUint8 val) {

atUint8 ALTTPQuest::unknown1(atUint32 id) {
if (id > m_unknown1.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return 0;
}

Expand All @@ -223,7 +223,7 @@ void ALTTPQuest::setPlayerName(std::vector<atUint16> playerName) { m_playerName

void ALTTPQuest::setPlayerName(const std::string& playerName) {
if (playerName == std::string() || playerName.size() > 6) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand Down Expand Up @@ -401,7 +401,7 @@ void ALTTPQuest::setDungeonDeathTotals(std::vector<atUint16> val) { m_dungeonDea

void ALTTPQuest::setDungeonDeathTotal(atUint32 id, atUint16 val) {
if (id > m_dungeonDeathTotals.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return;
}

Expand All @@ -410,7 +410,7 @@ void ALTTPQuest::setDungeonDeathTotal(atUint32 id, atUint16 val) {

atUint16 ALTTPQuest::dungeonDeathTotal(atUint32 id) const {
if (id > m_dungeonDeathTotals.size()) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/athena/SkywardSwordFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void SkywardSwordFile::addQuest(athena::SkywardSwordQuest* q) {

SkywardSwordQuest* SkywardSwordFile::quest(atUint32 id) {
if (id > m_quests.size() - 1) {
atWarning("index out of range");
atWarning(fmt("index out of range"));
return nullptr;
}

Expand Down
6 changes: 3 additions & 3 deletions src/athena/SkywardSwordFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ SkywardSwordFile* SkywardSwordFileReader::read() {
SkywardSwordFile* file = NULL;

if (length() != 0xFBE0) {
atError("File not the expected size of 0xFBE0");
atError(fmt("File not the expected size of 0xFBE0"));
return nullptr;
}

atUint32 magic = readUint32();

if (magic != SkywardSwordFile::USMagic && magic != SkywardSwordFile::JAMagic && magic != SkywardSwordFile::EUMagic) {
atError("Not a valid Skyward Sword save file");
atError(fmt("Not a valid Skyward Sword save file"));
return nullptr;
}

seek(0x01C, SeekOrigin::Begin);
atUint32 headerSize = readUint32(); // Seems to be (headerSize - 1)

if (headerSize != 0x1D) {
atError("Invalid header size, Corrupted data?");
atError(fmt("Invalid header size, Corrupted data?"));
return nullptr;
}

Expand Down
4 changes: 2 additions & 2 deletions src/athena/SkywardSwordFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SkywardSwordFileWriter::SkywardSwordFileWriter(const std::string& filename) : Me

void SkywardSwordFileWriter::write(SkywardSwordFile* file) {
if (!file) {
atError("file cannot be NULL");
atError(fmt("file cannot be NULL"));
return;
}

Expand All @@ -31,7 +31,7 @@ void SkywardSwordFileWriter::write(SkywardSwordFile* file) {

for (SkywardSwordQuest* q : quests) {
if (q->length() != 0x53C0) {
atError("q->data() not 0x53C0 bytes in length");
atError(fmt("q->data() not 0x53C0 bytes in length"));
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/athena/SkywardSwordQuest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ atUint8* SkywardSwordQuest::skipData() const { return m_skipData.get(); }

void SkywardSwordQuest::setPlayerName(const std::string& name) {
if (name.length() > 8)
atDebug("WARNING: name cannot be greater than 8 characters, automatically truncating");
atDebug(fmt("WARNING: name cannot be greater than 8 characters, automatically truncating"));

const utf8proc_uint8_t* buf = reinterpret_cast<const utf8proc_uint8_t*>(name.c_str());
for (atUint32 i = 0; i < 8; i++) {
Expand All @@ -57,7 +57,7 @@ void SkywardSwordQuest::setPlayerName(const std::string& name) {
utf8proc_int32_t wc;
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
if (len < 0) {
atError("invalid UTF-8 string");
atError(fmt("invalid UTF-8 string"));
return;
}
buf += len;
Expand Down
8 changes: 4 additions & 4 deletions src/athena/SpriteFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ Sakura::SpriteFile* SpriteFileReader::readFile() {
atUint32 magic = readUint32();

if (magic != Sakura::SpriteFile::Magic) {
atError("Not a valid Sakura Sprite container");
atError(fmt("Not a valid Sakura Sprite container"));
return nullptr;
}

atUint32 version = readUint32();

// TODO: Make this more verbose
if (version != Sakura::SpriteFile::Version) {
atError("Unsupported version");
atError(fmt("Unsupported version"));
return nullptr;
}

Expand All @@ -51,7 +51,7 @@ Sakura::SpriteFile* SpriteFileReader::readFile() {
// which require data to be 32 byte aligned, or it causes some issues.
// It's also convenient to have this, for later expansion.
atUint32 reserved = readUint32();
UNUSED(reserved);
//UNUSED(reserved);

// Next we have to load the textures
// If we tried to add them one at a time to the sprite container
Expand Down Expand Up @@ -175,7 +175,7 @@ Sakura::SpriteFile* SpriteFileReader::readFile() {

#endif
else {
atError("Sprite names cannot be empty");
atError(fmt("Sprite names cannot be empty"));
return nullptr;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/athena/SpriteFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SpriteFileWriter::SpriteFileWriter(std::string_view filepath) : MemoryCopyWriter

void SpriteFileWriter::writeFile(Sakura::SpriteFile* file) {
if (!file) {
atError("file cannot be NULL");
atError(fmt("file cannot be NULL"));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/athena/WiiFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ bool WiiFile::isFile() const { return (m_type == WiiFile::File); }

void WiiFile::addChild(WiiFile* file) {
if (!isDirectory()) {
atWarning("{} is not a directory", filename());
atWarning(fmt("{} is not a directory"), filename());
return;
}

Expand Down
12 changes: 6 additions & 6 deletions src/athena/WiiSaveReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ std::unique_ptr<WiiSave> WiiSaveReader::readSave() {
WiiSave* ret = new WiiSave;

if (length() < 0xF0C0) {
atError("Not a valid WiiSave");
atError(fmt("Not a valid WiiSave"));
return nullptr;
}

WiiBanner* banner = this->readBanner();

if (!banner) {
atError("Invalid banner");
atError(fmt("Invalid banner"));
return nullptr;
}

ret->setBanner(banner);
atUint32 bkVer = readUint32();

if (bkVer != 0x00000070) {
atError("Invalid BacKup header size");
atError(fmt("Invalid BacKup header size"));
return nullptr;
}

atUint32 bkMagic = readUint32();

if (bkMagic != 0x426B0001) {
atError("Invalid BacKup header magic");
atError(fmt("Invalid BacKup header magic"));
return nullptr;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ WiiBanner* WiiSaveReader::readBanner() {
std::cerr << std::endl;
setData(oldData, oldLen);
seek(oldPos, SeekOrigin::Begin);
atError("MD5 Mismatch");
atError(fmt("MD5 Mismatch"));
return nullptr;
}

Expand Down Expand Up @@ -158,7 +158,7 @@ WiiBanner* WiiSaveReader::readBanner() {
// Make sure to reset m_reader values back to the old ones.
setData(oldData, oldLen);
seek(oldPos, SeekOrigin::Begin);
atError("Invalid Header Magic");
atError(fmt("Invalid Header Magic"));
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion src/athena/WiiSaveWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ WiiSaveWriter::WiiSaveWriter(const std::string& filename) : MemoryCopyWriter(fil
bool WiiSaveWriter::writeSave(WiiSave* save, atUint8* macAddress, atUint32 ngId, atUint8* ngPriv, atUint8* ngSig,
atUint32 ngKeyId, const std::string& filepath) {
if (!save) {
atError("save cannot be NULL");
atError(fmt("save cannot be NULL"));
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions src/athena/ZQuestFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ ZQuestFile* ZQuestFileReader::read() {
magic = readUint32();

if ((magic & 0x00FFFFFF) != (ZQuestFile::Magic & 0x00FFFFFF)) {
atError("Not a valid ZQuest file");
atError(fmt("Not a valid ZQuest file"));
return nullptr;
}

version = readUint32();

if (version > ZQuestFile::Version) {
atError("Unsupported ZQuest version");
atError(fmt("Unsupported ZQuest version"));
return nullptr;
}

Expand Down Expand Up @@ -60,7 +60,7 @@ ZQuestFile* ZQuestFileReader::read() {

if (version >= ZQUEST_VERSION_CHECK(2, 0, 0)) {
if (checksum != athena::checksums::crc32(data.get(), compressedLen)) {
atError("Checksum mismatch, data corrupt");
atError(fmt("Checksum mismatch, data corrupt"));
return nullptr;
}
} else {
Expand All @@ -75,7 +75,7 @@ ZQuestFile* ZQuestFileReader::read() {

if (dstLen != uncompressedLen) {
delete[] dst;
atError("Error decompressing data");
atError(fmt("Error decompressing data"));
return nullptr;
}

Expand Down
2 changes: 1 addition & 1 deletion src/athena/ZQuestFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ZQuestFileWriter::ZQuestFileWriter(const std::string& filename) : MemoryCopyWrit

void ZQuestFileWriter::write(ZQuestFile* quest, bool compress) {
if (!quest) {
atError("quest cannot be NULL");
atError(fmt("quest cannot be NULL"));
return;
}

Expand Down