Skip to content

Commit

Permalink
Just check gameSetup->ghostedBuildings when setting unit.leavesGhost.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurtron committed Jan 9, 2025
1 parent 0ec0141 commit afd9a07
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions rts/Lua/LuaSyncedCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,9 @@ int LuaSyncedCtrl::SetUnitSeismicSignature(lua_State* L)
*/
int LuaSyncedCtrl::SetUnitLeavesGhost(lua_State* L)
{
if (!gameSetup->ghostedBuildings)
return 0;

CUnit* unit = ParseUnit(L, __func__, 1);

if (unit == nullptr)
Expand Down
6 changes: 3 additions & 3 deletions rts/Rendering/Units/UnitDrawerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const icon::CIconData* CUnitDrawerData::GetUnitIcon(const CUnit* unit)
// use the unit's custom icon if we can currently see it,
// or have seen it before and did not lose contact since
bool unitVisible = ((losStatus & (LOS_INLOS | LOS_INRADAR)) && ((losStatus & prevMask) == prevMask));
unitVisible |= gameSetup->ghostedBuildings && unit->leavesGhost && (losStatus & LOS_PREVLOS);
unitVisible |= unit->leavesGhost && (losStatus & LOS_PREVLOS);
const bool customIcon = (unitVisible || gu->spectatingFullView);

if (customIcon)
Expand Down Expand Up @@ -656,7 +656,7 @@ void CUnitDrawerData::UnitEnteredLos(const CUnit* unit, int allyTeam)
RECOIL_DETAILED_TRACY_ZONE;
CUnit* u = const_cast<CUnit*>(unit); //cleanup

if (gameSetup->ghostedBuildings && unit->leavesGhost)
if (unit->leavesGhost)
spring::VectorErase(savedData.liveGhostBuildings[allyTeam][MDL_TYPE(unit)], u);

if (allyTeam != gu->myAllyTeam)
Expand All @@ -670,7 +670,7 @@ void CUnitDrawerData::UnitLeftLos(const CUnit* unit, int allyTeam)
RECOIL_DETAILED_TRACY_ZONE;
CUnit* u = const_cast<CUnit*>(unit); //cleanup

if (gameSetup->ghostedBuildings && unit->leavesGhost)
if (unit->leavesGhost)
spring::VectorInsertUnique(savedData.liveGhostBuildings[allyTeam][MDL_TYPE(unit)], u, true);

if (allyTeam != gu->myAllyTeam)
Expand Down
4 changes: 2 additions & 2 deletions rts/Sim/Units/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void CUnit::PreInit(const UnitLoadParams& params)
wantCloak |= unitDef->startCloaked;
decloakDistance = unitDef->decloakDistance;

leavesGhost = unitDef->leavesGhost;
leavesGhost = gameSetup->ghostedBuildings && unitDef->leavesGhost;

flankingBonusMode = unitDef->flankingBonusMode;
flankingBonusDir = unitDef->flankingBonusDir;
Expand Down Expand Up @@ -562,7 +562,7 @@ float3 CUnit::GetErrorVector(int argAllyTeam) const
const int atSightMask = losStatus[argAllyTeam];

const int isVisible = 2 * ((atSightMask & LOS_INLOS ) != 0 || teamHandler.Ally(argAllyTeam, allyteam)); // in LOS or allied, no error
const int seenGhost = 4 * ((atSightMask & LOS_PREVLOS) != 0 && gameSetup->ghostedBuildings && leavesGhost); // seen ghosted immobiles, no error
const int seenGhost = 4 * ((atSightMask & LOS_PREVLOS) != 0 && leavesGhost); // seen ghosted immobiles, no error
const int isOnRadar = 8 * ((atSightMask & LOS_INRADAR) != 0 ); // current radar contact

float errorMult = 0.0f;
Expand Down

0 comments on commit afd9a07

Please sign in to comment.