Changeset 6676 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 24, 2006, 8:24:48 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/movie_entity.cc
r6600 r6676 19 19 #include "load_param.h" 20 20 #include "factory.h" 21 22 #include "network_game_manager.h"23 #include "converter.h"24 21 25 22 using namespace std; -
trunk/src/world_entities/playable.cc
r6669 r6676 52 52 void Playable::addWeapon(Weapon* weapon, int configID, int slotID) 53 53 { 54 this->weaponMan->addWeapon(weapon );54 this->weaponMan->addWeapon(weapon, configID, slotID); 55 55 56 56 this->weaponConfigChanged(); -
trunk/src/world_entities/weapons/weapon_manager.cc
r6669 r6676 208 208 int weaponConf = this->currentConfigID; 209 209 int slot; 210 if (slot = this->getNextFreeSlot(weaponConf, weapon->getCapability()) == -1 )210 if (slot = this->getNextFreeSlot(weaponConf, weapon->getCapability()) != -1 ) 211 211 this->addWeapon(weapon, weaponConf, slot); 212 else 213 this->addWeapon(weapon, -1, -1); 212 214 } 213 215 … … 231 233 } 232 234 233 if (this->configs[configID][slotID] != NULL && configID > 0 && slotID > 0) 234 PRINTF(3)("Weapon-slot %d/%d of %s already poulated, overwriting\n", configID, slotID, this->getName()); 235 236 if (slotID == -1) // WM_FREE_SLOT 235 if (configID > 0 && slotID > 0 && this->configs[configID][slotID] != NULL) 236 { 237 PRINTF(3)("Weapon-slot %d/%d of %s already poulated, remove weapon (%s::%s) first\n", configID, slotID, this->getName(), weapon->getClassName(), weapon->getName()); 238 return false; 239 } 240 241 if (slotID <= -1) // WM_FREE_SLOT 237 242 { 238 243 slotID = this->getNextFreeSlot(configID, weapon->getCapability()); … … 253 258 254 259 //! @todo check if the weapon is already assigned to another config in another slot 260 assert(this->configs[configID][slotID] == NULL); 261 255 262 this->configs[configID][slotID] = weapon; 256 263 weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType())); … … 259 266 this->parent->addChild(weapon); 260 267 } 261 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID);268 PRINTF(3)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassName(), weapon->getName(), configID, slotID); 262 269 return true; 263 270 } … … 433 440 int WeaponManager::getNextFreeSlot(int configID, long capability) 434 441 { 435 for( int i = 0; i < this->slotCount; ++i) 436 { 437 if( this->configs[configID][i] == NULL && 438 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) && 439 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS)) 440 return i; 442 if (configID == -1) 443 { 444 for (configID = 0; configID < WM_MAX_CONFIGS; configID++) 445 for( int i = 0; i < this->slotCount; ++i) 446 { 447 if( this->configs[configID][i] == NULL && 448 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) && 449 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS)) 450 return i; 451 } 452 } 453 else 454 { 455 for( int i = 0; i < this->slotCount; ++i) 456 { 457 if( this->configs[configID][i] == NULL && 458 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLKINDS) && 459 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS)) 460 return i; 461 } 441 462 } 442 463 return -1;
Note: See TracChangeset
for help on using the changeset viewer.