Skip to content

Commit

Permalink
Merge branch 'main' into game-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 12, 2025
2 parents 46c8a5a + 58e55f7 commit 7fbd123
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analysis-reviewdog-cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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' }}
Expand All @@ -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

Expand Down
30 changes: 15 additions & 15 deletions data/scripts/talkactions/god/manage_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,7 +45,6 @@ end
storageGet:separator(" ")
storageGet:groupType("gamemaster")
storageGet:register()

---------------- // ----------------
function Player.setStorageValueTalkaction(self, param)
-- Sanity check for parameters
Expand Down
11 changes: 10 additions & 1 deletion src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,11 @@ bool Monster::removeTarget(const std::shared_ptr<Creature> &creature) {
totalPlayersOnScreen--;
}

targetList.erase(it);
if (auto shared = it->lock()) {
targetList.erase(it);
} else {
return false;
}

return true;
}
Expand Down Expand Up @@ -1529,6 +1533,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;
Expand Down
13 changes: 10 additions & 3 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7200,9 +7200,16 @@ uint8_t Player::getRandomMountId() const {
}
}

const auto playerMountsSize = static_cast<int32_t>(playerMounts.size() - 1);
const auto randomIndex = uniform_random(0, std::max<int32_t>(0, playerMountsSize));
return playerMounts.at(randomIndex);
if (playerMounts.empty()) {
return 0;
}

const auto randomIndex = uniform_random(0, static_cast<int32_t>(playerMounts.size() - 1));
if (randomIndex >= 0 && static_cast<size_t>(randomIndex) < playerMounts.size()) {
return playerMounts[randomIndex];
}

return 0;
}

bool Player::toggleMount(bool mount) {
Expand Down

0 comments on commit 7fbd123

Please sign in to comment.