ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassWeapon *type) { int currSlot, index; if (!LocateWeapon (type, &currSlot, &index)) { if (slot >= 0 && slot < NUM_WEAPON_SLOTS) { bool added = Slots[slot].AddWeapon (type); return added ? SLOTDEF_Added : SLOTDEF_Full; } return SLOTDEF_Full; } return SLOTDEF_Exists; }
void FWeaponSlots::AddExtraWeapons() { unsigned int i; // Set fractional positions for current weapons. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].SetInitialPositions(); } // Append extra weapons to the slots. for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i) { PClass *cls = PClassActor::AllActorClasses[i]; if (!cls->IsDescendantOf(RUNTIME_CLASS(AWeapon))) { continue; } PClassWeapon *acls = static_cast<PClassWeapon *>(cls); if ((acls->GameFilter == GAME_Any || (acls->GameFilter & gameinfo.gametype)) && acls->Replacement == NULL && // Replaced weapons don't get slotted. !(((AWeapon *)(acls->Defaults))->WeaponFlags & WIF_POWERED_UP) && !LocateWeapon(acls, NULL, NULL) // Don't duplicate it if it's already present. ) { int slot = acls->SlotNumber; if ((unsigned)slot < NUM_WEAPON_SLOTS) { FWeaponSlot::WeaponInfo info = { acls, acls->SlotPriority }; Slots[slot].Weapons.Push(info); } } } // Now resort every slot to put the new weapons in their proper places. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].Sort(); } }
void FWeaponSlots::AddExtraWeapons() { unsigned int i; // Set fractional positions for current weapons. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].SetInitialPositions(); } // Append extra weapons to the slots. ClassDef::ClassIterator iter = ClassDef::GetClassIterator(); ClassDef::ClassPair *pair; while (iter.NextPair(pair)) { ClassDef *cls = pair->Value; if (//cls->ActorInfo != NULL && //(cls->ActorInfo->GameFilter == GAME_Any || (cls->ActorInfo->GameFilter & gameinfo.gametype)) && //cls->ActorInfo->Replacement == NULL && // Replaced weapons don't get slotted. cls->IsDescendantOf(NATIVE_CLASS(Weapon)) && !LocateWeapon(cls, NULL, NULL) // Don't duplicate it if it's already present. ) { int slot = cls->Meta.GetMetaInt(AWMETA_SlotNumber, -1); if ((unsigned)slot < NUM_WEAPON_SLOTS) { fixed_t position = cls->Meta.GetMetaFixed(AWMETA_SlotPriority, INT_MAX); FWeaponSlot::WeaponInfo info = { cls, position }; Slots[slot].Weapons.Push(info); } } } // Now resort every slot to put the new weapons in their proper places. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].Sort(); } }
void FWeaponSlots::AddExtraWeapons() { unsigned int i; // Set fractional positions for current weapons. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].SetInitialPositions(); } // Append extra weapons to the slots. for (unsigned int i = 0; i < PClass::m_Types.Size(); ++i) { PClass *cls = PClass::m_Types[i]; if (cls->ActorInfo != NULL && (cls->ActorInfo->GameFilter == GAME_Any || (cls->ActorInfo->GameFilter & gameinfo.gametype)) && cls->ActorInfo->Replacement == NULL && // Replaced weapons don't get slotted. cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)) && !(static_cast<AWeapon*>(GetDefaultByType(cls))->WeaponFlags & WIF_POWERED_UP) && !LocateWeapon(cls, NULL, NULL) // Don't duplicate it if it's already present. ) { int slot = cls->Meta.GetMetaInt(AWMETA_SlotNumber, -1); if ((unsigned)slot < NUM_WEAPON_SLOTS) { fixed_t position = cls->Meta.GetMetaFixed(AWMETA_SlotPriority, INT_MAX); FWeaponSlot::WeaponInfo info = { cls, position }; Slots[slot].Weapons.Push(info); } } } // Now resort every slot to put the new weapons in their proper places. for (i = 0; i < NUM_WEAPON_SLOTS; ++i) { Slots[i].Sort(); } }