Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 22, 2014, 2:18:47 PM (10 years ago)
Author:
noep
Message:

Removed all segfaults (or at least those we found…)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/modularships/src/orxonox/worldentities/pawns/ModularSpaceShip.cc

    r10067 r10071  
    5050namespace orxonox
    5151{
    52     SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPart);
     52    SetConsoleCommand("ModularSpaceShip", "killshippart", &ModularSpaceShip::killShipPartStatic);
    5353
    5454    RegisterClass(ModularSpaceShip);
     
    174174    /**
    175175    @brief
     176        STATIC: Needed for consolecommand. Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]".
     177    @param name
     178        The name of the part to be killed.
     179    */
     180    void ModularSpaceShip::killShipPartStatic(std::string name)
     181    {
     182        for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)
     183        {
     184            if (it->second->getName() == name)
     185            {
     186                it->second->setAlive(false);
     187                return;
     188            }
     189        }
     190        orxout(internal_warning) << "Could not apply damage to ShipPart \"" << name << "\". Part not found." << endl;
     191    }
     192
     193    /**
     194    @brief
    176195        Kills the ShipPart with the given name. Used from the console-command "ModularSpaceShip killshippart [string]".
    177196    @param name
     
    180199    void ModularSpaceShip::killShipPart(std::string name)
    181200    {
    182         for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_s->begin(); it != ModularSpaceShip::partMap_s->end(); ++it)
     201        for (std::map<StaticEntity*, ShipPart*>::const_iterator it = ModularSpaceShip::partMap_.begin(); it != ModularSpaceShip::partMap_.end(); ++it)
    183202        {
    184203            if (it->second->getName() == name)
    185204            {
    186                 it->second->death();
     205                it->second->setAlive(false);
    187206                return;
    188207            }
Note: See TracChangeset for help on using the changeset viewer.