[Gcblue-commits] gcb_wx/src/network tcMultiplayerInterface.cpp, 1.39, 1.40 tcUpdateMessageHandler.c
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-06 01:20:48
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv22513/src/network Modified Files: tcMultiplayerInterface.cpp tcUpdateMessageHandler.cpp Log Message: Index: tcUpdateMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcUpdateMessageHandler.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcUpdateMessageHandler.cpp 27 Nov 2006 00:46:39 -0000 1.20 --- tcUpdateMessageHandler.cpp 6 Dec 2006 01:20:43 -0000 1.21 *************** *** 236,239 **** --- 236,240 ---- temp.SetMaxSize(size_t(freeSpace)); temp.SetDoneFlag(true); + temp.SetDetailLevel(stream.GetDetailLevel()); *obj >> temp; Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** tcMultiplayerInterface.cpp 30 Nov 2006 04:11:13 -0000 1.39 --- tcMultiplayerInterface.cpp 6 Dec 2006 01:20:42 -0000 1.40 *************** *** 61,65 **** void tcPlayerStatus::EraseEntry(long id) { ! std::map<long, unsigned int>::iterator iter; if (id == -1) return; --- 61,65 ---- void tcPlayerStatus::EraseEntry(long id) { ! std::map<long, UpdateInfo>::iterator iter; if (id == -1) return; *************** *** 88,94 **** * @return true if id exists in update map, false otherwise */ ! bool tcPlayerStatus::GetLastUpdate(long id, unsigned int& updateTime) { ! std::map<long, unsigned int>::iterator mapIter; if (id == -1) return false; --- 88,94 ---- * @return true if id exists in update map, false otherwise */ ! bool tcPlayerStatus::GetLastUpdate(long id, unsigned int& updateTime, unsigned int& detailedUpdateTime) { ! std::map<long, UpdateInfo>::iterator mapIter; if (id == -1) return false; *************** *** 100,104 **** } ! updateTime = mapIter->second; return true; --- 100,105 ---- } ! updateTime = mapIter->second.updateTime; ! detailedUpdateTime = mapIter->second.detailedUpdateTime; return true; *************** *** 164,168 **** if (id == -1) return; // return and do nothing if null idx passed ! lastUpdate[id] = updateTime; } --- 165,180 ---- if (id == -1) return; // return and do nothing if null idx passed ! lastUpdate[id].updateTime = updateTime; ! } ! ! /** ! * Updates lastUpdate detailed update time. ! * A new map entry is created if this is the first update. ! */ ! void tcPlayerStatus::SetDetailedUpdate(long id, unsigned int detailedUpdateTime) ! { ! if (id == -1) return; // return and do nothing if null idx passed ! ! lastUpdate[id].detailedUpdateTime = detailedUpdateTime; } *************** *** 412,416 **** if (iter == playerToConnection.end()) { ! fprintf(stderr, "tcMultiplayerInterface::LogOutPlayer - not found in playerToConnection map\n"); return; } --- 424,429 ---- if (iter == playerToConnection.end()) { ! fprintf(stderr, "tcMultiplayerInterface::LogOutPlayer - %s not found in playerToConnection map\n", ! username.c_str()); return; } *************** *** 850,853 **** --- 863,867 ---- SendChatText(connectionId, " /gm create '<class>' '<unitname>' <alliance> <lat_deg> <lon_deg> (<alt_m>)"); SendChatText(connectionId, " /gm destroy <id>"); + SendChatText(connectionId, " /gm kick '<playername>'"); SendChatText(connectionId, " /gm move <id> <lat_deg> <lon_deg> (<alt_m>)"); // SendChatText(connectionId, " /gm reload <id>"); *************** *** 878,881 **** --- 892,901 ---- } } + else if (command == "kick") + { + syntaxError = false; + + ProcessGMKick(args, msg); + } else if (command == "move") { *************** *** 1040,1043 **** --- 1060,1087 ---- /** + * Kick player from game + * /gm kick '<playername>' + * @param args argument string + * @param msg message text to be returned + */ + void tcMultiplayerInterface::ProcessGMKick(const wxString& args, wxString& msg) + { + const char delim = '\''; + wxString s1 = args.AfterFirst(delim); + std::string playername = s1.BeforeFirst(delim).c_str(); + + int playerId = GetPlayerConnectionId(playername); + if (playerId == -1) return; + + SendChatText(playerId, "You have been kicked from the game"); + + LogOutPlayer(playername); + + playerInfo.erase(playerId); + networkInterface->RemoveConnection(playerId); + } + + + /** * Moves a game entity * move <id> <lat_deg> <lon_deg> (<alt>) *************** *** 1656,1660 **** unsigned destroyCount = 0; ! for (std::map<long, unsigned int>::iterator iter = pstatus.lastUpdate.begin(); iter != pstatus.lastUpdate.end(); ) { --- 1700,1704 ---- unsigned destroyCount = 0; ! for (std::map<long, tcPlayerStatus::UpdateInfo>::iterator iter = pstatus.lastUpdate.begin(); iter != pstatus.lastUpdate.end(); ) { *************** *** 1804,1811 **** } ! unsigned int tcMultiplayerInterface::GetUpdatePeriod(const tcGameObject* obj, const std::string& playerName) const { bool playerControlled = obj->IsControlledBy(playerName); const tcFlightOpsObject* flightOps = dynamic_cast<const tcFlightOpsObject*>(obj); bool largeFlightOps = (flightOps == 0) ? false : (flightOps->CurrentAirComplementSize() > 8); --- 1848,1858 ---- } ! void tcMultiplayerInterface::GetUpdatePeriod(const tcGameObject* obj, const std::string& playerName, ! unsigned int& updatePeriod, unsigned int& detailedUpdatePeriod) const { bool playerControlled = obj->IsControlledBy(playerName); + detailedUpdatePeriod = playerControlled ? 300 : 900; + const tcFlightOpsObject* flightOps = dynamic_cast<const tcFlightOpsObject*>(obj); bool largeFlightOps = (flightOps == 0) ? false : (flightOps->CurrentAirComplementSize() > 8); *************** *** 1815,1823 **** if (!largeFlightOps) { ! return 90; } else { ! return 90; } } --- 1862,1870 ---- if (!largeFlightOps) { ! updatePeriod = 90; } else { ! updatePeriod = 90; } } *************** *** 1826,1834 **** if (!largeFlightOps) { ! return 25; } else { ! return 60; } } --- 1873,1881 ---- if (!largeFlightOps) { ! updatePeriod = 25; } else { ! updatePeriod = 60; } } *************** *** 1866,1880 **** if (pstatus.alliance == obj->GetAlliance()) { ! unsigned int lastUpdate; ! if (pstatus.GetLastUpdate(obj->mnID, lastUpdate)) { unsigned int dt = t - lastUpdate; ! bool doUpdate = (dt >= GetUpdatePeriod(obj, playerName)); if (doUpdate) { ! bool updateAdded = tcUpdateMessageHandler::AddUpdate(obj, updateStream); if (updateAdded) { --- 1913,1940 ---- if (pstatus.alliance == obj->GetAlliance()) { ! unsigned int lastUpdate, lastDetailedUpdate; ! if (pstatus.GetLastUpdate(obj->mnID, lastUpdate, lastDetailedUpdate)) { unsigned int dt = t - lastUpdate; + unsigned int updatePeriod, detailedUpdatePeriod; + GetUpdatePeriod(obj, playerName, updatePeriod, detailedUpdatePeriod); ! bool doUpdate = (dt >= updatePeriod); if (doUpdate) { ! unsigned int dt_detailed = t - lastDetailedUpdate; ! bool detailUpdate = (dt_detailed >= detailedUpdatePeriod); ! if (!detailUpdate) ! { ! updateStream.SetDetailLevel(0); ! } ! else ! { ! updateStream.SetDetailLevel(1); ! } + bool updateAdded = tcUpdateMessageHandler::AddUpdate(obj, updateStream); + if (updateAdded) { *************** *** 1913,1917 **** } ! pstatus.SetUpdate(obj->mnID, t); } --- 1973,1978 ---- } ! pstatus.SetUpdate(obj->mnID, t); ! if (detailUpdate) pstatus.SetDetailedUpdate(obj->mnID, t); } *************** *** 1972,1977 **** // set time to force update at next opportunity ! pstatus.SetUpdate(obj->mnID, (unsigned int)(t-90)); ! #ifdef _DEBUG fprintf(stdout, "C%d ", obj->mnID); --- 2033,2038 ---- // set time to force update at next opportunity ! pstatus.SetUpdate(obj->mnID, (unsigned int)(t-200)); ! pstatus.SetDetailedUpdate(obj->mnID, (unsigned int)(t-200)); #ifdef _DEBUG fprintf(stdout, "C%d ", obj->mnID); |