From e1e7d21a48062a56eebefa500a89eb939f81db1e Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 15 Aug 2024 00:15:54 -0300 Subject: [PATCH 1/3] fix: only take screenshot when achievement is successfully added --- src/lua/functions/creatures/player/player_functions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lua/functions/creatures/player/player_functions.cpp b/src/lua/functions/creatures/player/player_functions.cpp index 9ccbc95c6bb..d360b482a7b 100644 --- a/src/lua/functions/creatures/player/player_functions.cpp +++ b/src/lua/functions/creatures/player/player_functions.cpp @@ -4224,8 +4224,12 @@ int PlayerFunctions::luaPlayerAddAchievement(lua_State* L) { achievementId = g_game().getAchievementByName(getString(L, 2)).id; } - player->sendTakeScreenshot(SCREENSHOT_TYPE_ACHIEVEMENT); - pushBoolean(L, player->achiev()->add(achievementId, getBoolean(L, 3, true))); + bool success = player->achiev()->add(achievementId, getBoolean(L, 3, true)); + if (success) { + player->sendTakeScreenshot(SCREENSHOT_TYPE_ACHIEVEMENT); + } + + pushBoolean(L, success); return 1; } From d875de8f9a04e337481f31bfebe0d48a9d09b946 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 15 Aug 2024 00:19:14 -0300 Subject: [PATCH 2/3] style: capitalize "Title System" in log message --- src/game/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index d5c9544a8f9..df1b401bf48 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -10591,7 +10591,7 @@ std::map Game::getAchievements() { void Game::logCyclopediaStats() { g_logger().info("Loaded {} badges from Badge System", m_badges.size()); - g_logger().info("Loaded {} titles from Title system", m_titles.size()); + g_logger().info("Loaded {} titles from Title System", m_titles.size()); } std::unordered_set Game::getBadges() { From 36dd185107231c7fcfcdae5f8bf58fcdde735182 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 15 Aug 2024 00:33:26 -0300 Subject: [PATCH 3/3] feat: add new constant for missing screenshot type --- src/lua/functions/core/game/lua_enums.cpp | 1 + src/utils/utils_definitions.hpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lua/functions/core/game/lua_enums.cpp b/src/lua/functions/core/game/lua_enums.cpp index bfaa07dcc73..05fc72c019f 100644 --- a/src/lua/functions/core/game/lua_enums.cpp +++ b/src/lua/functions/core/game/lua_enums.cpp @@ -228,6 +228,7 @@ void LuaEnums::initOthersEnums(lua_State* L) { registerEnum(L, SCREENSHOT_TYPE_PLAYERATTACKING); registerEnum(L, SCREENSHOT_TYPE_TREASUREFOUND); registerEnum(L, SCREENSHOT_TYPE_SKILLUP); + registerEnum(L, SCREENSHOT_TYPE_GIFTOFLIFE); } void LuaEnums::initAccountEnums(lua_State* L) { diff --git a/src/utils/utils_definitions.hpp b/src/utils/utils_definitions.hpp index abf690522d5..9775a5ebcad 100644 --- a/src/utils/utils_definitions.hpp +++ b/src/utils/utils_definitions.hpp @@ -734,5 +734,6 @@ enum Screenshot_t : uint8_t { SCREENSHOT_TYPE_PLAYERKILL = 9, SCREENSHOT_TYPE_PLAYERATTACKING = 10, SCREENSHOT_TYPE_TREASUREFOUND = 11, - SCREENSHOT_TYPE_SKILLUP = 12 + SCREENSHOT_TYPE_SKILLUP = 12, + SCREENSHOT_TYPE_GIFTOFLIFE = 13, };