Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 7e63249

Browse files
committed
Move FlashWhite from Actor to MOSRotating
1 parent 9a26402 commit 7e63249

File tree

8 files changed

+17
-59
lines changed

8 files changed

+17
-59
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ This can be accessed via the new Lua (R/W) `SettingsMan` property `AIUpdateInter
859859

860860
- Changed `LuaMan:FileOpen` access modes so it only allows `"r", "r+", "w", "w+", "a", "a+"`, i.e. specifying type (text, binary) is not supported. See [this reference page](https://cplusplus.com/reference/cstdio/fopen) for details on the access modes.
861861

862+
- Moved `FlashWhite` function from `Actor` to `MOSRotating`.
863+
862864
</details>
863865

864866
<details><summary><b>Fixed</b></summary>

Entities/AHuman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4048,7 +4048,7 @@ void AHuman::DrawThrowingReticle(BITMAP *targetBitmap, const Vector &targetPos,
40484048
void AHuman::Draw(BITMAP *pTargetBitmap, const Vector &targetPos, DrawMode mode, bool onlyPhysical) const {
40494049
Actor::Draw(pTargetBitmap, targetPos, mode, onlyPhysical);
40504050

4051-
DrawMode realMode = (mode == g_DrawColor && m_FlashWhiteMS) ? g_DrawWhite : mode;
4051+
DrawMode realMode = (mode == g_DrawColor && !m_FlashWhiteTimer.IsPastRealTimeLimit()) ? g_DrawWhite : mode;
40524052
// Note: For some reason the ordering of the attachables list can get messed up. The most important thing here is that the FGArm is on top of everything else.
40534053
if (m_pHead && m_pHead->IsDrawnAfterParent()) { m_pHead->Draw(pTargetBitmap, targetPos, realMode, onlyPhysical); }
40544054
if (m_pFGArm) { m_pFGArm->Draw(pTargetBitmap, targetPos, realMode, onlyPhysical); }

Entities/Actor.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ void Actor::Clear() {
109109
m_MaxInventoryMass = -1.0F;
110110
m_pItemInReach = nullptr;
111111
m_HUDStack = 0;
112-
m_FlashWhiteMS = 0;
113-
m_WhiteFlashTimer.Reset();
114112
m_DeploymentID = 0;
115113
m_PassengerSlots = 1;
116114

@@ -1588,15 +1586,6 @@ void Actor::Update()
15881586
g_MovableMan.SortTeamRoster(m_Team);
15891587
}
15901588

1591-
// Reduce the remaining white flash time
1592-
if (m_FlashWhiteMS)
1593-
{
1594-
m_FlashWhiteMS -= m_WhiteFlashTimer.GetElapsedRealTimeMS();
1595-
m_WhiteFlashTimer.Reset();
1596-
if (m_FlashWhiteMS < 0)
1597-
m_FlashWhiteMS = 0;
1598-
}
1599-
16001589
int brainOfPlayer = g_ActivityMan.GetActivity()->IsBrainOfWhichPlayer(this);
16011590
if (brainOfPlayer != Players::NoPlayer && g_ActivityMan.GetActivity()->PlayerHuman(brainOfPlayer)) {
16021591
if (m_PrevHealth - m_Health > 1.5F) {
@@ -1631,22 +1620,6 @@ void Actor::Update()
16311620
}
16321621

16331622

1634-
//////////////////////////////////////////////////////////////////////////////////////////
1635-
// Virtual method: Draw
1636-
//////////////////////////////////////////////////////////////////////////////////////////
1637-
// Description: Draws this Actor's current graphical representation to a
1638-
// BITMAP of choice.
1639-
1640-
void Actor::Draw(BITMAP *pTargetBitmap,
1641-
const Vector &targetPos,
1642-
DrawMode mode,
1643-
bool onlyPhysical) const
1644-
{
1645-
// Make it draw white if is going to be drawn as color
1646-
MOSRotating::Draw(pTargetBitmap, targetPos, mode == g_DrawColor && m_FlashWhiteMS ? g_DrawWhite : mode, onlyPhysical);
1647-
}
1648-
1649-
16501623
//////////////////////////////////////////////////////////////////////////////////////////
16511624
// Virtual method: DrawHUD
16521625
//////////////////////////////////////////////////////////////////////////////////////////

Entities/Actor.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,17 +1003,6 @@ ClassInfoGetters;
10031003
void SetAimRange(float range) { m_AimRange = range; }
10041004

10051005

1006-
//////////////////////////////////////////////////////////////////////////////////////////
1007-
// Method: FlashWhite
1008-
//////////////////////////////////////////////////////////////////////////////////////////
1009-
// Description: Tells to make this and all children get drawn as completely white, but
1010-
// only for a specified amount of time.
1011-
// Arguments: For how long to flash the whiteness, in MS.
1012-
// Return value: None.
1013-
1014-
void FlashWhite(int howLongMS = 32) { m_FlashWhiteMS = howLongMS; m_WhiteFlashTimer.Reset(); }
1015-
1016-
10171006
//////////////////////////////////////////////////////////////////////////////////////////
10181007
// Method: DrawWaypoints
10191008
//////////////////////////////////////////////////////////////////////////////////////////
@@ -1212,20 +1201,6 @@ ClassInfoGetters;
12121201

12131202
void SetSightDistance(float newValue) { m_SightDistance = newValue; }
12141203

1215-
//////////////////////////////////////////////////////////////////////////////////////////
1216-
// Virtual method: Draw
1217-
//////////////////////////////////////////////////////////////////////////////////////////
1218-
// Description: Draws this Actor's current graphical representation to a
1219-
// BITMAP of choice.
1220-
// Arguments: A pointer to a BITMAP to draw on.
1221-
// The absolute position of the target bitmap's upper left corner in the Scene.
1222-
// In which mode to draw in. See the DrawMode enumeration for the modes.
1223-
// Whether to not draw any extra 'ghost' items of this MovableObject,
1224-
// indicator arrows or hovering HUD text and so on.
1225-
// Return value: None.
1226-
1227-
void Draw(BITMAP *pTargetBitmap, const Vector &targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override;
1228-
12291204

12301205
//////////////////////////////////////////////////////////////////////////////////////////
12311206
// Virtual method: DrawHUD
@@ -1524,10 +1499,6 @@ ClassInfoGetters;
15241499
HeldDevice *m_pItemInReach;
15251500
// HUD positioning aid
15261501
int m_HUDStack;
1527-
// For how much longer to draw this as white. 0 means don't draw as white
1528-
int m_FlashWhiteMS;
1529-
// The timer that measures and deducts past time from the remaining white flash time
1530-
Timer m_WhiteFlashTimer;
15311502
// ID of deployment which spawned this actor
15321503
unsigned int m_DeploymentID;
15331504
// How many passenger slots this actor will take in a craft

Entities/MOSRotating.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ void MOSRotating::Clear()
8989
m_LoudnessOnGib = 1;
9090
m_DamageMultiplier = 0;
9191
m_NoSetDamageMultiplier = true;
92+
m_FlashWhiteTimer.Reset();
93+
m_FlashWhiteTimer.SetRealTimeLimitMS(0);
9294
m_StringValueMap.clear();
9395
m_NumberValueMap.clear();
9496
m_ObjectValueMap.clear();
@@ -1822,6 +1824,8 @@ void MOSRotating::Draw(BITMAP *pTargetBitmap, const Vector &targetPos, DrawMode
18221824
return;
18231825
}
18241826

1827+
if (mode == g_DrawColor && !m_FlashWhiteTimer.IsPastRealTimeLimit()) { mode = g_DrawWhite; }
1828+
18251829
// Draw all the attached wound emitters, and only if the mode is g_DrawColor and not onlyphysical
18261830
// Only draw attachables and emitters which are not drawn after parent, so we draw them before
18271831
if (mode == g_DrawColor || (!onlyPhysical && mode == g_DrawMaterial)) {

Entities/MOSRotating.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,12 @@ ClassInfoGetters;
900900
/// <param name="newValue">New scalar value.</param>
901901
void SetOrientToVel(float newValue) { m_OrientToVel = newValue; }
902902

903+
/// <summary>
904+
/// Sets this MOSRotating and all its children to drawn white for a specified amount of time.
905+
/// </summary>
906+
/// <param name="durationMS">Duration of flash in real time MS.</param>
907+
void FlashWhite(int durationMS = 32) { m_FlashWhiteTimer.SetRealTimeLimitMS(durationMS); m_FlashWhiteTimer.Reset(); }
908+
903909

904910
//////////////////////////////////////////////////////////////////////////////////////////
905911
// Method: GetTravelImpulse
@@ -1046,6 +1052,8 @@ ClassInfoGetters;
10461052
float m_DamageMultiplier; //!< Damage multiplier for this MOSRotating.
10471053
bool m_NoSetDamageMultiplier; //!< Whether or not the damage multiplier for this MOSRotating was set.
10481054

1055+
Timer m_FlashWhiteTimer; //!< The timer for timing white draw mode duration.
1056+
10491057
// Intermediary drawing bitmap used to flip rotating bitmaps. Owned!
10501058
BITMAP *m_pFlipBitmap;
10511059
BITMAP *m_pFlipBitmapS;

Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ namespace RTE {
287287
.def("DropAllInventory", &Actor::DropAllInventory)
288288
.def("DropAllGold", &Actor::DropAllGold)
289289
.def("IsInventoryEmpty", &Actor::IsInventoryEmpty)
290-
.def("FlashWhite", &Actor::FlashWhite)
291290
.def("DrawWaypoints", &Actor::DrawWaypoints)
292291
.def("SetMovePathToUpdate", &Actor::SetMovePathToUpdate)
293292
.def("UpdateMovePath", &Actor::UpdateMovePath)
@@ -926,6 +925,7 @@ namespace RTE {
926925
.def("ForceDeepCheck", &MOSRotating::ForceDeepCheck)
927926
.def("GibThis", &MOSRotating::GibThis)
928927
.def("MoveOutOfTerrain", &MOSRotating::MoveOutOfTerrain)
928+
.def("FlashWhite", &MOSRotating::FlashWhite)
929929
.def("GetGibWoundLimit", (int (MOSRotating:: *)() const) &MOSRotating::GetGibWoundLimit)
930930
.def("GetGibWoundLimit", (int (MOSRotating:: *)(bool positiveDamage, bool negativeDamage, bool noDamage) const) &MOSRotating::GetGibWoundLimit)
931931
.def("GetWoundCount", (int (MOSRotating:: *)() const) &MOSRotating::GetWoundCount)

System/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace RTE {
169169
/// Returns true if the elapsed real time is past a certain amount of time after the start previously set by SetRealTimeLimit.
170170
/// </summary>
171171
/// <returns>A bool only yielding true if the elapsed real time is greater than the set limit value. If no limit has been set, this returns false.</returns>
172-
bool IsPastRealTimeLimit() { return (m_RealTimeLimit == 0) ? true : (m_RealTimeLimit > 0 && (g_TimerMan.GetRealTickCount() - m_StartRealTime) > m_RealTimeLimit); }
172+
bool IsPastRealTimeLimit() const { return (m_RealTimeLimit == 0) ? true : (m_RealTimeLimit > 0 && (g_TimerMan.GetRealTickCount() - m_StartRealTime) > m_RealTimeLimit); }
173173

174174
/// <summary>
175175
/// Returns how much progress has been made toward the set time limit previously set by SetRealTimeLimitMS.

0 commit comments

Comments
 (0)