Oops, I realise now that this function is an over-engineered solution to a simpler solution in most cases. If you need to tell the difference between a goggles and a binocs type or if you want to know the vehicle weapon type, then it could still be useful. You can get the most useful info from just finding out what slots the weapon uses:
#define VEHICLE 0
#define PRIMARY 1
#define PISTOL 2
#define SECONDARY 4
#define SUPPORT 5
#define OPTIC 4096
_weaponClass = "M5A5";
_weaponType = getNumber (configFile >> "CfgWeapons" >> _weaponClass >> "type");
switch (_weaponType) do
{
case PRIMARY:
{
};
// ... etc ...
};
SUPPORT weapons are those that use both the PRIMARY and SECONDARY weapon slots, such as MGs. OPTIC is binocs, laser, NV-goggles.
Not sure whether to leave the SPON_getWeaponType function as it is, delete it, or use a combination of the two methods to optimise the function. Anyone care?