Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 7, 2007, 5:59:39 PM (17 years ago)
Author:
nicolasc
Message:

xfer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/vs-enhencements/src/world_entities/weapons/weapon_manager.cc

    r10676 r10678  
    100100  }
    101101
    102   for (int i = 0; i < WM_MAX_LOADED_WEAPONS; i++)
    103     this->availiableWeapons[i] = NULL;
     102//   for (int i = 0; i < WM_MAX_LOADED_WEAPONS; i++)
     103//     this->availiableWeapons[i] = NULL;
    104104
    105105
     
    287287  }
    288288
    289 //   if (configID > 0 && slotID > 0 && this->configs[configID][slotID] != NULL)
    290 //   {
    291 //     PRINTF(3)("Weapon-slot %d/%d of %s already poulated, remove weapon (%s::%s) first\n", configID, slotID, this->getCName(), weapon->getClassCName(), weapon->getCName());
    292 //     return false;
    293 //   }
    294 
    295 //   if (slotID <= -1) // WM_FREE_SLOT
    296 //   {
    297 //     slotID = this->getNextFreeSlot(configID, weapon->getCapability());
    298 //     if( slotID < 0 || slotID >= this->slotCount)
    299 //     {
    300 //       PRINTF(1)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
    301 //       return false;
    302 //     }
    303 //   }
    304 
    305 //   if (!(this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLKINDS) &&
    306 //       this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLDIRS)
    307 //   {
    308 //     PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
    309 //               slotID, weapon->getCapability(), this->slotConfigs[slotID]->getCapability());
    310 //     return false;
    311 //   }
     289  if (configID > 0 && slotID > 0 && this->slotConfigs[slotID]->getWeapon(configID) != NULL)
     290  {
     291    PRINTF(3)("Weapon-slot %d/%d of %s already poulated, remove weapon (%s::%s) first\n", configID, slotID, this->getCName(), weapon->getClassCName(), weapon->getCName());
     292    return false;
     293  }
     294
     295  if (slotID <= -1) // WM_FREE_SLOT
     296  {
     297    slotID = this->getNextFreeSlot(configID, weapon->getCapability());
     298    if( slotID < 0 || slotID >= this->slotCount)
     299    {
     300      PRINTF(1)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n");
     301      return false;
     302    }
     303  }
     304
     305  if (!(this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLKINDS) &&
     306      this->slotConfigs[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLDIRS)
     307  {
     308    PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n",
     309              slotID, weapon->getCapability(), this->slotConfigs[slotID]->getCapability());
     310    return false;
     311  }
    312312
    313313  //! @todo check if the weapon is already assigned to another config in another slot
     
    508508        {
    509509          tickWeapon->toList(OM_NULL);
    510           this->slotConfigs[i]->setCurrentWeapon(NULL);
     510          this->slotConfigs[i]->setCurrentWeapon(-1);
    511511        }
    512512      }
     
    530530    }
    531531    else if (unlikely(tickWeapon != NULL && tickWeapon->getCurrentState() == WS_DEACTIVATING))
    532       this->slotConfigs[i]->setCurrentWeapon(NULL);
     532      this->slotConfigs[i]->setCurrentWeapon(-1);
    533533  }
    534534}
Note: See TracChangeset for help on using the changeset viewer.