[Gcblue-commits] gcb_wx/src/network tcMultiplayerInterface.cpp,1.29,1.30 tcUpdateMessageHandler.cpp,
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-07-26 00:37:30
|
Update of /cvsroot/gcblue/gcb_wx/src/network In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13788/src/network Modified Files: tcMultiplayerInterface.cpp tcUpdateMessageHandler.cpp Log Message: Added mission goal status to "Mission" channel (hit F7), added sub periscope and mast ops to multiplayer, changed torpedo behavior to resume s-search if track lost early, made afterburner smoke thin a little more uniformly Index: tcUpdateMessageHandler.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcUpdateMessageHandler.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcUpdateMessageHandler.cpp 8 May 2005 23:28:58 -0000 1.16 --- tcUpdateMessageHandler.cpp 26 Jul 2005 00:37:04 -0000 1.17 *************** *** 34,37 **** --- 34,38 ---- #include "common/tcStream.h" #include "common/tcObjStream.h" + #include "tcGoalTracker.h" #include "tcSimPythonInterface.h" #include "tcScenarioInterface.h" *************** *** 126,129 **** --- 127,139 ---- } + void tcUpdateMessageHandler::AddGoalStatus(long alliance, tcUpdateStream& stream) + { + stream.SetDetailLevel(alliance); + + tcGoalTracker* goalTracker = tcGoalTracker::Get(); + + goalTracker->operator>>(stream); + } + void tcUpdateMessageHandler::AddScenarioInfo(tcUpdateStream& stream) { *************** *** 229,232 **** --- 239,244 ---- case SCENARIO_INFO: break; + case GOAL_STATUS: + break; default: fprintf(stderr, "tcUpdateMessageHandler::InitializeMessage - bad message type\n"); *************** *** 352,355 **** --- 364,374 ---- } break; + case GOAL_STATUS: + { + tcUpdateStream stream((const char*)data, messageSize); + stream >> messageType; + HandleGoalStatus(stream); + } + break; default: fprintf(stderr, "tcUpdateMessageHandler::Handle - " *************** *** 640,643 **** --- 659,675 ---- } + /** + * Handle message from server to client updating goal status + */ + void tcUpdateMessageHandler::HandleGoalStatus(tcUpdateStream& stream) + { + wxASSERT(tcSimState::Get()->IsMultiplayerClient()); + + tcGoalTracker* goalTracker = tcGoalTracker::Get(); + + goalTracker->operator<<(stream); + } + + void tcUpdateMessageHandler::HandleScenarioInfo(tcUpdateStream& stream) { Index: tcMultiplayerInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/network/tcMultiplayerInterface.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** tcMultiplayerInterface.cpp 22 Jun 2005 01:22:08 -0000 1.29 --- tcMultiplayerInterface.cpp 26 Jul 2005 00:37:04 -0000 1.30 *************** *** 1489,1492 **** --- 1489,1494 ---- { UpdateSensorMaps(); + + UpdateGoalStatus(); } *************** *** 1609,1612 **** --- 1611,1653 ---- } + /** + * Periodically sends goal status (win/loss) to all clients + */ + void tcMultiplayerInterface::UpdateGoalStatus() + { + static unsigned int lastUpdate = 0; + + wxASSERT(IsServer()); + + unsigned t = tcTime::Get()->Get30HzCount(); + if (t - lastUpdate < goalUpdateInterval) return; + lastUpdate = t; + + const std::list<int>& connectionList = networkInterface->GetConnectionList(); + + std::list<int>::const_iterator iter = connectionList.begin(); + unsigned n = 0; + for( ; iter != connectionList.end(); ++iter) + { + int connectionId = *iter; + + tcPlayerStatus& player = GetPlayerStatus(connectionId); + + if (player.isAuthenticated) + { + tcUpdateStream updateStream; + + tcUpdateMessageHandler::InitializeMessage(tcUpdateMessageHandler::GOAL_STATUS, updateStream); + tcUpdateMessageHandler::AddGoalStatus(player.GetAlliance(), updateStream); + + SendUpdateMessageAck(connectionId, updateStream); + + fprintf(stdout, "Performed goal status update, conn %d, t: %d\n", + connectionId, t); + } + } + + } + /** *************** *** 1987,1991 **** evtHandler(0), entityUpdateInterval(50), ! sensorUpdateInterval(50) { networkInterface = new tcNetworkInterface(); --- 2028,2033 ---- evtHandler(0), entityUpdateInterval(50), ! sensorUpdateInterval(50), ! goalUpdateInterval(600) { networkInterface = new tcNetworkInterface(); *************** *** 2012,2016 **** tcMultiplayerInterface::tcMultiplayerInterface(const tcMultiplayerInterface& source) : entityUpdateInterval(50), ! sensorUpdateInterval(50) { wxASSERT(false); --- 2054,2059 ---- tcMultiplayerInterface::tcMultiplayerInterface(const tcMultiplayerInterface& source) : entityUpdateInterval(50), ! sensorUpdateInterval(50), ! goalUpdateInterval(600) { wxASSERT(false); |