Skip to content

Commit 8cb1333

Browse files
committed
refactor: Consolidate duplicate duration logic
1 parent afb1459 commit 8cb1333

File tree

2 files changed

+16
-34
lines changed
  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus
  • Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus

2 files changed

+16
-34
lines changed

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,17 @@ void PopulateReplayFileListbox(GameWindow *listbox)
274274

275275
// extra
276276
UnicodeString extraStr;
277+
278+
time_t totalSeconds = header.endTime - header.startTime;
279+
Int hours = totalSeconds / 3600;
280+
Int mins = (totalSeconds % 3600) / 60;
281+
Int secs = totalSeconds % 60;
282+
Real fps = header.frameCount / totalSeconds;
283+
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
284+
277285
if (header.localPlayerIndex >= 0)
278286
{
279287
// MP game
280-
time_t totalSeconds = header.endTime - header.startTime;
281-
Int hours = totalSeconds / 3600;
282-
Int mins = (totalSeconds % 3600) / 60;
283-
Int secs = totalSeconds % 60;
284-
Real fps = header.frameCount / totalSeconds;
285-
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
286-
287288
for (Int i=0; i<MAX_SLOTS; ++i)
288289
{
289290
const GameSlot *slot = info.getConstSlot(i);
@@ -294,16 +295,6 @@ void PopulateReplayFileListbox(GameWindow *listbox)
294295
}
295296
}
296297
}
297-
else
298-
{
299-
// solo game
300-
time_t totalSeconds = header.endTime - header.startTime;
301-
Int hours = totalSeconds / 3600;
302-
Int mins = (totalSeconds % 3600) / 60;
303-
Int secs = totalSeconds % 60;
304-
Real fps = header.frameCount / totalSeconds;
305-
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
306-
}
307298

308299
ReplayInfoCacheEntry entry;
309300
entry.header = header;

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,17 @@ void PopulateReplayFileListbox(GameWindow *listbox)
274274

275275
// extra
276276
UnicodeString extraStr;
277+
278+
time_t totalSeconds = header.endTime - header.startTime;
279+
Int hours = totalSeconds / 3600;
280+
Int mins = (totalSeconds % 3600) / 60;
281+
Int secs = totalSeconds % 60;
282+
Real fps = header.frameCount / totalSeconds;
283+
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
284+
277285
if (header.localPlayerIndex >= 0)
278286
{
279287
// MP game
280-
time_t totalSeconds = header.endTime - header.startTime;
281-
Int hours = totalSeconds / 3600;
282-
Int mins = (totalSeconds % 3600) / 60;
283-
Int secs = totalSeconds % 60;
284-
Real fps = header.frameCount / totalSeconds;
285-
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
286-
287288
for (Int i=0; i<MAX_SLOTS; ++i)
288289
{
289290
const GameSlot *slot = info.getConstSlot(i);
@@ -294,16 +295,6 @@ void PopulateReplayFileListbox(GameWindow *listbox)
294295
}
295296
}
296297
}
297-
else
298-
{
299-
// solo game
300-
time_t totalSeconds = header.endTime - header.startTime;
301-
Int hours = totalSeconds / 3600;
302-
Int mins = (totalSeconds % 3600) / 60;
303-
Int secs = totalSeconds % 60;
304-
Real fps = header.frameCount / totalSeconds;
305-
extraStr.format(L"%02d:%02d:%02d (%g fps)", hours, mins, secs, fps);
306-
}
307298

308299
ReplayInfoCacheEntry entry;
309300
entry.header = header;

0 commit comments

Comments
 (0)