[Orxonox-commit 1118] r5839 - in code/branches/core5/src: libraries/core libraries/network/synchronisable orxonox
scheusso at orxonox.net
scheusso at orxonox.net
Wed Sep 30 12:42:29 CEST 2009
Author: scheusso
Date: 2009-09-30 12:42:28 +0200 (Wed, 30 Sep 2009)
New Revision: 5839
Modified:
code/branches/core5/src/libraries/core/BaseObject.cc
code/branches/core5/src/libraries/core/BaseObject.h
code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc
code/branches/core5/src/orxonox/Scene.cc
code/branches/core5/src/orxonox/Scene.h
Log:
Fixed problem with scene and creators
creatorID is now always the objectID of the scene except for the case
- if the object is the scene (then the creatorID is OBJECTID_UNKNOWN)
- if the object is "above" the scene (e.g. level), then the cID is also OBJECTID_UNKNOWN
Modified: code/branches/core5/src/libraries/core/BaseObject.cc
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.cc 2009-09-30 08:21:51 UTC (rev 5838)
+++ code/branches/core5/src/libraries/core/BaseObject.cc 2009-09-30 10:42:28 UTC (rev 5839)
@@ -45,6 +45,7 @@
#include "XMLFile.h"
#include "XMLNameListener.h"
#include "XMLPort.h"
+#include "network/NetworkPrereqs.h"
namespace orxonox
{
@@ -73,7 +74,7 @@
{
this->setFile(this->creator_->getFile());
this->setNamespace(this->creator_->getNamespace());
- this->setScene(this->creator_->getScene());
+ this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
this->setGametype(this->creator_->getGametype());
}
else
@@ -81,6 +82,7 @@
this->file_ = 0;
this->namespace_ = 0;
this->scene_ = 0;
+ this->sceneID_ = OBJECTID_UNKNOWN;
this->gametype_ = 0;
}
}
Modified: code/branches/core5/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.h 2009-09-30 08:21:51 UTC (rev 5838)
+++ code/branches/core5/src/libraries/core/BaseObject.h 2009-09-30 10:42:28 UTC (rev 5839)
@@ -134,8 +134,9 @@
inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
inline BaseObject* getCreator() const { return this->creator_; }
- inline void setScene(const SmartPtr<Scene>& scene) { this->scene_ = scene; }
+ inline void setScene(const SmartPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
inline const SmartPtr<Scene>& getScene() const { return this->scene_; }
+ inline virtual uint32_t getSceneID() const { return this->sceneID_; }
inline void setGametype(const SmartPtr<Gametype>& gametype)
{
@@ -201,6 +202,7 @@
std::map<BaseObject*, std::string> eventListeners_;
std::list<BaseObject*> events_;
std::map<std::string, EventContainer*> eventContainers_;
+ uint32_t sceneID_;
};
SUPER_FUNCTION(0, BaseObject, XMLPort, false);
Modified: code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc 2009-09-30 08:21:51 UTC (rev 5838)
+++ code/branches/core5/src/libraries/network/synchronisable/Synchronisable.cc 2009-09-30 10:42:28 UTC (rev 5839)
@@ -71,22 +71,25 @@
this->setPriority( Priority::Normal );
// get creator id
- this->creatorID = OBJECTID_UNKNOWN;
+ if( creator )
+ this->creatorID = creator->getSceneID();
+ else
+ this->creatorID = OBJECTID_UNKNOWN;
- searchcreatorID:
+ /*searchcreatorID:
if (creator)
{
Synchronisable* synchronisable_creator = orxonox_cast<Synchronisable*>(creator);
if (synchronisable_creator && synchronisable_creator->objectMode_)
{
- this->creatorID = synchronisable_creator->getObjectID();
+ this->creatorID = synchronisable_creator->getScene()->getObjectID();
}
else if (creator != creator->getCreator())
{
creator = creator->getCreator();
goto searchcreatorID;
}
- }
+ }*/
}
/**
@@ -172,8 +175,10 @@
Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
assert(no);
no->objectID=header.getObjectID();
- no->creatorID=header.getCreatorID(); //TODO: remove this
+ //no->creatorID=header.getCreatorID(); //TODO: remove this
no->classID=header.getClassID();
+ assert(no->creatorID == header.getCreatorID());
+ //assert(no->classID == header.getClassID());
COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
// update data and create object/entity...
assert( Synchronisable::objectMap_.find(header.getObjectID()) == Synchronisable::objectMap_.end() );
Modified: code/branches/core5/src/orxonox/Scene.cc
===================================================================
--- code/branches/core5/src/orxonox/Scene.cc 2009-09-30 08:21:51 UTC (rev 5838)
+++ code/branches/core5/src/orxonox/Scene.cc 2009-09-30 10:42:28 UTC (rev 5839)
@@ -54,7 +54,7 @@
{
RegisterObject(Scene);
- this->setScene(SmartPtr<Scene>(this, false));
+ this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
this->bShadows_ = true;
if (GameMode::showsGraphics())
@@ -282,7 +282,7 @@
void Scene::addObject(BaseObject* object)
{
this->objects_.push_back(object);
- object->setScene(this);
+ object->setScene(this, this->getObjectID());
}
BaseObject* Scene::getObject(unsigned int index) const
Modified: code/branches/core5/src/orxonox/Scene.h
===================================================================
--- code/branches/core5/src/orxonox/Scene.h 2009-09-30 08:21:51 UTC (rev 5838)
+++ code/branches/core5/src/orxonox/Scene.h 2009-09-30 10:42:28 UTC (rev 5839)
@@ -72,6 +72,8 @@
inline Radar* getRadar()
{ return this->radar_; }
+
+ inline virtual uint32_t getSceneID() const { return this->getObjectID(); }
virtual void tick(float dt);
More information about the Orxonox-commit
mailing list