From a2d9eb76d448c9db1d76d4eb31c204f8f31e3af3 Mon Sep 17 00:00:00 2001 From: Fx-Doo Date: Tue, 8 Sep 2026 18:06:20 +0200 Subject: [PATCH 1/4] Displace oldPos update to right before we call owner->Move() (#2797) So we successfully update with the f-1 value, not the f value; and OwnerMoved() can be called with the proper p(f) - p(f-1) vector --- rts/Sim/MoveTypes/GroundMoveType.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/rts/Sim/MoveTypes/GroundMoveType.cpp b/rts/Sim/MoveTypes/GroundMoveType.cpp index 8790ce9eb6..c7e97eceef 100644 --- a/rts/Sim/MoveTypes/GroundMoveType.cpp +++ b/rts/Sim/MoveTypes/GroundMoveType.cpp @@ -1622,6 +1622,11 @@ void CGroundMoveType::UpdateSkid() } } + // always update here so that does not make + // extreme jumps when the unit transitions from skidding back + // to non-skidding + oldPos = owner->pos; + // finally update speed.w owner->SetSpeed(spd); // translate before rotate, match terrain normal if not in air @@ -1637,12 +1642,6 @@ void CGroundMoveType::UpdateSkid() } AdjustPosToWaterLine(); - - // always update here so that does not make - // extreme jumps when the unit transitions from skidding back - // to non-skidding - oldPos = owner->pos; - ASSERT_SANE_OWNER_SPEED(spd); ASSERT_SYNCED(owner->midPos); } From 4ad4c28052deade4054a073894d13c1bad86f014 Mon Sep 17 00:00:00 2001 From: sprunk Date: Tue, 8 Sep 2026 18:27:31 +0200 Subject: [PATCH 2/4] Document why UnitResurrected is missing (#2907) Via a dummy function so that people trying to add it in the future are likely to actually stumble upon it. --- rts/Lua/LuaHandle.cpp | 5 +++++ rts/Lua/LuaHandle.h | 1 + 2 files changed, 6 insertions(+) diff --git a/rts/Lua/LuaHandle.cpp b/rts/Lua/LuaHandle.cpp index fcfadffeb0..9e8b12ec14 100644 --- a/rts/Lua/LuaHandle.cpp +++ b/rts/Lua/LuaHandle.cpp @@ -1121,6 +1121,11 @@ void CLuaHandle::UnitFinished(const CUnit* unit) UnitCallIn(cmdStr, unit); } +void CLuaHandle::UnitResurrected([[maybe_unused]] const CUnit* unit) +{ + /* This implementation is intentionally left blank for educational purposes, + * since a gameside implementation is an excellent example of a custom call-in. */ +} /*** Called when a factory finishes construction of a unit. * diff --git a/rts/Lua/LuaHandle.h b/rts/Lua/LuaHandle.h index 97ddf4323c..a3757b7af5 100644 --- a/rts/Lua/LuaHandle.h +++ b/rts/Lua/LuaHandle.h @@ -127,6 +127,7 @@ class CLuaHandle : public CEventClient void UnitCreated(const CUnit* unit, const CUnit* builder) override; void UnitFinished(const CUnit* unit) override; + void UnitResurrected(const CUnit* unit); // fake call-in, doesn't exist in CEventClient void UnitFromFactory(const CUnit* unit, const CUnit* factory, bool userOrders) override; void UnitReverseBuilt(const CUnit* unit) override; void UnitConstructionDecayed(const CUnit* unit, float timeSinceLastBuild, float iterationPeriod, float part) override; From 200cad2cf11e34ac33ecb9eaf80d71c0a0961e51 Mon Sep 17 00:00:00 2001 From: sprunk Date: Tue, 8 Sep 2026 18:49:29 +0200 Subject: [PATCH 3/4] Remove individual resourcing API from CUnit/CTeam (#2878) Obsoleted by resource packs. No logic change, internals only. Co-authored-by: TarnishedKnight --- rts/Sim/Misc/Team.cpp | 57 ------------------------- rts/Sim/Misc/Team.h | 5 --- rts/Sim/Units/Unit.cpp | 96 ------------------------------------------ rts/Sim/Units/Unit.h | 6 --- 4 files changed, 164 deletions(-) diff --git a/rts/Sim/Misc/Team.cpp b/rts/Sim/Misc/Team.cpp index 2486a94ed7..3fdc4ffebc 100644 --- a/rts/Sim/Misc/Team.cpp +++ b/rts/Sim/Misc/Team.cpp @@ -120,63 +120,6 @@ void CTeam::ClampStartPosInStartBox(float3* pos) const pos->z = ipos.y; } - -bool CTeam::UseMetal(float amount) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (res.metal < amount) - return false; - - res.metal -= amount; - resExpense.metal += amount; - return true; -} - -bool CTeam::UseEnergy(float amount) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (res.energy < amount) - return false; - - res.energy -= amount; - resExpense.energy += amount; - return true; -} - - - -void CTeam::AddMetal(float amount, bool useIncomeMultiplier) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (useIncomeMultiplier) - amount *= GetIncomeMultiplier(); - - res.metal += amount; - resIncome.metal += amount; - - if (res.metal <= resStorage.metal) - return; - - resExcessThisFrame.metal += (res.metal - resStorage.metal); - res.metal = resStorage.metal; -} - -void CTeam::AddEnergy(float amount, bool useIncomeMultiplier) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (useIncomeMultiplier) - amount *= GetIncomeMultiplier(); - - res.energy += amount; - resIncome.energy += amount; - - if (res.energy > resStorage.energy) { - resExcessThisFrame.energy += (res.energy - resStorage.energy); - res.energy = resStorage.energy; - } -} - - bool CTeam::HaveResources(const SResourcePack& amount) const { RECOIL_DETAILED_TRACY_ZONE; diff --git a/rts/Sim/Misc/Team.h b/rts/Sim/Misc/Team.h index 3a1c0fad8a..15fd78b2bb 100644 --- a/rts/Sim/Misc/Team.h +++ b/rts/Sim/Misc/Team.h @@ -29,11 +29,6 @@ class CTeam : public TeamBase void AddResources(SResourcePack res, bool useIncomeMultiplier = true); bool UseResources(const SResourcePack& res); - void AddMetal(float amount, bool useIncomeMultiplier = true); - void AddEnergy(float amount, bool useIncomeMultiplier = true); - bool UseEnergy(float amount); - bool UseMetal(float amount); - void GiveEverythingTo(const unsigned toTeam); void Died(bool normalDeath = true); diff --git a/rts/Sim/Units/Unit.cpp b/rts/Sim/Units/Unit.cpp index 44ac4ab71e..8511e6cc3d 100644 --- a/rts/Sim/Units/Unit.cpp +++ b/rts/Sim/Units/Unit.cpp @@ -2135,92 +2135,6 @@ bool CUnit::AllowedReclaim(CUnit* builder) const return true; } - -bool CUnit::UseMetal(float metal) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (metal < 0.0f) { - AddMetal(-metal); - return true; - } - - CTeam* myTeam = teamHandler.Team(team); - myTeam->resPull.metal += metal; - - if (myTeam->UseMetal(metal)) { - resourcesUseI.metal += metal; - return true; - } - - return false; -} - -void CUnit::AddMetal(float metal, bool useIncomeMultiplier) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (metal < 0.0f) { - UseMetal(-metal); - return; - } - - resourcesMakeI.metal += metal; - teamHandler.Team(team)->AddMetal(metal, useIncomeMultiplier); -} - - -bool CUnit::UseEnergy(float energy) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (energy < 0.0f) { - AddEnergy(-energy); - return true; - } - - CTeam* myTeam = teamHandler.Team(team); - myTeam->resPull.energy += energy; - - if (myTeam->UseEnergy(energy)) { - resourcesUseI.energy += energy; - return true; - } - - return false; -} - -void CUnit::AddEnergy(float energy, bool useIncomeMultiplier) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (energy < 0.0f) { - UseEnergy(-energy); - return; - } - resourcesMakeI.energy += energy; - teamHandler.Team(team)->AddEnergy(energy, useIncomeMultiplier); -} - - -bool CUnit::AddHarvestedMetal(float metal) -{ - RECOIL_DETAILED_TRACY_ZONE; - if (harvestStorage.metal <= 0.0f) { - AddMetal(metal, false); - return true; - } - - if (harvested.metal >= harvestStorage.metal) { - eventHandler.UnitHarvestStorageFull(this); - return false; - } - - //FIXME what do with exceeding metal? - harvested.metal = std::min(harvested.metal + metal, harvestStorage.metal); - if (harvested.metal >= harvestStorage.metal) { - eventHandler.UnitHarvestStorageFull(this); - } - return true; -} - - void CUnit::SetStorage(const SResourcePack& newStorage) { RECOIL_DETAILED_TRACY_ZONE; @@ -2240,11 +2154,6 @@ bool CUnit::HaveResources(const SResourcePack& pack) const bool CUnit::UseResources(const SResourcePack& pack) { RECOIL_DETAILED_TRACY_ZONE; - //FIXME - /*if (energy < 0.0f) { - AddEnergy(-energy); - return true; - }*/ CTeam* myTeam = teamHandler.Team(team); myTeam->resPull += pack; @@ -2260,11 +2169,6 @@ bool CUnit::UseResources(const SResourcePack& pack) void CUnit::AddResources(const SResourcePack& pack, bool useIncomeMultiplier) { RECOIL_DETAILED_TRACY_ZONE; - //FIXME - /*if (energy < 0.0f) { - UseEnergy(-energy); - return true; - }*/ resourcesMakeI += pack; teamHandler.Team(team)->AddResources(pack, useIncomeMultiplier); } diff --git a/rts/Sim/Units/Unit.h b/rts/Sim/Units/Unit.h index 81cd737754..24c1d9d7fe 100644 --- a/rts/Sim/Units/Unit.h +++ b/rts/Sim/Units/Unit.h @@ -116,12 +116,6 @@ class CUnit : public CSolidObject bool AllowedReclaim(CUnit* builder) const; - bool UseMetal(float metal); - void AddMetal(float metal, bool useIncomeMultiplier = true); - bool UseEnergy(float energy); - void AddEnergy(float energy, bool useIncomeMultiplier = true); - bool AddHarvestedMetal(float metal); - void SetStorage(const SResourcePack& newstorage); bool HaveResources(const SResourcePack& res) const; bool UseResources(const SResourcePack& res); From 977f612eb72da12939b3413884409bbf4001e348 Mon Sep 17 00:00:00 2001 From: sprunk Date: Tue, 8 Sep 2026 18:58:13 +0200 Subject: [PATCH 4/4] LuaGaia: load from game first (#2973) --- rts/Lua/LuaGaia.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rts/Lua/LuaGaia.cpp b/rts/Lua/LuaGaia.cpp index f9258e45f7..3968d16e36 100644 --- a/rts/Lua/LuaGaia.cpp +++ b/rts/Lua/LuaGaia.cpp @@ -57,7 +57,7 @@ std::string CLuaGaia::GetSyncedFileName() const std::string CLuaGaia::GetInitFileModes() const { - return SPRING_VFS_MAP_BASE; + return SPRING_VFS_MOD SPRING_VFS_MAP_BASE; } int CLuaGaia::GetInitSelectTeam() const