Commit 9135f797 authored by DailyShana's avatar DailyShana

move restarting duel to replay thread

to avoid crash caused by clicking undo button twice in a very short time
parent a5655685
...@@ -101,6 +101,8 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -101,6 +101,8 @@ int ReplayMode::ReplayThread(void* param) {
if(is_restarting) { if(is_restarting) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
is_restarting = false; is_restarting = false;
mainGame->dInfo.isReplaySkiping = true;
Restart(false);
int step = current_step - 1; int step = current_step - 1;
if(step < 0) if(step < 0)
step = 0; step = 0;
...@@ -109,9 +111,7 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -109,9 +111,7 @@ int ReplayMode::ReplayThread(void* param) {
skip_step = 0; skip_step = 0;
int len = get_message(pduel, (byte*)engineBuffer); int len = get_message(pduel, (byte*)engineBuffer);
if (len > 0) { if (len > 0) {
mainGame->gMutex.Unlock();
is_continuing = ReplayAnalyze(engineBuffer, len); is_continuing = ReplayAnalyze(engineBuffer, len);
mainGame->gMutex.Lock();
} }
} else { } else {
ReplayRefreshDeck(0); ReplayRefreshDeck(0);
...@@ -272,13 +272,11 @@ void ReplayMode::Restart(bool refresh) { ...@@ -272,13 +272,11 @@ void ReplayMode::Restart(bool refresh) {
//mainGame->dInfo.isReplay = true; //mainGame->dInfo.isReplay = true;
} }
skip_turn = 0; skip_turn = 0;
is_restarting = true;
} }
void ReplayMode::Undo() { void ReplayMode::Undo() {
if(skip_step > 0 || current_step == 0) if(skip_step > 0 || current_step == 0)
return; return;
mainGame->dInfo.isReplaySkiping = true; is_restarting = true;
Restart(false);
Pause(false, false); Pause(false, false);
} }
bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment