Skip to content

Commit

Permalink
Make leaving dead ghosts behind optional when staticRadarGhost is dis…
Browse files Browse the repository at this point in the history
…abled.
  • Loading branch information
saurtron committed Jan 9, 2025
1 parent 7197698 commit fcbb300
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rts/Lua/LuaSyncedCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2694,6 +2694,7 @@ int LuaSyncedCtrl::SetUnitSeismicSignature(lua_State* L)
*
* @number unitID
* @bool staticRadarGhost
* @bool[opt] leaveDeadGhost leave a dead ghost behind if disabling and the unit had a live static ghost.
* @treturn nil
*/
int LuaSyncedCtrl::SetUnitStaticRadarGhost(lua_State* L)
Expand All @@ -2706,7 +2707,7 @@ int LuaSyncedCtrl::SetUnitStaticRadarGhost(lua_State* L)
bool prevValue = unit->staticRadarGhost;
unit->SetStaticRadarGhost(luaL_checkboolean(L, 2));
if (prevValue != unit->staticRadarGhost)
unitDrawer->SetUnitStaticRadarGhost(unit);
unitDrawer->SetUnitStaticRadarGhost(unit, luaL_optboolean(L, 3, false));
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Units/UnitDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CUnitDrawer : public CModelDrawerBase<CUnitDrawerData, CUnitDrawer>
static const std::vector<CUnit*>& GetUnsortedUnits() { return modelDrawerData->GetUnsortedObjects(); }

static void ClearPreviousDrawFlags() { modelDrawerData->ClearPreviousDrawFlags(); }
static void SetUnitStaticRadarGhost(const CUnit* unit) { modelDrawerData->SetUnitStaticRadarGhost(unit); }
static void SetUnitStaticRadarGhost(const CUnit* unit, const bool leaveDeadGhost) { modelDrawerData->SetUnitStaticRadarGhost(unit, leaveDeadGhost); }
public:
// DrawUnit*
virtual void DrawUnitNoTrans(const CUnit* unit, uint32_t preList, uint32_t postList, bool lodCall, bool noLuaCall) const = 0;
Expand Down
4 changes: 2 additions & 2 deletions rts/Rendering/Units/UnitDrawerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,12 @@ void CUnitDrawerData::UnitLeftLos(const CUnit* unit, int allyTeam)
UpdateUnitIcon(unit, false, false);
}

void CUnitDrawerData::SetUnitStaticRadarGhost(const CUnit* unit)
void CUnitDrawerData::SetUnitStaticRadarGhost(const CUnit* unit, const bool leaveDeadGhost)
{
if (unit->staticRadarGhost)
return;

if (UpdateUnitGhosts(unit, true))
if (UpdateUnitGhosts(unit, leaveDeadGhost))
UpdateUnitIcon(unit, false, true);
}

Expand Down
2 changes: 1 addition & 1 deletion rts/Rendering/Units/UnitDrawerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CUnitDrawerData : public CUnitDrawerDataBase {

void PlayerChanged(int playerNum) override;
bool UpdateUnitGhosts(const CUnit* unit, const bool addNewGhost);
void SetUnitStaticRadarGhost(const CUnit* unit);
void SetUnitStaticRadarGhost(const CUnit* unit, const bool leaveDeadGhost);
public:
class TempDrawUnit {
CR_DECLARE_STRUCT(TempDrawUnit)
Expand Down

0 comments on commit fcbb300

Please sign in to comment.