Index: /trunk/src/lib/coord/p_node.cc
===================================================================
--- /trunk/src/lib/coord/p_node.cc	(revision 6077)
+++ /trunk/src/lib/coord/p_node.cc	(revision 6078)
@@ -21,4 +21,5 @@
 #include "class_list.h"
 
+#include <algorithm>
 #include "compiler.h"
 #include "debug.h"
@@ -32,17 +33,8 @@
 /**
  * @brief standard constructor
- */
-PNode::PNode (PNode* parent)
-{
-  init();
-  if (parent != NULL)
-    parent->addChild(this);
-}
-
-/**
- * @brief initializes a PNode
- * @param parent the parent for this PNode
- */
-void PNode::init()
+ * @param parent the Parent of this Node. __NULL__ if __No Parent__ requested, PNode::getNullParent(), if connected to NullParent directly (default)
+ * @param nodeFlags all flags to set. THIS_WILL_OVERWRITE Default_Values. look at creation of NullParent for more Info.
+ */
+PNode::PNode (PNode* parent, long nodeFlags)
 {
   this->setClassID(CL_PARENT_NODE, "PNode");
@@ -51,5 +43,5 @@
   this->bRelDirChanged = true;
   this->parent = NULL;
-  this->parentMode = PNODE_PARENT_MODE_DEFAULT;
+  this->parentMode = nodeFlags;
   this->bActive = true;
 
@@ -58,4 +50,7 @@
   this->toDirection = NULL;
   this->bias = 1.0;
+
+  if (parent != NULL)
+    parent->addChild(this);
 }
 
@@ -87,9 +82,9 @@
       deleteNode = tmp;
       ++tmp;
-      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
+//      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
       if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
           ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
       {
-        if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULLPARENT)
+        if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
           delete (*deleteNode);
         else
@@ -102,5 +97,5 @@
   if (this->parent != NULL)
    {
-     this->parent->children.remove(this);
+     this->parent->eraseChild(this);
      this->parent = NULL;
    }
@@ -462,5 +457,5 @@
 {
   if( likely(child->parent != NULL))
-      child->parent->children.remove(child);
+      child->parent->eraseChild(child);
   if (this->checkIntegrity(child))
   {
@@ -510,8 +505,17 @@
 void PNode::reparent()
 {
-  if (this->parentMode & PNODE_REPARENT_TO_NULLPARENT)
-    this->setParent(PNode::getNullParent());
+  if (this->parentMode & PNODE_REPARENT_TO_NULL)
+    this->setParent((PNode*)NULL);
   else if (this->parentMode & PNODE_REPARENT_TO_PARENTS_PARENT && this->parent != NULL)
     this->setParent(this->parent->getParent());
+  else
+    this->setParent(PNode::getNullParent());
+}
+
+void PNode::eraseChild(PNode* child)
+{
+  std::list<PNode*>::iterator childRemover = std::find(this->children.begin(), this->children.end(), child);
+  if(childRemover != this->children.end())
+    this->children.erase(childRemover);
 }
 
@@ -524,17 +528,19 @@
 void PNode::removeNode()
 {
-  if (this->parentMode & PNODE_REPARENT_CHILDREN_ON_REMOVE)
-  {
-    list<PNode*>::iterator child = this->children.begin();
-    list<PNode*>::iterator reparenter;
-    while (child != this->children.end())
-    {
-      reparenter = child;
-      child++;
+  list<PNode*>::iterator child = this->children.begin();
+  list<PNode*>::iterator reparenter;
+  while (child != this->children.end())
+  {
+    reparenter = child;
+    child++;
+    if (this->parentMode & PNODE_REPARENT_CHILDREN_ON_REMOVE ||
+        (*reparenter)->parentMode & PNODE_REPARENT_ON_PARENTS_REMOVE)
+    {      printf("TEST----------------%s ---- %s\n", this->getClassName(), (*reparenter)->getClassName());
       (*reparenter)->reparent();
+      printf("REPARENTED TO: %s::%s\n",(*reparenter)->getParent()->getClassName(),(*reparenter)->getParent()->getName());
     }
   }
   if (this->parent != NULL)
-    this->parent->children.remove(this);
+    this->parent->eraseChild(this);
 }
 
@@ -630,5 +636,5 @@
  * @param nodeFlags a compsition of PARENT_MODE-flags, split by the '|' (or) operator.
  */
-void PNode::addNodeModeFlags(unsigned short nodeFlags)
+void PNode::addNodeFlags(unsigned short nodeFlags)
 {
   this->parentMode |= nodeFlags;
@@ -640,7 +646,20 @@
  * @param nodeFlags a compsition of PARENT_MODE-flags, split by the '|' (or) operator.
  */
-void PNode::removeNodeModeFlags(unsigned short nodeFlags)
+void PNode::removeNodeFlags(unsigned short nodeFlags)
 {
   this->parentMode &= !nodeFlags;
+}
+
+/**
+ * @returns the NullParent (and if needed creates it)
+ */
+PNode* PNode::createNullParent()
+{
+  if (likely(PNode::nullParent == NULL))
+  {
+    PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
+    PNode::nullParent->setName("NullParent");
+  }
+  return PNode::nullParent;
 }
 
Index: /trunk/src/lib/coord/p_node.h
===================================================================
--- /trunk/src/lib/coord/p_node.h	(revision 6077)
+++ /trunk/src/lib/coord/p_node.h	(revision 6078)
@@ -43,6 +43,7 @@
 
   // REPARENTING
-  PNODE_REPARENT_TO_NULLPARENT         = 0x0010,    //!< Reparents to the NullParent, if the Parent is Removed.
+  PNODE_REPARENT_TO_NULL               = 0x0010,    //!< Reparents to the Null, if the Parent is Removed. Meaning the Node wont have a parent anymore.
   PNODE_REPARENT_TO_PARENTS_PARENT     = 0x0020,    //!< Reparents the Node to the parents (old) parent it the parent gets removed.
+  /////////////////////////////////////////////     //  ELSE: Reparents to the NullParent.
   PNODE_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
   /// FIXME
@@ -54,4 +55,5 @@
   PNODE_PROHIBIT_DELETE_WITH_PARENT    = 0x0200,    //!< Prohibits the Node to be deleted if the Parent is. Child will be reparented according to the Repaenting-Rules
   PNODE_REPARENT_CHILDREN_ON_REMOVE    = 0x0400,    //!< Reparents the Children of the Node if the Node gets Removed.
+  PNODE_REPARENT_ON_PARENTS_REMOVE     = 0x0800,    //!< The Node gets Reparented if its Parent gets removed. Child will be reparented according to the Reparenting-Rules.
 
   // VISIBILITY/ACTIVITY
@@ -65,5 +67,4 @@
 //! The default mode of the translation-binding.
 #define PNODE_PARENT_MODE_DEFAULT PNODE_ALL | \
-                                  PNODE_REPARENT_CHILDREN_ON_REMOVE | \
                                   PNODE_REPARENT_KEEP_POSITION
 
@@ -72,13 +73,15 @@
 class PNode : virtual public BaseObject {
  public:
-  PNode (PNode* parent = PNode::getNullParent());
+  PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT);
   virtual ~PNode ();
 
   void loadParams(const TiXmlElement* root);
 
+  // ACTIVATION //
   inline void activateNode() { this->bActive = true; };
   inline void deactivateNode() { this->bActive = false; };
   inline bool getNodeActiveState() { return this->bActive; };
 
+  // POSITION //
   void setRelCoor (const Vector& relCoord);
   void setRelCoor (float x, float y, float z);
@@ -98,4 +101,12 @@
   void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
 
+  // SPEED //
+  /** @returns the Speed of the Node */
+  inline float getSpeed() const { return this->velocity.len(); };
+  /** @returns the Velocity of the Node */
+  inline const Vector& getVelocity() const { return this->velocity; };
+
+
+  // ROTATION //
   void setRelDir (const Quaternion& relDir);
   void setRelDir (float x, float y, float z);
@@ -124,10 +135,6 @@
   inline Vector getAbsDirZ() const { return this->absDirection.apply(Vector(0,0,1)); };
 
-  /** @returns the Speed of the Node */
-  inline float getSpeed() const { return this->velocity.len(); };
-  /** @returns the Velocity of the Node */
-  inline const Vector& getVelocity() const { return this->velocity; };
-
-
+
+  // PARENTING //
   void addChild (PNode* child);
   void addChild (const char* childName);
@@ -146,4 +153,5 @@
   void setParentSoft(const char* parentName, float bias = 1.0);
 
+  // PARENTING_MODE AND OTHER FLAGS //
   void setParentMode (PARENT_MODE parentMode);
   void setParentMode (const char* parentingMode);
@@ -151,18 +159,20 @@
   int getParentMode() const { return 0x000f & this->parentMode; };
 
-  void addNodeModeFlags(unsigned short nodeFlags);
-  void removeNodeModeFlags(unsigned short nodeFlags);
-
+  void addNodeFlags(unsigned short nodeFlags);
+  void removeNodeFlags(unsigned short nodeFlags);
+
+  // NULL_PARENT //
   /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
-  static PNode* getNullParent()  { return (PNode::nullParent != NULL || (PNode::nullParent = new PNode(NULL)) != NULL)? PNode::nullParent : NULL; };
-
+  static PNode* getNullParent()  { return (PNode::nullParent != NULL)? PNode::nullParent : PNode::createNullParent(); };
+
+  // UPDATING //
   void updateNode (float dt);
 
+  // DEBUG //
   void countChildNodes(int& nodes) const;
   void debugNode (unsigned int depth = 1, unsigned int level = 0) const;
   void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const;
 
-
-  // helper functions //
+  // HELPER_FUNCTIONS //
   static const char* parentingModeToChar(int parentingMode);
   static PARENT_MODE charToParentingMode(const char* parentingMode);
@@ -170,5 +180,4 @@
 
  private:
-  void init();
   /** tells the child that the parent's Coordinate has changed */
   inline void parentCoorChanged () { this->bRelCoorChanged = true; }
@@ -178,6 +187,8 @@
   inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; }
 
+  static PNode* createNullParent();
   void reparent();
   bool checkIntegrity(const PNode* checkParent) const;
+  void eraseChild(PNode* child);
 
  private:
Index: /trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- /trunk/src/world_entities/space_ships/space_ship.cc	(revision 6077)
+++ /trunk/src/world_entities/space_ships/space_ship.cc	(revision 6078)
@@ -112,5 +112,5 @@
   PRINTF(4)("SPACESHIP INIT\n");
 
-  EventHandler::getInstance()->grabEvents(false);
+  EventHandler::getInstance()->grabEvents(true);
 
   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
Index: /trunk/src/world_entities/weapons/aim.cc
===================================================================
--- /trunk/src/world_entities/weapons/aim.cc	(revision 6077)
+++ /trunk/src/world_entities/weapons/aim.cc	(revision 6078)
@@ -65,6 +65,4 @@
   this->setClassID(CL_CROSSHAIR, "Aim");
   this->setName("Aim");
-
-  this->addNodeModeFlags(PNODE_REPARENT_TO_NULLPARENT);
 
   this->setLayer(E2D_LAYER_TOP);
Index: /trunk/src/world_entities/weapons/guided_missile.cc
===================================================================
--- /trunk/src/world_entities/weapons/guided_missile.cc	(revision 6077)
+++ /trunk/src/world_entities/weapons/guided_missile.cc	(revision 6078)
@@ -150,7 +150,8 @@
 {
   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
-  if (target.getParent() != PNode::getNullParent())
+  if (this->target != NULL && this->target->getParent() != PNode::getNullParent())
    {
-     velocity += ((target.getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
+     printf("========%s::%s\n", target->getParent()->getClassName(), target->getParent()->getName() );
+     velocity += ((target->getAbsCoor() - this->getAbsCoor()).getNormalized())*agility;
      float speed = velocity.len();
      if (speed > this->maxVelocity)
Index: /trunk/src/world_entities/weapons/projectile.cc
===================================================================
--- /trunk/src/world_entities/weapons/projectile.cc	(revision 6077)
+++ /trunk/src/world_entities/weapons/projectile.cc	(revision 6078)
@@ -37,7 +37,5 @@
   this->lifeCycle = 0.0;
   this->lifeSpan = 1.0f; /* sec */
-  this->target.addNodeModeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT |
-                                PNODE_REPARENT_TO_NULLPARENT);
-
+  this->target = NULL;
   this->removeNode();
 }
@@ -103,5 +101,8 @@
 void Projectile::setTarget(PNode* target)
 {
-  this->target.setParent(target);
+  if (this->target == NULL)
+    this->target = new PNode(target, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_ON_PARENTS_REMOVE);
+  else
+    this->target->setParent(target);
 }
 
Index: /trunk/src/world_entities/weapons/projectile.h
===================================================================
--- /trunk/src/world_entities/weapons/projectile.h	(revision 6077)
+++ /trunk/src/world_entities/weapons/projectile.h	(revision 6078)
@@ -60,5 +60,5 @@
     Vector                velocity;                  //!< velocity of the projectile.
 
-    PNode                 target;                    //!< A target for guided Weapons.
+    PNode*                target;                    //!< A target for guided Weapons.
 };
 
