Fix OSX not starting matches following 8fbc095a88.

That commit illegaly polled SDL events from a different thread which for
an unknown reason did not error on Windows and GNU/linux.

Refs #4822 / D1304, similarly 8fec942e8a.

Differential Revision: https://code.wildfiregames.com/D1484
Previous iteration tested on OSX and some comments with regards to
letter case by Vladislav (refs 27da92e55f, 4c73614955).

This was SVN commit r21818.
This commit is contained in:
elexis 2018-05-08 10:03:46 +00:00
parent 27da92e55f
commit a5d1e0068b
4 changed files with 18 additions and 3 deletions

View File

@ -41,10 +41,13 @@
// TODO: what's a good default? perhaps based on map size
#define RMS_RUNTIME_SIZE 96 * 1024 * 1024
extern bool IsQuitRequested();
static bool
MapGeneratorInterruptCallback(JSContext* UNUSED(cx))
{
if (SDL_QuitRequested())
// This may not use SDL_IsQuitRequested(), because it runs in a thread separate to SDL, see SDL_PumpEvents
if (IsQuitRequested())
{
LOGWARNING("Quit requested!");
return false;

View File

@ -123,6 +123,11 @@ static int g_ResizedH;
static std::chrono::high_resolution_clock::time_point lastFrameTime;
bool IsQuitRequested()
{
return g_Shutdown == ShutdownType::Quit;
}
void QuitEngine()
{
g_Shutdown = ShutdownType::Quit;

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2017 Wildfire Games.
/* Copyright (C) 2018 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -149,8 +149,10 @@ JS::HandleObject VisualReplay::ReloadReplayCache(const ScriptInterface& scriptIn
for (const OsPath& directory : directories)
{
// This cannot use IsQuitRequested(), because the current loop and that function both run in the main thread.
// So SDL events are not processed unless called explicitly here.
if (SDL_QuitRequested())
// We want to save our progress in searching through the replays
// Don't return, because we want to save our progress
break;
const OsPath replayFile = GetDirectoryName() / directory / L"commands.txt";

View File

@ -22,6 +22,11 @@
bool g_GameRestarted;
bool IsQuitRequested()
{
return false;
}
void QuitEngine()
{
}