From c87e8fc43ca53911b663cde215332e4c35ad127a Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Wed, 19 Apr 2023 05:22:50 -0700 Subject: [PATCH 1/2] fix: possible nil table on useStamina function --- data/events/scripts/player.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index f655d45bbb3..90c48a6f905 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -614,7 +614,7 @@ local function useStamina(player) end local playerId = player:getId() - if not playerId then + if not playerId or not nextUseStaminaTime[playerId] then return false end From 2af891819c3d72db3438dea1de316ff2eb27cb16 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 19 Apr 2023 12:23:28 +0000 Subject: [PATCH 2/2] Code format - (Clang-format) --- src/game/game.cpp | 11 +++++------ src/map/map.cpp | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 6bcdaf67673..738c70a9049 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -187,8 +187,8 @@ void Game::setGameState(GameState_t newState) { // Load monsters and npcs custom stored by the "loadFromXML" function for (int i = 0; i < 50; i++) { - map.spawnsNpcCustomMaps[i].startup(); - map.spawnsMonsterCustomMaps[i].startup(); + map.spawnsNpcCustomMaps[i].startup(); + map.spawnsMonsterCustomMaps[i].startup(); } raids.loadFromXml(); @@ -311,7 +311,7 @@ bool Game::loadCustomMaps(const std::string &customMapPath) { Monster::despawnRange = g_configManager().getNumber(DEFAULT_DESPAWNRANGE); Monster::despawnRadius = g_configManager().getNumber(DEFAULT_DESPAWNRADIUS); - namespace fs = std::filesystem; + namespace fs = std::filesystem; int customMapIndex = 0; for (const auto &entry : fs::directory_iterator(customMapPath)) { @@ -323,7 +323,7 @@ bool Game::loadCustomMaps(const std::string &customMapPath) { std::string filename = realPath.stem().string(); - //Do not load more maps than possible + // Do not load more maps than possible if (customMapIndex >= 50) { SPDLOG_WARN("Maximum number of custom maps loaded. Custom map {} [ignored]", filename); continue; @@ -335,7 +335,7 @@ bool Game::loadCustomMaps(const std::string &customMapPath) { continue; } - //Avoid loading main map again. + // Avoid loading main map again. if (filename == g_configManager().getString(MAP_NAME)) { SPDLOG_WARN("Custom map {} is main map", filename); continue; @@ -355,7 +355,6 @@ bool Game::loadCustomMaps(const std::string &customMapPath) { return true; } - void Game::loadMap(const std::string &path, const Position &pos, bool unload) { map.loadMap(path, false, false, false, false, pos, unload); } diff --git a/src/map/map.cpp b/src/map/map.cpp index eb469657a4d..35486267dcb 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -99,7 +99,6 @@ bool Map::loadMap(const std::string &identifier, bool mainMap /*= false*/, bool return true; } - bool Map::loadMapCustom(const std::string &mapName, bool loadHouses, bool loadMonsters, bool loadNpcs, int customMapIndex) { // Load the map std::string path = g_configManager().getString(DATA_DIRECTORY) + "/world/custom/" + mapName + ".otbm";