diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index ebe12f05..8c0e8170 100644 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -1024,7 +1024,7 @@ NetworkMessageType ClientInterface::waitForMessage() chrono.start(); NetworkMessageType msg = nmtInvalid; - int waitLoopCount = 0; + uint64 waitLoopCount = 0; while(msg == nmtInvalid) { msg = getNextMessageType(true); if(msg == nmtInvalid) { @@ -1073,7 +1073,7 @@ NetworkMessageType ClientInterface::waitForMessage() waitLoopCount++; } - if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] waiting took %lld msecs, waitLoopCount = %d, msg = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitLoopCount,msg); + if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] waiting took %lld msecs, waitLoopCount = %ull, msg = %d\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis(),waitLoopCount,msg); return msg; } diff --git a/source/glest_game/network/network_message.cpp b/source/glest_game/network/network_message.cpp index 98cc60f1..3b7420f0 100644 --- a/source/glest_game/network/network_message.cpp +++ b/source/glest_game/network/network_message.cpp @@ -394,16 +394,21 @@ NetworkMessageCommandList::NetworkMessageCommandList(int32 frameCount) { } bool NetworkMessageCommandList::addCommand(const NetworkCommand* networkCommand){ - if(data.header.commandCount < maxCommandCount){ - data.commands[static_cast(data.header.commandCount)]= *networkCommand; - data.header.commandCount++; - return true; - } - else { - if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount); - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount); - } - return false; +// if(data.header.commandCount < maxCommandCount){ +// data.commands[static_cast(data.header.commandCount)]= *networkCommand; +// data.header.commandCount++; +// return true; +// } +// else { +// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount); +// SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] WARNING / ERROR too many commands in commandlist data.header.commandCount = %d\n",__FILE__,__FUNCTION__,__LINE__,data.header.commandCount); +// } +// return false; + + data.commands.push_back(*networkCommand); + data.header.commandCount++; + return true; + } bool NetworkMessageCommandList::receive(Socket* socket) { @@ -468,8 +473,10 @@ bool NetworkMessageCommandList::receive(Socket* socket) { //int totalMsgSize = commandListHeaderSize + (sizeof(NetworkCommand) * data.header.commandCount); if(data.header.commandCount > 0) { + data.commands.resize(data.header.commandCount); + int totalMsgSize = (sizeof(NetworkCommand) * data.header.commandCount); - result = NetworkMessage::receive(socket, &data.commands, totalMsgSize, true); + result = NetworkMessage::receive(socket, &data.commands[0], totalMsgSize, true); if(result == true) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled == true) { for(int idx = 0 ; idx < data.header.commandCount; ++idx) { @@ -498,7 +505,11 @@ void NetworkMessageCommandList::send(Socket* socket) const { assert(data.header.messageType==nmtCommandList); int totalMsgSize = commandListHeaderSize + (sizeof(NetworkCommand) * data.header.commandCount); - NetworkMessage::send(socket, &data, totalMsgSize); + //NetworkMessage::send(socket, &data, totalMsgSize); + NetworkMessage::send(socket, &data.header, commandListHeaderSize); + if(data.header.commandCount > 0) { + NetworkMessage::send(socket, &data.commands[0], (sizeof(NetworkCommand) * data.header.commandCount)); + } if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled == true) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] messageType = %d, frameCount = %d, data.commandCount = %d\n", diff --git a/source/glest_game/network/network_message.h b/source/glest_game/network/network_message.h index daa2c6a0..734483fa 100644 --- a/source/glest_game/network/network_message.h +++ b/source/glest_game/network/network_message.h @@ -268,7 +268,7 @@ public: #pragma pack(push, 1) class NetworkMessageCommandList: public NetworkMessage { private: - static const int maxCommandCount = 2496; // can be as large as 65535 + //static const int maxCommandCount = 2496; // can be as large as 65535 private: struct DataHeader { @@ -281,7 +281,8 @@ private: struct Data { DataHeader header; - NetworkCommand commands[maxCommandCount]; + //NetworkCommand commands[maxCommandCount]; + std::vector commands; }; private: