chore: add static assertions for weapon field names

This commit is contained in:
Jan 2024-04-07 15:09:51 +02:00
parent 4f0d9674ff
commit c1a4874791
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
4 changed files with 39 additions and 19 deletions

View File

@ -2852,7 +2852,7 @@ namespace IW5
WEAPTYPE_PROJECTILE = 0x3,
WEAPTYPE_RIOTSHIELD = 0x4,
WEAPTYPE_NUM
WEAPTYPE_COUNT
};
enum weapClass_t
@ -2870,7 +2870,7 @@ namespace IW5
WEAPCLASS_NON_PLAYER = 0xA,
WEAPCLASS_ITEM = 0xB,
WEAPCLASS_NUM
WEAPCLASS_COUNT
};
enum PenetrateType
@ -2909,9 +2909,7 @@ namespace IW5
WEAPON_FIRETYPE_BURSTFIRE4 = 0x4,
WEAPON_FIRETYPE_DOUBLEBARREL = 0x5,
WEAPON_FIRETYPECOUNT,
WEAPON_FIRETYPE_BURSTFIRE_FIRST = WEAPON_FIRETYPE_BURSTFIRE2,
WEAPON_FIRETYPE_BURSTFIRE_LAST = WEAPON_FIRETYPE_BURSTFIRE4
WEAPON_FIRETYPE_COUNT
};
struct AttAmmoGeneral
@ -3099,7 +3097,7 @@ namespace IW5
WEAPOVERLAYRETICLE_NONE = 0x0,
WEAPOVERLAYRETICLE_CROSSHAIR = 0x1,
WEAPOVERLAYRETICLE_NUM
WEAPOVERLAYRETICLE_COUNT
};
struct ADSOverlay
@ -3168,7 +3166,7 @@ namespace IW5
WEAPPROJEXP_SMOKE = 0x5,
WEAPPROJEXP_HEAVY = 0x6,
WEAPPROJEXP_NUM
WEAPPROJEXP_COUNT
};
struct snd_alias_list_name
@ -3266,7 +3264,7 @@ namespace IW5
WEAPINVENTORY_EXCLUSIVE = 0x4,
WEAPINVENTORY_SCAVENGER = 0x5,
WEAPINVENTORYCOUNT
WEAPINVENTORY_COUNT
};
enum OffhandClass
@ -3287,7 +3285,7 @@ namespace IW5
WEAPSTANCE_DUCK = 0x1,
WEAPSTANCE_PRONE = 0x2,
WEAPSTANCE_NUM
WEAPSTANCE_COUNT
};
enum activeReticleType_t
@ -3358,7 +3356,7 @@ namespace IW5
WEAPOVERLAYINTERFACE_JAVELIN = 0x1,
WEAPOVERLAYINTERFACE_TURRETSCOPE = 0x2,
WEAPOVERLAYINTERFACECOUNT
WEAPOVERLAYINTERFACE_COUNT
};
enum WeapStickinessType
@ -3491,7 +3489,7 @@ namespace IW5
SURF_TYPE_RIOT_SHIELD,
SURF_TYPE_SLUSH,
SURF_TYPE_NUM
SURF_TYPE_COUNT
};
struct WeaponDef
@ -4524,7 +4522,8 @@ namespace IW5
VEH_SNOWMOBILE = 0x6,
VEH_SUBMARINE = 0x7,
VEH_UGV = 0x8,
VEH_TYPE_COUNT = 0x9
VEH_TYPE_COUNT
};
enum VehicleAxleType
@ -4532,7 +4531,8 @@ namespace IW5
VEH_AXLE_FRONT = 0x0,
VEH_AXLE_REAR = 0x1,
VEH_AXLE_ALL = 0x2,
VEH_AXLE_COUNT = 0x3
VEH_AXLE_COUNT
};
enum VehCamZOffsetMode

View File

@ -743,6 +743,7 @@ namespace IW5
"projectile",
"riotshield",
};
static_assert(std::extent_v<decltype(szWeapTypeNames)> == WEAPTYPE_COUNT);
inline const char* szWeapClassNames[]{
"rifle",
@ -758,11 +759,13 @@ namespace IW5
"non-player",
"item",
};
static_assert(std::extent_v<decltype(szWeapClassNames)> == WEAPCLASS_COUNT);
inline const char* szWeapOverlayReticleNames[]{
"none",
"crosshair",
};
static_assert(std::extent_v<decltype(szWeapOverlayReticleNames)> == WEAPOVERLAYRETICLE_COUNT);
inline const char* szWeapInventoryTypeNames[]{
"primary",
@ -772,6 +775,7 @@ namespace IW5
"exclusive",
"scavenger",
};
static_assert(std::extent_v<decltype(szWeapInventoryTypeNames)> == WEAPINVENTORY_COUNT);
inline const char* szWeapFireTypeNames[]{
"Full Auto",
@ -781,6 +785,7 @@ namespace IW5
"4-Round Burst",
"Double Barrel",
};
static_assert(std::extent_v<decltype(szWeapFireTypeNames)> == WEAPON_FIRETYPE_COUNT);
inline const char* penetrateTypeNames[]{
"none",
@ -788,6 +793,7 @@ namespace IW5
"medium",
"large",
};
static_assert(std::extent_v<decltype(penetrateTypeNames)> == PENETRATE_TYPE_COUNT);
inline const char* impactTypeNames[]{
"none",
@ -802,12 +808,14 @@ namespace IW5
"rocket_explode",
"projectile_dud",
};
static_assert(std::extent_v<decltype(impactTypeNames)> == IMPACT_TYPE_COUNT);
inline const char* szWeapStanceNames[]{
"stand",
"duck",
"prone",
};
static_assert(std::extent_v<decltype(szWeapStanceNames)> == WEAPSTANCE_COUNT);
inline const char* szProjectileExplosionNames[]{
"grenade",
@ -818,6 +826,7 @@ namespace IW5
"smoke",
"heavy explosive",
};
static_assert(std::extent_v<decltype(szProjectileExplosionNames)> == WEAPPROJEXP_COUNT);
inline const char* offhandClassNames[]{
"None",
@ -827,6 +836,7 @@ namespace IW5
"Throwing Knife",
"Other",
};
static_assert(std::extent_v<decltype(offhandClassNames)> == OFFHAND_CLASS_COUNT);
inline const char* playerAnimTypeNames[]{
"none",
@ -854,6 +864,7 @@ namespace IW5
"Pip-On-A-Stick",
"Bouncing diamond",
};
static_assert(std::extent_v<decltype(activeReticleNames)> == VEH_ACTIVE_RETICLE_COUNT);
inline const char* guidedMissileNames[]{
"None",
@ -861,6 +872,7 @@ namespace IW5
"Hellfire",
"Javelin",
};
static_assert(std::extent_v<decltype(guidedMissileNames)> == MISSILE_GUIDANCE_COUNT);
inline const char* stickinessNames[]{
"Don't stick",
@ -870,12 +882,14 @@ namespace IW5
"Stick to ground, maintain yaw",
"Knife",
};
static_assert(std::extent_v<decltype(stickinessNames)> == WEAPSTICKINESS_COUNT);
inline const char* overlayInterfaceNames[]{
"None",
"Javelin",
"Turret Scope",
};
static_assert(std::extent_v<decltype(overlayInterfaceNames)> == WEAPOVERLAYINTERFACE_COUNT);
inline const char* ammoCounterClipNames[]{
"None",
@ -886,12 +900,14 @@ namespace IW5
"Beltfed",
"AltWeapon",
};
static_assert(std::extent_v<decltype(ammoCounterClipNames)> == AMMO_COUNTER_CLIP_COUNT);
inline const char* weapIconRatioNames[]{
"1:1",
"2:1",
"4:1",
};
static_assert(std::extent_v<decltype(weapIconRatioNames)> == WEAPON_ICON_RATIO_COUNT);
inline const char* s_vehicleClassNames[]{
"4 wheel",
@ -901,13 +917,17 @@ namespace IW5
"artillery",
"helicopter",
"snowmobile",
"submarine",
"ugv",
};
static_assert(std::extent_v<decltype(s_vehicleClassNames)> == VEH_TYPE_COUNT);
inline const char* s_vehicleAxleTypeNames[]{
"front",
"rear",
"all",
};
static_assert(std::extent_v<decltype(s_vehicleAxleTypeNames)> == VEH_AXLE_COUNT);
inline const char* bounceSoundSuffixes[]{
"_default", "_bark", "_brick", "_carpet", "_cloth", "_concrete", "_dirt", "_flesh", "_foliage", "_glass", "_grass",

View File

@ -550,7 +550,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
if (fullDef->weapDef.parallelBounce)
{
static_assert(std::extent_v<decltype(WeaponFullDef::parallelBounce)> == SURF_TYPE_NUM);
static_assert(std::extent_v<decltype(WeaponFullDef::parallelBounce)> == SURF_TYPE_COUNT);
assert(sizeof(WeaponFullDef::parallelBounce) >= sizeof(float) * std::extent_v<decltype(WeaponFullDef::parallelBounce)>);
memcpy(fullDef->parallelBounce, fullDef->weapDef.parallelBounce, sizeof(float) * std::extent_v<decltype(WeaponFullDef::parallelBounce)>);
fullDef->weapDef.parallelBounce = fullDef->parallelBounce;
@ -558,7 +558,7 @@ void AssetDumperWeapon::CopyToFullDef(const WeaponCompleteDef* weapon, WeaponFul
if (fullDef->weapDef.perpendicularBounce)
{
static_assert(std::extent_v<decltype(WeaponFullDef::perpendicularBounce)> == SURF_TYPE_NUM);
static_assert(std::extent_v<decltype(WeaponFullDef::perpendicularBounce)> == SURF_TYPE_COUNT);
assert(sizeof(WeaponFullDef::perpendicularBounce) >= sizeof(float) * std::extent_v<decltype(WeaponFullDef::perpendicularBounce)>);
memcpy(fullDef->perpendicularBounce, fullDef->weapDef.perpendicularBounce, sizeof(float) * std::extent_v<decltype(WeaponFullDef::perpendicularBounce)>);
fullDef->weapDef.perpendicularBounce = fullDef->perpendicularBounce;

View File

@ -78,18 +78,18 @@ set reusable notetrackRumbleMapValues;
set scriptstring notetrackRumbleMapValues;
set count notetrackRumbleMapValues 16;
set reusable bounceSound;
set count bounceSound SURF_TYPE_NUM;
set count bounceSound SURF_TYPE_COUNT;
set reusable rollingSound;
set count rollingSound SURF_TYPE_NUM;
set count rollingSound SURF_TYPE_COUNT;
set reusable worldModel;
set count worldModel 16;
set string szAmmoName;
set string szClipName;
set string szSharedAmmoCapName;
set reusable parallelBounce;
set count parallelBounce SURF_TYPE_NUM;
set count parallelBounce SURF_TYPE_COUNT;
set reusable perpendicularBounce;
set count perpendicularBounce SURF_TYPE_NUM;
set count perpendicularBounce SURF_TYPE_COUNT;
set string accuracyGraphName0;
set string accuracyGraphName1;
set reusable originalAccuracyGraphKnots0;