[Orxonox-commit 54] r2759 - in trunk/src: core network network/packet network/synchronisable orxonox/gamestates orxonox/gui orxonox/objects/worldentities
scheusso at orxonox.net
scheusso at orxonox.net
Sun Mar 8 16:51:28 CET 2009
Author: scheusso
Date: 2009-03-08 16:51:27 +0100 (Sun, 08 Mar 2009)
New Revision: 2759
Modified:
trunk/src/core/ArgumentCompletionFunctions.cc
trunk/src/core/CommandLine.cc
trunk/src/core/ConfigFileManager.cc
trunk/src/core/Core.cc
trunk/src/core/Core.h
trunk/src/core/Factory.cc
trunk/src/core/Factory.h
trunk/src/core/Language.cc
trunk/src/core/LuaBind.cc
trunk/src/network/ConnectionManager.cc
trunk/src/network/ConnectionManager.h
trunk/src/network/packet/ClassID.cc
trunk/src/network/packet/ClassID.h
trunk/src/network/packet/Gamestate.cc
trunk/src/network/packet/Gamestate.h
trunk/src/network/synchronisable/Synchronisable.cc
trunk/src/network/synchronisable/Synchronisable.h
trunk/src/orxonox/gamestates/GSGraphics.cc
trunk/src/orxonox/gamestates/GSLevel.cc
trunk/src/orxonox/gamestates/GSRoot.cc
trunk/src/orxonox/gui/GUIManager.cc
trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc
Log:
merged network branch (windows,multiplayer fixes) back to trunk
Modified: trunk/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- trunk/src/core/ArgumentCompletionFunctions.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/ArgumentCompletionFunctions.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -75,7 +75,7 @@
{
std::string dir = startdirectory.string();
if (dir.size() > 0 && dir[dir.size() - 1] == ':')
- startdirectory = dir + CP_SLASH;
+ startdirectory = dir + '/';
}
#endif
@@ -85,7 +85,7 @@
while (file != end)
{
if (boost::filesystem::is_directory(*file))
- dirlist.push_back(ArgumentCompletionListElement((*file).string() + CP_SLASH, getLowercase((*file).string()) + "/", (*file).BOOST_LEAF_FUNCTION() + "/"));
+ dirlist.push_back(ArgumentCompletionListElement((*file).string() + '/', getLowercase((*file).string()) + '/', (*file).BOOST_LEAF_FUNCTION() + '/'));
else
filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).BOOST_LEAF_FUNCTION()));
++file;
Modified: trunk/src/core/CommandLine.cc
===================================================================
--- trunk/src/core/CommandLine.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/CommandLine.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -306,7 +306,7 @@
// look for additional arguments in given file or start.ini as default
// They will not overwrite the arguments given directly
std::ifstream file;
- file.open(filepath.file_string().c_str());
+ file.open(filepath.string().c_str());
args.clear();
if (file)
{
Modified: trunk/src/core/ConfigFileManager.cc
===================================================================
--- trunk/src/core/ConfigFileManager.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/ConfigFileManager.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -240,7 +240,7 @@
// Open the file
std::ifstream file;
- file.open(filepath.file_string().c_str(), std::fstream::in);
+ file.open(filepath.string().c_str(), std::fstream::in);
if (file.is_open())
{
@@ -346,7 +346,7 @@
boost::filesystem::path filepath(Core::getConfigPath() / this->filename_);
std::ofstream file;
- file.open(filepath.file_string().c_str(), std::fstream::out);
+ file.open(filepath.string().c_str(), std::fstream::out);
file.setf(std::ios::fixed, std::ios::floatfield);
file.precision(6);
Modified: trunk/src/core/Core.cc
===================================================================
--- trunk/src/core/Core.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/Core.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -259,12 +259,7 @@
}
/*static*/ std::string Core::getMediaPathString()
{
- return mediaPath_g.directory_string() + CP_SLASH;
- }
- /*static*/ std::string Core::getMediaPathPOSIXString()
- {
return mediaPath_g.string() + '/';
-
}
/*static*/ const boost::filesystem::path& Core::getConfigPath()
@@ -273,10 +268,6 @@
}
/*static*/ std::string Core::getConfigPathString()
{
- return configPath_g.directory_string() + CP_SLASH;
- }
- /*static*/ std::string Core::getConfigPathPOSIXString()
- {
return configPath_g.string() + '/';
}
@@ -286,10 +277,6 @@
}
/*static*/ std::string Core::getLogPathString()
{
- return logPath_g.directory_string() + CP_SLASH;
- }
- /*static*/ std::string Core::getLogPathPOSIXString()
- {
return logPath_g.string() + '/';
}
@@ -455,7 +442,7 @@
if (boost::filesystem::exists(it->first) && !boost::filesystem::is_directory(it->first))
{
ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
- Please remove " + it->first.file_string());
+ Please remove " + it->first.string());
}
if (boost::filesystem::create_directories(it->first)) // function may not return true at all (bug?)
{
Modified: trunk/src/core/Core.h
===================================================================
--- trunk/src/core/Core.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/Core.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -82,9 +82,6 @@
static std::string getMediaPathString();
static std::string getConfigPathString();
static std::string getLogPathString();
- static std::string getMediaPathPOSIXString();
- static std::string getConfigPathPOSIXString();
- static std::string getLogPathPOSIXString();
// fast access global variables.
static bool showsGraphics() { return bShowsGraphics_s; }
Modified: trunk/src/core/Factory.cc
===================================================================
--- trunk/src/core/Factory.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/Factory.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -86,12 +86,20 @@
*/
void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)
{
- getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
+// getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
//std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl;
}
/**
+ @brief Cleans the NetworkID map (needed on clients for correct initialization)
+ */
+ void Factory::cleanNetworkIDs()
+ {
+ getFactoryPointer()->identifierNetworkIDMap_.clear();
+ }
+
+ /**
@brief Creates the class-hierarchy by creating and destroying one object of each type.
*/
void Factory::createClassHierarchy()
Modified: trunk/src/core/Factory.h
===================================================================
--- trunk/src/core/Factory.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/Factory.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -62,6 +62,7 @@
static Identifier* getIdentifier(const uint32_t id);
static void add(const std::string& name, Identifier* identifier);
static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
+ static void cleanNetworkIDs();
static void createClassHierarchy();
static Factory* getFactoryPointer(); // avoid overriding order problem in the static intialisation process
Modified: trunk/src/core/Language.cc
===================================================================
--- trunk/src/core/Language.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/Language.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -209,12 +209,12 @@
// This creates the file if it's not existing
std::ofstream createFile;
- createFile.open(filepath.file_string().c_str(), std::fstream::app);
+ createFile.open(filepath.string().c_str(), std::fstream::app);
createFile.close();
// Open the file
std::ifstream file;
- file.open(filepath.file_string().c_str(), std::fstream::in);
+ file.open(filepath.string().c_str(), std::fstream::in);
if (!file.is_open())
{
@@ -260,7 +260,7 @@
// Open the file
std::ifstream file;
- file.open(filepath.file_string().c_str(), std::fstream::in);
+ file.open(filepath.string().c_str(), std::fstream::in);
if (!file.is_open())
{
@@ -316,7 +316,7 @@
// Open the file
std::ofstream file;
- file.open(filepath.file_string().c_str(), std::fstream::out);
+ file.open(filepath.string().c_str(), std::fstream::out);
if (!file.is_open())
{
Modified: trunk/src/core/LuaBind.cc
===================================================================
--- trunk/src/core/LuaBind.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/core/LuaBind.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -52,7 +52,7 @@
assert(LuaBind::singletonRef_s == 0);
LuaBind::singletonRef_s = this;
- this->includePath_ = Core::getMediaPathPOSIXString();
+ this->includePath_ = Core::getMediaPathString();
luaState_ = lua_open();
luaSource_ = "";
@@ -89,7 +89,7 @@
output_ = "";
std::ifstream file;
- file.open(filepath.file_string().c_str(), std::fstream::in);
+ file.open(filepath.string().c_str(), std::fstream::in);
if (!file.is_open())
{
Modified: trunk/src/network/ConnectionManager.cc
===================================================================
--- trunk/src/network/ConnectionManager.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/ConnectionManager.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -45,9 +45,6 @@
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
-#include "core/CoreIncludes.h"
-#include "core/BaseObject.h"
-#include "core/Iterator.h"
#include "util/Math.h"
#include "util/Sleep.h"
#include "ClientInformation.h"
@@ -123,14 +120,11 @@
void ConnectionManager::createListener() {
receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
- //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
- //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
return;
}
bool ConnectionManager::quitListener() {
quit=true;
- //network_threads.join_all();
receiverThread_->join();
return true;
}
@@ -205,25 +199,11 @@
switch(event->type){
// log handling ================
case ENET_EVENT_TYPE_CONNECT:
- //COUT(3) << "adding event_type_connect to queue" << std::endl;
case ENET_EVENT_TYPE_DISCONNECT:
- //addClient(event);
- //this is a workaround to ensure thread safety
- //COUT(5) << "Con.Man: connection event has occured" << std::endl;
- //break;
case ENET_EVENT_TYPE_RECEIVE:
- //std::cout << "received data" << std::endl;
- //COUT(5) << "Con.Man: receive event has occured" << std::endl;
- // only add, if client has connected yet and not been disconnected
- //if(head_->findClient(&event->peer->address))
processData(event);
event = new ENetEvent;
-// else
-// COUT(3) << "received a packet from a client we don't know" << std::endl;
break;
- //case ENET_EVENT_TYPE_DISCONNECT:
- //clientDisconnect(event->peer);
- //break;
case ENET_EVENT_TYPE_NONE:
//receiverThread_->yield();
msleep(1);
@@ -298,37 +278,19 @@
return ClientInformation::findClient(clientID)->getPeer();
}
- /**
- *
- * @param clientID
- */
- void ConnectionManager::syncClassid(unsigned int clientID) {
- unsigned int network_id=0, failures=0;
- std::string classname;
- Identifier *id;
- std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
- while(it != Factory::getFactoryMapEnd()){
- id = (*it).second;
- if(id == NULL)
- continue;
- classname = id->getName();
- network_id = id->getNetworkID();
- if(network_id==0)
- COUT(3) << "we got a null class id: " << id->getName() << std::endl;
- COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
- packet::ClassID *classid = new packet::ClassID( network_id, classname );
- classid->setClientID(clientID);
- while(!classid->send() && failures < 10){
- failures++;
- }
- ++it;
+ void ConnectionManager::syncClassid(unsigned int clientID) {
+ int failures=0;
+ packet::ClassID *classid = new packet::ClassID();
+ classid->setClientID(clientID);
+ while(!classid->send() && failures < 10){
+ failures++;
}
- //sendPackets();
+ assert(failures<10);
COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
}
+
-
void ConnectionManager::disconnectClient(ClientInformation *client){
{
boost::recursive_mutex::scoped_lock lock(ConnectionManager::enet_mutex);
Modified: trunk/src/network/ConnectionManager.h
===================================================================
--- trunk/src/network/ConnectionManager.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/ConnectionManager.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -79,32 +79,23 @@
public:
static boost::recursive_mutex enet_mutex;
ConnectionManager();
- //ConnectionManager(ClientInformation *head);
ConnectionManager(int port);
ConnectionManager(int port, const char *address);
ConnectionManager(int port, const std::string& address);
~ConnectionManager();
- //ENetPacket *getPacket(ENetAddress &address); // thread1
- //ENetPacket *getPacket(int &clientID);
ENetEvent *getEvent();
bool queueEmpty();
void createListener();
bool quitListener();
-// bool addPacket(Packet::Packet *packet);
static bool addPacket(ENetPacket *packet, ENetPeer *peer);
static bool addPacket(ENetPacket *packet, int ID);
static bool addPacketAll(ENetPacket *packet);
- // bool sendPackets(ENetEvent *event);
bool sendPackets();
- //bool createClient(int clientID);
void disconnectClient(ClientInformation *client);
void syncClassid(unsigned int clientID);
private:
-// bool clientDisconnect(ENetPeer *peer);
-// bool removeClient(int clientID);
bool processData(ENetEvent *event);
- //bool addClient(ENetEvent *event);
void receiverThread();
void disconnectClients();
int getClientID(ENetPeer peer);
Modified: trunk/src/network/packet/ClassID.cc
===================================================================
--- trunk/src/network/packet/ClassID.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/packet/ClassID.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -30,56 +30,129 @@
#include "ClassID.h"
#include "core/CoreIncludes.h"
+#include "core/Factory.h"
#include <cstring>
+#include <string>
#include <assert.h>
+#include <map>
+#include <queue>
namespace orxonox {
namespace packet {
+#define PACKET_FLAGS_CLASSID ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID 0
- ClassID::ClassID( unsigned int classID, std::string className )
- : Packet()
-{
+
+ClassID::ClassID( ) : Packet(){
+ Identifier *id;
+ std::string classname;
+ unsigned int nrOfClasses=0;
+ unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
+ uint32_t network_id;
flags_ = flags_ | PACKET_FLAGS_CLASSID;
- classNameLength_=className.length()+1;
- assert(getSize());
- data_=new unsigned char[ getSize() ];
- assert(data_);
- *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID;
- *(unsigned int *)(data_ + _CLASSID ) = classID;
- *(unsigned int *)(data_ + _CLASSNAMELENGTH ) = classNameLength_;
- memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ );
+ std::queue<std::pair<uint32_t, std::string> > tempQueue;
+
+ //calculate total needed size (for all strings and integers)
+ std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
+ for(;it != Factory::getFactoryMapEnd();++it){
+ id = (*it).second;
+ if(id == NULL)
+ continue;
+ classname = id->getName();
+ network_id = id->getNetworkID();
+ if(network_id==0)
+ COUT(3) << "we got a null class id: " << id->getName() << std::endl;
+ // now push the network id and the classname to the stack
+ tempQueue.push( std::pair<unsigned int, std::string>(network_id, classname) );
+ ++nrOfClasses;
+ packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t);
+ }
+
+ this->data_=new uint8_t[ packetSize ];
+ //set the appropriate packet id
+ assert(this->data_);
+ *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;
+
+ uint8_t *temp=data_+sizeof(uint32_t);
+ // save the number of all classes
+ *(uint32_t*)temp = nrOfClasses;
+ temp += sizeof(uint32_t);
+
+ // now save all classids and classnames
+ std::pair<uint32_t, std::string> tempPair;
+ while( !tempQueue.empty() ){
+ tempPair = tempQueue.front();
+ tempQueue.pop();
+ *(uint32_t*)temp = tempPair.first;
+ *(uint32_t*)(temp+sizeof(uint32_t)) = tempPair.second.size()+1;
+ memcpy(temp+2*sizeof(uint32_t), tempPair.second.c_str(), tempPair.second.size()+1);
+ temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
+ }
+
+ COUT(0) << "classid packetSize is " << packetSize << endl;
+
}
ClassID::ClassID( uint8_t* data, unsigned int clientID )
: Packet(data, clientID)
{
- memcpy( (void *)&classNameLength_, &data[ _CLASSNAMELENGTH ], sizeof(classNameLength_) );
}
ClassID::~ClassID()
{
}
-unsigned int ClassID::getSize() const{
- return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t) + classNameLength_;
+uint32_t ClassID::getSize() const{
+ uint8_t *temp = data_+sizeof(uint32_t); // packet identification
+ uint32_t totalsize = sizeof(uint32_t); // packet identification
+ uint32_t nrOfClasses = *(uint32_t*)temp;
+ temp += sizeof(uint32_t);
+ totalsize += sizeof(uint32_t); // storage size for nr of all classes
+
+ for(unsigned int i=0; i<nrOfClasses; i++){
+ totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
+ }
+ return totalsize;
}
+
bool ClassID::process(){
- COUT(3) << "processing classid: " << getClassID() << " name: " << getClassName() << std::endl;
- Identifier *id=ClassByString( std::string(getClassName()) );
- if(id==NULL)
- return false;
- id->setNetworkID( getClassID() );
+ int nrOfClasses;
+ uint8_t *temp = data_+sizeof(uint32_t); //skip the packetid
+ uint32_t networkID;
+ uint32_t stringsize;
+ unsigned char *classname;
+
+
+ //clean the map of network ids
+ Factory::cleanNetworkIDs();
+
+ COUT(4) << "=== processing classids: " << endl;
+ std::pair<uint32_t, std::string> tempPair;
+ Identifier *id;
+ // read the total number of classes
+ nrOfClasses = *(uint32_t*)temp;
+ temp += sizeof(uint32_t);
+
+ for( int i=0; i<nrOfClasses; i++){
+ networkID = *(uint32_t*)temp;
+ 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;
+ if(id==NULL){
+ COUT(0) << "Recieved a bad classname" << endl;
+ abort();
+ }
+ id->setNetworkID( networkID );
+ temp += 2*sizeof(uint32_t) + stringsize;
+ }
delete this;
return true;
}
-unsigned int ClassID::getClassID(){
- return *(uint32_t *)(data_ + _CLASSID);
-}
-
} //namespace packet
}//namespace orxonox
Modified: trunk/src/network/packet/ClassID.h
===================================================================
--- trunk/src/network/packet/ClassID.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/packet/ClassID.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -37,11 +37,6 @@
namespace orxonox {
namespace packet {
-#define PACKET_FLAGS_CLASSID ENET_PACKET_FLAG_RELIABLE
-#define _PACKETID 0
-#define _CLASSID _PACKETID + sizeof(ENUM::Type)
-#define _CLASSNAMELENGTH _CLASSID + sizeof(uint32_t)
-#define _CLASSNAME _CLASSNAMELENGTH + sizeof(classNameLength_)
/**
@author
@@ -49,18 +44,14 @@
class _NetworkExport ClassID : public Packet
{
public:
- ClassID( unsigned int classID, std::string className );
+ ClassID( );
ClassID( uint8_t* data, unsigned int clientID );
~ClassID();
- inline unsigned int getSize() const;
+ uint32_t getSize() const;
bool process();
- unsigned int getClassID();
- unsigned int getClassNameLength(){ return classNameLength_; }
- const char *getClassName(){ return (const char*)(data_+_CLASSNAME); }
private:
- uint32_t classNameLength_;
};
} //namespace packet
Modified: trunk/src/network/packet/Gamestate.cc
===================================================================
--- trunk/src/network/packet/Gamestate.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/packet/Gamestate.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -47,10 +47,6 @@
#define PACKET_FLAG_GAMESTATE ENET_PACKET_FLAG_RELIABLE
-// Gamestate::Gamestate()
-// {
-// flags_ = flags_ | PACKET_FLAG_GAMESTATE;
-// }
Gamestate::Gamestate()
{
@@ -126,10 +122,8 @@
}// stop allocate additional memory
#endif
- //if(it->doSelection(id))
if ( it->doSync( id, mode ) )
dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
-// dataMap_[mem-data_]=(*it); // save the mem location of the synchronisable data
if(!it->getData(mem, id, mode))
return false; // mem pointer gets automatically increased because of call by reference
// increase size counter by size of current synchronisable
@@ -157,8 +151,6 @@
assert(!header_->isCompressed());
assert(!header_->isDiffed());
uint8_t *mem=data_+GamestateHeader::getSize();
- // get the start of the Synchronisable list
- //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();
Synchronisable *s;
// update the data of the objects we received
@@ -176,15 +168,10 @@
{
mem += objectheader.getDataSize();
}
-// COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
-// else
-// COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
}
else
{
bool b = s->updateData(mem, mode);
-// if(!b)
-// COUT(0) << "data could not be updated" << endl;
assert(b);
}
}
@@ -261,7 +248,6 @@
uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()];
uint8_t *dest = ndata + GamestateHeader::getSize();
- //unsigned char *dest = new unsigned char[buffer];
uint8_t *source = data_ + GamestateHeader::getSize();
int retval;
retval = compress( dest, &buffer, source, (uLong)(header_->getDataSize()) );
@@ -293,7 +279,6 @@
uint32_t datasize = header_->getDataSize();
uint32_t compsize = header_->getCompSize();
uint32_t bufsize;
-// assert(compsize<=datasize);
bufsize = datasize;
assert(bufsize!=0);
uint8_t *ndata = new uint8_t[bufsize + GamestateHeader::getSize()];
@@ -339,7 +324,6 @@
assert(!header_->isCompressed());
assert(!header_->isDiffed());
GamestateHeader diffHeader(base->data_);
- //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
uint32_t of=0; // pointers offset
uint32_t dest_length=0;
@@ -396,10 +380,6 @@
//copy in the zeros
for(it=dataMap_.begin(); it!=dataMap_.end();){
-// if((*it).objSize==0)
-// continue;
-// if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this
-// continue; // merged from objecthierarchy2, doesn't work anymore; TODO: change this
SynchronisableHeader oldobjectheader(origdata);
SynchronisableHeader newobjectheader(newdata);
if ( (*it).objSize == 0 )
@@ -407,8 +387,6 @@
++it;
continue;
}
-// object = Synchronisable::getSynchronisable( (*it).objID );
-// assert(object->objectID == oldobjectheader->objectID);
objectsize = oldobjectheader.getDataSize();
objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
if ( (*it).objID == oldobjectheader.getObjectID() ){
@@ -446,7 +424,6 @@
assert(this && base);assert(data_);
assert(header_->isDiffed());
assert(!header_->isCompressed() && !base->header_->isCompressed());
- //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
uint8_t *basep = GAMESTATE_START(base->data_);
uint8_t *gs = GAMESTATE_START(this->data_);
uint32_t of=0; // pointers offset
Modified: trunk/src/network/packet/Gamestate.h
===================================================================
--- trunk/src/network/packet/Gamestate.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/packet/Gamestate.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -92,9 +92,6 @@
{ assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); }
private:
uint8_t *data_;
-//#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
-//#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
-//#define HEADER GAMESTATE_HEADER(data_)
};
Modified: trunk/src/network/synchronisable/Synchronisable.cc
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/synchronisable/Synchronisable.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -99,28 +99,12 @@
delete (*it);
if (this->objectMode_ != 0x0 && (Host::running() && Host::isServer()))
deletedObjects_.push(objectID);
-// COUT(3) << "destruct synchronisable +++" << objectID << " | " << classID << std::endl;
-// COUT(3) << " bump ---" << objectID << " | " << &objectMap_ << std::endl;
-// assert(objectMap_[objectID]->objectID==objectID);
-// objectMap_.erase(objectID);
}
std::map<uint32_t, Synchronisable*>::iterator it;
it = objectMap_.find(objectID);
if (it != objectMap_.end())
objectMap_.erase(it);
- //HACK HACK HACK HACK HACK HACK
- // this hack ensures that children of this object also get destroyed
-// ObjectList<Synchronisable>::iterator it2, it3;
-// // get total size of gamestate
-// for(it2 = ObjectList<Synchronisable>::begin(); it2; ++it2)
-// {
-// if ( it2->getCreatorID() == this->objectID && it2->getCreatorID() != OBJECTID_UNKNOWN )
-// {
-// Synchronisable::deleteObject( it2->getObjectID() );
-// }
-// }
- //HACK HACK HACK HACK HACK HACK
}
@@ -157,6 +141,8 @@
Identifier* id = ClassByID(header.getClassID());
if (!id)
{
+ for(int i = 0; i<100; i++)
+ COUT(0) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
COUT(0) << "Assertion failed: id" << std::endl;
COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
abort();
@@ -202,11 +188,9 @@
* @return true/false
*/
bool Synchronisable::deleteObject(uint32_t objectID){
-// assert(getSynchronisable(objectID));
if(!getSynchronisable(objectID))
return false;
assert(getSynchronisable(objectID)->objectID==objectID);
-// delete objectMap_[objectID];
Synchronisable *s = getSynchronisable(objectID);
if(s)
delete s;
@@ -257,7 +241,6 @@
//if this tick is we dont synchronise, then abort now
if(!doSync(id, mode))
return true;
- //std::cout << "inside getData" << std::endl;
uint32_t tempsize = 0;
if (this->classID==0)
COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
@@ -266,7 +249,6 @@
this->classID = this->getIdentifier()->getNetworkID();
assert(this->classID==this->getIdentifier()->getNetworkID());
-// this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
std::list<SynchronisableVariableBase*>::iterator i;
uint32_t size;
size=getSize(id, mode);
@@ -304,8 +286,6 @@
if(mode==0x0)
mode=state_;
std::list<SynchronisableVariableBase *>::iterator i;
- //assert(objectMode_!=0x0);
- //assert( (mode ^ objectMode_) != 0);
if(syncList.empty()){
assert(0);
COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
Modified: trunk/src/network/synchronisable/Synchronisable.h
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.h 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/network/synchronisable/Synchronisable.h 2009-03-08 15:51:27 UTC (rev 2759)
@@ -141,7 +141,6 @@
protected:
Synchronisable(BaseObject* creator);
-// void registerVariable(void *var, int size, variableType t, uint8_t mode=0x1, NetworkCallbackBase *cb=0);
template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
template <class T> void unregisterVariable(T& var);
void setObjectMode(uint8_t mode);
@@ -204,8 +203,6 @@
template <> _NetworkExport void Synchronisable::registerVariable( mbool& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
template <> _NetworkExport void Synchronisable::registerVariable( const Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
template <> _NetworkExport void Synchronisable::registerVariable( Quaternion& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-// template <> _NetworkExport void Synchronisable::registerVariable( LODParticle::LOD& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
-// template <> _NetworkExport void Synchronisable::registerVariable( Ogre::Light::LightTypes& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional);
}
#endif /* _Synchronisable_H__ */
Modified: trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSGraphics.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/orxonox/gamestates/GSGraphics.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -135,7 +135,7 @@
// load debug overlay
COUT(3) << "Loading Debug Overlay..." << std::endl;
- this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").file_string());
+ this->debugOverlay_ = new XMLFile((Core::getMediaPath() / "overlay" / "debug.oxo").string());
Loader::open(debugOverlay_);
// Calls the InputManager which sets up the input devices.
@@ -303,7 +303,7 @@
// create our own log that we can listen to
Ogre::Log *myLog;
- myLog = ogreLogger_->createLog(ogreLogFilepath.file_string(), true, false, false);
+ myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
COUT(4) << "Ogre Log created" << std::endl;
myLog->setLogDetail(Ogre::LL_BOREME);
@@ -316,12 +316,12 @@
{
// create a zero sized file
std::ofstream creator;
- creator.open(ogreConfigFilepath.file_string().c_str());
+ creator.open(ogreConfigFilepath.string().c_str());
creator.close();
}
// Leave plugins file empty. We're going to do that part manually later
- ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.file_string(), ogreLogFilepath.file_string());
+ ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
COUT(3) << "Ogre set up done." << std::endl;
}
@@ -335,6 +335,7 @@
boost::filesystem::path folder(ogrePluginsFolder_);
// Do some SubString magic to get the comma separated list of plugins
SubString plugins(ogrePlugins_, ",", " ", false, 92, false, 34, false, 40, 41, false, '\0');
+ // Use backslash paths on Windows! file_string() already does that though.
for (unsigned int i = 0; i < plugins.size(); ++i)
ogreRoot_->loadPlugin((folder / plugins[i]).file_string());
}
@@ -355,7 +356,7 @@
Ogre::ConfigFile cf;
try
{
- cf.load((Core::getMediaPath() / resourceFile_).file_string());
+ cf.load((Core::getMediaPath() / resourceFile_).string());
}
catch (...)
{
@@ -381,7 +382,7 @@
archName = i->second; // name (and location) of archive
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
- (Core::getMediaPath() / archName).directory_string(), typeName, secName);
+ (Core::getMediaPath() / archName).string(), typeName, secName);
}
}
catch (Ogre::Exception& ex)
Modified: trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSLevel.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/orxonox/gamestates/GSLevel.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -201,7 +201,7 @@
COUT(0) << "Loading level..." << std::endl;
std::string levelName;
CommandLine::getValue("level", &levelName);
- startFile_ = new XMLFile(Core::getMediaPathString() + "levels" + CP_SLASH + levelName);
+ startFile_ = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
Loader::open(startFile_);
}
Modified: trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSRoot.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/orxonox/gamestates/GSRoot.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -103,7 +103,7 @@
this->luaBind_ = new LuaBind();
// initialise TCL
- this->tclBind_ = new TclBind(Core::getMediaPathPOSIXString());
+ this->tclBind_ = new TclBind(Core::getMediaPathString());
this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
// create a shell
Modified: trunk/src/orxonox/gui/GUIManager.cc
===================================================================
--- trunk/src/orxonox/gui/GUIManager.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/orxonox/gui/GUIManager.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -153,7 +153,7 @@
// Create our own logger to specify the filepath
boost::filesystem::path ceguiLogFilepath(Core::getLogPath() / "cegui.log");
this->ceguiLogger_ = new DefaultLogger();
- this->ceguiLogger_->setLogFilename(ceguiLogFilepath.file_string());
+ this->ceguiLogger_->setLogFilename(ceguiLogFilepath.string());
// set the log level according to ours (translate by subtracting 1)
this->ceguiLogger_->setLoggingLevel(
(LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
Modified: trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc 2009-03-08 15:40:01 UTC (rev 2758)
+++ trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc 2009-03-08 15:51:27 UTC (rev 2759)
@@ -46,22 +46,30 @@
{
RegisterObject(ExplosionChunk);
- if (!this->getScene() || !Core::showsGraphics() || !this->getScene()->getSceneManager())
+ if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given.");
this->bStop_ = false;
this->LOD_ = LODParticle::normal;
- try
+ if ( Core::showsGraphics() )
{
- this->fire_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
- this->attachOgreObject(this->fire_->getParticleSystem());
- this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
- this->attachOgreObject(this->smoke_->getParticleSystem());
+ try
+ {
+ this->fire_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
+ this->attachOgreObject(this->fire_->getParticleSystem());
+ this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
+ this->attachOgreObject(this->smoke_->getParticleSystem());
+ }
+ catch (...)
+ {
+ COUT(1) << "Error: Couln't load particle effect in ExplosionChunk." << std::endl;
+ this->fire_ = 0;
+ this->smoke_ = 0;
+ }
}
- catch (...)
+ else
{
- COUT(1) << "Error: Couln't load particle effect in ExplosionChunk." << std::endl;
this->fire_ = 0;
this->smoke_ = 0;
}
More information about the Orxonox-commit
mailing list