[Added] A way to check if a class is abstract.

Moderator: GZDoom Developers

A way to check if a class is abstract.

Postby Accensus » Wed Feb 17, 2021 10:18 am

Let's take Hideous Destructor for example. If I do the following:
Code: Select allExpand view
class SpecialAmmoBase : HDAmmo abstract
{ }

I risk a VM abort upon spawning the actor because the mod's backpack generates its contents by iterating AllActorClasses. SpecialAmmoBase passes all the checks but there's no way to avoid it without hardcoding exceptions for that class. Needless to say, that's a bad solution when addons are involved.

Checking if a class is abstract would let the backpack generation code just skip that class and not try to spawn it.
User avatar
Accensus
Vector, locked in.
 
Joined: 11 Feb 2016
Location: Somalia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: A way to check if a class is abstract.

Postby Player701 » Thu Feb 18, 2021 12:16 am

Attempting to spawn an abstract class will not trigger a VM abort; instead, a warning message will be logged to the console. However, I agree that it would be useful to have a way to check if a class is abstract. I imagine it'd work like GetClassName, e.g.

Code: Select allExpand view
class<Actor> cls = 'ZombieMan';
bool isAbstract = cls.IsAbstractClass();

upd: Since this check wouldn't make sense outside of a class pointer context anyway, let's call it just IsAbstract. PR here.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: A way to check if a class is abstract.

Postby Accensus » Thu Feb 18, 2021 6:13 am

I appreciate the PR. I see it has been merged so this can be closed now. Thank you.
User avatar
Accensus
Vector, locked in.
 
Joined: 11 Feb 2016
Location: Somalia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests