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.

Relationships

Activities

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[] =
        {	
            "D4DCash",
            "AssaultRifleMod1", //1
            "AssaultRifleMod2",
            "ChaingunMod1",
            "ChaingunMod2",
            "GaussCannonMod1",
            "GaussCannonMod2",
            "PlasmaRifleMod1",
            "PlasmaRifleMod2",
            "RocketLauncherMod1",
            "RocketLauncherMod2",
            "ShotgunMod1",
            "ShotgunMod2",
            "SSGUpgrade1",
            "SSGUpgrade2",
            "SSGUpgrade3",
            "SSGUpgrade4",
            "PistolUpgradeAutomatic",
            "PistolUpgradeAltDamage",
            "PistolUpgradeAltCharge",
            "PistolUpgradeDamage",
            "PistolUpgradeLance",
            "BFGUpgrade1",
            "BFGUpgrade2",
            "BFGUpgrade3",
            "BFGUpgrade4", // 25
            "StaticUpgrade1",
            "StaticUpgrade2",
            "StaticUpgrade3",
            "StaticUpgrade4",
            "SovietActive",
            "SovietToken",
            "LGUpgradeAmmo",
            "LGUpgradeRange",
            "LGUpgradeDamage",
            "LGUpgradeAltFire",
            "VortexUpgradeDamage",
            "VortexUpgradeAmmo",
            "VortexUpgradeAltSpeed",
            "VortexUpgradeAltPierce",
            "RepeaterUpgradePiercing",
            "RepeaterUpgradeDamage",
            "RepeaterUpgradeAltDamage",
            "RepeaterUpgradeAltAmmo",
            "D4CarrionCannon",
            "D4CarrionToken",
            "CarrionLevel",
            "CarrionUpgradePickup",
            "CarrionUpgradeAmmo",
            "CarrionUpgradeStun",
            "CarrionUpgradeTime",
            "DollUses",
            "FragGrenadePickup",
            "HoloGrenadePickup",
            "SyphonGrenadePickup",
            "FragGrenadeSelected",
            "MarineHoloSelected",
            "SyphonGrenadeSelected",
            "D4Stamina",
            "ProtectionBonus1",
            "ProtectionBonus2",
            "ProtectionBonus3",
            "D4ArmorCapRaiser",
            "D4AirControl",
            "D4HigherJump",
            "D4MultiJump",
            "D4CrateUpgrade",
            "CashPercentBonus",
            "D4MegasphereDamageReducer",
            "D4MegachargeUpgrade1",
            "D4MegachargeUpgrade2",
            "D4DoomDollUpgrade1",
            "D4DoomDollUpgrade2",
            "D4RegenUpgrade1",
            "D4RegenUpgrade2",
            "D4RegenUpgrade3",
            "D4RegenUpgrade4" // 77
        };
        ItemList.Clear();
        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