[Orxonox-commit 3083] r7777 - in code/branches/network5/src: libraries/network libraries/network/packet orxonox orxonox/gametypes orxonox/infos orxonox/worldentities/pawns
scheusso at orxonox.net
scheusso at orxonox.net
Sun Dec 19 14:27:07 CET 2010
Author: scheusso
Date: 2010-12-19 14:27:06 +0100 (Sun, 19 Dec 2010)
New Revision: 7777
Modified:
code/branches/network5/src/libraries/network/CMakeLists.txt
code/branches/network5/src/libraries/network/Client.cc
code/branches/network5/src/libraries/network/Client.h
code/branches/network5/src/libraries/network/ClientConnection.h
code/branches/network5/src/libraries/network/ClientInformation.cc
code/branches/network5/src/libraries/network/ClientInformation.h
code/branches/network5/src/libraries/network/Connection.cc
code/branches/network5/src/libraries/network/Connection.h
code/branches/network5/src/libraries/network/FunctionCallManager.cc
code/branches/network5/src/libraries/network/FunctionCallManager.h
code/branches/network5/src/libraries/network/GamestateClient.cc
code/branches/network5/src/libraries/network/GamestateClient.h
code/branches/network5/src/libraries/network/GamestateHandler.cc
code/branches/network5/src/libraries/network/GamestateHandler.h
code/branches/network5/src/libraries/network/GamestateManager.cc
code/branches/network5/src/libraries/network/GamestateManager.h
code/branches/network5/src/libraries/network/Host.cc
code/branches/network5/src/libraries/network/Host.h
code/branches/network5/src/libraries/network/Server.cc
code/branches/network5/src/libraries/network/Server.h
code/branches/network5/src/libraries/network/packet/Acknowledgement.cc
code/branches/network5/src/libraries/network/packet/Acknowledgement.h
code/branches/network5/src/libraries/network/packet/Chat.cc
code/branches/network5/src/libraries/network/packet/Chat.h
code/branches/network5/src/libraries/network/packet/ClassID.cc
code/branches/network5/src/libraries/network/packet/ClassID.h
code/branches/network5/src/libraries/network/packet/DeleteObjects.cc
code/branches/network5/src/libraries/network/packet/DeleteObjects.h
code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
code/branches/network5/src/libraries/network/packet/FunctionCalls.h
code/branches/network5/src/libraries/network/packet/FunctionIDs.cc
code/branches/network5/src/libraries/network/packet/FunctionIDs.h
code/branches/network5/src/libraries/network/packet/Gamestate.cc
code/branches/network5/src/libraries/network/packet/Gamestate.h
code/branches/network5/src/libraries/network/packet/Packet.cc
code/branches/network5/src/libraries/network/packet/Packet.h
code/branches/network5/src/libraries/network/packet/Welcome.cc
code/branches/network5/src/libraries/network/packet/Welcome.h
code/branches/network5/src/orxonox/PlayerManager.cc
code/branches/network5/src/orxonox/gametypes/Gametype.cc
code/branches/network5/src/orxonox/infos/HumanPlayer.cc
code/branches/network5/src/orxonox/worldentities/pawns/Spectator.cc
Log:
some (^^) structural changes
some functional changes (GamestateClient replaced through GamestateManager on client)
reliable packets get buffered until a recent gamestate arrived and got processed
Modified: code/branches/network5/src/libraries/network/CMakeLists.txt
===================================================================
--- code/branches/network5/src/libraries/network/CMakeLists.txt 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/CMakeLists.txt 2010-12-19 13:27:06 UTC (rev 7777)
@@ -27,7 +27,7 @@
FunctionCall.cc
FunctionCallManager.cc
GamestateManager.cc
- GamestateClient.cc
+ #GamestateClient.cc
GamestateHandler.cc
LANDiscoverable.cc
LANDiscovery.cc
@@ -52,7 +52,7 @@
Connection.h
FunctionCall.h
FunctionCallManager.h
- GamestateClient.h
+ #GamestateClient.h
GamestateHandler.h
GamestateManager.h
Host.h
Modified: code/branches/network5/src/libraries/network/Client.cc
===================================================================
--- code/branches/network5/src/libraries/network/Client.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Client.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -63,7 +63,6 @@
* initializes the address and the port to default localhost:NETWORK_PORT
*/
Client::Client():
- gamestate(0),
isSynched_(false),
gameStateFailure_(false),
timeSinceLastUpdate_(0)
@@ -84,10 +83,10 @@
bool Client::establishConnection()
{
Synchronisable::setClient(true);
- this->gamestate = new GamestateClient();
if( ClientConnection::establishConnection() )
{
Host::setActive(true);
+ GamestateManager::addPeer(NETWORK_PEER_ID_SERVER);
return true;
}
else
@@ -100,10 +99,8 @@
*/
bool Client::closeConnection()
{
- assert(this->gamestate);
- delete this->gamestate;
- this->gamestate = 0;
Host::setActive(false);
+ GamestateManager::removePeer(NETWORK_PEER_ID_SERVER);
return ClientConnection::closeConnection();
}
@@ -137,7 +134,7 @@
bool Client::chat(const std::string& message)
{
packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
- return m->send();
+ return m->send(static_cast<Host*>(this));
}
@@ -156,27 +153,34 @@
if ( isConnected() && isSynched_ )
{
COUT(4) << "popping partial gamestate: " << std::endl;
- packet::Gamestate *gs = gamestate->getGamestate();
+// packet::Gamestate *gs = GamestateClient::getGamestate();
+ GamestateManager::update();
+ std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
+ std::vector<packet::Gamestate*>::iterator it;
+ for( it = gamestates.begin(); it != gamestates.end(); ++it )
+ {
+ (*it)->send( static_cast<Host*>(this) );
+ }
//assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
- if(gs){
- COUT(4) << "client tick: sending gs " << gs << std::endl;
- if( !gs->send() )
- COUT(2) << "Problem adding partial gamestate to queue" << std::endl;
- // gs gets automatically deleted by enet callback
- }
- FunctionCallManager::sendCalls();
+// if(gs){
+// COUT(4) << "client tick: sending gs " << gs << std::endl;
+// if( !gs->send() )
+// COUT(2) << "Problem adding partial gamestate to queue" << std::endl;
+// // gs gets automatically deleted by enet callback
+// }
+ FunctionCallManager::sendCalls(static_cast<Host*>(this));
}
}
// sendPackets(); // flush the enet queue
Connection::processQueue();
- if(gamestate->processGamestates())
+ if(GamestateManager::processGamestates())
{
FunctionCallManager::processBufferedFunctionCalls();
if(!isSynched_)
isSynched_=true;
}
- gamestate->cleanup();
+// GamestateManager::cleanup();;
// Connection::sendPackets();
return;
@@ -197,7 +201,21 @@
Game::getInstance().popState();
Game::getInstance().popState();
}
+
+ void Client::processPacket(packet::Packet* packet)
+ {
+ if( packet->isReliable() )
+ {
+ if( this->getLastProcessedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID() )
+ packet->process(static_cast<Host*>(this));
+ else
+ this->packetQueue_.push_back(packet);
+ }
+ else
+ packet->process(static_cast<Host*>(this));
+ }
+
}
Modified: code/branches/network5/src/libraries/network/Client.h
===================================================================
--- code/branches/network5/src/libraries/network/Client.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Client.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -44,11 +44,12 @@
#include "NetworkPrereqs.h"
#include <string>
+#include <deque>
#include "util/UtilPrereqs.h"
#include "util/Singleton.h"
#include "ClientConnection.h"
-#include "GamestateClient.h"
+// #include "GamestateClient.h"
#include "Host.h"
#include "LANDiscovery.h"
#include "packet/ServerInformation.h"
@@ -89,10 +90,11 @@
private:
Client(const Client& copy); // not used
virtual bool isServer_(){return false;}
+ void processPacket(packet::Packet* packet);
static Client* singletonPtr_s;
- GamestateClient* gamestate;
bool isSynched_;
+ std::deque<packet::Packet*> packetQueue_;
bool gameStateFailure_;
float timeSinceLastUpdate_;
Modified: code/branches/network5/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/network5/src/libraries/network/ClientConnection.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/ClientConnection.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -43,9 +43,9 @@
void setServerAddress( const std::string& serverAddress );
void setPort( unsigned int port );
- ENetEvent *getEvent();
+// ENetEvent *getEvent();
// check wheter the packet queue is empty
- bool queueEmpty();
+// bool queueEmpty();
// create a new listener thread
virtual bool establishConnection();
virtual bool closeConnection();
Modified: code/branches/network5/src/libraries/network/ClientInformation.cc
===================================================================
--- code/branches/network5/src/libraries/network/ClientInformation.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/ClientInformation.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -55,7 +55,6 @@
gamestateID_=GAMESTATEID_INITIAL;
preve=0;
nexte=0;
- partialGamestateID_=GAMESTATEID_INITIAL-1;
synched_=false;
}
@@ -132,13 +131,6 @@
return true;
}
- bool ClientInformation::setPartialGamestateID(int id){
- if(!this)
- return false;
- partialGamestateID_=id;
- return true;
- }
-
unsigned int ClientInformation::getID() {
if(!this)
return CLIENTID_UNKNOWN;
@@ -153,16 +145,6 @@
return NULL;
}
- int ClientInformation::getFailures(){
- return failures_;
- }
- void ClientInformation::addFailure(){
- failures_++;
- }
- void ClientInformation::resetFailures(){
- failures_=0;
- }
-
uint32_t ClientInformation::getRTT(){
return this->peer_->roundTripTime;
}
@@ -178,13 +160,6 @@
return static_cast<unsigned int>(-1);
}
- unsigned int ClientInformation::getPartialGamestateID() {
- if(this)
- return partialGamestateID_;
- else
- return static_cast<unsigned int>(-1);
- }
-
ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
ClientInformation *temp = head_;
if(temp==ins){
Modified: code/branches/network5/src/libraries/network/ClientInformation.h
===================================================================
--- code/branches/network5/src/libraries/network/ClientInformation.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/ClientInformation.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -65,19 +65,14 @@
void setID(int clientID);
bool setPeer(ENetPeer *peer);
bool setGamestateID(int id);
- bool setPartialGamestateID(int id);
inline void setShipID(unsigned int id){ShipID_=id;}
// get functions
inline unsigned int getShipID(){return ShipID_;}
unsigned int getID();
unsigned int getGamestateID();
- unsigned int getPartialGamestateID();
ENetPeer *getPeer();
- int getFailures();
- void addFailure();
- void resetFailures();
uint32_t getRTT();
double getPacketLoss();
@@ -105,10 +100,8 @@
ENetPeer *peer_;
unsigned int clientID_;
unsigned int gamestateID_;
- unsigned int partialGamestateID_;
unsigned int ShipID_; // this is the unique objectID
bool synched_;
- unsigned short failures_;
};
Modified: code/branches/network5/src/libraries/network/Connection.cc
===================================================================
--- code/branches/network5/src/libraries/network/Connection.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Connection.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -176,6 +176,7 @@
this->incomingEventsMutex_->unlock();
while( incomingEventsCount > 0 )
{
+ packet::Packet* p;
this->incomingEventsMutex_->lock();
event = this->incomingEvents_.front();
this->incomingEvents_.pop_front();
@@ -192,7 +193,8 @@
break;
case ENET_EVENT_TYPE_RECEIVE:
// COUT(0) << "ENET_EVENT_TYPE_RECEIVE" << endl;
- processPacket( &event );
+ p = createPacket( &event );
+ processPacket(p);
break;
case ENET_EVENT_TYPE_NONE:
break;
@@ -204,10 +206,11 @@
}
}
- bool Connection::processPacket(ENetEvent* event)
+ packet::Packet* Connection::createPacket(ENetEvent* event)
{
packet::Packet *p = packet::Packet::createPacket(event->packet, event->peer);
- return p->process();
+ return p;
+// return p->process();
}
void Connection::enableCompression()
Modified: code/branches/network5/src/libraries/network/Connection.h
===================================================================
--- code/branches/network5/src/libraries/network/Connection.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Connection.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -83,7 +83,7 @@
void addPacket(ENetPacket *packet, ENetPeer *peer, uint8_t channelID);
void broadcastPacket(ENetPacket* packet, uint8_t channelID);
- ENetHost* getHost(){ return this->host_; }
+// ENetHost* getHost(){ return this->host_; }
protected:
Connection();
@@ -100,17 +100,18 @@
void processQueue();
virtual void addPeer(ENetEvent* event)=0;
virtual void removePeer(ENetEvent* event)=0;
- virtual bool processPacket(ENetEvent* event);
+ virtual void processPacket( packet::Packet* packet)=0;
+ virtual packet::Packet* createPacket(ENetEvent* event);
ENetHost* host_;
- boost::mutex* incomingEventsMutex_;
- boost::mutex* outgoingEventsMutex_;
private:
boost::thread* communicationThread_;
bool bCommunicationThreadRunning_;
ENetAddress* bindAddress_;
std::deque<ENetEvent> incomingEvents_;
std::deque<outgoingEvent> outgoingEvents_;
+ boost::mutex* incomingEventsMutex_;
+ boost::mutex* outgoingEventsMutex_;
// static Connection *instance_;
Modified: code/branches/network5/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/branches/network5/src/libraries/network/FunctionCallManager.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/FunctionCallManager.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -33,140 +33,140 @@
namespace orxonox {
-std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sClientMap_;
+std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_;
std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
// Static calls
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallStatic(functionID);
+ FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1);
+ FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2);
+ FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
+ FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
+ FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager:: sClientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
+ FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
}
// MemberCalls
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
+void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
{
- if(sClientMap_.find(clientID)==sClientMap_.end())
+ if(sPeerMap_.find(peerID)==sPeerMap_.end())
{
- FunctionCallManager::sClientMap_[clientID] = new packet::FunctionCalls;
- FunctionCallManager::sClientMap_[clientID]->setClientID(clientID);
+ FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
+ FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
}
- FunctionCallManager::sClientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
+ FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
}
// Send calls
-void FunctionCallManager::sendCalls()
+void FunctionCallManager::sendCalls(orxonox::Host* host)
{
std::map<uint32_t, packet::FunctionCalls*>::iterator it;
- for (it = FunctionCallManager::sClientMap_.begin(); it != FunctionCallManager::sClientMap_.end(); ++it )
+ for (it = FunctionCallManager::sPeerMap_.begin(); it != FunctionCallManager::sPeerMap_.end(); ++it )
{
- assert(!FunctionCallManager::sClientMap_.empty());
- it->second->send();
+ assert(!FunctionCallManager::sPeerMap_.empty());
+ it->second->send(host);
}
- FunctionCallManager::sClientMap_.clear();
+ FunctionCallManager::sPeerMap_.clear();
}
-void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t clientID)
+void FunctionCallManager::bufferIncomingFunctionCall(const orxonox::FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID)
{
- FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, clientID)));
+ FunctionCallManager::sIncomingFunctionCallBuffer_.push_back( std::make_pair(fctCall, std::make_pair(minGamestateID, peerID)));
}
void FunctionCallManager::processBufferedFunctionCalls()
@@ -174,9 +174,7 @@
std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > >::iterator it = FunctionCallManager::sIncomingFunctionCallBuffer_.begin();
while( it!=FunctionCallManager::sIncomingFunctionCallBuffer_.end() )
{
- uint32_t minGamestateID = it->second.first;
- uint32_t clientID = it->second.second;
- if( minGamestateID <= GamestateHandler::getInstance()->getLastProcessedGamestateID(clientID) && it->first.execute() )
+ if( it->first.execute() )
FunctionCallManager::sIncomingFunctionCallBuffer_.erase(it);
else
{
Modified: code/branches/network5/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/branches/network5/src/libraries/network/FunctionCallManager.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/FunctionCallManager.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -45,26 +45,26 @@
class _NetworkExport FunctionCallManager
{
public:
- static void addCallStatic(uint32_t functionID, uint32_t clientID);
- static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1);
- static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
- static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
- static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
- static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+ static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
- static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
+ static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
- static void sendCalls();
+ static void sendCalls(orxonox::Host* host);
- static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t clientID );
+ static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID );
static void processBufferedFunctionCalls();
- static std::map<uint32_t, packet::FunctionCalls*> sClientMap_;
+ static std::map<uint32_t, packet::FunctionCalls*> sPeerMap_;
static std::vector<std::pair<FunctionCall,std::pair<uint32_t, uint32_t> > > sIncomingFunctionCallBuffer_;
protected:
FunctionCallManager();
Modified: code/branches/network5/src/libraries/network/GamestateClient.cc
===================================================================
--- code/branches/network5/src/libraries/network/GamestateClient.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateClient.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -61,12 +61,12 @@
delete this->tempGamestate_;
}
- bool GamestateClient::ack(unsigned int gamestateID, unsigned int clientID)
+ bool GamestateClient::ackGamestate(unsigned int gamestateID, unsigned int clientID)
{
return true;
}
- bool GamestateClient::add(packet::Gamestate *gs, unsigned int clientID)
+ bool GamestateClient::addGamestate(packet::Gamestate *gs, unsigned int clientID)
{
if(tempGamestate_!=NULL)
{
Modified: code/branches/network5/src/libraries/network/GamestateClient.h
===================================================================
--- code/branches/network5/src/libraries/network/GamestateClient.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateClient.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -56,9 +56,9 @@
GamestateClient();
~GamestateClient();
- virtual bool add(packet::Gamestate *gs, unsigned int clientID);
- virtual bool ack(unsigned int gamestateID, unsigned int clientID);
- virtual uint32_t getLastProcessedGamestateID(unsigned int clientID) { return this->lastProcessedGamestateID_; }
+ virtual bool addGamestate(packet::Gamestate *gs, unsigned int clientID);
+ virtual bool ackGamestate(unsigned int gamestateID, unsigned int clientID);
+ virtual uint32_t getLastProcessedGamestateID(unsigned int clientID=0) { return this->lastProcessedGamestateID_; }
virtual uint32_t getCurrentGamestateID(){ return this->lastProcessedGamestateID_; }
bool processGamestates();
Modified: code/branches/network5/src/libraries/network/GamestateHandler.cc
===================================================================
--- code/branches/network5/src/libraries/network/GamestateHandler.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateHandler.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -31,18 +31,15 @@
namespace orxonox {
-GamestateHandler *GamestateHandler::instance_=0;
+// GamestateHandler *GamestateHandler::instance_=0;
GamestateHandler::GamestateHandler()
{
- assert(instance_==0);
- instance_=this;
}
GamestateHandler::~GamestateHandler()
{
- instance_=0;
}
Modified: code/branches/network5/src/libraries/network/GamestateHandler.h
===================================================================
--- code/branches/network5/src/libraries/network/GamestateHandler.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateHandler.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -38,23 +38,18 @@
/**
@author Oliver Scheuss
*/
-class _NetworkExport GamestateHandler{
+class _NetworkExport GamestateHandler
+{
private:
- virtual bool add(packet::Gamestate *gs, unsigned int clientID)=0;
- virtual bool ack(unsigned int gamestateID, unsigned int clientID)=0;
- static GamestateHandler* instance_;
-
protected:
GamestateHandler();
virtual ~GamestateHandler();
public:
- static bool addGamestate(packet::Gamestate *gs, unsigned int clientID){ return instance_->add(gs, clientID); }
- static bool ackGamestate(unsigned int gamestateID, unsigned int clientID){ return instance_->ack(gamestateID, clientID); }
- static GamestateHandler* getInstance(){ assert(instance_); return instance_; }
-
+ virtual bool addGamestate(packet::Gamestate* gs, unsigned int clientID) = 0;
+ virtual bool ackGamestate(unsigned int gamestateID, unsigned int clientID) = 0;
virtual uint32_t getLastProcessedGamestateID( unsigned int clientID )=0;
virtual uint32_t getCurrentGamestateID()=0;
};
Modified: code/branches/network5/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/network5/src/libraries/network/GamestateManager.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateManager.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -42,42 +42,43 @@
#include <cassert>
#include <queue>
-#include "util/Clock.h"
// #include <boost/thread/mutex.hpp>
-#include "util/Debug.h"
-#include "core/ThreadPool.h"
-#include "core/command/Executor.h"
-#include "ClientInformation.h"
#include "packet/Acknowledgement.h"
#include "packet/Gamestate.h"
#include "synchronisable/NetworkCallbackManager.h"
-#include "TrafficControl.h"
+#include "core/ThreadPool.h"
+#include "core/command/Executor.h"
+#include "core/GameMode.h"
+#include "util/Debug.h"
+#include "util/Clock.h"
+// #include "TrafficControl.h"
+
namespace orxonox
{
GamestateManager::GamestateManager() :
- reference(0), id_(0)
+ currentGamestate_(0), id_(0)
{
- trafficControl_ = new TrafficControl();
+// trafficControl_ = new TrafficControl();
// threadMutex_ = new boost::mutex();
// threadPool_ = new ThreadPool();
}
GamestateManager::~GamestateManager()
{
- if( this->reference )
- delete this->reference;std::map<unsigned int, packet::Gamestate*>::iterator it;
+ if( this->currentGamestate_ )
+ delete this->currentGamestate_;std::map<unsigned int, packet::Gamestate*>::iterator it;
for( it = gamestateQueue.begin(); it != gamestateQueue.end(); ++it )
delete it->second;
- std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator it1;
- std::map<unsigned int, packet::Gamestate*>::iterator it2;
- for( it1 = gamestateMap_.begin(); it1 != gamestateMap_.end(); ++it1 )
+ std::map<uint32_t, peerInfo>::iterator peerIt;
+ std::map<uint32_t, packet::Gamestate*>::iterator gamestateIt;
+ for( peerIt = peerMap_.begin(); peerIt != peerMap_.end(); ++peerIt )
{
- for( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
- delete it2->second;
+ for( gamestateIt = peerIt->second.gamestates.begin(); gamestateIt != peerIt->second.gamestates.end(); ++gamestateIt )
+ delete gamestateIt->second;
}
- this->trafficControl_->destroy();
+// this->trafficControl_->destroy();
// delete this->threadMutex_;
// delete this->threadPool_;
}
@@ -87,7 +88,8 @@
return getSnapshot();
}
- bool GamestateManager::add(packet::Gamestate *gs, unsigned int clientID){
+ bool GamestateManager::addGamestate(packet::Gamestate *gs, unsigned int clientID)
+ {
assert(gs);
std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
if(it!=gamestateQueue.end()){
@@ -98,7 +100,8 @@
return true;
}
- bool GamestateManager::processGamestates(){
+ bool GamestateManager::processGamestates()
+ {
if( this->gamestateQueue.empty() )
return true;
std::map<unsigned int, packet::Gamestate*>::iterator it;
@@ -117,70 +120,73 @@
bool GamestateManager::getSnapshot(){
- if ( reference != 0 )
- delete reference;
- reference = new packet::Gamestate();
- if(!reference->collectData(++id_, 0x1)){ //we have no data to send
- delete reference;
- reference=0;
+ if ( currentGamestate_ != 0 )
+ delete currentGamestate_;
+ currentGamestate_ = new packet::Gamestate();
+ uint8_t gsMode;
+ if( GameMode::isMaster() )
+ gsMode = packet::GAMESTATE_MODE_SERVER;
+ else
+ gsMode = packet::GAMESTATE_MODE_CLIENT;
+ uint32_t newID;
+ if( GameMode::isMaster() )
+ newID = ++id_;
+ else
+ newID = peerMap_[NETWORK_PEER_ID_SERVER].lastProcessedGamestateID;
+
+ if(!currentGamestate_->collectData(newID, gsMode)){ //we have no data to send
+ delete currentGamestate_;
+ currentGamestate_=0;
}
return true;
}
- void GamestateManager::sendGamestates()
+ std::vector<packet::Gamestate*> GamestateManager::getGamestates()
{
- ClientInformation *temp = ClientInformation::getBegin();
- std::queue<packet::Gamestate*> clientGamestates;
- while(temp != NULL){
- if( !(temp->getSynched()) ){
+ if(!currentGamestate_)
+ return std::vector<packet::Gamestate*>();
+ std::vector<packet::Gamestate*> peerGamestates;
+
+ std::map<uint32_t, peerInfo>::iterator peerIt;
+ for( peerIt=peerMap_.begin(); peerIt!=peerMap_.end(); ++peerIt )
+ {
+ if( !peerIt->second.isSynched )
+ {
COUT(5) << "Server: not sending gamestate" << std::endl;
- temp=temp->next();
- if(!temp)
- break;
continue;
}
- COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
+ COUT(4) << "client id: " << peerIt->first << std::endl;
COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
- int cid = temp->getID(); //get client id
+ int peerID = peerIt->first; //get client id
- unsigned int gID = temp->getGamestateID();
- if(!reference)
- return;
+ unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;
- packet::Gamestate *client=0;
- if(gID != GAMESTATEID_INITIAL){
- assert(gamestateMap_.find(cid)!=gamestateMap_.end());
- std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[cid].find(gID);
- if(it!=gamestateMap_[cid].end())
- {
- client = it->second;
- }
+ packet::Gamestate* baseGamestate=0;
+ if(lastAckedGamestateID != GAMESTATEID_INITIAL)
+ {
+ assert(peerMap_.find(peerID)!=peerMap_.end());
+ std::map<uint32_t, packet::Gamestate*>::iterator it = peerMap_[peerID].gamestates.find(lastAckedGamestateID);
+ assert(it!=peerMap_[peerID].gamestates.end());
+ baseGamestate = it->second;
}
- clientGamestates.push(0);
- finishGamestate( cid, clientGamestates.back(), client, reference );
+ peerGamestates.push_back(0); // insert an empty gamestate* to change
+ finishGamestate( peerID, peerGamestates.back(), baseGamestate, currentGamestate_ );
//FunctorMember<GamestateManager>* functor =
// ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
-// executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
+// executor->setDefaultValues( cid, &clientGamestates.back(), client, currentGamestate_ );
// (*static_cast<Executor*>(executor))();
// this->threadPool_->passFunction( executor, true );
-// (*functor)( cid, &(clientGamestates.back()), client, reference );
-
- temp = temp->next();
+// (*functor)( cid, &(clientGamestates.back()), client, currentGamestate_ );
}
// threadPool_->synchronise();
- while( !clientGamestates.empty() )
- {
- if(clientGamestates.front())
- clientGamestates.front()->send();
- clientGamestates.pop();
- }
+ return peerGamestates;
}
- void GamestateManager::finishGamestate( unsigned int clientID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
+ void GamestateManager::finishGamestate( unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate ) {
//why are we searching the same client's gamestate id as we searched in
//Server::sendGameState?
// save the (undiffed) gamestate in the clients gamestate map
@@ -193,10 +199,10 @@
// packet::Gamestate *gs = new packet::Gamestate();
// gs->collectData( id_, 0x1 );
// this->threadMutex_->lock();
- gamestateMap_[clientID][gamestate->getID()]=gs;
+ peerMap_[peerID].gamestates[gamestate->getID()]=gs;
// this->threadMutex_->unlock();
- Clock clock;
- clock.capture();
+ Clock clock;
+ clock.capture();
if(base)
{
@@ -217,77 +223,123 @@
// bool b = gs->compressData();
// assert(b);
- clock.capture();
- COUT(4) << "diff and compress time: " << clock.getDeltaTime() << endl;
+ clock.capture();
+ COUT(4) << "diff and compress time: " << clock.getDeltaTime() << endl;
// COUT(5) << "sending gamestate with id " << gs->getID();
// if(gamestate->isDiffed())
// COUT(5) << " and baseid " << gs->getBaseID() << endl;
// else
// COUT(5) << endl;
- gs->setClientID(clientID);
+ gs->setPeerID(peerID);
destgamestate = gs;
}
- bool GamestateManager::ack(unsigned int gamestateID, unsigned int clientID) {
- ClientInformation *temp = ClientInformation::findClient(clientID);
- assert(temp);
- unsigned int curid = temp->getGamestateID();
+ bool GamestateManager::ackGamestate(unsigned int gamestateID, unsigned int peerID) {
+// ClientInformation *temp = ClientInformation::findClient(peerID);
+// assert(temp);
+ std::map<uint32_t, peerInfo>::iterator it = this->peerMap_.find(peerID);
+ assert(it!=this->peerMap_.end());
+ unsigned int curid = it->second.lastAckedGamestateID;
if(gamestateID == ACKID_NACK){
- temp->setGamestateID(GAMESTATEID_INITIAL);
+ it->second.lastAckedGamestateID = GAMESTATEID_INITIAL;
+// temp->setGamestateID(GAMESTATEID_INITIAL);
// now delete all saved gamestates for this client
- std::map<unsigned int, packet::Gamestate*>::iterator it;
- for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end(); ){
- delete it->second;
-
- gamestateMap_[clientID].erase(it++);
+ std::map<uint32_t, packet::Gamestate*>::iterator it2;
+ for(it2 = it->second.gamestates.begin(); it2!=it->second.gamestates.end(); ++it2 ){
+ delete it2->second;
}
+ it->second.gamestates.clear();
return true;
}
assert(curid==GAMESTATEID_INITIAL || curid<gamestateID);
- COUT(5) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
- std::map<unsigned int, packet::Gamestate*>::iterator it;
- for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){
- delete it->second;
- gamestateMap_[clientID].erase(it++);
+ COUT(5) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;
+ std::map<uint32_t, packet::Gamestate*>::iterator it2;
+ for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); )
+ {
+ if( it2->second->getID() < gamestateID )
+ {
+ delete it2->second;
+ it->second.gamestates.erase(it2++);
+ }
+ else
+ ++it2;
}
- temp->setGamestateID(gamestateID);
- TrafficControl::processAck(clientID, gamestateID);
+
+// std::map<unsigned int, packet::Gamestate*>::iterator it;
+// for(it = gamestateMap_[peerID].begin(); it!=gamestateMap_[peerID].end() && it->first<gamestateID; ){
+// delete it->second;
+// gamestateMap_[peerID].erase(it++);
+// }
+ it->second.lastAckedGamestateID = gamestateID;
+// temp->setGamestateID(gamestateID);
+// TrafficControl::processAck(peerID, gamestateID);
return true;
}
- uint32_t GamestateManager::getLastProcessedGamestateID(unsigned int clientID)
+ uint32_t GamestateManager::getLastProcessedGamestateID(unsigned int peerID)
{
- assert( this->lastProcessedGamestateID_.find(clientID) != this->lastProcessedGamestateID_.end() );
- if( this->lastProcessedGamestateID_.find(clientID) != this->lastProcessedGamestateID_.end() )
- return this->lastProcessedGamestateID_[clientID];
+ assert( this->peerMap_.find(peerID)!=this->peerMap_.end() );
+ if( this->peerMap_.find(peerID) != this->peerMap_.end() )
+ return this->peerMap_[peerID].lastProcessedGamestateID;
else
return GAMESTATEID_INITIAL;
}
+
+
+ void GamestateManager::addPeer(uint32_t peerID)
+ {
+ assert(peerMap_.find(peerID)==peerMap_.end());
+ peerMap_[peerID].peerID = peerID;
+ peerMap_[peerID].lastProcessedGamestateID = GAMESTATEID_INITIAL;
+ peerMap_[peerID].lastAckedGamestateID = GAMESTATEID_INITIAL;
+ if( GameMode::isMaster() )
+ peerMap_[peerID].isSynched = false;
+ else
+ peerMap_[peerID].isSynched = true;
+ }
- void GamestateManager::removeClient(ClientInformation* client){
- assert(client);
- std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
- // first delete all remained gamestates
- std::map<unsigned int, packet::Gamestate*>::iterator it;
- for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
- delete it->second;
- // now delete the clients gamestatemap
- gamestateMap_.erase(clientMap);
+ void GamestateManager::removePeer(uint32_t peerID)
+ {
+ assert(peerMap_.find(peerID)!=peerMap_.end());
+ std::map<uint32_t, packet::Gamestate*>::iterator peerIt;
+ for( peerIt = peerMap_[peerID].gamestates.begin(); peerIt!=peerMap_[peerID].gamestates.end(); ++peerIt )
+ {
+ delete peerIt->second;
+ }
+ peerMap_.erase(peerMap_.find(peerID));
}
- bool GamestateManager::processGamestate(packet::Gamestate *gs){
+
+// void GamestateManager::removeClient(ClientInformation* client){
+// assert(client);
+// std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(client->getID());
+// // first delete all remained gamestates
+// std::map<unsigned int, packet::Gamestate*>::iterator it;
+// for(it=clientMap->second.begin(); it!=clientMap->second.end(); it++)
+// delete it->second;
+// // now delete the clients gamestatemap
+// gamestateMap_.erase(clientMap);
+// }
+
+ bool GamestateManager::processGamestate(packet::Gamestate *gs)
+ {
if(gs->isCompressed())
{
bool b = gs->decompressData();
assert(b);
}
assert(!gs->isDiffed());
- if( gs->spreadData(0x1) )
+ uint8_t gsMode;
+ if( GameMode::isMaster() )
+ gsMode = packet::GAMESTATE_MODE_SERVER;
+ else
+ gsMode = packet::GAMESTATE_MODE_CLIENT;
+ if( gs->spreadData(gsMode) )
{
- this->lastProcessedGamestateID_[gs->getClientID()] = gs->getID();
+ this->peerMap_[gs->getPeerID()].lastProcessedGamestateID = gs->getID();
return true;
}
else
Modified: code/branches/network5/src/libraries/network/GamestateManager.h
===================================================================
--- code/branches/network5/src/libraries/network/GamestateManager.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/GamestateManager.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -46,6 +46,7 @@
#include "GamestateHandler.h"
#include "core/CorePrereqs.h"
#include "packet/Gamestate.h"
+#include <boost/concept_check.hpp>
namespace orxonox
{
@@ -66,33 +67,48 @@
* diff(a,diff(a,x))=x (hope this is correct)
* @author Oliver Scheuss
*/
- class _NetworkExport GamestateManager: public GamestateHandler{
+ class _NetworkExport GamestateManager: public GamestateHandler
+ {
+ struct peerInfo
+ {
+ uint32_t peerID;
+ uint32_t lastProcessedGamestateID;
+ uint32_t lastAckedGamestateID;
+ bool isSynched;
+ std::map< uint32_t, packet::Gamestate* > gamestates;
+ };
+
public:
+
GamestateManager();
~GamestateManager();
- virtual bool add(packet::Gamestate *gs, unsigned int clientID);
- virtual bool ack(unsigned int gamestateID, unsigned int clientID);
- virtual uint32_t getLastProcessedGamestateID( unsigned int clientID );
- virtual uint32_t getCurrentGamestateID(){ return reference->getID(); }
+ virtual bool addGamestate(packet::Gamestate *gs, unsigned int peerID);
+ virtual bool ackGamestate(unsigned int gamestateID, unsigned int peerID);
+ virtual uint32_t getLastProcessedGamestateID( unsigned int peerID );
+ virtual uint32_t getCurrentGamestateID(){ return currentGamestate_->getID(); }
bool processGamestates();
bool update();
- void sendGamestates();
-// packet::Gamestate *popGameState(unsigned int clientID);
- void finishGamestate( unsigned int clientID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
+ std::vector<packet::Gamestate*> getGamestates();
+ void finishGamestate( unsigned int peerID, packet::Gamestate*& destgamestate, packet::Gamestate* base, packet::Gamestate* gamestate );
bool getSnapshot();
- void removeClient(ClientInformation *client);
+ void addPeer( uint32_t peerID );
+ void setSynched( uint32_t peerID )
+ { assert(peerMap_.find(peerID)!=peerMap_.end()); peerMap_[peerID].isSynched = true; }
+ void removePeer( uint32_t peerID );
+// void removeClient(ClientInformation *client);
private:
bool processGamestate(packet::Gamestate *gs);
- std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
+// std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> > gamestateMap_;
std::map<unsigned int, packet::Gamestate*> gamestateQueue;
- std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
- packet::Gamestate *reference;
- TrafficControl *trafficControl_;
+// std::map<unsigned int, uint32_t> lastProcessedGamestateID_;
+ std::map<uint32_t, peerInfo> peerMap_;
+ packet::Gamestate* currentGamestate_;
+// TrafficControl *trafficControl_;
unsigned int id_;
// boost::mutex* threadMutex_;
ThreadPool* /*thread*/Pool_;
Modified: code/branches/network5/src/libraries/network/Host.cc
===================================================================
--- code/branches/network5/src/libraries/network/Host.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Host.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -44,7 +44,7 @@
// Host* Host::instance_=0;
uint32_t Host::clientID_s=0;
- uint32_t Host::shipID_s=-1;
+// uint32_t Host::shipID_s=-1;
std::vector<Host*> Host::instances_s;
/**
Modified: code/branches/network5/src/libraries/network/Host.h
===================================================================
--- code/branches/network5/src/libraries/network/Host.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Host.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -30,6 +30,7 @@
#define _NETWORK_Host_H__
#include "NetworkPrereqs.h"
+#include "GamestateManager.h"
#include "core/CorePrereqs.h"
#include <vector>
@@ -48,7 +49,8 @@
* - is the interface to be used when communicating with the network
* @author Oliver Scheuss
*/
-class _NetworkExport Host{
+class _NetworkExport Host: public GamestateManager
+{
private:
//TODO add these functions or adequate
//virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
@@ -74,9 +76,7 @@
//static bool chat(std::string& message);
// static bool receiveChat(packet::Chat *message, unsigned int clientID);
static unsigned int getPlayerID(){ return clientID_s; }
- static unsigned int getShipID(){return shipID_s;}
static void setClientID(unsigned int id){ clientID_s = id; }
- static void setShipID(unsigned int id){ shipID_s = id; }
static bool isServer();
static void Chat(const std::string& message);
static bool Broadcast(const std::string& message);
@@ -85,7 +85,6 @@
bool isActive(){ return bIsActive_; }
private:
static uint32_t clientID_s;
- static uint32_t shipID_s;
static std::vector<Host*> instances_s;
bool bIsActive_;
};
Modified: code/branches/network5/src/libraries/network/Server.cc
===================================================================
--- code/branches/network5/src/libraries/network/Server.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Server.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -161,8 +161,8 @@
packet::Chat *chat;
while(temp){
chat = new packet::Chat(message, playerID);
- chat->setClientID(temp->getID());
- if(!chat->send())
+ chat->setPeerID(temp->getID());
+ if(!chat->send( static_cast<Host*>(this) ))
COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
temp = temp->next();
}
@@ -219,7 +219,7 @@
FunctionCallManager::processBufferedFunctionCalls();
// send function calls to clients
- FunctionCallManager::sendCalls();
+ FunctionCallManager::sendCalls( static_cast<Host*>(this) );
//this steers our network frequency
timeSinceLastUpdate_+=time.getDeltaTime();
@@ -270,60 +270,30 @@
//no client connected
return;
GamestateManager::update();
- COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
+// COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
//std::cout << "updated gamestate, sending it" << std::endl;
//if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
- sendGameState();
+ sendGameStates();
sendObjectDeletes();
- COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
+// COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
//std::cout << "sent gamestate" << std::endl;
}
- bool Server::processPacket( ENetPacket *packet, ENetPeer *peer ){
- packet::Packet *p = packet::Packet::createPacket(packet, peer);
- return p->process();
- }
-
/**
- * sends the gamestate
+ * sends the current gamestate to all peers
*/
- bool Server::sendGameState()
+ bool Server::sendGameStates()
{
-// COUT(5) << "Server: starting function sendGameState" << std::endl;
-// ClientInformation *temp = ClientInformation::getBegin();
-// bool added=false;
-// while(temp != NULL){
-// if( !(temp->getSynched()) ){
-// COUT(5) << "Server: not sending gamestate" << std::endl;
-// temp=temp->next();
-// if(!temp)
-// break;
-// continue;
-// }
-// COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
-// COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
-// int cid = temp->getID(); //get client id
-// packet::Gamestate *gs = GamestateManager::popGameState(cid);
-// if(gs==NULL){
-// COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
-// temp = temp->next();
-// continue;
-// }
-// //std::cout << "adding gamestate" << std::endl;
-// gs->setClientID(cid);
-// if ( !gs->send() ){
-// COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
-// temp->addFailure();
-// }else
-// temp->resetFailures();
-// added=true;
-// temp=temp->next();
-// // gs gets automatically deleted by enet callback
-// }
- GamestateManager::sendGamestates();
+ std::vector<packet::Gamestate*> gamestates = GamestateManager::getGamestates();
+ std::vector<packet::Gamestate*>::iterator it;
+ for( it = gamestates.begin(); it != gamestates.end(); ++it )
+ {
+ (*it)->send(static_cast<Host*>(this));
+ }
return true;
}
+
bool Server::sendObjectDeletes()
{
ClientInformation *temp = ClientInformation::getBegin();
@@ -347,9 +317,9 @@
int cid = temp->getID(); //get client id
packet::DeleteObjects *cd = new packet::DeleteObjects(*del);
assert(cd);
- cd->setClientID(cid);
- if ( !cd->send() )
- COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
+ cd->setPeerID(cid);
+ if ( !cd->send( static_cast<Host*>(this) ) )
+ COUT(3) << "Server: packet with client id (cid): " << cid << " not sended" << std::endl;
temp=temp->next();
// gs gets automatically deleted by enet callback
}
@@ -373,6 +343,7 @@
// inform all the listeners
ClientConnectionListener::broadcastClientConnected(newid);
+ GamestateManager::addPeer(newid);
++newid;
@@ -393,7 +364,21 @@
delete client;
}
}
+
+ void Server::processPacket(packet::Packet* packet)
+ {
+ if( packet->isReliable() )
+ {
+ if( this->getLastProcessedGamestateID(packet->getPeerID()) >= packet->getRequiredGamestateID() )
+ packet->process(static_cast<Host*>(this));
+ else
+ this->packetQueue_.push_back(packet);
+ }
+ else
+ packet->process(static_cast<Host*>(this));
+ }
+
bool Server::createClient(int clientID)
{
ClientInformation *temp = ClientInformation::findClient(clientID);
@@ -402,31 +387,34 @@
COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
return false;
}
- COUT(5) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+ COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
// synchronise class ids
syncClassid(temp->getID());
// now synchronise functionIDs
packet::FunctionIDs *fIDs = new packet::FunctionIDs();
- fIDs->setClientID(clientID);
- bool b = fIDs->send();
+ fIDs->setPeerID(clientID);
+ bool b = fIDs->send( static_cast<Host*>(this) );
assert(b);
temp->setSynched(true);
+ GamestateManager::setSynched(clientID);
+
COUT(4) << "sending welcome" << std::endl;
packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
- w->setClientID(temp->getID());
- b = w->send();
+ w->setPeerID(temp->getID());
+ b = w->send( static_cast<Host*>(this) );
assert(b);
packet::Gamestate *g = new packet::Gamestate();
- g->setClientID(temp->getID());
- b = g->collectData(0,0x1);
+ g->setPeerID(temp->getID());
+ b = g->collectData(0,packet::GAMESTATE_MODE_SERVER);
+ assert(b);
if(!b)
return false; //no data for the client
// b = g->compressData();
// assert(b);
- b = g->send();
+ b = g->send( static_cast<Host*>(this) );
assert(b);
return true;
}
@@ -434,7 +422,7 @@
void Server::disconnectClient( ClientInformation *client )
{
ServerConnection::disconnectClient( client );
- GamestateManager::removeClient(client);
+ GamestateManager::removePeer(client->getID());
// inform all the listeners
// ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
}
@@ -456,8 +444,8 @@
while(temp)
{
chat = new packet::Chat(message, clientID);
- chat->setClientID(temp->getID());
- if(!chat->send())
+ chat->setPeerID(temp->getID());
+ if(!chat->send( static_cast<Host*>(this) ))
COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
temp = temp->next();
}
@@ -472,8 +460,8 @@
{
int failures=0;
packet::ClassID *classid = new packet::ClassID();
- classid->setClientID(clientID);
- while(!classid->send() && failures < 10){
+ classid->setPeerID(clientID);
+ while(!classid->send( static_cast<Host*>(this) ) && failures < 10){
failures++;
}
assert(failures<10);
Modified: code/branches/network5/src/libraries/network/Server.h
===================================================================
--- code/branches/network5/src/libraries/network/Server.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/Server.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -31,10 +31,12 @@
#include "NetworkPrereqs.h"
+#include <deque>
+
#include "util/UtilPrereqs.h"
#include "core/CorePrereqs.h"
#include "Host.h"
-#include "GamestateManager.h"
+// #include "GamestateManager.h"
#include "ServerConnection.h"
#include "LANDiscoverable.h"
#include "MasterServerComm.h"
@@ -48,7 +50,7 @@
* This class is the root class of the network module for a server.
* It implements all functions necessary for a Server
*/
- class _NetworkExport Server : public Host, public ServerConnection, public GamestateManager, public LANDiscoverable{
+ class _NetworkExport Server : public Host, public ServerConnection, public LANDiscoverable{
public:
Server();
Server(int port);
@@ -72,16 +74,15 @@
void updateGamestate();
private:
virtual bool isServer_(){return true;}
- unsigned int shipID(){return 0;}
unsigned int playerID(){return 0;}
void addPeer(ENetEvent *event);
void removePeer(ENetEvent *event);
+ void processPacket(packet::Packet* packet);
bool createClient(int clientID);
void disconnectClient( ClientInformation *client);
- bool processPacket( ENetPacket *packet, ENetPeer *peer );
- bool sendGameState();
+ bool sendGameStates();
bool sendObjectDeletes();
virtual bool chat(const std::string& message);
virtual bool broadcast(const std::string& message);
@@ -90,6 +91,7 @@
float timeSinceLastUpdate_;
MasterServerComm msc;
+ std::deque<packet::Packet*> packetQueue_;
};
Modified: code/branches/network5/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Acknowledgement.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Acknowledgement.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -30,6 +30,7 @@
#include "util/Debug.h"
#include "network/GamestateHandler.h"
+#include "network/Host.h"
namespace orxonox {
namespace packet {
@@ -38,18 +39,18 @@
#define _PACKETID 0
#define _ACKID _PACKETID + sizeof(packet::Type::Value)
-Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
+Acknowledgement::Acknowledgement( unsigned int id, unsigned int peerID )
: Packet()
{
flags_ = flags_ | PACKET_FLAGS_ACK;
data_=new uint8_t[ getSize() ];
*(Type::Value *)(data_ + _PACKETID ) = Type::Acknowledgement;
*(uint32_t *)(data_ + _ACKID ) = id;
- clientID_=clientID;
+ peerID_=peerID;
}
-Acknowledgement::Acknowledgement( uint8_t *data, unsigned int clientID )
- : Packet(data, clientID)
+Acknowledgement::Acknowledgement( uint8_t *data, unsigned int peerID )
+ : Packet(data, peerID)
{
}
@@ -61,9 +62,9 @@
return _ACKID + sizeof(uint32_t);
}
-bool Acknowledgement::process(){
+bool Acknowledgement::process(orxonox::Host* host){
COUT(5) << "processing ACK with ID: " << getAckID() << endl;
- bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
+ bool b = host->ackGamestate(getAckID(), peerID_);
delete this;
return b;
}
Modified: code/branches/network5/src/libraries/network/packet/Acknowledgement.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/Acknowledgement.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Acknowledgement.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -41,12 +41,12 @@
class _NetworkExport Acknowledgement : public Packet
{
public:
- Acknowledgement( unsigned int id, unsigned int clientID );
- Acknowledgement( uint8_t* data, unsigned int clientID );
+ Acknowledgement( unsigned int id, unsigned int peerID );
+ Acknowledgement( uint8_t* data, unsigned int peerID );
~Acknowledgement();
inline unsigned int getSize() const;
- bool process();
+ virtual bool process(orxonox::Host* host);
unsigned int getAckID();
private:
Modified: code/branches/network5/src/libraries/network/packet/Chat.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Chat.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Chat.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -79,8 +79,8 @@
return _MESSAGE + messageLength_;
}
-bool Chat::process(){
- bool b = Host::incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));
+bool Chat::process(orxonox::Host* host){
+ bool b = host->incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));
delete this;
return b;
}
Modified: code/branches/network5/src/libraries/network/packet/Chat.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/Chat.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Chat.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -51,7 +51,7 @@
inline unsigned int getSize() const;
/* process chat message packet and remove it afterwards */
- bool process();
+ virtual bool process(orxonox::Host* host);
/* Get the length of the message (not the full size of the packet) */
unsigned int getMessageLength(){ return messageLength_; };
Modified: code/branches/network5/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/ClassID.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/ClassID.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -119,7 +119,7 @@
}
-bool ClassID::process(){
+bool ClassID::process(orxonox::Host* host){
int nrOfClasses;
uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
uint32_t networkID;
Modified: code/branches/network5/src/libraries/network/packet/ClassID.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/ClassID.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/ClassID.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -47,7 +47,7 @@
~ClassID();
uint32_t getSize() const;
- bool process();
+ virtual bool process(orxonox::Host* host);
private:
};
Modified: code/branches/network5/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/DeleteObjects.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/DeleteObjects.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -56,7 +56,8 @@
{
}
-bool DeleteObjects::fetchIDs(){
+bool DeleteObjects::fetchIDs()
+{
unsigned int number = Synchronisable::getNumberOfDeletedObject();
if(number==0)
return false;
@@ -78,13 +79,16 @@
return true;
}
-unsigned int DeleteObjects::getSize() const{
+unsigned int DeleteObjects::getSize() const
+{
assert(data_);
return _OBJECTIDS + *(uint32_t*)(data_+_QUANTITY)*sizeof(uint32_t);
}
-bool DeleteObjects::process(){
- for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++){
+bool DeleteObjects::process(orxonox::Host* host)
+{
+ for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
+ {
COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
}
Modified: code/branches/network5/src/libraries/network/packet/DeleteObjects.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/DeleteObjects.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/DeleteObjects.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -31,8 +31,10 @@
#include "network/NetworkPrereqs.h"
#include "Packet.h"
-namespace orxonox {
-namespace packet {
+namespace orxonox
+{
+namespace packet
+{
/**
@author
*/
@@ -46,7 +48,7 @@
bool fetchIDs();
inline unsigned int getSize() const;
- bool process();
+ virtual bool process(orxonox::Host* host);
private:
};
Modified: code/branches/network5/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/FunctionCalls.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/FunctionCalls.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -57,7 +57,8 @@
}
-bool FunctionCalls::process(){
+bool FunctionCalls::process(orxonox::Host* host)
+{
assert(isDataENetAllocated());
uint8_t* temp = data_+sizeof(uint32_t); //skip packetid
@@ -69,9 +70,9 @@
{
FunctionCall fctCall;
fctCall.loadData(temp);
- if( this->minGamestateID_ > GamestateHandler::getInstance()->getLastProcessedGamestateID(this->getClientID()) || !fctCall.execute() )
+ if( this->minGamestateID_ > host->getLastProcessedGamestateID(this->getPeerID()) || !fctCall.execute() )
{
- FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getClientID() );
+ FunctionCallManager::bufferIncomingFunctionCall( fctCall, minGamestateID_, this->getPeerID() );
}
}
@@ -79,7 +80,8 @@
return true;
}
-void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
+{
assert(!isDataENetAllocated());
this->functionCalls_.push(orxonox::FunctionCall());
@@ -87,7 +89,8 @@
this->currentSize_ += this->functionCalls_.back().getSize();
}
-void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
+{
assert(!isDataENetAllocated());
this->functionCalls_.push(orxonox::FunctionCall());
@@ -95,9 +98,9 @@
this->currentSize_ += this->functionCalls_.back().getSize();
}
-bool FunctionCalls::send()
+bool FunctionCalls::send(orxonox::Host* host)
{
- this->minGamestateID_ = GamestateHandler::getInstance()->getCurrentGamestateID();
+ this->minGamestateID_ = host->getCurrentGamestateID();
assert(this->functionCalls_.size());
data_=new uint8_t[ currentSize_ ];
*(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls; // Set the Packet ID
@@ -113,7 +116,7 @@
assert( temp==data_+currentSize_ );
- Packet::send();
+ Packet::send(host);
return true;
}
Modified: code/branches/network5/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/FunctionCalls.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/FunctionCalls.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -53,11 +53,11 @@
inline unsigned int getSize() const
{ assert(!this->isDataENetAllocated()); return currentSize_; }
- bool process();
+ virtual bool process(orxonox::Host* host);
void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
- virtual bool send();
+ virtual bool send(orxonox::Host* host);
private:
std::queue<orxonox::FunctionCall> functionCalls_;
unsigned int clientID_;
Modified: code/branches/network5/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/FunctionIDs.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/FunctionIDs.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -45,7 +45,8 @@
#define _PACKETID 0
-FunctionIDs::FunctionIDs( ) : Packet(){
+FunctionIDs::FunctionIDs( ) : Packet()
+{
unsigned int nrOfFunctions=0;
unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nroffunctions
uint32_t networkID;
@@ -54,7 +55,8 @@
//calculate total needed size (for all strings and integers)
ObjectList<NetworkFunctionBase>::iterator it;
- for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it){
+ for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it)
+ {
const std::string& functionname = it->getName();
networkID = it->getNetworkID();
// now push the network id and the classname to the stack
@@ -75,7 +77,8 @@
// now save all classids and classnames
std::pair<uint32_t, std::string> tempPair;
- while( !tempQueue.empty() ){
+ while( !tempQueue.empty() )
+ {
tempPair = tempQueue.front();
tempQueue.pop();
*(uint32_t*)temp = tempPair.first;
@@ -97,7 +100,8 @@
{
}
-uint32_t FunctionIDs::getSize() const{
+uint32_t FunctionIDs::getSize() const
+{
assert(this->data_);
uint8_t *temp = data_+sizeof(uint32_t); // packet identification
uint32_t totalsize = sizeof(uint32_t); // data size
@@ -113,7 +117,8 @@
}
-bool FunctionIDs::process(){
+bool FunctionIDs::process(orxonox::Host* host)
+{
int nrOfFunctions;
uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
uint32_t networkID;
@@ -126,7 +131,8 @@
nrOfFunctions = *(uint32_t*)temp;
temp += sizeof(uint32_t);
- for( int i=0; i<nrOfFunctions; i++){
+ for( int i=0; i<nrOfFunctions; i++)
+ {
networkID = *(uint32_t*)temp;
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
functionname = temp+2*sizeof(uint32_t);
Modified: code/branches/network5/src/libraries/network/packet/FunctionIDs.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/FunctionIDs.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/FunctionIDs.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -46,8 +46,8 @@
FunctionIDs( uint8_t* data, unsigned int clientID );
~FunctionIDs();
- uint32_t getSize() const;
- bool process();
+ virtual uint32_t getSize() const;
+ virtual bool process(orxonox::Host* host);
private:
};
Modified: code/branches/network5/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Gamestate.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Gamestate.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -35,6 +35,7 @@
#include "core/ObjectList.h"
#include "network/synchronisable/Synchronisable.h"
#include "network/GamestateHandler.h"
+#include "network/Host.h"
namespace orxonox {
@@ -43,8 +44,8 @@
#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
// #define PACKET_FLAG_GAMESTATE PacketFlag::Unsequenced
-// #define PACKET_FLAG_GAMESTATE 0
-#define PACKET_FLAG_GAMESTATE PacketFlag::Reliable
+#define PACKET_FLAG_GAMESTATE 0
+// #define PACKET_FLAG_GAMESTATE PacketFlag::Reliable
inline bool memzero( uint8_t* data, uint32_t datalength)
{
@@ -137,7 +138,7 @@
{
assert(0); // if we don't use multithreading this part shouldn't be neccessary
// start allocate additional memory
- COUT(3) << "G.St.Man: need additional memory" << std::endl;
+ COUT(3) << "Gamestate: need additional memory" << std::endl;
ObjectList<Synchronisable>::iterator temp = it;
uint32_t addsize=tempsize;
while(++temp)
@@ -164,15 +165,15 @@
header_.setCompressed( false );
//stop write gamestate header
- COUT(5) << "G.ST.Man: Gamestate size: " << currentsize << std::endl;
- COUT(5) << "G.ST.Man: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
+ COUT(5) << "Gamestate: Gamestate size: " << currentsize << std::endl;
+ COUT(5) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
return true;
}
bool Gamestate::spreadData(uint8_t mode)
{
- COUT(4) << "processing gamestate with id " << header_.getID() << endl;
+ COUT(5) << "processing gamestate with id " << header_.getID() << endl;
assert(data_);
assert(!header_.isCompressed());
uint8_t *mem=data_+GamestateHeader::getSize();
@@ -203,6 +204,8 @@
assert(b);
}
}
+ assert(mem-data_ == GamestateHeader::getSize()+header_.getDataSize());
+
// In debug mode, check first, whether there are no duplicate objectIDs
#ifndef NDEBUG
if(this->getID()%1000==1)
@@ -268,9 +271,9 @@
}
-bool Gamestate::process()
+bool Gamestate::process(orxonox::Host* host)
{
- return GamestateHandler::addGamestate(this, getClientID());
+ return host->addGamestate(this, getPeerID());
}
@@ -584,7 +587,7 @@
assert(sizesIt==this->sizes_.end());
- Gamestate *g = new Gamestate(newData, getClientID());
+ Gamestate *g = new Gamestate(newData, getPeerID());
(g->header_) = header_;
g->header_.setBaseID( base->getID() );
g->header_.setDataSize(destDataPtr - newData - GamestateHeader::getSize());
@@ -756,7 +759,7 @@
}*/
-uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode)
+uint32_t Gamestate::calcGamestateSize(uint32_t id, uint8_t mode)
{
uint32_t size = 0;
uint32_t nrOfVariables = 0;
Modified: code/branches/network5/src/libraries/network/packet/Gamestate.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/Gamestate.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Gamestate.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -41,11 +41,17 @@
#include "network/TrafficControl.h"
#include "Packet.h"
-namespace orxonox {
+namespace orxonox
+{
-namespace packet {
+namespace packet
+{
+
+static const uint8_t GAMESTATE_MODE_SERVER = 0x1;
+static const uint8_t GAMESTATE_MODE_CLIENT = 0x2;
-class _NetworkExport GamestateHeader{
+class _NetworkExport GamestateHeader
+{
public:
GamestateHeader(){ data_=0; }
GamestateHeader(uint8_t* data)
@@ -57,15 +63,15 @@
static inline uint32_t getSize()
{ return 21; }
- inline int32_t getID() const
- { assert(data_); return *(int32_t*)(data_+4); }
- inline void setID(int32_t id)
- { assert(data_); *(int32_t*)(data_+4) = id; }
+ inline uint32_t getID() const
+ { assert(data_); return *(uint32_t*)(data_+4); }
+ inline void setID(uint32_t id)
+ { assert(data_); *(uint32_t*)(data_+4) = id; }
- inline int32_t getBaseID() const
- { assert(data_); return *(int32_t*)(data_+8); }
- inline void setBaseID(int32_t id)
- { assert(data_); *(int32_t*)(data_+8) = id; }
+ inline uint32_t getBaseID() const
+ { assert(data_); return *(uint32_t*)(data_+8); }
+ inline void setBaseID(uint32_t id)
+ { assert(data_); *(uint32_t*)(data_+8) = id; }
inline uint32_t getDataSize() const
{ assert(data_); return *(uint32_t*)(data_+12); }
@@ -102,7 +108,8 @@
/**
@author Oliver Scheuss
*/
-class _NetworkExport Gamestate: public Packet{
+class _NetworkExport Gamestate: public Packet
+{
public:
Gamestate();
Gamestate(uint8_t *data, unsigned int clientID);
@@ -113,7 +120,7 @@
bool collectData(int id, uint8_t mode=0x0);
bool spreadData( uint8_t mode=0x0);
- inline int32_t getID() const { return header_.getID(); }
+ inline uint32_t getID() const { return header_.getID(); }
inline bool isDiffed() const { return header_.isDiffed(); }
inline bool isCompressed() const { return header_.isCompressed(); }
inline int32_t getBaseID() const { return header_.getBaseID(); }
@@ -131,8 +138,8 @@
// void rawDiff( uint8_t* newdata, uint8_t* data, uint8_t* basedata, uint32_t datalength, uint32_t baselength);
// inline uint32_t findObject( const SynchronisableHeader& header, uint8_t* mem, uint32_t dataLength, uint32_t startPosition = 0 );
virtual uint32_t getSize() const;
- virtual inline bool process();
- uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
+ virtual bool process(orxonox::Host* host);
+ uint32_t calcGamestateSize(uint32_t id, uint8_t mode=0x0);
// inline void diffObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
// inline void copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes );
Modified: code/branches/network5/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Packet.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Packet.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -67,17 +67,17 @@
{
flags_ = PACKET_FLAG_DEFAULT;
packetDirection_ = Direction::Outgoing;
- clientID_=0;
+ peerID_=0;
data_=0;
enetPacket_=0;
bDataENetAllocated_ = false;
}
-Packet::Packet(uint8_t *data, unsigned int clientID)
+Packet::Packet(uint8_t *data, unsigned int peerID)
{
flags_ = PACKET_FLAG_DEFAULT;
packetDirection_ = Direction::Incoming;
- clientID_=clientID;
+ peerID_=peerID;
data_=data;
enetPacket_=0;
bDataENetAllocated_ = false;
@@ -88,7 +88,7 @@
enetPacket_=p.enetPacket_;
flags_=p.flags_;
packetDirection_ = p.packetDirection_;
- clientID_ = p.clientID_;
+ peerID_ = p.peerID_;
if(p.data_){
data_ = new uint8_t[p.getSize()];
memcpy(data_, p.data_, p.getSize());
@@ -124,7 +124,7 @@
}
}
-bool Packet::send(){
+bool Packet::send(orxonox::Host* host){
if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){
assert(0);
return false;
@@ -168,51 +168,51 @@
// ENetPacket *temp = enetPacket_;
// enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
if( this->flags_ & PacketFlag::Reliable )
- Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_DEFAULT);
+ host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_DEFAULT);
else
- Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_UNRELIABLE);
+ host->addPacket( enetPacket_, peerID_, NETWORK_CHANNEL_UNRELIABLE);
return true;
}
Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
uint8_t *data = packet->data;
assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
- unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
+ unsigned int peerID = ClientInformation::findClient(&peer->address)->getID();
Packet *p = 0;
// COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
switch( *(Type::Value *)(data + _PACKETID) )
{
case Type::Acknowledgement:
// COUT(5) << "ack" << std::endl;
- p = new Acknowledgement( data, clientID );
+ p = new Acknowledgement( data, peerID );
break;
case Type::Chat:
// COUT(5) << "chat" << std::endl;
- p = new Chat( data, clientID );
+ p = new Chat( data, peerID );
break;
case Type::ClassID:
// COUT(5) << "classid" << std::endl;
- p = new ClassID( data, clientID );
+ p = new ClassID( data, peerID );
break;
case Type::Gamestate:
// COUT(5) << "gamestate" << std::endl;
- p = new Gamestate( data, clientID );
+ p = new Gamestate( data, peerID );
break;
case Type::Welcome:
// COUT(5) << "welcome" << std::endl;
- p = new Welcome( data, clientID );
+ p = new Welcome( data, peerID );
break;
case Type::DeleteObjects:
// COUT(5) << "deleteobjects" << std::endl;
- p = new DeleteObjects( data, clientID );
+ p = new DeleteObjects( data, peerID );
break;
case Type::FunctionCalls:
// COUT(5) << "functionCalls" << std::endl;
- p = new FunctionCalls( data, clientID );
+ p = new FunctionCalls( data, peerID );
break;
case Type::FunctionIDs:
// COUT(5) << "functionIDs" << std::endl;
- p = new FunctionIDs( data, clientID );
+ p = new FunctionIDs( data, peerID );
break;
default:
assert(0);
Modified: code/branches/network5/src/libraries/network/packet/Packet.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/Packet.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Packet.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -67,24 +67,29 @@
virtual unsigned char *getData(){ return data_; };
virtual unsigned int getSize() const =0;
- virtual bool process()=0;
+ virtual bool process(orxonox::Host* host)=0;
inline uint32_t getFlags()
{ return flags_; }
- inline int getClientID()
- { return clientID_; }
- inline void setClientID( int id )
- { clientID_ = id; }
+ inline int getPeerID()
+ { return peerID_; }
+ inline void setPeerID( int id )
+ { peerID_ = id; }
+ inline bool isReliable()
+ { return this->flags_ & PacketFlag::Reliable; }
+ inline uint32_t getRequiredGamestateID()
+ { return this->requiredGamestateID_; }
- virtual bool send();
+ virtual bool send(orxonox::Host* host);
protected:
Packet();
- Packet(uint8_t *data, unsigned int clientID);
+ Packet(uint8_t *data, unsigned int peerID);
// Packet(ENetPacket *packet, ENetPeer *peer);
inline bool isDataENetAllocated() const
{ return bDataENetAllocated_; }
uint32_t flags_;
- unsigned int clientID_;
+ unsigned int peerID_;
+ uint32_t requiredGamestateID_;
Direction::Value packetDirection_;
/** Pointer to the data. Be careful when deleting it because it might
point to a location that was allocated by ENet.
Modified: code/branches/network5/src/libraries/network/packet/Welcome.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Welcome.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Welcome.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -72,11 +72,11 @@
return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
}
-bool Welcome::process(){
+bool Welcome::process(orxonox::Host* host){
uint32_t clientID;
clientID = *(uint32_t *)(data_ + _CLIENTID );
assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
- Host::setClientID(clientID);
+ host->setClientID(clientID);
COUT(3) << "Welcome set clientId: " << clientID << endl;
Synchronisable::setClient(true);
delete this;
Modified: code/branches/network5/src/libraries/network/packet/Welcome.h
===================================================================
--- code/branches/network5/src/libraries/network/packet/Welcome.h 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/libraries/network/packet/Welcome.h 2010-12-19 13:27:06 UTC (rev 7777)
@@ -46,7 +46,7 @@
uint8_t *getData();
inline unsigned int getSize() const;
- bool process();
+ virtual bool process(orxonox::Host* host);
private:
};
Modified: code/branches/network5/src/orxonox/PlayerManager.cc
===================================================================
--- code/branches/network5/src/orxonox/PlayerManager.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/orxonox/PlayerManager.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -53,6 +53,7 @@
void PlayerManager::clientConnected(unsigned int clientID)
{
+ COUT(0) << "PlayerManager: client connected with id: " << clientID << endl;
if (GameMode::isMaster())
{
if (clientID != 0)
Modified: code/branches/network5/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/branches/network5/src/orxonox/gametypes/Gametype.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/orxonox/gametypes/Gametype.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -170,6 +170,7 @@
void Gametype::playerEntered(PlayerInfo* player)
{
+ COUT(0) << "Gametype: playerentered" << endl;
this->players_[player].state_ = PlayerState::Joined;
}
@@ -410,6 +411,7 @@
void Gametype::spawnPlayer(PlayerInfo* player)
{
+ COUT(0) << "Gametype: spawnPlayer" << endl;
SpawnPoint* spawnpoint = this->getBestSpawnPoint(player);
if (spawnpoint)
{
Modified: code/branches/network5/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/branches/network5/src/orxonox/infos/HumanPlayer.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/orxonox/infos/HumanPlayer.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -44,6 +44,7 @@
HumanPlayer::HumanPlayer(BaseObject* creator) : PlayerInfo(creator)
{
+ COUT(0) << "new HumanPlayer" << endl;
RegisterObject(HumanPlayer);
this->server_initialized_ = GameMode::isMaster();
@@ -132,6 +133,7 @@
void HumanPlayer::networkcallback_client_initialized()
{
+ COUT(0) << "networkcallback_client_initialized" << endl;
if (this->getGametype())
this->getGametype()->playerEntered(this);
}
Modified: code/branches/network5/src/orxonox/worldentities/pawns/Spectator.cc
===================================================================
--- code/branches/network5/src/orxonox/worldentities/pawns/Spectator.cc 2010-12-17 19:26:35 UTC (rev 7776)
+++ code/branches/network5/src/orxonox/worldentities/pawns/Spectator.cc 2010-12-19 13:27:06 UTC (rev 7777)
@@ -42,6 +42,7 @@
Spectator::Spectator(BaseObject* creator) : ControllableEntity(creator)
{
+ COUT(0) << "creating specator" << endl;
RegisterObject(Spectator);
this->speed_ = 200;
More information about the Orxonox-commit
mailing list