View Issue Details

IDProjectCategoryView StatusLast Update
0000404Gameplay + OpenGL[All Projects] Featurepublic2017-03-14 18:49
ReporterMajor Cooke 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status resolvedResolutionfixed 
Summary0000404: Support for static const arrays in structs
Description...or something. Seriously, things are so warped right now with constants:

You can do constant regulars inside a class scope, but you can't do it in (actor) (anonymous) functions.
You can do static constant arrays inside (actor) (anonymous) functions, but you can't do those in class scopes.
TagsNo tags attached.



Major Cooke

Major Cooke

2017-03-08 16:31

reporter   ~0000915

Also I mainly bring this up because otherwise, we have to resort to hacks like this:

Struct ItemsToSave
    Array<String> ItemList;
    void Init()
        static const String SavedItemsStr[] =
            "AssaultRifleMod1", //1
            "BFGUpgrade4", // 25
            "D4RegenUpgrade4" // 77
        for (int i = 0; i < SavedItemsStr.Size(); i++)
            ItemList.Push (SavedItemsStr[i]);
Graf Zahl

Graf Zahl

2017-03-14 14:00

administrator   ~0000997

In case you wonder: I do not manage to get the syntax through Randi's wonderfully messed up grammar. Adding the feature itself would be trivial, but if doing so it should use the same syntax inside and outside functions, but the parser will not allow this outside of functions because some rules are so broad that they create endless conflicts that forced me to compromise the syntax before.
Major Cooke

Major Cooke

2017-03-14 14:16

reporter   ~0000998

Understandable. Well, for now, my 'solution' above can suffice as I don't see anything breaking from that anytime soon.
Graf Zahl

Graf Zahl

2017-03-14 17:53

administrator   ~0001001

Got it solved. The trick was to fake a new token for 'static const' because the separate one would never work.
Major Cooke

Major Cooke

2017-03-14 17:56

reporter   ~0001003

So do they all need staticconst now for the things defined in the original statement?
Graf Zahl

Graf Zahl

2017-03-14 18:49

administrator   ~0001004

No, I hacked that into the parser. If it encounters a 'static' token, it checks the next one and if that is 'const', they get merged into a 'staticconst' token (which you cannot specify directly in the source.)

Issue History

Date Modified Username Field Change
2017-03-08 15:59 Major Cooke New Issue
2017-03-08 16:31 Major Cooke Note Added: 0000915
2017-03-14 14:00 Graf Zahl Note Added: 0000997
2017-03-14 14:16 Major Cooke Note Added: 0000998
2017-03-14 17:53 Graf Zahl Note Added: 0001001
2017-03-14 17:54 Graf Zahl Status new => resolved
2017-03-14 17:54 Graf Zahl Resolution open => fixed
2017-03-14 17:56 Major Cooke Note Added: 0001003
2017-03-14 18:49 Graf Zahl Note Added: 0001004