Page MenuHomeFeedback Tracker

Multiple Inheritance
Acknowledged, WishlistPublic

Description

It would be very useful to be able to define multiple inheritance in config.cpp

That would highly reduce the size of config files.

It would also make the maintenance of them easier.

It would also open the doors to lighter and better mods.

Details

Legacy ID
2579890551
Severity
None
Resolution
Open
Reproducibility
Always
Category
Feature Request
Additional Information

Simplified Example

CfgWeapons
{

class 556_Magazine
{
    magazines[] = {"30rnd_556x45_EPR","30rnd_556x45_SOST"};
};
class add_special_pointer
    class WeaponSlotsInfo
        class PointerSlot: PointerSlot
        {
            compatibleItems[] += {"special_pointer"};
        };
    };
};
class modB_weapon_m4a1: modA_weapon_m4a1,556_Magazine{};
class modB_weapon_m16a4: modA_weapon_m16a4,556_Magazine,add_special_pointer{};

};

In this example I would create a new class using the base class from another mod and a new class I created to overwrite the magazines used by those weapons and also a second new class used to add the ability to use a special pointer for the m16a4.

The current way to do that is to rewrite the magazine property and the pointer property in every new class.
Which would work but if we have the same 20 properties to change in every weapon then it becomes a bit clumsy and complicated to maintain.

Isn't it the base of programming to never write the same code twice ?

Event Timeline

Patrix87 edited Additional Information. (Show Details)Feb 3 2016, 4:08 PM
Patrix87 set Category to Feature Request.
Patrix87 set Reproducibility to Always.
Patrix87 set Severity to None.
Patrix87 set Resolution to Open.
Patrix87 set Legacy ID to 2579890551.May 8 2016, 1:38 PM
Patrix87 added a subscriber: Patrix87.

I think that the Current Inheritance structure is unnecessarily complex to work with for a simple reason.

Every-time you want to redefine something on more than one level at the time you have to re-declare the whole tree of parent classes making sure not to mention one class twice...

Which makes it especially hard to do pragmatically or even manually if you have a lot of classes to redefine.

Since then they all at some point inherit from each other on multiple level and even sometime on the same level.

Multiple Inheritance would solve.

Being able to redefine inherited sub-properties without being forced to re-declare them would also solve that issue.

Oh and by the way, Bjarne Stroustrup implemented Mulitple Inheritance in C++ in 1984, So I guess that 30 years later Bohemia is probably able to do the same...