mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-04-21 21:52:04 +02:00
Merge pull request #163 from WaywardHeart/hang-on-close
Don't hang if the user closes the game while it's still initializing
This commit is contained in:
commit
b42c13a8ca
3 changed files with 32 additions and 2 deletions
|
@ -531,7 +531,7 @@ RB_METHOD(mkxpSystemMemory) {
|
||||||
RB_METHOD(mkxpReloadPathCache) {
|
RB_METHOD(mkxpReloadPathCache) {
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
shState->fileSystem().reloadPathCache();
|
GUARD_EXC(shState->fileSystem().reloadPathCache(););
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -968,7 +968,11 @@ static void runRMXPScripts(BacktraceData &btData) {
|
||||||
/* Execute preloaded scripts */
|
/* Execute preloaded scripts */
|
||||||
for (std::vector<std::string>::const_iterator i = conf.preloadScripts.begin();
|
for (std::vector<std::string>::const_iterator i = conf.preloadScripts.begin();
|
||||||
i != conf.preloadScripts.end(); ++i)
|
i != conf.preloadScripts.end(); ++i)
|
||||||
|
{
|
||||||
|
if (shState->rtData().rqTerm)
|
||||||
|
break;
|
||||||
runCustomScript(*i);
|
runCustomScript(*i);
|
||||||
|
}
|
||||||
|
|
||||||
VALUE exc = rb_gv_get("$!");
|
VALUE exc = rb_gv_get("$!");
|
||||||
if (exc != Qnil)
|
if (exc != Qnil)
|
||||||
|
@ -976,6 +980,9 @@ static void runRMXPScripts(BacktraceData &btData) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
for (long i = 0; i < scriptCount; ++i) {
|
for (long i = 0; i < scriptCount; ++i) {
|
||||||
|
if (shState->rtData().rqTerm)
|
||||||
|
break;
|
||||||
|
|
||||||
VALUE script = rb_ary_entry(scriptArray, i);
|
VALUE script = rb_ary_entry(scriptArray, i);
|
||||||
VALUE scriptDecoded = rb_ary_entry(script, 3);
|
VALUE scriptDecoded = rb_ary_entry(script, 3);
|
||||||
VALUE string =
|
VALUE string =
|
||||||
|
|
|
@ -396,6 +396,9 @@ struct CacheEnumData {
|
||||||
|
|
||||||
static PHYSFS_EnumerateCallbackResult cacheEnumCB(void *d, const char *origdir,
|
static PHYSFS_EnumerateCallbackResult cacheEnumCB(void *d, const char *origdir,
|
||||||
const char *fname) {
|
const char *fname) {
|
||||||
|
if (shState && shState->rtData().rqTerm)
|
||||||
|
throw Exception(Exception::MKXPError, "Game close requested. Aborting path cache enumeration.");
|
||||||
|
|
||||||
CacheEnumData &data = *static_cast<CacheEnumData *>(d);
|
CacheEnumData &data = *static_cast<CacheEnumData *>(d);
|
||||||
char fullPath[512];
|
char fullPath[512];
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,9 @@ struct SharedStatePrivate
|
||||||
_glState(threadData->config),
|
_glState(threadData->config),
|
||||||
fontState(threadData->config),
|
fontState(threadData->config),
|
||||||
stampCounter(0)
|
stampCounter(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void init(RGSSThreadData *threadData)
|
||||||
{
|
{
|
||||||
|
|
||||||
startupTime = std::chrono::steady_clock::now();
|
startupTime = std::chrono::steady_clock::now();
|
||||||
|
@ -380,7 +383,24 @@ unsigned int SharedState::genTimeStamp()
|
||||||
SharedState::SharedState(RGSSThreadData *threadData)
|
SharedState::SharedState(RGSSThreadData *threadData)
|
||||||
{
|
{
|
||||||
p = new SharedStatePrivate(threadData);
|
p = new SharedStatePrivate(threadData);
|
||||||
p->screen = p->graphics.getScreen();
|
SharedState::instance = this;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
p->init(threadData);
|
||||||
|
p->screen = p->graphics.getScreen();
|
||||||
|
}
|
||||||
|
catch (const Exception &exc)
|
||||||
|
{
|
||||||
|
// If the "error" was the user quitting the game before the path cache finished building,
|
||||||
|
// then just return
|
||||||
|
if (rtData().rqTerm)
|
||||||
|
return;
|
||||||
|
|
||||||
|
delete p;
|
||||||
|
SharedState::instance = 0;
|
||||||
|
|
||||||
|
throw exc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedState::~SharedState()
|
SharedState::~SharedState()
|
||||||
|
|
Loading…
Add table
Reference in a new issue