mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-26 13:51:09 +00:00
- fixed generic class type properties to handle "" and "none" as 'no class'.
This commit is contained in:
parent
2c789a2d75
commit
ac95cba848
4 changed files with 36 additions and 61 deletions
|
@ -883,8 +883,14 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul
|
||||||
else if (f->Type->IsKindOf(RUNTIME_CLASS(PClassPointer)))
|
else if (f->Type->IsKindOf(RUNTIME_CLASS(PClassPointer)))
|
||||||
{
|
{
|
||||||
sc.MustGetString();
|
sc.MustGetString();
|
||||||
|
|
||||||
|
if (*sc.String == 0 || !stricmp(sc.String, "none"))
|
||||||
|
{
|
||||||
|
*(PClass**)addr = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto cls = PClass::FindClass(sc.String);
|
auto cls = PClass::FindClass(sc.String);
|
||||||
*(PClass**)addr = cls;
|
|
||||||
if (cls == nullptr)
|
if (cls == nullptr)
|
||||||
{
|
{
|
||||||
cls = static_cast<PClassPointer*>(f->Type)->ClassRestriction->FindClassTentative(sc.String);
|
cls = static_cast<PClassPointer*>(f->Type)->ClassRestriction->FindClassTentative(sc.String);
|
||||||
|
@ -896,6 +902,7 @@ static void DispatchScriptProperty(FScanner &sc, PProperty *prop, AActor *defaul
|
||||||
}
|
}
|
||||||
*(PClass**)addr = cls;
|
*(PClass**)addr = cls;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sc.ScriptMessage("unhandled property type %s", f->Type->DescriptiveName());
|
sc.ScriptMessage("unhandled property type %s", f->Type->DescriptiveName());
|
||||||
|
|
|
@ -96,18 +96,6 @@ static PClassActor *FindClassTentative(const char *name, PClass *ancestor, bool
|
||||||
}
|
}
|
||||||
return static_cast<PClassActor *>(cls);
|
return static_cast<PClassActor *>(cls);
|
||||||
}
|
}
|
||||||
static AInventory::MetaClass *FindClassTentativeAmmo(const char *name, bool optional = false)
|
|
||||||
{
|
|
||||||
return static_cast<AInventory::MetaClass *>(FindClassTentative(name, PClass::FindActor(NAME_Ammo), optional));
|
|
||||||
}
|
|
||||||
static AWeapon::MetaClass *FindClassTentativeWeapon(const char *name, bool optional = false)
|
|
||||||
{
|
|
||||||
return static_cast<AWeapon::MetaClass *>(FindClassTentative(name, RUNTIME_CLASS(AWeapon), optional));
|
|
||||||
}
|
|
||||||
static APlayerPawn::MetaClass *FindClassTentativePlayerPawn(const char *name, bool optional = false)
|
|
||||||
{
|
|
||||||
return static_cast<APlayerPawn::MetaClass *>(FindClassTentative(name, RUNTIME_CLASS(APlayerPawn), optional));
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -1065,7 +1053,7 @@ DEFINE_PROPERTY(visibletoplayerclass, Ssssssssssssssssssss, Actor)
|
||||||
{
|
{
|
||||||
PROP_STRING_PARM(n, i);
|
PROP_STRING_PARM(n, i);
|
||||||
if (*n != 0)
|
if (*n != 0)
|
||||||
info->VisibleToPlayerClass.Push(FindClassTentativePlayerPawn(n));
|
info->VisibleToPlayerClass.Push(FindClassTentative(n, RUNTIME_CLASS(APlayerPawn)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,7 +1095,7 @@ DEFINE_CLASS_PROPERTY(restrictedto, Ssssssssssssssssssss, Inventory)
|
||||||
{
|
{
|
||||||
PROP_STRING_PARM(n, i);
|
PROP_STRING_PARM(n, i);
|
||||||
if (*n != 0)
|
if (*n != 0)
|
||||||
static_cast<PClassActor*>(info)->RestrictedToPlayerClass.Push(FindClassTentativePlayerPawn(n));
|
static_cast<PClassActor*>(info)->RestrictedToPlayerClass.Push(FindClassTentative(n, RUNTIME_CLASS(APlayerPawn)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1109,7 @@ DEFINE_CLASS_PROPERTY(forbiddento, Ssssssssssssssssssss, Inventory)
|
||||||
{
|
{
|
||||||
PROP_STRING_PARM(n, i);
|
PROP_STRING_PARM(n, i);
|
||||||
if (*n != 0)
|
if (*n != 0)
|
||||||
static_cast<PClassActor*>(info)->ForbiddenToPlayerClass.Push(FindClassTentativePlayerPawn(n));
|
static_cast<PClassActor*>(info)->ForbiddenToPlayerClass.Push(FindClassTentative(n, RUNTIME_CLASS(APlayerPawn)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,36 +1172,6 @@ DEFINE_CLASS_PROPERTY(pickupannouncerentry, S, Inventory)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
DEFINE_CLASS_PROPERTY(ammotype, S, Weapon)
|
|
||||||
{
|
|
||||||
PROP_STRING_PARM(str, 0);
|
|
||||||
if (!stricmp(str, "none") || *str == 0) defaults->AmmoType1 = NULL;
|
|
||||||
else defaults->AmmoType1 = FindClassTentativeAmmo(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
DEFINE_CLASS_PROPERTY(ammotype1, S, Weapon)
|
|
||||||
{
|
|
||||||
PROP_STRING_PARM(str, 0);
|
|
||||||
if (!stricmp(str, "none") || *str == 0) defaults->AmmoType1 = NULL;
|
|
||||||
else defaults->AmmoType1 = FindClassTentativeAmmo(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
DEFINE_CLASS_PROPERTY(ammotype2, S, Weapon)
|
|
||||||
{
|
|
||||||
PROP_STRING_PARM(str, 0);
|
|
||||||
if (!stricmp(str, "none") || *str == 0) defaults->AmmoType1 = NULL;
|
|
||||||
else defaults->AmmoType2 = FindClassTentativeAmmo(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1779,7 +1737,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, viewbob, F, PlayerPawn)
|
||||||
DEFINE_SCRIPTED_PROPERTY(playerclass, S, MorphProjectile)
|
DEFINE_SCRIPTED_PROPERTY(playerclass, S, MorphProjectile)
|
||||||
{
|
{
|
||||||
PROP_STRING_PARM(str, 0);
|
PROP_STRING_PARM(str, 0);
|
||||||
defaults->PointerVar<PClassActor>(NAME_PlayerClass) = FindClassTentativePlayerPawn(str, bag.fromDecorate);
|
defaults->PointerVar<PClassActor>(NAME_PlayerClass) = FindClassTentative(str, RUNTIME_CLASS(APlayerPawn), bag.fromDecorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1833,7 +1791,7 @@ DEFINE_SCRIPTED_PROPERTY(unmorphflash, S, MorphProjectile)
|
||||||
DEFINE_SCRIPTED_PROPERTY(playerclass, S, PowerMorph)
|
DEFINE_SCRIPTED_PROPERTY(playerclass, S, PowerMorph)
|
||||||
{
|
{
|
||||||
PROP_STRING_PARM(str, 0);
|
PROP_STRING_PARM(str, 0);
|
||||||
defaults->PointerVar<PClassActor>(NAME_PlayerClass) = FindClassTentativePlayerPawn(str, bag.fromDecorate);
|
defaults->PointerVar<PClassActor>(NAME_PlayerClass) = FindClassTentative(str, RUNTIME_CLASS(APlayerPawn), bag.fromDecorate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -2018,6 +2018,12 @@ void ZCCCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *prop
|
||||||
else if (f->Type->IsKindOf(RUNTIME_CLASS(PClassPointer)))
|
else if (f->Type->IsKindOf(RUNTIME_CLASS(PClassPointer)))
|
||||||
{
|
{
|
||||||
auto clsname = GetStringConst(ex, ctx);
|
auto clsname = GetStringConst(ex, ctx);
|
||||||
|
if (*clsname == 0 || !stricmp(clsname, "none"))
|
||||||
|
{
|
||||||
|
*(PClass**)addr = nullptr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto cls = PClass::FindClass(clsname);
|
auto cls = PClass::FindClass(clsname);
|
||||||
if (cls == nullptr)
|
if (cls == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -2029,6 +2035,7 @@ void ZCCCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *prop
|
||||||
}
|
}
|
||||||
*(PClass**)addr = cls;
|
*(PClass**)addr = cls;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Error(property, "unhandled property type %s", f->Type->DescriptiveName());
|
Error(property, "unhandled property type %s", f->Type->DescriptiveName());
|
||||||
|
|
|
@ -43,6 +43,9 @@ class Weapon : StateProvider native
|
||||||
property AmmoUse: AmmoUse1;
|
property AmmoUse: AmmoUse1;
|
||||||
property AmmoUse1: AmmoUse1;
|
property AmmoUse1: AmmoUse1;
|
||||||
property AmmoUse2: AmmoUse2;
|
property AmmoUse2: AmmoUse2;
|
||||||
|
property AmmoType: AmmoType1;
|
||||||
|
property AmmoType1: AmmoType1;
|
||||||
|
property AmmoType2: AmmoType2;
|
||||||
property Kickback: Kickback;
|
property Kickback: Kickback;
|
||||||
property ReadySound: ReadySound;
|
property ReadySound: ReadySound;
|
||||||
property SelectionOrder: SelectionOrder;
|
property SelectionOrder: SelectionOrder;
|
||||||
|
|
Loading…
Reference in a new issue