Public Methods | |
| NetworkData (void) | |
| ~NetworkData (void) | |
| void | addData (string data) |
| vector< string > | getData (int gameTickWanted) |
| bool | hasDataForGameTickArrived (int gameTick) |
| void | clean (int gameTickToClean) |
Private Attributes | |
| hash_map< uint, vector< string > > | m_data |
| hash_map< uint, uint > | m_syncData |
|
|
Definition at line 93 of file Network.cpp.
00093 : m_data(), m_syncData() 00094 { 00095 } |
|
|
Definition at line 97 of file Network.cpp.
00098 {
00099 //Nothing to do
00100 }
|
|
|
Definition at line 102 of file Network.cpp. References NetworkMessages::COMMAND_SYNC(), Globals::currGameTick, getGameTick(), m_data, m_syncData, NDataPair, NDataPairIter, sys_console(), sys_flushConsole(), and Globals::WARNING(). Referenced by NetworkSubsystem::enQueueMsg(), NetworkSubsystem::loadNetworkData(), and NetworkSubsystem::receiveNetworkData().
00103 {
00104 int gameTickToCommit = getGameTick(data);
00105 stringstream sstr(data);
00106 string command;
00107 sstr >> command;
00108 if (command == COMMAND_SYNC)
00109 {
00110 hash_map<uint,uint>::iterator iter = m_syncData.find(gameTickToCommit);
00111 if (iter == m_syncData.end())
00112 {
00113 m_syncData.insert(pair<uint,uint>(gameTickToCommit, 1));
00114 } else
00115 {
00116 ++iter->second;
00117 }
00118 } else
00119 {
00120 if (gameTickToCommit < currGameTick)
00121 {
00122 sys_console() << WARNING << "Error received command that should have happened in the past command is:" << data << endl;
00123 sys_flushConsole();
00124 } else
00125 {
00126 NDataPairIter iter = m_data.find(gameTickToCommit);
00127 if (iter == m_data.end())
00128 {
00129 vector<string> vstr;
00130 vstr.push_back(data);
00131 m_data.insert(NDataPair(gameTickToCommit, vstr));
00132 } else
00133 {
00134 iter->second.push_back(data);
00135 }
00136 }
00137 }
00138 }
|
|
|
Definition at line 162 of file Network.cpp. References m_data, and m_syncData. Referenced by NetworkSubsystem::processNetworkData().
00163 {
00164 int num(gameTickToClean - Globals::NETWORK_GAME_TICK_LAG);
00165 if (num > 0)
00166 {
00167 m_syncData.erase(num);
00168 m_data.erase(num);
00169 }
00170 }
|
|
|
Get all data that should be processed during gameTick. Definition at line 140 of file Network.cpp. References m_data, and NDataPairIter. Referenced by NetworkSubsystem::processNetworkData().
00141 {
00142 NDataPairIter iter = m_data.find(gameTickWanted);
00143 if (iter == m_data.end()) return vector<string>();
00144 else return iter->second;
00145 }
|
|
|
Definition at line 147 of file Network.cpp. References m_syncData, net_getAllPlayers(), and Globals::NETWORK_SYNC_RATE(). Referenced by NetworkSubsystem::hasNetworkDataForCurrentTickBeenReceived().
00148 {
00149 //round down to the closest gameTick sync point
00150 gameTick /= NETWORK_SYNC_RATE;
00151 gameTick *= NETWORK_SYNC_RATE;
00152 gameTick += NETWORK_SYNC_RATE;
00153 assert(gameTick % NETWORK_SYNC_RATE == 0 && "Programming Error: Code above is being optimized out");
00154 hash_map<uint,uint>::iterator iter = m_syncData.find(gameTick);
00155 if (iter == m_syncData.end()) return false;
00156 else
00157 {
00158 return iter->second >= net_getAllPlayers().size();
00159 }
00160 }
|
|
|
Definition at line 87 of file Network.cpp. |
|
|
Definition at line 88 of file Network.cpp. Referenced by addData(), clean(), and hasDataForGameTickArrived(). |
1.3-rc2