[Orxonox-commit 2147] r6863 - in code/branches/rocket: data/levels/includes src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes

gnadler at orxonox.net gnadler at orxonox.net
Fri May 7 16:14:18 CEST 2010


Author: gnadler
Date: 2010-05-07 16:14:18 +0200 (Fri, 07 May 2010)
New Revision: 6863

Modified:
   code/branches/rocket/data/levels/includes/weaponsettings3.oxi
   code/branches/rocket/src/modules/weapons/RocketController.cc
   code/branches/rocket/src/modules/weapons/RocketController.h
   code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
   code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
   code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
Log:
orxonox crashes while, respectively after destroying either the Rocket or the Controller. 

Modified: code/branches/rocket/data/levels/includes/weaponsettings3.oxi
===================================================================
--- code/branches/rocket/data/levels/includes/weaponsettings3.oxi	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/data/levels/includes/weaponsettings3.oxi	2010-05-07 14:14:18 UTC (rev 6863)
@@ -38,7 +38,7 @@
           <LightningGun mode=1 muzzleoffset="0,0,0" />
         </Weapon>
         <Weapon>
-          <SimpleRocketFire mode=2 muzzleoffset="10,10,10" />
+          <SimpleRocketFire mode=2 muzzleoffset="0,0,0" />
         </Weapon>
       </WeaponPack>
       <WeaponPack>

Modified: code/branches/rocket/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-07 14:14:18 UTC (rev 6863)
@@ -47,6 +47,7 @@
 		this->rocket = new SimpleRocket(this);
 		this->rocket->setController(dynamic_cast<RocketController*>(this));
 		this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
+		this->haha=0;
     }
 
 
@@ -58,16 +59,21 @@
     */
     void RocketController::tick(float dt)
     {
+		haha++;
 
         SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity());
-		double rd = rand();
-		if (rd > 0.5) rocket->rotateRoll(5); 
+		rocket->setAcceleration(rocket->getAcceleration()*2);
+		if (haha < 100) rocket->rotateYaw(10);
+		else {
+		if (rand() > 0.5) rocket->rotateRoll(5); 
 		else rocket->rotatePitch(5);
+		}
 
     }
 
 
 	RocketController::~RocketController() {
+		
 		COUT(0)<< "RocketController destroyed\n";
 	}
 

Modified: code/branches/rocket/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.h	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/src/modules/weapons/RocketController.h	2010-05-07 14:14:18 UTC (rev 6863)
@@ -51,13 +51,16 @@
 			virtual ~RocketController();
             
             virtual void tick(float dt);
-			SimpleRocket* getRocket(){return rocket;};
+			SimpleRocket* getRocket(){return this->rocket;};
         protected:
 
 
         private:
 			SimpleRocket* rocket;
+			WeakPtr<PlayerInfo> player_;
+						int haha;
 
+
     };
 }
 

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-07 14:14:18 UTC (rev 6863)
@@ -97,8 +97,8 @@
     SimpleRocket::~SimpleRocket()
     {
 		if (this->isInitialized()) {
+			this->getController()->destroy();
 		COUT(0)<< "simplerocket destroyed\n";
-		delete this->getController();
 		}
 	}
 
@@ -157,7 +157,7 @@
             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
             if (victim)
                 victim->hit(this->owner_, contactPoint, dmg);
-//             this->destroy();
+             this->destroy();
         }
         return false;
     }

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-07 14:14:18 UTC (rev 6863)
@@ -111,6 +111,7 @@
             inline float getDamage() const
                 { return this->damage_; }
             virtual void fired(unsigned int firemode);
+			
 
         private:
             WeakPtr<Pawn> owner_;
@@ -118,6 +119,7 @@
             float damage_;
             bool bDestroy_;
 
+
             WeakPtr<PlayerInfo> player_;
             Timer destroyTimer_;
             float lifetime_;

Modified: code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-06 14:42:59 UTC (rev 6862)
+++ code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-07 14:14:18 UTC (rev 6863)
@@ -44,14 +44,13 @@
     SimpleRocketFire::SimpleRocketFire(BaseObject* creator) : WeaponMode(creator)
     {
         RegisterObject(SimpleRocketFire);
-		
 
-      /*  this->reloadTime_ = 0.20f;
+        this->reloadTime_ = 0.20f;
         this->bParallelReload_ = false;
         this->damage_ = 100;
-        this->speed_ = 500;
+        this->speed_ = 50;
 
-        this->setMunitionName("LaserMunition");*/
+        this->setMunitionName("LaserMunition");
         // The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
     }
 
@@ -66,11 +65,15 @@
 		SimpleRocket* rocket = con->getRocket();
 		this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
 		rocket->setOrientation(this->getMuzzleOrientation());
-        rocket->setPosition(this->getMuzzlePosition());
-		rocket->setVelocity(this->getMuzzleDirection() * rocket->getVelocity());
+		Vector3 pos = this->getMuzzlePosition() + (this->getMuzzleOrientation()* Vector3(-2, -3, -2));
+        rocket->setPosition(pos);
+		rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
+		//Ogre::Vector3 vec = this->getMuzzlePosition();
+		//vec.normalise();
+		//rocket->setAcceleration(100*vec);
 		rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
 		//con->getRocket()->setPosition(this->getMuzzlePosition());
-	//con->setControllableEntity(dynamic_cast<ControllableEntity*>(rocket));
+	//con->setControllableEntity(dynamic_cast<rocket*>(ControllableEntity));
 	//con->getControllableEntity()->setPosition(this->getMuzzlePosition());
 
         /* this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());




More information about the Orxonox-commit mailing list