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

View File

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

View File

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