Commit 0d449202 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro

parents c3c03409 dad4962a
......@@ -606,7 +606,7 @@ void ClientField::ShowSelectOption(int select_hint) {
wchar_t textBuffer[256];
int count = select_options.size();
bool quickmode = true;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
for(auto option : select_options) {
if(mainGame->guiFont->getDimension(dataManager.GetDesc(option)).Width > 310) {
quickmode = false;
......@@ -654,7 +654,7 @@ void ClientField::ShowSelectOption(int select_hint) {
myswprintf(textBuffer, dataManager.GetSysString(555));
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
void ClientField::ReplaySwap() {
std::swap(deck[0], deck[1]);
......
......@@ -71,9 +71,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <time.h>
#include <thread>
#include <mutex>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
......
......@@ -211,10 +211,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) {
case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1339));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......@@ -273,7 +273,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int sel = mainGame->cbDBDecks->getSelected();
if(sel == -1)
break;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->wDeckCode->setText(dataManager.GetSysString(1387));
if(deckManager.current_deck.main.size() > 0 || deckManager.current_deck.extra.size() > 0 || deckManager.current_deck.side.size() > 0) {
wchar_t deck_code[2048];
......@@ -284,7 +284,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
} else
mainGame->ebDeckCode->setText(L"");
mainGame->PopupElement(mainGame->wDeckCode);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
break;
......@@ -314,22 +314,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int sel = mainGame->cbDBDecks->getSelected();
if(sel == -1)
break;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
break;
}
case BUTTON_LEAVE_GAME: {
if(is_modified && !readonly && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......@@ -363,10 +363,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
case BUTTON_MANAGE_DECK: {
if(is_modified && !readonly && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......@@ -374,69 +374,69 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_NEW_CATEGORY: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1469));
mainGame->ebDMName->setVisible(true);
mainGame->ebDMName->setText(L"");
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_RENAME_CATEGORY: {
if(mainGame->lstCategories->getSelected() < 4)
break;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1469));
mainGame->ebDMName->setVisible(true);
mainGame->ebDMName->setText(L"");
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_DELETE_CATEGORY: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1470));
mainGame->stDMMessage2->setVisible(true);
mainGame->stDMMessage2->setText(mainGame->lstCategories->getListItem(mainGame->lstCategories->getSelected()));
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_NEW_DECK: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1471));
mainGame->ebDMName->setVisible(true);
mainGame->ebDMName->setText(L"");
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_RENAME_DECK: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1471));
mainGame->ebDMName->setVisible(true);
mainGame->ebDMName->setText(L"");
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_DELETE_DECK_DM: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1337));
mainGame->stDMMessage2->setVisible(true);
mainGame->stDMMessage2->setText(mainGame->lstDecks->getListItem(mainGame->lstDecks->getSelected()));
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_MOVE_DECK: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1472));
mainGame->cbDMCategory->setVisible(true);
mainGame->cbDMCategory->clear();
......@@ -448,12 +448,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->cbDMCategory->addItem(mainGame->lstCategories->getListItem(i));
}
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
case BUTTON_COPY_DECK: {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stDMMessage->setText(dataManager.GetSysString(1473));
mainGame->cbDMCategory->setVisible(true);
mainGame->cbDMCategory->clear();
......@@ -465,7 +465,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->cbDMCategory->addItem(mainGame->lstCategories->getListItem(i));
}
mainGame->PopupElement(mainGame->wDMQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......@@ -888,10 +888,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
if(is_modified && !readonly && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......@@ -904,10 +904,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
if(is_modified && !readonly && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
break;
}
......
This diff is collapsed.
......@@ -1697,9 +1697,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(!mainGame->dInfo.isReplay && !mainGame->HasFocus(EGUIET_EDIT_BOX)) {
mainGame->dInfo.isReplaySkiping = event.KeyInput.PressedDown;
if(mainGame->dInfo.isStarted && !mainGame->dInfo.isReplaySkiping) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
}
break;
......
......@@ -879,7 +879,7 @@ void Game::MainLoop() {
atkframe += 0.1f;
atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0));
gMutex.Lock();
gMutex.lock();
if(dInfo.isStarted) {
if(dInfo.isFinished && showcardcode == 1)
soundManager.PlayBGM(BGM_WIN);
......@@ -908,7 +908,7 @@ void Game::MainLoop() {
}
DrawGUI();
DrawSpec();
gMutex.Unlock();
gMutex.unlock();
if(signalFrame > 0) {
signalFrame--;
if(!signalFrame)
......@@ -925,7 +925,7 @@ void Game::MainLoop() {
}
}
driver->endScene();
if(closeSignal.Wait(0))
if(closeSignal.Wait(1))
CloseDuelWindow();
fps++;
cur_time = timer->getTime();
......
......@@ -203,8 +203,7 @@ public:
void takeScreenshot();
void SetCursor(ECURSOR_ICON icon);
Mutex gMutex;
Mutex gBuffer;
std::mutex gMutex;
Signal frameSignal;
Signal actionSignal;
Signal replaySignal;
......
......@@ -82,10 +82,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
hints.ai_flags = EVUTIL_AI_ADDRCONFIG;
int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
break;
} else {
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
......@@ -250,12 +250,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
break;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
break;
......@@ -264,11 +264,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected();
if(sel == -1)
break;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->wReplaySave->setText(dataManager.GetSysString(1364));
mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel));
mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
prev_operation = id;
prev_sel = sel;
break;
......
#ifndef MUTEX_H
#define MUTEX_H
#ifdef _WIN32
#include <windows.h>
class Mutex {
public:
Mutex() {
InitializeCriticalSection(&_mutex);
}
~Mutex() {
DeleteCriticalSection(&_mutex);
}
void Lock() {
EnterCriticalSection(&_mutex);
}
void Unlock() {
LeaveCriticalSection(&_mutex);
}
bool TryLock() {
return TryEnterCriticalSection(&_mutex) == TRUE;
}
private:
CRITICAL_SECTION _mutex;
};
#else // _WIN32
#include <pthread.h>
class Mutex {
public:
Mutex() {
pthread_mutex_init(&mutex_t, NULL);
}
~Mutex() {
pthread_mutex_destroy(&mutex_t);
}
void Lock() {
pthread_mutex_lock(&mutex_t);
}
void Unlock() {
pthread_mutex_unlock(&mutex_t);
}
bool TryLock() {
return !pthread_mutex_trylock(&mutex_t);
}
private:
pthread_mutex_t mutex_t;
};
#endif // _WIN32
#endif // MUTEX_H
#ifndef SIGNAL_H
#define SIGNAL_H
#ifdef _WIN32
#include <windows.h>
class Signal {
public:
Signal() {
_event = CreateEvent(0, FALSE, FALSE, 0);
_nowait = false;
}
~Signal() {
CloseHandle(_event);
}
void Set() {
SetEvent(_event);
}
void Reset() {
ResetEvent(_event);
}
void Wait() {
if(_nowait)
return;
WaitForSingleObject(_event, INFINITE);
}
bool Wait(long milli) {
if(_nowait)
return false;
return WaitForSingleObject(_event, milli + 1) != WAIT_TIMEOUT;
}
void SetNoWait(bool nowait) {
_nowait = nowait;
}
private:
HANDLE _event;
bool _nowait;
};
#else // _WIN32
#include <sys/time.h>
#include <pthread.h>
#include <mutex>
#include <condition_variable>
class Signal {
public:
Signal() {
_state = false;
_nowait = false;
pthread_mutex_init(&_mutex, NULL);
pthread_cond_init(&_cond, NULL);
}
~Signal() {
pthread_cond_destroy(&_cond);
pthread_mutex_destroy(&_mutex);
}
void Set() {
if(pthread_mutex_lock(&_mutex))
return;
std::unique_lock<std::mutex> lock(_mutex);
_state = true;
if(pthread_cond_broadcast(&_cond))
{
pthread_mutex_unlock(&_mutex);
// ERROR Broadcasting event status!
return;
}
pthread_mutex_unlock(&_mutex);
_cond.notify_all();
}
void Reset() {
if(pthread_mutex_lock(&_mutex))
return;
std::unique_lock<std::mutex> lock(_mutex);
_state = false;
pthread_mutex_unlock(&_mutex);
}
void Wait() {
if(_nowait || pthread_mutex_lock(&_mutex))
if(_nowait)
return;
while(!_state)
{
if(pthread_cond_wait(&_cond, &_mutex))
{
pthread_mutex_unlock(&_mutex);
// ERROR Waiting events;
return;
}
}
std::unique_lock<std::mutex> lock(_mutex);
_cond.wait(lock, [this]() { return _state; });
_state = false;
pthread_mutex_unlock(&_mutex);
}
bool Wait(long milliseconds)
{
if (_nowait || pthread_mutex_lock(&_mutex) != 0)
bool Wait(long milliseconds) {
if(_nowait)
return false;
int rc = 0;
struct timespec abstime;
struct timeval tv;
gettimeofday(&tv, NULL);
abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
if (abstime.tv_nsec >= 1000000000)
{
abstime.tv_nsec -= 1000000000;
abstime.tv_sec++;
}
while (!_state)
{
if ((rc = pthread_cond_timedwait(&_cond, &_mutex, &abstime)))
{
if (rc == ETIMEDOUT) break;
pthread_mutex_unlock(&_mutex);
return false;
}
}
std::unique_lock<std::mutex> lock(_mutex);
bool res = _cond.wait_for(lock, std::chrono::milliseconds(milliseconds), [this]() { return _state; });
_state = false;
pthread_mutex_unlock(&_mutex);
return rc == 0;
return res;
}
void SetNoWait(bool nowait) {
_nowait = nowait;
}
private:
pthread_mutex_t _mutex;
pthread_cond_t _cond;
std::mutex _mutex;
std::condition_variable _cond;
bool _state;
bool _nowait;
};
#endif // _WIN32
#endif // SIGNAL_H
......@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() {
exit_pending = false;
current_step = 0;
if(mainGame->dInfo.isReplaySkiping)
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
while (is_continuing && !exit_pending) {
int result = process(pduel);
int len = result & 0xffff;
......@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() {
get_message(pduel, (byte*)engineBuffer);
is_continuing = ReplayAnalyze(engineBuffer, len);
if(is_restarting) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
is_restarting = false;
mainGame->dInfo.isReplaySkiping = true;
Restart(false);
......@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() {
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
skip_step = step;
current_step = 0;
......@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() {
if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
EndDuel();
return 0;
......@@ -232,26 +232,26 @@ void ReplayMode::EndDuel() {
end_duel(pduel);
if(!is_closing) {
mainGame->actionSignal.Reset();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501));
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->actionSignal.Wait();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false;
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->ShowElement(mainGame->wReplay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
if(exit_on_return)
mainGame->device->closeDevice();
}
......@@ -295,9 +295,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
return true;
}
if(is_swaping) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->dField.ReplaySwap();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
is_swaping = false;
}
char* offset = pbuf;
......@@ -308,12 +308,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
return false;
......@@ -327,7 +327,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
pbuf += 2;
DuelClient::ClientAnalyze(offset, pbuf - offset);
......@@ -509,7 +509,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(skip_turn == 0) {
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
}
player = BufferIO::ReadInt8(pbuf);
......@@ -846,7 +846,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
}
}
if(is_pausing) {
......
......@@ -84,7 +84,7 @@ int SingleMode::SinglePlayThread() {
rh.version = PRO_VERSION;
rh.flag = REPLAY_SINGLE_MODE;
rh.seed = seed;
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ClearCardInfo();
mainGame->wCardImg->setVisible(true);
......@@ -98,7 +98,7 @@ int SingleMode::SinglePlayThread() {
mainGame->dInfo.isFinished = false;
mainGame->dInfo.isSingleMode = true;
mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
char engineBuffer[0x1000];
is_closing = false;
is_continuing = true;
......@@ -130,7 +130,7 @@ int SingleMode::SinglePlayThread() {
}
}
last_replay.EndRecord();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
time_t nowtime = time(NULL);
tm* localedtime = localtime(&nowtime);
wchar_t timetext[40];
......@@ -139,7 +139,7 @@ int SingleMode::SinglePlayThread() {
if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait();
} else {
......@@ -148,26 +148,26 @@ int SingleMode::SinglePlayThread() {
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(30);
}
if(mainGame->actionParam)
last_replay.SaveReplay(mainGame->ebRSName->getText());
end_duel(pduel);
if(!is_closing) {
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
if(exit_on_return)
mainGame->device->closeDevice();
}
......@@ -737,9 +737,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf++;
DuelClient::ClientAnalyze(offset, pbuf - offset);
SinglePlayReload();
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
break;
}
case MSG_AI_NAME: {
......@@ -761,10 +761,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf += len + 1;
memcpy(msgbuf, begin, len + 1);
BufferIO::DecodeUTF8(msgbuf, msg);
mainGame->gMutex.Lock();
mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->guiFont, msg);
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->gMutex.unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
break;
......
This diff is collapsed.
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