Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 18, 2019, 3:44:09 PM (5 years ago)
Author:
ahuwyler
Message:

Bats are gone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12305 r12308  
    3939#include "gametypes/Gametype.h"
    4040
    41 #include "OrxoBloxBat.h"
    4241
    4342#include "sound/WorldSound.h"
     
    6160        this->speed_ = 0;
    6261        this->accelerationFactor_ = 1.0f;
    63         this->bat_ = nullptr;
    6462        this->bDeleteBats_ = false;
    65         this->batID_ = new unsigned int[2];
    66         this->batID_[0] = OBJECTID_UNKNOWN;
    67         this->batID_[1] = OBJECTID_UNKNOWN;
    6863        this->relMercyOffset_ = 0.05f;
    6964
     
    9792        {
    9893            if (this->bDeleteBats_)
    99                 delete[] this->bat_;
    10094
    10195            delete[] this->batID_;
     
    123117        registerVariable( this->speed_ );
    124118        registerVariable( this->relMercyOffset_ );
    125         registerVariable( this->batID_[0] );
    126         registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBats) );
    127119    }
    128120
     
    217209    }
    218210
    219     /**
    220     @brief
    221         Set the bats for the ball.
    222     @param bats
    223         An array (of size 2) of weak pointers, to be set as the new bats.
    224     */
    225     void OrxoBloxBall::setBats(WeakPtr<OrxoBloxBat>* bats)
    226     {
    227         if (this->bDeleteBats_) // If there are already some bats, delete them.
    228         {
    229             delete[] this->bat_;
    230             this->bDeleteBats_ = false;
    231         }
    232 
    233         this->bat_ = bats;
    234         // Also store their object IDs, for synchronization.
    235         this->batID_[0] = this->bat_[0]->getObjectID();
    236         this->batID_[1] = this->bat_[1]->getObjectID();
    237     }
    238 
    239     /**
    240     @brief
    241         Get the bats over the network.
    242     */
    243     void OrxoBloxBall::applyBats()
    244     {
    245         // Make space for the bats, if they don't exist, yet.
    246         if (this->bat_ == nullptr)
    247         {
    248             this->bat_ = new WeakPtr<OrxoBloxBat>[2];
    249             this->bDeleteBats_ = true;
    250         }
    251 
    252         if (this->batID_[0] != OBJECTID_UNKNOWN)
    253             this->bat_[0] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[0]));
    254         if (this->batID_[1] != OBJECTID_UNKNOWN)
    255             this->bat_[1] = orxonox_cast<OrxoBloxBat*>(Synchronisable::getSynchronisable(this->batID_[1]));
    256     }
    257211
    258212    void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound)
Note: See TracChangeset for help on using the changeset viewer.