Skip to content

Commit 4559d15

Browse files
authored
Merge pull request #4045 from Goober5000/fix_popup_time
fix time resuming when popups are closed
2 parents 58ac0df + 1e06711 commit 4559d15

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

code/popup/popup.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ static popup_info Popup_info;
129129
static int Popup_flags;
130130
static int Popup_screen_id = -1;
131131

132+
static bool Popup_time_was_stopped_in_init = false;
133+
132134
static int Title_coords[GR_NUM_RESOLUTIONS][5] =
133135
{
134136
{ // GR_640
@@ -477,8 +479,12 @@ int popup_init(popup_info *pi, int flags)
477479
}
478480

479481
// anytime in single player, and multiplayer, not in mission, go ahead and stop time
482+
Popup_time_was_stopped_in_init = false;
480483
if ( (Game_mode & GM_NORMAL) || ((Game_mode & GM_MULTIPLAYER) && !(Game_mode & GM_IN_MISSION)) ){
481-
game_stop_time();
484+
if (!game_time_is_stopped()) {
485+
game_stop_time();
486+
Popup_time_was_stopped_in_init = true;
487+
}
482488
}
483489

484490
// create base window
@@ -578,8 +584,8 @@ void popup_close(popup_info *pi, int screen_id)
578584
Popup_is_active = 0;
579585
Popup_running_state = 0;
580586

581-
// anytime in single player, and multiplayer, not in mission, go ahead and resume time
582-
if ( (Game_mode & GM_NORMAL) || ((Game_mode & GM_MULTIPLAYER) && !(Game_mode & GM_IN_MISSION)) )
587+
// if we had previously stopped time, go ahead and resume time
588+
if ( Popup_time_was_stopped_in_init )
583589
game_start_time();
584590
}
585591

fred2/fredstubs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ int Test_begin;
183183
int Debug_octant;
184184
int Framerate_delay;
185185
void game_start_time(bool){}
186+
bool game_time_is_stopped(){return false;}
186187
void game_stop_time(bool){}
187188
int game_get_default_skill_level(){return 0;}
188189
int find_freespace_cd(char*){return 0;}

freespace2/freespace.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,6 +4177,11 @@ void game_stop_time(bool by_os_focus)
41774177
timestamp_pause(!by_os_focus);
41784178
}
41794179

4180+
bool game_time_is_stopped()
4181+
{
4182+
return Time_paused;
4183+
}
4184+
41804185
void game_start_time(bool by_os_focus)
41814186
{
41824187
if (Time_paused) {

freespace2/freespace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ void game_level_close();
9797
// stop the game (mission) timer
9898
void game_stop_time(bool by_os_focus = false);
9999

100+
bool game_time_is_stopped();
101+
100102
// start the game (mission) timer
101103
void game_start_time(bool by_os_focus = false);
102104

qtfred/src/fredstubs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ int Test_begin;
187187
int Debug_octant;
188188
int Framerate_delay;
189189
void game_start_time(bool){}
190+
bool game_time_is_stopped(){return false;}
190191
void game_stop_time(bool){}
191192
int game_get_default_skill_level(){return 0;}
192193
int find_freespace_cd(char*){return 0;}

test/src/test_stubs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ int Test_begin;
191191
int Debug_octant;
192192
int Framerate_delay;
193193
void game_start_time(bool){}
194+
bool game_time_is_stopped(){return false;}
194195
void game_stop_time(bool){}
195196
int game_get_default_skill_level(){return 0;}
196197
int find_freespace_cd(char*){return 0;}

0 commit comments

Comments
 (0)