Commit 7f727569 authored by nanahira's avatar nanahira

Merge branch 'master' into server

parents bb4a7207 1111ae48
...@@ -253,6 +253,9 @@ int DuelClient::ClientThread() { ...@@ -253,6 +253,9 @@ int DuelClient::ClientThread() {
void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
char* pdata = data; char* pdata = data;
unsigned char pktType = BufferIO::ReadUInt8(pdata); unsigned char pktType = BufferIO::ReadUInt8(pdata);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("STOC: %d Length: %d\n", pktType, len);
#endif
switch(pktType) { switch(pktType) {
case STOC_GAME_MSG: { case STOC_GAME_MSG: {
ClientAnalyze(pdata, len - 1); ClientAnalyze(pdata, len - 1);
...@@ -960,6 +963,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -960,6 +963,9 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
char* pbuf = msg; char* pbuf = msg;
wchar_t textBuffer[256]; wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf); mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("MSG: %d Length: %d\n", mainGame->dInfo.curMsg, len);
#endif
if(mainGame->dInfo.curMsg != MSG_RETRY) { if(mainGame->dInfo.curMsg != MSG_RETRY) {
memcpy(last_successful_msg, msg, len); memcpy(last_successful_msg, msg, len);
last_successful_msg_length = len; last_successful_msg_length = len;
......
...@@ -59,6 +59,9 @@ public: ...@@ -59,6 +59,9 @@ public:
char* p = duel_client_write; char* p = duel_client_write;
BufferIO::WriteInt16(p, 1); BufferIO::WriteInt16(p, 1);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d\n", proto);
#endif
bufferevent_write(client_bev, duel_client_write, 3); bufferevent_write(client_bev, duel_client_write, 3);
} }
template<typename ST> template<typename ST>
...@@ -67,6 +70,9 @@ public: ...@@ -67,6 +70,9 @@ public:
BufferIO::WriteInt16(p, 1 + sizeof(ST)); BufferIO::WriteInt16(p, 1 + sizeof(ST));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, &st, sizeof(ST)); memcpy(p, &st, sizeof(ST));
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d Length: %d\n", proto, sizeof(ST));
#endif
bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3); bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3);
} }
static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) { static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) {
...@@ -74,6 +80,9 @@ public: ...@@ -74,6 +80,9 @@ public:
BufferIO::WriteInt16(p, 1 + len); BufferIO::WriteInt16(p, 1 + len);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, buffer, len); memcpy(p, buffer, len);
#ifdef YGOPRO_MESSAGE_DEBUG
printf("CTOS: %d Length: %d\n", proto, len);
#endif
bufferevent_write(client_bev, duel_client_write, len + 3); bufferevent_write(client_bev, duel_client_write, len + 3);
} }
......
Subproject commit f6d075baab757900f16210b77e47149319c4fc4e Subproject commit 38c7e0776bcef0da934b1686cefec2692bcf4d66
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