Commit 6dcb7a3f authored by argon.sun's avatar argon.sun

fix

parent 1308d53b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "materials.h" #include "materials.h"
#include "image_manager.h" #include "image_manager.h"
#include "deck_manager.h" #include "deck_manager.h"
#include "duelclient.h"
#include "../ocgcore/field.h" #include "../ocgcore/field.h"
namespace ygo { namespace ygo {
...@@ -442,7 +443,7 @@ void Game::DrawGUI() { ...@@ -442,7 +443,7 @@ void Game::DrawGUI() {
fu.guiFading->setRelativePosition(irr::core::recti(fu.fadingUL, fu.fadingLR)); fu.guiFading->setRelativePosition(irr::core::recti(fu.fadingUL, fu.fadingLR));
} }
if(fu.signalAction && !fu.fadingFrame) { if(fu.signalAction && !fu.fadingFrame) {
localAction.Set(); DuelClient::SendResponse();
fu.signalAction = false; fu.signalAction = false;
} }
} }
......
...@@ -401,8 +401,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -401,8 +401,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
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->localAction.Reset(); mainGame->actionSignal.Reset();
mainGame->localAction.Wait(); mainGame->actionSignal.Wait();
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->CloseDuelWindow(); mainGame->CloseDuelWindow();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
...@@ -521,8 +521,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -521,8 +521,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
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->localAction.Reset(); mainGame->actionSignal.Reset();
mainGame->localAction.Wait(); mainGame->actionSignal.Wait();
break; break;
} }
case HINT_SELECTMSG: { case HINT_SELECTMSG: {
...@@ -715,12 +715,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -715,12 +715,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->btnEP->setPressed(false); mainGame->btnEP->setPressed(false);
} }
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearCommandFlag();
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_IDLECMD: { case MSG_SELECT_IDLECMD: {
...@@ -820,12 +814,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -820,12 +814,6 @@ 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->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearCommandFlag();
mainGame->btnBP->setVisible(false);
mainGame->btnEP->setVisible(false);
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
...@@ -843,9 +831,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -843,9 +831,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_YESNO: { case MSG_SELECT_YESNO: {
...@@ -855,9 +840,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -855,9 +840,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc)); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_OPTION: { case MSG_SELECT_OPTION: {
...@@ -881,9 +863,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -881,9 +863,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->wOptions->setText(textBuffer); mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions); mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_CARD: { case MSG_SELECT_CARD: {
...@@ -932,10 +911,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -932,10 +911,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
} }
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_CHAIN: { case MSG_SELECT_CHAIN: {
...@@ -982,10 +957,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -982,10 +957,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer); mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery); mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearChainSelect();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_PLACE: case MSG_SELECT_PLACE:
...@@ -1030,9 +1001,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1030,9 +1001,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
DuelClient::SendResponse(); DuelClient::SendResponse();
return true; return true;
} }
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_POSITION: { case MSG_SELECT_POSITION: {
...@@ -1076,9 +1044,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1076,9 +1044,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->PopupElement(mainGame->wPosSelect); mainGame->PopupElement(mainGame->wPosSelect);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_TRIBUTE: { case MSG_SELECT_TRIBUTE: {
...@@ -1108,10 +1073,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1108,10 +1073,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
} }
mainGame->stHintMsg->setText(dataManager.GetSysString(531)); mainGame->stHintMsg->setText(dataManager.GetSysString(531));
mainGame->stHintMsg->setVisible(false); mainGame->stHintMsg->setVisible(false);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_COUNTER: { case MSG_SELECT_COUNTER: {
...@@ -1138,10 +1099,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1138,10 +1099,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SELECT_SUM: { case MSG_SELECT_SUM: {
...@@ -1183,13 +1140,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1183,13 +1140,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer); mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true); mainGame->stHintMsg->setVisible(true);
} }
mainGame->localAction.Reset();
mainGame->localAction.Wait();
for(int i = 0; i < mainGame->dField.selectsum_all.size(); ++i) {
mainGame->dField.selectsum_all[i]->is_selectable = false;
mainGame->dField.selectsum_all[i]->is_selected = false;
}
DuelClient::SendResponse();
return true; return true;
} }
case MSG_SORT_CARD: case MSG_SORT_CARD:
...@@ -1225,9 +1175,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1225,9 +1175,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.select_min = 0; mainGame->dField.select_min = 0;
mainGame->dField.select_max = count; mainGame->dField.select_max = count;
mainGame->dField.ShowSelectCard(); mainGame->dField.ShowSelectCard();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_CONFIRM_DECKTOP: { case MSG_CONFIRM_DECKTOP: {
...@@ -1337,8 +1284,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -1337,8 +1284,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.selectable_cards = panel_confirm; mainGame->dField.selectable_cards = panel_confirm;
mainGame->dField.ShowSelectCard(true); mainGame->dField.ShowSelectCard(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset(); mainGame->actionSignal.Reset();
mainGame->localAction.Wait(); mainGame->actionSignal.Wait();
} }
return true; return true;
} }
...@@ -2301,9 +2248,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2301,9 +2248,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->wANRace->setText(textBuffer); mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace); mainGame->PopupElement(mainGame->wANRace);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_ANNOUNCE_ATTRIB: { case MSG_ANNOUNCE_ATTRIB: {
...@@ -2324,9 +2268,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2324,9 +2268,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->wANAttribute->setText(textBuffer); mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute); mainGame->PopupElement(mainGame->wANAttribute);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_ANNOUNCE_CARD: { case MSG_ANNOUNCE_CARD: {
...@@ -2340,9 +2281,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2340,9 +2281,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->wANCard->setText(textBuffer); mainGame->wANCard->setText(textBuffer);
mainGame->PopupElement(mainGame->wANCard); mainGame->PopupElement(mainGame->wANCard);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_ANNOUNCE_NUMBER: { case MSG_ANNOUNCE_NUMBER: {
...@@ -2363,9 +2301,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) { ...@@ -2363,9 +2301,6 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->wANNumber->setText(textBuffer); mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber); mainGame->PopupElement(mainGame->wANNumber);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
DuelClient::SendResponse();
return true; return true;
} }
case MSG_CARD_HINT: { case MSG_CARD_HINT: {
...@@ -2405,6 +2340,43 @@ void DuelClient::SetResponseB(unsigned char* respB, unsigned char len) { ...@@ -2405,6 +2340,43 @@ void DuelClient::SetResponseB(unsigned char* respB, unsigned char len) {
response_len = len; response_len = len;
} }
void DuelClient::SendResponse() { void DuelClient::SendResponse() {
switch(mainGame->dInfo.curMsg) {
case MSG_SELECT_BATTLECMD: {
mainGame->dField.ClearCommandFlag();
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
break;
}
case MSG_SELECT_IDLECMD: {
mainGame->dField.ClearCommandFlag();
mainGame->btnBP->setVisible(false);
mainGame->btnEP->setVisible(false);
break;
}
case MSG_SELECT_CARD: {
mainGame->dField.ClearSelect();
break;
}
case MSG_SELECT_CHAIN: {
mainGame->dField.ClearChainSelect();
break;
}
case MSG_SELECT_TRIBUTE: {
mainGame->dField.ClearSelect();
break;
}
case MSG_SELECT_COUNTER: {
mainGame->dField.ClearSelect();
break;
}
case MSG_SELECT_SUM: {
for(int i = 0; i < mainGame->dField.selectsum_all.size(); ++i) {
mainGame->dField.selectsum_all[i]->is_selectable = false;
mainGame->dField.selectsum_all[i]->is_selected = false;
}
break;
}
}
SendBufferToServer(CTOS_RESPONSE, response_buf, response_len); SendBufferToServer(CTOS_RESPONSE, response_buf, response_len);
} }
void DuelClient::BeginRefreshHost() { void DuelClient::BeginRefreshHost() {
......
...@@ -106,12 +106,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -106,12 +106,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
DuelClient::SendPacketToServer(CTOS_SURRENDER); DuelClient::SendPacketToServer(CTOS_SURRENDER);
if(panel) if(panel)
mainGame->HideElement(panel); mainGame->HideElement(panel);
mainGame->localAction.Set();
} }
break; break;
} }
case BUTTON_MSG_OK: { case BUTTON_MSG_OK: {
mainGame->HideElement(mainGame->wMessage, true); mainGame->HideElement(mainGame->wMessage);
mainGame->actionSignal.Set();
break; break;
} }
case BUTTON_YES: { case BUTTON_YES: {
...@@ -254,7 +254,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -254,7 +254,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} else { } else {
DuelClient::SetResponseI(index); DuelClient::SetResponseI(index);
} }
mainGame->localAction.Set(); DuelClient::SendResponse();
} else { } else {
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[0])); mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(select_options[0]));
selected_option = 0; selected_option = 0;
...@@ -305,7 +305,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -305,7 +305,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(summonable_cards[i] == clicked_card) { if(summonable_cards[i] == clicked_card) {
ClearCommandFlag(); ClearCommandFlag();
DuelClient::SetResponseI(i << 16); DuelClient::SetResponseI(i << 16);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -320,7 +320,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -320,7 +320,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(spsummonable_cards[i] == clicked_card) { if(spsummonable_cards[i] == clicked_card) {
ClearCommandFlag(); ClearCommandFlag();
DuelClient::SetResponseI((i << 16) + 1); DuelClient::SetResponseI((i << 16) + 1);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -359,7 +359,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -359,7 +359,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < msetable_cards.size(); ++i) { for(int i = 0; i < msetable_cards.size(); ++i) {
if(msetable_cards[i] == clicked_card) { if(msetable_cards[i] == clicked_card) {
DuelClient::SetResponseI((i << 16) + 3); DuelClient::SetResponseI((i << 16) + 3);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -372,7 +372,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -372,7 +372,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < ssetable_cards.size(); ++i) { for(int i = 0; i < ssetable_cards.size(); ++i) {
if(ssetable_cards[i] == clicked_card) { if(ssetable_cards[i] == clicked_card) {
DuelClient::SetResponseI((i << 16) + 4); DuelClient::SetResponseI((i << 16) + 4);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -385,7 +385,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -385,7 +385,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < reposable_cards.size(); ++i) { for(int i = 0; i < reposable_cards.size(); ++i) {
if(reposable_cards[i] == clicked_card) { if(reposable_cards[i] == clicked_card) {
DuelClient::SetResponseI((i << 16) + 2); DuelClient::SetResponseI((i << 16) + 2);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -398,7 +398,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -398,7 +398,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for(int i = 0; i < attackable_cards.size(); ++i) { for(int i = 0; i < attackable_cards.size(); ++i) {
if(attackable_cards[i] == clicked_card) { if(attackable_cards[i] == clicked_card) {
DuelClient::SetResponseI((i << 16) + 1); DuelClient::SetResponseI((i << 16) + 1);
mainGame->localAction.Set(); DuelClient::SendResponse();
break; break;
} }
} }
...@@ -445,24 +445,24 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -445,24 +445,24 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case BUTTON_BP: { case BUTTON_BP: {
if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI(6); DuelClient::SetResponseI(6);
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
break; break;
} }
case BUTTON_M2: { case BUTTON_M2: {
if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
DuelClient::SetResponseI(2); DuelClient::SetResponseI(2);
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
break; break;
} }
case BUTTON_EP: { case BUTTON_EP: {
if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) { if(mainGame->dInfo.curMsg == MSG_SELECT_BATTLECMD) {
DuelClient::SetResponseI(3); DuelClient::SetResponseI(3);
mainGame->localAction.Set(); DuelClient::SendResponse();
} else if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) { } else if(mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD) {
DuelClient::SetResponseI(7); DuelClient::SetResponseI(7);
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
break; break;
} }
...@@ -613,7 +613,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -613,7 +613,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} else if(mainGame->dInfo.curMsg == MSG_CONFIRM_CARDS) { } else if(mainGame->dInfo.curMsg == MSG_CONFIRM_CARDS) {
mainGame->HideElement(mainGame->wCardSelect, true); mainGame->HideElement(mainGame->wCardSelect);
mainGame->actionSignal.Set();
break; break;
} else { } else {
mainGame->HideElement(mainGame->wCardSelect); mainGame->HideElement(mainGame->wCardSelect);
...@@ -957,7 +958,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -957,7 +958,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
selectable_field = 0; selectable_field = 0;
selected_field = 0; selected_field = 0;
DuelClient::SetResponseB(respbuf, p); DuelClient::SetResponseB(respbuf, p);
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
} }
} }
...@@ -989,7 +990,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -989,7 +990,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for (int i = 0; i < selected_cards.size(); ++i) for (int i = 0; i < selected_cards.size(); ++i)
respbuf[i + 1] = selected_cards[i]->select_seq; respbuf[i + 1] = selected_cards[i]->select_seq;
DuelClient::SetResponseB(respbuf, selected_cards.size() + 1); DuelClient::SetResponseB(respbuf, selected_cards.size() + 1);
mainGame->localAction.Set(); DuelClient::SendResponse();
} else if (max >= select_min) { } else if (max >= select_min) {
if(selected_cards.size() == selectable_cards.size()) { if(selected_cards.size() == selectable_cards.size()) {
unsigned char respbuf[64]; unsigned char respbuf[64];
...@@ -997,7 +998,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -997,7 +998,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for (int i = 0; i < selected_cards.size(); ++i) for (int i = 0; i < selected_cards.size(); ++i)
respbuf[i + 1] = selected_cards[i]->select_seq; respbuf[i + 1] = selected_cards[i]->select_seq;
DuelClient::SetResponseB(respbuf, selected_cards.size() + 1); DuelClient::SetResponseB(respbuf, selected_cards.size() + 1);
mainGame->localAction.Set(); DuelClient::SendResponse();
} else { } else {
select_ready = true; select_ready = true;
if(mainGame->dInfo.curMsg == MSG_SELECT_TRIBUTE) { if(mainGame->dInfo.curMsg == MSG_SELECT_TRIBUTE) {
...@@ -1028,7 +1029,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1028,7 +1029,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->stHintMsg->setVisible(false); mainGame->stHintMsg->setVisible(false);
ClearSelect(); ClearSelect();
DuelClient::SetResponseB(respbuf, selectable_cards.size()); DuelClient::SetResponseB(respbuf, selectable_cards.size());
mainGame->localAction.Set(); DuelClient::SendResponse();
} else { } else {
myswprintf(formatBuffer, dataManager.GetSysString(204), select_counter_count, dataManager.GetCounterName(select_counter_type)); myswprintf(formatBuffer, dataManager.GetSysString(204), select_counter_count, dataManager.GetCounterName(select_counter_type));
mainGame->stHintMsg->setText(formatBuffer); mainGame->stHintMsg->setText(formatBuffer);
...@@ -1052,7 +1053,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1052,7 +1053,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for (int i = 0; i < selected_cards.size(); ++i) for (int i = 0; i < selected_cards.size(); ++i)
respbuf[i + 1] = selected_cards[i]->select_seq; respbuf[i + 1] = selected_cards[i]->select_seq;
DuelClient::SetResponseB(respbuf, selected_cards.size() + 1); DuelClient::SetResponseB(respbuf, selected_cards.size() + 1);
mainGame->localAction.Set(); DuelClient::SendResponse();
} else { } else {
select_ready = true; select_ready = true;
wchar_t wbuf[256], *pwbuf = wbuf; wchar_t wbuf[256], *pwbuf = wbuf;
...@@ -1113,7 +1114,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1113,7 +1114,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->wCardSelect->isVisible()) if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true); mainGame->HideElement(mainGame->wCardSelect, true);
else else
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
break; break;
} }
...@@ -1135,7 +1136,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1135,7 +1136,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if(mainGame->wCardSelect->isVisible()) if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect, true); mainGame->HideElement(mainGame->wCardSelect, true);
else else
mainGame->localAction.Set(); DuelClient::SendResponse();
} }
break; break;
} }
......
...@@ -514,7 +514,6 @@ void Game::MainLoop() { ...@@ -514,7 +514,6 @@ void Game::MainLoop() {
} }
} }
DuelClient::StopClient(true); DuelClient::StopClient(true);
NetServer::StopServer();
SaveConfig(); SaveConfig();
device->drop(); device->drop();
} }
......
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
Mutex gMutex; Mutex gMutex;
Mutex gBuffer; Mutex gBuffer;
Signal frameSignal; Signal frameSignal;
Signal localAction; Signal actionSignal;
Signal replaySignal; Signal replaySignal;
Config gameConf; Config gameConf;
DuelInfo dInfo; DuelInfo dInfo;
......
...@@ -178,6 +178,12 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -178,6 +178,12 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
duel_mode->GetResponse(dp, pdata, len > 64 ? 64 : len - 1); duel_mode->GetResponse(dp, pdata, len > 64 ? 64 : len - 1);
break; break;
} }
case CTOS_TIME_CONFIRM: {
if(!dp->game || !duel_mode->pduel)
return;
duel_mode->TimeConfirm(dp);
break;
}
case CTOS_UPDATE_DECK: { case CTOS_UPDATE_DECK: {
if(!dp->game) if(!dp->game)
return; return;
...@@ -212,6 +218,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -212,6 +218,8 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
} else if(pkt->info.mode == MODE_MATCH) { } else if(pkt->info.mode == MODE_MATCH) {
duel_mode = new SingleDuel(true); duel_mode = new SingleDuel(true);
} }
timeval timeout = {1, 0};
duel_mode->etimer = event_new(net_evbase, 0, EV_PERSIST, SingleDuel::SingleTimer, duel_mode);
if(pkt->info.rule > 3) if(pkt->info.rule > 3)
pkt->info.rule = 0; pkt->info.rule = 0;
if(pkt->info.mode > 1) if(pkt->info.mode > 1)
......
...@@ -73,7 +73,11 @@ struct STOC_TypeChange { ...@@ -73,7 +73,11 @@ struct STOC_TypeChange {
unsigned char type; unsigned char type;
}; };
struct STOC_ExitGame { struct STOC_ExitGame {
unsigned pos; unsigned char pos;
};
struct STOC_TimeLimit {
unsigned char player;
unsigned short left_time;
}; };
struct STOC_HS_PlayerEnter { struct STOC_HS_PlayerEnter {
unsigned short name[20]; unsigned short name[20];
...@@ -123,9 +127,11 @@ public: ...@@ -123,9 +127,11 @@ public:
} }
virtual void Surrender(DuelPlayer* dp) {} virtual void Surrender(DuelPlayer* dp) {}
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {} virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len) {}
virtual void TimeConfirm(DuelPlayer* dp) {}
virtual void EndDuel() {}; virtual void EndDuel() {};
public: public:
event* etimer;
DuelPlayer* host_player; DuelPlayer* host_player;
HostInfo host_info; HostInfo host_info;
unsigned long pduel; unsigned long pduel;
...@@ -155,6 +161,7 @@ public: ...@@ -155,6 +161,7 @@ public:
#define CTOS_JOIN_GAME 0x12 #define CTOS_JOIN_GAME 0x12
#define CTOS_LEAVE_GAME 0x13 #define CTOS_LEAVE_GAME 0x13
#define CTOS_SURRENDER 0x14 #define CTOS_SURRENDER 0x14
#define CTOS_TIME_CONFIRM 0x15
#define CTOS_HS_TODUELIST 0x20 #define CTOS_HS_TODUELIST 0x20
#define CTOS_HS_TOOBSERVER 0x21 #define CTOS_HS_TOOBSERVER 0x21
#define CTOS_HS_READY 0x22 #define CTOS_HS_READY 0x22
...@@ -177,6 +184,7 @@ public: ...@@ -177,6 +184,7 @@ public:
#define STOC_DUEL_START 0x15 #define STOC_DUEL_START 0x15
#define STOC_DUEL_END 0x16 #define STOC_DUEL_END 0x16
#define STOC_REPLAY 0x17 #define STOC_REPLAY 0x17
#define STOC_TIME_LIMIT 0x18
#define STOC_HS_PLAYER_ENTER 0x20 #define STOC_HS_PLAYER_ENTER 0x20
#define STOC_HS_PLAYER_CHANGE 0x21 #define STOC_HS_PLAYER_CHANGE 0x21
#define STOC_HS_WATCH_CHANGE 0x22 #define STOC_HS_WATCH_CHANGE 0x22
......
...@@ -119,6 +119,7 @@ void Replay::EndRecord() { ...@@ -119,6 +119,7 @@ void Replay::EndRecord() {
pheader.flag |= REPLAY_COMPRESSED; pheader.flag |= REPLAY_COMPRESSED;
size_t propsize = 5; size_t propsize = 5;
comp_size = 0x1000; comp_size = 0x1000;
printf("%x\n",comp_data);
LzmaCompress(comp_data, &comp_size, replay_data, pdata - replay_data, pheader.props, &propsize, 5, 1 << 24, 3, 0, 2, 32, 1); LzmaCompress(comp_data, &comp_size, replay_data, pdata - replay_data, pheader.props, &propsize, 5, 1 << 24, 3, 0, 2, 32, 1);
is_recording = false; is_recording = false;
} }
......
...@@ -25,7 +25,7 @@ void ReplayMode::StopReplay(bool is_exiting) { ...@@ -25,7 +25,7 @@ void ReplayMode::StopReplay(bool is_exiting) {
is_continuing = false; is_continuing = false;
is_closing = is_exiting; is_closing = is_exiting;
exit_pending = true; exit_pending = true;
mainGame->localAction.Set(); mainGame->actionSignal.Set();
} }
void ReplayMode::SwapField() { void ReplayMode::SwapField() {
if(is_paused) if(is_paused)
...@@ -39,7 +39,7 @@ void ReplayMode::Pause(bool is_pause, bool is_step) { ...@@ -39,7 +39,7 @@ void ReplayMode::Pause(bool is_pause, bool is_step) {
else { else {
if(!is_step) if(!is_step)
is_pausing = false; is_pausing = false;
mainGame->localAction.Set(); mainGame->actionSignal.Set();
} }
} }
bool ReplayMode::ReadReplayResponse() { bool ReplayMode::ReadReplayResponse() {
...@@ -105,9 +105,9 @@ int ReplayMode::ReplayThread(void* param) { ...@@ -105,9 +105,9 @@ int ReplayMode::ReplayThread(void* param) {
end_duel(pduel); end_duel(pduel);
if(!is_closing) { if(!is_closing) {
mainGame->stMessage->setText(dataManager.GetSysString(1501)); mainGame->stMessage->setText(dataManager.GetSysString(1501));
mainGame->localAction.Reset(); mainGame->actionSignal.Reset();
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->localAction.Wait(); mainGame->actionSignal.Wait();
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isReplay = false; mainGame->dInfo.isReplay = false;
mainGame->CloseDuelWindow(); mainGame->CloseDuelWindow();
...@@ -554,8 +554,8 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) { ...@@ -554,8 +554,8 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
} }
if(pauseable && is_pausing) { if(pauseable && is_pausing) {
is_paused = true; is_paused = true;
mainGame->localAction.Reset(); mainGame->actionSignal.Reset();
mainGame->localAction.Wait(); mainGame->actionSignal.Wait();
is_paused = false; is_paused = false;
} }
} }
......
...@@ -1257,6 +1257,9 @@ void SingleDuel::WaitforResponse(int playerid) { ...@@ -1257,6 +1257,9 @@ void SingleDuel::WaitforResponse(int playerid) {
players[playerid]->state = CTOS_RESPONSE; players[playerid]->state = CTOS_RESPONSE;
unsigned char msg = MSG_WAITING; unsigned char msg = MSG_WAITING;
NetServer::SendPacketToPlayer(players[1 - playerid], STOC_GAME_MSG, msg); NetServer::SendPacketToPlayer(players[1 - playerid], STOC_GAME_MSG, msg);
}
void SingleDuel::TimeConfirm(DuelPlayer* dp) {
} }
void SingleDuel::RefreshMzone(int player, int flag, int use_cache) { void SingleDuel::RefreshMzone(int player, int flag, int use_cache) {
char query_buffer[0x1000]; char query_buffer[0x1000];
...@@ -1358,5 +1361,8 @@ int SingleDuel::MessageHandler(long fduel, int type) { ...@@ -1358,5 +1361,8 @@ int SingleDuel::MessageHandler(long fduel, int type) {
fclose(fp); fclose(fp);
return 0; return 0;
} }
void SingleDuel::SingleTimer(evutil_socket_t fd, short events, void* arg) {
SingleDuel* sd = static_cast<SingleDuel*>(arg);
}
} }
...@@ -25,6 +25,7 @@ public: ...@@ -25,6 +25,7 @@ public:
virtual void Surrender(DuelPlayer* dp); virtual void Surrender(DuelPlayer* dp);
virtual int Analyze(char* msgbuffer, unsigned int len); virtual int Analyze(char* msgbuffer, unsigned int len);
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len); virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void TimeConfirm(DuelPlayer* dp);
virtual void EndDuel(); virtual void EndDuel();
void DuelEndProc(); void DuelEndProc();
...@@ -37,6 +38,7 @@ public: ...@@ -37,6 +38,7 @@ public:
void RefreshSingle(int player, int location, int sequence, int flag = 0x181fff); void RefreshSingle(int player, int location, int sequence, int flag = 0x181fff);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg);
protected: protected:
DuelPlayer* players[2]; DuelPlayer* players[2];
......
This diff is collapsed.
...@@ -28,7 +28,7 @@ function c33396948.check(g) ...@@ -28,7 +28,7 @@ function c33396948.check(g)
return a1 and a2 and a3 and a4 and a5 return a1 and a2 and a3 and a4 and a5
end end
function c33396948.operation(e,tp,eg,ep,ev,re,r,rp) function c33396948.operation(e,tp,eg,ep,ev,re,r,rp)
local WIN_REASON_EXODIA = 0x3 local WIN_REASON_EXODIA = 0x10
local g1=Duel.GetFieldGroup(tp,LOCATION_HAND,0) local g1=Duel.GetFieldGroup(tp,LOCATION_HAND,0)
local g2=Duel.GetFieldGroup(tp,0,LOCATION_HAND) local g2=Duel.GetFieldGroup(tp,0,LOCATION_HAND)
local wtp=c33396948.check(g1) local wtp=c33396948.check(g1)
......
...@@ -75,6 +75,6 @@ function c8062132.ctop(e,tp,eg,ep,ev,re,r,rp) ...@@ -75,6 +75,6 @@ function c8062132.ctop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
c:AddCounter(0x11,1) c:AddCounter(0x11,1)
if c:GetCounter(0x11)>=3 then if c:GetCounter(0x11)>=3 then
Duel.Win(tp,0x5) Duel.Win(tp,0x12)
end end
end end
...@@ -32,6 +32,6 @@ function c95308449.checkop(e,tp,eg,ep,ev,re,r,rp) ...@@ -32,6 +32,6 @@ function c95308449.checkop(e,tp,eg,ep,ev,re,r,rp)
ct=ct+1 ct=ct+1
c:SetTurnCounter(ct) c:SetTurnCounter(ct)
if ct==20 then if ct==20 then
Duel.Win(tp,0x4) Duel.Win(tp,0x11)
end end
end end
...@@ -351,9 +351,11 @@ ...@@ -351,9 +351,11 @@
!victory 0x0 投降 !victory 0x0 投降
!victory 0x1 LP变成0 !victory 0x1 LP变成0
!victory 0x2 没有卡可抽 !victory 0x2 没有卡可抽
!victory 0x3 被封印的埃及使者 !victory 0x3 超时
!victory 0x4 終焉のカウントダウン !victory 0x4 失去连接
!victory 0x5 毒蛇神ヴェノミナーガ !victory 0x10 封印されしエクゾディア
!victory 0x11 終焉のカウントダウン
!victory 0x12 毒蛇神ヴェノミナーガ
#counters #counters
!counter 0x3001 魔力指示物 !counter 0x3001 魔力指示物
!counter 0x2 楔指示物 !counter 0x2 楔指示物
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
antialias = 2 antialias = 2
nickname = Player nickname = Player
gamename = Game gamename = Game
lastdeck = Burn1 lastdeck = test
textfont = c:/windows/fonts/simsun.ttc textfont = c:/windows/fonts/simsun.ttc
numfont = c:/windows/fonts/arialbd.ttf numfont = c:/windows/fonts/arialbd.ttf
serverport = 7911 serverport = 7911
......
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