prefer spdlog over luslog in C++ code (#7149)

luslog more meant for C compatibility
This commit is contained in:
Philip Dubé
2026-09-05 21:21:25 +00:00
committed by GitHub
parent 6d65db6174
commit e44bd8d989
10 changed files with 30 additions and 44 deletions
@@ -1,3 +1,5 @@
#include <spdlog/spdlog.h>
#include "functions.h"
#include "macros.h"
#include "soh/ShipUtils.h"
@@ -1018,8 +1020,9 @@ void RegisterEnemyRandomizer() {
? (player->actor.world.pos.y - 1500.0f)
: (player->actor.world.pos.y - 1000.0f);
if (enemy->world.pos.y < killHeight) {
LUSLOG_INFO(
"AfterActorUpdateBgCheckInfo: Killing enemy, out of bounds (id 0x%x, pos x %.1f y %.1f z %.1f)",
SPDLOG_INFO(
"AfterActorUpdateBgCheckInfo: Killing enemy, out of bounds (id {:#x}, pos x {:.1f} y {:.1f} z "
"{:.1f})",
enemy->id, enemy->world.pos.x, enemy->world.pos.y, enemy->world.pos.z);
Actor_Kill(enemy);
}
@@ -1,3 +1,5 @@
#include <spdlog/spdlog.h>
#include "GameInteractor.h"
#include "soh/ShipUtils.h"
#include <math.h>
@@ -268,7 +270,7 @@ void GameInteractor::RawAction::UnsetFlag(int16_t flagType, int16_t flag) {
break;
case FlagType::FLAG_RANDOMIZER_INF:
if (!IS_RANDO) {
LUSLOG_ERROR("Tried to unset randomizerInf flag outside of rando (%d)", flag);
SPDLOG_ERROR("Tried to unset randomizerInf flag outside of rando ({})", flag);
assert(false);
break;
}
@@ -419,7 +419,7 @@ void Context::ParseSpoiler(const char* spoilerFileName) {
mTrials->ParseJson(spoilerFileJson);
mSpoilerLoaded = true;
mSeedGenerated = false;
} catch (...) { LUSLOG_ERROR("Failed to load Spoiler File: %s", spoilerFileName); }
} catch (...) { SPDLOG_ERROR("Failed to load Spoiler File: {}", spoilerFileName); }
}
void Context::ParseHashIconIndexesJson(const nlohmann::json& spoilerFileJson) {
@@ -1,3 +1,5 @@
#include <spdlog/spdlog.h>
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/game-interactor/GameInteractor.h"
#include "randomizer_grotto.h"
@@ -6,6 +8,7 @@
#include "soh/Enhancements/item-tables/ItemTableTypes.h"
#include "soh/ObjectExtension/ObjectExtension.h"
#include "soh/Enhancements/randomizer/randomizer.h"
#include "soh/Enhancements/randomizer/randomizerEnumStrings.h"
extern "C" {
#include "src/overlays/actors/ovl_En_Elf/z_en_elf.h"
@@ -67,7 +70,7 @@ CheckIdentity ShuffleFairies_GetFairyIdentity(int32_t params, ActorID id) {
Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(id, sceneNum, params);
if (location->GetRandomizerCheck() == RC_UNKNOWN_CHECK) {
LUSLOG_WARN("FairyGetIdentity did not receive a valid RC value (%d).", location->GetRandomizerCheck());
SPDLOG_WARN("FairyGetIdentity did not receive a valid RC value ({}).", location->GetRandomizerCheck());
assert(false);
} else {
fairyIdentity.randomizerInf = static_cast<RandomizerInf>(location->GetCollectionCheck().flag);
@@ -147,8 +147,6 @@ uint8_t Rock_RandomizerHoldsItem(CheckIdentity rockIdentity, PlayState* play, bo
}
void Rock_RandomizerSpawnCollectible(Actor* actor, CheckIdentity rockIdentity, PlayState* play) {
LUSLOG_INFO("ROCKdrop %d\t:\t%d, %d", rockIdentity.randomizerCheck, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
EnItem00* item00 = (EnItem00*)Item_DropCollectible2(play, &actor->world.pos, ITEM00_SOH_DUMMY);
item00->randoInf = rockIdentity.randomizerInf;
item00->itemEntry = Rando::Context::GetInstance()->GetFinalGIEntry(rockIdentity.randomizerCheck, true, GI_NONE);
@@ -217,9 +215,7 @@ static CheckIdentity IdentifyRock(s32 sceneNum, s32 posX, s32 posZ) {
Rando::Location* location = OTRGlobals::Instance->gRandomizer->GetCheckObjectFromActor(
ACTOR_EN_ISHI, sceneNum, TWO_ACTOR_PARAMS(posX, posZ));
if (!IdentifyCheck(&rockIdentity, location)) {
SPDLOG_WARN("IdentifyRock did not receive a valid RC value %d,%d.", posX, posZ);
}
IdentifyCheck(&rockIdentity, location);
return rockIdentity;
}
@@ -228,13 +224,6 @@ void EnIshi_RandomizerInit(void* actorRef) {
Actor* actor = static_cast<Actor*>(actorRef);
EnIshi* rockActor = static_cast<EnIshi*>(actorRef);
auto rockIdentity = IdentifyRock(gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
if (rockIdentity.randomizerCheck == RC_MAX) {
LUSLOG_WARN("ROCK ishi %d\t:\t%d, %d", rockIdentity.randomizerCheck, actor->params & 1,
(s16)actor->world.pos.x, (s16)actor->world.pos.z);
} else {
LUSLOG_INFO("ROCK ishi%d %d\t:\t%d, %d", rockIdentity.randomizerCheck, actor->params & 1,
(s16)actor->world.pos.x, (s16)actor->world.pos.z);
}
if (Rock_RandomizerHoldsItem(rockIdentity, gPlayState, actor->params & 1) && rockActor->actor.draw != nullptr) {
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(rockIdentity));
@@ -246,13 +235,7 @@ void ObjBombiwa_RandomizerInit(void* actorRef) {
Actor* actor = static_cast<Actor*>(actorRef);
ObjBombiwa* rockActor = static_cast<ObjBombiwa*>(actorRef);
auto rockIdentity = IdentifyRock(gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
if (rockIdentity.randomizerCheck == RC_MAX) {
LUSLOG_INFO("ROCK bombiwa\t:\t%d, %d", rockIdentity.randomizerCheck, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
} else {
LUSLOG_INFO("ROCK bombiwa%d\t:\t%d, %d", rockIdentity.randomizerCheck, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
}
if (Rock_RandomizerHoldsItem(rockIdentity, gPlayState, true) && rockActor->actor.draw != nullptr) {
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(rockIdentity));
rockActor->actor.draw = ObjBombiwa_RandomizerDraw;
@@ -263,13 +246,7 @@ void ObjHamishi_RandomizerInit(void* actorRef) {
Actor* actor = static_cast<Actor*>(actorRef);
ObjHamishi* rockActor = static_cast<ObjHamishi*>(actorRef);
auto rockIdentity = IdentifyRock(gPlayState->sceneNum, (s16)actor->world.pos.x, (s16)actor->world.pos.z);
if (rockIdentity.randomizerCheck == RC_MAX) {
LUSLOG_WARN("ROCK hamishi\t:\t%d, %d", rockIdentity.randomizerCheck, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
} else {
LUSLOG_INFO("ROCK hamishi%d\t:\t%d, %d", rockIdentity.randomizerCheck, (s16)actor->world.pos.x,
(s16)actor->world.pos.z);
}
if (Rock_RandomizerHoldsItem(rockIdentity, gPlayState, true) && rockActor->actor.draw != nullptr) {
ObjectExtension::GetInstance().Set<CheckIdentity>(actor, std::move(rockIdentity));
rockActor->actor.draw = ObjHamishi_RandomizerDraw;
@@ -6,7 +6,7 @@
#include "soh/Enhancements/debugger/performanceTimer.h"
#include <fstream>
#include <libultraship/log/luslog.h>
#include <spdlog/spdlog.h>
#include <soh/OTRGlobals.h>
#include "3drando/shops.hpp"
@@ -498,8 +498,8 @@ Rando::Entrance* Region::GetExit(RandomizerRegion exitToReturn) {
}
}
LUSLOG_ERROR("ERROR: EXIT \"%s\" DOES NOT EXIST IN \"%s\"", RegionTable(exitToReturn)->regionName.c_str(),
this->regionName.c_str());
SPDLOG_ERROR("ERROR: EXIT \"{}\" DOES NOT EXIST IN \"{}\"", RegionTable(exitToReturn)->regionName,
this->regionName);
assert(false);
return nullptr;
}
@@ -5,6 +5,7 @@
#include <nlohmann/json.hpp>
#include <ship/window/FileDropMgr.h>
#include <spdlog/spdlog.h>
#include "randomizer.h"
#include "3drando/menu.hpp"
@@ -17,6 +18,7 @@
#include "settings.h"
#include "soh/util.h"
#include "randomizerTypes.h"
#include "randomizerEnumStrings.h"
#include "soh/ObjectExtension/ObjectExtension.h"
#include "soh/Enhancements/randomizer/RCToRandInf.h"
#include "dungeon.h"
@@ -1139,8 +1141,8 @@ static bool ChildTradeSlotOccupied() {
extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
if (giEntry.modIndex != MOD_RANDOMIZER) {
LUSLOG_WARN(
"Randomizer_Item_Give was called with a GetItemEntry with a mod index different from MOD_RANDOMIZER (%d)",
SPDLOG_WARN(
"Randomizer_Item_Give was called with a GetItemEntry with a mod index different from MOD_RANDOMIZER ({})",
giEntry.modIndex);
assert(false);
return -1;
@@ -1456,7 +1458,7 @@ extern "C" u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
break;
}
default:
LUSLOG_WARN("Randomizer_Item_Give didn't have behaviour specified for getItemId=%d", item);
SPDLOG_WARN("Randomizer_Item_Give didn't have behaviour specified for getItemId={}", item);
assert(false);
return -1;
}
@@ -1,6 +1,6 @@
#include <dlfcn.h>
#include <libultraship/log/luslog.h>
#include <spdlog/spdlog.h>
#include "ESpeakSpeechSynthesizer.h"
@@ -16,7 +16,7 @@ bool ESpeakSpeechSynthesizer::DoInit() {
this->Terminate = (speak_Terminate)dlsym(espeak, "espeak_Terminate");
if (this->Initialize == NULL || this->SetVoiceByProperties == NULL || this->Synth == NULL ||
this->Terminate == NULL) {
lusprintf(__FILE__, __LINE__, 2, "Failed to load espeak-ng");
SPDLOG_INFO("Failed to load espeak-ng");
dlclose(espeak);
return false;
} else {
@@ -37,7 +37,7 @@ void ESpeakSpeechSynthesizer::DoUninitialize() {
void ESpeakSpeechSynthesizer::Speak(const char* text, const char* language) {
if (this->espeak == NULL) {
lusprintf(__FILE__, __LINE__, 2, "Spoken Text (%s): %s", language, text);
SPDLOG_INFO("Spoken Text ({}): {}", language, text);
} else {
if (language != this->mLanguage) {
espeak_VOICE voice = { .languages = language };
@@ -1,4 +1,4 @@
#include <libultraship/log/luslog.h>
#include <spdlog/spdlog.h>
#include "SpeechLogger.h"
@@ -6,7 +6,7 @@ SpeechLogger::SpeechLogger() {
}
void SpeechLogger::Speak(const char* text, const char* language) {
lusprintf(__FILE__, __LINE__, 2, "Spoken Text (%s): %s", language, text);
SPDLOG_INFO("Spoken Text ({}): {}", language, text);
}
bool SpeechLogger::DoInit() {
+1 -2
View File
@@ -48,8 +48,7 @@ extern "C" void OTRPlay_SpawnScene(PlayState* play, s32 sceneId, s32 spawn) {
// Failed to load scene... default to doodongs cavern
if (play->sceneSegment == nullptr) {
lusprintf(__FILE__, __LINE__, 2, "Unable to load scene %s... Defaulting to Doodong's Cavern!\n",
scenePath.c_str());
SPDLOG_INFO("Unable to load scene {}... Defaulting to Doodong's Cavern!", scenePath);
OTRPlay_SpawnScene(play, 0x01, 0);
return;
}