Commit 8049c367 authored by IMJoyJ's avatar IMJoyJ Committed by GitHub

auto-watch mode improve (#25)

* fix the white card bug in auto_watch_mode;
Game::DrawSpec improvement in auto_watch_mode

* fix

* improve auto_watch_mode behavior when connection failed; fix DrawSpec function bug

* auto_watch_mode visual effect rework

* no longer use ShowCardInfo in auto_watch_mode

* Exit program in auto_watch_mode when connect time out

* improve auto-watch mode
Co-authored-by: JoyJ's avatarJoy J <316351048@qq.com>
Co-authored-by: nanahira's avatarNanahira <78877@qq.com>
parent d0547c04
...@@ -77,6 +77,9 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g ...@@ -77,6 +77,9 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
return true; return true;
} }
void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) { void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
if (auto_watch_mode) {
mainGame->device->closeDevice();
}
if(connect_state == 0x7) if(connect_state == 0x7)
return; return;
if(!is_closing) { if(!is_closing) {
...@@ -2143,6 +2146,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2143,6 +2146,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard = *(mainGame->dField.deck[player].rbegin() + i); pcard = *(mainGame->dField.deck[player].rbegin() + i);
if (code != 0) if (code != 0)
pcard->SetCode(code); pcard->SetCode(code);
if (auto_watch_mode && code > 0) {
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcardp = 0;
mainGame->showcard = 4;
}
} }
if(mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplaySkiping)
return true; return true;
...@@ -2181,6 +2190,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2181,6 +2190,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
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]);
if (code != 0) if (code != 0)
pcard->SetCode(code); pcard->SetCode(code);
if (auto_watch_mode && code > 0) {
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcardp = 0;
mainGame->showcard = 4;
}
} }
if(mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplaySkiping)
return true; return true;
...@@ -2232,6 +2247,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2232,6 +2247,12 @@ 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);
if (auto_watch_mode && code > 0) {
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcardp = 0;
mainGame->showcard = 4;
}
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);
...@@ -3454,14 +3475,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3454,14 +3475,10 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int count = BufferIO::ReadInt16(pbuf); int count = BufferIO::ReadInt16(pbuf);
ClientCard* pc = mainGame->dField.GetCard(c, l, s); ClientCard* pc = mainGame->dField.GetCard(c, l, s);
if (auto_watch_mode && pc->code > 0) { if (auto_watch_mode && pc->code > 0) {
myswprintf(event_string, dataManager.GetSysString(1610), dataManager.GetName(pc->code));
mainGame->showcardcode = pc->code; mainGame->showcardcode = pc->code;
mainGame->showcarddif = 0; mainGame->showcarddif = 0;
mainGame->showcardp = 0; mainGame->showcardp = 0;
mainGame->showcard = 5; mainGame->showcard = 2;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(11);
} }
if (pc->counters.count(type)) if (pc->counters.count(type))
pc->counters[type] += count; pc->counters[type] += count;
......
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