[Orxonox-commit 122] r2815 - in branches/gui/src: core core/input orxonox/objects orxonox/objects/pickup orxonox/overlays/hud
rgrieder at orxonox.net
rgrieder at orxonox.net
Sat Mar 21 17:56:10 CET 2009
Author: rgrieder
Date: 2009-03-21 16:56:10 +0000 (Sat, 21 Mar 2009)
New Revision: 2815
Modified:
branches/gui/src/core/ConfigFileManager.cc
branches/gui/src/core/Core.cc
branches/gui/src/core/GameState.cc
branches/gui/src/core/GameState.h
branches/gui/src/core/Iterator.h
branches/gui/src/core/ObjectListBase.h
branches/gui/src/core/RootGameState.cc
branches/gui/src/core/Template.cc
branches/gui/src/core/XMLPort.h
branches/gui/src/core/input/InputBuffer.h
branches/gui/src/orxonox/objects/EventTarget.cc
branches/gui/src/orxonox/objects/Radar.cc
branches/gui/src/orxonox/objects/pickup/PickupSpawner.cc
branches/gui/src/orxonox/overlays/hud/HUDRadar.cc
Log:
various small changes:
- Fixed a bug in the GameStates concerning return type of virtual functions
- Found some more C-style casts
Modified: branches/gui/src/core/ConfigFileManager.cc
===================================================================
--- branches/gui/src/core/ConfigFileManager.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/ConfigFileManager.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -189,7 +189,7 @@
this->bUpdated_ = true;
- return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback, bString)));
+ return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryValue(name, fallback, bString)));
}
std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
@@ -206,9 +206,9 @@
this->bUpdated_ = true;
if (index == 0)
- return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+ return this->entries_.insert(this->entries_.end(), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
else
- return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+ return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), static_cast<ConfigFileEntry*>(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
}
Modified: branches/gui/src/core/Core.cc
===================================================================
--- branches/gui/src/core/Core.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/Core.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -400,8 +400,8 @@
if (limitToCPU <= 0)
return;
+#ifdef ORXONOX_PLATFORM_WINDOWS
unsigned int coreNr = limitToCPU - 1;
-#ifdef ORXONOX_PLATFORM_WINDOWS
// Get the current process core mask
DWORD procMask;
DWORD sysMask;
Modified: branches/gui/src/core/GameState.cc
===================================================================
--- branches/gui/src/core/GameState.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/GameState.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -177,8 +177,8 @@
// fill the two maps correctly.
this->allChildren_[grandchild->getName()] = grandchild;
this->grandchildrenToChildren_[grandchild] = child;
- if (this->getParent())
- this->getParent()->grandchildAdded(this, grandchild);
+ if (this->getParentAsBase())
+ this->getParentAsBase()->grandchildAdded(this, grandchild);
}
/**
@@ -195,8 +195,8 @@
// adjust the two maps correctly.
this->allChildren_.erase(grandchild->getName());
this->grandchildrenToChildren_.erase(grandchild);
- if (this->getParent())
- this->getParent()->grandchildRemoved(grandchild);
+ if (this->getParentAsBase())
+ this->getParentAsBase()->grandchildRemoved(grandchild);
}
/**
@@ -207,8 +207,8 @@
*/
GameStateBase* GameStateBase::getState(const std::string& name)
{
- if (this->getParent())
- return this->getParent()->getState(name);
+ if (this->getParentAsBase())
+ return this->getParentAsBase()->getState(name);
else
{
// The map only contains children, so check ourself first
@@ -226,8 +226,8 @@
*/
GameStateBase* GameStateBase::getRoot()
{
- if (this->getParent())
- return this->getParent()->getRoot();
+ if (this->getParentAsBase())
+ return this->getParentAsBase()->getRoot();
else
return this;
}
@@ -250,8 +250,8 @@
}
else
{
- if (this->getParent())
- return this->getParent()->getCurrentState();
+ if (this->getParentAsBase())
+ return this->getParentAsBase()->getCurrentState();
else
return 0;
}
@@ -287,7 +287,7 @@
*/
void GameStateBase::makeTransition(GameStateBase* source, GameStateBase* destination)
{
- if (source == this->getParent())
+ if (source == this->getParentAsBase())
{
// call is from the parent
this->activate();
@@ -318,10 +318,10 @@
else
{
// parent. We can be sure of this.
- assert(this->getParent() != 0);
+ assert(this->getParentAsBase() != 0);
this->deactivate();
- this->getParent()->makeTransition(this, destination);
+ this->getParentAsBase()->makeTransition(this, destination);
}
}
Modified: branches/gui/src/core/GameState.h
===================================================================
--- branches/gui/src/core/GameState.h 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/GameState.h 2009-03-21 16:56:10 UTC (rev 2815)
@@ -108,7 +108,7 @@
void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
- virtual GameStateBase* getParent() const = 0;
+ virtual GameStateBase* getParentAsBase() const = 0;
virtual void setParent(GameStateBase* state) = 0;
private:
@@ -145,6 +145,9 @@
{ }
virtual ~GameState() { }
+ GameStateBase* getParentAsBase() const
+ { return parent_; }
+
ParentType* getParent() const
{ return parent_; }
Modified: branches/gui/src/core/Iterator.h
===================================================================
--- branches/gui/src/core/Iterator.h 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/Iterator.h 2009-03-21 16:56:10 UTC (rev 2815)
@@ -180,7 +180,7 @@
if (this->list_)
this->list_->unregisterIterator(this);
- this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
+ this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0;
this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
this->list_->registerIterator(this);
Modified: branches/gui/src/core/ObjectListBase.h
===================================================================
--- branches/gui/src/core/ObjectListBase.h 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/ObjectListBase.h 2009-03-21 16:56:10 UTC (rev 2815)
@@ -70,7 +70,7 @@
class ObjectListElement : public ObjectListBaseElement
{
public:
- ObjectListElement(T* object) : ObjectListBaseElement((OrxonoxClass*)object), object_(object) {}
+ ObjectListElement(T* object) : ObjectListBaseElement(static_cast<OrxonoxClass*>(object)), object_(object) {}
T* object_; //!< The object
};
Modified: branches/gui/src/core/RootGameState.cc
===================================================================
--- branches/gui/src/core/RootGameState.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/RootGameState.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -68,7 +68,7 @@
= this->grandchildrenToChildren_.find(destination);
if (it != this->grandchildrenToChildren_.end())
{
- OrxAssert(dynamic_cast<GameStateBase*>(it->second) != 0,
+ OrxAssert(static_cast<GameStateBase*>(it->second) != 0,
"There was a mix with RootGameState and GameState, could not cast.");
GameStateBase* child = static_cast<GameStateBase*>(it->second);
// child state. Don't use 'state', might be a grandchild!
Modified: branches/gui/src/core/Template.cc
===================================================================
--- branches/gui/src/core/Template.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/Template.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -64,7 +64,7 @@
Element* element = xmlelement.FirstChildElement(false);
if (element)
{
- TiXmlElement* tixmlelement = dynamic_cast<TiXmlElement*>(element->GetTiXmlPointer());
+ TiXmlElement* tixmlelement = static_cast<TiXmlElement*>(element->GetTiXmlPointer());
if (tixmlelement)
this->setXMLElement(*tixmlelement);
}
@@ -137,7 +137,7 @@
COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;
- Element temp = ((TiXmlElement*)&this->getXMLElement());
+ Element temp = &const_cast<TiXmlElement&>(this->getXMLElement());
if (this->bLoadDefaults_)
object->XMLPort(temp, XMLPort::LoadObject);
Modified: branches/gui/src/core/XMLPort.h
===================================================================
--- branches/gui/src/core/XMLPort.h 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/XMLPort.h 2009-03-21 16:56:10 UTC (rev 2815)
@@ -555,11 +555,11 @@
{
try
{
- COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+ COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
BaseObject* newObject = identifier->fabricate((BaseObject*)object);
assert(newObject);
- newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " ");
+ newObject->setLoaderIndentation(object->getLoaderIndentation() + " ");
O* castedObject = dynamic_cast<O*>(newObject);
assert(castedObject);
@@ -567,20 +567,20 @@
if (this->bLoadBefore_)
{
newObject->XMLPort(*child, XMLPort::LoadObject);
- COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+ COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
}
else
{
- COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+ COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
}
- COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
+ COUT(5) << object->getLoaderIndentation();
(*this->loadexecutor_)(object, castedObject);
if (!this->bLoadBefore_)
newObject->XMLPort(*child, XMLPort::LoadObject);
- COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+ COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
}
catch (AbortLoadingException& ex)
{
@@ -600,12 +600,12 @@
}
else
{
- COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
+ COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
}
}
else
{
- COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
+ COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
}
}
else
@@ -625,7 +625,7 @@
catch (ticpp::Exception& ex)
{
COUT(1) << std::endl;
- COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getFilename() << ":" << std::endl;
+ COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ":" << std::endl;
COUT(1) << ex.what() << std::endl;
}
}
Modified: branches/gui/src/core/input/InputBuffer.h
===================================================================
--- branches/gui/src/core/input/InputBuffer.h 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/core/input/InputBuffer.h 2009-03-21 16:56:10 UTC (rev 2815)
@@ -126,7 +126,7 @@
{
for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
{
- InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
+ InputBufferListenerTuple<T>* refListener = static_cast<InputBufferListenerTuple<T>*>(*it);
if (refListener && refListener->listener_ == listener)
this->listeners_.erase(it++);
else
Modified: branches/gui/src/orxonox/objects/EventTarget.cc
===================================================================
--- branches/gui/src/orxonox/objects/EventTarget.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/orxonox/objects/EventTarget.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -65,7 +65,7 @@
void EventTarget::addAsEvent(BaseObject* object)
{
- if (object != (BaseObject*)this)
+ if (object != static_cast<BaseObject*>(this))
object->addEvent(this, "");
}
}
Modified: branches/gui/src/orxonox/objects/Radar.cc
===================================================================
--- branches/gui/src/orxonox/objects/Radar.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/orxonox/objects/Radar.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -143,7 +143,7 @@
for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
{
- if (*it == (RadarViewable*)this->owner_)
+ if (*it == static_cast<RadarViewable*>(this)->owner_)
continue;
float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition());
Modified: branches/gui/src/orxonox/objects/pickup/PickupSpawner.cc
===================================================================
--- branches/gui/src/orxonox/objects/pickup/PickupSpawner.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/orxonox/objects/pickup/PickupSpawner.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -88,7 +88,7 @@
{
ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive));
executor->setDefaultValues(true);
- RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor);
+ RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);
COUT(0) << "TIMER SET" << std::endl;
}
}
Modified: branches/gui/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- branches/gui/src/orxonox/overlays/hud/HUDRadar.cc 2009-03-21 16:30:16 UTC (rev 2814)
+++ branches/gui/src/orxonox/overlays/hud/HUDRadar.cc 2009-03-21 16:56:10 UTC (rev 2815)
@@ -93,7 +93,7 @@
void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
{
- if (object == (RadarViewable*)this->owner_)
+ if (object == static_cast<RadarViewable*>(this->owner_))
return;
const WorldEntity* wePointer = object->getWorldEntity();
More information about the Orxonox-commit
mailing list