mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 14:51:46 +00:00
- removed PClassAmmo.
No need to maintain these clunky meta class for one single property. The overhead the mere existence of this class creates is far more than 100 spawned ammo items would cost. There is no need to serialize AAmmo::DropAmount, this value has no meaning on an already spawned item.
This commit is contained in:
parent
da43576035
commit
23482735a0
17 changed files with 30 additions and 62 deletions
|
@ -44,7 +44,6 @@
|
|||
#include "portal.h"
|
||||
|
||||
struct subsector_t;
|
||||
class PClassAmmo;
|
||||
struct FBlockNode;
|
||||
struct FPortalGroupArray;
|
||||
|
||||
|
@ -733,7 +732,7 @@ public:
|
|||
AInventory *FirstInv ();
|
||||
|
||||
// Tries to give the actor some ammo.
|
||||
bool GiveAmmo (PClassAmmo *type, int amount);
|
||||
bool GiveAmmo (PClassInventory *type, int amount);
|
||||
|
||||
// Destroys all the inventory the actor is holding.
|
||||
void DestroyAllInventory ();
|
||||
|
|
|
@ -147,7 +147,7 @@ struct StyleName
|
|||
|
||||
static TArray<StyleName> StyleNames;
|
||||
|
||||
static TArray<PClassAmmo *> AmmoNames;
|
||||
static TArray<PClassActor *> AmmoNames;
|
||||
static TArray<PClassActor *> WeaponNames;
|
||||
|
||||
// DeHackEd trickery to support MBF-style parameters
|
||||
|
@ -1535,7 +1535,7 @@ static int PatchSprite (int sprNum)
|
|||
|
||||
static int PatchAmmo (int ammoNum)
|
||||
{
|
||||
PClassAmmo *ammoType = NULL;
|
||||
PClassActor *ammoType = NULL;
|
||||
AAmmo *defaultAmmo = NULL;
|
||||
int result;
|
||||
int oldclip;
|
||||
|
@ -1670,7 +1670,7 @@ static int PatchWeapon (int weapNum)
|
|||
{
|
||||
val = 5;
|
||||
}
|
||||
info->AmmoType1 = AmmoNames[val];
|
||||
info->AmmoType1 = (PClassInventory*)AmmoNames[val];
|
||||
if (info->AmmoType1 != NULL)
|
||||
{
|
||||
info->AmmoGive1 = ((AAmmo*)GetDefaultByType (info->AmmoType1))->Amount * 2;
|
||||
|
@ -2929,8 +2929,8 @@ static bool LoadDehSupp ()
|
|||
}
|
||||
else
|
||||
{
|
||||
PClassAmmo *cls = dyn_cast<PClassAmmo>(PClass::FindClass(sc.String));
|
||||
if (cls == NULL)
|
||||
auto cls = PClass::FindActor(sc.String);
|
||||
if (cls == NULL || !cls->IsDescendantOf(RUNTIME_CLASS(AAmmo)))
|
||||
{
|
||||
sc.ScriptError("Unknown ammo type '%s'", sc.String);
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ public:
|
|||
void TweakSpeeds (double &forwardmove, double &sidemove);
|
||||
void MorphPlayerThink ();
|
||||
void ActivateMorphWeapon ();
|
||||
AWeapon *PickNewWeapon (PClassAmmo *ammotype);
|
||||
AWeapon *BestWeapon (PClassAmmo *ammotype);
|
||||
void CheckWeaponSwitch(PClassAmmo *ammotype);
|
||||
AWeapon *PickNewWeapon (PClassInventory *ammotype);
|
||||
AWeapon *BestWeapon (PClassInventory *ammotype);
|
||||
void CheckWeaponSwitch(PClassInventory *ammotype);
|
||||
void GiveDeathmatchInventory ();
|
||||
void FilterCoopRespawnInventory (APlayerPawn *oldplayer);
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ enum
|
|||
CLASSREG_PClass,
|
||||
CLASSREG_PClassActor,
|
||||
CLASSREG_PClassInventory,
|
||||
CLASSREG_PClassAmmo,
|
||||
CLASSREG_PClassHealth,
|
||||
CLASSREG_PClassPuzzleItem,
|
||||
CLASSREG_PClassWeapon,
|
||||
|
|
|
@ -3090,7 +3090,6 @@ PClass *ClassReg::RegisterClass()
|
|||
&PClass::RegistrationInfo,
|
||||
&PClassActor::RegistrationInfo,
|
||||
&PClassInventory::RegistrationInfo,
|
||||
&PClassAmmo::RegistrationInfo,
|
||||
&PClassHealth::RegistrationInfo,
|
||||
&PClassPuzzleItem::RegistrationInfo,
|
||||
&PClassWeapon::RegistrationInfo,
|
||||
|
|
|
@ -341,7 +341,7 @@ inline int T_FindFirstSectorFromTag(int tagnum)
|
|||
// Doom index is only supported for the 4 original ammo types
|
||||
//
|
||||
//==========================================================================
|
||||
static PClassAmmo * T_GetAmmo(const svalue_t &t)
|
||||
static PClassInventory * T_GetAmmo(const svalue_t &t)
|
||||
{
|
||||
const char * p;
|
||||
|
||||
|
@ -362,7 +362,7 @@ static PClassAmmo * T_GetAmmo(const svalue_t &t)
|
|||
}
|
||||
p=DefAmmo[ammonum];
|
||||
}
|
||||
PClassAmmo * am=dyn_cast<PClassAmmo>(PClass::FindActor(p));
|
||||
PClassInventory * am=dyn_cast<PClassInventory>(PClass::FindActor(p));
|
||||
if (am == NULL)
|
||||
{
|
||||
script_error("unknown ammo type : %s", p);
|
||||
|
@ -2572,7 +2572,7 @@ void FParser::SF_PlayerKeys(void)
|
|||
void FParser::SF_PlayerAmmo(void)
|
||||
{
|
||||
int playernum, amount;
|
||||
PClassAmmo * ammotype;
|
||||
PClassInventory * ammotype;
|
||||
|
||||
if (CheckArgs(2))
|
||||
{
|
||||
|
@ -2608,7 +2608,7 @@ void FParser::SF_PlayerAmmo(void)
|
|||
void FParser::SF_MaxPlayerAmmo()
|
||||
{
|
||||
int playernum, amount;
|
||||
PClassAmmo * ammotype;
|
||||
PClassInventory * ammotype;
|
||||
|
||||
if (CheckArgs(2))
|
||||
{
|
||||
|
|
|
@ -37,22 +37,6 @@
|
|||
#include "d_player.h"
|
||||
#include "serializer.h"
|
||||
|
||||
IMPLEMENT_CLASS(PClassAmmo, false, false)
|
||||
|
||||
PClassAmmo::PClassAmmo()
|
||||
{
|
||||
DropAmount = 0;
|
||||
}
|
||||
|
||||
void PClassAmmo::DeriveData(PClass *newclass)
|
||||
{
|
||||
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassAmmo)));
|
||||
Super::DeriveData(newclass);
|
||||
PClassAmmo *newc = static_cast<PClassAmmo *>(newclass);
|
||||
|
||||
newc->DropAmount = DropAmount;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(AAmmo, false, false)
|
||||
|
||||
DEFINE_FIELD(AAmmo, BackpackAmount)
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
#pragma once
|
||||
#include "a_pickups.h"
|
||||
|
||||
// Ammo: Something a weapon needs to operate
|
||||
class PClassAmmo : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassAmmo, PClassInventory)
|
||||
protected:
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
public:
|
||||
PClassAmmo();
|
||||
|
||||
int DropAmount; // Specifies the amount for a dropped ammo item.
|
||||
};
|
||||
|
||||
class AAmmo : public AInventory
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(AAmmo, AInventory, PClassAmmo)
|
||||
DECLARE_CLASS(AAmmo, AInventory)
|
||||
public:
|
||||
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
|
@ -24,7 +12,7 @@ public:
|
|||
virtual AInventory *CreateTossable () override;
|
||||
PClassActor *GetParentAmmo () const;
|
||||
|
||||
int BackpackAmount, BackpackMaxAmount;
|
||||
int BackpackAmount, BackpackMaxAmount, DropAmount;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class AWeapon : public AStateProvider
|
|||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
DWORD WeaponFlags;
|
||||
PClassAmmo *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
|
||||
PClassInventory *AmmoType1, *AmmoType2; // Types of ammo used by this weapon
|
||||
int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon
|
||||
int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon
|
||||
int AmmoUse1, AmmoUse2; // How much ammo to use with each shot
|
||||
|
|
|
@ -517,14 +517,14 @@ static int DrawKeys(player_t * CPlayer, int x, int y)
|
|||
// Drawing Ammo
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
static TArray<PClassAmmo *> orderedammos;
|
||||
static TArray<PClassInventory *> orderedammos;
|
||||
|
||||
static void AddAmmoToList(AWeapon * weapdef)
|
||||
{
|
||||
|
||||
for(int i=0; i<2;i++)
|
||||
{
|
||||
PClassAmmo * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
|
||||
PClassInventory * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
|
||||
if (ti)
|
||||
{
|
||||
AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti);
|
||||
|
@ -647,7 +647,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y)
|
|||
for(i=orderedammos.Size()-1;i>=0;i--)
|
||||
{
|
||||
|
||||
PClassAmmo * type = orderedammos[i];
|
||||
PClassInventory * type = orderedammos[i];
|
||||
AAmmo * ammoitem = (AAmmo*)CPlayer->mo->FindInventory(type);
|
||||
|
||||
AAmmo * inv = ammoitem? ammoitem : (AAmmo*)GetDefaultByType(orderedammos[i]);
|
||||
|
|
|
@ -646,7 +646,7 @@ void cht_Give (player_t *player, const char *name, int amount)
|
|||
|
||||
if (type->ParentClass == RUNTIME_CLASS(AAmmo))
|
||||
{
|
||||
PClassAmmo *atype = static_cast<PClassAmmo *>(type);
|
||||
PClassInventory *atype = static_cast<PClassInventory *>(type);
|
||||
AInventory *ammo = player->mo->FindInventory(atype);
|
||||
if (ammo == NULL)
|
||||
{
|
||||
|
|
|
@ -8720,19 +8720,19 @@ scriptwait:
|
|||
case PCD_SETAMMOCAPACITY:
|
||||
if (activator != NULL)
|
||||
{
|
||||
PClass *type = PClass::FindClass (FBehavior::StaticLookupString (STACK(2)));
|
||||
PClassActor *type = PClass::FindActor (FBehavior::StaticLookupString (STACK(2)));
|
||||
AInventory *item;
|
||||
|
||||
if (type != NULL && type->ParentClass == RUNTIME_CLASS(AAmmo))
|
||||
{
|
||||
item = activator->FindInventory (static_cast<PClassActor *>(type));
|
||||
item = activator->FindInventory (type);
|
||||
if (item != NULL)
|
||||
{
|
||||
item->MaxAmount = STACK(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = activator->GiveInventoryType (static_cast<PClassAmmo *>(type));
|
||||
item = activator->GiveInventoryType (type);
|
||||
if (item != NULL)
|
||||
{
|
||||
item->MaxAmount = STACK(1);
|
||||
|
|
|
@ -3241,7 +3241,7 @@ void ModifyDropAmount(AInventory *inv, int dropamount)
|
|||
else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
||||
{
|
||||
// Half ammo when dropped by bad guys.
|
||||
int amount = static_cast<PClassAmmo *>(inv->GetClass())->DropAmount;
|
||||
int amount = static_cast<AAmmo *>(inv)->DropAmount;
|
||||
if (amount <= 0)
|
||||
{
|
||||
amount = MAX(1, int(inv->Amount * dropammofactor));
|
||||
|
|
|
@ -1134,7 +1134,7 @@ DEFINE_ACTION_FUNCTION(AActor, GiveInventoryType)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
bool AActor::GiveAmmo (PClassAmmo *type, int amount)
|
||||
bool AActor::GiveAmmo (PClassInventory *type, int amount)
|
||||
{
|
||||
if (type != NULL)
|
||||
{
|
||||
|
|
|
@ -942,7 +942,7 @@ bool APlayerPawn::UseInventory (AInventory *item)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
AWeapon *APlayerPawn::BestWeapon(PClassAmmo *ammotype)
|
||||
AWeapon *APlayerPawn::BestWeapon(PClassInventory *ammotype)
|
||||
{
|
||||
AWeapon *bestMatch = NULL;
|
||||
int bestOrder = INT_MAX;
|
||||
|
@ -1004,7 +1004,7 @@ AWeapon *APlayerPawn::BestWeapon(PClassAmmo *ammotype)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
AWeapon *APlayerPawn::PickNewWeapon(PClassAmmo *ammotype)
|
||||
AWeapon *APlayerPawn::PickNewWeapon(PClassInventory *ammotype)
|
||||
{
|
||||
AWeapon *best = BestWeapon (ammotype);
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ AWeapon *APlayerPawn::PickNewWeapon(PClassAmmo *ammotype)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void APlayerPawn::CheckWeaponSwitch(PClassAmmo *ammotype)
|
||||
void APlayerPawn::CheckWeaponSwitch(PClassInventory *ammotype)
|
||||
{
|
||||
if (!player->userinfo.GetNeverSwitch() &&
|
||||
player->PendingWeapon == WP_NOCHANGE &&
|
||||
|
|
|
@ -1723,8 +1723,7 @@ DEFINE_CLASS_PROPERTY(backpackmaxamount, I, Ammo)
|
|||
DEFINE_CLASS_PROPERTY(dropamount, I, Ammo)
|
||||
{
|
||||
PROP_INT_PARM(i, 0);
|
||||
assert(info->IsKindOf(RUNTIME_CLASS(PClassAmmo)));
|
||||
static_cast<PClassAmmo *>(info)->DropAmount = i;
|
||||
defaults->DropAmount = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -258,7 +258,7 @@ FONT 8, "MS Shell Dlg"
|
|||
CONTROL "Load lights", IDC_WELCOME_LIGHTS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 180, 51, 10
|
||||
CONTROL "Load brightmaps", IDC_WELCOME_BRIGHTMAPS, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 130, 190, 65, 10
|
||||
CONTROL "Don't ask me this again", IDC_DONTASKIWAD, BUTTON, BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 73, 211, 87, 10
|
||||
CONTROL "Play QZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14
|
||||
CONTROL "Play GZDoom", IDOK, BUTTON, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 228, 90, 14
|
||||
CONTROL "Exit", IDCANCEL, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 166, 228, 50, 14
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue