Skip to content

Commit

Permalink
Merge branch 'main' into feature/support_dat_items
Browse files Browse the repository at this point in the history
  • Loading branch information
MUN1Z authored Dec 6, 2024
2 parents 79943b6 + b54a712 commit 25bd795
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ jobs:
with:
install: true

- name: Cache Docker layers
uses: actions/cache@main
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-x86-${{ github.sha }}
restore-keys: |
${{ runner.os }}-x86-
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down Expand Up @@ -109,14 +101,6 @@ jobs:
with:
install: true

- name: Cache Docker layers
uses: actions/cache@main
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-arm-${{ github.sha }}
restore-keys: |
${{ runner.os }}-arm-
- name: Build
uses: docker/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions data-otservbr-global/scripts/lib/monster_functions.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function Monster:handleCobraOnSpawn()
if Game.getStorageValue(Global.Storage.CobraFlask) >= os.time() then
monster:setHealth(monster:getMaxHealth() * 0.75)
monster:getPosition():sendMagicEffect(CONST_ME_GREEN_RINGS)
self:setHealth(self:getMaxHealth() * 0.75)
self:getPosition():sendMagicEffect(CONST_ME_GREEN_RINGS)
else
Game.setStorageValue(Global.Storage.CobraFlask, -1)
end
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.arm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Download all dependencies
FROM ubuntu:23.04 AS dependencies
FROM ubuntu:24.04 AS dependencies

RUN apt-get update && apt-get install -y --no-install-recommends cmake git \
unzip build-essential ca-certificates curl zip unzip tar \
Expand Down Expand Up @@ -30,7 +30,7 @@ WORKDIR /srv
RUN export VCPKG_ROOT=/opt/vcpkg/ && VCPKG_FORCE_SYSTEM_BINARIES=1 cmake --preset linux-release && cmake --build --preset linux-release

# Stage 3: load data and execute
FROM ubuntu:23.04
FROM ubuntu:24.04

VOLUME [ "/data" ]

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.x86
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Download all dependencies
FROM ubuntu:23.04 AS dependencies
FROM ubuntu:24.04 AS dependencies

RUN apt-get update && apt-get install -y --no-install-recommends cmake git \
unzip build-essential ca-certificates curl zip unzip tar \
Expand Down Expand Up @@ -30,7 +30,7 @@ WORKDIR /srv
RUN export VCPKG_ROOT=/opt/vcpkg/ && cmake --preset linux-release && cmake --build --preset linux-release

# Stage 3: load data and execute
FROM ubuntu:23.04
FROM ubuntu:24.04
VOLUME [ "/data" ]

COPY --from=build /srv/build/linux-release/bin/canary /bin/canary
Expand Down
30 changes: 16 additions & 14 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

#include <appearances.pb.h>

std::vector<std::shared_ptr<Creature>> checkCreatureLists[EVENT_CREATURECOUNT];
std::vector<std::weak_ptr<Creature>> checkCreatureLists[EVENT_CREATURECOUNT];

namespace InternalGame {
void sendBlockEffect(BlockType_t blockType, CombatType_t combatType, const Position &targetPos, const std::shared_ptr<Creature> &source) {
Expand Down Expand Up @@ -6466,16 +6466,15 @@ void Game::addCreatureCheck(const std::shared_ptr<Creature> &creature) {

creature->creatureCheck.store(true);

if (creature->inCheckCreaturesVector.load()) {
if (creature->inCheckCreaturesVector.exchange(true)) {
// already in a vector
return;
}

creature->inCheckCreaturesVector.store(true);

creature->safeCall([this, creature] {
checkCreatureLists[uniform_random(0, EVENT_CREATURECOUNT - 1)].emplace_back(creature);
});
g_dispatcher().addEvent([this, index = uniform_random(0, EVENT_CREATURECOUNT - 1), creature] {
checkCreatureLists[index].emplace_back(creature);
},
"Game::addCreatureCheck");
}

void Game::removeCreatureCheck(const std::shared_ptr<Creature> &creature) {
Expand All @@ -6489,15 +6488,18 @@ void Game::checkCreatures() {
metrics::method_latency measure(__METRICS_METHOD_NAME__);
static size_t index = 0;

std::erase_if(checkCreatureLists[index], [this](const std::shared_ptr<Creature> creature) {
if (creature->creatureCheck && creature->isAlive()) {
creature->onThink(EVENT_CREATURE_THINK_INTERVAL);
creature->onAttacking(EVENT_CREATURE_THINK_INTERVAL);
creature->executeConditions(EVENT_CREATURE_THINK_INTERVAL);
return false;
std::erase_if(checkCreatureLists[index], [this](const std::weak_ptr<Creature> &weak) {
if (const auto creature = weak.lock()) {
if (creature->creatureCheck && creature->isAlive()) {
creature->onThink(EVENT_CREATURE_THINK_INTERVAL);
creature->onAttacking(EVENT_CREATURE_THINK_INTERVAL);
creature->executeConditions(EVENT_CREATURE_THINK_INTERVAL);
return false;
}

creature->inCheckCreaturesVector = false;
}

creature->inCheckCreaturesVector = false;
return true;
});

Expand Down
1 change: 1 addition & 0 deletions src/game/scheduling/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Task {
"Game::createInfluencedMonsters",
"Game::updateCreatureWalk",
"Game::updateForgeableMonsters",
"Game::addCreatureCheck",
"GlobalEvents::think",
"LuaEnvironment::executeTimerEvent",
"Modules::executeOnRecvbyte",
Expand Down

0 comments on commit 25bd795

Please sign in to comment.