Quit if the user requested that while loading the replay list. Fixes #3446.
This was SVN commit r17852.
This commit is contained in:
parent
f2ed0098ee
commit
2fea95530f
@ -50,6 +50,13 @@ function init()
|
||||
}
|
||||
|
||||
loadReplays();
|
||||
|
||||
if (!g_Replays)
|
||||
{
|
||||
Engine.SwitchGuiPage("page_pregame.xml");
|
||||
return;
|
||||
}
|
||||
|
||||
displayReplayList();
|
||||
}
|
||||
|
||||
@ -61,6 +68,9 @@ function loadReplays()
|
||||
{
|
||||
g_Replays = Engine.GetReplays();
|
||||
|
||||
if (!g_Replays)
|
||||
return;
|
||||
|
||||
g_Playernames = [];
|
||||
for (let replay of g_Replays)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "graphics/GameView.h"
|
||||
#include "gui/GUIManager.h"
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/external_libraries/libsdl.h"
|
||||
#include "lib/utf8.h"
|
||||
#include "network/NetClient.h"
|
||||
#include "network/NetServer.h"
|
||||
@ -60,6 +61,12 @@ void VisualReplay::StartVisualReplay(const CStrW& directory)
|
||||
g_Game->StartVisualReplay(replayFile.string8());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all replays found in the directory.
|
||||
*
|
||||
* Since files are spread across the harddisk,
|
||||
* loading hundreds of them can consume a lot of time.
|
||||
*/
|
||||
JS::Value VisualReplay::GetReplays(ScriptInterface& scriptInterface)
|
||||
{
|
||||
TIMER(L"GetReplays");
|
||||
@ -69,9 +76,13 @@ JS::Value VisualReplay::GetReplays(ScriptInterface& scriptInterface)
|
||||
u32 i = 0;
|
||||
DirectoryNames directories;
|
||||
JS::RootedObject replays(cx, JS_NewArrayObject(cx, 0));
|
||||
|
||||
if (GetDirectoryEntries(GetDirectoryName(), NULL, &directories) == INFO::OK)
|
||||
for (OsPath& directory : directories)
|
||||
{
|
||||
if (SDL_QuitRequested())
|
||||
return JSVAL_NULL;
|
||||
|
||||
JS::RootedValue replayData(cx, LoadReplayData(scriptInterface, directory));
|
||||
if (!replayData.isNull())
|
||||
JS_SetElement(cx, replays, i++, replayData);
|
||||
|
Loading…
Reference in New Issue
Block a user