Commit 75889e7b authored by argon.sun's avatar argon.sun

client

parent 339d756b
......@@ -454,7 +454,6 @@ void ClientField::ReplaySwap() {
(*cit)->is_moving = false;
}
mainGame->dInfo.is_first_turn = !mainGame->dInfo.is_first_turn;
std::swap(mainGame->dInfo.is_host_player[0], mainGame->dInfo.is_host_player[1]);
std::swap(mainGame->dInfo.lp[0], mainGame->dInfo.lp[1]);
for(int i = 0; i < 16; ++i)
std::swap(mainGame->dInfo.strLP[0][i], mainGame->dInfo.strLP[1][i]);
......
#include "duelclient.h"
#include client_card.h"
#include "client_card.h"
#include "materials.h"
#include "../ocgcore/field.h"
#include "../ocgcore/duel.h"
#include "game.h"
namespace ygo {
unsigned DuelClient::connect_state = 0;
unsigned char DuelClient::response_buf[64];
bool DuelClient::is_responseB;
unsigned char DuelClient::response_len;
unsigned char DuelClient::response_len = 0;
event_base* DuelClient::client_base = 0;
bufferevent* DuelClient::client_bev = 0;
char DuelClient::duel_client_read[0x2000];
char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false;
int DuelClient::select_hint = 0;
wchar_t DuelClient::event_string[256];
mtrandom DuelClient::rnd;
bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_game) {
if(connect_state)
......@@ -35,6 +40,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
return false;
}
connect_state = 1;
rnd.reset(time(0));
Thread::NewThread(ClientThread, 0);
return true;
}
......@@ -192,29 +198,29 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
STOC_JoinGame* pkt = (STOC_JoinGame*)pdata;
std::wstring str;
wchar_t msgbuf[256];
myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist));
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist));
str.append(msgbuf);
myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1240 + pkt->info.rule));
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1240 + pkt->info.rule));
str.append(msgbuf);
myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1227), dataManager.GetSysString(1244 + pkt->info.mode));
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1227), dataManager.GetSysString(1244 + pkt->info.mode));
str.append(msgbuf);
if(pkt->info.enable_priority) {
myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1236));
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1236));
str.append(msgbuf);
}
str.append(L" == == == == == \n");
myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1231), pkt->info.start_lp);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1231), pkt->info.start_lp);
str.append(msgbuf);
myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1232), pkt->info.start_hand);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1232), pkt->info.start_hand);
str.append(msgbuf);
myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1233), pkt->info.draw_count);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1233), pkt->info.draw_count);
str.append(msgbuf);
if(pkt->info.no_check_deck) {
myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1229));
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1229));
str.append(msgbuf);
}
if(pkt->info.no_shuffle_deck) {
myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1230));
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1230));
str.append(msgbuf);
}
mainGame->gMutex.Lock();
......@@ -305,7 +311,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} else if(state == PLAYERCHANGE_OBSERVE) {
watching++;
wchar_t watchbuf[32];
myswprintf(watchbuf, L" % ls % d", dataManager.GetSysString(1253), watching);
myswprintf(watchbuf, L"%ls%d", dataManager.GetSysString(1253), watching);
mainGame->stHostSingleDuelist[pos]->setText(L"");
mainGame->chkHostSingleReady[pos]->setChecked(false);
mainGame->stHostSingleOB->setText(watchbuf);
......@@ -313,16 +319,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Unlock();
break;
}
case STOC_HS_WATCH_CHANGE:
case STOC_HS_WATCH_CHANGE: {
STOC_HS_WatchChange* pkt = (STOC_HS_WatchChange*)pdata;
watching = pkt->watch_count;
wchar_t watchbuf[32];
myswprintf(watchbuf, L" % ls % d", dataManager.GetSysString(1253), watching);
myswprintf(watchbuf, L"%ls%d", dataManager.GetSysString(1253), watching);
mainGame->gMutex.Lock();
mainGame->stHostSingleOB->setText(watchbuf);
mainGame->gMutex.Unlock();
break;
}
}
}
int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
char* pbuf = msg;
......@@ -343,8 +350,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->PopupElement(mainGame->wACMessage, 100);
mainGame->WaitFrameSignal(120);
if(!mainGame->dField.is_replaying) {
pdInfo->isStarted = false;
mainGame->localResponse.Set();
mainGame->dInfo.isStarted = false;
}
return false;
}
......@@ -354,7 +360,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int data = BufferIO::ReadInt32(pbuf);
switch (type) {
case HINT_EVENT: {
myswprintf(pdInfo->strEvent, L" % ls", dataManager.GetDesc(data));
myswprintf(event_string, L"%ls", dataManager.GetDesc(data));
break;
}
case HINT_MESSAGE: {
......@@ -365,11 +371,11 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
break;
}
case HINT_SELECTMSG: {
mainGame->dInfo.selectHint = data;
select_hint = data;
break;
}
case HINT_OPSELECTED: {
myswprintf(textBuffer, L"对方选择了:[ % ls]", dataManager.GetDesc(data));
myswprintf(textBuffer, L"对方选择了:[%ls]", dataManager.GetDesc(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
......@@ -385,7 +391,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
break;
}
case HINT_RACE: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.FormatRace(data));
myswprintf(textBuffer, L"对方宣言了:[%ls]", dataManager.FormatRace(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
......@@ -394,7 +400,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
break;
}
case HINT_ATTRIB: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.FormatAttribute(data));
myswprintf(textBuffer, L"对方宣言了:[%ls]", dataManager.FormatAttribute(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
......@@ -403,7 +409,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
break;
}
case HINT_CODE: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.GetName(data));
myswprintf(textBuffer, L"对方宣言了:[%ls]", dataManager.GetName(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(data);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
......@@ -412,7 +418,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
break;
}
case HINT_NUMBER: {
myswprintf(textBuffer, L"对方选择了:[ % d]", data);
myswprintf(textBuffer, L"对方选择了:[%d]", data);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
......@@ -434,51 +440,31 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int player = BufferIO::ReadInt8(pbuf);
int type = BufferIO::ReadInt8(pbuf);
if(player == 2)
myswprintf(textBuffer, L"Draw Game.\n原因: % ls", dataManager.GetVictoryString(type));
myswprintf(textBuffer, L"Draw Game.\n原因:%ls", dataManager.GetVictoryString(type));
else if(mainGame->LocalPlayer(player) == 0) {
if(!mainGame->dField.is_replaying) {
if(type == 1 || type == 2)
myswprintf(textBuffer, L"You Win!\n原因: % ls % ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Win!\n原因: % ls", dataManager.GetVictoryString(type));
myswprintf(textBuffer, L"You Win!\n原因:%ls%ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Win!\n原因:%ls", dataManager.GetVictoryString(type));
} else {
if(type == 1 || type == 2)
myswprintf(textBuffer, L" % ls Win!\n原因: % ls % ls", mainGame->LocalName(0), mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L" % ls Win!\n原因: % ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
myswprintf(textBuffer, L"%ls Win!\n原因:%ls%ls", mainGame->LocalName(0), mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"%ls Win!\n原因:%ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
}
} else {
if(!mainGame->dField.is_replaying) {
if(type == 1 || type == 2)
myswprintf(textBuffer, L"You Lose!\n原因: % ls % ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Lose!\n原因: % ls", dataManager.GetVictoryString(type));
myswprintf(textBuffer, L"You Lose!\n原因:%ls%ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Lose!\n原因:%ls", dataManager.GetVictoryString(type));
} else {
if(type == 1 || type == 2)
myswprintf(textBuffer, L" % ls Win!\n原因: % ls % ls", mainGame->LocalName(1), mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L" % ls Win!\n原因: % ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
myswprintf(textBuffer, L"%ls Win!\n原因:%ls%ls", mainGame->LocalName(1), mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"%ls Win!\n原因:%ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
}
}
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 100);
mainGame->WaitFrameSignal(120);
if(mainGame->dInfo.is_local_host)
mainGame->localResponse.Set();
break;
}
case MSG_DUEL_END: {
pdInfo->isStarted = false;
mainGame->localResponse.Set();
return false;
}
case MSG_REPLAY: {
pbuf -= 3;
int size = BufferIO::ReadInt16(pbuf);
pbuf++;
memcpy(&mainGame->lastReplay.pheader, pbuf, sizeof(ReplayHeader));
pbuf += sizeof(ReplayHeader);
memcpy(mainGame->lastReplay.comp_data, pbuf, size - sizeof(ReplayHeader) - 1);
mainGame->lastReplay.comp_size = size - sizeof(ReplayHeader) - 1;
mainGame->PopupElement(mainGame->wReplaySave);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
break;
}
case MSG_WAITING: {
......@@ -491,20 +477,20 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
}
case MSG_START: {
mainGame->gMutex.Lock();
pdInfo->is_first_turn = BufferIO::ReadInt32(pbuf) ? false : true;
pdInfo->lp[mainGame->LocalPlayer(0)] = BufferIO::ReadInt32(pbuf);
pdInfo->lp[mainGame->LocalPlayer(1)] = BufferIO::ReadInt32(pbuf);
myswprintf(pdInfo->strLP[0], L" % d", pdInfo->lp[0]);
myswprintf(pdInfo->strLP[1], L" % d", pdInfo->lp[1]);
int deckc = BufferIO::ReadInt32(pbuf);
int extrac = BufferIO::ReadInt32(pbuf);
mainGame->dInfo.is_first_turn = BufferIO::ReadInt8(pbuf) ? false : true;
mainGame->dInfo.lp[mainGame->LocalPlayer(0)] = BufferIO::ReadInt32(pbuf);
mainGame->dInfo.lp[mainGame->LocalPlayer(1)] = BufferIO::ReadInt32(pbuf);
myswprintf(mainGame->dInfo.strLP[0], L"%d", mainGame->dInfo.lp[0]);
myswprintf(mainGame->dInfo.strLP[1], L"%d", mainGame->dInfo.lp[1]);
int deckc = BufferIO::ReadInt16(pbuf);
int extrac = BufferIO::ReadInt16(pbuf);
mainGame->dField.Initial(mainGame->LocalPlayer(0), deckc, extrac);
deckc = BufferIO::ReadInt32(pbuf);
extrac = BufferIO::ReadInt32(pbuf);
deckc = BufferIO::ReadInt16(pbuf);
extrac = BufferIO::ReadInt16(pbuf);
mainGame->dField.Initial(mainGame->LocalPlayer(1), deckc, extrac);
pdInfo->turn = 0;
pdInfo->strTurn[0] = 0;
pdInfo->is_shuffling = false;
mainGame->dInfo.turn = 0;
mainGame->dInfo.strTurn[0] = 0;
mainGame->dInfo.is_shuffling = false;
mainGame->gMutex.Unlock();
return true;
}
......@@ -514,8 +500,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->dField.UpdateFieldCard(player, location, pbuf);
mainGame->gMutex.Unlock();
if (location == LOCATION_HAND && pdInfo->is_shuffling) {
pdInfo->is_shuffling = false;
if (location == LOCATION_HAND && mainGame->dInfo.is_shuffling) {
mainGame->dInfo.is_shuffling = false;
for(int i = 0; i < mainGame->dField.hand[0].size(); ++i) {
mainGame->dField.hand[0][i]->is_hovered = false;
mainGame->dField.MoveCard(mainGame->dField.hand[0][i], 5);
......@@ -584,7 +570,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.ClearCommandFlag();
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_IDLECMD: {
......@@ -689,7 +675,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.ClearCommandFlag();
mainGame->btnBP->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_EFFECTYN: {
......@@ -702,14 +688,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
if (pcard->code != code)
pcard->SetCode(code);
BufferIO::ReadInt8(pbuf);
myswprintf(textBuffer, L"是否在[ % ls]发动[ % ls]的效果?", dataManager.FormatLocation(l), dataManager.GetName(code));
myswprintf(textBuffer, L"是否在[%ls]发动[%ls]的效果?", dataManager.FormatLocation(l), dataManager.GetName(code));
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_YESNO: {
......@@ -721,7 +707,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_OPTION: {
......@@ -738,16 +724,16 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->btnOptionn->setVisible(true);
else mainGame->btnOptionn->setVisible(false);
mainGame->dField.selected_option = 0;
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, L"请选择一个选项:");
mainGame->dInfo.selectHint = 0;
select_hint = 0;
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_CARD: {
......@@ -782,11 +768,11 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
panelmode = true;
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls( % d - % d)", dataManager.GetDesc(mainGame->dInfo.selectHint),
if(select_hint)
myswprintf(textBuffer, L"%ls(%d-%d)", dataManager.GetDesc(select_hint),
mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"请选择卡:( % d - % d)", mainGame->dField.select_min, mainGame->dField.select_max);
mainGame->dInfo.selectHint = 0;
else myswprintf(textBuffer, L"请选择卡:(%d-%d)", mainGame->dField.select_min, mainGame->dField.select_max);
select_hint = 0;
if (panelmode) {
mainGame->gMutex.Lock();
mainGame->wCardSelect->setText(textBuffer);
......@@ -799,7 +785,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_CHAIN: {
......@@ -830,27 +816,26 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.remove_act = true;
}
if(mainGame->ignore_chain || ((count == 0 || specount == 0) && !mainGame->always_chain)) {
mainGame->dInfo.responseI = -1;
mainGame->SetResponseI();
SetResponseI(-1);
mainGame->dField.ClearChainSelect();
if(mainGame->chkWaitChain->isChecked()) {
mainGame->WaitFrameSignal(mainGame->rnd.real() * 20 + 20);
mainGame->WaitFrameSignal(rnd.real() * 20 + 20);
}
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
mainGame->gMutex.Lock();
if(count == 0)
myswprintf(textBuffer, L"此时没有可以发动的效果\n是否要确认场上的情况?");
else
myswprintf(textBuffer, L" % ls\n是否进行连锁?", pdInfo->strEvent);
myswprintf(textBuffer, L"%ls\n是否进行连锁?", event_string);
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearChainSelect();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_PLACE:
......@@ -859,44 +844,45 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_field = ~BufferIO::ReadInt32(pbuf);
mainGame->dField.selected_field = 0;
unsigned char respbuf[64];
if (mainGame->dInfo.curMsg == MSG_SELECT_PLACE && mainGame->chkAutoPos->isChecked()) {
int filter;
if (mainGame->dField.selectable_field & 0x1f) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
mainGame->dInfo.responseB[1] = 0x4;
respbuf[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
respbuf[1] = 0x4;
filter = mainGame->dField.selectable_field & 0x1f;
} else if (mainGame->dField.selectable_field & 0x1f00) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
mainGame->dInfo.responseB[1] = 0x8;
respbuf[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
respbuf[1] = 0x8;
filter = (mainGame->dField.selectable_field >> 8) & 0x1f;
} else if (mainGame->dField.selectable_field & 0x1f0000) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
mainGame->dInfo.responseB[1] = 0x4;
respbuf[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
respbuf[1] = 0x4;
filter = (mainGame->dField.selectable_field >> 16) & 0x1f;
} else {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
mainGame->dInfo.responseB[1] = 0x8;
respbuf[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
respbuf[1] = 0x8;
filter = (mainGame->dField.selectable_field >> 24) & 0x1f;
}
if(mainGame->chkRandomPos->isChecked()) {
mainGame->dInfo.responseB[2] = mainGame->rnd.real() * 5;
while(!(filter & (1 << mainGame->dInfo.responseB[2])))
mainGame->dInfo.responseB[2] = mainGame->rnd.real() * 5;
respbuf[2] = rnd.real() * 5;
while(!(filter & (1 << respbuf[2])))
respbuf[2] = rnd.real() * 5;
} else {
if (filter & 0x4) mainGame->dInfo.responseB[2] = 2;
else if (filter & 0x2) mainGame->dInfo.responseB[2] = 1;
else if (filter & 0x8) mainGame->dInfo.responseB[2] = 3;
else if (filter & 0x1) mainGame->dInfo.responseB[2] = 0;
else if (filter & 0x10) mainGame->dInfo.responseB[2] = 4;
if (filter & 0x4) respbuf[2] = 2;
else if (filter & 0x2) respbuf[2] = 1;
else if (filter & 0x8) respbuf[2] = 3;
else if (filter & 0x1) respbuf[2] = 0;
else if (filter & 0x10) respbuf[2] = 4;
}
mainGame->dField.selectable_field = 0;
mainGame->SetResponseB(3);
mainGame->localResponse.Set();
SetResponseB(respbuf, 3);
DuelClient::SendResponse();
return true;
}
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_POSITION: {
......@@ -904,8 +890,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int code = BufferIO::ReadInt32(pbuf);
int positions = BufferIO::ReadInt8(pbuf);
if (positions == 0x1 || positions == 0x2 || positions == 0x4 || positions == 0x8) {
mainGame->dInfo.responseI = positions;
mainGame->SetResponseI();
SetResponseI(positions);
return true;
}
int count = 0, filter = 0x1, startpos;
......@@ -941,7 +926,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->PopupElement(mainGame->wPosSelect);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_TRIBUTE: {
......@@ -974,7 +959,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_COUNTER: {
......@@ -993,12 +978,11 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
t = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
mainGame->dField.selectable_cards.push_back(pcard);
pcard->opParam = t;
pcard->opParam = (t << 16) | t;
pcard->select_seq = i;
pcard->is_selectable = true;
mainGame->dInfo.responseB[i] = 0;
}
myswprintf(textBuffer, L"请移除 % d个[ % ls]: ", mainGame->dField.select_counter_count, dataManager.GetCounterName(mainGame->dField.select_counter_type));
myswprintf(textBuffer, L"请移除%d个[%ls]: ", mainGame->dField.select_counter_count, dataManager.GetCounterName(mainGame->dField.select_counter_type));
mainGame->gMutex.Lock();
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
......@@ -1006,7 +990,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SELECT_SUM: {
......@@ -1037,11 +1021,10 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
}
std::sort(mainGame->dField.selectsum_all.begin(), mainGame->dField.selectsum_all.end(), ClientCard::client_card_sort);
mainGame->dField.CheckSelectSum();
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L"
% ls( % d)", dataManager.GetDesc(mainGame->dInfo.selectHint), mainGame->dField.select_max);
else myswprintf(textBuffer, L"请选择卡:( % d)", mainGame->dField.select_max);
mainGame->dInfo.selectHint = 0;
if(select_hint)
myswprintf(textBuffer, L"%ls(%d)", dataManager.GetDesc(select_hint), mainGame->dField.select_max);
else myswprintf(textBuffer, L"请选择卡:(%d)", mainGame->dField.select_max);
select_hint = 0;
if (panelmode) {
mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard();
......@@ -1052,7 +1035,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_SORT_CARD:
......@@ -1076,13 +1059,12 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
pcard->select_seq = i;
mainGame->dField.sort_list.push_back(0);
}
if (mainGame->chkAutoChain->isChecked() && pdInfo->curMsg == MSG_SORT_CHAIN) {
mainGame->dInfo.responseI = -1;
mainGame->SetResponseI();
mainGame->localResponse.Set();
if (mainGame->chkAutoChain->isChecked() && mainGame->dInfo.curMsg == MSG_SORT_CHAIN) {
SetResponseI(-1);
DuelClient::SendResponse();
return true;
}
if(pdInfo->curMsg == MSG_SORT_CHAIN)
if(mainGame->dInfo.curMsg == MSG_SORT_CHAIN)
mainGame->wCardSelect->setText(L"请选择连锁顺序:");
else
mainGame->wCardSelect->setText(L"请选择排列顺序:");
......@@ -1091,7 +1073,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->dField.ShowSelectCard();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_CONFIRM_DECKTOP: {
......@@ -1099,7 +1081,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int count = BufferIO::ReadInt8(pbuf);
int code, c, l, s;
ClientCard* pcard;
myswprintf(textBuffer, L"翻开卡组上方 % d张卡:", count);
myswprintf(textBuffer, L"翻开卡组上方%d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->dField.selectable_cards.clear();
......@@ -1111,7 +1093,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0)
pcard->SetCode(code);
myswprintf(textBuffer, L" % d [ % ls]", i, dataManager.GetName(code));
myswprintf(textBuffer, L"%d[%ls]", i, dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
float shift = -0.15f;
......@@ -1132,7 +1114,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int code, c, l, s;
std::vector<ClientCard*> field_confirm;
ClientCard* pcard;
myswprintf(textBuffer, L"确认 % d张卡:", count);
myswprintf(textBuffer, L"确认%d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
for (int i = 0; i < count; ++i) {
......@@ -1143,7 +1125,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0)
pcard->SetCode(code);
myswprintf(textBuffer, L" % d [ % ls]", i, dataManager.GetName(code));
myswprintf(textBuffer, L"%d[%ls]", i, dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
if (l & 0x41) {
......@@ -1316,9 +1298,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
case MSG_NEW_TURN: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dInfo.turn++;
myswprintf(mainGame->dInfo.strTurn, L"Turn:
% d", mainGame->dInfo.turn);
myswprintf(textBuffer, L" % ls的回合", mainGame->LocalName(player));
myswprintf(mainGame->dInfo.strTurn, L"Turn:%d", mainGame->dInfo.turn);
myswprintf(textBuffer, L"%ls的回合", mainGame->LocalName(player));
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1537,7 +1518,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->position = cp;
myswprintf(pdInfo->strEvent, L"卡片改变了表示形式");
myswprintf(event_string, L"卡片改变了表示形式");
mainGame->dField.MoveCard(pcard, 10);
mainGame->WaitFrameSignal(10);
return true;
......@@ -1548,7 +1529,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"放置了卡片");
myswprintf(event_string, L"放置了卡片");
return true;
}
case MSG_SWAP: {
......@@ -1562,7 +1543,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int l2 = BufferIO::ReadInt8(pbuf);
int s2 = BufferIO::ReadInt8(pbuf);
int p2 = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"卡的控制权改变了");
myswprintf(event_string, L"卡的控制权改变了");
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
mainGame->gMutex.Lock();
......@@ -1593,7 +1574,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"[ % ls]召唤中...", dataManager.GetName(code));
myswprintf(event_string, L"[%ls]召唤中...", dataManager.GetName(code));
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 4;
......@@ -1603,7 +1584,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
return true;
}
case MSG_SUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽召唤成功");
myswprintf(event_string, L"怪兽召唤成功");
return true;
}
case MSG_SPSUMMONING: {
......@@ -1612,8 +1593,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"[ % ls]特殊召唤中...", dataManager.GetName(code));
myswprintf(pdInfo->strEvent, L"[ % ls]召唤中...", dataManager.GetName(code));
myswprintf(event_string, L"[%ls]特殊召唤中...", dataManager.GetName(code));
mainGame->showcardcode = code;
mainGame->showcarddif = 1;
mainGame->showcard = 5;
......@@ -1623,7 +1603,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
return true;
}
case MSG_SPSUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽特殊召唤成功");
myswprintf(event_string, L"怪兽特殊召唤成功");
return true;
}
case MSG_FLIPSUMMONING: {
......@@ -1635,7 +1615,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
ClientCard* pcard = mainGame->dField.GetCard(cc, cl, cs);
pcard->SetCode(code);
pcard->position = cp;
myswprintf(pdInfo->strEvent, L"[ % ls]反转召唤中...", dataManager.GetName(code));
myswprintf(event_string, L"[%ls]反转召唤中...", dataManager.GetName(code));
mainGame->dField.MoveCard(pcard, 10);
mainGame->WaitFrameSignal(10);
mainGame->showcardcode = code;
......@@ -1647,7 +1627,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
return true;
}
case MSG_FLIPSUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽反转召唤成功");
myswprintf(event_string, L"怪兽反转召唤成功");
return true;
}
case MSG_CHAINING: {
......@@ -1694,7 +1674,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
}
case MSG_CHAINED: {
int ct = BufferIO::ReadInt8(pbuf);
myswprintf(mainGame->dInfo.strEvent, L"[ % ls]的效果发动", dataManager.GetName(mainGame->dField.current_chain.code));
myswprintf(event_string, L"[%ls]的效果发动", dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->gMutex.Lock();
mainGame->dField.chains.push_back(mainGame->dField.current_chain);
mainGame->gMutex.Unlock();
......@@ -1778,7 +1758,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
}
} else
mainGame->WaitFrameSignal(30);
myswprintf(textBuffer, L"[ % ls]( % ls, % d)成为对象", dataManager.GetName(pcard->code), dataManager.FormatLocation(l), s);
myswprintf(textBuffer, L"[%ls](%ls,%d)成为对象", dataManager.GetName(pcard->code), dataManager.FormatLocation(l), s);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(pcard->code);
pcard->is_highlighting = false;
......@@ -1802,8 +1782,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->WaitFrameSignal(5);
}
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方抽了 % d张卡", count);
else myswprintf(pdInfo->strEvent, L"对手抽了 % d张卡", count);
myswprintf(event_string, L"我方抽了%d张卡", count);
else myswprintf(event_string, L"对手抽了%d张卡", count);
return true;
}
case MSG_DAMAGE: {
......@@ -1814,9 +1794,9 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
final = 0;
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方受到 % d伤害", val);
myswprintf(event_string, L"我方受到%d伤害", val);
else
myswprintf(pdInfo->strEvent, L"对方受到 % d伤害", val);
myswprintf(event_string, L"对方受到%d伤害", val);
mainGame->lpccolor = 0xffff0000;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" - % d", val);
......@@ -1827,7 +1807,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
......@@ -1837,9 +1817,9 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
int final = mainGame->dInfo.lp[player] + val;
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方回复 % dLP", val);
myswprintf(event_string, L"我方回复%dLP", val);
else
myswprintf(pdInfo->strEvent, L"对方回复 % dLP", val);
myswprintf(event_string, L"对方回复%dLP", val);
mainGame->lpccolor = 0xff00ff00;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" + % d", val);
......@@ -1884,7 +1864,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->WaitFrameSignal(10);
mainGame->dInfo.lp[player] = val;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
......@@ -1955,7 +1935,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
mainGame->lpccolor = 0xff0000ff;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" - % d", cost);
myswprintf(textBuffer, L"-%d", cost);
mainGame->lpcstring = textBuffer;
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
......@@ -1963,7 +1943,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
myswprintf(mainGame->dInfo.strLP[player], L"%d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
......@@ -1977,7 +1957,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
if (pc->counters.count(type))
pc->counters[type] += count;
else pc->counters[type] = count;
myswprintf(textBuffer, L"[ % ls]放置了 % d个[ % ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
myswprintf(textBuffer, L"[%ls]放置了%d个[%ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true;
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
......@@ -1997,7 +1977,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
pc->counters[type] -= count;
if (pc->counters[type] <= 0)
pc->counters.erase(type);
myswprintf(textBuffer, L"[ % ls]移除了 % d个[ % ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
myswprintf(textBuffer, L"[%ls]移除了%d个[%ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true;
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
......@@ -2020,7 +2000,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
float sy;
if (ld != 0) {
mainGame->dField.attack_target = mainGame->dField.GetCard(cd, ld, sd);
myswprintf(pdInfo->strEvent, L"[ % ls]攻击[ % ls]", dataManager.GetName(mainGame->dField.attacker->code),
myswprintf(event_string, L"[%ls]攻击[%ls]", dataManager.GetName(mainGame->dField.attacker->code),
dataManager.GetName(mainGame->dField.attack_target->code));
float xa = mainGame->dField.attacker->curPos.X;
float ya = mainGame->dField.attacker->curPos.Y;
......@@ -2033,7 +2013,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
} else {
myswprintf(pdInfo->strEvent, L"[ % ls]直接攻击", dataManager.GetName(mainGame->dField.attacker->code));
myswprintf(event_string, L"[%ls]直接攻击", dataManager.GetName(mainGame->dField.attacker->code));
float xa = mainGame->dField.attacker->curPos.X;
float ya = mainGame->dField.attacker->curPos.Y;
float xd = 3.95f;
......@@ -2047,7 +2027,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
}
mainGame->matManager.GenArrow(sy);
matManager.GenArrow(sy);
mainGame->attack_sv = 0;
mainGame->is_attacking = true;
mainGame->WaitFrameSignal(40);
......@@ -2070,7 +2050,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
return true;
}
case MSG_ATTACK_DISABLED: {
myswprintf(pdInfo->strEvent, L"攻击被无效", dataManager.GetName(mainGame->dField.attacker->code));
myswprintf(event_string, L"攻击被无效", dataManager.GetName(mainGame->dField.attacker->code));
return true;
}
case MSG_DAMAGE_STEP_START: {
......@@ -2082,7 +2062,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
case MSG_MISSED_EFFECT: {
BufferIO::ReadInt32(pbuf);
int code = BufferIO::ReadInt32(pbuf);
myswprintf(textBuffer, L"[ % ls]错过时点", dataManager.GetName(code));
myswprintf(textBuffer, L"[%ls]错过时点", dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
return true;
......@@ -2133,15 +2113,15 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->chkRace[i]->setVisible(true);
else mainGame->chkRace[i]->setVisible(false);
}
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, L"请宣言种族");
mainGame->dInfo.selectHint = 0;
select_hint = 0;
mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_ANNOUNCE_ATTRIB: {
......@@ -2154,29 +2134,29 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->chkAttribute[i]->setVisible(true);
else mainGame->chkAttribute[i]->setVisible(false);
}
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, L"请宣言属性");
mainGame->dInfo.selectHint = 0;
select_hint = 0;
mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_ANNOUNCE_CARD: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->ebANCard->setText(L"");
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, L"请宣言卡名");
mainGame->dInfo.selectHint = 0;
select_hint = 0;
mainGame->wANCard->setText(textBuffer);
mainGame->PopupElement(mainGame->wANCard);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_ANNOUNCE_NUMBER: {
......@@ -2190,16 +2170,16 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->cbANNumber->addItem(textBuffer, value);
}
mainGame->cbANNumber->setSelected(0);
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
if(select_hint)
myswprintf(textBuffer, L"%ls", dataManager.GetDesc(select_hint));
else myswprintf(textBuffer, L"请宣言数字");
mainGame->dInfo.selectHint = 0;
select_hint = 0;
mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
DuelClient::SendResponse();
return true;
}
case MSG_COUNT_TURN: {
......@@ -2228,12 +2208,14 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
}
void DuelClient::SetResponseI(int respI) {
*((int*)response_buf) = respI;
is_responseB = false;
response_len = 4;
}
void DuelClient::SetResponseB(unsigned char* respB, unsigned char len) {
memcpy(response_buf, respB, len);
is_responseB = true;
response_len = len;
}
void DuelClient::SendResponse() {
SendBufferToServer(CTOS_RESPONSE, response_buf, response_len);
}
}
......@@ -10,6 +10,7 @@
#include "network.h"
#include "data_manager.h"
#include "deck_manager.h"
#include "../ocgcore/mtrandom.h"
namespace ygo {
......@@ -17,7 +18,6 @@ class DuelClient {
private:
static unsigned int connect_state;
static unsigned char response_buf[64];
static bool is_responseB;
static unsigned char response_len;
static event_base* client_base;
static bufferevent* client_bev;
......@@ -25,7 +25,8 @@ private:
static char duel_client_write[0x2000];
static bool is_closing;
static int select_hint;
static wchar_t event_string[128];
static wchar_t event_string[256];
static mtrandom rnd;
public:
static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true);
static void StopClient(bool is_exiting = false);
......@@ -36,6 +37,7 @@ public:
static int ClientAnalyze(char* msg, unsigned int len);
static void SetResponseI(int respI);
static void SetResponseB(unsigned char* respB, unsigned char len);
static void SendResponse();
static void SendPacketToServer(unsigned char proto) {
char* p = duel_client_write;
BufferIO::WriteInt16(p, 1);
......
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