From 7f4344fa722caccb985bef468eb15b5bd614d0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sat, 11 Jan 2025 02:40:03 -0300 Subject: [PATCH 01/15] Update analysis-reviewdog-cppcheck.yml --- .github/workflows/analysis-reviewdog-cppcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analysis-reviewdog-cppcheck.yml b/.github/workflows/analysis-reviewdog-cppcheck.yml index bca1d057..b39f6ee5 100644 --- a/.github/workflows/analysis-reviewdog-cppcheck.yml +++ b/.github/workflows/analysis-reviewdog-cppcheck.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@main - name: Setup reviewdog - uses: reviewdog/action-setup@v1.0.3 + uses: reviewdog/action-setup@v1.3.0 - name: Setup cppcheck run: sudo apt-get update && sudo apt-get install -y cppcheck From 05d55dbf726d756068823621780f1aef871a5760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sat, 11 Jan 2025 11:57:34 -0300 Subject: [PATCH 02/15] * Fix spells and runes interactions https://github.com/opentibiabr/canary/pull/3241 Ty @kaleohanopahala --- src/creatures/combat/combat.cpp | 30 +++++++++++++++--------------- src/creatures/combat/combat.hpp | 2 +- src/creatures/combat/spells.cpp | 7 ------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/creatures/combat/combat.cpp b/src/creatures/combat/combat.cpp index 65da2cfd..2224505f 100644 --- a/src/creatures/combat/combat.cpp +++ b/src/creatures/combat/combat.cpp @@ -129,7 +129,7 @@ void Combat::getCombatArea(const Position ¢erPos, const Position &targetPos, } if (area) { - area->getList(centerPos, targetPos, list); + area->getList(centerPos, targetPos, list, getDirectionTo(targetPos, centerPos)); } else { list.emplace_back(g_game().map.getOrCreateTile(targetPos)); } @@ -261,18 +261,14 @@ ReturnValue Combat::canTargetCreature(const std::shared_ptr &player, con ReturnValue Combat::canDoCombat(const std::shared_ptr &caster, const std::shared_ptr &tile, bool aggressive) { if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) { - return RETURNVALUE_NOTENOUGHROOM; + return RETURNVALUE_CANNOTTHROW; } if (aggressive && tile->hasFlag(TILESTATE_PROTECTIONZONE)) { return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE; } - if (tile->hasFlag(TILESTATE_FLOORCHANGE)) { - return RETURNVALUE_NOTENOUGHROOM; - } - if (tile->getTeleportItem()) { - return RETURNVALUE_NOTENOUGHROOM; + return RETURNVALUE_CANNOTTHROW; } if (caster) { @@ -1945,7 +1941,9 @@ AreaCombat::~AreaCombat() { clear(); } -void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, std::vector> &list) const { +void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, std::vector> &list, const Direction dir) const { + auto casterPos = getNextPosition(dir, targetPos); + const std::unique_ptr &area = getArea(centerPos, targetPos); if (!area) { return; @@ -1957,17 +1955,19 @@ void AreaCombat::getList(const Position ¢erPos, const Position &targetPos, s const uint32_t rows = area->getRows(); const uint32_t cols = area->getCols(); - list.reserve(rows * cols); + list.reserve(rows * cols); Position tmpPos(targetPos.x - centerX, targetPos.y - centerY, targetPos.z); - for (uint32_t y = 0; y < rows; ++y, ++tmpPos.y, tmpPos.x -= cols) { - for (uint32_t x = 0; x < cols; ++x, ++tmpPos.x) { - if (area->getValue(y, x) != 0) { - if (g_game().isSightClear(targetPos, tmpPos, true)) { - list.emplace_back(g_game().map.getOrCreateTile(tmpPos)); - } + + for (uint32_t y = 0; y < rows; ++y) { + for (uint32_t x = 0; x < cols; ++x) { + if (area->getValue(y, x) != 0 && g_game().isSightClear(casterPos, tmpPos, true)) { + list.emplace_back(g_game().map.getOrCreateTile(tmpPos)); } + ++tmpPos.x; } + ++tmpPos.y; + tmpPos.x -= cols; } } diff --git a/src/creatures/combat/combat.hpp b/src/creatures/combat/combat.hpp index 4e7e0f6f..105445d1 100644 --- a/src/creatures/combat/combat.hpp +++ b/src/creatures/combat/combat.hpp @@ -163,7 +163,7 @@ class AreaCombat { // non-assignable AreaCombat &operator=(const AreaCombat &) = delete; - void getList(const Position ¢erPos, const Position &targetPos, std::vector> &list) const; + void getList(const Position ¢erPos, const Position &targetPos, std::vector> &list, const Direction dir) const; void setupArea(const std::list &list, uint32_t rows); void setupArea(int32_t length, int32_t spread); diff --git a/src/creatures/combat/spells.cpp b/src/creatures/combat/spells.cpp index 2bb4889c..642a2e46 100644 --- a/src/creatures/combat/spells.cpp +++ b/src/creatures/combat/spells.cpp @@ -562,13 +562,6 @@ bool Spell::playerInstantSpellCheck(const std::shared_ptr &player, const const auto &tile = g_game().map.getOrCreateTile(toPos); - ReturnValue ret = Combat::canDoCombat(player, tile, aggressive); - if (ret != RETURNVALUE_NOERROR) { - player->sendCancelMessage(ret); - g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF); - return false; - } - if (blockingCreature && tile->getBottomVisibleCreature(player) != nullptr) { player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM); g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF); From 676978d1e5bb3cd249d9f87a3b276f82f01782a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sat, 11 Jan 2025 14:52:06 -0300 Subject: [PATCH 03/15] * Game tester moved to flags - Some improvements to game tester, removed config from config.lua and added a new flag and group --- config.lua.dist | 3 --- data/XML/groups.xml | 5 +++++ data/libs/functions/boss_lever.lua | 5 +++-- data/scripts/talkactions/god/flags.lua | 1 + markdowns/CHANGELOG.md | 5 ++++- src/config/config_enums.hpp | 1 - src/config/configmanager.cpp | 1 - src/creatures/players/player.cpp | 10 +++++++--- src/utils/utils_definitions.hpp | 1 + 9 files changed, 21 insertions(+), 11 deletions(-) diff --git a/config.lua.dist b/config.lua.dist index c725782d..35823c03 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -21,9 +21,6 @@ toggleMaintainMode = false -- @field [parent=#global] #string maintainModeMessage an empty string by default, set a custom message if needed. maintainModeMessage = "" --- toggleTestMode get player infinite health mana and soul. -toggleTestMode = false - -- Rook system -- NOTE: Town ids: Dawnport = 2, Rookgaard = 3 toggleRookSystem = false diff --git a/data/XML/groups.xml b/data/XML/groups.xml index e5c697ce..2c3fee37 100644 --- a/data/XML/groups.xml +++ b/data/XML/groups.xml @@ -147,4 +147,9 @@ + + + + + diff --git a/data/libs/functions/boss_lever.lua b/data/libs/functions/boss_lever.lua index 33b1b3e7..bc3b0aba 100644 --- a/data/libs/functions/boss_lever.lua +++ b/data/libs/functions/boss_lever.lua @@ -178,7 +178,8 @@ function BossLever:onUse(player) end local checkAccountType = creature:getAccountType() < ACCOUNT_TYPE_GAMEMASTER - if checkAccountType and creature:getLevel() < self.requiredLevel then + local isGameTester = player:hasFlag(PlayerFlag_IsGameTester) + if checkAccountType and not isGameTester and creature:getLevel() < self.requiredLevel then local message = "All players need to be level " .. self.requiredLevel .. " or higher." creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) @@ -186,7 +187,7 @@ function BossLever:onUse(player) end local infoPositions = lever:getInfoPositions() - if creature:getGroup():getId() < GROUP_TYPE_GOD and checkAccountType and self:lastEncounterTime(creature) > os.time() then + if creature:getGroup():getId() < GROUP_TYPE_GOD and checkAccountType and not isGameTester and self:lastEncounterTime(creature) > os.time() then for _, posInfo in pairs(infoPositions) do local currentPlayer = posInfo.creature if currentPlayer then diff --git a/data/scripts/talkactions/god/flags.lua b/data/scripts/talkactions/god/flags.lua index 3364fd01..58246043 100644 --- a/data/scripts/talkactions/god/flags.lua +++ b/data/scripts/talkactions/god/flags.lua @@ -39,6 +39,7 @@ local PlayerFlags_t = { ["IsAlwaysPremium"] = IsAlwaysPremium, ["CanMapClickTeleport"] = CanMapClickTeleport, ["IgnoredByNpcs"] = IgnoredByNpcs, + ["IsGameTester"] = IsGameTester, } local function sendValidKeys(player) diff --git a/markdowns/CHANGELOG.md b/markdowns/CHANGELOG.md index 246d2349..8802e2f1 100644 --- a/markdowns/CHANGELOG.md +++ b/markdowns/CHANGELOG.md @@ -13,7 +13,7 @@ - Moved emote spells to `kv` instead of `storage`. ([Tryller](https://github.com/jprzimba)) - Updated npcs and spells from 13.40 updates. ([murilo09](https://github.com/murilo09)) - Added a Rook system with configurations in `config.lua`. ([Tryller](https://github.com/jprzimba)) -- Added a Test Mode with configurations in `config.lua`. ([Tryller](https://github.com/jprzimba)) +- Added a new group `game tester` with flag `isgametester` in `groups.xml` and a new player flag `PlayerFlag_IsGameTester`. ([Tryller](https://github.com/jprzimba)) ## Added files @@ -29,6 +29,7 @@ - config.lua - data/items/assets.dat - data/items/items.xml +- data/libs/functions/boss_lever.lua - data/libs/systems/features.lua - data/scripts/creaturescripts/player/login.lua - data/scripts/movements/special_tiles.lua @@ -39,12 +40,14 @@ - data/scripts/talkactions/god/create_item.lua - data/scripts/talkactions/god/create_summon.lua - data/scripts/talkactions/god/create_npc.lua +- data/scripts/talkactions/god/flags.lua - data/scripts/talkactions/player/chain_system.lua - data/scripts/talkactions/player/emote_spell.lua - data/scripts/spells/attack/annihilation.lua - data/scripts/spells/attack/ultimate_ice_strike.lua - data/scripts/spells/attack/ultimate_terra_strike.lua - data/XML/imbuements.xml +- data/XML/groups.xml - data-global/npc (all npc files) - data-global/npc/the_oracle.lua (modified to rook system) - data-global/world/world.otbm (7z file) diff --git a/src/config/config_enums.hpp b/src/config/config_enums.hpp index 39366e5d..7e9b9397 100644 --- a/src/config/config_enums.hpp +++ b/src/config/config_enums.hpp @@ -353,7 +353,6 @@ enum ConfigKey_t : uint16_t { LOGIN_PROTECTION, SPELL_NAME_INSTEAD_WORDS, LOG_PLAYERS_STATEMENTS, - TOGGLE_TEST_MODE, ROOK_SYSTEM, ROOK_TOWN, LEVEL_TO_ROOK, diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index e7e9a8c8..2ae3e8f2 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -174,7 +174,6 @@ bool ConfigManager::load() { loadBoolConfig(L, BEDS_ONLY_PREMIUM, "bedsOnlyPremium", true); loadBoolConfig(L, SPELL_NAME_INSTEAD_WORDS, "spellNameInsteadOfWords", false); loadBoolConfig(L, LOG_PLAYERS_STATEMENTS, "logPlayersStatements", false); - loadBoolConfig(L, TOGGLE_TEST_MODE, "toggleTestMode", false); loadBoolConfig(L, ROOK_SYSTEM, "toggleRookSystem", false); loadBoolConfig(L, TOGGLE_ADD_ROOK_ITEMS, "toggleAddRookItems", false); diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 80b0c26c..514ecdd3 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -166,6 +166,8 @@ std::string Player::getDescription(int32_t lookDistance) { if (group->access) { s << " You are " << group->name << '.'; + } else if (hasFlag(PlayerFlags_t::IsGameTester)) { + s << " You are a " << group->name << '.'; } else if (vocation->getId() != VOCATION_NONE) { s << " You are " << vocation->getVocDescription() << '.'; } else { @@ -189,6 +191,8 @@ std::string Player::getDescription(int32_t lookDistance) { if (group->access) { s << " " << getSubjectVerb() << " " << group->name << '.'; + } else if (hasFlag(PlayerFlags_t::IsGameTester)) { + s << " " << getSubjectVerb() << " a " << group->name << '.'; } else if (vocation->getId() != VOCATION_NONE) { s << " " << getSubjectVerb() << " " << vocation->getVocDescription() << '.'; } else { @@ -6108,7 +6112,7 @@ bool Player::lastHitIsPlayer(const std::shared_ptr &lastHitCreature) { } void Player::changeHealth(int32_t healthChange, bool sendHealthChange /* = true*/) { - if (g_configManager().getBoolean(TOGGLE_TEST_MODE)) { + if (hasFlag(PlayerFlags_t::IsGameTester)) { return; } @@ -6117,7 +6121,7 @@ void Player::changeHealth(int32_t healthChange, bool sendHealthChange /* = true* } void Player::changeMana(int32_t manaChange) { - if (g_configManager().getBoolean(TOGGLE_TEST_MODE)) { + if (hasFlag(PlayerFlags_t::IsGameTester)) { return; } @@ -6129,7 +6133,7 @@ void Player::changeMana(int32_t manaChange) { } void Player::changeSoul(int32_t soulChange) { - if (g_configManager().getBoolean(TOGGLE_TEST_MODE)) { + if (hasFlag(PlayerFlags_t::IsGameTester)) { return; } diff --git a/src/utils/utils_definitions.hpp b/src/utils/utils_definitions.hpp index f472a7be..2d70dcc4 100644 --- a/src/utils/utils_definitions.hpp +++ b/src/utils/utils_definitions.hpp @@ -689,6 +689,7 @@ enum class PlayerFlags_t : uint8_t { IsAlwaysPremium, CanMapClickTeleport, IgnoredByNpcs, + IsGameTester, // Must always be the last FlagLast From f5c4d921cd6a21cce131dd9431c6917a5fd99af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:21:56 -0300 Subject: [PATCH 04/15] * Fix npc crash --- src/creatures/npcs/npc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index 2d848ada..f9060b00 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -828,13 +828,13 @@ void Npc::removeShopPlayer(uint32_t playerGUID) { } void Npc::closeAllShopWindows() { - for (const auto &playerGUID : shopPlayers | std::views::keys) { - const auto &player = g_game().getPlayerByGUID(playerGUID); + for (auto it = shopPlayers.begin(); it != shopPlayers.end();) { + const auto &player = g_game().getPlayerByGUID(it->first); if (player) { player->closeShopWindow(); } + it = shopPlayers.erase(it); } - shopPlayers.clear(); } void Npc::handlePlayerMove(const std::shared_ptr &player, const Position &newPos) { From 42bc0235246af9648b6a7bcb810fc1d0f1cc3f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:24:55 -0300 Subject: [PATCH 05/15] * Fix rotten bosses wrong looktype --- data-global/monster/bosses/chagorz.lua | 2 +- data-global/monster/bosses/vemiath.lua | 2 +- data-global/monster/quests/rotten_bood/mushroom.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data-global/monster/bosses/chagorz.lua b/data-global/monster/bosses/chagorz.lua index bec5b74e..27e8c158 100644 --- a/data-global/monster/bosses/chagorz.lua +++ b/data-global/monster/bosses/chagorz.lua @@ -4,7 +4,7 @@ local monster = {} monster.description = "Chagorz" monster.experience = 3250000 monster.outfit = { - lookType = 1665, + lookType = 1666, lookHead = 0, lookBody = 0, lookLegs = 0, diff --git a/data-global/monster/bosses/vemiath.lua b/data-global/monster/bosses/vemiath.lua index 97be142a..ba63097f 100644 --- a/data-global/monster/bosses/vemiath.lua +++ b/data-global/monster/bosses/vemiath.lua @@ -4,7 +4,7 @@ local monster = {} monster.description = "Vemiath" monster.experience = 3250000 monster.outfit = { - lookType = 1665, + lookType = 1668, lookHead = 0, lookBody = 0, lookLegs = 0, diff --git a/data-global/monster/quests/rotten_bood/mushroom.lua b/data-global/monster/quests/rotten_bood/mushroom.lua index d5611b8e..26945aba 100644 --- a/data-global/monster/quests/rotten_bood/mushroom.lua +++ b/data-global/monster/quests/rotten_bood/mushroom.lua @@ -4,7 +4,7 @@ local monster = {} monster.description = "a Mushroom" monster.experience = 0 monster.outfit = { - lookType = 1669, --todo get correct lookType + lookType = 1773, lookHead = 0, lookBody = 0, lookLegs = 0, From cef8e10dd7713361285daaad3895d7854d9b5421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:28:01 -0300 Subject: [PATCH 06/15] * Fix item usage under players and doors --- .../scripts/actions/objects/cask_and_kegs.lua | 2 +- src/items/tile.cpp | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/data/scripts/actions/objects/cask_and_kegs.lua b/data/scripts/actions/objects/cask_and_kegs.lua index 1180257e..6eeb4b6f 100644 --- a/data/scripts/actions/objects/cask_and_kegs.lua +++ b/data/scripts/actions/objects/cask_and_kegs.lua @@ -26,7 +26,7 @@ local targetIdList = { local flasks = Action() function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if not target or not target:getItem() then + if not target or not target:isItem() then return false end diff --git a/src/items/tile.cpp b/src/items/tile.cpp index 6c980345..7be7a3ed 100644 --- a/src/items/tile.cpp +++ b/src/items/tile.cpp @@ -1888,11 +1888,25 @@ std::shared_ptr Tile::getUseItem(int32_t index) const { return ground; } - if (const auto &thing = getThing(index)) { - return thing->getItem(); + if (index >= 0 && index < static_cast(items->size())) { + if (const auto &thing = getThing(index)) { + if (auto thingItem = thing->getItem()) { + return thingItem; + } + } } - return nullptr; + if (auto topDownItem = getTopDownItem()) { + return topDownItem; + } + + for (auto it = items->rbegin(), end = items->rend(); it != end; ++it) { + if ((*it)->getDoor()) { + return (*it)->getItem(); + } + } + + return !items->empty() ? *items->begin() : nullptr; } std::shared_ptr Tile::getDoorItem() const { From 0bce574affaf276c6434714eb5b125765bc03c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:31:29 -0300 Subject: [PATCH 07/15] * Fix gha warnings --- src/game/game.cpp | 9 +++++---- src/map/spectators.cpp | 18 +++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 38a2cadb..1b2333dc 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -9058,12 +9058,13 @@ void Game::playerCreateMarketOffer(uint32_t playerId, uint8_t type, uint16_t ite } uint64_t totalPrice = price * amount; - uint64_t totalFee = totalPrice * 0.02; - uint64_t maxFee = std::min(1000000, totalFee); - uint64_t fee = std::max(20, totalFee); + uint64_t totalFee = totalPrice * 0.02; // 2% fee + uint64_t maxFee = std::min(1000000, totalFee); // Max fee is 1kk + uint64_t fee = std::clamp(totalFee, uint64_t(20), maxFee); // Limit between 20 and maxFee if (type == MARKETACTION_SELL) { - if (fee > (player->getBankBalance() + player->getMoney())) { + uint64_t totalPriceWithFee = totalPrice + fee; + if (totalPriceWithFee > (player->getMoney() + player->getBankBalance())) { offerStatus << "Fee is greater than player money"; return; } diff --git a/src/map/spectators.cpp b/src/map/spectators.cpp index e286023b..097272a4 100644 --- a/src/map/spectators.cpp +++ b/src/map/spectators.cpp @@ -67,14 +67,14 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl for (const auto &creature : *list) { const auto &specPos = creature->getPosition(); if ((centerPos.x - specPos.x >= minRangeX - && centerPos.y - specPos.y >= minRangeY - && centerPos.x - specPos.x <= maxRangeX - && centerPos.y - specPos.y <= maxRangeY - && (multifloor || specPos.z == centerPos.z) - && ((onlyPlayers && creature->getPlayer()) - || (onlyMonsters && creature->getMonster()) - || (onlyNpcs && creature->getNpc())) - || (!onlyPlayers && !onlyMonsters && !onlyNpcs))) { + && centerPos.y - specPos.y >= minRangeY + && centerPos.x - specPos.x <= maxRangeX + && centerPos.y - specPos.y <= maxRangeY + && (multifloor || specPos.z == centerPos.z) + && ((onlyPlayers && creature->getPlayer()) + || (onlyMonsters && creature->getMonster()) + || (onlyNpcs && creature->getNpc()))) + || (!onlyPlayers && !onlyMonsters && !onlyNpcs)) { spectators.emplace_back(creature); } } @@ -265,7 +265,7 @@ Spectators Spectators::excludePlayerMaster() const { specs.creatures.reserve(creatures.size()); for (const auto &c : creatures) { - if ((c->getMonster() != nullptr && !c->getMaster() || !c->getMaster()->getPlayer())) { + if ((c->getMonster() != nullptr && !c->getMaster()) || (!c->getMaster() || !c->getMaster()->getPlayer())) { specs.insert(c); } } From 46c8a5a6131edaf3774cc32578ed5edbeacff33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:38:47 -0300 Subject: [PATCH 08/15] * Fix familiars upon death --- data-global/monster/familiars/druid_familiar.lua | 2 +- data-global/monster/familiars/knight_familiar.lua | 2 +- data-global/monster/familiars/paladin_familiar.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data-global/monster/familiars/druid_familiar.lua b/data-global/monster/familiars/druid_familiar.lua index 4e3861b5..2c4f3a55 100644 --- a/data-global/monster/familiars/druid_familiar.lua +++ b/data-global/monster/familiars/druid_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Druid Familiar") +local mType = Game.createMonsterType("Druid familiar") local monster = {} monster.description = "a druid familiar" diff --git a/data-global/monster/familiars/knight_familiar.lua b/data-global/monster/familiars/knight_familiar.lua index ce507c0a..83c61969 100644 --- a/data-global/monster/familiars/knight_familiar.lua +++ b/data-global/monster/familiars/knight_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Knight Familiar") +local mType = Game.createMonsterType("Knight familiar") local monster = {} monster.description = "a knight familiar" diff --git a/data-global/monster/familiars/paladin_familiar.lua b/data-global/monster/familiars/paladin_familiar.lua index 42b4736a..181e96f3 100644 --- a/data-global/monster/familiars/paladin_familiar.lua +++ b/data-global/monster/familiars/paladin_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Paladin Familiar") +local mType = Game.createMonsterType("Paladin familiar") local monster = {} monster.description = "a paladin familiar" From 563021a815053c7b77367440a2e0ed6cf14f370f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:39:57 -0300 Subject: [PATCH 09/15] * Fix familiars upon death --- data-global/monster/familiars/druid_familiar.lua | 2 +- data-global/monster/familiars/knight_familiar.lua | 2 +- data-global/monster/familiars/paladin_familiar.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/data-global/monster/familiars/druid_familiar.lua b/data-global/monster/familiars/druid_familiar.lua index 4e3861b5..2c4f3a55 100644 --- a/data-global/monster/familiars/druid_familiar.lua +++ b/data-global/monster/familiars/druid_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Druid Familiar") +local mType = Game.createMonsterType("Druid familiar") local monster = {} monster.description = "a druid familiar" diff --git a/data-global/monster/familiars/knight_familiar.lua b/data-global/monster/familiars/knight_familiar.lua index ce507c0a..83c61969 100644 --- a/data-global/monster/familiars/knight_familiar.lua +++ b/data-global/monster/familiars/knight_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Knight Familiar") +local mType = Game.createMonsterType("Knight familiar") local monster = {} monster.description = "a knight familiar" diff --git a/data-global/monster/familiars/paladin_familiar.lua b/data-global/monster/familiars/paladin_familiar.lua index 42b4736a..181e96f3 100644 --- a/data-global/monster/familiars/paladin_familiar.lua +++ b/data-global/monster/familiars/paladin_familiar.lua @@ -1,4 +1,4 @@ -local mType = Game.createMonsterType("Paladin Familiar") +local mType = Game.createMonsterType("Paladin familiar") local monster = {} monster.description = "a paladin familiar" From a9571a4f75aad60e1aef3a2e0a6fa8975ecf1e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:42:37 -0300 Subject: [PATCH 10/15] * Fix stoage talkaction --- .../talkactions/god/manage_storage.lua | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/data/scripts/talkactions/god/manage_storage.lua b/data/scripts/talkactions/god/manage_storage.lua index e1973ebd..ec723386 100644 --- a/data/scripts/talkactions/god/manage_storage.lua +++ b/data/scripts/talkactions/god/manage_storage.lua @@ -7,29 +7,30 @@ function Player.getStorageValueTalkaction(self, param) end local split = param:split(",") - if split[2] == nil then - player:sendCancelMessage("Insufficient parameters.") + if not split[2] then + self:sendCancelMessage("Insufficient parameters.") return true end - local target = Player(split[1]) - if target == nil then + local target = Player(split[1]:trim()) + if not target then self:sendCancelMessage("A player with that name is not online.") return true end - split[2] = split[2]:trimSpace() + -- Storage key Validation + local storageKey = tonumber(split[2]) or split[2]:trim() + if not storageKey then + self:sendCancelMessage("Invalid storage key or name.") + return true + end - -- Try to convert the second parameter to a number. If it's not a number, treat it as a storage name - local storageKey = tonumber(split[2]) - if storageKey == nil then - -- Get the key for this storage name - local storageName = tostring(split[2]) - local storageValue = target:getStorageValueByName(storageName) - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageName .. " from player " .. split[1] .. " is: " .. storageValue .. ".") + -- Get the storage key + local storageValue = target:getStorageValue(storageKey) + if storageValue == nil then + self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. split[2] .. " does not exist or is not set for player " .. target:getName() .. ".") else - local storageValue = target:getStorageValue(storageKey) - self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageKey .. " from player " .. split[1] .. " is: " .. storageValue .. ".") + self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. split[2] .. " from player " .. target:getName() .. " is: " .. storageValue .. ".") end return true @@ -44,7 +45,6 @@ end storageGet:separator(" ") storageGet:groupType("gamemaster") storageGet:register() - ---------------- // ---------------- function Player.setStorageValueTalkaction(self, param) -- Sanity check for parameters From 3dfd2dcbdc68acca7210e1951fe0dbd23b4a9823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:44:44 -0300 Subject: [PATCH 11/15] * Fix doWalkBack --- src/creatures/monsters/monster.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 6b3ea8c5..6d520a28 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -1529,6 +1529,11 @@ void Monster::doRandomStep(Direction &nextDirection, bool &result) { } void Monster::doWalkBack(uint32_t &flags, Direction &nextDirection, bool &result) { + if (totalPlayersOnScreen > 0) { + isWalkingBack = false; + return; + } + result = Creature::getNextStep(nextDirection, flags); if (result) { flags |= FLAG_PATHFINDING; From 68f1ce91f7b24ded91df851eed81c52fcdc621cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 08:49:44 -0300 Subject: [PATCH 12/15] * Fix removeTarget crash --- src/creatures/monsters/monster.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index 6d520a28..ea08577e 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -612,7 +612,11 @@ bool Monster::removeTarget(const std::shared_ptr &creature) { totalPlayersOnScreen--; } - targetList.erase(it); + if (auto shared = it->lock()) { + targetList.erase(it); + } else { + return false; + } return true; } From de9b2255d3ad390eec33000803ffa9b44877c85f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 09:28:37 -0300 Subject: [PATCH 13/15] * Fix ranodm mount crash --- src/creatures/players/player.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 80b0c26c..bb0a8409 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -7196,9 +7196,16 @@ uint8_t Player::getRandomMountId() const { } } - const auto playerMountsSize = static_cast(playerMounts.size() - 1); - const auto randomIndex = uniform_random(0, std::max(0, playerMountsSize)); - return playerMounts.at(randomIndex); + if (playerMounts.empty()) { + return 0; + } + + const auto randomIndex = uniform_random(0, static_cast(playerMounts.size() - 1)); + if (randomIndex >= 0 && static_cast(randomIndex) < playerMounts.size()) { + return playerMounts[randomIndex]; + } + + return 0; } bool Player::toggleMount(bool mount) { From 58e55f7d41a385b00b1e4b7863f168afbfdce7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 10:55:15 -0300 Subject: [PATCH 14/15] * Updated github actions --- .github/workflows/analysis-reviewdog-cppcheck.yml | 2 +- .github/workflows/build-docker.yml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analysis-reviewdog-cppcheck.yml b/.github/workflows/analysis-reviewdog-cppcheck.yml index b39f6ee5..bca1d057 100644 --- a/.github/workflows/analysis-reviewdog-cppcheck.yml +++ b/.github/workflows/analysis-reviewdog-cppcheck.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@main - name: Setup reviewdog - uses: reviewdog/action-setup@v1.3.0 + uses: reviewdog/action-setup@v1.0.3 - name: Setup cppcheck run: sudo apt-get update && sudo apt-get install -y cppcheck diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index b91216e6..7dd7b657 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -43,12 +43,12 @@ jobs: uses: gittools/actions/gitversion/execute@v0.9.15 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.7.1 + uses: docker/setup-buildx-action@v2 with: install: true - name: Login to GitHub Container Registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -73,8 +73,6 @@ jobs: tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }} cache-from: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }} - secrets: | - DEBUG=1 - name: Image digest if: ${{ github.event_name == 'push' }} @@ -99,7 +97,7 @@ jobs: uses: gittools/actions/gitversion/execute@v0.9.15 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.7.1 + uses: docker/setup-buildx-action@v2 with: install: true From 85ba005f8c9b29dfe87e87f5dcb794bd7270cf22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo?= Date: Sun, 12 Jan 2025 18:19:45 -0300 Subject: [PATCH 15/15] * not use --- .../workflows/analysis-reviewdog-cppcheck.yml | 38 ------ .github/workflows/analysis-reviewdog.yml | 121 ------------------ 2 files changed, 159 deletions(-) delete mode 100644 .github/workflows/analysis-reviewdog-cppcheck.yml delete mode 100644 .github/workflows/analysis-reviewdog.yml diff --git a/.github/workflows/analysis-reviewdog-cppcheck.yml b/.github/workflows/analysis-reviewdog-cppcheck.yml deleted file mode 100644 index bca1d057..00000000 --- a/.github/workflows/analysis-reviewdog-cppcheck.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Analysis - Review Dog - -on: - pull_request: - paths: - - "src/**" - push: - paths: - - "src/**" - -jobs: - cppcheck: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - if: github.ref != 'refs/heads/main' - uses: fkirc/skip-duplicate-actions@master - with: - concurrent_skipping: "same_content" - cancel_others: true - - - name: Check out code. - uses: actions/checkout@main - - - name: Setup reviewdog - uses: reviewdog/action-setup@v1.0.3 - - - name: Setup cppcheck - run: sudo apt-get update && sudo apt-get install -y cppcheck - - - name: cppcheck - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd "$GITHUB_WORKSPACE" - cppcheck --version - reviewdog -reporter=github-pr-check -runners=cppcheck diff --git a/.github/workflows/analysis-reviewdog.yml b/.github/workflows/analysis-reviewdog.yml deleted file mode 100644 index a7d6edda..00000000 --- a/.github/workflows/analysis-reviewdog.yml +++ /dev/null @@ -1,121 +0,0 @@ ---- -name: Analysis - Review Dog - -on: - pull_request: - -jobs: - luac: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - if: github.ref != 'refs/heads/main' - uses: fkirc/skip-duplicate-actions@master - with: - concurrent_skipping: "same_content" - cancel_others: true - - - name: Check out code. - uses: actions/checkout@main - - - name: Setup reviewdog - uses: reviewdog/action-setup@v1.0.3 - - - name: Setup Lua/Luacheck - run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check - - - name: luac - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd "$GITHUB_WORKSPACE" - luac -v - reviewdog -reporter=github-pr-check -runners=luac - - luacheck: - runs-on: ubuntu-latest - steps: - - name: Check out code. - uses: actions/checkout@main - - - name: Setup reviewdog - uses: reviewdog/action-setup@v1.0.3 - - - name: Setup Lua/Luacheck - run: sudo apt-get update && sudo apt-get install -y libluajit-5.1-dev lua-check - - - name: luacheck - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - luacheck --version - cd "$GITHUB_WORKSPACE" - reviewdog -reporter=github-pr-check -runners=luacheck - - shellcheck: - runs-on: ubuntu-latest - steps: - - name: Check out code. - uses: actions/checkout@main - - - name: shellcheck - uses: reviewdog/action-shellcheck@v1.15.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-pr-check - pattern: "*.sh" - exclude: "./.git/*" - - xmllint: - runs-on: ubuntu-latest - steps: - - name: Check out code. - uses: actions/checkout@main - - - name: Setup reviewdog - uses: reviewdog/action-setup@v1.0.3 - - - name: Setup xmllint - run: sudo apt-get update && sudo apt-get install -y libxml2-utils - - - name: xmllint - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd "$GITHUB_WORKSPACE" - xmllint --version - reviewdog -reporter=github-pr-check -runners=xmllint - - yamllint: - runs-on: ubuntu-latest - steps: - - name: Check out code. - uses: actions/checkout@main - - - name: Run yamllint - uses: reviewdog/action-yamllint@v1.6.1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-pr-check - - hadolint: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@main - - - name: hadolint - uses: reviewdog/action-hadolint@v1.33.0 - with: - reporter: github-pr-check - - actionlint: - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@main - - - name: actionlint - uses: reviewdog/action-actionlint@v1 - with: - reporter: github-pr-check