Commit 055b523f authored by nanahira's avatar nanahira

really retrying one when MSG_RETRY

parent 7476a432
......@@ -25,6 +25,9 @@ char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false;
int DuelClient::select_hint = 0;
int DuelClient::select_unselect_hint = 0;
int DuelClient::last_select_hint = 0;
char DuelClient::last_successful_msg[2048];
unsigned int DuelClient::last_successful_msg_length = 0;
wchar_t DuelClient::event_string[256];
mtrandom DuelClient::rnd;
......@@ -955,10 +958,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
}
int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
char* pbuf = msg;
wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
if(mainGame->dInfo.curMsg != MSG_RETRY && !retry) {
memcpy(last_successful_msg, msg, len);
last_successful_msg_length = len;
}
mainGame->wCmdMenu->setVisible(false);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.curMsg != MSG_WAITING && mainGame->dInfo.curMsg != MSG_CARD_SELECTED) {
mainGame->waitFrame = -1;
......@@ -980,6 +987,17 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.time_player = 2;
switch(mainGame->dInfo.curMsg) {
case MSG_RETRY: {
if(!retry && last_successful_msg_length) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(dataManager.GetDesc(1422));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
select_hint = last_select_hint;
ClientAnalyze(last_successful_msg, last_successful_msg_length, true);
break;
}
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
......@@ -1031,6 +1049,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_SELECTMSG: {
select_hint = data;
last_select_hint = data;
break;
}
case HINT_OPSELECTED: {
......@@ -1218,8 +1237,13 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.Initial(mainGame->LocalPlayer(1), deckc, extrac);
mainGame->dInfo.turn = 0;
mainGame->dInfo.is_shuffling = false;
mainGame->dInfo.is_swapped = false;
if(mainGame->dInfo.isReplaySwapped) {
mainGame->dInfo.is_swapped = false;
select_hint = 0;
select_unselect_hint = 0;
last_select_hint = 0;
last_successful_msg_length = 0;
if (mainGame->dInfo.isReplaySwapped)
{
std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname);
std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag);
mainGame->dInfo.isReplaySwapped = false;
......
......@@ -31,6 +31,9 @@ private:
static bool is_closing;
static int select_hint;
static int select_unselect_hint;
static int last_select_hint;
static char last_successful_msg[2048];
static unsigned int last_successful_msg_length;
static wchar_t event_string[256];
static mtrandom rnd;
public:
......@@ -46,7 +49,7 @@ public:
static void ClientEvent(bufferevent *bev, short events, void *ctx);
static int ClientThread(void* param);
static void HandleSTOCPacketLan(char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len, bool retry = false);
static void SetResponseI(int respI);
static void SetResponseB(void* respB, unsigned char len);
static void SendResponse();
......
......@@ -448,6 +448,7 @@
!system 1419 副卡组数量应不超过15张,当前卡组数量为%d张。
!system 1420 有额外卡组卡片存在于主卡组,可能是额外卡组数量超过15张。
!system 1421 宣言的卡不符合条件,或无法被主机识别。
!system 1422 操作无效,请重试。
!system 1450 卡包展示
!system 1451 人机卡组
!system 1452 未分类卡组
......
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