Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 24, 2006, 2:26:15 PM (18 years ago)
Author:
bensch
Message:

some WeaponManager remake

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r6568 r6669  
    203203}
    204204
     205
     206bool WeaponManager::addWeapon(Weapon* weapon)
     207{
     208  int weaponConf = this->currentConfigID;
     209  int slot;
     210  if (slot = this->getNextFreeSlot(weaponConf, weapon->getCapability()) == -1 )
     211    this->addWeapon(weapon, weaponConf, slot);
     212}
    205213
    206214/**
     
    246254  //! @todo check if the weapon is already assigned to another config in another slot
    247255  this->configs[configID][slotID] = weapon;
     256  weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType()));
    248257  if (this->parent != NULL)
    249258  {
     
    420429/**
    421430 * private gets the next free slot in a certain weaponconfig
    422  * @param the selected weaponconfig
     431 * @param the selected weaponconfig -1 if none found
    423432 */
    424433int WeaponManager::getNextFreeSlot(int configID, long capability)
     
    434443}
    435444
     445CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(ClassID projectileType)
     446{
     447  for (unsigned int i = 0; i < this->ammo.size(); i++)
     448  {
     449    if (this->ammo[i]->getProjectileType() == projectileType)
     450      return this->ammo[i];
     451  }
     452  this->ammo.push_back(CountPointer<AmmoContainer>(new AmmoContainer(projectileType)));
     453  return this->ammo.back();
     454}
    436455
    437456
Note: See TracChangeset for help on using the changeset viewer.