- Timestamp:
- Apr 12, 2009, 12:34:55 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2914 r2915 63 63 this->pawn_->setWeaponSystem(0); 64 64 65 for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ) 66 delete (it++)->second; 67 68 for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ) 69 delete (*(it++)); 70 71 for (std::set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ) 72 delete (*(it++)); 65 // for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ) 66 // delete (it++)->second; 67 while (!this->weaponSets_.empty()) 68 delete (this->weaponSets_.begin()->second); 69 70 // for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ) 71 // delete (*(it++)); 72 while (!this->weaponPacks_.empty()) 73 delete (*this->weaponPacks_.begin()); 74 75 // for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ) 76 // delete (*(it++)); 77 while (!this->weaponSlots_.empty()) 78 delete (*this->weaponSlots_.begin()); 73 79 } 74 80 } … … 79 85 return; 80 86 81 this->weaponSlots_. insert(wSlot);87 this->weaponSlots_.push_back(wSlot); 82 88 wSlot->setWeaponSystem(this); 83 89 } … … 91 97 this->removeWeaponPack(wSlot->getWeapon()->getWeaponPack()); 92 98 93 this->weaponSlots_.erase(wSlot); 99 for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it) 100 { 101 if ((*it) == wSlot) 102 { 103 this->weaponSlots_.erase(it); 104 break; 105 } 106 } 94 107 } 95 108 … … 97 110 { 98 111 unsigned int i = 0; 99 for (std:: set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)112 for (std::vector<WeaponSlot*>::const_iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it) 100 113 { 101 114 ++i; … … 159 172 160 173 unsigned int freeSlots = 0; 161 for (std:: set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)174 for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it) 162 175 { 163 176 if (!(*it)->isOccupied()) … … 175 188 // Attach all weapons to the first free slots (and to the Pawn) 176 189 unsigned int i = 0; 177 for (std:: set<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it)190 for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); ++it) 178 191 { 179 192 if (!(*it)->isOccupied() && i < wPack->getNumWeapons()) … … 196 209 this->weaponPacks_.insert(wPack); 197 210 wPack->setWeaponSystem(this); 198 wPack->attachNeededMunitionToAllWeapons(); // TODO - what is this?199 211 200 212 return true; … … 231 243 bool WeaponSystem::swapWeaponSlots(WeaponSlot * wSlot1, WeaponSlot * wSlot2) 232 244 { 233 // TODO 245 if (!wSlot1 || !wSlot2) 246 return false; 247 248 Weapon* weapon1 = wSlot1->getWeapon(); 249 Weapon* weapon2 = wSlot2->getWeapon(); 250 251 wSlot1->attachWeapon(weapon2); 252 wSlot2->attachWeapon(weapon1); 253 254 return true; 255 // In the future, certain weapons might not fit to some slots. Swapping would then be 256 // impossible and the returnvalue would be false. 234 257 } 235 258
Note: See TracChangeset
for help on using the changeset viewer.