From cb5bebf3ae69f8558a1e9aa68aecdc0cb94b5482 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 1 Nov 2026 04:54:13 +0300 Subject: [PATCH 1/3] fix core:pathfinding with low refresh interval --- res/scripts/components/pathfinding.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/res/scripts/components/pathfinding.lua b/res/scripts/components/pathfinding.lua index 2ae8b3e72..fd5990280 100644 --- a/res/scripts/components/pathfinding.lua +++ b/res/scripts/components/pathfinding.lua @@ -45,6 +45,25 @@ function next_waypoint() return route[#route] end +local function is_passed(waypoint, next_point, pos) + local wx, wz = waypoint[1] + 0.5, waypoint[3] + 0.5 + local dx, dz = pos[1] - wx, pos[3] - wz + if dx * dx + dz * dz > 2.25 then + return false + end + return dx * (next_point[1] + 0.5 - wx) + dz * (next_point[3] + 0.5 - wz) > 0 +end + +local function drop_passed_waypoints(new_route) + table.remove(new_route, #new_route) + local pos = tsf:get_pos() + while #new_route >= 2 and + is_passed(new_route[#new_route], new_route[#new_route - 1], pos) do + table.remove(new_route, #new_route) + end + return new_route +end + local refresh_internal = 100 local frameid = math.random(0, refresh_internal) @@ -64,7 +83,7 @@ function on_update() else local new_route = pathfinding.pull_route(agent) if new_route then - route = new_route + route = drop_passed_waypoints(new_route) started = false end end From 1bb66ebf1fc0114b92f5cd321a50255fdd5fb68f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:26:03 +0300 Subject: [PATCH 2/3] fix audio streams cleanup --- src/audio/audio.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/audio/audio.cpp b/src/audio/audio.cpp index ee35abeeb..1fa8a1966 100644 --- a/src/audio/audio.cpp +++ b/src/audio/audio.cpp @@ -349,7 +349,8 @@ void remove_lower_priority_speaker(int priority) { for (auto it = speakers.begin(); it != speakers.end();) { if (it->second->getPriority() < priority && it->second->isPaused()) { it->second->stop(); - it = speakers.erase(it); + streams.erase(it->first); + speakers.erase(it); return; } it++; @@ -357,7 +358,8 @@ void remove_lower_priority_speaker(int priority) { for (auto it = speakers.begin(); it != speakers.end();) { if (it->second->getPriority() < priority) { it->second->stop(); - it = speakers.erase(it); + streams.erase(it->first); + speakers.erase(it); return; } it++; @@ -445,6 +447,7 @@ speakerid_t audio::play_stream( int channel ) { std::shared_ptr stream(open_stream(file, false)); + stream->setStopOnEnd(true); return play(stream, position, relative, volume, pitch, loop, channel); } @@ -520,8 +523,8 @@ void audio::update(double delta) { if (speaker->isStopped()) { auto foundStream = streams.find(it->first); if (foundStream == streams.end() || - (!speaker->isManuallyStopped() && - foundStream->second->isStopOnEnd())) { + speaker->isManuallyStopped() || + foundStream->second->isStopOnEnd()) { streams.erase(it->first); it = speakers.erase(it); } else { From 498868a8d5c6c07e4bc6376471b96cbef3b66132 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 3 Nov 2026 22:45:30 +0300 Subject: [PATCH 3/3] cleanup --- src/audio/AL/ALAudio.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/audio/AL/ALAudio.cpp b/src/audio/AL/ALAudio.cpp index c3ec5b24f..1aaeb8f1a 100644 --- a/src/audio/AL/ALAudio.cpp +++ b/src/audio/AL/ALAudio.cpp @@ -275,8 +275,7 @@ void ALStream::update(double delta) { unqueueBuffers(alsource); uint preloaded = enqueueBuffers(alsource); - // alspeaker->stopped is assigned to false at ALSpeaker::play(...) - if (speaker->isStopped() && !alspeaker->manuallyStopped) { //TODO: -V560 false-positive? + if (speaker->isStopped()) { if (preloaded) { speaker->play(); } else if (isStopOnEnd()){