Fix: thread safety issue during exiting the game (#9380)
_exit_game is read by the draw-thread to know when to exit, but
most of the time written by the game-thread.
(cherry picked from commit c12a152ec9
)
This commit is contained in:

committed by
Jonathan G Rennison

parent
573ab48e9c
commit
441ff7e436
@@ -48,7 +48,7 @@ bool _right_button_clicked; ///< Is right mouse button clicked?
|
|||||||
DrawPixelInfo _screen;
|
DrawPixelInfo _screen;
|
||||||
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
bool _screen_disable_anim = false; ///< Disable palette animation (important for 32bpp-anim blitter during giant screenshot)
|
||||||
bool _check_special_modes;
|
bool _check_special_modes;
|
||||||
bool _exit_game;
|
std::atomic<bool> _exit_game;
|
||||||
GameMode _game_mode;
|
GameMode _game_mode;
|
||||||
SwitchMode _switch_mode; ///< The next mainloop command.
|
SwitchMode _switch_mode; ///< The next mainloop command.
|
||||||
PauseMode _pause_mode;
|
PauseMode _pause_mode;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#ifndef OPENTTD_H
|
#ifndef OPENTTD_H
|
||||||
#define OPENTTD_H
|
#define OPENTTD_H
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include "core/enum_type.hpp"
|
#include "core/enum_type.hpp"
|
||||||
|
|
||||||
/** Mode which defines the state of the game. */
|
/** Mode which defines the state of the game. */
|
||||||
@@ -57,7 +58,7 @@ enum ExtraDisplayOptions {
|
|||||||
extern GameMode _game_mode;
|
extern GameMode _game_mode;
|
||||||
extern SwitchMode _switch_mode;
|
extern SwitchMode _switch_mode;
|
||||||
extern bool _check_special_modes;
|
extern bool _check_special_modes;
|
||||||
extern bool _exit_game;
|
extern std::atomic<bool> _exit_game;
|
||||||
extern bool _save_config;
|
extern bool _save_config;
|
||||||
|
|
||||||
/** Modes of pausing we've got */
|
/** Modes of pausing we've got */
|
||||||
|
@@ -15,12 +15,14 @@
|
|||||||
#include "../thread.h"
|
#include "../thread.h"
|
||||||
#include "null_v.h"
|
#include "null_v.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
/** Factory for the null video driver. */
|
/** Factory for the null video driver. */
|
||||||
static FVideoDriver_Null iFVideoDriver_Null;
|
static FVideoDriver_Null iFVideoDriver_Null;
|
||||||
|
|
||||||
extern bool _exit_game;
|
extern std::atomic<bool> _exit_game;
|
||||||
|
|
||||||
const char *VideoDriver_Null::Start(const StringList &parm)
|
const char *VideoDriver_Null::Start(const StringList &parm)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user