Commit b7f858f3 authored by IMJoyJ's avatar IMJoyJ Committed by nanahira

auto_watch_mode fix (#20)

* 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
parent c6bfe3d8
......@@ -984,7 +984,7 @@ void Game::DrawSpec() {
break;
}
}
if (auto_watch_mode && showcardp < 8 && showcardp > 0 && showcardcode > 100) {
if (auto_watch_mode && showcardcode > 9999 && (showcardcode & 0xFFFCFFFC) > 0) {
mainGame->ShowCardInfo(showcardcode);
}
}
......
......@@ -190,6 +190,10 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
} else if(connect_state == 0x7) {
if(!mainGame->dInfo.isStarted && !mainGame->is_building) {
mainGame->btnCreateHost->setEnabled(true);
......@@ -209,6 +213,10 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1401));
else mainGame->env->addMessageBox(L"", dataManager.GetSysString(1402));
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
} else {
mainGame->gMutex.lock();
soundManager.PlaySoundEffect(SOUND_INFO);
......@@ -220,6 +228,10 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->btnBotCancel->setEnabled(true);
mainGame->stTip->setVisible(false);
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait();
......@@ -237,8 +249,6 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
}
}
event_base_loopexit(client_base, 0);
if(exit_on_return && auto_watch_mode)
mainGame->device->closeDevice();
}
}
int DuelClient::ClientThread() {
......@@ -280,6 +290,10 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
else if(pkt->code == 2)
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1405));
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
event_base_loopbreak(client_base);
break;
}
......@@ -736,16 +750,20 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.isReplaySkiping = false;
mainGame->wSurrender->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500));
if(!auto_watch_mode) {
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
else {
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.lock();
}
mainGame->closeDoneSignal.Reset();
mainGame->closeSignal.Set();
mainGame->closeDoneSignal.Wait();
mainGame->gMutex.lock();
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = true;
mainGame->dInfo.announce_cache.clear();
......@@ -3002,6 +3020,8 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.current_chain.chain_pos.X += 0.35f;
else
mainGame->dField.current_chain.chain_pos.Y += chc * 0.25f;
if (auto_watch_mode && (mainGame->dField.current_chain.chain_card->location & LOCATION_ONFIELD))
mainGame->ShowCardInfo(mainGame->dField.current_chain.chain_card->code);
return true;
}
case MSG_CHAINED: {
......@@ -3105,7 +3125,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int s = BufferIO::ReadInt8(pbuf);
/*int ss = */BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
if (auto_watch_mode && i == 0) {
if (auto_watch_mode && i == 0 && (pcard->position & POS_FACEUP) && (pcard->location & LOCATION_ONFIELD)) {
mainGame->ShowCardInfo(pcard->code);
}
pcard->is_highlighting = true;
......
......@@ -86,6 +86,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1412));
mainGame->gMutex.unlock();
if (auto_watch_mode) {
mainGame->actionSignal.Wait(2000);
mainGame->device->closeDevice();
}
break;
} else {
sockaddr_in * sin = ((struct sockaddr_in *)answer->ai_addr);
......
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