[Orxonox-commit 775] r3302 - in branches/netp6/src/network: . packet synchronisable
scheusso at orxonox.net
scheusso at orxonox.net
Sat Jul 18 17:13:38 CEST 2009
Author: scheusso
Date: 2009-07-18 17:13:38 +0200 (Sat, 18 Jul 2009)
New Revision: 3302
Modified:
branches/netp6/src/network/ClientInformation.h
branches/netp6/src/network/Connection.cc
branches/netp6/src/network/GamestateManager.cc
branches/netp6/src/network/Server.cc
branches/netp6/src/network/Server.h
branches/netp6/src/network/packet/ClassID.cc
branches/netp6/src/network/packet/FunctionIDs.cc
branches/netp6/src/network/synchronisable/Synchronisable.cc
branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc
Log:
changed some debug output
removed some uneccessary "multi"threading
some enhancements in Connection
Modified: branches/netp6/src/network/ClientInformation.h
===================================================================
--- branches/netp6/src/network/ClientInformation.h 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/ClientInformation.h 2009-07-18 15:13:38 UTC (rev 3302)
@@ -86,6 +86,7 @@
static ClientInformation *findClient(unsigned int clientID, bool look_backwards=false);
static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
static ClientInformation *getBegin(){return head_;}
+ static bool hasClients(){ return ClientInformation::head_!=0; }
bool setSynched(bool s);
bool getSynched();
Modified: branches/netp6/src/network/Connection.cc
===================================================================
--- branches/netp6/src/network/Connection.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/Connection.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -30,7 +30,6 @@
#include <cassert>
#include <enet/enet.h>
-#include <OgreTimer.h>
#include "packet/Packet.h"
namespace orxonox
@@ -76,9 +75,8 @@
ENetEvent event;
assert(this->host_);
- Ogre::Timer timer;
- while( timer.getMilliseconds()<NETWORK_MAX_QUEUE_PROCESS_TIME && enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
+ while( enet_host_service( this->host_, &event, NETWORK_WAIT_TIMEOUT ) > 0 )
{
switch(event.type){
// log handling ================
Modified: branches/netp6/src/network/GamestateManager.cc
===================================================================
--- branches/netp6/src/network/GamestateManager.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/GamestateManager.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -98,6 +98,8 @@
}
bool GamestateManager::processGamestates(){
+ if( this->gamestateQueue.empty() )
+ return true;
std::map<unsigned int, packet::Gamestate*>::iterator it;
// now push only the most recent gamestates we received (ignore obsolete ones)
for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
@@ -140,7 +142,6 @@
COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
int cid = temp->getID(); //get client id
- packet::Gamestate *gs;
unsigned int gID = temp->getGamestateID();
if(!reference)
return;
@@ -241,7 +242,7 @@
}
assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
- COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
+ 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;
Modified: branches/netp6/src/network/Server.cc
===================================================================
--- branches/netp6/src/network/Server.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/Server.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -48,7 +48,6 @@
#include "core/Clock.h"
#include "core/ObjectList.h"
#include "core/Executor.h"
-#include "core/ThreadPool.h"
#include "packet/Chat.h"
#include "packet/ClassID.h"
#include "packet/DeleteObjects.h"
@@ -70,13 +69,11 @@
*/
Server::Server() {
this->timeSinceLastUpdate_=0;
- this->threadPool_ = new ThreadPool();
}
Server::Server(int port){
this->setPort( port );
this->timeSinceLastUpdate_=0;
- this->threadPool_ = new ThreadPool();
}
/**
@@ -88,14 +85,12 @@
this->setPort( port );
this->setBindAddress( bindAddress );
this->timeSinceLastUpdate_=0;
- this->threadPool_ = new ThreadPool();
}
/**
* @brief Destructor
*/
Server::~Server(){
- delete this->threadPool_;
}
/**
@@ -140,26 +135,24 @@
void Server::update(const Clock& time) {
// receive incoming packets
Connection::processQueue();
- // process incoming gamestates
- GamestateManager::processGamestates();
- // pass sendFunctionCalls to worker thread pool
- ExecutorStatic* functioncalls = createExecutor( createFunctor(&FunctionCallManager::sendCalls) );
- this->threadPool_->passFunction( functioncalls, true );
-
- this->threadPool_->synchronise();
-
- //this steers our network frequency
- timeSinceLastUpdate_+=time.getDeltaTime();
- if(timeSinceLastUpdate_>=NETWORK_PERIOD)
+ if ( ClientInformation::hasClients() )
{
- timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
-// ExecutorMember<GamestateManager>* updategamestate = createExecutor( createFunctor(&GamestateManager::updateGamestate);
-// updategamestate->setObject( static_cast<GamestateManager*>(this) );
-// this->threadPool_->passFunction( updategamestate );
- updateGamestate();
+ // process incoming gamestates
+ GamestateManager::processGamestates();
+
+ // send function calls to clients
+ FunctionCallManager::sendCalls();
+
+ //this steers our network frequency
+ timeSinceLastUpdate_+=time.getDeltaTime();
+ if(timeSinceLastUpdate_>=NETWORK_PERIOD)
+ {
+ timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
+ updateGamestate();
+ }
+ sendPackets(); // flush the enet queue
}
- sendPackets(); // flush the enet queue
}
bool Server::queuePacket(ENetPacket *packet, int clientID){
Modified: branches/netp6/src/network/Server.h
===================================================================
--- branches/netp6/src/network/Server.h 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/Server.h 2009-07-18 15:13:38 UTC (rev 3302)
@@ -75,7 +75,6 @@
bool sendChat(const std::string& message, unsigned int clientID);
void syncClassid(unsigned int clientID);
- ThreadPool* threadPool_;
float timeSinceLastUpdate_;
};
Modified: branches/netp6/src/network/packet/ClassID.cc
===================================================================
--- branches/netp6/src/network/packet/ClassID.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/packet/ClassID.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -141,7 +141,7 @@
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
classname = temp+2*sizeof(uint32_t);
id=ClassByString( std::string((const char*)classname) );
- COUT(0) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
+ COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
if(id==NULL){
COUT(0) << "Recieved a bad classname" << endl;
abort();
Modified: branches/netp6/src/network/packet/FunctionIDs.cc
===================================================================
--- branches/netp6/src/network/packet/FunctionIDs.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/packet/FunctionIDs.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -131,7 +131,7 @@
networkID = *(uint32_t*)temp;
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
functionname = temp+2*sizeof(uint32_t);
- COUT(0) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
+ COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
temp += 2*sizeof(uint32_t) + stringsize;
}
Modified: branches/netp6/src/network/synchronisable/Synchronisable.cc
===================================================================
--- branches/netp6/src/network/synchronisable/Synchronisable.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/synchronisable/Synchronisable.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -95,12 +95,12 @@
// remove object from the static objectMap
if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
deletedObjects_.push(objectID);
- // delete all Synchronisable Variables from syncList ( which are also in stringList )
- for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
- delete (*it);
- syncList.clear();
- stringList.clear();
}
+ // delete all Synchronisable Variables from syncList ( which are also in stringList )
+ for(std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin(); it!=syncList.end(); it++)
+ delete (*it);
+ syncList.clear();
+ stringList.clear();
std::map<uint32_t, Synchronisable*>::iterator it;
it = objectMap_.find(objectID);
if (it != objectMap_.end())
Modified: branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc
===================================================================
--- branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc 2009-07-18 14:03:59 UTC (rev 3301)
+++ branches/netp6/src/network/synchronisable/SynchronisableSpecialisations.cc 2009-07-18 15:13:38 UTC (rev 3302)
@@ -37,22 +37,15 @@
namespace orxonox{
-// template <> void Synchronisable::registerVariable( const std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
-// {
-// if (bidirectional)
-// syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
-// else
-// syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
-// stringList.push_back(syncList.back());
-// }
-
template <> void Synchronisable::registerVariable( std::string& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional)
{
+ SynchronisableVariableBase* sv;
if (bidirectional)
- syncList.push_back(new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb));
+ sv = new SynchronisableVariableBidirectional<const std::string>(variable, mode, cb);
else
- syncList.push_back(new SynchronisableVariable<const std::string>(variable, mode, cb));
- stringList.push_back(syncList.back());
+ sv = new SynchronisableVariable<const std::string>(variable, mode, cb);
+ syncList.push_back(sv);
+ stringList.push_back(sv);
}
template <> void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
More information about the Orxonox-commit
mailing list