[Orxonox-commit 1360] r6078 - in code/branches/particles2/src/orxonox: controllers weaponsystem worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Tue Nov 17 01:36:21 CET 2009
Author: landauf
Date: 2009-11-17 01:36:21 +0100 (Tue, 17 Nov 2009)
New Revision: 6078
Modified:
code/branches/particles2/src/orxonox/controllers/Controller.h
code/branches/particles2/src/orxonox/weaponsystem/WeaponPack.cc
code/branches/particles2/src/orxonox/weaponsystem/WeaponSystem.cc
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h
Log:
delete weaponpacks which were defined in xml but don't fit onto the weaponslots (in the future we could put them into the inventory).
+ some small changes
Modified: code/branches/particles2/src/orxonox/controllers/Controller.h
===================================================================
--- code/branches/particles2/src/orxonox/controllers/Controller.h 2009-11-16 21:26:43 UTC (rev 6077)
+++ code/branches/particles2/src/orxonox/controllers/Controller.h 2009-11-17 00:36:21 UTC (rev 6078)
@@ -36,6 +36,10 @@
{
class _OrxonoxExport Controller : public BaseObject
{
+ // set friend classes to access setControllableEntity
+ friend class PlayerInfo;
+ friend class ControllableEntity;
+
public:
Controller(BaseObject* creator);
virtual ~Controller();
@@ -45,6 +49,12 @@
inline PlayerInfo* getPlayer() const
{ return this->player_; }
+ inline ControllableEntity* getControllableEntity() const
+ { return this->controllableEntity_; }
+ virtual void changedControllableEntity() {}
+
+ protected:
+ // don't use this directly, use getPlayer()->startControl(entity) (unless you know exactly what you do)
inline void setControllableEntity(ControllableEntity* entity)
{
if (entity != this->controllableEntity_)
@@ -53,11 +63,7 @@
this->changedControllableEntity();
}
}
- inline ControllableEntity* getControllableEntity() const
- { return this->controllableEntity_; }
- virtual void changedControllableEntity() {}
- protected:
PlayerInfo* player_;
ControllableEntity* controllableEntity_;
};
Modified: code/branches/particles2/src/orxonox/weaponsystem/WeaponPack.cc
===================================================================
--- code/branches/particles2/src/orxonox/weaponsystem/WeaponPack.cc 2009-11-16 21:26:43 UTC (rev 6077)
+++ code/branches/particles2/src/orxonox/weaponsystem/WeaponPack.cc 2009-11-17 00:36:21 UTC (rev 6078)
@@ -95,8 +95,9 @@
if (!weapon)
return;
- assert( std::find(this->weapons_.begin(), this->weapons_.end(), weapon)!=this->weapons_.end() );
- this->weapons_.erase( std::find(this->weapons_.begin(), this->weapons_.end(), weapon) );
+ std::vector<Weapon*>::iterator it = std::find(this->weapons_.begin(), this->weapons_.end(), weapon);
+ assert(it != this->weapons_.end());
+ this->weapons_.erase(it);
weapon->setWeaponPack(0);
}
Modified: code/branches/particles2/src/orxonox/weaponsystem/WeaponSystem.cc
===================================================================
--- code/branches/particles2/src/orxonox/weaponsystem/WeaponSystem.cc 2009-11-16 21:26:43 UTC (rev 6077)
+++ code/branches/particles2/src/orxonox/weaponsystem/WeaponSystem.cc 2009-11-17 00:36:21 UTC (rev 6078)
@@ -220,8 +220,9 @@
it->second->removeWeaponmodeLink(wPack);
// Remove the WeaponPack from the WeaponSystem
- assert( std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(),wPack)!=this->weaponPacks_.end() );
- this->weaponPacks_.erase( std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(),wPack) );
+ std::vector<WeaponPack*>::iterator it = std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(), wPack);
+ assert(it !=this->weaponPacks_.end());
+ this->weaponPacks_.erase(it);
}
WeaponPack * WeaponSystem::getWeaponPack(unsigned int index) const
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-16 21:26:43 UTC (rev 6077)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-17 00:36:21 UTC (rev 6078)
@@ -109,7 +109,7 @@
XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
- XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
+ XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
}
void Pawn::registerVariables()
@@ -340,6 +340,13 @@
this->weaponSystem_->addWeaponPack(wPack);
}
+ void Pawn::addWeaponPackXML(WeaponPack * wPack)
+ {
+ if (this->weaponSystem_)
+ if (!this->weaponSystem_->addWeaponPack(wPack))
+ wPack->destroy();
+ }
+
WeaponPack * Pawn::getWeaponPack(unsigned int index) const
{
if (this->weaponSystem_)
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h 2009-11-16 21:26:43 UTC (rev 6077)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h 2009-11-17 00:36:21 UTC (rev 6078)
@@ -88,6 +88,7 @@
void addWeaponSet(WeaponSet * wSet);
WeaponSet * getWeaponSet(unsigned int index) const;
void addWeaponPack(WeaponPack * wPack);
+ void addWeaponPackXML(WeaponPack * wPack);
WeaponPack * getWeaponPack(unsigned int index) const;
inline const WorldEntity* getWorldEntity() const
More information about the Orxonox-commit
mailing list