[Orxonox-commit 1383] r6101 - in code/branches/particles2/src: modules/weapons/projectiles orxonox/controllers orxonox/infos orxonox/worldentities orxonox/worldentities/pawns
scheusso at orxonox.net
scheusso at orxonox.net
Fri Nov 20 01:02:10 CET 2009
Author: scheusso
Date: 2009-11-20 01:02:09 +0100 (Fri, 20 Nov 2009)
New Revision: 6101
Modified:
code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
code/branches/particles2/src/orxonox/controllers/AIController.cc
code/branches/particles2/src/orxonox/controllers/HumanController.cc
code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
code/branches/particles2/src/orxonox/infos/PlayerInfo.h
code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc
code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h
code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc
code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h
Log:
rocket now steerable also on client
AIController shoots again now ;)
fire network function is now in CE instead of Pawn
some changes in PlayerInfo that allow controlling of temporary objects (such as Rocket)
Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -136,7 +136,7 @@
{
SUPER(Rocket, tick, dt);
- if( GameMode::isMaster() )
+ if( this->hasLocalController() )
{
this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
@@ -195,7 +195,7 @@
this->destroy();
}
- void Rocket::fire(unsigned int firemode)
+ void Rocket::fired(unsigned int firemode)
{
if (this->owner_)
{
Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.h 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.h 2009-11-20 00:02:09 UTC (rev 6101)
@@ -109,7 +109,7 @@
{ this->damage_ = damage; }
inline float getDamage() const
{ return this->damage_; }
- virtual void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
private:
WeakPtr<Pawn> owner_;
Modified: code/branches/particles2/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/particles2/src/orxonox/controllers/AIController.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/controllers/AIController.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -108,7 +108,7 @@
this->moveToTargetPosition();
if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
-// this->getControllableEntity()->fire(0);
+ this->getControllableEntity()->fire(0);
SUPER(AIController, tick, dt);
}
Modified: code/branches/particles2/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/particles2/src/orxonox/controllers/HumanController.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/controllers/HumanController.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -144,7 +144,7 @@
void HumanController::fire(unsigned int firemode)
{
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ if( HumanController::localController_s && HumanController::localController_s->controllableEntity_ )
HumanController::localController_s->controllableEntity_->fire(firemode);
}
Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -50,8 +50,7 @@
this->controller_ = 0;
this->controllableEntity_ = 0;
this->controllableEntityID_ = OBJECTID_UNKNOWN;
- this->temporaryControllableEntity_ = 0;
- this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
+ this->oldControllableEntity_ = 0;
this->gtinfo_ = 0;
this->gtinfoID_ = OBJECTID_UNKNOWN;
@@ -81,8 +80,6 @@
{
registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
- registerVariable(this->temporaryControllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
- registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);
registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
}
@@ -150,6 +147,8 @@
if (!entity || entity == this->controllableEntity_)
return;
+ if (this->oldControllableEntity_)
+ this->stopTemporaryControl();
if (this->controllableEntity_)
this->stopControl();
@@ -171,15 +170,14 @@
if (!entity)
return;
- assert( this->temporaryControllableEntity_==0 );
+// assert( this->temporaryControllableEntity_==0 );
- this->temporaryControllableEntity_ = entity;
- this->temporaryControllableEntityID_ = entity->getObjectID();
+ this->oldControllableEntity_ = this->controllableEntity_;
+ this->controllableEntity_ = entity;
+ this->controllableEntityID_ = entity->getObjectID();
entity->setPlayer(this);
- this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
-
if (this->controller_)
this->controller_->setControllableEntity(entity);
@@ -188,6 +186,9 @@
void PlayerInfo::stopControl()
{
+ if ( this->oldControllableEntity_ )
+ this->stopTemporaryControl();
+
ControllableEntity* entity = this->controllableEntity_;
if (!entity)
@@ -199,25 +200,28 @@
if (this->controller_)
this->controller_->setControllableEntity(0);
- entity->removePlayer();
+ if ( GameMode::isMaster() )
+ entity->removePlayer();
this->changedControllableEntity();
}
void PlayerInfo::stopTemporaryControl()
{
- ControllableEntity* entity = this->temporaryControllableEntity_;
+ ControllableEntity* entity = this->controllableEntity_;
- if (!entity)
+ if (!entity || !this->oldControllableEntity_)
return;
- this->temporaryControllableEntity_ = 0;
- this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
+ this->controllableEntity_ = this->oldControllableEntity_;
+ this->controllableEntityID_ = this->controllableEntity_->getObjectID();
+ this->oldControllableEntity_ = 0;
if ( this->controllableEntity_ && this->controller_)
this->controller_->setControllableEntity(this->controllableEntity_);
- entity->removePlayer();
+ if ( GameMode::isMaster() )
+ entity->removePlayer();
this->changedControllableEntity();
}
@@ -236,25 +240,9 @@
}
}
- void PlayerInfo::networkcallback_changedtemporarycontrollableentityID()
- {
- CCOUT(0) << "changedtemporarycontrollableentityid" << endl;
- if (this->temporaryControllableEntityID_ != OBJECTID_UNKNOWN)
- {
- Synchronisable* temp = Synchronisable::getSynchronisable(this->temporaryControllableEntityID_);
- ControllableEntity* entity = orxonox_cast<ControllableEntity*>(temp);
- this->startTemporaryControl(entity);
- }
- else
- {
- this->stopTemporaryControl();
- }
- }
-
void PlayerInfo::networkcallback_changedgtinfoID()
{
- CCOUT(0) << "changedcontrollableentityid" << endl;
if (this->gtinfoID_ != OBJECTID_UNKNOWN)
{
this->gtinfo_ = orxonox_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.h 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.h 2009-11-20 00:02:09 UTC (rev 6101)
@@ -91,16 +91,14 @@
private:
void networkcallback_changedcontrollableentityID();
- void networkcallback_changedtemporarycontrollableentityID();
void networkcallback_changedgtinfoID();
void updateGametypeInfo();
bool bReadyToSpawn_;
Controller* controller_;
ControllableEntity* controllableEntity_;
- ControllableEntity* temporaryControllableEntity_;
+ ControllableEntity* oldControllableEntity_;
unsigned int controllableEntityID_;
- unsigned int temporaryControllableEntityID_;
const GametypeInfo* gtinfo_;
unsigned int gtinfoID_;
Modified: code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -35,6 +35,7 @@
#include "core/ConfigValueIncludes.h"
#include "core/GameMode.h"
#include "core/XMLPort.h"
+#include "network/NetworkFunction.h"
#include "Scene.h"
#include "infos/PlayerInfo.h"
@@ -47,6 +48,8 @@
{
CreateFactory(ControllableEntity);
+ registerMemberNetworkFunction( ControllableEntity, fire );
+
ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
{
RegisterObject(ControllableEntity);
@@ -216,6 +219,18 @@
if (this->bMouseLook_)
this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
}
+
+ void ControllableEntity::fire(unsigned int firemode)
+ {
+ if(GameMode::isMaster())
+ {
+ this->fired(firemode);
+ }
+ else
+ {
+ callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
+ }
+ }
void ControllableEntity::setPlayer(PlayerInfo* player)
{
Modified: code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h 2009-11-20 00:02:09 UTC (rev 6101)
@@ -83,7 +83,8 @@
inline void rotateRoll(float value)
{ this->rotateRoll(Vector2(value, 0)); }
- virtual void fire(unsigned int firemode) {}
+ void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode) {}
virtual void reload() {}
virtual void boost() {}
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -51,8 +51,6 @@
{
CreateFactory(Pawn);
- registerMemberNetworkFunction( Pawn, doFire );
-
Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
{
RegisterObject(Pawn);
@@ -262,26 +260,12 @@
}
}
- void Pawn::fire(unsigned int firemode)
+ void Pawn::fired(unsigned int firemode)
{
- this->doFire(firemode);
+ if (this->weaponSystem_)
+ this->weaponSystem_->fire(firemode);
}
- void Pawn::doFire(uint8_t firemode)
- {
- if(GameMode::isMaster())
- {
- if (this->weaponSystem_)
- this->weaponSystem_->fire(firemode);
- }
- else
- {
- callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
- if (this->weaponSystem_)
- this->weaponSystem_->fire(firemode);
- }
- }
-
void Pawn::reload()
{
this->bReload_ = true;
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h 2009-11-20 00:02:09 UTC (rev 6101)
@@ -78,9 +78,8 @@
virtual void hit(Pawn* originator, const Vector3& force, float damage);
virtual void kill();
- virtual void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
virtual void reload();
- virtual void doFire(uint8_t firemode);
virtual void postSpawn();
void addWeaponSlot(WeaponSlot * wSlot);
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc 2009-11-20 00:02:09 UTC (rev 6101)
@@ -188,7 +188,7 @@
ControllableEntity::rotateRoll(value);
}
- void Spectator::fire(unsigned int firemode)
+ void Spectator::fired(unsigned int firemode)
{
if (this->getPlayer())
this->getPlayer()->setReadyToSpawn(true);
Modified: code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h
===================================================================
--- code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h 2009-11-19 20:01:16 UTC (rev 6100)
+++ code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h 2009-11-20 00:02:09 UTC (rev 6101)
@@ -54,7 +54,7 @@
virtual void rotatePitch(const Vector2& value);
virtual void rotateRoll(const Vector2& value);
- virtual void fire(unsigned int firemode);
+ virtual void fired(unsigned int firemode);
virtual void greet();
protected:
More information about the Orxonox-commit
mailing list