Skip to content

Commit

Permalink
Unit def build speed now defined per second
Browse files Browse the repository at this point in the history
Previously was defined per team slowupdate, which happens every second.
This means there is no behaviour difference, but it now works correctly
if somebody tweaks game speed or team slowupdate rate.
  • Loading branch information
sprunk authored and lhog committed Feb 24, 2024
1 parent da75c7e commit cd8a245
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rts/Lua/LuaSyncedCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,7 @@ int LuaSyncedCtrl::SetUnitBuildSpeed(lua_State* L)
if (unit == nullptr)
return 0;

const float buildScale = (1.0f / TEAM_SLOWUPDATE_RATE);
constexpr float buildScale = (1.0f / GAME_SPEED);
const float buildSpeed = buildScale * max(0.0f, luaL_checkfloat(L, 2));

CFactory* factory = dynamic_cast<CFactory*>(unit);
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/UnitTypes/Builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void CBuilder::PreInit(const UnitLoadParams& params)
range3D = unitDef->buildRange3D;
buildDistance = (params.unitDef)->buildDistance;

const float scale = (1.0f / TEAM_SLOWUPDATE_RATE);
constexpr float scale = (1.0f / GAME_SPEED);

buildSpeed = scale * unitDef->buildSpeed;
repairSpeed = scale * unitDef->repairSpeed;
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/UnitTypes/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void CFactory::KillUnit(CUnit* attacker, bool selfDestruct, bool reclaimed)
void CFactory::PreInit(const UnitLoadParams& params)
{
unitDef = params.unitDef;
buildSpeed = unitDef->buildSpeed / TEAM_SLOWUPDATE_RATE;
buildSpeed = unitDef->buildSpeed / GAME_SPEED;

CBuilding::PreInit(params);

Expand Down

0 comments on commit cd8a245

Please sign in to comment.