Epic release new beta almost every month. This part of the documentation says nothing about the relation of the enum type variables to dependson specifier. It is also possible the documentation is not actual and this is a new or not documented feature.
Also:
DEPENDSON(CLASSNAME[,CLASSNAME,...]) The DependsOn specifier is used to determine the order of compiling when classes have dependencies which require certain classes to be compiled before others within the same package. The class, or classes, listed inside the parentheses will be compiled before the class the specifier is within. This can be useful when the current class needs to access a struct or enumeration that is declared in another class. If the current class is compiled first, the compiler does not know the struct or enumeration exists and will throw an error. By adding the DependsOn specifier, the other class is ensured to be compiled first and compiler will know about the struct or enumeration.
PS. I moved the enum declaration in a class which is compiled before the current and on which current class does not depend on and it seems that once the compiler goes through a class, it knows about the structs and enums and classes that use these variables are compiled fine.
Announcement
Collapse
No announcement yet.
UDK UC compiler switching on enum broken
Collapse
X
-
ambershee repliedThere is also another workaround if you run into such an issue; enumerators are effectively integers in UnrealScript, so you can compare your parameter against int values.
Leave a comment:
-
nullsoldier repliedI consider your code a bug. The documentation for Enum clearly specifies that unqualified Enum values are only possible through the class hierarchy where it's defined. When using it in a separate class hierarchy, such as RPG_BaseAttr_CTRL, you must qualify your enum tag by using the name of the enum like the following, "case ETest.Value1"
UnrealScript only recognizes unqualified enum tags (like FRUIT_Apple) in classes where the enumeration was defined, and in its subclasses. If you need to refer to an enumeration tag defined somewhere else in the class hierarchy, you must "qualify it":
Leave a comment:
-
AdAstra repliedThe new test rig:
PHP Code:// used existing classes from my game - UDK 2011 November beta
class RPGSaveGame extends Object;
enum ETest
{
Value1,
Value2,
Value3
};
var ETest TestValue;
PHP Code:class RPG_BaseAttr_CTRL extends BasePlayerController
dependson(RPGSaveGame);
function ShowSuccess(RPGSaveGame inSG)
{
switch (inSG.TestValue)
{
case Value1: // COMPILES FINE
break;
case Value2: // COMPILES FINE
break;
case Value3: // COMPILES FINE
break;
}
}
Leave a comment:
-
nullsoldier repliedThe reason your test works, is because when you compile, the ETest symbol is found thanks to it being in the same inheritance tree. In my example, the Enum was in another class not located in the used inheritance tree and so the symbol is not discovered correctly.
My class without the Enum is declared as depending on the class with the enum so it should discover the enum's symbol correctly as per the dependency tree.
Leave a comment:
-
AdAstra repliedI did the test and it compiled.
The test rig:
PHP Code:// used existing classes from my game - UDK 2011 November beta
class BasePlayerController extends SimplePC;
enum ETest
{
Value1,
Value2,
Value3
};
var ETest TestValue;
PHP Code:class NextPlayerController extends BasePlayerController;
function ShowFailure(BasePlayerController inCTRL)
{
switch (inCTRL.TestValue)
{
case ETest.Value1: // COMPILES FINE
break;
}
}
Leave a comment:
-
nullsoldier started a topic UDK UC compiler switching on enum brokenUDK UC compiler switching on enum broken
The compiler is throwing errors when attempting to switch on Enum values. Of course, this isn't the first problem I've seen with Switch statements today; switching on an Array of string is also broken. The following code is a reproducible test case showing how switch's fail to correctly compile when switching on an enum.
It's important to note that this works if ETestEnum is in the same class that you're switching in. Then it compiles fine. This is wrong considering my test case should work because I'm telling the compiler the class without the enum, depends on the class with the enum.
Code:class TestClassWithEnum extends Object; enum ETest { Value1, Value2, Value3 }; var ETest TestValue;
Code:class TestClassNoEnum extends Object DependsOn (TestClassWithEnum); function ShowFailure(TestClassWithEnum classWithEnum) { switch (classWithEnum.TestValue) { case ETest.Value1: // CAUSES COMPILER ERROR break; } }
Code:Error 3 - Bad or missing expression for token: ETest, in 'Case' - TestClassNoEnum.uc
Tags: None
Leave a comment: