- Attempted fix for some synch network errors (ensure client messages are processed in proper order)

This commit is contained in:
Mark Vejvoda 2010-05-26 05:33:15 +00:00
parent 2504baad20
commit f92bf42d82
3 changed files with 20 additions and 1 deletions

View File

@ -147,7 +147,8 @@ void ConnectionSlot::update(bool checkForNewClients) {
NetworkMessageCommandList networkMessageCommandList;
if(receiveMessage(&networkMessageCommandList)) {
for(int i= 0; i<networkMessageCommandList.getCommandCount(); ++i) {
serverInterface->requestCommand(networkMessageCommandList.getCommand(i));
//serverInterface->requestCommand(networkMessageCommandList.getCommand(i));
vctPendingNetworkCommandList.push_back(*networkMessageCommandList.getCommand(i));
}
}
}

View File

@ -40,6 +40,7 @@ private:
bool receivedNetworkGameStatus;
time_t connectedTime;
bool gotIntro;
vector<NetworkCommand> vctPendingNetworkCommandList;
public:
ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
@ -68,6 +69,9 @@ public:
std::vector<std::string> getThreadErrorList() const { return threadErrorList; }
void clearThreadErrorList() { threadErrorList.clear(); }
vector<NetworkCommand> getPendingNetworkCommandList() { return vctPendingNetworkCommandList; }
void clearPendingNetworkCommandList() { vctPendingNetworkCommandList.clear(); }
protected:
Mutex * getServerSynchAccessor();

View File

@ -440,6 +440,20 @@ void ServerInterface::update() {
sleep(0);
}
for(int i= 0; i< GameConstants::maxPlayers; ++i) {
ConnectionSlot* connectionSlot= slots[i];
if(connectionSlot != NULL && connectionSlot->isConnected() == true &&
connectionSlot->getPendingNetworkCommandList().size() > 0) {
vector<NetworkCommand> vctPendingNetworkCommandList = connectionSlot->getPendingNetworkCommandList();
for(int idx = 0; idx < vctPendingNetworkCommandList.size(); ++idx) {
NetworkCommand &cmd = vctPendingNetworkCommandList[idx];
this->requestCommand(&cmd);
}
connectionSlot->clearPendingNetworkCommandList();
}
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
//process text messages