Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions crates/analysis/tests/spec/WeaponValues.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Object LaserObject
End

Weapon ValidWeapon
LaserName = LaserObject
LaserBoneName = WeaponA
DamageStatusType = BURNED
RadiusDamageAffects = SELF ALLIES NOT_AIRBORNE
ProjectileCollidesWith = ALLIES PROJECTILES CONTROLLED_STRUCTURES
AntiAirborneVehicle = Yes
AntiGround = Yes
AntiProjectile = No
AntiSmallMissile = No
AntiMine = No
AntiParachute = No
AntiAirborneInfantry = Yes
AntiBallisticMissile = No
DelayBetweenShots = 500
DelayBetweenShots = Min:100 Max:200
WeaponBonus = GARRISONED DAMAGE 125%
End

Weapon InvalidWeapon
LaserName = MissingLaser
DamageStatusType = CRANKY
RadiusDamageAffects = FRIENDS
ProjectileCollidesWith = CIVILIANS
AntiAirborneVehicle = Maybe
DelayBetweenShots = eventually
WeaponBonus = SOMETIMES POWER lots
End
44 changes: 44 additions & 0 deletions crates/analysis/tests/spec/WeaponValues.spec.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[[diag]]
severity = "warning"
code = "unresolved-reference"
on = "MissingLaser"

[[diag]]
severity = "error"
code = "bad-enum"
on = "CRANKY"

[[diag]]
severity = "error"
code = "bad-flag"
on = "FRIENDS"

[[diag]]
severity = "error"
code = "bad-flag"
on = "CIVILIANS"

[[diag]]
severity = "error"
code = "bad-bool"
on = "Maybe"

[[diag]]
severity = "error"
code = "bad-number"
on = "eventually"

[[diag]]
severity = "error"
code = "bad-enum"
on = "SOMETIMES"

[[diag]]
severity = "error"
code = "bad-enum"
on = "POWER"

[[diag]]
severity = "error"
code = "bad-percent"
on = "lots"
152 changes: 124 additions & 28 deletions crates/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16021,7 +16021,8 @@
{
"name": "LaserName",
"value_type": {
"kind": "ascii_string"
"kind": "reference",
"ref_kind": "object"
},
"parse_fn": "INI::parseAsciiString",
"doc": null
Expand All @@ -16032,7 +16033,7 @@
"kind": "ascii_string"
},
"parse_fn": "INI::parseAsciiString",
"doc": null
"doc": "Bone on the firing object's model; a shared Weapon template does not identify that object statically."
},
{
"name": "LeechRangeWeapon",
Expand Down Expand Up @@ -16150,8 +16151,8 @@
{
"name": "DamageStatusType",
"value_type": {
"kind": "unknown",
"parse_fn": "ObjectStatusMaskType::parseSingleBitFromINI"
"kind": "enum",
"value_set": "object_status"
},
"parse_fn": "ObjectStatusMaskType::parseSingleBitFromINI",
"doc": null
Expand Down Expand Up @@ -16294,98 +16295,113 @@
{
"name": "DelayBetweenShots",
"value_type": {
"kind": "unknown",
"parse_fn": "WeaponTemplate::parseShotDelay"
"kind": "one_of",
"variants": [
{
"kind": "duration"
},
{
"kind": "token_list",
"tokens": [
{
"kind": "prefixed",
"prefix": "Min",
"value_type": {
"kind": "duration"
}
},
{
"kind": "prefixed",
"prefix": "Max",
"value_type": {
"kind": "duration"
}
}
]
}
]
},
"parse_fn": "WeaponTemplate::parseShotDelay",
"doc": null
},
{
"name": "RadiusDamageAffects",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitString32"
"kind": "bit_flags",
"value_set": "weapon_affects"
},
"parse_fn": "INI::parseBitString32",
"doc": null
},
{
"name": "ProjectileCollidesWith",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitString32"
"kind": "bit_flags",
"value_set": "weapon_collide"
},
"parse_fn": "INI::parseBitString32",
"doc": null
},
{
"name": "AntiAirborneVehicle",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiGround",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiProjectile",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiSmallMissile",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiMine",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiParachute",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiAirborneInfantry",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
},
{
"name": "AntiBallisticMissile",
"value_type": {
"kind": "unknown",
"parse_fn": "INI::parseBitInInt32"
"kind": "bool"
},
"parse_fn": "INI::parseBitInInt32",
"doc": null
Expand All @@ -16402,8 +16418,20 @@
{
"name": "WeaponBonus",
"value_type": {
"kind": "unknown",
"parse_fn": "WeaponTemplate::parseWeaponBonusSet"
"kind": "token_list",
"tokens": [
{
"kind": "enum",
"value_set": "weapon_bonus_condition"
},
{
"kind": "enum",
"value_set": "weapon_bonus_field"
},
{
"kind": "percent"
}
]
},
"parse_fn": "WeaponTemplate::parseWeaponBonusSet",
"doc": null
Expand Down Expand Up @@ -67985,6 +68013,32 @@
],
"doc": "TheWeaponBonusNames (Weapon.h)"
},
{
"id": "weapon_bonus_field",
"members": [
{
"name": "DAMAGE",
"value": 0
},
{
"name": "RADIUS",
"value": 1
},
{
"name": "RANGE",
"value": 2
},
{
"name": "RATE_OF_FIRE",
"value": 3
},
{
"name": "PRE_ATTACK",
"value": 4
}
],
"doc": "TheWeaponBonusFieldNames (Weapon.h)"
},
{
"id": "ocl_create_location",
"members": [
Expand Down Expand Up @@ -69446,6 +69500,48 @@
}
]
},
{
"id": "weapon_collide",
"members": [
{
"name": "ALLIES",
"value": 0
},
{
"name": "ENEMIES",
"value": 1
},
{
"name": "STRUCTURES",
"value": 2
},
{
"name": "SHRUBBERY",
"value": 3
},
{
"name": "PROJECTILES",
"value": 4
},
{
"name": "WALLS",
"value": 5
},
{
"name": "SMALL_MISSILES",
"value": 6
},
{
"name": "BALLISTIC_MISSILES",
"value": 7
},
{
"name": "CONTROLLED_STRUCTURES",
"value": 8
}
],
"doc": "TheWeaponCollideMaskNames (Weapon.h)"
},
{
"id": "terrain_class",
"members": [
Expand Down
19 changes: 19 additions & 0 deletions crates/schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,25 @@ mod tests {
}
}

#[test]
fn weapon_fields_have_concrete_value_types() {
let schema = embedded();
let weapon = schema
.index()
.block("Weapon")
.expect("Weapon block missing");
for field in &weapon.fields {
assert!(
!contains(&field.value_type, |ty| matches!(
ty,
ValueType::Unknown { .. }
)),
"Weapon.{} still has an unknown value type",
field.name
);
}
}

#[test]
fn object_backed_module_fields_are_object_references() {
let schema = embedded();
Expand Down