mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 07:12:36 +00:00
Merge remote-tracking branch 'gzdoom/master' into qzdoom
# Conflicts: # src/r_draw.cpp
This commit is contained in:
commit
4f73a722af
26 changed files with 536 additions and 500 deletions
|
@ -596,6 +596,7 @@ public:
|
|||
AActor &operator= (const AActor &other);
|
||||
~AActor ();
|
||||
|
||||
virtual void Finalize(FStateDefinitions &statedef);
|
||||
virtual void OnDestroy() override;
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
virtual void PostSerialize() override;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -397,6 +397,23 @@ size_t DObject::PropagateMark()
|
|||
GC::Mark((DObject **)((BYTE *)this + *offsets));
|
||||
offsets++;
|
||||
}
|
||||
|
||||
offsets = info->ArrayPointers;
|
||||
if (offsets == NULL)
|
||||
{
|
||||
const_cast<PClass *>(info)->BuildArrayPointers();
|
||||
offsets = info->ArrayPointers;
|
||||
}
|
||||
while (*offsets != ~(size_t)0)
|
||||
{
|
||||
auto aray = (TArray<DObject*>*)((BYTE *)this + *offsets);
|
||||
for (auto &p : *aray)
|
||||
{
|
||||
GC::Mark(&p);
|
||||
}
|
||||
offsets++;
|
||||
}
|
||||
|
||||
return info->Size;
|
||||
}
|
||||
return 0;
|
||||
|
@ -427,6 +444,28 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld)
|
|||
}
|
||||
offsets++;
|
||||
}
|
||||
|
||||
offsets = info->ArrayPointers;
|
||||
if (offsets == NULL)
|
||||
{
|
||||
const_cast<PClass *>(info)->BuildArrayPointers();
|
||||
offsets = info->ArrayPointers;
|
||||
}
|
||||
while (*offsets != ~(size_t)0)
|
||||
{
|
||||
auto aray = (TArray<DObject*>*)((BYTE *)this + *offsets);
|
||||
for (auto &p : *aray)
|
||||
{
|
||||
if (p == old)
|
||||
{
|
||||
p = notOld;
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
offsets++;
|
||||
}
|
||||
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,10 +94,7 @@ enum
|
|||
CLASSREG_PClass,
|
||||
CLASSREG_PClassActor,
|
||||
CLASSREG_PClassInventory,
|
||||
CLASSREG_PClassWeapon,
|
||||
CLASSREG_PClassPlayerPawn,
|
||||
CLASSREG_PClassType,
|
||||
CLASSREG_PClassClass,
|
||||
};
|
||||
|
||||
struct ClassReg
|
||||
|
|
554
src/dobjtype.cpp
554
src/dobjtype.cpp
File diff suppressed because it is too large
Load diff
|
@ -199,22 +199,14 @@ public:
|
|||
// Prototype *+ *+
|
||||
|
||||
struct ZCC_ExprConstant;
|
||||
class PClassType;
|
||||
class PType : public PTypeBase
|
||||
{
|
||||
//DECLARE_ABSTRACT_CLASS_WITH_META(PType, DObject, PClassType);
|
||||
// We need to unravel the _WITH_META macro, since PClassType isn't defined yet,
|
||||
// and we can't define it until we've defined PClass. But we can't define that
|
||||
// without defining PType.
|
||||
DECLARE_ABSTRACT_CLASS(PType, PTypeBase)
|
||||
HAS_OBJECT_POINTERS;
|
||||
protected:
|
||||
enum { MetaClassNum = CLASSREG_PClassType };
|
||||
|
||||
public:
|
||||
typedef PClassType MetaClass;
|
||||
MetaClass *GetClass() const;
|
||||
|
||||
PClass *TypeTableType; // The type to use for hashing into the type table
|
||||
unsigned int Size; // this type's size
|
||||
unsigned int Align; // this type's preferred alignment
|
||||
PType *HashNext; // next type in this type table
|
||||
|
@ -247,6 +239,7 @@ public:
|
|||
// object is destroyed.
|
||||
virtual void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *special=NULL) const;
|
||||
virtual void SetPointer(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const;
|
||||
virtual void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const;
|
||||
|
||||
// Initialize the value, if needed (e.g. strings)
|
||||
virtual void InitializeValue(void *addr, const void *def) const;
|
||||
|
@ -534,7 +527,7 @@ class PClassPointer : public PPointer
|
|||
DECLARE_CLASS(PClassPointer, PPointer);
|
||||
HAS_OBJECT_POINTERS;
|
||||
public:
|
||||
PClassPointer(class PClass *restrict);
|
||||
PClassPointer(class PClass *restrict = nullptr);
|
||||
|
||||
class PClass *ClassRestriction;
|
||||
|
||||
|
@ -542,8 +535,6 @@ public:
|
|||
|
||||
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
|
||||
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;
|
||||
protected:
|
||||
PClassPointer();
|
||||
};
|
||||
|
||||
// Struct/class fields ------------------------------------------------------
|
||||
|
@ -657,6 +648,14 @@ public:
|
|||
|
||||
virtual bool IsMatch(intptr_t id1, intptr_t id2) const;
|
||||
virtual void GetTypeIDs(intptr_t &id1, intptr_t &id2) const;
|
||||
|
||||
void WriteValue(FSerializer &ar, const char *key, const void *addr) const override;
|
||||
bool ReadValue(FSerializer &ar, const char *key, void *addr) const override;
|
||||
void SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *specials) const override;
|
||||
void InitializeValue(void *addr, const void *def) const override;
|
||||
void DestroyValue(void *addr) const override;
|
||||
void SetPointerArray(void *base, unsigned offset, TArray<size_t> *ptrofs = NULL) const override;
|
||||
|
||||
protected:
|
||||
PDynArray();
|
||||
};
|
||||
|
@ -769,22 +768,17 @@ enum
|
|||
TentativeClass = UINT_MAX,
|
||||
};
|
||||
|
||||
class PClassClass;
|
||||
class PClass : public PNativeStruct
|
||||
{
|
||||
DECLARE_CLASS(PClass, PNativeStruct);
|
||||
HAS_OBJECT_POINTERS;
|
||||
protected:
|
||||
// We unravel _WITH_META here just as we did for PType.
|
||||
enum { MetaClassNum = CLASSREG_PClassClass };
|
||||
TArray<FTypeAndOffset> SpecialInits;
|
||||
void Derive(PClass *newclass, FName name);
|
||||
void InitializeSpecials(void *addr, void *defaults) const;
|
||||
void SetSuper();
|
||||
public:
|
||||
typedef PClassClass MetaClass;
|
||||
MetaClass *GetClass() const;
|
||||
|
||||
void WriteValue(FSerializer &ar, const char *key,const void *addr) const override;
|
||||
void WriteAllFields(FSerializer &ar, const void *addr) const;
|
||||
bool ReadValue(FSerializer &ar, const char *key,void *addr) const override;
|
||||
|
@ -801,6 +795,7 @@ public:
|
|||
PClass *ParentClass; // the class this class derives from
|
||||
const size_t *Pointers; // object pointers defined by this class *only*
|
||||
const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default
|
||||
const size_t *ArrayPointers; // dynamic arrays containing object pointers.
|
||||
BYTE *Defaults;
|
||||
bool bRuntimeClass; // class was defined at run-time, not compile-time
|
||||
bool bExported; // This type has been declared in a script
|
||||
|
@ -818,6 +813,7 @@ public:
|
|||
PField *AddField(FName name, PType *type, DWORD flags=0) override;
|
||||
void InitializeActorInfo();
|
||||
void BuildFlatPointers();
|
||||
void BuildArrayPointers();
|
||||
void DestroySpecials(void *addr) const;
|
||||
const PClass *NativeClass() const;
|
||||
|
||||
|
@ -860,34 +856,6 @@ public:
|
|||
static bool bVMOperational;
|
||||
};
|
||||
|
||||
class PClassType : public PClass
|
||||
{
|
||||
DECLARE_CLASS(PClassType, PClass);
|
||||
protected:
|
||||
public:
|
||||
PClassType();
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
|
||||
PClass *TypeTableType; // The type to use for hashing into the type table
|
||||
};
|
||||
|
||||
inline PType::MetaClass *PType::GetClass() const
|
||||
{
|
||||
return static_cast<MetaClass *>(DObject::GetClass());
|
||||
}
|
||||
|
||||
class PClassClass : public PClassType
|
||||
{
|
||||
DECLARE_CLASS(PClassClass, PClassType);
|
||||
public:
|
||||
PClassClass();
|
||||
};
|
||||
|
||||
inline PClass::MetaClass *PClass::GetClass() const
|
||||
{
|
||||
return static_cast<MetaClass *>(DObject::GetClass());
|
||||
}
|
||||
|
||||
// Type tables --------------------------------------------------------------
|
||||
|
||||
struct FTypeTable
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -73,10 +73,10 @@ size_t PClassInventory::PointerSubstitution(DObject *oldclass, DObject *newclass
|
|||
return changed;
|
||||
}
|
||||
|
||||
void PClassInventory::Finalize(FStateDefinitions &statedef)
|
||||
void AInventory::Finalize(FStateDefinitions &statedef)
|
||||
{
|
||||
Super::Finalize(statedef);
|
||||
((AActor*)Defaults)->flags |= MF_SPECIAL;
|
||||
flags |= MF_SPECIAL;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(AInventory, false, true)
|
||||
|
|
|
@ -72,6 +72,7 @@ class AInventory : public AActor
|
|||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
|
||||
virtual void Finalize(FStateDefinitions &statedef) override;
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
virtual void MarkPrecacheSounds() const override;
|
||||
virtual void OnDestroy() override;
|
||||
|
|
|
@ -113,55 +113,25 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void PClassWeapon::Finalize(FStateDefinitions &statedef)
|
||||
void AWeapon::Finalize(FStateDefinitions &statedef)
|
||||
{
|
||||
Super::Finalize(statedef);
|
||||
FState *ready = FindState(NAME_Ready);
|
||||
FState *select = FindState(NAME_Select);
|
||||
FState *deselect = FindState(NAME_Deselect);
|
||||
FState *fire = FindState(NAME_Fire);
|
||||
auto TypeName = GetClass()->TypeName;
|
||||
|
||||
// Consider any weapon without any valid state abstract and don't output a warning
|
||||
// This is for creating base classes for weapon groups that only set up some properties.
|
||||
|
@ -272,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;
|
||||
}
|
||||
|
@ -281,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;
|
||||
}
|
||||
|
@ -306,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;
|
||||
}
|
||||
|
@ -317,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;
|
||||
}
|
||||
|
@ -352,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))
|
||||
{
|
||||
|
@ -363,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;
|
||||
|
@ -546,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;
|
||||
}
|
||||
|
@ -594,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, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,7 +580,7 @@ void FWeaponSlot :: AddWeaponList(const char *list, bool clear)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
int FWeaponSlot::LocateWeapon(PClassWeapon *type)
|
||||
int FWeaponSlot::LocateWeapon(PClassActor *type)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
@ -641,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);
|
||||
|
@ -665,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))
|
||||
{
|
||||
|
@ -680,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))
|
||||
{
|
||||
|
@ -736,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];
|
||||
|
@ -785,7 +755,7 @@ void FWeaponSlots::Clear()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassWeapon *type)
|
||||
ESlotDef FWeaponSlots::AddDefaultWeapon (int slot, PClassActor *type)
|
||||
{
|
||||
int currSlot, index;
|
||||
|
||||
|
@ -810,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;
|
||||
|
||||
|
@ -819,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;
|
||||
}
|
||||
}
|
||||
|
@ -857,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);
|
||||
}
|
||||
|
@ -893,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;
|
||||
|
@ -921,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;
|
||||
}
|
||||
|
@ -948,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;
|
||||
|
@ -976,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;
|
||||
}
|
||||
|
@ -1010,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);
|
||||
}
|
||||
}
|
||||
|
@ -1063,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());
|
||||
|
@ -1260,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
|
||||
|
@ -1279,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)
|
||||
|
@ -1299,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])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1310,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);
|
||||
}
|
||||
|
@ -1328,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;
|
||||
|
@ -1339,7 +1309,7 @@ CCMD (addslot)
|
|||
{
|
||||
KeyConfWeapons.Push(argv.args());
|
||||
}
|
||||
else if (PlayingKeyConf != NULL)
|
||||
else if (PlayingKeyConf != nullptr)
|
||||
{
|
||||
PlayingKeyConf->AddSlot(int(slot), type, false);
|
||||
}
|
||||
|
@ -1370,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))
|
||||
{
|
||||
|
@ -1395,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)
|
||||
|
@ -1404,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;
|
||||
|
@ -1415,7 +1385,7 @@ CCMD (addslotdefault)
|
|||
{
|
||||
KeyConfWeapons.Push(argv.args());
|
||||
}
|
||||
else if (PlayingKeyConf != NULL)
|
||||
else if (PlayingKeyConf != nullptr)
|
||||
{
|
||||
PlayingKeyConf->AddSlotDefault(int(slot), type, false);
|
||||
}
|
||||
|
@ -1443,7 +1413,7 @@ void P_PlaybackKeyConfWeapons(FWeaponSlots *slots)
|
|||
FString cmd(KeyConfWeapons[i]);
|
||||
AddCommandString(cmd.LockBuffer());
|
||||
}
|
||||
PlayingKeyConf = NULL;
|
||||
PlayingKeyConf = nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -1460,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);
|
||||
|
@ -1499,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)
|
||||
|
@ -1540,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;
|
||||
}
|
||||
|
@ -1570,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;
|
||||
}
|
||||
|
@ -1602,7 +1572,7 @@ void Net_WriteWeapon(PClassWeapon *type)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassWeapon *Net_ReadWeapon(BYTE **stream)
|
||||
PClassActor *Net_ReadWeapon(BYTE **stream)
|
||||
{
|
||||
int index;
|
||||
|
||||
|
@ -1613,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,37 +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();
|
||||
void Finalize(FStateDefinitions &statedef);
|
||||
|
||||
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;
|
||||
|
@ -113,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
|
||||
|
@ -123,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;
|
||||
|
@ -135,7 +123,8 @@ public:
|
|||
|
||||
virtual void MarkPrecacheSounds() const;
|
||||
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
void Finalize(FStateDefinitions &statedef) override;
|
||||
void Serialize(FSerializer &arc) override;
|
||||
|
||||
void PostMorphWeapon();
|
||||
|
||||
|
|
|
@ -429,20 +429,20 @@ void PClassActor::SetDropItems(DDropItem *drops)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void PClassActor::Finalize(FStateDefinitions &statedef)
|
||||
void AActor::Finalize(FStateDefinitions &statedef)
|
||||
{
|
||||
AActor *defaults = (AActor*)Defaults;
|
||||
AActor *defaults = this;
|
||||
|
||||
try
|
||||
{
|
||||
statedef.FinishStates(this, defaults);
|
||||
statedef.FinishStates(GetClass(), defaults);
|
||||
}
|
||||
catch (CRecoverableError &)
|
||||
{
|
||||
statedef.MakeStateDefines(NULL);
|
||||
throw;
|
||||
}
|
||||
statedef.InstallStates(this, defaults);
|
||||
statedef.InstallStates(GetClass(), defaults);
|
||||
statedef.MakeStateDefines(NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,6 @@ public:
|
|||
size_t PropagateMark();
|
||||
bool SetReplacement(FName replaceName);
|
||||
void SetDropItems(DDropItem *drops);
|
||||
virtual void Finalize(FStateDefinitions &statedef);
|
||||
|
||||
FState *FindState(int numnames, FName *names, bool exact=false) const;
|
||||
FState *FindStateByString(const char *name, bool exact=false);
|
||||
|
|
|
@ -83,26 +83,9 @@ class FileReader;
|
|||
|
||||
/* Global Definitions */
|
||||
|
||||
#define MLVERSION 0x0175
|
||||
#define MLVERSIONSTR "1.75"
|
||||
extern char MLversion[];
|
||||
extern char MLcopyright[];
|
||||
|
||||
#define CHANNELS 16 // total channels 0..CHANNELS-1
|
||||
#define PERCUSSION 15 // percussion channel
|
||||
|
||||
/* MUS file header structure */
|
||||
struct MUSheader {
|
||||
char ID[4]; // identifier "MUS" 0x1A
|
||||
WORD scoreLen; // score length
|
||||
WORD scoreStart; // score start
|
||||
WORD channels; // primary channels
|
||||
WORD sec_channels; // secondary channels (??)
|
||||
WORD instrCnt; // used instrument count
|
||||
WORD dummy;
|
||||
// WORD instruments[...]; // table of used instruments
|
||||
};
|
||||
|
||||
/* OPL2 instrument */
|
||||
struct OPL2instrument {
|
||||
/*00*/ BYTE trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */
|
||||
|
@ -131,7 +114,6 @@ struct OP2instrEntry {
|
|||
};
|
||||
|
||||
#define FL_FIXED_PITCH 0x0001 // note has fixed pitch (see below)
|
||||
#define FL_UNKNOWN 0x0002 // ??? (used in instrument #65 only)
|
||||
#define FL_DOUBLE_VOICE 0x0004 // use two voices instead of one
|
||||
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ double GetAlpha(int type, double alpha)
|
|||
switch (type)
|
||||
{
|
||||
case STYLEALPHA_Zero: return 0;
|
||||
case STYLEALPHA_One: return OPAQUE;
|
||||
case STYLEALPHA_One: return 1.;
|
||||
case STYLEALPHA_Src: return alpha;
|
||||
case STYLEALPHA_InvSrc: return 1. - alpha;
|
||||
default: return 0;
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
enum
|
||||
{
|
||||
OPAQUE = 65536,
|
||||
TRANSLUC25 = (OPAQUE / 4),
|
||||
TRANSLUC33 = (OPAQUE / 3),
|
||||
TRANSLUC66 = ((OPAQUE * 2) / 3),
|
||||
TRANSLUC75 = ((OPAQUE * 3) / 4),
|
||||
};
|
||||
|
||||
// Legacy render styles
|
||||
|
|
|
@ -542,7 +542,7 @@ ExpEmit FxConstant::Emit(VMFunctionBuilder *build)
|
|||
{
|
||||
tag = ATAG_STATE;
|
||||
}
|
||||
else if (value.Type->GetLoadOp() == OP_LO)
|
||||
else if (value.Type->GetLoadOp() != OP_LP)
|
||||
{
|
||||
tag = ATAG_OBJECT;
|
||||
}
|
||||
|
@ -6356,7 +6356,7 @@ ExpEmit FxClassDefaults::Emit(VMFunctionBuilder *build)
|
|||
ob.Free(build);
|
||||
ExpEmit meta(build, REGT_POINTER);
|
||||
build->Emit(OP_META, meta.RegNum, ob.RegNum);
|
||||
build->Emit(OP_LO, meta.RegNum, meta.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults)));
|
||||
build->Emit(OP_LOS, meta.RegNum, meta.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults)));
|
||||
return meta;
|
||||
|
||||
}
|
||||
|
@ -8874,7 +8874,7 @@ ExpEmit FxGetParentClass::Emit(VMFunctionBuilder *build)
|
|||
op.Free(build);
|
||||
}
|
||||
ExpEmit to(build, REGT_POINTER);
|
||||
build->Emit(OP_LO, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, ParentClass)));
|
||||
build->Emit(OP_LOS, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, ParentClass)));
|
||||
return to;
|
||||
}
|
||||
|
||||
|
@ -8946,7 +8946,7 @@ ExpEmit FxGetDefaultByType::Emit(VMFunctionBuilder *build)
|
|||
build->Emit(OP_LKP, to.RegNum, op.RegNum);
|
||||
op = to;
|
||||
}
|
||||
build->Emit(OP_LO, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults)));
|
||||
build->Emit(OP_LOS, to.RegNum, op.RegNum, build->GetConstantInt(myoffsetof(PClass, Defaults)));
|
||||
return to;
|
||||
}
|
||||
|
||||
|
@ -10683,8 +10683,7 @@ ExpEmit FxLocalVariableDeclaration::Emit(VMFunctionBuilder *build)
|
|||
|
||||
case REGT_POINTER:
|
||||
{
|
||||
bool isobject = ValueType->IsKindOf(RUNTIME_CLASS(PClassPointer)) || (ValueType->IsKindOf(RUNTIME_CLASS(PPointer)) && static_cast<PPointer*>(ValueType)->PointedType->IsKindOf(RUNTIME_CLASS(PClass)));
|
||||
build->Emit(OP_LKP, RegNum, build->GetConstantAddress(constval->GetValue().GetPointer(), isobject ? ATAG_OBJECT : ATAG_GENERIC));
|
||||
build->Emit(OP_LKP, RegNum, build->GetConstantAddress(constval->GetValue().GetPointer(), ValueType->GetLoadOp() != OP_LP ? ATAG_OBJECT : ATAG_GENERIC));
|
||||
break;
|
||||
}
|
||||
case REGT_STRING:
|
||||
|
@ -10824,7 +10823,7 @@ ExpEmit FxStaticArray::Emit(VMFunctionBuilder *build)
|
|||
{
|
||||
TArray<void*> cvalues;
|
||||
for (auto v : values) cvalues.Push(static_cast<FxConstant *>(v)->GetValue().GetPointer());
|
||||
StackOffset = build->AllocConstantsAddress(cvalues.Size(), &cvalues[0], ElementType->GetLoadOp() == OP_LO ? ATAG_OBJECT : ATAG_GENERIC);
|
||||
StackOffset = build->AllocConstantsAddress(cvalues.Size(), &cvalues[0], ElementType->GetLoadOp() != OP_LP ? ATAG_OBJECT : ATAG_GENERIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1155,7 +1155,7 @@ static void ParseActor(FScanner &sc, PNamespace *ns)
|
|||
}
|
||||
try
|
||||
{
|
||||
info->Finalize(bag.statedef);
|
||||
GetDefaultByType(info)->Finalize(bag.statedef);
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
|
|
|
@ -1141,19 +1141,8 @@ DEFINE_ACTION_FUNCTION(FStringStruct, AppendFormat)
|
|||
DEFINE_ACTION_FUNCTION(FStringStruct, Mid)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
PARAM_INT(ipos);
|
||||
PARAM_INT(ilen);
|
||||
// validate. we don't want to crash if someone passes negative values.
|
||||
// with size_t it's handled naturally I think, as it's unsigned, but not in ZScript.
|
||||
if (ipos < 0) ipos = 0;
|
||||
if (ilen < 0) ilen = 0;
|
||||
// convert to size_t to prevent overflows here
|
||||
size_t slen = self->Len();
|
||||
size_t pos = (size_t)ipos;
|
||||
size_t len = (size_t)ilen;
|
||||
if (pos > slen) pos = slen - 1;
|
||||
if (pos + len > slen)
|
||||
len = slen - pos;
|
||||
PARAM_UINT(pos);
|
||||
PARAM_UINT(len);
|
||||
FString s = self->Mid(pos, len);
|
||||
ACTION_RETURN_STRING(s);
|
||||
}
|
||||
|
@ -1161,7 +1150,7 @@ DEFINE_ACTION_FUNCTION(FStringStruct, Mid)
|
|||
DEFINE_ACTION_FUNCTION(FStringStruct, Len)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
ACTION_RETURN_INT(self->Len());
|
||||
ACTION_RETURN_INT((int)self->Len());
|
||||
}
|
||||
|
||||
// CharAt and CharCodeAt is how JS does it, and JS is similar here in that it doesn't have char type as int.
|
||||
|
@ -1169,7 +1158,7 @@ DEFINE_ACTION_FUNCTION(FStringStruct, CharAt)
|
|||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
PARAM_INT(pos);
|
||||
int slen = self->Len();
|
||||
int slen = (int)self->Len();
|
||||
if (pos < 0 || pos >= slen)
|
||||
ACTION_RETURN_STRING("");
|
||||
ACTION_RETURN_STRING(FString((*self)[pos]));
|
||||
|
@ -1179,7 +1168,7 @@ DEFINE_ACTION_FUNCTION(FStringStruct, CharCodeAt)
|
|||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
PARAM_INT(pos);
|
||||
int slen = self->Len();
|
||||
int slen = (int)self->Len();
|
||||
if (pos < 0 || pos >= slen)
|
||||
ACTION_RETURN_INT(0);
|
||||
ACTION_RETURN_INT((*self)[pos]);
|
||||
|
|
|
@ -560,7 +560,7 @@ DEFINE_PROPERTY(skip_super, 0, Actor)
|
|||
return;
|
||||
}
|
||||
|
||||
memcpy ((void *)defaults, (void *)GetDefault<AActor>(), sizeof(AActor));
|
||||
*defaults = *GetDefault<AActor>();
|
||||
ResetBaggage (&bag, RUNTIME_CLASS(AActor));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -997,6 +997,7 @@ void NullParam(const char *varname);
|
|||
|
||||
// For required parameters.
|
||||
#define PARAM_INT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); int x = param[p].i;
|
||||
#define PARAM_UINT_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); unsigned x = param[p].i;
|
||||
#define PARAM_BOOL_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); bool x = !!param[p].i;
|
||||
#define PARAM_NAME_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); FName x = ENamedName(param[p].i);
|
||||
#define PARAM_SOUND_AT(p,x) assert((p) < numparam); assert(param[p].Type == REGT_INT); FSoundID x = param[p].i;
|
||||
|
@ -1040,6 +1041,7 @@ void NullParam(const char *varname);
|
|||
#define PARAM_PROLOGUE int paramnum = -1;
|
||||
|
||||
#define PARAM_INT(x) ++paramnum; PARAM_INT_AT(paramnum,x)
|
||||
#define PARAM_UINT(x) ++paramnum; PARAM_UINT_AT(paramnum,x)
|
||||
#define PARAM_BOOL(x) ++paramnum; PARAM_BOOL_AT(paramnum,x)
|
||||
#define PARAM_NAME(x) ++paramnum; PARAM_NAME_AT(paramnum,x)
|
||||
#define PARAM_SOUND(x) ++paramnum; PARAM_SOUND_AT(paramnum,x)
|
||||
|
|
|
@ -347,6 +347,17 @@ begin:
|
|||
GETADDR(PA,RC,X_WRITE_NIL);
|
||||
*(void **)ptr = reg.a[B];
|
||||
NEXTOP;
|
||||
OP(SO):
|
||||
ASSERTA(a); ASSERTA(B); ASSERTKD(C);
|
||||
GETADDR(PA,KC,X_WRITE_NIL);
|
||||
*(void **)ptr = reg.a[B];
|
||||
GC::WriteBarrier((DObject*)*(void **)ptr);
|
||||
NEXTOP;
|
||||
OP(SO_R):
|
||||
ASSERTA(a); ASSERTA(B); ASSERTD(C);
|
||||
GETADDR(PA,RC,X_WRITE_NIL);
|
||||
GC::WriteBarrier((DObject*)*(void **)ptr);
|
||||
NEXTOP;
|
||||
OP(SV2):
|
||||
ASSERTA(a); ASSERTF(B+1); ASSERTKD(C);
|
||||
GETADDR(PA,KC,X_WRITE_NIL);
|
||||
|
|
|
@ -70,6 +70,8 @@ xx(SS, ss, RPRSKI, SS_R, 4, REGT_INT), // store string
|
|||
xx(SS_R, ss, RPRSRI, NOP, 0, 0),
|
||||
xx(SP, sp, RPRPKI, SP_R, 4, REGT_INT), // store pointer
|
||||
xx(SP_R, sp, RPRPRI, NOP, 0, 0),
|
||||
xx(SO, sp, RPRPKI, SO_R, 4, REGT_INT), // store object pointer with write barrier (only needed for non thinkers and non types
|
||||
xx(SO_R, sp, RPRPRI, NOP, 0, 0),
|
||||
xx(SV2, sv2, RPRVKI, SV2_R, 4, REGT_INT), // store vector2
|
||||
xx(SV2_R, sv2, RPRVRI, NOP, 0, 0),
|
||||
xx(SV3, sv3, RPRVKI, SV3_R, 4, REGT_INT), // store vector3
|
||||
|
|
|
@ -2447,19 +2447,6 @@ void ZCCCompiler::CompileStates()
|
|||
continue;
|
||||
}
|
||||
|
||||
// Same here, hack in the DVMObject as they weren't in the list originally
|
||||
// TODO: process them in a non hackish way obviously
|
||||
if (c->Type()->bRuntimeClass == true && c->Type()->ParentClass->bRuntimeClass == false)
|
||||
{
|
||||
auto vmtype = static_cast<PClassActor *>(c->Type()->ParentClass);
|
||||
if (vmtype->StateList == nullptr)
|
||||
{
|
||||
FStateDefinitions vmstates;
|
||||
vmstates.MakeStateDefines(dyn_cast<PClassActor>(vmtype->ParentClass));
|
||||
vmtype->Finalize(vmstates);
|
||||
}
|
||||
}
|
||||
|
||||
FString statename; // The state builder wants the label as one complete string, not separated into tokens.
|
||||
FStateDefinitions statedef;
|
||||
statedef.MakeStateDefines(dyn_cast<PClassActor>(c->Type()->ParentClass));
|
||||
|
@ -2658,7 +2645,7 @@ void ZCCCompiler::CompileStates()
|
|||
}
|
||||
try
|
||||
{
|
||||
static_cast<PClassActor *>(c->Type())->Finalize(statedef);
|
||||
GetDefaultByType(c->Type())->Finalize(statedef);
|
||||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
|
|
|
@ -387,7 +387,7 @@ namespace swrenderer
|
|||
if (style.BlendOp == STYLEOP_Shadow)
|
||||
{
|
||||
style = LegacyRenderStyles[STYLE_TranslucentStencil];
|
||||
alpha = TRANSLUC33;
|
||||
alpha = OPAQUE / 3;
|
||||
color = 0;
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ namespace swrenderer
|
|||
}
|
||||
else if (style.Flags & STYLEF_Alpha1)
|
||||
{
|
||||
alpha = FRACUNIT;
|
||||
alpha = OPAQUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -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