Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2008, 2:34:54 AM (16 years ago)
Author:
landauf
Message:

used isInitialized() in destructors where needed and changed constructors back to normal variable initialization instead of the "myclass() : variable(value), …" pattern. in my opinion this is much more comfortable and I hope everyone agrees ;)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1558 r1559  
    7979    }
    8080
    81     SpaceShip::SpaceShip() :
    82       //testvector_(0,0,0),
    83       //bInvertYAxis_(false),
    84       setMouseEventCallback_(false),
    85       bLMousePressed_(false),
    86       bRMousePressed_(false),
    87       camNode_(0),
    88       cam_(0),
    89       camName_("CamNode"),
    90       tt1_(0),
    91       tt2_(0),
    92       redNode_(0),
    93       greenNode_(0),
    94       blinkTime_(0.0f),
    95       chNearNode_(0),
    96       chFarNode_(0),
    97       timeToReload_(0.0f),
    98       //reloadTime_(0.0f),
    99       maxSideAndBackSpeed_(0.0f),
    100       maxSpeed_(0.0f),
    101       maxRotation_(0.0f),
    102       translationAcceleration_(0.0f),
    103       rotationAcceleration_(0.0f),
    104       translationDamping_(0.0f),
    105       rotationDamping_(0.0f),
    106       maxRotationRadian_(0),
    107       rotationAccelerationRadian_(0),
    108       rotationDampingRadian_(0),
    109       zeroRadian_(0),
    110       mouseXRotation_(0),
    111       mouseYRotation_(0),
    112       mouseX_(0.0f),
    113       mouseY_(0.0f),
    114       myShip_(false),
    115       teamNr_(0),
    116       health_(100)
     81    SpaceShip::SpaceShip()
    11782    {
    11883        RegisterObject(SpaceShip);
    119         this->registerAllVariables();
    120 
    121         SpaceShip::instance_s = this;
    122 
    123         this->setConfigValues();
    124 
    125         initialDir_ = Vector3(1.0, 0.0, 0.0);
    126         currentDir_ = initialDir_;
    127         initialOrth_ = Vector3(0.0, 0.0, 1.0);
    128         currentOrth_ = initialOrth_;
    129 
    130         this->camName_ = this->getName() + "CamNode";
    13184
    13285        this->setRotationAxis(1, 0, 0);
    13386        this->setStatic(false);
    13487
     88        this->zeroRadian_ = 0;
     89        this->maxSideAndBackSpeed_ = 0;
     90        this->maxSpeed_ = 0;
     91        this->maxRotation_ = 0;
     92        this->translationAcceleration_ = 0;
     93        this->rotationAcceleration_ = 0;
     94        this->translationDamping_ = 0;
     95        this->rotationDamping_ = 0;
     96        this->maxRotationRadian_ = 0;
     97        this->rotationAccelerationRadian_ = 0;
     98        this->rotationDampingRadian_ = 0;
     99
     100        this->cam_ = 0;
     101        this->tt1_ = 0;
     102        this->tt2_ = 0;
     103
     104        this->redNode_ = 0;
     105        this->greenNode_ = 0;
     106        this->blinkTime_ = 0;
     107
     108        this->timeToReload_ = 0;
     109
     110        this->setMouseEventCallback_ = false;
     111        this->bLMousePressed_ = false;
     112        this->bRMousePressed_ = false;
     113        this->mouseXRotation_ = 0;
     114        this->mouseYRotation_ = 0;
     115        this->mouseX_ = 0;
     116        this->mouseY_ = 0;
     117        this->myShip_ = false;
     118
     119        this->registerAllVariables();
     120
     121        SpaceShip::instance_s = this;
     122
     123        this->setConfigValues();
     124
     125        this->initialDir_ = Vector3(1.0, 0.0, 0.0);
     126        this->currentDir_ = initialDir_;
     127        this->initialOrth_ = Vector3(0.0, 0.0, 1.0);
     128        this->currentOrth_ = initialOrth_;
     129
     130        this->camName_ = this->getName() + "CamNode";
     131
     132        this->teamNr_ = 0;
     133        this->health_ = 100;
     134
    135135        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
    136136    }
     
    138138    SpaceShip::~SpaceShip()
    139139    {
    140         if (this->tt1_)
    141             delete this->tt1_;
    142         if (this->tt2_)
    143             delete this->tt2_;
    144         if(setMouseEventCallback_)
    145           InputManager::removeMouseHandler("SpaceShip");
    146         if (this->cam_)
    147           delete this->cam_;
    148         if (!Identifier::isCreatingHierarchy() && !myShip_ && &HUD::getSingleton()!=NULL)
    149           //remove the radar object
    150           HUD::getSingleton().removeRadarObject(this->getNode());
     140        if (this->isInitialized())
     141        {
     142            if (this->tt1_)
     143                delete this->tt1_;
     144            if (this->tt2_)
     145                delete this->tt2_;
     146
     147            if (setMouseEventCallback_)
     148                InputManager::removeMouseHandler("SpaceShip");
     149
     150            if (this->cam_)
     151                delete this->cam_;
     152
     153            if (!myShip_ && &HUD::getSingleton()!=NULL)
     154              HUD::getSingleton().removeRadarObject(this->getNode());
     155        }
    151156    }
    152157
     
    307312      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
    308313      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(1,0,0));
    309       camNode_->setOrientation(q2*q1);
     314      this->camNode_->setOrientation(q2*q1);
    310315      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
    311316        this->setBacksync(true);
Note: See TracChangeset for help on using the changeset viewer.