From 3f7e2b48f39c5bc615ec5d39bad428bef9398215 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 13 Dec 2022 19:28:38 +0000 Subject: [PATCH] Adjust messages logged on game handle creation --- src/api/api.cpp | 30 ++++++++++++++++++++++++++++-- src/api/game/game.cpp | 9 +-------- src/tests/api/interface/main.cpp | 12 ++++++------ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/api/api.cpp b/src/api/api.cpp index 59bbe9a1..1c12dd46 100644 --- a/src/api/api.cpp +++ b/src/api/api.cpp @@ -32,6 +32,31 @@ namespace fs = std::filesystem; namespace loot { +const char* DescribeGameType(GameType gameType) { + switch (gameType) { + case GameType::tes4: + return "The Elder Scrolls IV: Oblivion"; + case GameType::tes5: + return "The Elder Scrolls V: Skyrim"; + case GameType::fo3: + return "Fallout 3"; + case GameType::fonv: + return "Fallout: New Vegas"; + case GameType::fo4: + return "Fallout 4"; + case GameType::tes5se: + return "The Elder Scrolls V: Skyrim Special Edition"; + case GameType::fo4vr: + return "Fallout 4 VR"; + case GameType::tes5vr: + return "The Elder Scrolls V: Skyrim VR"; + case GameType::tes3: + return "The Elder Scrolls III: Morrowind"; + default: + return "Unknown"; + } +} + std::filesystem::path ResolvePath(const std::filesystem::path& path) { // is_symlink can throw on MSVC with the message // "symlink_status: The parameter is incorrect." @@ -79,8 +104,9 @@ LOOT_API std::unique_ptr CreateGameHandle( auto logger = getLogger(); if (logger) { logger->info( - "Attempting to create a game handle with game path \"{}\" " - "and local path \"{}\"", + "Attempting to create a game handle for game type \"{}\" with game " + "path \"{}\" and game local path \"{}\"", + DescribeGameType(game), gamePath.u8string(), gameLocalPath.u8string()); } diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 4300b225..f4785363 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -62,14 +62,7 @@ Game::Game(const GameType gameType, loadOrderHandler_(type_, gamePath_, localDataPath), conditionEvaluator_( std::make_shared(Type(), DataPath())), - database_(ApiDatabase(conditionEvaluator_)) { - auto logger = getLogger(); - if (logger) { - logger->info("Initialising load order data for game of type {} at: {}", - (int)type_, - gamePath_.u8string()); - } -} + database_(ApiDatabase(conditionEvaluator_)) {} GameType Game::Type() const { return type_; } diff --git a/src/tests/api/interface/main.cpp b/src/tests/api/interface/main.cpp index c5b1609d..6d96e418 100644 --- a/src/tests/api/interface/main.cpp +++ b/src/tests/api/interface/main.cpp @@ -73,8 +73,8 @@ TEST(SetLoggingCallback, shouldAcceptAMemberFunction) { FAIL(); } catch (...) { EXPECT_EQ( - "Attempting to create a game handle with game path \"dummy\" " - "and local path \"\"", + "Attempting to create a game handle for game type \"The Elder Scrolls " + "IV: Oblivion\" with game path \"dummy\" and game local path \"\"", testLogger.loggedMessages); SetLoggingCallback([](LogLevel, const char *) {}); @@ -112,8 +112,8 @@ TEST(SetLoggingCallback, shouldAcceptALambdaFunction) { FAIL(); } catch (...) { EXPECT_EQ( - "Attempting to create a game handle with game path \"dummy\" " - "and local path \"\"", + "Attempting to create a game handle for game type \"The Elder Scrolls " + "IV: Oblivion\" with game path \"dummy\" and game local path \"\"", loggedMessages); SetLoggingCallback([](LogLevel, const char *) {}); @@ -134,8 +134,8 @@ TEST(SetLoggingCallback, FAIL(); } catch (...) { EXPECT_EQ( - "Attempting to create a game handle with game path \"dummy\" " - "and local path \"\"", + "Attempting to create a game handle for game type \"The Elder Scrolls " + "IV: Oblivion\" with game path \"dummy\" and game local path \"\"", loggedMessages); SetLoggingCallback([](LogLevel, const char *) {});