mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- got rid of PClassWeapon.
Still 5 subclasses of PClass left...
This commit is contained in:
parent
776509e68a
commit
7ed554158c
8 changed files with 118 additions and 155 deletions
|
@ -2638,7 +2638,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
}
|
||||
for(i = 0; i < count; ++i)
|
||||
{
|
||||
PClassWeapon *wpn = Net_ReadWeapon(stream);
|
||||
PClassActor *wpn = Net_ReadWeapon(stream);
|
||||
players[pnum].weapons.AddSlot(slot, wpn, pnum == consoleplayer);
|
||||
}
|
||||
}
|
||||
|
@ -2647,7 +2647,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
case DEM_ADDSLOT:
|
||||
{
|
||||
int slot = ReadByte(stream);
|
||||
PClassWeapon *wpn = Net_ReadWeapon(stream);
|
||||
PClassActor *wpn = Net_ReadWeapon(stream);
|
||||
players[player].weapons.AddSlot(slot, wpn, player == consoleplayer);
|
||||
}
|
||||
break;
|
||||
|
@ -2655,7 +2655,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
case DEM_ADDSLOTDEFAULT:
|
||||
{
|
||||
int slot = ReadByte(stream);
|
||||
PClassWeapon *wpn = Net_ReadWeapon(stream);
|
||||
PClassActor *wpn = Net_ReadWeapon(stream);
|
||||
players[player].weapons.AddSlotDefault(slot, wpn, player == consoleplayer);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -94,7 +94,6 @@ enum
|
|||
CLASSREG_PClass,
|
||||
CLASSREG_PClassActor,
|
||||
CLASSREG_PClassInventory,
|
||||
CLASSREG_PClassWeapon,
|
||||
CLASSREG_PClassPlayerPawn,
|
||||
CLASSREG_PClassType,
|
||||
CLASSREG_PClassClass,
|
||||
|
|
|
@ -3030,6 +3030,13 @@ void PClass::StaticShutdown ()
|
|||
FlatpointerArena.FreeAllBlocks();
|
||||
bShutdown = true;
|
||||
|
||||
for (unsigned i = 0; i < PClass::AllClasses.Size(); ++i)
|
||||
{
|
||||
PClass *type = PClass::AllClasses[i];
|
||||
PClass::AllClasses[i] = NULL;
|
||||
type->Destroy();
|
||||
}
|
||||
|
||||
AllClasses.Clear();
|
||||
PClassActor::AllActorClasses.Clear();
|
||||
|
||||
|
@ -3129,7 +3136,6 @@ PClass *ClassReg::RegisterClass()
|
|||
&PClass::RegistrationInfo,
|
||||
&PClassActor::RegistrationInfo,
|
||||
&PClassInventory::RegistrationInfo,
|
||||
&PClassWeapon::RegistrationInfo,
|
||||
&PClassPlayerPawn::RegistrationInfo,
|
||||
&PClassType::RegistrationInfo,
|
||||
&PClassClass::RegistrationInfo,
|
||||
|
|
|
@ -2675,8 +2675,8 @@ void FParser::SF_PlayerWeapon()
|
|||
script_error("weaponnum out of range! %d\n", weaponnum);
|
||||
return;
|
||||
}
|
||||
PClassWeapon * ti = static_cast<PClassWeapon *>(PClass::FindActor(WeaponNames[weaponnum]));
|
||||
if (!ti)
|
||||
auto ti = PClass::FindActor(WeaponNames[weaponnum]);
|
||||
if (!ti || !ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
script_error("incompatibility in playerweapon %d\n", weaponnum);
|
||||
return;
|
||||
|
@ -2686,7 +2686,7 @@ void FParser::SF_PlayerWeapon()
|
|||
{
|
||||
AActor * wp = players[playernum].mo->FindInventory(ti);
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = wp!=NULL;;
|
||||
t_return.value.i = wp!=NULL;
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -2756,8 +2756,8 @@ void FParser::SF_PlayerSelectedWeapon()
|
|||
script_error("weaponnum out of range! %d\n", weaponnum);
|
||||
return;
|
||||
}
|
||||
PClassWeapon * ti = static_cast<PClassWeapon *>(PClass::FindActor(WeaponNames[weaponnum]));
|
||||
if (!ti)
|
||||
auto ti = PClass::FindActor(WeaponNames[weaponnum]);
|
||||
if (!ti || !ti->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
script_error("incompatibility in playerweapon %d\n", weaponnum);
|
||||
return;
|
||||
|
|
|
@ -113,42 +113,11 @@ FString WeaponSection;
|
|||
TArray<FString> KeyConfWeapons;
|
||||
FWeaponSlots *PlayingKeyConf;
|
||||
|
||||
TArray<PClassWeapon *> Weapons_ntoh;
|
||||
TMap<PClassWeapon *, int> Weapons_hton;
|
||||
TArray<PClassActor *> Weapons_ntoh;
|
||||
TMap<PClassActor *, int> Weapons_hton;
|
||||
|
||||
static int ntoh_cmp(const void *a, const void *b);
|
||||
|
||||
IMPLEMENT_CLASS(PClassWeapon, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassWeapon::PClassWeapon()
|
||||
{
|
||||
SlotNumber = -1;
|
||||
SlotPriority = INT_MAX;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void PClassWeapon::DeriveData(PClass *newclass)
|
||||
{
|
||||
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassWeapon)));
|
||||
Super::DeriveData(newclass);
|
||||
PClassWeapon *newc = static_cast<PClassWeapon *>(newclass);
|
||||
|
||||
newc->SlotNumber = SlotNumber;
|
||||
newc->SlotPriority = SlotPriority;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -273,7 +242,7 @@ bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int am
|
|||
bool gotSome = CheckAmmo (PrimaryFire, false) || CheckAmmo (AltFire, false);
|
||||
if (!gotSome && autoSwitch)
|
||||
{
|
||||
barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (NULL);
|
||||
barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (nullptr);
|
||||
}
|
||||
return gotSome;
|
||||
}
|
||||
|
@ -282,10 +251,10 @@ bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int am
|
|||
{
|
||||
return true;
|
||||
}
|
||||
count1 = (Ammo1 != NULL) ? Ammo1->Amount : 0;
|
||||
count2 = (Ammo2 != NULL) ? Ammo2->Amount : 0;
|
||||
count1 = (Ammo1 != nullptr) ? Ammo1->Amount : 0;
|
||||
count2 = (Ammo2 != nullptr) ? Ammo2->Amount : 0;
|
||||
|
||||
if ((WeaponFlags & WIF_DEHAMMO) && (Ammo1 == NULL))
|
||||
if ((WeaponFlags & WIF_DEHAMMO) && (Ammo1 == nullptr))
|
||||
{
|
||||
lAmmoUse1 = 0;
|
||||
}
|
||||
|
@ -307,7 +276,7 @@ bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int am
|
|||
{
|
||||
enoughmask = 1 << altFire;
|
||||
}
|
||||
if (altFire && FindState(NAME_AltFire) == NULL)
|
||||
if (altFire && FindState(NAME_AltFire) == nullptr)
|
||||
{ // If this weapon has no alternate fire, then there is never enough ammo for it
|
||||
enough &= 1;
|
||||
}
|
||||
|
@ -318,7 +287,7 @@ bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int am
|
|||
// out of ammo, pick a weapon to change to
|
||||
if (autoSwitch)
|
||||
{
|
||||
barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (NULL);
|
||||
barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -353,7 +322,7 @@ bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
|
|||
}
|
||||
if (!altFire)
|
||||
{
|
||||
if (Ammo1 != NULL)
|
||||
if (Ammo1 != nullptr)
|
||||
{
|
||||
if (ammouse >= 0 && (WeaponFlags & WIF_DEHAMMO))
|
||||
{
|
||||
|
@ -364,25 +333,25 @@ bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
|
|||
Ammo1->Amount -= AmmoUse1;
|
||||
}
|
||||
}
|
||||
if ((WeaponFlags & WIF_PRIMARY_USES_BOTH) && Ammo2 != NULL)
|
||||
if ((WeaponFlags & WIF_PRIMARY_USES_BOTH) && Ammo2 != nullptr)
|
||||
{
|
||||
Ammo2->Amount -= AmmoUse2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Ammo2 != NULL)
|
||||
if (Ammo2 != nullptr)
|
||||
{
|
||||
Ammo2->Amount -= AmmoUse2;
|
||||
}
|
||||
if ((WeaponFlags & WIF_ALT_USES_BOTH) && Ammo1 != NULL)
|
||||
if ((WeaponFlags & WIF_ALT_USES_BOTH) && Ammo1 != nullptr)
|
||||
{
|
||||
Ammo1->Amount -= AmmoUse1;
|
||||
}
|
||||
}
|
||||
if (Ammo1 != NULL && Ammo1->Amount < 0)
|
||||
if (Ammo1 != nullptr && Ammo1->Amount < 0)
|
||||
Ammo1->Amount = 0;
|
||||
if (Ammo2 != NULL && Ammo2->Amount < 0)
|
||||
if (Ammo2 != nullptr && Ammo2->Amount < 0)
|
||||
Ammo2->Amount = 0;
|
||||
}
|
||||
return true;
|
||||
|
@ -547,14 +516,14 @@ FState *AWeapon::GetStateForButtonName (FName button)
|
|||
|
||||
bool FWeaponSlot::AddWeapon(const char *type)
|
||||
{
|
||||
return AddWeapon(static_cast<PClassWeapon *>(PClass::FindClass(type)));
|
||||
return AddWeapon(static_cast<PClassActor *>(PClass::FindClass(type)));
|
||||
}
|
||||
|
||||
bool FWeaponSlot::AddWeapon(PClassWeapon *type)
|
||||
bool FWeaponSlot::AddWeapon(PClassActor *type)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (type == NULL)
|
||||
if (type == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -595,10 +564,10 @@ void FWeaponSlot :: AddWeaponList(const char *list, bool clear)
|
|||
Clear();
|
||||
}
|
||||
tok = strtok(buff, " ");
|
||||
while (tok != NULL)
|
||||
while (tok != nullptr)
|
||||
{
|
||||
AddWeapon(tok);
|
||||
tok = strtok(NULL, " ");
|
||||
tok = strtok(nullptr, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,7 +580,7 @@ void FWeaponSlot :: AddWeaponList(const char *list, bool clear)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FWeaponSlot::LocateWeapon(PClassWeapon *type)
|
||||
int FWeaponSlot::LocateWeapon(PClassActor *type)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -642,22 +611,22 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player, bool checkammo)
|
|||
{
|
||||
int i, j;
|
||||
|
||||
if (player->mo == NULL)
|
||||
if (player->mo == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
// Does this slot even have any weapons?
|
||||
if (Weapons.Size() == 0)
|
||||
{
|
||||
return player->ReadyWeapon;
|
||||
}
|
||||
if (player->ReadyWeapon != NULL)
|
||||
if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
for (i = 0; (unsigned)i < Weapons.Size(); i++)
|
||||
{
|
||||
if (Weapons[i].Type == player->ReadyWeapon->GetClass() ||
|
||||
(player->ReadyWeapon->WeaponFlags & WIF_POWERED_UP &&
|
||||
player->ReadyWeapon->SisterWeapon != NULL &&
|
||||
player->ReadyWeapon->SisterWeapon != nullptr &&
|
||||
player->ReadyWeapon->SisterWeapon->GetClass() == Weapons[i].Type))
|
||||
{
|
||||
for (j = (i == 0 ? Weapons.Size() - 1 : i - 1);
|
||||
|
@ -666,7 +635,7 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player, bool checkammo)
|
|||
{
|
||||
AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[j].Type));
|
||||
|
||||
if (weap != NULL && weap->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
if (weap != nullptr && weap->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
{
|
||||
|
@ -681,7 +650,7 @@ AWeapon *FWeaponSlot::PickWeapon(player_t *player, bool checkammo)
|
|||
{
|
||||
AWeapon *weap = static_cast<AWeapon *> (player->mo->FindInventory(Weapons[i].Type));
|
||||
|
||||
if (weap != NULL && weap->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
if (weap != nullptr && weap->IsKindOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
if (!checkammo || weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
{
|
||||
|
@ -737,7 +706,7 @@ void FWeaponSlot::Sort()
|
|||
for (i = 1; i < (int)Weapons.Size(); ++i)
|
||||
{
|
||||
int pos = Weapons[i].Position;
|
||||
PClassWeapon *type = Weapons[i].Type;
|
||||
PClassActor *type = Weapons[i].Type;
|
||||
for (j = i - 1; j >= 0 && Weapons[j].Position > pos; --j)
|
||||
{
|
||||
Weapons[j + 1] = Weapons[j];
|
||||
|
@ -786,7 +755,7 @@ void FWeaponSlots::Clear()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassWeapon *type)
|
||||
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassActor *type)
|
||||
{
|
||||
int currSlot, index;
|
||||
|
||||
|
@ -811,7 +780,7 @@ ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassWeapon *type)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool FWeaponSlots::LocateWeapon (PClassWeapon *type, int *const slot, int *const index)
|
||||
bool FWeaponSlots::LocateWeapon (PClassActor *type, int *const slot, int *const index)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -820,8 +789,8 @@ bool FWeaponSlots::LocateWeapon (PClassWeapon *type, int *const slot, int *const
|
|||
j = Slots[i].LocateWeapon(type);
|
||||
if (j >= 0)
|
||||
{
|
||||
if (slot != NULL) *slot = i;
|
||||
if (index != NULL) *index = j;
|
||||
if (slot != nullptr) *slot = i;
|
||||
if (index != nullptr) *index = j;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -858,14 +827,14 @@ static bool FindMostRecentWeapon(player_t *player, int *slot, int *index)
|
|||
{
|
||||
return player->weapons.LocateWeapon(player->PendingWeapon->GetClass(), slot, index);
|
||||
}
|
||||
else if (player->ReadyWeapon != NULL)
|
||||
else if (player->ReadyWeapon != nullptr)
|
||||
{
|
||||
AWeapon *weap = player->ReadyWeapon;
|
||||
if (!player->weapons.LocateWeapon(weap->GetClass(), slot, index))
|
||||
{
|
||||
// If the current weapon wasn't found and is powered up,
|
||||
// look for its non-powered up version.
|
||||
if (weap->WeaponFlags & WIF_POWERED_UP && weap->SisterWeaponType != NULL)
|
||||
if (weap->WeaponFlags & WIF_POWERED_UP && weap->SisterWeaponType != nullptr)
|
||||
{
|
||||
return player->weapons.LocateWeapon(weap->SisterWeaponType, slot, index);
|
||||
}
|
||||
|
@ -894,16 +863,16 @@ AWeapon *FWeaponSlots::PickNextWeapon(player_t *player)
|
|||
int startslot, startindex;
|
||||
int slotschecked = 0;
|
||||
|
||||
if (player->mo == NULL)
|
||||
if (player->mo == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (player->ReadyWeapon == NULL || FindMostRecentWeapon(player, &startslot, &startindex))
|
||||
if (player->ReadyWeapon == nullptr || FindMostRecentWeapon(player, &startslot, &startindex))
|
||||
{
|
||||
int slot;
|
||||
int index;
|
||||
|
||||
if (player->ReadyWeapon == NULL)
|
||||
if (player->ReadyWeapon == nullptr)
|
||||
{
|
||||
startslot = NUM_WEAPON_SLOTS - 1;
|
||||
startindex = Slots[startslot].Size() - 1;
|
||||
|
@ -922,9 +891,9 @@ AWeapon *FWeaponSlots::PickNextWeapon(player_t *player)
|
|||
slot = 0;
|
||||
}
|
||||
}
|
||||
PClassWeapon *type = Slots[slot].GetWeapon(index);
|
||||
PClassActor *type = Slots[slot].GetWeapon(index);
|
||||
AWeapon *weap = static_cast<AWeapon *>(player->mo->FindInventory(type));
|
||||
if (weap != NULL && weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
if (weap != nullptr && weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
{
|
||||
return weap;
|
||||
}
|
||||
|
@ -949,16 +918,16 @@ AWeapon *FWeaponSlots::PickPrevWeapon (player_t *player)
|
|||
int startslot, startindex;
|
||||
int slotschecked = 0;
|
||||
|
||||
if (player->mo == NULL)
|
||||
if (player->mo == nullptr)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
if (player->ReadyWeapon == NULL || FindMostRecentWeapon (player, &startslot, &startindex))
|
||||
if (player->ReadyWeapon == nullptr || FindMostRecentWeapon (player, &startslot, &startindex))
|
||||
{
|
||||
int slot;
|
||||
int index;
|
||||
|
||||
if (player->ReadyWeapon == NULL)
|
||||
if (player->ReadyWeapon == nullptr)
|
||||
{
|
||||
startslot = 0;
|
||||
startindex = 0;
|
||||
|
@ -977,9 +946,9 @@ AWeapon *FWeaponSlots::PickPrevWeapon (player_t *player)
|
|||
}
|
||||
index = Slots[slot].Size() - 1;
|
||||
}
|
||||
PClassWeapon *type = Slots[slot].GetWeapon(index);
|
||||
PClassActor *type = Slots[slot].GetWeapon(index);
|
||||
AWeapon *weap = static_cast<AWeapon *>(player->mo->FindInventory(type));
|
||||
if (weap != NULL && weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
if (weap != nullptr && weap->CheckAmmo(AWeapon::EitherFire, false))
|
||||
{
|
||||
return weap;
|
||||
}
|
||||
|
@ -1011,23 +980,23 @@ void FWeaponSlots::AddExtraWeapons()
|
|||
// Append extra weapons to the slots.
|
||||
for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
||||
{
|
||||
PClass *cls = PClassActor::AllActorClasses[i];
|
||||
PClassActor *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.
|
||||
auto weapdef = ((AWeapon*)GetDefaultByType(cls));
|
||||
if ((cls->GameFilter == GAME_Any || (cls->GameFilter & gameinfo.gametype)) &&
|
||||
cls->Replacement == nullptr && // Replaced weapons don't get slotted.
|
||||
!(weapdef->WeaponFlags & WIF_POWERED_UP) &&
|
||||
!LocateWeapon(cls, nullptr, nullptr) // Don't duplicate it if it's already present.
|
||||
)
|
||||
{
|
||||
int slot = acls->SlotNumber;
|
||||
int slot = weapdef->SlotNumber;
|
||||
if ((unsigned)slot < NUM_WEAPON_SLOTS)
|
||||
{
|
||||
FWeaponSlot::WeaponInfo info = { acls, acls->SlotPriority };
|
||||
FWeaponSlot::WeaponInfo info = { cls, weapdef->SlotPriority };
|
||||
Slots[slot].Weapons.Push(info);
|
||||
}
|
||||
}
|
||||
|
@ -1064,8 +1033,8 @@ void FWeaponSlots::SetFromGameInfo()
|
|||
{
|
||||
for (unsigned j = 0; j < gameinfo.DefaultWeaponSlots[i].Size(); j++)
|
||||
{
|
||||
PClassWeapon *cls = dyn_cast<PClassWeapon>(PClass::FindClass(gameinfo.DefaultWeaponSlots[i][j]));
|
||||
if (cls == NULL)
|
||||
PClassActor *cls = PClass::FindActor(gameinfo.DefaultWeaponSlots[i][j]);
|
||||
if (cls == nullptr)
|
||||
{
|
||||
Printf("Unknown weapon class '%s' found in default weapon slot assignments\n",
|
||||
gameinfo.DefaultWeaponSlots[i][j].GetChars());
|
||||
|
@ -1261,7 +1230,7 @@ CCMD (setslot)
|
|||
if (argv.argc() < 2 || (slot = atoi (argv[1])) >= NUM_WEAPON_SLOTS)
|
||||
{
|
||||
Printf("Usage: setslot [slot] [weapons]\nCurrent slot assignments:\n");
|
||||
if (players[consoleplayer].mo != NULL)
|
||||
if (players[consoleplayer].mo != nullptr)
|
||||
{
|
||||
FString config(GameConfig->GetConfigPath(false));
|
||||
Printf(TEXTCOLOR_BLUE "Add the following to " TEXTCOLOR_ORANGE "%s" TEXTCOLOR_BLUE
|
||||
|
@ -1280,7 +1249,7 @@ CCMD (setslot)
|
|||
{
|
||||
KeyConfWeapons.Push(argv.args());
|
||||
}
|
||||
else if (PlayingKeyConf != NULL)
|
||||
else if (PlayingKeyConf != nullptr)
|
||||
{
|
||||
PlayingKeyConf->Slots[slot].Clear();
|
||||
for (int i = 2; i < argv.argc(); ++i)
|
||||
|
@ -1300,7 +1269,7 @@ CCMD (setslot)
|
|||
Net_WriteByte(argv.argc()-2);
|
||||
for (int i = 2; i < argv.argc(); i++)
|
||||
{
|
||||
Net_WriteWeapon(dyn_cast<PClassWeapon>(PClass::FindClass(argv[i])));
|
||||
Net_WriteWeapon(dyn_cast<PClassActor>(PClass::FindClass(argv[i])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1311,9 +1280,9 @@ CCMD (setslot)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void FWeaponSlots::AddSlot(int slot, PClassWeapon *type, bool feedback)
|
||||
void FWeaponSlots::AddSlot(int slot, PClassActor *type, bool feedback)
|
||||
{
|
||||
if (type != NULL && !Slots[slot].AddWeapon(type) && feedback)
|
||||
if (type != nullptr && !Slots[slot].AddWeapon(type) && feedback)
|
||||
{
|
||||
Printf ("Could not add %s to slot %d\n", type->TypeName.GetChars(), slot);
|
||||
}
|
||||
|
@ -1329,8 +1298,8 @@ CCMD (addslot)
|
|||
return;
|
||||
}
|
||||
|
||||
PClassWeapon *type= dyn_cast<PClassWeapon>(PClass::FindClass(argv[2]));
|
||||
if (type == NULL)
|
||||
PClassActor *type= dyn_cast<PClassActor>(PClass::FindClass(argv[2]));
|
||||
if (type == nullptr)
|
||||
{
|
||||
Printf("%s is not a weapon\n", argv[2]);
|
||||
return;
|
||||
|
@ -1340,7 +1309,7 @@ CCMD (addslot)
|
|||
{
|
||||
KeyConfWeapons.Push(argv.args());
|
||||
}
|
||||
else if (PlayingKeyConf != NULL)
|
||||
else if (PlayingKeyConf != nullptr)
|
||||
{
|
||||
PlayingKeyConf->AddSlot(int(slot), type, false);
|
||||
}
|
||||
|
@ -1371,9 +1340,9 @@ CCMD (weaponsection)
|
|||
// CCMD addslotdefault
|
||||
//
|
||||
//===========================================================================
|
||||
void FWeaponSlots::AddSlotDefault(int slot, PClassWeapon *type, bool feedback)
|
||||
void FWeaponSlots::AddSlotDefault(int slot, PClassActor *type, bool feedback)
|
||||
{
|
||||
if (type != NULL && type->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
||||
if (type != nullptr && type->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
switch (AddDefaultWeapon(slot, type))
|
||||
{
|
||||
|
@ -1396,7 +1365,7 @@ void FWeaponSlots::AddSlotDefault(int slot, PClassWeapon *type, bool feedback)
|
|||
|
||||
CCMD (addslotdefault)
|
||||
{
|
||||
PClassWeapon *type;
|
||||
PClassActor *type;
|
||||
unsigned int slot;
|
||||
|
||||
if (argv.argc() != 3 || (slot = atoi (argv[1])) >= NUM_WEAPON_SLOTS)
|
||||
|
@ -1405,8 +1374,8 @@ CCMD (addslotdefault)
|
|||
return;
|
||||
}
|
||||
|
||||
type = dyn_cast<PClassWeapon>(PClass::FindClass(argv[2]));
|
||||
if (type == NULL)
|
||||
type = dyn_cast<PClassActor>(PClass::FindClass(argv[2]));
|
||||
if (type == nullptr)
|
||||
{
|
||||
Printf ("%s is not a weapon\n", argv[2]);
|
||||
return;
|
||||
|
@ -1416,7 +1385,7 @@ CCMD (addslotdefault)
|
|||
{
|
||||
KeyConfWeapons.Push(argv.args());
|
||||
}
|
||||
else if (PlayingKeyConf != NULL)
|
||||
else if (PlayingKeyConf != nullptr)
|
||||
{
|
||||
PlayingKeyConf->AddSlotDefault(int(slot), type, false);
|
||||
}
|
||||
|
@ -1444,7 +1413,7 @@ void P_PlaybackKeyConfWeapons(FWeaponSlots *slots)
|
|||
FString cmd(KeyConfWeapons[i]);
|
||||
AddCommandString(cmd.LockBuffer());
|
||||
}
|
||||
PlayingKeyConf = NULL;
|
||||
PlayingKeyConf = nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -1461,20 +1430,20 @@ void P_PlaybackKeyConfWeapons(FWeaponSlots *slots)
|
|||
void P_SetupWeapons_ntohton()
|
||||
{
|
||||
unsigned int i;
|
||||
PClassWeapon *cls;
|
||||
PClassActor *cls;
|
||||
|
||||
Weapons_ntoh.Clear();
|
||||
Weapons_hton.Clear();
|
||||
|
||||
cls = NULL;
|
||||
Weapons_ntoh.Push(cls); // Index 0 is always NULL.
|
||||
cls = nullptr;
|
||||
Weapons_ntoh.Push(cls); // Index 0 is always nullptr.
|
||||
for (i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
|
||||
{
|
||||
PClassActor *cls = PClassActor::AllActorClasses[i];
|
||||
|
||||
if (cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
|
||||
{
|
||||
Weapons_ntoh.Push(static_cast<PClassWeapon *>(cls));
|
||||
Weapons_ntoh.Push(static_cast<PClassActor *>(cls));
|
||||
}
|
||||
}
|
||||
qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp);
|
||||
|
@ -1500,8 +1469,8 @@ void P_SetupWeapons_ntohton()
|
|||
|
||||
static int ntoh_cmp(const void *a, const void *b)
|
||||
{
|
||||
PClassWeapon *c1 = *(PClassWeapon **)a;
|
||||
PClassWeapon *c2 = *(PClassWeapon **)b;
|
||||
PClassActor *c1 = *(PClassActor **)a;
|
||||
PClassActor *c2 = *(PClassActor **)b;
|
||||
int g1 = c1->GameFilter == GAME_Any ? 1 : (c1->GameFilter & gameinfo.gametype) ? 0 : 2;
|
||||
int g2 = c2->GameFilter == GAME_Any ? 1 : (c2->GameFilter & gameinfo.gametype) ? 0 : 2;
|
||||
if (g1 != g2)
|
||||
|
@ -1541,24 +1510,24 @@ void P_WriteDemoWeaponsChunk(BYTE **demo)
|
|||
void P_ReadDemoWeaponsChunk(BYTE **demo)
|
||||
{
|
||||
int count, i;
|
||||
PClassWeapon *type;
|
||||
PClassActor *type;
|
||||
const char *s;
|
||||
|
||||
count = ReadWord(demo);
|
||||
Weapons_ntoh.Resize(count);
|
||||
Weapons_hton.Clear(count);
|
||||
|
||||
Weapons_ntoh[0] = type = NULL;
|
||||
Weapons_ntoh[0] = type = nullptr;
|
||||
Weapons_hton[type] = 0;
|
||||
|
||||
for (i = 1; i < count; ++i)
|
||||
{
|
||||
s = ReadStringConst(demo);
|
||||
type = dyn_cast<PClassWeapon>(PClass::FindClass(s));
|
||||
type = dyn_cast<PClassActor>(PClass::FindClass(s));
|
||||
// If a demo was recorded with a weapon that is no longer present,
|
||||
// should we report it?
|
||||
Weapons_ntoh[i] = type;
|
||||
if (type != NULL)
|
||||
if (type != nullptr)
|
||||
{
|
||||
Weapons_hton[type] = i;
|
||||
}
|
||||
|
@ -1571,12 +1540,12 @@ void P_ReadDemoWeaponsChunk(BYTE **demo)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void Net_WriteWeapon(PClassWeapon *type)
|
||||
void Net_WriteWeapon(PClassActor *type)
|
||||
{
|
||||
int index, *index_p;
|
||||
|
||||
index_p = Weapons_hton.CheckKey(type);
|
||||
if (index_p == NULL)
|
||||
if (index_p == nullptr)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
@ -1603,7 +1572,7 @@ void Net_WriteWeapon(PClassWeapon *type)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassWeapon *Net_ReadWeapon(BYTE **stream)
|
||||
PClassActor *Net_ReadWeapon(BYTE **stream)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
@ -1614,7 +1583,7 @@ PClassWeapon *Net_ReadWeapon(BYTE **stream)
|
|||
}
|
||||
if ((unsigned)index >= Weapons_ntoh.Size())
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
return Weapons_ntoh[index];
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "a_pickups.h"
|
||||
class PClassWeapon;
|
||||
class PClassActor;
|
||||
class AWeapon;
|
||||
|
||||
class FWeaponSlot
|
||||
|
@ -12,13 +12,13 @@ public:
|
|||
FWeaponSlot &operator= (const FWeaponSlot &other) { Weapons = other.Weapons; return *this; }
|
||||
void Clear() { Weapons.Clear(); }
|
||||
bool AddWeapon (const char *type);
|
||||
bool AddWeapon (PClassWeapon *type);
|
||||
bool AddWeapon (PClassActor *type);
|
||||
void AddWeaponList (const char *list, bool clear);
|
||||
AWeapon *PickWeapon (player_t *player, bool checkammo = false);
|
||||
int Size () const { return (int)Weapons.Size(); }
|
||||
int LocateWeapon (PClassWeapon *type);
|
||||
int LocateWeapon (PClassActor *type);
|
||||
|
||||
inline PClassWeapon *GetWeapon (int index) const
|
||||
inline PClassActor *GetWeapon (int index) const
|
||||
{
|
||||
if ((unsigned)index < Weapons.Size())
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
private:
|
||||
struct WeaponInfo
|
||||
{
|
||||
PClassWeapon *Type;
|
||||
PClassActor *Type;
|
||||
int Position;
|
||||
};
|
||||
void SetInitialPositions();
|
||||
|
@ -61,8 +61,8 @@ struct FWeaponSlots
|
|||
AWeapon *PickPrevWeapon (player_t *player);
|
||||
|
||||
void Clear ();
|
||||
bool LocateWeapon (PClassWeapon *type, int *const slot, int *const index);
|
||||
ESlotDef AddDefaultWeapon (int slot, PClassWeapon *type);
|
||||
bool LocateWeapon (PClassActor *type, int *const slot, int *const index);
|
||||
ESlotDef AddDefaultWeapon (int slot, PClassActor *type);
|
||||
void AddExtraWeapons();
|
||||
void SetFromGameInfo();
|
||||
void SetFromPlayer(PClassPlayerPawn *type);
|
||||
|
@ -72,36 +72,23 @@ struct FWeaponSlots
|
|||
int RestoreSlots (FConfigFile *config, const char *section);
|
||||
void PrintSettings();
|
||||
|
||||
void AddSlot(int slot, PClassWeapon *type, bool feedback);
|
||||
void AddSlotDefault(int slot, PClassWeapon *type, bool feedback);
|
||||
void AddSlot(int slot, PClassActor *type, bool feedback);
|
||||
void AddSlotDefault(int slot, PClassActor *type, bool feedback);
|
||||
|
||||
};
|
||||
|
||||
void P_PlaybackKeyConfWeapons(FWeaponSlots *slots);
|
||||
void Net_WriteWeapon(PClassWeapon *type);
|
||||
PClassWeapon *Net_ReadWeapon(BYTE **stream);
|
||||
void Net_WriteWeapon(PClassActor *type);
|
||||
PClassActor *Net_ReadWeapon(BYTE **stream);
|
||||
|
||||
void P_SetupWeapons_ntohton();
|
||||
void P_WriteDemoWeaponsChunk(BYTE **demo);
|
||||
void P_ReadDemoWeaponsChunk(BYTE **demo);
|
||||
|
||||
|
||||
// A weapon is just that.
|
||||
class PClassWeapon : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassWeapon, PClassInventory);
|
||||
protected:
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
public:
|
||||
PClassWeapon();
|
||||
|
||||
int SlotNumber;
|
||||
int SlotPriority;
|
||||
};
|
||||
|
||||
class AWeapon : public AStateProvider
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(AWeapon, AStateProvider, PClassWeapon)
|
||||
DECLARE_CLASS(AWeapon, AStateProvider)
|
||||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
DWORD WeaponFlags;
|
||||
|
@ -112,7 +99,7 @@ public:
|
|||
int Kickback;
|
||||
float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double)
|
||||
FSoundIDNoInit UpSound, ReadySound; // Sounds when coming up and idle
|
||||
PClassWeapon *SisterWeaponType; // Another weapon to pick up with this one
|
||||
PClassActor *SisterWeaponType; // Another weapon to pick up with this one
|
||||
PClassActor *ProjectileType; // Projectile used by primary attack
|
||||
PClassActor *AltProjectileType; // Projectile used by alternate attack
|
||||
int SelectionOrder; // Lower-numbered weapons get picked first
|
||||
|
@ -122,6 +109,8 @@ public:
|
|||
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double)
|
||||
float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs.
|
||||
float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
|
||||
int SlotNumber;
|
||||
int SlotPriority;
|
||||
|
||||
// In-inventory instance variables
|
||||
TObjPtr<AInventory> Ammo1, Ammo2;
|
||||
|
|
|
@ -2065,8 +2065,7 @@ DEFINE_CLASS_PROPERTY(bobrangey, F, Weapon)
|
|||
DEFINE_CLASS_PROPERTY(slotnumber, I, Weapon)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassWeapon)));
|
||||
static_cast<PClassWeapon *>(info)->SlotNumber = i;
|
||||
defaults->SlotNumber = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -2075,8 +2074,7 @@ DEFINE_CLASS_PROPERTY(slotnumber, I, Weapon)
|
|||
DEFINE_CLASS_PROPERTY(slotpriority, F, Weapon)
|
||||
{
|
||||
PROP_DOUBLE_PARM(i, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassWeapon)));
|
||||
static_cast<PClassWeapon *>(info)->SlotPriority = int(i*65536);
|
||||
defaults->SlotPriority = int(i*65536);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -43,6 +43,8 @@ class Weapon : StateProvider native
|
|||
Weapon.BobSpeed 1.0;
|
||||
Weapon.BobRangeX 1.0;
|
||||
Weapon.BobRangeY 1.0;
|
||||
Weapon.SlotNumber -1;
|
||||
Weapon.SlotPriority 32767;
|
||||
+WEAPONSPAWN
|
||||
DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_WEAPON;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue