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 1/6] * 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 2/6] * 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 3/6] * 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 4/6] * 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 5/6] * 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 6/6] * 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