Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what drawing was possible. This is a bit nonsense now we have a game-thread. And it makes much more sense to do things like NewGRFScan and GenerateWorld in the game-thread, and not in a thread next to the game-thread. This commit changes that: it removes the threads for NewGRFScan and GenerateWorld, and just runs the code in the game-thread. On regular intervals it allows the draw-thread to do a tick, which gives a much smoother look and feel. It does slow down NewGRFScan and GenerateWorld ever so slightly as it spends more time on drawing. But the slowdown is not measureable on my machines (with 700+ NewGRFs / 4kx4k map and a Debug build). Running without a game-thread means NewGRFScan and GenerateWorld are now blocking.
This commit is contained in:
committed by
Patric Stout
parent
098d5b2239
commit
970fedd78c
@@ -52,15 +52,12 @@ typedef void GWAbortProc(); ///< Called when genworld is aborted
|
||||
/** Properties of current genworld process */
|
||||
struct GenWorldInfo {
|
||||
bool abort; ///< Whether to abort the thread ASAP
|
||||
bool quit_thread; ///< Do we want to quit the active thread
|
||||
bool threaded; ///< Whether we run _GenerateWorld threaded
|
||||
GenWorldMode mode; ///< What mode are we making a world in
|
||||
CompanyID lc; ///< The local_company before generating
|
||||
uint size_x; ///< X-size of the map
|
||||
uint size_y; ///< Y-size of the map
|
||||
GWDoneProc *proc; ///< Proc that is called when done (can be nullptr)
|
||||
GWAbortProc *abortp; ///< Proc that is called when aborting (can be nullptr)
|
||||
std::thread thread; ///< The thread we are in (joinable if a thread was created)
|
||||
};
|
||||
|
||||
/** Current stage of world generation process */
|
||||
@@ -81,10 +78,8 @@ enum GenWorldProgress {
|
||||
};
|
||||
|
||||
/* genworld.cpp */
|
||||
bool IsGenerateWorldThreaded();
|
||||
void GenerateWorldSetCallback(GWDoneProc *proc);
|
||||
void GenerateWorldSetAbortCallback(GWAbortProc *proc);
|
||||
void WaitTillGeneratedWorld();
|
||||
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings = true);
|
||||
void AbortGeneratingWorld();
|
||||
bool IsGeneratingWorldAborted();
|
||||
|
||||
Reference in New Issue
Block a user