[Gcblue-commits] gcb_wx/src/network tcConnectionData.cpp,1.13,1.14 tcMessage.cpp,1.10,1.11 tcMultipl
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-07-29 02:36:02
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28827/src/network Modified Files: tcConnectionData.cpp tcMessage.cpp tcMultiplayerInterface.cpp Log Message: 0.7.2 pre-release test build, added waypoints to client display, fixed multiplayer message overload bug, added better throttling for bad multiplayer connections Index: tcMessage.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMessage.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcMessage.cpp 22 Jun 2005 01:22:08 -0000 1.10 --- tcMessage.cpp 29 Jul 2005 02:35:53 -0000 1.11 *************** *** 58,61 **** --- 58,63 ---- } + + unsigned int tcMessage::GetAckId() const { *************** *** 155,158 **** --- 157,168 ---- /** + * Used to set or clear the ack request flag of this message + */ + void tcMessage::SetAck(bool state) + { + data.header.ackFlag = state ? 1 : 0; + } + + /** * Sets timestamp using current time */ Index: tcConnectionData.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcConnectionData.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcConnectionData.cpp 29 Apr 2005 18:52:53 -0000 1.13 --- tcConnectionData.cpp 29 Jul 2005 02:35:53 -0000 1.14 *************** *** 30,33 **** --- 30,34 ---- #include "tcTime.h" #include <iostream> + #include <math.h> #ifdef _DEBUG *************** *** 354,358 **** void tcConnectionData::ResendFailedAcks() { ! const unsigned int ackTimeout = 26; const unsigned short maxResends = 2; unsigned int t = tcTime::Get()->Get30HzCount(); --- 355,367 ---- void tcConnectionData::ResendFailedAcks() { ! // calculate ackTimeout based on ping time ! unsigned int ackTimeout; ! float ping_s = GetPingTime(); ! ackTimeout = (unsigned int)(floorf(45.0f * ping_s)); ! if (ackTimeout < 10) ackTimeout = 10; // 0.33 s minimum ! else if (ackTimeout > 45) ackTimeout = 45; // 1.5 s maximum ! ! const unsigned int resendLimit_sec = 8; ! const unsigned short maxResends = 2; unsigned int t = tcTime::Get()->Get30HzCount(); *************** *** 365,369 **** if ((msg->GetMessageTimestamp() - t) > ackTimeout) { ! if (msg->resendCount < maxResends) { msg->StampTime(); --- 374,378 ---- if ((msg->GetMessageTimestamp() - t) > ackTimeout) { ! if ((msg->resendCount < maxResends) && (resentCount_sec < resendLimit_sec)) { msg->StampTime(); *************** *** 377,386 **** } else ! { ! fprintf(stdout, "* Max resend of msg %d reached, deleting\n", ! bufferId); ! networkInterface->ReturnMessage(bufferId); ! } ! waitForAck.erase(iter++); } else --- 386,403 ---- } else ! { ! if (resentCount_sec < resendLimit_sec) ! { ! fprintf(stdout, "* Max resend of msg %d reached, deleting\n", ! bufferId); ! } ! else ! { ! fprintf(stdout, "*Resend limit reached, deleting msg %d\n", ! bufferId); ! } ! networkInterface->ReturnMessage(bufferId); ! } ! waitForAck.erase(iter++); } else *************** *** 451,456 **** --- 468,476 ---- readCount_sec = readCount - lastReadCount; writeCount_sec = writeCount - lastWriteCount; + resentCount_sec = resentCount - lastResentCount; + lastReadCount = readCount; lastWriteCount = writeCount; + lastResentCount = resentCount; } } *************** *** 539,542 **** --- 559,575 ---- } + // cancel ack if maxWaitingForAck has been exceeded + if (message->GetAck() && (waitForAck.size() > maxWaitingForAck)) + { + message->SetAck(false); + + static unsigned errorCount = 0; + if (errorCount++ < 8) + { + fprintf(stderr, "tcConnectionData::WriteUDP() - Ack canceled due to overload (id:%d)\n", + message->GetId()); + } + } + // attach rider to message with ids of packets to ack AttachAckRider(message); *************** *** 584,593 **** lastReadCount(0), lastWriteCount(0), readCount_sec(0), writeCount_sec(0), pingTime_s(0), lastCountUpdate(0), lastResendUpdate(0), ! resentCount(0) { --- 617,629 ---- lastReadCount(0), lastWriteCount(0), + lastResentCount(0), readCount_sec(0), writeCount_sec(0), + resentCount_sec(0), pingTime_s(0), lastCountUpdate(0), lastResendUpdate(0), ! resentCount(0), ! maxWaitingForAck(16) { Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcMultiplayerInterface.cpp 26 Jul 2005 00:37:04 -0000 1.30 --- tcMultiplayerInterface.cpp 29 Jul 2005 02:35:53 -0000 1.31 *************** *** 490,495 **** static std::string s; ! s = GetPlayerName(connectionId).c_str(); ! s += " "; s += networkInterface->GetConnectionStatus(connectionId).c_str(); --- 490,500 ---- static std::string s; ! const tcPlayerStatus& status = GetPlayerStatus(connectionId); ! ! wxString s2 = wxString::Format("%s (%d) ", status.GetName().c_str(), ! status.GetAlliance()); ! ! s = s2.c_str(); ! s += networkInterface->GetConnectionStatus(connectionId).c_str(); |