Jump to content
Sign in to follow this  
Freghar

How exactly does overwriting work in Arma configs?

Recommended Posts

What exactly specifies when a class should be completely overwritten and when it should be changed?

Consider

class CfgVehicles {
    class B_Soldier_A_F {
        displayName = "some name";
    };
};
versus

class CfgVehicles {
    class B_Soldier_A_F {
        displayName = "some name";
        class GunFire {
            size = 4;
        };
    };
};
Why does the latter overwrite the class completely?

(And I know the "fix" by inheriting the originally inherited class, B_Soldier_F, I just don't get why the double standards.)

If it is due to me defining a subclass, why doesn't CfgVehicles get completely replaced when I define the B_Soldier_A_F subclass in it? It can't be Cfg* being special cases as the same works in many other subclasses, ie. in Cfg3DEN (class AttributeCategories).

Maybe it's because CfgVehicles doesn't inherit anything? If so, then why class EventHandlers gets overwritten for second_soldier, even though it itself doesn't inherit anything at any point?

class CfgVehicles {
    class B_Soldier_F;
    class first_soldier : B_Soldier_F {
        class EventHandlers {
            class one { init = "one"; }
        };
    };
    class second_soldier : first_soldier {
        class EventHandlers {
            class two { init = "two"; }
        };
    };
};
(Again, I know that the solution is to class EventHandlers : EventHandlers, but I don't know why as it seems inconsistent with how other classes are defined and work.)

I have a very wild guess of overwriting always being a thing when any inheritance in any parent class is in effect while at least one subclass being defined, but that seems like a very exotic definition.

Thanks.

Share this post


Link to post
Share on other sites

You have to make sure the addon containing the class you want to overwrite is loaded first(Use requiredAddons). This is how I rewrite default menus and such.

Share this post


Link to post
Share on other sites

You have to make sure the addon containing the class you want to overwrite is loaded first(Use requiredAddons). This is how I rewrite default menus and such.

I obviously use the correct order, otherwise the behavior wouldn't be 100% reproducible. I'm not looking for a particular answer to a particular problem, I'm trying to understand the syntactic and semantic nature of the configuration language, which (to me) doesn't feel very consistent regarding overwriting, hence the first post.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×