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

Commit 5402d63

Browse files
committed
Review changes
1 parent 014f2d7 commit 5402d63

File tree

5 files changed

+71
-62
lines changed

5 files changed

+71
-62
lines changed

Managers/FrameMan.cpp

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ namespace RTE {
2424
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2525

2626
/// <summary>
27-
/// Callback function for the allegro set_display_switch_callback. It will be called when focus is switched away from the game window.
27+
/// Callback function for the allegro set_display_switch_callback. It will be called when focus is switched away from the game window.
28+
/// It will temporarily disable positioning of the mouse so that when focus is switched back to the game window, the game window won't fly away because the user clicked the title bar of the window.
2829
/// </summary>
2930
void DisplaySwitchOut(void) { g_UInputMan.DisableMouseMoving(true); }
3031

3132
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3233

3334
/// <summary>
34-
/// Callback function for the allegro set_display_switch_callback. It will be called when focus is switched back to the game window. It will temporarily disable positioning of the mouse.
35-
/// This is so that when focus is switched back to the game window, it avoids having the window fly away because the user clicked the title bar of the window.
35+
/// Callback function for the allegro set_display_switch_callback. It will be called when focus is switched back to the game window.
3636
/// </summary>
3737
void DisplaySwitchIn(void) { g_UInputMan.DisableMouseMoving(false); }
3838

@@ -70,22 +70,22 @@ namespace RTE {
7070
m_SmallFont = 0;
7171
m_TextBlinkTimer.Reset();
7272

73-
for (short i = 0; i < c_MaxScreenCount; ++i) {
74-
m_ScreenText[i].clear();
75-
m_TextDuration[i] = -1;
76-
m_TextDurationTimer[i].Reset();
77-
m_TextBlinking[i] = 0;
78-
m_TextCentered[i] = false;
79-
m_FlashScreenColor[i] = -1;
80-
m_FlashedLastFrame[i] = false;
81-
m_FlashTimer[i].Reset();
82-
m_NetworkBitmapIsLocked[i] = false;
83-
84-
for (short f = 0; f < 2; f++) {
85-
m_NetworkBackBufferIntermediate8[f][i] = 0;
86-
m_NetworkBackBufferFinal8[f][i] = 0;
87-
m_NetworkBackBufferIntermediateGUI8[f][i] = 0;
88-
m_NetworkBackBufferFinalGUI8[f][i] = 0;
73+
for (short screenCount = 0; screenCount < c_MaxScreenCount; ++screenCount) {
74+
m_ScreenText[screenCount].clear();
75+
m_TextDuration[screenCount] = -1;
76+
m_TextDurationTimer[screenCount].Reset();
77+
m_TextBlinking[screenCount] = 0;
78+
m_TextCentered[screenCount] = false;
79+
m_FlashScreenColor[screenCount] = -1;
80+
m_FlashedLastFrame[screenCount] = false;
81+
m_FlashTimer[screenCount].Reset();
82+
m_NetworkBitmapIsLocked[screenCount] = false;
83+
84+
for (short bufferFrame = 0; bufferFrame < 2; bufferFrame++) {
85+
m_NetworkBackBufferIntermediate8[bufferFrame][screenCount] = 0;
86+
m_NetworkBackBufferFinal8[bufferFrame][screenCount] = 0;
87+
m_NetworkBackBufferIntermediateGUI8[bufferFrame][screenCount] = 0;
88+
m_NetworkBackBufferFinalGUI8[bufferFrame][screenCount] = 0;
8989
}
9090
}
9191
}
@@ -150,7 +150,6 @@ namespace RTE {
150150

151151
// Set the switching mode; what happens when the app window is switched to and from
152152
set_display_switch_mode(SWITCH_BACKGROUND);
153-
//set_display_switch_mode(SWITCH_PAUSE);
154153
set_display_switch_callback(SWITCH_OUT, DisplaySwitchOut);
155154
set_display_switch_callback(SWITCH_IN, DisplaySwitchIn);
156155

@@ -163,6 +162,14 @@ namespace RTE {
163162
// Set the one Allegro currently uses
164163
color_map = &m_HalfTransTable;
165164

165+
CreateBackBuffers();
166+
167+
return 0;
168+
}
169+
170+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
171+
172+
int FrameMan::CreateBackBuffers() {
166173
// Create the back buffer, this is still in 8bpp, we will do any post-processing on the PostProcessing bitmap
167174
m_BackBuffer8 = create_bitmap_ex(8, m_ResX, m_ResY);
168175
ClearBackBuffer8();
@@ -280,7 +287,6 @@ namespace RTE {
280287
delete m_LargeFont;
281288
delete m_SmallFont;
282289

283-
g_TimerMan.Destroy();
284290
Clear();
285291
}
286292

@@ -340,9 +346,9 @@ namespace RTE {
340346
// Make sure everything gets caught up after the switch
341347
rest(2000);
342348
g_ConsoleMan.PrintString("SYSTEM: Switched to windowed mode");
343-
m_Fullscreen = false;
344-
// Switch to fullscreen
349+
m_Fullscreen = false;
345350
} else {
351+
// Switch to fullscreen
346352
if (set_gfx_mode(fullscreenGfxDriver, resX * m_NxFullscreen, resY * m_NxFullscreen, 0, 0) != 0) {
347353
// Oops, failed to set fullscreen mode, try a different fullscreen scaling
348354
m_NewNxFullscreen = m_NxFullscreen = m_NxFullscreen == 1 ? 2 : 1;
@@ -453,7 +459,6 @@ namespace RTE {
453459
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
454460

455461
void FrameMan::ResetSplitScreens(bool hSplit, bool vSplit) {
456-
// Free the previous splitscreen, if any
457462
if (m_PlayerScreen) { release_bitmap(m_PlayerScreen); }
458463

459464
// Override screen splitting according to settings if needed
@@ -470,16 +475,13 @@ namespace RTE {
470475
clear_to_color(m_PlayerScreen, m_BlackColor);
471476
set_clip_state(m_PlayerScreen, 1);
472477

473-
// Update these to represent the split screens
474478
m_PlayerScreenWidth = m_PlayerScreen->w;
475479
m_PlayerScreenHeight = m_PlayerScreen->h;
476-
477-
// No splits, so set the screen dimensions equal to the back buffer
478480
} else {
481+
// No splits, so set the screen dimensions equal to the back buffer
479482
m_PlayerScreenWidth = m_BackBuffer8->w;
480483
m_PlayerScreenHeight = m_BackBuffer8->h;
481484
}
482-
// Reset the flashes
483485
for (short i = 0; i < c_MaxScreenCount; ++i) {
484486
m_FlashScreenColor[i] = -1;
485487
m_FlashedLastFrame[i] = false;
@@ -588,7 +590,7 @@ namespace RTE {
588590
color_map = &m_HalfTransTable;
589591
break;
590592
default:
591-
RTEAbort("Undefined transparency preset value passed in. See TransparencyPreset enumeration for defined values.")
593+
RTEAbort("Undefined transparency preset value passed in. See TransparencyPreset enumeration for defined values.");
592594
}
593595
}
594596

Managers/FrameMan.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace RTE {
2121

2222
public:
2323

24-
Vector SLOffset[c_MaxScreenCount][c_MaxLayersStoredForNetwork]; //!<
24+
Vector SLOffset[c_MaxScreenCount][c_MaxLayersStoredForNetwork]; //!< SceneLayer offsets for each screen in online multiplayer.
2525

2626
#pragma region Creation
2727
/// <summary>
@@ -276,17 +276,17 @@ namespace RTE {
276276
int GetPlayerScreenHeight() const { return GetPlayerFrameBufferHeight(-1); }
277277

278278
/// <summary>
279-
/// Gets the width of the individual player screens. This will only be less than the backbuffer resolution if there are split screens.
279+
/// Gets the width of the specified player screen. This will only be less than the backbuffer resolution if there are split screens.
280280
/// </summary>
281281
/// <param name="whichPlayer">Player to get screen width for, only used by multiplayer parts.</param>
282-
/// <returns>The width of the player screens.</returns>
282+
/// <returns>The width of the specified player screen.</returns>
283283
int GetPlayerFrameBufferWidth(int whichPlayer) const;
284284

285285
/// <summary>
286-
/// Gets the height of the individual player screens. This will only be less than the backbuffer resolution if there are split screens.
286+
/// Gets the height of the specified player screen. This will only be less than the backbuffer resolution if there are split screens.
287287
/// </summary>
288288
/// <param name="whichPlayer">Player to get screen width for, only used by multiplayer parts.</param>
289-
/// <returns>The height of the player screens.</returns>
289+
/// <returns>The height of the specified player screen.</returns>
290290
int GetPlayerFrameBufferHeight(int whichPlayer) const;
291291
#pragma endregion
292292

@@ -591,14 +591,14 @@ namespace RTE {
591591
int m_NewResY; //!< New display height that will take effect next time the FrameMan is started.
592592

593593
bool m_Fullscreen; //!< Whether in fullscreen mode or not.
594-
int m_NxWindowed; //!< The number of times the windowed mode resolution should be multiplied and stretched across for better visibility.
595594

596595
/// <summary>
597596
/// The number of times the fullscreen mode resolution should be multiplied and stretched across for better visibility.
598597
/// The internal virtual resolution (m_ResX, m_ResY) is 1/n of the actual fullscreen resolution that the graphics card outputs.
599598
/// </summary>
600599
int m_NxFullscreen;
601600
int m_NewNxFullscreen; //!< This is the new fullscreen multiple that will take effect next time the FrameMan is started.
601+
int m_NxWindowed; //!< The number of times the windowed mode resolution should be multiplied and stretched across for better visibility.
602602

603603
bool m_HSplit; //!< Whether the screen is split horizontally across the screen, ie as two splitscreens one above the other.
604604
bool m_VSplit; //!< Whether the screen is split vertically across the screen, ie as two splitscreens side by side.
@@ -660,6 +660,15 @@ namespace RTE {
660660
//std::mutex m_NetworkBitmapIsLocked[c_MaxScreenCount];
661661

662662
private:
663+
664+
#pragma region Create Breakdown
665+
/// <summary>
666+
/// Creates all the frame buffer bitmaps to be used by FrameMan. This is called during Create().
667+
/// </summary>
668+
/// <returns>An error return value signaling success or any particular failure. Anything below 0 is an error signal.</returns>
669+
int CreateBackBuffers();
670+
#pragma endregion
671+
663672
#pragma region Draw Breakdown
664673
/// <summary>
665674
/// Draws all the text messages to the specified player screen. This is called during Draw().

Managers/PerformanceMan.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,6 @@ namespace RTE {
179179
private:
180180

181181
#pragma region Performance Counter Handling
182-
/// <summary>
183-
/// Draws the performance graphs to the screen. This will be called by Draw() if advanced performance stats are enabled.
184-
/// </summary>
185-
void DrawPeformanceGraphs(AllegroBitmap bitmapToDrawTo);
186-
187182
/// <summary>
188183
/// Adds provided value to current sample of specified performance counter.
189184
/// </summary>
@@ -204,6 +199,11 @@ namespace RTE {
204199
unsigned long long GetPerformanceCounterAverage(PerformanceCounters counter);
205200
#pragma endregion
206201

202+
/// <summary>
203+
/// Draws the performance graphs to the screen. This will be called by Draw() if advanced performance stats are enabled.
204+
/// </summary>
205+
void DrawPeformanceGraphs(AllegroBitmap bitmapToDrawTo);
206+
207207
/// <summary>
208208
/// Clears all the member variables of this PerformanceMan, effectively resetting the members of this abstraction level only.
209209
/// </summary>

Managers/PostProcessMan.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ namespace RTE {
8383
int right = left + boxWidth;
8484
int bottom = top + boxHeight;
8585

86-
// Check wrapped rectangles
8786
if (g_SceneMan.SceneWrapsX()) {
8887
int sceneWidth = g_SceneMan.GetScene()->GetWidth();
8988
if (left < 0) { found = GetPostScreenEffects(left + sceneWidth, top, right + sceneWidth, bottom, effectsList, team) || found; }
@@ -370,13 +369,10 @@ namespace RTE {
370369

371370
clear_to_color(pTargetBitmap, 0);
372371

373-
//fixed fAngle;
374-
//fAngle = fixmul(angle, radtofix_r);
372+
Matrix newAngle;
373+
newAngle.SetRadAngle(angle);
375374

376-
Matrix m;
377-
m.SetRadAngle(angle);
378-
379-
rotate_sprite(pTargetBitmap, pBitmap, 0, 0, ftofix(m.GetAllegroAngle()));
375+
rotate_sprite(pTargetBitmap, pBitmap, 0, 0, ftofix(newAngle.GetAllegroAngle()));
380376
draw_trans_sprite(g_FrameMan.GetBackBuffer32(), pTargetBitmap, effectPosX, effectPosY);
381377
}
382378
}

Managers/PostProcessMan.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ namespace RTE {
8888

8989
#pragma region Post Effect Handling
9090
/// <summary>
91-
///
91+
/// Gets the list of effects to apply at the end of each frame.
9292
/// </summary>
93-
/// <returns></returns>
93+
/// <returns>The list of effects to apply at the end of each frame.</returns>
9494
std::list<PostEffect> *GetPostScreenEffectsList() { return &m_PostScreenEffects; }
9595

9696
/// <summary>
@@ -116,18 +116,18 @@ namespace RTE {
116116
bool GetPostScreenEffectsWrapped(const Vector &boxPos, int boxWidth, int boxHeight, std::list<PostEffect> &effectsList, int team = -1);
117117

118118
/// <summary>
119-
///
119+
/// Gets a temporary bitmap of specified size to rotate post effects in.
120120
/// </summary>
121-
/// <param name="bitmapSize"></param>
122-
/// <returns></returns>
121+
/// <param name="bitmapSize">Size of bitmap to get.</param>
122+
/// <returns>Pointer to the temporary bitmap.</returns>
123123
BITMAP* GetTempEffectBitmap(unsigned short bitmapSize) const;
124124
#pragma endregion
125125

126126
#pragma region Post Pixel Glow Handling
127127
/// <summary>
128-
///
128+
/// Gets the list of areas that will be processed with glow.
129129
/// </summary>
130-
/// <returns></returns>
130+
/// <returns>The list of areas that will be processed with glow.</returns>
131131
std::list<Box>* GetPostScreenGlowBoxesList() { return &m_PostScreenGlowBoxes; }
132132

133133
/// <summary>
@@ -137,7 +137,7 @@ namespace RTE {
137137
void RegisterGlowArea(const IntRect &glowArea) { if (g_TimerMan.DrawnSimUpdate() && g_TimerMan.SimUpdatesSinceDrawn() >= 0) { m_GlowAreas.push_back(glowArea); } }
138138

139139
/// <summary>
140-
/// Registers a specific IntRect to be post-processed and have special pixel colors lit up by glow effects in it.
140+
/// Creates an IntRect and registers it to be post-processed and have special pixel colors lit up by glow effects in it.
141141
/// </summary>
142142
/// <param name="center">The center of the IntRect.</param>
143143
/// <param name="radius">The radius around it to add as an area.</param>
@@ -164,17 +164,19 @@ namespace RTE {
164164
#pragma endregion
165165

166166
#pragma region Network Post Effect Handling
167+
// TODO: Figure out.
167168
/// <summary>
168169
///
169170
/// </summary>
170-
/// <param name="whichScreen"></param>
171+
/// <param name="whichScreen">Which player screen to get list for.</param>
171172
/// <param name="outputList"></param>
172173
void GetNetworkPostEffectsList(int whichScreen, std::list<PostEffect> & outputList);
173174

175+
// TODO: Figure out.
174176
/// <summary>
175177
///
176178
/// </summary>
177-
/// <param name="whichScreen"></param>
179+
/// <param name="whichScreen">Which player screen to set list for.</param>
178180
/// <param name="inputList"></param>
179181
void SetNetworkPostEffectsList(int whichScreen, std::list<PostEffect> & inputList);
180182
#pragma endregion
@@ -194,11 +196,11 @@ namespace RTE {
194196
std::list<PostEffect> m_PostScreenEffects; //!< List of effects to apply at the end of each frame. This list gets cleared out and re-filled each frame.
195197
std::list<PostEffect> m_PostSceneEffects; //!< All post-processing effects registered for this draw frame in the scene.
196198

197-
std::list<Box> m_PostScreenGlowBoxes; //!< List of screen-relative areas that will be processed with glow.
199+
std::list<Box> m_PostScreenGlowBoxes; //!< List of areas that will be processed with glow.
198200
std::list<IntRect> m_GlowAreas; //!< All the areas to do post glow pixel effects on, in scene coordinates.
199201

200-
std::list<PostEffect> m_ScreenRelativeEffects[c_MaxScreenCount]; //!<
201-
std::mutex ScreenRelativeEffectsMutex[c_MaxScreenCount]; //!<
202+
std::list<PostEffect> m_ScreenRelativeEffects[c_MaxScreenCount]; //!< List of screen relative effects for each player in online multiplayer.
203+
std::mutex ScreenRelativeEffectsMutex[c_MaxScreenCount]; //!< Mutex for the ScreenRelativeEffects list when accessed by multiple threads in online multiplayer.
202204

203205
BITMAP *m_YellowGlow; //!< Bitmap for the yellow dot glow effect.
204206
BITMAP *m_RedGlow; //!< Bitmap for the red dot glow effect.
@@ -260,12 +262,12 @@ namespace RTE {
260262

261263
#pragma region PostProcess Breakdown
262264
/// <summary>
263-
///
265+
/// Draws all the glow dot effects on pixels registered inside glow boxes for this frame. This is called from PostProcess().
264266
/// </summary>
265267
void DrawDotGlowEffects();
266268

267269
/// <summary>
268-
///
270+
/// Draws all the glow effects registered for this frame. This is called from PostProcess().
269271
/// </summary>
270272
void DrawPostScreenEffects();
271273
#pragma endregion

0 commit comments

Comments
 (0)