Page 1 of 2

Check if an Actor is abstract

Posted: Thu Mar 25, 2021 10:05 pm
by Barbie
Is there a possibility to check if a given Actor string like "Class'UnrealShare.Skaarj'" describes an abstract class without spawing it? I want to realize something like

Code: Select all

var() class<actor> prototype;
...
if (IsAbstract(prototype))
	warn("cannot spawn an abstract Actor");

Re: Check if an Actor is abstract

Posted: Thu Mar 25, 2021 10:50 pm
by Buggie
Look like no any direct way determine this.

You can try instantiate object directly with key word new, but it is very Buggie bugged way.

Like that:
https://github.com/Slipyx/UT99/blob/f2e ... dow.uc#L60

Code: Select all

LooksAndFeels[i] = new LFClass;
If result None (or game/server crash :lol2: ) then you try do it on abstract class.

Also even if this work initially, then on garbage collection can be another crash...
Or in new UT version even if now all fine. :loool:

--- EDIT --

Partially solution - make list of all standard abstract classes and compare full Class with it.
Also need pray and cross fingers for any author will be not smart enough for use abstract classes or pass to your code. :lol2:

--- EDIT ---
Buuuuu!

Code: Select all

Botpack/Classes/Arena.uc:       abstract;
Botpack/Classes/Bot.uc: abstract;
Botpack/Classes/ChallengeVoicePack.uc:  abstract;
Botpack/Classes/FemaleBotPlus.uc:       abstract;
Botpack/Classes/HumanBotPlus.uc:        abstract;
Botpack/Classes/Ladder.uc:      abstract
Botpack/Classes/MaleBotPlus.uc: abstract;
Botpack/Classes/StationaryPawn.uc:      abstract;
Botpack/Classes/TFemaleBody.uc: abstract;
Botpack/Classes/TMaleBody.uc:   abstract;
Botpack/Classes/TournamentAmmo.uc:      abstract;
Botpack/Classes/TournamentConsole.uc:   abstract;
Botpack/Classes/TournamentFemale.uc:    abstract;
Botpack/Classes/TournamentHealth.uc:    abstract;
Botpack/Classes/TournamentMale.uc:      abstract;
Botpack/Classes/TournamentPlayer.uc:    abstract;
Botpack/Classes/TournamentWeapon.uc:    abstract;
Botpack/Classes/UTHumanCarcass.uc:      abstract;
Botpack/Classes/UT_Decoration.uc:       abstract;
Botpack/Classes/VoiceFemale.uc: abstract;
Botpack/Classes/VoiceMale.uc:   abstract;
Core/Classes/Commandlet.uc:     abstract
Editor/Classes/BrushBuilder.uc: abstract
Engine/Classes/Actor.uc:        abstract
Engine/Classes/Ammo.uc: abstract
Engine/Classes/DamageType.uc:   abstract;
Engine/Classes/Decoration.uc:   abstract
Engine/Classes/HUD.uc:  abstract
Engine/Classes/Info.uc: abstract
Engine/Classes/Inventory.uc:    abstract
Engine/Classes/Keypoint.uc:     abstract
Engine/Classes/MessagingSpectator.uc:   abstract;
Engine/Classes/Pawn.uc: abstract
Engine/Classes/Pickup.uc:       abstract
Engine/Classes/Projectile.uc:   abstract
Engine/Classes/ReplicationInfo.uc:      abstract
Engine/Classes/VoicePack.uc:    abstract;
Engine/Classes/Weapon.uc:       abstract
Fire/Classes/FractalTexture.uc: abstract;
Fire/Classes/WaterTexture.uc:   abstract;
MultiMesh/Classes/CustomBot.uc: abstract;
MultiMesh/Classes/customplayer.uc:      abstract;
Relics/Classes/Relic.uc:        abstract;
UBrowser/Classes/UBrowserServerListFactory.uc:  abstract;
UnrealI/Classes/Burned.uc:      abstract;
UnrealI/Classes/Corroded.uc:    abstract;
UnrealI/Classes/Decapitated.uc: abstract;
UnrealI/Classes/Drowned.uc:     abstract;
UnrealI/Classes/Fell.uc:        abstract;
UnrealI/Classes/UnrealDamageType.uc:    abstract;
UnrealShare/Classes/Bots.uc:    abstract;
UnrealShare/Classes/DeadMales.uc:       abstract;
UnrealShare/Classes/Female.uc:  abstract;
UnrealShare/Classes/FemaleBot.uc:       abstract;
UnrealShare/Classes/Human.uc:   abstract;
UnrealShare/Classes/HumanBot.uc:        abstract;
UnrealShare/Classes/HumanCarcass.uc:    abstract;
UnrealShare/Classes/Male.uc:    abstract;
UnrealShare/Classes/MaleBot.uc: abstract;
UnrealShare/Classes/ScriptedPawn.uc:    abstract;
UnrealShare/Classes/ShareSounds.uc:     abstract;
UnrealShare/Classes/Skaarj.uc:  abstract;
UnrealShare/Classes/UnrealIPlayer.uc:   abstract;
UTMenu/Classes/MeshBrowser.uc:  abstract;
UTMenu/Classes/UTLadder.uc:     abstract;
UTMenu/Classes/UTLadderStub.uc: abstract;

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 9:18 am
by sektor2111
Thanks for the list, Buggie. I think future checkers will go based on this list instead of attempting to spawn abstracts and checking them. The rest means private patching when a "mapping" surprise shows up from nowhere.

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 12:44 pm
by Barbie
Thanks for all replies.
That information must be somewhere inside an Actor because function Spawn() tells you that an Actor cannot be spawned because it it abstract.
Buggie wrote: Thu Mar 25, 2021 10:50 pmPartially solution - make list of all standard abstract classes
BTW: I suspect that the star in front of a class name in UnrealEd v469b indicate an abstract class?
Stars.jpg
Stars.jpg (20.3 KiB) Viewed 641 times

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 1:09 pm
by OjitroC
Barbie wrote: Sun Mar 28, 2021 12:44 pm BTW: I suspect that the star in front of a class name in UnrealEd v469b indicate an abstract class?
Yes, it does - it took me a while to work that out. First noticed that in the 227 Editor.

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 9:53 pm
by Feralidragon
As others said, there's no such function or flag that you can check, as far as I know.
The engine obviously knows what's abstract and what isn't, but that isn't exposed to UScript, even because that would essentially amount to a "reflection" feature, which UScript has none of.

Why exactly do you want to do this?
Considering that the spawn fails already with abstract classes, and it gets logged and the game doesn't crash, what's the problem you're trying to address here?

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 10:57 pm
by Barbie
Feralidragon wrote: Sun Mar 28, 2021 9:53 pmwhat's the problem you're trying to address here?
I have a Mutator that checks some things in a map and this topic is especially for Factories where the prototype is an abstract class.
No mapper does such? It happened even to myself when I thought "oh, let's spawn some Skaarj here"... :loool:

Re: Check if an Actor is abstract

Posted: Sun Mar 28, 2021 11:40 pm
by Feralidragon
Never mentioned that no mapper does it, especially having it done myself in my early days. :)
I was trying to understand what exactly you were trying to accomplish.

That makes sense, but unfortunately you can't do that directly.

In that case Buggie's suggestion of a list makes most sense, since that mistake is common for standard Actors, whereas for custom ones from custom packages not so much, so knowing if a custom actor is abstract may not be that important in relation to what you're trying to do.

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 5:30 am
by sektor2111
"MH Mapper" perhaps uses mainly stock things as long as compiling classes in plain MH it's impossible and advanced users know what they do. I was thinking at an array with these abstract classes and testing if prototype is abstract comparing class with said embedded hard-coded stock array - or flexible array for future needs.

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 11:21 am
by Buggie
Barbie, I just say more. Even if custom code use abstract class, you always can extends your exclude list, when face this issue.

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 2:58 pm
by Shadow
You could write a simple native function that reads the ClassFlags property of the class you want to check:

Code: Select all

if (CheckedClass->ClassFlags & CLASS_Abstract)
{
  // this is an abstract class
}

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 4:03 pm
by Buggie
Native code mean next:
1. Build .dll and .so file.
2. Mess with compilers and linked stuff.
3. Prey it is work when you update server, because native code not compatible for any new patch.

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 4:19 pm
by Shadow
Yes, kinda. Native code should work with 469a at least. 469b is unusable for c++/native coding tho.
Sry, but there's no other way to check, if a class is abstract beforehand, because UClass has no script (checking X UClass->ClassFlags)..

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 4:30 pm
by Buggie
Also if this code must run on client side you in big trouble, because client can be v436 and v469. How handle this - IDK.

Re: Check if an Actor is abstract

Posted: Mon Mar 29, 2021 4:50 pm
by Shadow
That shouldnt be much of a problem, because the core mechanics of 436 and 469 shouldnt differ on this level, at least concerning UClass behavior, but I'm not 100 % sure, there're still NO public headers for 469 out there.