Commit 643f6ca8 authored by mercury233's avatar mercury233

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

parents 47935247 9addd246
...@@ -595,7 +595,7 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -595,7 +595,7 @@ void ClientField::ShowSelectOption(int select_hint) {
wchar_t textBuffer[256]; wchar_t textBuffer[256];
int count = select_options.size(); int count = select_options.size();
bool quickmode = true; bool quickmode = true;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
for(auto option : select_options) { for(auto option : select_options) {
if(mainGame->guiFont->getDimension(dataManager.GetDesc(option)).Width > 310) { if(mainGame->guiFont->getDimension(dataManager.GetDesc(option)).Width > 310) {
quickmode = false; quickmode = false;
...@@ -643,7 +643,7 @@ void ClientField::ShowSelectOption(int select_hint) { ...@@ -643,7 +643,7 @@ void ClientField::ShowSelectOption(int select_hint) {
myswprintf(textBuffer, dataManager.GetSysString(555)); myswprintf(textBuffer, dataManager.GetSysString(555));
mainGame->wOptions->setText(textBuffer); mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions); mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
void ClientField::ReplaySwap() { void ClientField::ReplaySwap() {
std::swap(deck[0], deck[1]); std::swap(deck[0], deck[1]);
......
...@@ -68,9 +68,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -68,9 +68,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h> #include <memory.h>
#include <time.h> #include <time.h>
#include <thread> #include <thread>
#include <mutex>
#include "bufferio.h" #include "bufferio.h"
#include "myfilesystem.h" #include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h" #include "mysignal.h"
#include "../ocgcore/ocgapi.h" #include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h" #include "../ocgcore/common.h"
......
...@@ -129,10 +129,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -129,10 +129,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
soundManager.PlaySoundEffect(SOUND_BUTTON); soundManager.PlaySoundEffect(SOUND_BUTTON);
switch(id) { switch(id) {
case BUTTON_CLEAR_DECK: { case BUTTON_CLEAR_DECK: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1339)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1339));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
break; break;
} }
...@@ -183,22 +183,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -183,22 +183,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int sel = mainGame->cbDBDecks->getSelected(); int sel = mainGame->cbDBDecks->getSelected();
if(sel == -1) if(sel == -1)
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
wchar_t textBuffer[256]; wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337)); myswprintf(textBuffer, L"%ls\n%ls", mainGame->cbDBDecks->getItem(sel), dataManager.GetSysString(1337));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
prev_sel = sel; prev_sel = sel;
break; break;
} }
case BUTTON_LEAVE_GAME: { case BUTTON_LEAVE_GAME: {
if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) { if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
break; break;
} }
...@@ -368,10 +368,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -368,10 +368,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
} }
case COMBOBOX_DBDECKS: { case COMBOBOX_DBDECKS: {
if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) { if(is_modified && !mainGame->chkIgnoreDeckChanges->isChecked()) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetSysString(1356));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
break; break;
} }
......
...@@ -77,14 +77,14 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) { ...@@ -77,14 +77,14 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(bot_mode && !mainGame->wSinglePlay->isVisible()) if(bot_mode && !mainGame->wSinglePlay->isVisible())
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else if(!bot_mode && !mainGame->wLanWindow->isVisible()) else if(!bot_mode && !mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
} }
...@@ -168,14 +168,14 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -168,14 +168,14 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(bot_mode && !mainGame->wSinglePlay->isVisible()) if(bot_mode && !mainGame->wSinglePlay->isVisible())
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else if(!bot_mode && !mainGame->wLanWindow->isVisible()) else if(!bot_mode && !mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} else if(connect_state == 0x7) { } else if(connect_state == 0x7) {
if(!mainGame->dInfo.isStarted && !mainGame->is_building) { if(!mainGame->dInfo.isStarted && !mainGame->is_building) {
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
...@@ -183,7 +183,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -183,7 +183,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wHostPrepare); mainGame->HideElement(mainGame->wHostPrepare);
if(bot_mode) if(bot_mode)
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
...@@ -194,9 +194,9 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -194,9 +194,9 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
if(events & BEV_EVENT_EOF) if(events & BEV_EVENT_EOF)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1401)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1401));
else mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402)); else mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1502)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1502));
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
...@@ -205,11 +205,11 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -205,11 +205,11 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->stTip->setVisible(false); mainGame->stTip->setVisible(false);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->is_building = false; mainGame->is_building = false;
...@@ -218,7 +218,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -218,7 +218,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else else
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
} }
} }
...@@ -251,7 +251,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -251,7 +251,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
if(pkt->code == 0) if(pkt->code == 0)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1403)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1403));
...@@ -259,12 +259,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -259,12 +259,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1404)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1404));
else if(pkt->code == 2) else if(pkt->code == 2)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1405)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1405));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
break; break;
} }
case ERRMSG_DECKERROR: { case ERRMSG_DECKERROR: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
unsigned int code = pkt->code & 0xFFFFFFF; unsigned int code = pkt->code & 0xFFFFFFF;
int flag = pkt->code >> 28; int flag = pkt->code >> 28;
wchar_t msgbuf[256]; wchar_t msgbuf[256];
...@@ -313,14 +313,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -313,14 +313,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", msgbuf); mainGame->env->addMessageBox(L"", msgbuf);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case ERRMSG_SIDEERROR: { case ERRMSG_SIDEERROR: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1408)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1408));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case ERRMSG_VERERROR: { case ERRMSG_VERERROR: {
...@@ -329,12 +329,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -329,12 +329,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnBotCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
wchar_t msgbuf[256]; wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1411), pkt->code >> 12, (pkt->code >> 4) & 0xff, pkt->code & 0xf); myswprintf(msgbuf, dataManager.GetSysString(1411), pkt->code >> 12, (pkt->code >> 4) & 0xff, pkt->code & 0xf);
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", msgbuf); mainGame->env->addMessageBox(L"", msgbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
break; break;
} }
...@@ -346,9 +346,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -346,9 +346,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break; break;
} }
case STOC_SELECT_TP: { case STOC_SELECT_TP: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->PopupElement(mainGame->wFTSelect); mainGame->PopupElement(mainGame->wFTSelect);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case STOC_HAND_RESULT: { case STOC_HAND_RESULT: {
...@@ -365,7 +365,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -365,7 +365,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break; break;
} }
case STOC_CHANGE_SIDE: { case STOC_CHANGE_SIDE: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->is_building = true; mainGame->is_building = true;
...@@ -398,15 +398,15 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -398,15 +398,15 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->deckBuilder.pre_extrac = deckManager.current_deck.extra.size(); mainGame->deckBuilder.pre_extrac = deckManager.current_deck.extra.size();
mainGame->deckBuilder.pre_sidec = deckManager.current_deck.side.size(); mainGame->deckBuilder.pre_sidec = deckManager.current_deck.side.size();
mainGame->device->setEventReceiver(&mainGame->deckBuilder); mainGame->device->setEventReceiver(&mainGame->deckBuilder);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case STOC_WAITING_SIDE: { case STOC_WAITING_SIDE: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->stHintMsg->setText(dataManager.GetSysString(1409)); mainGame->stHintMsg->setText(dataManager.GetSysString(1409));
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case STOC_JOIN_GAME: { case STOC_JOIN_GAME: {
...@@ -442,7 +442,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -442,7 +442,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1230)); myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1230));
str.append(msgbuf); str.append(msgbuf);
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(pkt->info.mode == 2) { if(pkt->info.mode == 2) {
mainGame->dInfo.isTag = true; mainGame->dInfo.isTag = true;
mainGame->chkHostPrepReady[2]->setVisible(true); mainGame->chkHostPrepReady[2]->setVisible(true);
...@@ -486,7 +486,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -486,7 +486,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->ShowElement(mainGame->wHostPrepare); mainGame->ShowElement(mainGame->wHostPrepare);
if(!mainGame->chkIgnore1->isChecked()) if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->dInfo.duel_rule = pkt->info.duel_rule; mainGame->dInfo.duel_rule = pkt->info.duel_rule;
watching = 0; watching = 0;
connect_state |= 0x4; connect_state |= 0x4;
...@@ -568,7 +568,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -568,7 +568,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_DUEL_START: { case STOC_DUEL_START: {
mainGame->HideElement(mainGame->wHostPrepare); mainGame->HideElement(mainGame->wHostPrepare);
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
...@@ -632,12 +632,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -632,12 +632,12 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.tag_player[0] = false; mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false; mainGame->dInfo.tag_player[1] = false;
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
match_kill = 0; match_kill = 0;
break; break;
} }
case STOC_DUEL_END: { case STOC_DUEL_END: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false); mainGame->btnSpectatorSwap->setVisible(false);
...@@ -648,13 +648,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -648,13 +648,13 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->wSurrender->setVisible(false); mainGame->wSurrender->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500)); mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->is_building = false; mainGame->is_building = false;
...@@ -670,14 +670,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -670,14 +670,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else else
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
break; break;
} }
case STOC_REPLAY: { case STOC_REPLAY: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wPhase->setVisible(false); mainGame->wPhase->setVisible(false);
mainGame->wSurrender->setVisible(false); mainGame->wSurrender->setVisible(false);
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
...@@ -698,7 +698,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -698,7 +698,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
if(!mainGame->chkAutoSaveReplay->isChecked()) { if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->replaySignal.Reset(); mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait(); mainGame->replaySignal.Wait();
} }
...@@ -708,7 +708,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -708,7 +708,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext); myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
} }
if(mainGame->actionParam || !is_host) { if(mainGame->actionParam || !is_host) {
...@@ -765,9 +765,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -765,9 +765,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} }
wchar_t msg[256]; wchar_t msg[256];
BufferIO::CopyWStr(pkt->msg, msg, 256); BufferIO::CopyWStr(pkt->msg, msg, 256);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->AddChatMsg(msg, player); mainGame->AddChatMsg(msg, player);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case STOC_HS_PLAYER_ENTER: { case STOC_HS_PLAYER_ENTER: {
...@@ -792,9 +792,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -792,9 +792,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if(pkt->pos == 1) else if(pkt->pos == 1)
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname, 20); BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname, 20);
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stHostPrepDuelist[pkt->pos]->setText(name); mainGame->stHostPrepDuelist[pkt->pos]->setText(name);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->FlashWindow(); mainGame->FlashWindow();
break; break;
} }
...@@ -804,7 +804,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -804,7 +804,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
unsigned char state = pkt->status & 0xf; unsigned char state = pkt->status & 0xf;
if(pos > 3) if(pos > 3)
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(state < 8) { if(state < 8) {
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER); soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText(); wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
...@@ -848,7 +848,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -848,7 +848,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} else { } else {
mainGame->btnHostPrepStart->setEnabled(false); mainGame->btnHostPrepStart->setEnabled(false);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case STOC_HS_WATCH_CHANGE: { case STOC_HS_WATCH_CHANGE: {
...@@ -856,9 +856,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -856,9 +856,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
watching = pkt->watch_count; watching = pkt->watch_count;
wchar_t watchbuf[32]; wchar_t watchbuf[32];
myswprintf(watchbuf, L"%ls%d", dataManager.GetSysString(1253), watching); myswprintf(watchbuf, L"%ls%d", dataManager.GetSysString(1253), watching);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stHostPrepOB->setText(watchbuf); mainGame->stHostPrepOB->setText(watchbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
} }
...@@ -876,24 +876,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -876,24 +876,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->waitFrame = -1; mainGame->waitFrame = -1;
mainGame->stHintMsg->setVisible(false); mainGame->stHintMsg->setVisible(false);
if(mainGame->wCardSelect->isVisible()) { if(mainGame->wCardSelect->isVisible()) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
} }
if(mainGame->wOptions->isVisible()) { if(mainGame->wOptions->isVisible()) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wOptions); mainGame->HideElement(mainGame->wOptions);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
} }
} }
if(mainGame->dInfo.time_player == 1) if(mainGame->dInfo.time_player == 1)
mainGame->dInfo.time_player = 2; mainGame->dInfo.time_player = 2;
if(is_swapping) { if(is_swapping) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.ReplaySwap(); mainGame->dField.ReplaySwap();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
is_swapping = false; is_swapping = false;
} }
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
...@@ -943,26 +943,26 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -943,26 +943,26 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
default: default:
break; break;
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetDesc(err_desc)); mainGame->stMessage->setText(dataManager.GetDesc(err_desc));
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
select_hint = last_select_hint; select_hint = last_select_hint;
return ClientAnalyze(last_successful_msg, last_successful_msg_length); return ClientAnalyze(last_successful_msg, last_successful_msg_length);
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(L"Error occurs."); mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
if(!mainGame->dInfo.isSingleMode) { if(!mainGame->dInfo.isSingleMode) {
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
...@@ -976,7 +976,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -976,7 +976,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
else else
mainGame->ShowElement(mainGame->wLanWindow); mainGame->ShowElement(mainGame->wLanWindow);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
event_base_loopbreak(client_base); event_base_loopbreak(client_base);
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
...@@ -995,10 +995,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -995,10 +995,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
break; break;
} }
case HINT_MESSAGE: { case HINT_MESSAGE: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetDesc(data)); mainGame->stMessage->setText(dataManager.GetDesc(data));
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
break; break;
...@@ -1011,10 +1011,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1011,10 +1011,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
case HINT_OPSELECTED: { case HINT_OPSELECTED: {
myswprintf(textBuffer, dataManager.GetSysString(1510), dataManager.GetDesc(data)); myswprintf(textBuffer, dataManager.GetSysString(1510), dataManager.GetDesc(data));
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
break; break;
} }
...@@ -1028,40 +1028,40 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1028,40 +1028,40 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
case HINT_RACE: { case HINT_RACE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data)); myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data));
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
break; break;
} }
case HINT_ATTRIB: { case HINT_ATTRIB: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data)); myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data));
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
break; break;
} }
case HINT_CODE: { case HINT_CODE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.GetName(data)); myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.GetName(data));
mainGame->AddLog(textBuffer, data); mainGame->AddLog(textBuffer, data);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
break; break;
} }
case HINT_NUMBER: { case HINT_NUMBER: {
myswprintf(textBuffer, dataManager.GetSysString(1512), data); myswprintf(textBuffer, dataManager.GetSysString(1512), data);
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
break; break;
} }
...@@ -1112,10 +1112,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1112,10 +1112,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
case MSG_WAITING: { case MSG_WAITING: {
mainGame->waitFrame = 0; mainGame->waitFrame = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stHintMsg->setText(dataManager.GetSysString(1390)); mainGame->stHintMsg->setText(dataManager.GetSysString(1390));
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_START: { case MSG_START: {
...@@ -1125,7 +1125,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1125,7 +1125,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->showcard = 101; mainGame->showcard = 101;
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
mainGame->showcard = 0; mainGame->showcard = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
int playertype = BufferIO::ReadInt8(pbuf); int playertype = BufferIO::ReadInt8(pbuf);
mainGame->dInfo.isFirst = (playertype & 0xf) ? false : true; mainGame->dInfo.isFirst = (playertype & 0xf) ? false : true;
if(playertype & 0xf0) if(playertype & 0xf0)
...@@ -1159,24 +1159,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1159,24 +1159,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.isReplaySwapped = false; mainGame->dInfo.isReplaySwapped = false;
mainGame->dField.ReplaySwap(); mainGame->dField.ReplaySwap();
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_UPDATE_DATA: { case MSG_UPDATE_DATA: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int location = BufferIO::ReadInt8(pbuf); int location = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.UpdateFieldCard(player, location, pbuf); mainGame->dField.UpdateFieldCard(player, location, pbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_UPDATE_CARD: { case MSG_UPDATE_CARD: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int loc = BufferIO::ReadInt8(pbuf); int loc = BufferIO::ReadInt8(pbuf);
int seq = BufferIO::ReadInt8(pbuf); int seq = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.UpdateCard(player, loc, seq, pbuf); mainGame->dField.UpdateCard(player, loc, seq, pbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case MSG_SELECT_BATTLECMD: { case MSG_SELECT_BATTLECMD: {
...@@ -1225,7 +1225,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1225,7 +1225,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.attackable_cards.push_back(pcard); mainGame->dField.attackable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_ATTACK; pcard->cmdFlag |= COMMAND_ATTACK;
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(BufferIO::ReadInt8(pbuf)) { if(BufferIO::ReadInt8(pbuf)) {
mainGame->btnM2->setVisible(true); mainGame->btnM2->setVisible(true);
mainGame->btnM2->setEnabled(true); mainGame->btnM2->setEnabled(true);
...@@ -1236,7 +1236,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1236,7 +1236,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnEP->setEnabled(true); mainGame->btnEP->setEnabled(true);
mainGame->btnEP->setPressed(false); mainGame->btnEP->setPressed(false);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_IDLECMD: { case MSG_SELECT_IDLECMD: {
...@@ -1387,20 +1387,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1387,20 +1387,20 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} else { } else {
myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code)); myswprintf(textBuffer, dataManager.GetDesc(desc), dataManager.GetName(code));
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_YESNO: { case MSG_SELECT_YESNO: {
/*int selecting_player = */BufferIO::ReadInt8(pbuf); /*int selecting_player = */BufferIO::ReadInt8(pbuf);
int desc = BufferIO::ReadInt32(pbuf); int desc = BufferIO::ReadInt32(pbuf);
mainGame->dField.highlighting_card = 0; mainGame->dField.highlighting_card = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetDesc(desc)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_OPTION: { case MSG_SELECT_OPTION: {
...@@ -1453,10 +1453,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1453,10 +1453,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max); else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0; select_hint = 0;
if (panelmode) { if (panelmode) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wCardSelect->setText(textBuffer); mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(select_ready); mainGame->dField.ShowSelectCard(select_ready);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} else { } else {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
...@@ -1533,10 +1533,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1533,10 +1533,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max); else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(560), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0; select_hint = 0;
if (panelmode) { if (panelmode) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wCardSelect->setText(textBuffer); mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(mainGame->dField.select_cancelable); mainGame->dField.ShowSelectCard(mainGame->dField.select_cancelable);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} else { } else {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
...@@ -1621,7 +1621,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1621,7 +1621,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
DuelClient::SendResponse(); DuelClient::SendResponse();
return true; return true;
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(!conti_exist) if(!conti_exist)
mainGame->stHintMsg->setText(dataManager.GetSysString(550)); mainGame->stHintMsg->setText(dataManager.GetSysString(550));
else else
...@@ -1646,7 +1646,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1646,7 +1646,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
} }
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_PLACE: case MSG_SELECT_PLACE:
...@@ -1765,9 +1765,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1765,9 +1765,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnPSDD->setVisible(true); mainGame->btnPSDD->setVisible(true);
startpos += 145; startpos += 145;
} else mainGame->btnPSDD->setVisible(false); } else mainGame->btnPSDD->setVisible(false);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->PopupElement(mainGame->wPosSelect); mainGame->PopupElement(mainGame->wPosSelect);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_TRIBUTE: { case MSG_SELECT_TRIBUTE: {
...@@ -1802,13 +1802,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1802,13 +1802,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.select_min, mainGame->dField.select_max); mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(531), mainGame->dField.select_min, mainGame->dField.select_max); else myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetSysString(531), mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0; select_hint = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
if (mainGame->dField.select_cancelable) { if (mainGame->dField.select_cancelable) {
mainGame->dField.ShowCancelOrFinishButton(1); mainGame->dField.ShowCancelOrFinishButton(1);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_COUNTER: { case MSG_SELECT_COUNTER: {
...@@ -1831,10 +1831,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1831,10 +1831,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->is_selectable = true; pcard->is_selectable = true;
} }
myswprintf(textBuffer, dataManager.GetSysString(204), mainGame->dField.select_counter_count, dataManager.GetCounterName(mainGame->dField.select_counter_type)); myswprintf(textBuffer, dataManager.GetSysString(204), mainGame->dField.select_counter_count, dataManager.GetCounterName(mainGame->dField.select_counter_type));
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_SELECT_SUM: { case MSG_SELECT_SUM: {
...@@ -1944,10 +1944,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1944,10 +1944,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
pcard = *(mainGame->dField.deck[player].rbegin() + i); pcard = *(mainGame->dField.deck[player].rbegin() + i);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code)); myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code));
mainGame->AddLog(textBuffer, pcard->code); mainGame->AddLog(textBuffer, pcard->code);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
float shift = -0.15f; float shift = -0.15f;
if (player == 1) shift = 0.15f; if (player == 1) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0); pcard->dPos = irr::core::vector3df(shift, 0, 0);
...@@ -1982,10 +1982,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1982,10 +1982,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
pcard = *(mainGame->dField.extra[player].rbegin() + i + mainGame->dField.extra_p_count[player]); pcard = *(mainGame->dField.extra[player].rbegin() + i + mainGame->dField.extra_p_count[player]);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code)); myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code));
mainGame->AddLog(textBuffer, pcard->code); mainGame->AddLog(textBuffer, pcard->code);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if (player == 0) if (player == 0)
pcard->dPos = irr::core::vector3df(0, -0.20f, 0); pcard->dPos = irr::core::vector3df(0, -0.20f, 0);
else else
...@@ -2021,10 +2021,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2021,10 +2021,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard = mainGame->dField.GetCard(c, l, s); pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0) if (code != 0)
pcard->SetCode(code); pcard->SetCode(code);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(code)); myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(code));
mainGame->AddLog(textBuffer, code); mainGame->AddLog(textBuffer, code);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if (l & 0x41) { if (l & 0x41) {
if(count == 1) { if(count == 1) {
float shift = -0.15f; float shift = -0.15f;
...@@ -2088,12 +2088,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2088,12 +2088,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
if (panel_confirm.size()) { if (panel_confirm.size()) {
std::sort(panel_confirm.begin(), panel_confirm.end(), ClientCard::client_card_sort); std::sort(panel_confirm.begin(), panel_confirm.end(), ClientCard::client_card_sort);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.selectable_cards = panel_confirm; mainGame->dField.selectable_cards = panel_confirm;
myswprintf(textBuffer, dataManager.GetSysString(208), panel_confirm.size()); myswprintf(textBuffer, dataManager.GetSysString(208), panel_confirm.size());
mainGame->wCardSelect->setText(textBuffer); mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard(true); mainGame->dField.ShowSelectCard(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
} }
...@@ -2233,7 +2233,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2233,7 +2233,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} }
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.grave[player].swap(mainGame->dField.deck[player]); mainGame->dField.grave[player].swap(mainGame->dField.deck[player]);
for (auto cit = mainGame->dField.grave[player].begin(); cit != mainGame->dField.grave[player].end(); ++cit) { for (auto cit = mainGame->dField.grave[player].begin(); cit != mainGame->dField.grave[player].end(); ++cit) {
(*cit)->location = LOCATION_GRAVE; (*cit)->location = LOCATION_GRAVE;
...@@ -2253,7 +2253,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2253,7 +2253,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
} }
return true; return true;
...@@ -2439,9 +2439,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2439,9 +2439,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->position = cp; pcard->position = cp;
pcard->SetCode(code); pcard->SetCode(code);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.AddCard(pcard, cc, cl, cs); mainGame->dField.AddCard(pcard, cc, cl, cs);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot, true); mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot, true);
pcard->curAlpha = 5; pcard->curAlpha = 5;
mainGame->dField.FadeCard(pcard, 255, 20); mainGame->dField.FadeCard(pcard, 255, 20);
...@@ -2458,9 +2458,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2458,9 +2458,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mainGame->dField.FadeCard(pcard, 5, 20); mainGame->dField.FadeCard(pcard, 5, 20);
mainGame->WaitFrameSignal(20); mainGame->WaitFrameSignal(20);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.RemoveCard(pc, pl, ps); mainGame->dField.RemoveCard(pc, pl, ps);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if(pcard == mainGame->dField.hovered_card) if(pcard == mainGame->dField.hovered_card)
mainGame->dField.hovered_card = 0; mainGame->dField.hovered_card = 0;
} else } else
...@@ -2492,11 +2492,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2492,11 +2492,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->position = cp; pcard->position = cp;
mainGame->dField.AddCard(pcard, cc, cl, cs); mainGame->dField.AddCard(pcard, cc, cl, cs);
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.RemoveCard(pc, pl, ps); mainGame->dField.RemoveCard(pc, pl, ps);
pcard->position = cp; pcard->position = cp;
mainGame->dField.AddCard(pcard, cc, cl, cs); mainGame->dField.AddCard(pcard, cc, cl, cs);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if (pl == cl && pc == cc && (cl & 0x71)) { if (pl == cl && pc == cc && (cl & 0x71)) {
pcard->dPos = irr::core::vector3df(-0.3f, 0, 0); pcard->dPos = irr::core::vector3df(-0.3f, 0, 0);
pcard->dRot = irr::core::vector3df(0, 0, 0); pcard->dRot = irr::core::vector3df(0, 0, 0);
...@@ -2508,24 +2508,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2508,24 +2508,24 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} else { } else {
if (cl == 0x4 && pcard->overlayed.size() > 0) { if (cl == 0x4 && pcard->overlayed.size() > 0) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
for (size_t i = 0; i < pcard->overlayed.size(); ++i) for (size_t i = 0; i < pcard->overlayed.size(); ++i)
mainGame->dField.MoveCard(pcard->overlayed[i], 10); mainGame->dField.MoveCard(pcard->overlayed[i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(10); mainGame->WaitFrameSignal(10);
} }
if (cl == 0x2) { if (cl == 0x2) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
for (size_t i = 0; i < mainGame->dField.hand[cc].size(); ++i) for (size_t i = 0; i < mainGame->dField.hand[cc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[cc][i], 10); mainGame->dField.MoveCard(mainGame->dField.hand[cc][i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
if (pl == 0x2) if (pl == 0x2)
for (size_t i = 0; i < mainGame->dField.hand[pc].size(); ++i) for (size_t i = 0; i < mainGame->dField.hand[pc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10); mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
...@@ -2547,21 +2547,21 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2547,21 +2547,21 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->location = 0x80; pcard->location = 0x80;
pcard->sequence = olcard->overlayed.size() - 1; pcard->sequence = olcard->overlayed.size() - 1;
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.RemoveCard(pc, pl, ps); mainGame->dField.RemoveCard(pc, pl, ps);
olcard->overlayed.push_back(pcard); olcard->overlayed.push_back(pcard);
mainGame->dField.overlay_cards.insert(pcard); mainGame->dField.overlay_cards.insert(pcard);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
pcard->overlayTarget = olcard; pcard->overlayTarget = olcard;
pcard->location = 0x80; pcard->location = 0x80;
pcard->sequence = olcard->overlayed.size() - 1; pcard->sequence = olcard->overlayed.size() - 1;
if (olcard->location == 0x4) { if (olcard->location == 0x4) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
if (pl == 0x2) if (pl == 0x2)
for (size_t i = 0; i < mainGame->dField.hand[pc].size(); ++i) for (size_t i = 0; i < mainGame->dField.hand[pc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10); mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
} }
...@@ -2577,7 +2577,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2577,7 +2577,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
for (size_t i = 0; i < olcard->overlayed.size(); ++i) for (size_t i = 0; i < olcard->overlayed.size(); ++i)
olcard->overlayed[i]->sequence = i; olcard->overlayed[i]->sequence = i;
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
olcard->overlayed.erase(olcard->overlayed.begin() + pcard->sequence); olcard->overlayed.erase(olcard->overlayed.begin() + pcard->sequence);
pcard->overlayTarget = 0; pcard->overlayTarget = 0;
pcard->position = cp; pcard->position = cp;
...@@ -2587,11 +2587,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2587,11 +2587,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
olcard->overlayed[i]->sequence = i; olcard->overlayed[i]->sequence = i;
mainGame->dField.MoveCard(olcard->overlayed[i], 2); mainGame->dField.MoveCard(olcard->overlayed[i], 2);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
} else { } else {
...@@ -2608,7 +2608,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2608,7 +2608,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
olcard1->overlayed[i]->sequence = i; olcard1->overlayed[i]->sequence = i;
} }
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
olcard1->overlayed.erase(olcard1->overlayed.begin() + pcard->sequence); olcard1->overlayed.erase(olcard1->overlayed.begin() + pcard->sequence);
olcard2->overlayed.push_back(pcard); olcard2->overlayed.push_back(pcard);
pcard->sequence = olcard2->overlayed.size() - 1; pcard->sequence = olcard2->overlayed.size() - 1;
...@@ -2619,7 +2619,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2619,7 +2619,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.MoveCard(olcard1->overlayed[i], 2); mainGame->dField.MoveCard(olcard1->overlayed[i], 2);
} }
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
} }
...@@ -2674,7 +2674,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2674,7 +2674,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1); ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2); ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.RemoveCard(c1, l1, s1); mainGame->dField.RemoveCard(c1, l1, s1);
mainGame->dField.RemoveCard(c2, l2, s2); mainGame->dField.RemoveCard(c2, l2, s2);
mainGame->dField.AddCard(pc1, c2, l2, s2); mainGame->dField.AddCard(pc1, c2, l2, s2);
...@@ -2685,7 +2685,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2685,7 +2685,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.MoveCard(pc1->overlayed[i], 10); mainGame->dField.MoveCard(pc1->overlayed[i], 10);
for (size_t i = 0; i < pc2->overlayed.size(); ++i) for (size_t i = 0; i < pc2->overlayed.size(); ++i)
mainGame->dField.MoveCard(pc2->overlayed[i], 10); mainGame->dField.MoveCard(pc2->overlayed[i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
} else { } else {
mainGame->dField.RemoveCard(c1, l1, s1); mainGame->dField.RemoveCard(c1, l1, s1);
...@@ -2844,9 +2844,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2844,9 +2844,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code)); myswprintf(event_string, dataManager.GetSysString(1609), dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.chains.push_back(mainGame->dField.current_chain); mainGame->dField.chains.push_back(mainGame->dField.current_chain);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if (ct > 1) if (ct > 1)
mainGame->WaitFrameSignal(20); mainGame->WaitFrameSignal(20);
mainGame->dField.last_chain = true; mainGame->dField.last_chain = true;
...@@ -2980,13 +2980,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2980,13 +2980,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} else { } else {
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
soundManager.PlaySoundEffect(SOUND_DRAW); soundManager.PlaySoundEffect(SOUND_DRAW);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1); pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1);
mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1); mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1);
mainGame->dField.AddCard(pcard, player, LOCATION_HAND, 0); mainGame->dField.AddCard(pcard, player, LOCATION_HAND, 0);
for(size_t i = 0; i < mainGame->dField.hand[player].size(); ++i) for(size_t i = 0; i < mainGame->dField.hand[player].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[player][i], 10); mainGame->dField.MoveCard(mainGame->dField.hand[player][i], 10);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(5); mainGame->WaitFrameSignal(5);
} }
} }
...@@ -3021,9 +3021,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3021,9 +3021,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_RECOVER: { case MSG_RECOVER: {
...@@ -3050,9 +3050,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3050,9 +3050,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_EQUIP: { case MSG_EQUIP: {
...@@ -3073,7 +3073,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3073,7 +3073,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc2->equipped.insert(pc1); pc2->equipped.insert(pc1);
} else { } else {
soundManager.PlaySoundEffect(SOUND_EQUIP); soundManager.PlaySoundEffect(SOUND_EQUIP);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(pc1->equipTarget) { if(pc1->equipTarget) {
pc1->is_showequip = false; pc1->is_showequip = false;
pc1->equipTarget->is_showequip = false; pc1->equipTarget->is_showequip = false;
...@@ -3085,7 +3085,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3085,7 +3085,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc2->is_showequip = true; pc2->is_showequip = true;
else if (mainGame->dField.hovered_card == pc2) else if (mainGame->dField.hovered_card == pc2)
pc1->is_showequip = true; pc1->is_showequip = true;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
return true; return true;
} }
...@@ -3102,9 +3102,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3102,9 +3102,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->lpframe = 10; mainGame->lpframe = 10;
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->dInfo.lp[player] = val; mainGame->dInfo.lp[player] = val;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_UNEQUIP: { case MSG_UNEQUIP: {
...@@ -3117,14 +3117,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3117,14 +3117,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc->equipTarget->equipped.erase(pc); pc->equipTarget->equipped.erase(pc);
pc->equipTarget = 0; pc->equipTarget = 0;
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if (mainGame->dField.hovered_card == pc) if (mainGame->dField.hovered_card == pc)
pc->equipTarget->is_showequip = false; pc->equipTarget->is_showequip = false;
else if (mainGame->dField.hovered_card == pc->equipTarget) else if (mainGame->dField.hovered_card == pc->equipTarget)
pc->is_showequip = false; pc->is_showequip = false;
pc->equipTarget->equipped.erase(pc); pc->equipTarget->equipped.erase(pc);
pc->equipTarget = 0; pc->equipTarget = 0;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
return true; return true;
} }
...@@ -3143,14 +3143,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3143,14 +3143,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc1->cardTarget.insert(pc2); pc1->cardTarget.insert(pc2);
pc2->ownerTarget.insert(pc1); pc2->ownerTarget.insert(pc1);
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
pc1->cardTarget.insert(pc2); pc1->cardTarget.insert(pc2);
pc2->ownerTarget.insert(pc1); pc2->ownerTarget.insert(pc1);
if (mainGame->dField.hovered_card == pc1) if (mainGame->dField.hovered_card == pc1)
pc2->is_showtarget = true; pc2->is_showtarget = true;
else if (mainGame->dField.hovered_card == pc2) else if (mainGame->dField.hovered_card == pc2)
pc1->is_showtarget = true; pc1->is_showtarget = true;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
break; break;
} }
...@@ -3169,14 +3169,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3169,14 +3169,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pc1->cardTarget.erase(pc2); pc1->cardTarget.erase(pc2);
pc2->ownerTarget.erase(pc1); pc2->ownerTarget.erase(pc1);
} else { } else {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
pc1->cardTarget.erase(pc2); pc1->cardTarget.erase(pc2);
pc2->ownerTarget.erase(pc1); pc2->ownerTarget.erase(pc1);
if (mainGame->dField.hovered_card == pc1) if (mainGame->dField.hovered_card == pc1)
pc2->is_showtarget = false; pc2->is_showtarget = false;
else if (mainGame->dField.hovered_card == pc2) else if (mainGame->dField.hovered_card == pc2)
pc1->is_showtarget = false; pc1->is_showtarget = false;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
break; break;
} }
...@@ -3202,9 +3202,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3202,9 +3202,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
mainGame->lpcstring = 0; mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final; mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]); myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_ADD_COUNTER: { case MSG_ADD_COUNTER: {
...@@ -3222,10 +3222,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3222,10 +3222,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_COUNTER_ADD); soundManager.PlaySoundEffect(SOUND_COUNTER_ADD);
myswprintf(textBuffer, dataManager.GetSysString(1617), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type)); myswprintf(textBuffer, dataManager.GetSysString(1617), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true; pc->is_highlighting = true;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stACMessage->setText(textBuffer); mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
pc->is_highlighting = false; pc->is_highlighting = false;
return true; return true;
...@@ -3245,10 +3245,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3245,10 +3245,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
soundManager.PlaySoundEffect(SOUND_COUNTER_REMOVE); soundManager.PlaySoundEffect(SOUND_COUNTER_REMOVE);
myswprintf(textBuffer, dataManager.GetSysString(1618), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type)); myswprintf(textBuffer, dataManager.GetSysString(1618), dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true; pc->is_highlighting = true;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stACMessage->setText(textBuffer); mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
pc->is_highlighting = false; pc->is_highlighting = false;
return true; return true;
...@@ -3321,7 +3321,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3321,7 +3321,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int dd = */BufferIO::ReadInt8(pbuf); /*int dd = */BufferIO::ReadInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
ClientCard* pcard = mainGame->dField.GetCard(ca, la, sa); ClientCard* pcard = mainGame->dField.GetCard(ca, la, sa);
if(aatk != pcard->attack) { if(aatk != pcard->attack) {
pcard->attack = aatk; pcard->attack = aatk;
...@@ -3342,7 +3342,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3342,7 +3342,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(pcard->defstring, L"%d", ddef); myswprintf(pcard->defstring, L"%d", ddef);
} }
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return true; return true;
} }
case MSG_ATTACK_DISABLED: { case MSG_ATTACK_DISABLED: {
...@@ -3377,11 +3377,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3377,11 +3377,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_COIN); soundManager.PlaySoundEffect(SOUND_COIN);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->stACMessage->setText(textBuffer); mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
return true; return true;
} }
...@@ -3400,11 +3400,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3400,11 +3400,11 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
soundManager.PlaySoundEffect(SOUND_DICE); soundManager.PlaySoundEffect(SOUND_DICE);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->AddLog(textBuffer); mainGame->AddLog(textBuffer);
mainGame->stACMessage->setText(textBuffer); mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(40); mainGame->WaitFrameSignal(40);
return true; return true;
} }
...@@ -3412,9 +3412,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3412,9 +3412,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
/*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); /*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->PopupElement(mainGame->wHand); mainGame->PopupElement(mainGame->wHand);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_HAND_RES: { case MSG_HAND_RES: {
...@@ -3448,10 +3448,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3448,10 +3448,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint)); myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(563)); else myswprintf(textBuffer, dataManager.GetSysString(563));
select_hint = 0; select_hint = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wANRace->setText(textBuffer); mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace); mainGame->PopupElement(mainGame->wANRace);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_ANNOUNCE_ATTRIB: { case MSG_ANNOUNCE_ATTRIB: {
...@@ -3468,10 +3468,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3468,10 +3468,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint)); myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(562)); else myswprintf(textBuffer, dataManager.GetSysString(562));
select_hint = 0; select_hint = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wANAttribute->setText(textBuffer); mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute); mainGame->PopupElement(mainGame->wANAttribute);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_ANNOUNCE_CARD: { case MSG_ANNOUNCE_CARD: {
...@@ -3484,18 +3484,18 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3484,18 +3484,18 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint)); myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, dataManager.GetSysString(564)); else myswprintf(textBuffer, dataManager.GetSysString(564));
select_hint = 0; select_hint = 0;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->ebANCard->setText(L""); mainGame->ebANCard->setText(L"");
mainGame->wANCard->setText(textBuffer); mainGame->wANCard->setText(textBuffer);
mainGame->dField.UpdateDeclarableList(); mainGame->dField.UpdateDeclarableList();
mainGame->PopupElement(mainGame->wANCard); mainGame->PopupElement(mainGame->wANCard);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_ANNOUNCE_NUMBER: { case MSG_ANNOUNCE_NUMBER: {
/*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf)); /*int player = */mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf); int count = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->cbANNumber->clear(); mainGame->cbANNumber->clear();
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int value = BufferIO::ReadInt32(pbuf); int value = BufferIO::ReadInt32(pbuf);
...@@ -3509,7 +3509,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3509,7 +3509,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
select_hint = 0; select_hint = 0;
mainGame->wANNumber->setText(textBuffer); mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber); mainGame->PopupElement(mainGame->wANNumber);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
return false; return false;
} }
case MSG_CARD_HINT: { case MSG_CARD_HINT: {
...@@ -3600,7 +3600,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3600,7 +3600,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
// //
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping)
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
if(mainGame->dField.deck[player].size() > mcount) { if(mainGame->dField.deck[player].size() > mcount) {
while(mainGame->dField.deck[player].size() > mcount) { while(mainGame->dField.deck[player].size() > mcount) {
ClientCard* ccard = *mainGame->dField.deck[player].rbegin(); ClientCard* ccard = *mainGame->dField.deck[player].rbegin();
...@@ -3648,7 +3648,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3648,7 +3648,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
mainGame->dField.extra_p_count[player] = pcount; mainGame->dField.extra_p_count[player] = pcount;
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping)
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
// //
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) { for (auto cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
...@@ -3681,7 +3681,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3681,7 +3681,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
break; break;
} }
case MSG_RELOAD_FIELD: { case MSG_RELOAD_FIELD: {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.duel_rule = BufferIO::ReadInt8(pbuf); mainGame->dInfo.duel_rule = BufferIO::ReadInt8(pbuf);
int val = 0; int val = 0;
...@@ -3789,7 +3789,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3789,7 +3789,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.last_chain = true; mainGame->dField.last_chain = true;
} }
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
} }
...@@ -3937,7 +3937,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) { ...@@ -3937,7 +3937,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
unsigned int ipaddr = bc_addr.sin_addr.s_addr; unsigned int ipaddr = bc_addr.sin_addr.s_addr;
HostPacket* pHP = (HostPacket*)buf; HostPacket* pHP = (HostPacket*)buf;
if(!is_closing && pHP->identifier == NETWORK_SERVER_ID && pHP->version == PRO_VERSION && remotes.find(ipaddr) == remotes.end() ) { if(!is_closing && pHP->identifier == NETWORK_SERVER_ID && pHP->version == PRO_VERSION && remotes.find(ipaddr) == remotes.end() ) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
remotes.insert(ipaddr); remotes.insert(ipaddr);
pHP->ipaddr = ipaddr; pHP->ipaddr = ipaddr;
hosts.push_back(*pHP); hosts.push_back(*pHP);
...@@ -3959,7 +3959,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) { ...@@ -3959,7 +3959,7 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
BufferIO::CopyWStr(pHP->name, gamename, 20); BufferIO::CopyWStr(pHP->name, gamename, 20);
hoststr.append(gamename); hoststr.append(gamename);
mainGame->lstHostList->addItem(hoststr.c_str()); mainGame->lstHostList->addItem(hoststr.c_str());
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
} }
} }
......
...@@ -817,7 +817,7 @@ void Game::MainLoop() { ...@@ -817,7 +817,7 @@ void Game::MainLoop() {
atkframe += 0.1f; atkframe += 0.1f;
atkdy = (float)sin(atkframe); atkdy = (float)sin(atkframe);
driver->beginScene(true, true, SColor(0, 0, 0, 0)); driver->beginScene(true, true, SColor(0, 0, 0, 0));
gMutex.Lock(); gMutex.lock();
if(dInfo.isStarted) { if(dInfo.isStarted) {
if(dInfo.isFinished && showcardcode == 1) if(dInfo.isFinished && showcardcode == 1)
soundManager.PlayBGM(BGM_WIN); soundManager.PlayBGM(BGM_WIN);
...@@ -846,7 +846,7 @@ void Game::MainLoop() { ...@@ -846,7 +846,7 @@ void Game::MainLoop() {
} }
DrawGUI(); DrawGUI();
DrawSpec(); DrawSpec();
gMutex.Unlock(); gMutex.unlock();
if(signalFrame > 0) { if(signalFrame > 0) {
signalFrame--; signalFrame--;
if(!signalFrame) if(!signalFrame)
......
...@@ -188,8 +188,7 @@ public: ...@@ -188,8 +188,7 @@ public:
void FlashWindow(); void FlashWindow();
void SetCursor(ECURSOR_ICON icon); void SetCursor(ECURSOR_ICON icon);
Mutex gMutex; std::mutex gMutex;
Mutex gBuffer;
Signal frameSignal; Signal frameSignal;
Signal actionSignal; Signal actionSignal;
Signal replaySignal; Signal replaySignal;
......
...@@ -80,10 +80,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -80,10 +80,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
hints.ai_flags = EVUTIL_AI_ADDRCONFIG; hints.ai_flags = EVUTIL_AI_ADDRCONFIG;
int status = evutil_getaddrinfo(hostname, port, &hints, &answer); int status = evutil_getaddrinfo(hostname, port, &hints, &answer);
if(status != 0) { if(status != 0) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO); soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} else { } else {
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr); sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
...@@ -245,12 +245,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -245,12 +245,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected(); int sel = mainGame->lstReplayList->getSelected();
if(sel == -1) if(sel == -1)
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
wchar_t textBuffer[256]; wchar_t textBuffer[256];
myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363)); myswprintf(textBuffer, L"%ls\n%ls", mainGame->lstReplayList->getListItem(sel), dataManager.GetSysString(1363));
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
prev_sel = sel; prev_sel = sel;
break; break;
...@@ -259,11 +259,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -259,11 +259,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int sel = mainGame->lstReplayList->getSelected(); int sel = mainGame->lstReplayList->getSelected();
if(sel == -1) if(sel == -1)
break; break;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->wReplaySave->setText(dataManager.GetSysString(1364)); mainGame->wReplaySave->setText(dataManager.GetSysString(1364));
mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel)); mainGame->ebRSName->setText(mainGame->lstReplayList->getListItem(sel));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
prev_operation = id; prev_operation = id;
prev_sel = sel; prev_sel = sel;
break; 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
...@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() { ...@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() {
exit_pending = false; exit_pending = false;
current_step = 0; current_step = 0;
if(mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplaySkiping)
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
while (is_continuing && !exit_pending) { while (is_continuing && !exit_pending) {
int result = process(pduel); int result = process(pduel);
int len = result & 0xffff; int len = result & 0xffff;
...@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() { ...@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() {
get_message(pduel, (byte*)engineBuffer); get_message(pduel, (byte*)engineBuffer);
is_continuing = ReplayAnalyze(engineBuffer, len); is_continuing = ReplayAnalyze(engineBuffer, len);
if(is_restarting) { if(is_restarting) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
is_restarting = false; is_restarting = false;
mainGame->dInfo.isReplaySkiping = true; mainGame->dInfo.isReplaySkiping = true;
Restart(false); Restart(false);
...@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() { ...@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() {
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
skip_step = step; skip_step = step;
current_step = 0; current_step = 0;
...@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() { ...@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() {
if(mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
EndDuel(); EndDuel();
return 0; return 0;
...@@ -231,26 +231,26 @@ void ReplayMode::EndDuel() { ...@@ -231,26 +231,26 @@ void ReplayMode::EndDuel() {
end_duel(pduel); end_duel(pduel);
if(!is_closing) { if(!is_closing) {
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501)); mainGame->stMessage->setText(dataManager.GetSysString(1501));
if(mainGame->wCardSelect->isVisible()) if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.isReplay = false; mainGame->dInfo.isReplay = false;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->ShowElement(mainGame->wReplay); mainGame->ShowElement(mainGame->wReplay);
mainGame->stTip->setVisible(false); mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
} }
...@@ -294,9 +294,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -294,9 +294,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
return true; return true;
} }
if(is_swaping) { if(is_swaping) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.ReplaySwap(); mainGame->dField.ReplaySwap();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
is_swaping = false; is_swaping = false;
} }
char* offset = pbuf; char* offset = pbuf;
...@@ -307,12 +307,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -307,12 +307,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(L"Error occurs."); mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
return false; return false;
...@@ -326,7 +326,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -326,7 +326,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(mainGame->dInfo.isReplaySkiping) { if(mainGame->dInfo.isReplaySkiping) {
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
pbuf += 2; pbuf += 2;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
...@@ -508,7 +508,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -508,7 +508,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if(skip_turn == 0) { if(skip_turn == 0) {
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
} }
player = BufferIO::ReadInt8(pbuf); player = BufferIO::ReadInt8(pbuf);
...@@ -845,7 +845,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -845,7 +845,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->dInfo.isReplaySkiping = false; mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
} }
} }
if(is_pausing) { if(is_pausing) {
......
...@@ -79,7 +79,7 @@ int SingleMode::SinglePlayThread() { ...@@ -79,7 +79,7 @@ int SingleMode::SinglePlayThread() {
rh.version = PRO_VERSION; rh.version = PRO_VERSION;
rh.flag = REPLAY_SINGLE_MODE; rh.flag = REPLAY_SINGLE_MODE;
rh.seed = seed; rh.seed = seed;
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ClearCardInfo(); mainGame->ClearCardInfo();
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
...@@ -93,7 +93,7 @@ int SingleMode::SinglePlayThread() { ...@@ -93,7 +93,7 @@ int SingleMode::SinglePlayThread() {
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->dInfo.isSingleMode = true; mainGame->dInfo.isSingleMode = true;
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
char engineBuffer[0x1000]; char engineBuffer[0x1000];
is_closing = false; is_closing = false;
is_continuing = true; is_continuing = true;
...@@ -125,7 +125,7 @@ int SingleMode::SinglePlayThread() { ...@@ -125,7 +125,7 @@ int SingleMode::SinglePlayThread() {
} }
} }
last_replay.EndRecord(); last_replay.EndRecord();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
time_t nowtime = time(NULL); time_t nowtime = time(NULL);
tm* localedtime = localtime(&nowtime); tm* localedtime = localtime(&nowtime);
wchar_t timetext[40]; wchar_t timetext[40];
...@@ -134,7 +134,7 @@ int SingleMode::SinglePlayThread() { ...@@ -134,7 +134,7 @@ int SingleMode::SinglePlayThread() {
if(!mainGame->chkAutoSaveReplay->isChecked()) { if(!mainGame->chkAutoSaveReplay->isChecked()) {
mainGame->wReplaySave->setText(dataManager.GetSysString(1340)); mainGame->wReplaySave->setText(dataManager.GetSysString(1340));
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->replaySignal.Reset(); mainGame->replaySignal.Reset();
mainGame->replaySignal.Wait(); mainGame->replaySignal.Wait();
} else { } else {
...@@ -143,26 +143,26 @@ int SingleMode::SinglePlayThread() { ...@@ -143,26 +143,26 @@ int SingleMode::SinglePlayThread() {
myswprintf(msgbuf, dataManager.GetSysString(1367), timetext); myswprintf(msgbuf, dataManager.GetSysString(1367), timetext);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf); mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, msgbuf);
mainGame->PopupElement(mainGame->wACMessage, 20); mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->WaitFrameSignal(30); mainGame->WaitFrameSignal(30);
} }
if(mainGame->actionParam) if(mainGame->actionParam)
last_replay.SaveReplay(mainGame->ebRSName->getText()); last_replay.SaveReplay(mainGame->ebRSName->getText());
end_duel(pduel); end_duel(pduel);
if(!is_closing) { if(!is_closing) {
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true; mainGame->dInfo.isFinished = true;
mainGame->dInfo.isSingleMode = false; mainGame->dInfo.isSingleMode = false;
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->closeDoneSignal.Reset(); mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set(); mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait(); mainGame->closeDoneSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->ShowElement(mainGame->wSinglePlay); mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->stTip->setVisible(false); mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
} }
...@@ -732,9 +732,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -732,9 +732,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf++; pbuf++;
DuelClient::ClientAnalyze(offset, pbuf - offset); DuelClient::ClientAnalyze(offset, pbuf - offset);
SinglePlayReload(); SinglePlayReload();
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->dField.RefreshAllCards(); mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
break; break;
} }
case MSG_AI_NAME: { case MSG_AI_NAME: {
...@@ -756,10 +756,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -756,10 +756,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf += len + 1; pbuf += len + 1;
memcpy(msgbuf, begin, len + 1); memcpy(msgbuf, begin, len + 1);
BufferIO::DecodeUTF8(msgbuf, msg); BufferIO::DecodeUTF8(msgbuf, msg);
mainGame->gMutex.Lock(); mainGame->gMutex.lock();
mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->guiFont, msg); mainGame->SetStaticText(mainGame->stMessage, 310, mainGame->guiFont, msg);
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
break; break;
......
...@@ -582,6 +582,10 @@ ...@@ -582,6 +582,10 @@
!counter 0x104f 蛊指示物 !counter 0x104f 蛊指示物
!counter 0x50 指示物(娱乐伙伴 掉头跑骑兵) !counter 0x50 指示物(娱乐伙伴 掉头跑骑兵)
!counter 0x51 指示物(蜂军巢) !counter 0x51 指示物(蜂军巢)
!counter 0x52 指示物(防火龙·暗流体)
!counter 0x53 指示物(炽天蝶)
!counter 0x54 指示物(星遗物引导的前路)
!counter 0x55 指示物(隐居者的大釜)
#setnames, using tab for comment #setnames, using tab for comment
!setname 0x1 正义盟军 AOJ !setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス !setname 0x2 次世代 ジェネクス
...@@ -970,3 +974,5 @@ ...@@ -970,3 +974,5 @@
!setname 0x12d 斯摩夫 シムルグ !setname 0x12d 斯摩夫 シムルグ
!setname 0x12e 占卜魔女 占い魔女 !setname 0x12e 占卜魔女 占い魔女
!setname 0x12f 蜂军 BF(ビー・フォース) !setname 0x12f 蜂军 BF(ビー・フォース)
!setname 0x130 破械
!setname 0x1130 破械神
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