mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-07-26 18:00:38 +00:00
feat: templated vehicle loading and dumping for IW4 and IW5 (#929)
* feat: templated vehicle loading and dumping for IW4 and IW5 * chore: restructure vehicle tests into separate files --------- Co-authored-by: Jan Laupetin <[email protected]>
This commit is contained in:
@@ -205,6 +205,18 @@ namespace IW5
|
||||
PPFT_NUM_FIELD_TYPES,
|
||||
};
|
||||
|
||||
enum VehicleFieldType
|
||||
{
|
||||
VFT_TYPE = CSPFT_NUM_BASE_FIELD_TYPES,
|
||||
VFT_AXLE_STEERING,
|
||||
VFT_AXLE_POWER,
|
||||
VFT_AXLE_BRAKING,
|
||||
VFT_TROPHY_TAGS,
|
||||
VFT_CAM_Z_OFFSET_MODE,
|
||||
|
||||
VFT_NUM,
|
||||
};
|
||||
|
||||
struct AccuracyGraph
|
||||
{
|
||||
vec2_t* graphKnots;
|
||||
|
||||
@@ -5173,7 +5173,8 @@ namespace IW5
|
||||
VEHCAM_ZMODE_WORLD = 0x0,
|
||||
VEHCAM_ZMODE_VEHICLE = 0x1,
|
||||
VEHCAM_ZMODE_VIEW = 0x2,
|
||||
VEHCAM_ZMODE_COUNT = 0x3
|
||||
|
||||
VEHCAM_ZMODE_COUNT
|
||||
};
|
||||
|
||||
struct VehiclePhysDef
|
||||
|
||||
@@ -158,22 +158,6 @@ namespace IW4
|
||||
"4:1",
|
||||
};
|
||||
|
||||
inline const char* s_vehicleClassNames[]{
|
||||
"4 wheel",
|
||||
"tank",
|
||||
"plane",
|
||||
"boat",
|
||||
"artillery",
|
||||
"helicopter",
|
||||
"snowmobile",
|
||||
};
|
||||
|
||||
inline const char* s_vehicleAxleTypeNames[]{
|
||||
"front",
|
||||
"rear",
|
||||
"all",
|
||||
};
|
||||
|
||||
inline const char* bounceSoundSuffixes[]{
|
||||
"_default", "_bark", "_brick", "_carpet", "_cloth", "_concrete", "_dirt", "_flesh", "_foliage", "_glass", "_grass",
|
||||
"_gravel", "_ice", "_metal", "_mud", "_paper", "_plaster", "_rock", "_sand", "_snow", "_water", "_wood",
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace IW4
|
||||
{"useHintString", offsetof(VehicleDef, useHintString), CSPFT_STRING },
|
||||
{"health", offsetof(VehicleDef, health), CSPFT_INT },
|
||||
{"quadBarrel", offsetof(VehicleDef, quadBarrel), CSPFT_QBOOLEAN },
|
||||
{"texureScrollScale", offsetof(VehicleDef, texScrollScale), CSPFT_FLOAT },
|
||||
{"textureScrollScale", offsetof(VehicleDef, texScrollScale), CSPFT_FLOAT },
|
||||
{"topSpeed", offsetof(VehicleDef, topSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"accel", offsetof(VehicleDef, accel), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"rotRate", offsetof(VehicleDef, rotRate), CSPFT_FLOAT },
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace IW4
|
||||
{
|
||||
inline const char* s_vehicleClassNames[]{
|
||||
"4 wheel",
|
||||
"tank",
|
||||
"plane",
|
||||
"boat",
|
||||
"artillery",
|
||||
"helicopter",
|
||||
"snowmobile",
|
||||
};
|
||||
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);
|
||||
} // namespace IW4
|
||||
@@ -0,0 +1,226 @@
|
||||
#pragma once
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
inline cspField_t vehicle_fields[]{
|
||||
{"type", offsetof(VehicleDef, type), VFT_TYPE },
|
||||
{"useHintString", offsetof(VehicleDef, useHintString), CSPFT_STRING },
|
||||
{"health", offsetof(VehicleDef, health), CSPFT_INT },
|
||||
{"quadBarrel", offsetof(VehicleDef, quadBarrel), CSPFT_QBOOLEAN },
|
||||
{"textureScrollScale", offsetof(VehicleDef, texScrollScale), CSPFT_FLOAT },
|
||||
{"topSpeed", offsetof(VehicleDef, topSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"accel", offsetof(VehicleDef, accel), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"rotRate", offsetof(VehicleDef, rotRate), CSPFT_FLOAT },
|
||||
{"rotAccel", offsetof(VehicleDef, rotAccel), CSPFT_FLOAT },
|
||||
{"maxBodyPitch", offsetof(VehicleDef, maxBodyPitch), CSPFT_FLOAT },
|
||||
{"maxBodyRoll", offsetof(VehicleDef, maxBodyRoll), CSPFT_FLOAT },
|
||||
{"fakeBodyStabilizer", offsetof(VehicleDef, fakeBodyStabilizer), CSPFT_QBOOLEAN },
|
||||
{"fakeBodyAccelPitch", offsetof(VehicleDef, fakeBodyAccelPitch), CSPFT_FLOAT },
|
||||
{"fakeBodyAccelRoll", offsetof(VehicleDef, fakeBodyAccelRoll), CSPFT_FLOAT },
|
||||
{"fakeBodyVelPitch", offsetof(VehicleDef, fakeBodyVelPitch), CSPFT_FLOAT },
|
||||
{"fakeBodyVelRoll", offsetof(VehicleDef, fakeBodyVelRoll), CSPFT_FLOAT },
|
||||
{"fakeBodySideVelPitch", offsetof(VehicleDef, fakeBodySideVelPitch), CSPFT_FLOAT },
|
||||
{"fakeBodyPitchStrength", offsetof(VehicleDef, fakeBodyPitchStrength), CSPFT_FLOAT },
|
||||
{"fakeBodyRollStrength", offsetof(VehicleDef, fakeBodyRollStrength), CSPFT_FLOAT },
|
||||
{"fakeBodyPitchDampening", offsetof(VehicleDef, fakeBodyPitchDampening), CSPFT_FLOAT },
|
||||
{"fakeBodyRollDampening", offsetof(VehicleDef, fakeBodyRollDampening), CSPFT_FLOAT },
|
||||
{"fakeBodyBoatRockingAmplitude", offsetof(VehicleDef, fakeBodyBoatRockingAmplitude), CSPFT_FLOAT },
|
||||
{"fakeBodyBoatRockingPeriod", offsetof(VehicleDef, fakeBodyBoatRockingPeriod), CSPFT_FLOAT },
|
||||
{"fakeBodyBoatRockingRotationPeriod", offsetof(VehicleDef, fakeBodyBoatRockingRotationPeriod), CSPFT_FLOAT },
|
||||
{"fakeBodyBoatRockingFadeoutSpeed", offsetof(VehicleDef, fakeBodyBoatRockingFadeoutSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"boatBouncingMinForce", offsetof(VehicleDef, boatBouncingMinForce), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"boatBouncingMaxForce", offsetof(VehicleDef, boatBouncingMaxForce), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"boatBouncingRate", offsetof(VehicleDef, boatBouncingRate), CSPFT_FLOAT },
|
||||
{"boatBouncingFadeinSpeed", offsetof(VehicleDef, boatBouncingFadeinSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"boatBouncingFadeoutSteeringAngle", offsetof(VehicleDef, boatBouncingFadeoutSteeringAngle), CSPFT_FLOAT },
|
||||
{"collisionDamage", offsetof(VehicleDef, collisionDamage), CSPFT_FLOAT },
|
||||
{"collisionSpeed", offsetof(VehicleDef, collisionSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"killcamZDist", offsetof(VehicleDef, killcamOffset[0]), CSPFT_FLOAT },
|
||||
{"killcamBackDist", offsetof(VehicleDef, killcamOffset[1]), CSPFT_FLOAT },
|
||||
{"killcamUpDist", offsetof(VehicleDef, killcamOffset[2]), CSPFT_FLOAT },
|
||||
{"playerProtected", offsetof(VehicleDef, playerProtected), CSPFT_QBOOLEAN },
|
||||
{"bulletDamage", offsetof(VehicleDef, bulletDamage), CSPFT_QBOOLEAN },
|
||||
{"armorPiercingDamage", offsetof(VehicleDef, armorPiercingDamage), CSPFT_QBOOLEAN },
|
||||
{"grenadeDamage", offsetof(VehicleDef, grenadeDamage), CSPFT_QBOOLEAN },
|
||||
{"projectileDamage", offsetof(VehicleDef, projectileDamage), CSPFT_QBOOLEAN },
|
||||
{"projectileSplashDamage", offsetof(VehicleDef, projectileSplashDamage), CSPFT_QBOOLEAN },
|
||||
{"heavyExplosiveDamage", offsetof(VehicleDef, heavyExplosiveDamage), CSPFT_QBOOLEAN },
|
||||
{"physicsEnabled", offsetof(VehicleDef, vehPhysDef.physicsEnabled), CSPFT_QBOOLEAN },
|
||||
{"physicsPreset", offsetof(VehicleDef, vehPhysDef.physPresetName), CSPFT_STRING },
|
||||
{"accelerationGraph", offsetof(VehicleDef, vehPhysDef.accelGraphName), CSPFT_STRING },
|
||||
{"steeringAxle", offsetof(VehicleDef, vehPhysDef.steeringAxle), VFT_AXLE_STEERING },
|
||||
{"powerAxle", offsetof(VehicleDef, vehPhysDef.powerAxle), VFT_AXLE_POWER },
|
||||
{"brakingAxle", offsetof(VehicleDef, vehPhysDef.brakingAxle), VFT_AXLE_BRAKING },
|
||||
{"reverseSpeed", offsetof(VehicleDef, vehPhysDef.reverseSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"maxVelocity", offsetof(VehicleDef, vehPhysDef.maxVelocity), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"maxPitch", offsetof(VehicleDef, vehPhysDef.maxPitch), CSPFT_FLOAT },
|
||||
{"maxRoll", offsetof(VehicleDef, vehPhysDef.maxRoll), CSPFT_FLOAT },
|
||||
{"suspensionTravelRear", offsetof(VehicleDef, vehPhysDef.suspensionTravelRear), CSPFT_FLOAT },
|
||||
{"suspensionStrengthFront", offsetof(VehicleDef, vehPhysDef.suspensionStrengthFront), CSPFT_FLOAT },
|
||||
{"suspensionDampingFront", offsetof(VehicleDef, vehPhysDef.suspensionDampingFront), CSPFT_FLOAT },
|
||||
{"suspensionStrengthRear", offsetof(VehicleDef, vehPhysDef.suspensionStrengthRear), CSPFT_FLOAT },
|
||||
{"suspensionDampingRear", offsetof(VehicleDef, vehPhysDef.suspensionDampingRear), CSPFT_FLOAT },
|
||||
{"frictionBraking", offsetof(VehicleDef, vehPhysDef.frictionBraking), CSPFT_FLOAT },
|
||||
{"frictionCoasting", offsetof(VehicleDef, vehPhysDef.frictionCoasting), CSPFT_FLOAT },
|
||||
{"frictionTopSpeed", offsetof(VehicleDef, vehPhysDef.frictionTopSpeed), CSPFT_FLOAT },
|
||||
{"frictionSide", offsetof(VehicleDef, vehPhysDef.frictionSide), CSPFT_FLOAT },
|
||||
{"frictionSideRear", offsetof(VehicleDef, vehPhysDef.frictionSideRear), CSPFT_FLOAT },
|
||||
{"velocityDependentSlip", offsetof(VehicleDef, vehPhysDef.velocityDependentSlip), CSPFT_FLOAT },
|
||||
{"rollStability", offsetof(VehicleDef, vehPhysDef.rollStability), CSPFT_FLOAT },
|
||||
{"rollResistance", offsetof(VehicleDef, vehPhysDef.rollResistance), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"pitchResistance", offsetof(VehicleDef, vehPhysDef.pitchResistance), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"yawResistance", offsetof(VehicleDef, vehPhysDef.yawResistance), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"uprightStrengthPitch", offsetof(VehicleDef, vehPhysDef.uprightStrengthPitch), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"uprightStrengthRoll", offsetof(VehicleDef, vehPhysDef.uprightStrengthRoll), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"targetAirPitch", offsetof(VehicleDef, vehPhysDef.targetAirPitch), CSPFT_FLOAT },
|
||||
{"airYawTorque", offsetof(VehicleDef, vehPhysDef.airYawTorque), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"airPitchTorque", offsetof(VehicleDef, vehPhysDef.airPitchTorque), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"minimumMomentumForCollision", offsetof(VehicleDef, vehPhysDef.minimumMomentumForCollision), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"collisionLaunchForceScale", offsetof(VehicleDef, vehPhysDef.collisionLaunchForceScale), CSPFT_FLOAT },
|
||||
{"wreckedMassScale", offsetof(VehicleDef, vehPhysDef.wreckedMassScale), CSPFT_FLOAT },
|
||||
{"wreckedBodyFriction", offsetof(VehicleDef, vehPhysDef.wreckedBodyFriction), CSPFT_FLOAT },
|
||||
{"minimumJoltForNotify", offsetof(VehicleDef, vehPhysDef.minimumJoltForNotify), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"slipThresholdFront", offsetof(VehicleDef, vehPhysDef.slipThresholdFront), CSPFT_FLOAT },
|
||||
{"slipThresholdRear", offsetof(VehicleDef, vehPhysDef.slipThresholdRear), CSPFT_FLOAT },
|
||||
{"slipFricScaleFront", offsetof(VehicleDef, vehPhysDef.slipFricScaleFront), CSPFT_FLOAT },
|
||||
{"slipFricScaleRear", offsetof(VehicleDef, vehPhysDef.slipFricScaleRear), CSPFT_FLOAT },
|
||||
{"slipFricRateFront", offsetof(VehicleDef, vehPhysDef.slipFricRateFront), CSPFT_FLOAT },
|
||||
{"slipFricRateRear", offsetof(VehicleDef, vehPhysDef.slipFricRateRear), CSPFT_FLOAT },
|
||||
{"slipYawTorque", offsetof(VehicleDef, vehPhysDef.slipYawTorque), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"boostDuration", offsetof(VehicleDef, boostDuration), CSPFT_FLOAT },
|
||||
{"boostRechargeTime", offsetof(VehicleDef, boostRechargeTime), CSPFT_FLOAT },
|
||||
{"boostAcceleration", offsetof(VehicleDef, boostAcceleration), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"suspensionTravel", offsetof(VehicleDef, suspensionTravel), CSPFT_FLOAT },
|
||||
{"maxSteeringAngle", offsetof(VehicleDef, maxSteeringAngle), CSPFT_FLOAT },
|
||||
{"steeringLerp", offsetof(VehicleDef, steeringLerp), CSPFT_FLOAT },
|
||||
{"minSteeringScale", offsetof(VehicleDef, minSteeringScale), CSPFT_FLOAT },
|
||||
{"minSteeringSpeed", offsetof(VehicleDef, minSteeringSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"vehHelicopterBoundsRadius", offsetof(VehicleDef, vehHelicopterBoundsRadius), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxSpeed", offsetof(VehicleDef, vehHelicopterMaxSpeed), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxSpeedVertical", offsetof(VehicleDef, vehHelicopterMaxSpeedVertical), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxAccel", offsetof(VehicleDef, vehHelicopterMaxAccel), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxAccelVertical", offsetof(VehicleDef, vehHelicopterMaxAccelVertical), CSPFT_FLOAT },
|
||||
{"vehHelicopterDecelerationFwd", offsetof(VehicleDef, vehHelicopterDecelerationFwd), CSPFT_FLOAT },
|
||||
{"vehHelicopterDecelerationSide", offsetof(VehicleDef, vehHelicopterDecelerationSide), CSPFT_FLOAT },
|
||||
{"vehHelicopterDecelerationUp", offsetof(VehicleDef, vehHelicopterDecelerationUp), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxYawRate", offsetof(VehicleDef, vehHelicopterMaxYawRate), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxYawAccel", offsetof(VehicleDef, vehHelicopterMaxYawAccel), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromVelocity", offsetof(VehicleDef, vehHelicopterTiltFromVelocity), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromControllerAxes", offsetof(VehicleDef, vehHelicopterTiltFromControllerAxes), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromAcceleration", offsetof(VehicleDef, vehHelicopterTiltFromAcceleration), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromDeceleration", offsetof(VehicleDef, vehHelicopterTiltFromDeceleration), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromFwdAndYaw_VelAtMaxTilt", offsetof(VehicleDef, vehHelicopterTiltFromFwdAndYaw_VelAtMaxTilt), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltFromFwdAndYaw", offsetof(VehicleDef, vehHelicopterTiltFromFwdAndYaw), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltMomentum", offsetof(VehicleDef, vehHelicopterTiltMomentum), CSPFT_FLOAT },
|
||||
{"vehHelicopterTiltSpeed", offsetof(VehicleDef, vehHelicopterTiltSpeed), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxPitch", offsetof(VehicleDef, vehHelicopterMaxPitch), CSPFT_FLOAT },
|
||||
{"vehHelicopterMaxRoll", offsetof(VehicleDef, vehHelicopterMaxRoll), CSPFT_FLOAT },
|
||||
{"vehHelicopterHoverSpeedThreshold", offsetof(VehicleDef, vehHelicopterHoverSpeedThreshold), CSPFT_FLOAT },
|
||||
{"vehHelicopterJitterJerkyness", offsetof(VehicleDef, vehHelicopterJitterJerkyness), CSPFT_FLOAT },
|
||||
{"vehHelicopterLookaheadTime", offsetof(VehicleDef, vehHelicopterLookaheadTime), CSPFT_FLOAT },
|
||||
{"vehHelicopterSoftCollisions", offsetof(VehicleDef, vehHelicopterSoftCollisions), CSPFT_QBOOLEAN },
|
||||
{"camLookEnabled", offsetof(VehicleDef, camLookEnabled), CSPFT_QBOOLEAN },
|
||||
{"camRelativeControl", offsetof(VehicleDef, camRelativeControl), CSPFT_QBOOLEAN },
|
||||
{"camLerp", offsetof(VehicleDef, camLerp), CSPFT_FLOAT },
|
||||
{"camHeight", offsetof(VehicleDef, camHeight), CSPFT_FLOAT },
|
||||
{"camRadius", offsetof(VehicleDef, camRadius), CSPFT_FLOAT },
|
||||
{"camPitchInfluence", offsetof(VehicleDef, camPitchInfluence), CSPFT_FLOAT },
|
||||
{"camYawInfluence", offsetof(VehicleDef, camYawInfluence), CSPFT_FLOAT },
|
||||
{"camRollInfluence", offsetof(VehicleDef, camRollInfluence), CSPFT_FLOAT },
|
||||
{"camFovIncrease", offsetof(VehicleDef, camFovIncrease), CSPFT_FLOAT },
|
||||
{"camFovOffset", offsetof(VehicleDef, camFovOffset), CSPFT_FLOAT },
|
||||
{"camFovSpeed", offsetof(VehicleDef, camFovSpeed), CSPFT_FLOAT },
|
||||
{"camReturnSpeed", offsetof(VehicleDef, camReturnSpeed), CSPFT_FLOAT },
|
||||
{"camReturnLerp", offsetof(VehicleDef, camReturnLerp), CSPFT_FLOAT },
|
||||
{"vehCam_UseGDT", offsetof(VehicleDef, vehCam_UseGDT), CSPFT_QBOOLEAN },
|
||||
{"vehCam_anglesPitch", offsetof(VehicleDef, vehCam_anglesPitch), CSPFT_FLOAT },
|
||||
{"vehCam_anglesYaw", offsetof(VehicleDef, vehCam_anglesYaw), CSPFT_FLOAT },
|
||||
{"vehCam_anglesRoll", offsetof(VehicleDef, vehCam_anglesRoll), CSPFT_FLOAT },
|
||||
{"vehCam_offsetX", offsetof(VehicleDef, vehCam_offsetX), CSPFT_FLOAT },
|
||||
{"vehCam_offsetY", offsetof(VehicleDef, vehCam_offsetY), CSPFT_FLOAT },
|
||||
{"vehCam_offsetZ", offsetof(VehicleDef, vehCam_offsetZ), CSPFT_FLOAT },
|
||||
{"vehCam_radius", offsetof(VehicleDef, vehCam_radius), CSPFT_FLOAT },
|
||||
{"vehCam_speedInfluence", offsetof(VehicleDef, vehCam_speedInfluence), CSPFT_FLOAT },
|
||||
{"vehCam_pitchTurnRate", offsetof(VehicleDef, vehCam_pitchTurnRate), CSPFT_FLOAT },
|
||||
{"vehCam_pitchClamp", offsetof(VehicleDef, vehCam_pitchClamp), CSPFT_FLOAT },
|
||||
{"vehCam_yawTurnRate", offsetof(VehicleDef, vehCam_yawTurnRate), CSPFT_FLOAT },
|
||||
{"vehCam_yawClamp", offsetof(VehicleDef, vehCam_yawClamp), CSPFT_FLOAT },
|
||||
{"vehCam_zOffsetMode", offsetof(VehicleDef, vehCam_zOffsetMode), VFT_CAM_Z_OFFSET_MODE },
|
||||
{"vehCam_anglesPitch3P", offsetof(VehicleDef, vehCam_anglesPitch3P), CSPFT_FLOAT },
|
||||
{"vehCam_anglesYaw3P", offsetof(VehicleDef, vehCam_anglesYaw3P), CSPFT_FLOAT },
|
||||
{"vehCam_anglesRoll3P", offsetof(VehicleDef, vehCam_anglesRoll3P), CSPFT_FLOAT },
|
||||
{"vehCam_offsetX3P", offsetof(VehicleDef, vehCam_offsetX3P), CSPFT_FLOAT },
|
||||
{"vehCam_offsetY3P", offsetof(VehicleDef, vehCam_offsetY3P), CSPFT_FLOAT },
|
||||
{"vehCam_offsetZ3P", offsetof(VehicleDef, vehCam_offsetZ3P), CSPFT_FLOAT },
|
||||
{"vehCam_radius3P", offsetof(VehicleDef, vehCam_radius3P), CSPFT_FLOAT },
|
||||
{"vehCam_speedInfluence3P", offsetof(VehicleDef, vehCam_speedInfluence3P), CSPFT_FLOAT },
|
||||
{"vehCam_pitchTurnRate3P", offsetof(VehicleDef, vehCam_pitchTurnRate3P), CSPFT_FLOAT },
|
||||
{"vehCam_pitchClamp3P", offsetof(VehicleDef, vehCam_pitchClamp3P), CSPFT_FLOAT },
|
||||
{"vehCam_yawTurnRate3P", offsetof(VehicleDef, vehCam_yawTurnRate3P), CSPFT_FLOAT },
|
||||
{"vehCam_yawClamp3P", offsetof(VehicleDef, vehCam_yawClamp3P), CSPFT_FLOAT },
|
||||
{"vehCam_zOffsetMode3P", offsetof(VehicleDef, vehCam_zOffsetMode3P), VFT_CAM_Z_OFFSET_MODE },
|
||||
{"turretWeaponName", offsetof(VehicleDef, turretWeaponName), CSPFT_STRING },
|
||||
{"turretHorizSpanLeft", offsetof(VehicleDef, turretHorizSpanLeft), CSPFT_FLOAT },
|
||||
{"turretHorizSpanRight", offsetof(VehicleDef, turretHorizSpanRight), CSPFT_FLOAT },
|
||||
{"turretVertSpanUp", offsetof(VehicleDef, turretVertSpanUp), CSPFT_FLOAT },
|
||||
{"turretVertSpanDown", offsetof(VehicleDef, turretVertSpanDown), CSPFT_FLOAT },
|
||||
{"turretHorizResistLeft", offsetof(VehicleDef, turretHorizResistLeft), CSPFT_FLOAT },
|
||||
{"turretHorizResistRight", offsetof(VehicleDef, turretHorizResistRight), CSPFT_FLOAT },
|
||||
{"turretVertResistUp", offsetof(VehicleDef, turretVertResistUp), CSPFT_FLOAT },
|
||||
{"turretVertResistDown", offsetof(VehicleDef, turretVertResistDown), CSPFT_FLOAT },
|
||||
{"turretRotRate", offsetof(VehicleDef, turretRotRate), CSPFT_FLOAT },
|
||||
{"turretSpinSnd", offsetof(VehicleDef, turretSpinSnd), CSPFT_SOUND },
|
||||
{"turretStopSnd", offsetof(VehicleDef, turretStopSnd), CSPFT_SOUND },
|
||||
{"trophyEnabled", offsetof(VehicleDef, trophyEnabled), CSPFT_QBOOLEAN },
|
||||
{"trophyRadius", offsetof(VehicleDef, trophyRadius), CSPFT_FLOAT },
|
||||
{"trophyInactiveRadius", offsetof(VehicleDef, trophyInactiveRadius), CSPFT_FLOAT },
|
||||
{"trophyAmmoCount", offsetof(VehicleDef, trophyAmmoCount), CSPFT_INT },
|
||||
{"trophyReloadTime", offsetof(VehicleDef, trophyReloadTime), CSPFT_FLOAT },
|
||||
{"trophyTags", offsetof(VehicleDef, trophyTags), VFT_TROPHY_TAGS },
|
||||
{"trophyExplodeFx", offsetof(VehicleDef, trophyExplodeFx), CSPFT_FX },
|
||||
{"trophyFlashFx", offsetof(VehicleDef, trophyFlashFx), CSPFT_FX },
|
||||
{"compassFriendlyIcon", offsetof(VehicleDef, compassFriendlyIcon), CSPFT_MATERIAL },
|
||||
{"compassEnemyIcon", offsetof(VehicleDef, compassEnemyIcon), CSPFT_MATERIAL },
|
||||
{"compassFriendlyAltIcon", offsetof(VehicleDef, compassFriendlyAltIcon), CSPFT_MATERIAL },
|
||||
{"compassEnemyAltIcon", offsetof(VehicleDef, compassEnemyAltIcon), CSPFT_MATERIAL },
|
||||
{"compassIconWidth", offsetof(VehicleDef, compassIconWidth), CSPFT_INT },
|
||||
{"compassIconHeight", offsetof(VehicleDef, compassIconHeight), CSPFT_INT },
|
||||
{"lowIdleSnd", offsetof(VehicleDef, idleLowSnd), CSPFT_SOUND },
|
||||
{"highIdleSnd", offsetof(VehicleDef, idleHighSnd), CSPFT_SOUND },
|
||||
{"lowEngineSnd", offsetof(VehicleDef, engineLowSnd), CSPFT_SOUND },
|
||||
{"highEngineSnd", offsetof(VehicleDef, engineHighSnd), CSPFT_SOUND },
|
||||
{"engineSndSpeed", offsetof(VehicleDef, engineSndSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"audioOriginTag", offsetof(VehicleDef, audioOriginTag), CSPFT_SCRIPT_STRING },
|
||||
{"lowIdleSndAlt", offsetof(VehicleDef, idleLowSndAlt), CSPFT_SOUND },
|
||||
{"highIdleSndAlt", offsetof(VehicleDef, idleHighSndAlt), CSPFT_SOUND },
|
||||
{"lowEngineSndAlt", offsetof(VehicleDef, engineLowSndAlt), CSPFT_SOUND },
|
||||
{"highEngineSndAlt", offsetof(VehicleDef, engineHighSndAlt), CSPFT_SOUND },
|
||||
{"engineSndSpeedAlt", offsetof(VehicleDef, engineSndSpeedAlt), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"audioOriginTagAlt", offsetof(VehicleDef, audioOriginTagAlt), CSPFT_SCRIPT_STRING },
|
||||
{"turretSpinSndAlt", offsetof(VehicleDef, turretSpinSndAlt), CSPFT_SOUND },
|
||||
{"turretStopSndAlt", offsetof(VehicleDef, turretStopSndAlt), CSPFT_SOUND },
|
||||
{"engineStartUpSnd", offsetof(VehicleDef, engineStartUpSnd), CSPFT_SOUND },
|
||||
{"engineStartUpLength", offsetof(VehicleDef, engineStartUpLength), CSPFT_MILLISECONDS },
|
||||
{"engineShutdownSnd", offsetof(VehicleDef, engineShutdownSnd), CSPFT_SOUND },
|
||||
{"engineIdleSnd", offsetof(VehicleDef, engineIdleSnd), CSPFT_SOUND },
|
||||
{"engineSustainSnd", offsetof(VehicleDef, engineSustainSnd), CSPFT_SOUND },
|
||||
{"engineRampUpSnd", offsetof(VehicleDef, engineRampUpSnd), CSPFT_SOUND },
|
||||
{"engineRampUpLength", offsetof(VehicleDef, engineRampUpLength), CSPFT_MILLISECONDS },
|
||||
{"engineRampDownSnd", offsetof(VehicleDef, engineRampDownSnd), CSPFT_SOUND },
|
||||
{"engineRampDownLength", offsetof(VehicleDef, engineRampDownLength), CSPFT_MILLISECONDS },
|
||||
{"suspensionSoftSnd", offsetof(VehicleDef, suspensionSoftSnd), CSPFT_SOUND },
|
||||
{"suspensionSoftCompression", offsetof(VehicleDef, suspensionSoftCompression), CSPFT_FLOAT },
|
||||
{"suspensionHardSnd", offsetof(VehicleDef, suspensionHardSnd), CSPFT_SOUND },
|
||||
{"suspensionHardCompression", offsetof(VehicleDef, suspensionHardCompression), CSPFT_FLOAT },
|
||||
{"collisionSnd", offsetof(VehicleDef, collisionSnd), CSPFT_SOUND },
|
||||
{"collisionBlendSpeed", offsetof(VehicleDef, collisionBlendSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"speedSnd", offsetof(VehicleDef, speedSnd), CSPFT_SOUND },
|
||||
{"speedSndBlendSpeed", offsetof(VehicleDef, speedSndBlendSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"surfaceSndPrefix", offsetof(VehicleDef, surfaceSndPrefix), CSPFT_STRING },
|
||||
{"surfaceSndBlendSpeed", offsetof(VehicleDef, surfaceSndBlendSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"slideVolume", offsetof(VehicleDef, slideVolume), CSPFT_FLOAT },
|
||||
{"slideBlendSpeed", offsetof(VehicleDef, slideBlendSpeed), CSPFT_MPH_TO_INCHES_PER_SEC},
|
||||
{"inAirPitch", offsetof(VehicleDef, inAirPitch), CSPFT_FLOAT },
|
||||
};
|
||||
} // namespace IW5
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Game/IW5/IW5.h"
|
||||
|
||||
namespace IW5
|
||||
{
|
||||
inline const char* s_vehicleClassNames[]{
|
||||
"4 wheel",
|
||||
"tank",
|
||||
"plane",
|
||||
"boat",
|
||||
"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* s_vehicleCameraZOffsetModeNames[]{
|
||||
"world",
|
||||
"vehicle",
|
||||
"view",
|
||||
};
|
||||
static_assert(std::extent_v<decltype(s_vehicleCameraZOffsetModeNames)> == VEHCAM_ZMODE_COUNT);
|
||||
} // namespace IW5
|
||||
@@ -952,26 +952,6 @@ namespace IW5
|
||||
};
|
||||
static_assert(std::extent_v<decltype(weapIconRatioNames)> == WEAPON_ICON_RATIO_COUNT);
|
||||
|
||||
inline const char* s_vehicleClassNames[]{
|
||||
"4 wheel",
|
||||
"tank",
|
||||
"plane",
|
||||
"boat",
|
||||
"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* surfaceTypeSoundSuffixes[]{
|
||||
"_default", "_bark", "_brick", "_carpet", "_cloth", "_concrete", "_dirt", "_flesh", "_foliage", "_glass", "_grass",
|
||||
"_gravel", "_ice", "_metal", "_mud", "_paper", "_plaster", "_rock", "_sand", "_snow", "_water", "_wood",
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "Game/IW4/Techset/VertexShaderLoaderIW4.h"
|
||||
#include "Game/IW4/Tracer/GdtLoaderTracerIW4.h"
|
||||
#include "Game/IW4/Tracer/RawLoaderTracerIW4.h"
|
||||
#include "Game/IW4/Vehicle/GdtLoaderVehicleIW4.h"
|
||||
#include "Game/IW4/Vehicle/RawLoaderVehicleIW4.h"
|
||||
#include "Game/IW4/Weapon/AccuracyGraphLoaderIW4.h"
|
||||
#include "Game/IW4/XAnim/XAnimLoaderIW4.h"
|
||||
#include "Game/IW4/XModel/LoaderXModelIW4.h"
|
||||
@@ -163,7 +165,8 @@ namespace
|
||||
collection.AddAssetCreator(structured_data_def::CreateLoaderIW4(memory, searchPath));
|
||||
collection.AddAssetCreator(tracer::CreateRawLoaderIW4(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(tracer::CreateGdtLoaderIW4(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
collection.AddAssetCreator(vehicle::CreateRawLoaderIW4(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(vehicle::CreateGdtLoaderIW4(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
|
||||
collection.AddSubAssetCreator(weapon::CreateAccuracyGraphLoaderIW4(memory, searchPath));
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "Game/IW5/Techset/VertexShaderLoaderIW5.h"
|
||||
#include "Game/IW5/Tracer/GdtLoaderTracerIW5.h"
|
||||
#include "Game/IW5/Tracer/RawLoaderTracerIW5.h"
|
||||
#include "Game/IW5/Vehicle/GdtLoaderVehicleIW5.h"
|
||||
#include "Game/IW5/Vehicle/RawLoaderVehicleIW5.h"
|
||||
#include "Game/IW5/Weapon/AccuracyGraphLoaderIW5.h"
|
||||
#include "Game/IW5/XAnim/XAnimLoaderIW5.h"
|
||||
#include "Game/IW5/XModel/LoaderXModelIW5.h"
|
||||
@@ -174,7 +176,8 @@ namespace
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderStructuredDataDef>(memory));
|
||||
collection.AddAssetCreator(tracer::CreateRawLoaderIW5(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(tracer::CreateGdtLoaderIW5(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderVehicle>(memory));
|
||||
collection.AddAssetCreator(vehicle::CreateRawLoaderIW5(memory, searchPath, zone));
|
||||
collection.AddAssetCreator(vehicle::CreateGdtLoaderIW5(memory, gdt, zone));
|
||||
// collection.AddAssetCreator(std::make_unique<AssetLoaderAddonMapEnts>(memory));
|
||||
|
||||
collection.AddSubAssetCreator(weapon::CreateAccuracyGraphLoaderIW5(memory, searchPath));
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/GdtLoaderVehicle" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"GdtLoaderVehicle" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_HEADER "\"InfoStringLoaderVehicle" + GAME + ".h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_NAME "InfoStringLoader" + GAME
|
||||
#set FACTORY_NAME "CreateGdtLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See GdtLoaderVehicle.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include INFO_STRING_LOADER_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
class GdtLoaderVehicle final : public AssetCreator<AssetVehicle>
|
||||
{
|
||||
public:
|
||||
GdtLoaderVehicle(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
: m_gdt(gdt),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto* gdtEntry = m_gdt.GetGdtEntryByGdfAndName(GDF_FILENAME_VEHICLE, assetName);
|
||||
if (gdtEntry == nullptr)
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromGdtProperties(*gdtEntry))
|
||||
{
|
||||
con::error("Failed to read vehicle gdt entry: \"{}\"", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
IGdtQueryable& m_gdt;
|
||||
vehicle::INFO_STRING_LOADER_NAME m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> FACTORY_NAME(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone)
|
||||
{
|
||||
return std::make_unique<GdtLoaderVehicle>(memory, gdt, zone);
|
||||
}
|
||||
} // namespace vehicle
|
||||
@@ -0,0 +1,25 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/GdtLoaderVehicle" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set FACTORY_NAME "CreateGdtLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See GdtLoaderVehicle.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include GAME_HEADER
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "Gdt/IGdtQueryable.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<GAME::AssetVehicle>> FACTORY_NAME(MemoryManager& memory, IGdtQueryable& gdt, Zone& zone);
|
||||
} // namespace vehicle
|
||||
@@ -0,0 +1,191 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/InfoStringLoaderVehicle" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"InfoStringLoaderVehicle" + GAME + ".h\""
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set INFO_STRING_CONVERTER_HEADER "\"Game/" + GAME + "/InfoString/InfoStringToStructConverter.h\""
|
||||
#set VEHICLE_FIELDS_HEADER "\"Game/" + GAME + "/Vehicle/VehicleFields" + GAME + ".h\""
|
||||
#set VEHICLE_STRINGS_HEADER "\"Game/" + GAME + "/Vehicle/VehicleStrings" + GAME + ".h\""
|
||||
#set CLASS_NAME "InfoStringLoader" + GAME
|
||||
|
||||
#if GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#endif
|
||||
|
||||
// This file was templated.
|
||||
// See InfoStringLoaderVehicle.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include GAME_HEADER
|
||||
#include INFO_STRING_CONVERTER_HEADER
|
||||
#include VEHICLE_FIELDS_HEADER
|
||||
#include VEHICLE_STRINGS_HEADER
|
||||
#include "Utils/Logging/Log.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr const char* SURFACE_SOUND_SUFFIXES[]{
|
||||
"_default", "_bark", "_brick", "_carpet", "_cloth", "_concrete", "_dirt", "_flesh", "_foliage", "_glass", "_grass",
|
||||
"_gravel", "_ice", "_metal", "_mud", "_paper", "_plaster", "_rock", "_sand", "_snow", "_water", "_wood",
|
||||
"_asphalt", "_ceramic", "_plastic", "_rubber", "_cushion", "_fruit", "_painted_metal", "_riot_shield", "_slush",
|
||||
};
|
||||
|
||||
class InfoStringToVehicleConverter final : public InfoStringToStructConverter
|
||||
{
|
||||
bool ConvertTrophyTags(const cspField_t& field, const std::string& value)
|
||||
{
|
||||
std::vector<std::string> valueArray;
|
||||
if (!ParseAsArray(value, valueArray))
|
||||
{
|
||||
con::error("Failed to parse trophy tags as array");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (valueArray.size() > std::extent_v<decltype(VehicleDef::trophyTags)>)
|
||||
{
|
||||
con::error("Cannot have more than {} trophy tags!", std::extent_v<decltype(VehicleDef::trophyTags)>);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* trophyTags = reinterpret_cast<scr_string_t*>(reinterpret_cast<uintptr_t>(m_structure) + field.iOffset);
|
||||
for (auto i = 0u; i < valueArray.size(); i++)
|
||||
{
|
||||
if (valueArray[i].empty())
|
||||
continue;
|
||||
|
||||
const auto scriptString = m_zone_script_strings.AddOrGetScriptString(valueArray[i]);
|
||||
trophyTags[i] = scriptString;
|
||||
m_registration.AddScriptString(scriptString);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool ConvertExtensionField(const cspField_t& field, const std::string& value) override
|
||||
{
|
||||
switch (static_cast<VehicleFieldType>(field.iFieldType))
|
||||
{
|
||||
case VFT_TYPE:
|
||||
return ConvertEnumInt(field.szName, value, field.iOffset, s_vehicleClassNames, std::extent_v<decltype(s_vehicleClassNames)>);
|
||||
|
||||
case VFT_AXLE_STEERING:
|
||||
case VFT_AXLE_POWER:
|
||||
case VFT_AXLE_BRAKING:
|
||||
return ConvertEnumInt(field.szName, value, field.iOffset, s_vehicleAxleTypeNames, std::extent_v<decltype(s_vehicleAxleTypeNames)>);
|
||||
|
||||
case VFT_TROPHY_TAGS:
|
||||
return ConvertTrophyTags(field, value);
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
case VFT_CAM_Z_OFFSET_MODE:
|
||||
return ConvertEnumInt(
|
||||
field.szName, value, field.iOffset, s_vehicleCameraZOffsetModeNames, std::extent_v<decltype(s_vehicleCameraZOffsetModeNames)>);
|
||||
#endif
|
||||
|
||||
case VFT_NUM:
|
||||
default:
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
InfoStringToVehicleConverter(const InfoString& infoString,
|
||||
VehicleDef& vehicle,
|
||||
ZoneScriptStrings& zoneScriptStrings,
|
||||
MemoryManager& memory,
|
||||
AssetCreationContext& context,
|
||||
AssetRegistration<AssetVehicle>& registration,
|
||||
const cspField_t* fields,
|
||||
const size_t fieldCount)
|
||||
: InfoStringToStructConverter(infoString, &vehicle, zoneScriptStrings, memory, context, registration, fields, fieldCount)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
bool LoadDependencies(VehicleDef& vehicle, AssetCreationContext& context, AssetRegistration<AssetVehicle>& registration)
|
||||
{
|
||||
if (vehicle.vehPhysDef.physPresetName && vehicle.vehPhysDef.physPresetName[0])
|
||||
{
|
||||
auto* physPreset = context.LoadDependency<AssetPhysPreset>(vehicle.vehPhysDef.physPresetName);
|
||||
if (physPreset == nullptr)
|
||||
{
|
||||
con::error("Failed to load phys preset asset \"{}\"", vehicle.vehPhysDef.physPresetName);
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicle.vehPhysDef.physPreset = physPreset->Asset();
|
||||
registration.AddDependency(physPreset);
|
||||
}
|
||||
|
||||
if (vehicle.turretWeaponName && vehicle.turretWeaponName[0])
|
||||
{
|
||||
auto* weapon = context.LoadDependency<AssetWeapon>(vehicle.turretWeaponName);
|
||||
if (weapon == nullptr)
|
||||
{
|
||||
con::error("Failed to load weapon asset \"{}\"", vehicle.turretWeaponName);
|
||||
return false;
|
||||
}
|
||||
|
||||
vehicle.turretWeapon = weapon->Asset();
|
||||
registration.AddDependency(weapon);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateSurfaceSounds(VehicleDef& vehicle, MemoryManager& memory, AssetCreationContext& context, AssetRegistration<AssetVehicle>& registration)
|
||||
{
|
||||
if (vehicle.surfaceSndPrefix == nullptr || vehicle.surfaceSndPrefix[0] == '\0')
|
||||
return;
|
||||
|
||||
static_assert(std::extent_v<decltype(VehicleDef::surfaceSnds)> == std::extent_v<decltype(SURFACE_SOUND_SUFFIXES)>);
|
||||
for (auto i = 0u; i < std::extent_v<decltype(VehicleDef::surfaceSnds)>; i++)
|
||||
{
|
||||
const auto soundName = std::string(vehicle.surfaceSndPrefix) + SURFACE_SOUND_SUFFIXES[i];
|
||||
vehicle.surfaceSnds[i].name = memory.Alloc<snd_alias_list_name>();
|
||||
vehicle.surfaceSnds[i].name->soundName = memory.Dup(soundName.c_str());
|
||||
registration.AddIndirectAssetReference(context.LoadIndirectAssetReference<AssetSound>(soundName));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
CLASS_NAME::CLASS_NAME(MemoryManager& memory, Zone& zone)
|
||||
: m_memory(memory),
|
||||
m_zone(zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CLASS_NAME::CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context)
|
||||
{
|
||||
auto* vehicle = m_memory.Alloc<VehicleDef>();
|
||||
vehicle->name = m_memory.Dup(assetName.c_str());
|
||||
|
||||
AssetRegistration<AssetVehicle> registration(assetName, vehicle);
|
||||
InfoStringToVehicleConverter converter(
|
||||
infoString, *vehicle, m_zone.m_script_strings, m_memory, context, registration, vehicle_fields, std::extent_v<decltype(vehicle_fields)>);
|
||||
if (!converter.Convert() || !LoadDependencies(*vehicle, context, registration))
|
||||
{
|
||||
con::error("Failed to parse vehicle: \"{}\"", assetName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
vehicle->vehPhysDef.topSpeed = vehicle->topSpeed;
|
||||
vehicle->vehPhysDef.suspensionTravelFront = vehicle->suspensionTravel;
|
||||
CreateSurfaceSounds(*vehicle, m_memory, context, registration);
|
||||
return AssetCreationResult::Success(context.AddAsset(std::move(registration)));
|
||||
}
|
||||
} // namespace vehicle
|
||||
@@ -0,0 +1,33 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/InfoStringLoaderVehicle" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set CLASS_NAME "InfoStringLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See InfoStringLoaderVehicle.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include GAME_HEADER
|
||||
#include "Asset/AssetCreationContext.h"
|
||||
#include "Asset/AssetRegistration.h"
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
class CLASS_NAME
|
||||
{
|
||||
public:
|
||||
CLASS_NAME(MemoryManager& memory, Zone& zone);
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, const InfoString& infoString, AssetCreationContext& context);
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace vehicle
|
||||
@@ -0,0 +1,65 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/RawLoaderVehicle" + GAME + ".cpp"
|
||||
|
||||
#set LOADER_HEADER "\"RawLoaderVehicle" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_HEADER "\"InfoStringLoaderVehicle" + GAME + ".h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set INFO_STRING_LOADER_NAME "InfoStringLoader" + GAME
|
||||
#set FACTORY_NAME "CreateRawLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See RawLoaderVehicle.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include LOADER_HEADER
|
||||
|
||||
#include INFO_STRING_LOADER_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include "InfoString/InfoString.h"
|
||||
#include "Utils/Logging/Log.h"
|
||||
#include "Vehicle/VehicleCommon.h"
|
||||
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
class RawLoaderVehicle final : public AssetCreator<AssetVehicle>
|
||||
{
|
||||
public:
|
||||
RawLoaderVehicle(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
: m_search_path(searchPath),
|
||||
m_info_string_loader(memory, zone)
|
||||
{
|
||||
}
|
||||
|
||||
AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override
|
||||
{
|
||||
const auto fileName = vehicle::GetFileNameForAssetName(assetName);
|
||||
const auto file = m_search_path.Open(fileName);
|
||||
if (!file.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
InfoString infoString;
|
||||
if (!infoString.FromStream(INFO_STRING_PREFIX_VEHICLE, *file.m_stream))
|
||||
{
|
||||
con::error("Could not parse as info string file: \"{}\"", fileName);
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
return m_info_string_loader.CreateAsset(assetName, infoString, context);
|
||||
}
|
||||
|
||||
private:
|
||||
ISearchPath& m_search_path;
|
||||
vehicle::INFO_STRING_LOADER_NAME m_info_string_loader;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetVehicle>> FACTORY_NAME(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<RawLoaderVehicle>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace vehicle
|
||||
@@ -0,0 +1,25 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/RawLoaderVehicle" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set FACTORY_NAME "CreateRawLoader" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See RawLoaderVehicle.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include GAME_HEADER
|
||||
#include "Asset/IAssetCreator.h"
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
#include "Zone/Zone.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
std::unique_ptr<AssetCreator<GAME::AssetVehicle>> FACTORY_NAME(MemoryManager& memory, ISearchPath& searchPath, Zone& zone);
|
||||
} // namespace vehicle
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Game/IW4/Techset/TechsetDumperIW4.h"
|
||||
#include "Game/IW4/Techset/VertexShaderDumperIW4.h"
|
||||
#include "Game/IW4/Tracer/TracerDumperIW4.h"
|
||||
#include "Game/IW4/Vehicle/VehicleDumperIW4.h"
|
||||
#include "Game/IW4/XAnim/XAnimDumperIW4.h"
|
||||
#include "Game/IW4/XModel/XModelDumperIW4.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW4.h"
|
||||
@@ -24,7 +25,6 @@
|
||||
#include "Sound/SndCurveDumperIW4.h"
|
||||
#include "StringTable/StringTableDumperIW4.h"
|
||||
#include "StructuredDataDef/StructuredDataDefDumperIW4.h"
|
||||
#include "Vehicle/VehicleDumperIW4.h"
|
||||
#include "Weapon/WeaponDumperIW4.h"
|
||||
|
||||
using namespace IW4;
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include "Game/IW4/IW4.h"
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
class DumperIW4 final : public AbstractAssetDumper<IW4::AssetVehicle>
|
||||
{
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<IW4::AssetVehicle::Type>& asset) override;
|
||||
};
|
||||
} // namespace vehicle
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Game/IW5/Techset/TechsetDumperIW5.h"
|
||||
#include "Game/IW5/Techset/VertexShaderDumperIW5.h"
|
||||
#include "Game/IW5/Tracer/TracerDumperIW5.h"
|
||||
#include "Game/IW5/Vehicle/VehicleDumperIW5.h"
|
||||
#include "Game/IW5/XModel/XModelDumperIW5.h"
|
||||
#include "Leaderboard/LeaderboardJsonDumperIW5.h"
|
||||
#include "LightDef/LightDefDumperIW5.h"
|
||||
@@ -71,6 +72,6 @@ void ObjWriter::RegisterAssetDumpers(AssetDumpingContext& context)
|
||||
RegisterAssetDumper(std::make_unique<leaderboard::JsonDumperIW5>());
|
||||
// REGISTER_DUMPER(AssetDumperStructuredDataDefSet)
|
||||
RegisterAssetDumper(std::make_unique<tracer::DumperIW5>());
|
||||
// REGISTER_DUMPER(AssetDumperVehicleDef)
|
||||
RegisterAssetDumper(std::make_unique<vehicle::DumperIW5>());
|
||||
RegisterAssetDumper(std::make_unique<addon_map_ents::DumperIW5>());
|
||||
}
|
||||
|
||||
+33
-8
@@ -1,17 +1,35 @@
|
||||
#include "VehicleDumperIW4.h"
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#include "Game/IW4/CommonIW4.h"
|
||||
#include "Game/IW4/InfoString/EnumStrings.h"
|
||||
#include "Game/IW4/InfoString/InfoStringFromStructConverter.h"
|
||||
#include "Game/IW4/ObjConstantsIW4.h"
|
||||
#include "Game/IW4/Vehicle/VehicleFields.h"
|
||||
#filename "Game/" + GAME + "/Vehicle/VehicleDumper" + GAME + ".cpp"
|
||||
|
||||
#set DUMPER_HEADER "\"VehicleDumper" + GAME + ".h\""
|
||||
#set INFO_STRING_CONVERTER_HEADER "\"Game/" + GAME + "/InfoString/InfoStringFromStructConverter.h\""
|
||||
#set OBJ_CONSTANTS_HEADER "\"Game/" + GAME + "/ObjConstants" + GAME + ".h\""
|
||||
#set VEHICLE_FIELDS_HEADER "\"Game/" + GAME + "/Vehicle/VehicleFields" + GAME + ".h\""
|
||||
#set VEHICLE_STRINGS_HEADER "\"Game/" + GAME + "/Vehicle/VehicleStrings" + GAME + ".h\""
|
||||
#set CLASS_NAME "Dumper" + GAME
|
||||
|
||||
#if GAME == "IW5"
|
||||
#define FEATURE_IW5
|
||||
#endif
|
||||
|
||||
// This file was templated.
|
||||
// See VehicleDumper.cpp.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#include DUMPER_HEADER
|
||||
|
||||
#include INFO_STRING_CONVERTER_HEADER
|
||||
#include OBJ_CONSTANTS_HEADER
|
||||
#include VEHICLE_FIELDS_HEADER
|
||||
#include VEHICLE_STRINGS_HEADER
|
||||
#include "Vehicle/VehicleCommon.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace IW4;
|
||||
using namespace GAME;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -56,6 +74,13 @@ namespace
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef FEATURE_IW5
|
||||
case VFT_CAM_Z_OFFSET_MODE:
|
||||
FillFromEnumInt(
|
||||
std::string(field.szName), field.iOffset, s_vehicleCameraZOffsetModeNames, std::extent_v<decltype(s_vehicleCameraZOffsetModeNames)>);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case VFT_NUM:
|
||||
default:
|
||||
assert(false);
|
||||
@@ -93,7 +118,7 @@ namespace
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
void DumperIW4::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetVehicle::Type>& asset)
|
||||
void CLASS_NAME::DumpAsset(AssetDumpingContext& context, const XAssetInfo<AssetVehicle::Type>& asset)
|
||||
{
|
||||
// Only dump raw when no gdt available
|
||||
if (context.m_gdt)
|
||||
@@ -0,0 +1,24 @@
|
||||
#options GAME(IW4, IW5)
|
||||
|
||||
#filename "Game/" + GAME + "/Vehicle/VehicleDumper" + GAME + ".h"
|
||||
|
||||
#set GAME_HEADER "\"Game/" + GAME + "/" + GAME + ".h\""
|
||||
#set CLASS_NAME "Dumper" + GAME
|
||||
|
||||
// This file was templated.
|
||||
// See VehicleDumper.h.template.
|
||||
// Do not modify, changes will be lost.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Dumping/AbstractAssetDumper.h"
|
||||
#include GAME_HEADER
|
||||
|
||||
namespace vehicle
|
||||
{
|
||||
class CLASS_NAME final : public AbstractAssetDumper<GAME::AssetVehicle>
|
||||
{
|
||||
protected:
|
||||
void DumpAsset(AssetDumpingContext& context, const XAssetInfo<GAME::AssetVehicle::Type>& asset) override;
|
||||
};
|
||||
} // namespace vehicle
|
||||
Reference in New Issue
Block a user