Commit 7bb284cc authored by nanahira's avatar nanahira

Merge branch 'retry_fh'

parents 8e67045d 27649ddb
...@@ -962,7 +962,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) { ...@@ -962,7 +962,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
char* pbuf = msg; char* pbuf = msg;
wchar_t textBuffer[256]; wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf); mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
if(mainGame->dInfo.curMsg != MSG_RETRY && !retry) { if(mainGame->dInfo.curMsg != MSG_RETRY) {
memcpy(last_successful_msg, msg, len); memcpy(last_successful_msg, msg, len);
last_successful_msg_length = len; last_successful_msg_length = len;
} }
...@@ -987,16 +987,32 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) { ...@@ -987,16 +987,32 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
mainGame->dInfo.time_player = 2; mainGame->dInfo.time_player = 2;
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
case MSG_RETRY: { case MSG_RETRY: {
<<<<<<< HEAD
if(!retry && last_successful_msg_length) { if(!retry && last_successful_msg_length) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->stMessage->setText(dataManager.GetDesc(1422)); mainGame->stMessage->setText(dataManager.GetDesc(1422));
=======
if(last_successful_msg_length) {
char* p = last_successful_msg;
auto last_msg = BufferIO::ReadUInt8(p);
int err_desc = 1422;
switch(last_msg) {
case MSG_ANNOUNCE_CARD:
case MSG_ANNOUNCE_CARD_FILTER:
err_desc = 1421;
//TODO: other cases
default:
break;
}
mainGame->gMutex.Lock();
mainGame->stMessage->setText(dataManager.GetDesc(err_desc));
>>>>>>> retry_fh
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;
ClientAnalyze(last_successful_msg, last_successful_msg_length, true); return ClientAnalyze(last_successful_msg, last_successful_msg_length);
break;
} }
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs."); mainGame->stMessage->setText(L"Error occurs.");
...@@ -1004,27 +1020,29 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) { ...@@ -1004,27 +1020,29 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
mainGame->closeDoneSignal.Reset(); if(!mainGame->dInfo.isSingleMode) {
mainGame->closeSignal.Set(); mainGame->closeDoneSignal.Reset();
mainGame->closeDoneSignal.Wait(); mainGame->closeSignal.Set();
mainGame->gMutex.Lock(); mainGame->closeDoneSignal.Wait();
mainGame->dInfo.isStarted = false; mainGame->gMutex.Lock();
mainGame->dInfo.isFinished = false; mainGame->dInfo.isStarted = false;
mainGame->btnCreateHost->setEnabled(true); mainGame->dInfo.isFinished = false;
mainGame->btnJoinHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnStartBot->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->btnBotCancel->setEnabled(true); mainGame->btnStartBot->setEnabled(true);
mainGame->stTip->setVisible(false); mainGame->btnBotCancel->setEnabled(true);
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->stTip->setVisible(false);
if(bot_mode) mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->ShowElement(mainGame->wSinglePlay); if(bot_mode)
else mainGame->ShowElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wLanWindow); else
mainGame->gMutex.Unlock(); mainGame->ShowElement(mainGame->wLanWindow);
event_base_loopbreak(client_base); mainGame->gMutex.Unlock();
if(exit_on_return) event_base_loopbreak(client_base);
mainGame->device->closeDevice(); if(exit_on_return)
mainGame->device->closeDevice();
}
return false; return false;
} }
case MSG_HINT: { case MSG_HINT: {
...@@ -1242,8 +1260,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) { ...@@ -1242,8 +1260,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
select_unselect_hint = 0; select_unselect_hint = 0;
last_select_hint = 0; last_select_hint = 0;
last_successful_msg_length = 0; last_successful_msg_length = 0;
if (mainGame->dInfo.isReplaySwapped) if(mainGame->dInfo.isReplaySwapped) {
{
std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname); std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname);
std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag); std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag);
mainGame->dInfo.isReplaySwapped = false; mainGame->dInfo.isReplaySwapped = false;
......
...@@ -182,13 +182,11 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -182,13 +182,11 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf); mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
switch (mainGame->dInfo.curMsg) { switch (mainGame->dInfo.curMsg) {
case MSG_RETRY: { case MSG_RETRY: {
mainGame->gMutex.Lock(); if(!DuelClient::ClientAnalyze(offset, pbuf - offset)) {
mainGame->stMessage->setText(L"Error occurs."); mainGame->singleSignal.Reset();
mainGame->PopupElement(mainGame->wMessage); mainGame->singleSignal.Wait();
mainGame->gMutex.Unlock(); }
mainGame->actionSignal.Reset(); break;
mainGame->actionSignal.Wait();
return false;
} }
case MSG_HINT: { case MSG_HINT: {
/*int type = */BufferIO::ReadInt8(pbuf); /*int type = */BufferIO::ReadInt8(pbuf);
......
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