- Timestamp:
- Apr 18, 2019, 3:44:09 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
r12305 r12308 39 39 #include "gametypes/Gametype.h" 40 40 41 #include "OrxoBloxBat.h"42 41 43 42 #include "sound/WorldSound.h" … … 61 60 this->speed_ = 0; 62 61 this->accelerationFactor_ = 1.0f; 63 this->bat_ = nullptr;64 62 this->bDeleteBats_ = false; 65 this->batID_ = new unsigned int[2];66 this->batID_[0] = OBJECTID_UNKNOWN;67 this->batID_[1] = OBJECTID_UNKNOWN;68 63 this->relMercyOffset_ = 0.05f; 69 64 … … 97 92 { 98 93 if (this->bDeleteBats_) 99 delete[] this->bat_;100 94 101 95 delete[] this->batID_; … … 123 117 registerVariable( this->speed_ ); 124 118 registerVariable( this->relMercyOffset_ ); 125 registerVariable( this->batID_[0] );126 registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<OrxoBloxBall>( this, &OrxoBloxBall::applyBats) );127 119 } 128 120 … … 217 209 } 218 210 219 /**220 @brief221 Set the bats for the ball.222 @param bats223 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 @brief241 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 }257 211 258 212 void OrxoBloxBall::setDefScoreSound(const std::string &OrxoBloxSound)
Note: See TracChangeset
for help on using the changeset viewer.