Skip to content

Commit 7d1e2ee

Browse files
authored
Fix inconsistent usage of "recursively" option for visibility flags (#56)
* Refactor visibility code * Set recursively to false for SetFlag * Reformat visibility
1 parent 9a48e83 commit 7d1e2ee

File tree

3 files changed

+22
-24
lines changed

3 files changed

+22
-24
lines changed

addons/GME/Scripts/Game/GME/Helpers/GME_VisibilityHelper.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/**
2-
Helper class with staic functions to enable and disable visiblity of units
3-
*/
4-
1+
//------------------------------------------------------------------------------------------------
2+
//! Helper class with staic functions to enable and disable visiblity of units
53
class GME_VisibilityHelper
64
{
5+
//------------------------------------------------------------------------------------------------
76
static void SetVisibility(GenericEntity entity, bool visible)
87
{
98
// casting to possible supported types, if not null we found our match and change visibility and return
@@ -22,9 +21,9 @@ class GME_VisibilityHelper
2221
}
2322
}
2423

24+
//------------------------------------------------------------------------------------------------
2525
static bool GetVisibility(IEntity entity)
2626
{
27-
int visible = entity.GetFlags() & EntityFlags.VISIBLE;
28-
return visible;
27+
return entity.GetFlags() & EntityFlags.VISIBLE;
2928
}
3029
}

addons/GME/Scripts/GameCode/GME/Character/SCR_ChimeraCharacter.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ modded class SCR_ChimeraCharacter : ChimeraCharacter
2929
}
3030

3131
//------------------------------------------------------------------------------------------------
32-
void GME_OnVisibilityValueUpdated()
32+
void GME_SetVisibility(bool visible)
3333
{
34-
if (m_bGME_isVisible)
35-
this.SetFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE, m_bGME_isVisible);
36-
else
37-
this.ClearFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE);
34+
m_bGME_isVisible = visible;
35+
Replication.BumpMe();
36+
GME_OnVisibilityValueUpdated();
3837
}
3938

4039
//------------------------------------------------------------------------------------------------
41-
void GME_SetVisibility(bool visible)
42-
{
43-
m_bGME_isVisible = visible;
44-
Replication.BumpMe();
45-
this.GME_OnVisibilityValueUpdated();
40+
protected void GME_OnVisibilityValueUpdated()
41+
{
42+
if (m_bGME_isVisible)
43+
SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
44+
else
45+
ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
4646
}
4747
}
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
2-
31
//------------------------------------------------------------------------------------------------
42
modded class Vehicle : BaseVehicle
53
{
64
[RplProp(onRplName: "GME_OnVisibilityValueUpdated")]
75
protected bool m_bGME_isVisible = true;
86

7+
//------------------------------------------------------------------------------------------------
98
void GME_SetVisibility(bool visible)
10-
{
9+
{
1110
m_bGME_isVisible = visible;
1211
Replication.BumpMe();
13-
this.GME_OnVisibilityValueUpdated();
12+
GME_OnVisibilityValueUpdated();
1413
}
1514

16-
17-
void GME_OnVisibilityValueUpdated()
15+
//------------------------------------------------------------------------------------------------
16+
protected void GME_OnVisibilityValueUpdated()
1817
{
1918
if (m_bGME_isVisible)
20-
this.SetFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE, m_bGME_isVisible);
19+
SetFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
2120
else
22-
this.ClearFlags(EntityFlags.VISIBLE|EntityFlags.TRACEABLE);
21+
ClearFlags(EntityFlags.VISIBLE | EntityFlags.TRACEABLE);
2322
}
2423
};

0 commit comments

Comments
 (0)