Index: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc	(revision 11641)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc	(revision 11664)
@@ -28,4 +28,6 @@
 
 /*
+
+    @file AsteroidMinable.cc
 
 *
@@ -45,4 +47,6 @@
 
 KNACKPUNKTE: 
+o Super-XML-Argumente werden nicht richtig geparst (Velocity, Pitch, Yaw etc. ) 
+
 
 OFFEN: 
@@ -58,5 +62,4 @@
 o Density doesn't add up to 1...
 o set collisionDamage? Just for static entities?
-o AsteroidBelt?
 
 o Dokumentieren mit @brief?
@@ -64,6 +67,4 @@
 o Add sound effect (crunching etc. ) (No sound in space...)
 o Explosion parts
-o custom HUD
-
 
 HANDBUCH:
@@ -124,30 +125,13 @@
 #include "util/Math.h"
 
-
-// #include "infos/PlayerInfo.h"
-// #include "controllers/Controller.h"
-// #include "gametypes/Gametype.h"
-// #include "graphics/ParticleSpawner.h"
-// #include "worldentities/ExplosionChunk.h"
-// #include "worldentities/ExplosionPart.h"
-
-// #include "core/object/ObjectListIterator.h"
-// #include "controllers/FormationController.h"
-
-#include "../pickup/items/HealthPickup.h"
 #include "../pickup/PickupSpawner.h"
 #include "../pickup/Pickup.h"
-//#include "../pickup/pickup ..... pickupable
+
 #include "../objects/collisionshapes/SphereCollisionShape.h"
 #include "../../orxonox/graphics/Model.h"
 
 
-
-
-
-
-
-namespace orxonox
-{
+namespace orxonox{
+
     RegisterClass(AsteroidMinable);
 
@@ -156,16 +140,23 @@
 
         RegisterObject(AsteroidMinable);
-
         this->context = context;
-        this->initialised = false;
-        this->dropStuff = true; // Default
+
+        // Default Values:
+        this->size = 10; 
+        this->dropStuff = true; 
+        this->generateSmaller = true; 
+        this->health_ = 15*size; 
+        this->maxHealth_ = this->health_;
+        this->acceptsPickups_ = false; 
 
         //Noetig, damit nicht sofort zerstoert?
         this->setCollisionType(WorldEntity::CollisionType::Dynamic);
+        this->enableCollisionCallback();
+
 
         // Old from Pawn
         this->registerVariables();
 
-        //orxout() << "AsteroidMining:: Pseudo-Konstruktor passiert!" << endl;
+        this->initialised = false;
 
     }
@@ -184,8 +175,4 @@
         }
 
-        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
-        this->enableCollisionCallback();
-
-        // Default Values
         this->context = c;
         this->size = size;
@@ -197,13 +184,15 @@
 
         this->setPosition(position);
-        this->setVelocity(v); // velocity = v; // The right one? 
-        //this->roll = rand()*5; //etwas Drehung. richtige Variable
-
-
-        // Add Model    //<Model position="0,-40,40" yaw="90" pitch="-90" roll="0" scale="4" mesh="ast6.mesh" />
+        this->setVelocity(v); 
+        //this->roll = rand()*5; //etwas Drehung. Richtige Variable?
+
+        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
+        this->enableCollisionCallback();
+
+
+        // Add Model, random one of the 6 shapes
         Model* hull = new Model(this->context);
-        // random one of the 6 shapes
         char meshThingy[] = "";
-        sprintf(meshThingy, "ast%.0f.mesh", round(5*rnd())+1); //    sprintf(str, "Value of Pi = %f", M_PI);
+        sprintf(meshThingy, "ast%.0f.mesh", round(5*rnd())+1); 
         hull->setMeshSource(meshThingy);
         hull->setScale(this->size);
@@ -212,14 +201,11 @@
         // Collision shape
         SphereCollisionShape* cs = new SphereCollisionShape(this->context);
-        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 2.5 in AsteroidField.lua
+        cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 
         this->attachCollisionShape(cs); 
 
-        // Old from Pawn
         this->registerVariables();
 
         this->initialised=true; 
 
-        //orxout() << "AsteroidMining:: Initialisierung Zweitkonstruktor abgeschlosssssen." << endl;
-
     }
 
@@ -227,4 +213,5 @@
 
     }
+
     // @brief Helper method. Create a new asteroid to have an appropriate size for the collision shape etc. 
     void AsteroidMinable::putStuff(){
@@ -232,43 +219,37 @@
         // Just create a new asteroid to avoid Collision shape scale problems etc. 
         AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->getVelocity(), this->dropStuff);
-        reborn->toggleShattering(true); // mainly here to avoid 'unused' warning. 
+        (void)reborn; // avoid compiler warning
         this->bAlive_ = false;
         this->destroyLater();
-        //this->~AsteroidMinable(); // seems dangerous, yields warning.  Necessary for efficiency? 
-
-    }
-
-    void AsteroidMinable::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-    {
-        SUPER(AsteroidMinable, XMLPort, xmlelement, mode);
-        //        XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode);
+
+    }
+
+    void AsteroidMinable::XMLPort(Element& xmlelement, XMLPort::Mode mode){
+
+        SUPER(AsteroidMinable, XMLPort, xmlelement, mode); 
+
         XMLPortParam(AsteroidMinable, "size", setSize, getSize, xmlelement, mode);
-
-    }
-
-    void AsteroidMinable::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
-    {
+        XMLPortParam(AsteroidMinable, "generateSmaller", toggleShattering, doesShatter, xmlelement, mode);
+        XMLPortParam(AsteroidMinable, "dropStuff", toggleDropStuff, doesDropStuff, xmlelement, mode); 
+
+    }
+
+    void AsteroidMinable::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){
+
         SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode);
 
-        XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
-    }
-
-    void AsteroidMinable::registerVariables()
-    {
+    }
+
+    void AsteroidMinable::registerVariables(){
 
         registerVariable(this->size, VariableDirection::ToClient);
         registerVariable(this->generateSmaller, VariableDirection::ToClient);
-
+        registerVariable(this->dropStuff, VariableDirection::ToClient); 
         registerVariable(this->initialised, VariableDirection::ToClient);
 
-            //         float size;
-            // bool generateSmaller;
-            // bool initialised;
-
-            // Context* context;
-    }
-
-    void AsteroidMinable::tick(float dt)
-    {
+    }
+
+    void AsteroidMinable::tick(float dt){
+
         if(!(this->initialised)){this->putStuff();} 
 
@@ -277,15 +258,7 @@
     }
 
-
-
-
-    void AsteroidMinable::death() //ueberschreiben
-    {
-
-        // orxout() << "AsteroidMinable::Death() aufgerufen." << endl;
-
-        // OFFEN: Sauber kapputten
-        // just copied other stuff:
-        // this->setHealth(1);
+    void AsteroidMinable::death(){ // ueberschreibt das Zeug in Pawn
+
+        // just copied that from somewhere else. 
         this->bAlive_ = false;
         this->destroyLater();
@@ -312,11 +285,8 @@
             thingy->setRespawnTime(0.2f);
         }
-        // orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl;
 
         // Smaller Parts = 'Children'
         if(this->generateSmaller){this->spawnChildren();}
 
-        // orxout() << "Wieder retour in death() geschafft. " << endl;
-
     }
 
@@ -324,5 +294,4 @@
 void AsteroidMinable::spawnChildren(){// Spawn smaller Children 
 
-    
     if (this->size <=1){return;} // Absicherung trivialer Fall
 
@@ -331,13 +300,17 @@
     if(num > 10){num = 10;} // no max function in C!
     int masses[num]; // Masses of the asteroids, at least one. 
-    //orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl;
+
+    // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl;
 
     massRem = massRem-num; // mass is at least one, add again below. 
 
     // Randomnised spawning points for the new asteroids
-    float phi[num]; // assuming that it gets initialised to 0. Add (= {0.0})?
-    float theta[num];
+    float phi[num]; 
+    float theta[num]; 
+
+    // Discusting C stuff -> use that to initialise dynamic array values to 0. 
+    for(int twat = 0; twat<num; ++twat){masses[twat] = 0; phi[twat] = 0.0; theta[twat] = 0.0;}
+
     float piG = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. 
-
     float d_p = 2*piG/num;
     float d_t = piG/num;
@@ -347,4 +320,5 @@
     // float thetaOffset = rnd()*pi;
     float rScaling; // scale radius to prevent asteroids from touching. (distance=AsteroidRadius/tan(sector/2))
+
     if(num == 1 ){
         rScaling = 1; // avoid tan(90). Unused. 
@@ -404,23 +378,16 @@
             result = 0;// reset
             rVal = rnd();// between 0 and 1
-            // orxout() << "Random Value picked: " << rVal << endl;
             probSum = probDensity[0]; 
-            //orxout() << "Sum at start: " << probSum << endl;
-
-            while(rVal>probSum && result<massRem){// Not yet found && there-s smth to distribute (Incrementing once inside!)
+
+            while(rVal>probSum && result<massRem){// Not yet found && there-s smth left to distribute (Incrementing once inside!)
                 if(result<(massRem-2)){probSum = probSum + probDensity[result+1];} // avoid logical/acess error
                 ++result;
-                // orxout() << "Sum so far: " << probSum << ". Just added " << probDensity[result+1] <<  endl;
             }
 
             massRem = massRem-result;
-            masses[trav] = 1 +result; // at least one 
-            // orxout() << "Mass chosen for child " << trav << " is: " << masses[trav] << endl;
-
-        }
-    }else{// Everyone has mass 1. Initialising the array to 1 doesn-t seem to work. Hideous C language!
-        for(int schnaegg = 0; schnaegg<num; ++schnaegg){
-            masses[schnaegg] = 1;
-        }
+            masses[trav] = 1 +result; // Fragments have mass of at least one. 
+        }
+    }else{
+        for(int schnaegg = 0; schnaegg<num; ++schnaegg){masses[schnaegg] = 1;}
     }
 
@@ -437,5 +404,4 @@
         }
         
-        // orxout() << "Creating asteroid with mass " << masses[fisch] << " at relative postition " << *pos << endl;
         AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos, this->getVelocity(), this->dropStuff);
 
