PSF-LoginServer/common/src/test/scala/game/BindPlayerMessageTest.scala

108 lines
3.4 KiB
Scala
Raw Normal View History

2017-03-06 19:30:45 -05:00
// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
import net.psforever.types.{SpawnGroup, Vector3}
import scodec.bits._
class BindPlayerMessageTest extends Specification {
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
val string_standard = hex"16028004000000000000000000000000000000"
val string_ams = hex"16 05 8440616D73 08 28000000 00000000 00000 00000 0000"
val string_tech = hex"16 01 8b40746563685f706c616e74 d4 28000000 38000000 00064 012b1 a044"
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
val string_akkan = hex"16048440616d7388100000001400000214e171a8e33024"
"decode (standard)" in {
PacketCoding.DecodePacket(string_standard).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Unbind
bindDesc mustEqual ""
unk1 mustEqual false
logging mustEqual false
unk2 mustEqual SpawnGroup.BoundAMS
unk3 mustEqual 0
unk4 mustEqual 0
pos mustEqual Vector3.Zero
case _ =>
ko
}
}
"decode (ams)" in {
PacketCoding.DecodePacket(string_ams).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
action mustEqual BindStatus.Unavailable
bindDesc mustEqual "@ams"
unk1 mustEqual false
logging mustEqual false
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
unk2 mustEqual SpawnGroup.AMS
unk3 mustEqual 10
unk4 mustEqual 0
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
pos mustEqual Vector3.Zero
case _ =>
ko
}
}
"decode (tech)" in {
PacketCoding.DecodePacket(string_tech).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
action mustEqual BindStatus.Bind
bindDesc mustEqual "@tech_plant"
unk1 mustEqual true
logging mustEqual true
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
unk2 mustEqual SpawnGroup.BoundFacility
unk3 mustEqual 10
unk4 mustEqual 14
pos mustEqual Vector3(4610.0f, 6292, 69.625f)
case _ =>
ko
}
}
"decode (akkan)" in {
PacketCoding.DecodePacket(string_akkan).require match {
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
action mustEqual BindStatus.Available
bindDesc mustEqual "@ams"
unk1 mustEqual true
logging mustEqual false
unk2 mustEqual SpawnGroup.AMS
unk3 mustEqual 4
unk4 mustEqual 5
pos mustEqual Vector3(2673.039f, 4423.547f, 39.1875f)
case _ =>
ko
}
}
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
"encode (standard)" in {
val msg = BindPlayerMessage.Standard
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_standard
}
"encode (ams)" in {
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
val msg = BindPlayerMessage(BindStatus.Unavailable, "@ams", false, false, SpawnGroup.AMS, 10, 0, Vector3.Zero)
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_ams
}
"encode (tech)" in {
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
val msg = BindPlayerMessage(BindStatus.Bind, "@tech_plant", true, true, SpawnGroup.BoundFacility, 10, 14, Vector3(4610.0f, 6292, 69.625f))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
pkt mustEqual string_tech
}
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
"encode (akkan)" in {
val msg = BindPlayerMessage(BindStatus.Available, "@ams", true, false, SpawnGroup.AMS, 4, 5, Vector3(2673.039f, 4423.547f, 39.1875f))
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
Damage Fix, and Stuff (#235) * redid splash damage radial degrade calculations; lasher damage fixed to 6/0 or 2/4 depending on armor; fixed direct hit distance for weapons that act like slash weapons; gave Falcon a valid projectile * delayed resource silo startup to avoid crash; discovered issue with MAX armor resulting from incorrect manipulation of inventory items during suit transfer * modifications to consider a specific modifier that exists on some vehicles and armored equipment called Subtract, a DamageProfile that reduces damage due to a set flag; manually controlling damage tick marks rather than relying only on HitHint (from client) * Tools now have default firemodes (temporary?); ammo gotten from loadouts is always full; loadouts and exo-suits juggle armor values differently on being changed; log messages for damage to players and vehicles * weapons with one (last) shot need support communicating that one (last) shot * fixing tests * correcting the codec for BindPlayerMessage * changed wording that identifies the damage log entries * switching exosuit no longer causes butterfingers * extending exosuit swap armor value changes to infantry loadout changes * ranges removed from non-vehicle containers * enabled partial damage functionality to facility turrets * BindPlayerMessage replacing BattleplanMessage for purposes of depicting the closest AMS spawn point; specific enums in relation to spawning in BPM and SpawnRequestMessage * rewrote exo-suit switching and loadout switching code, paying extra-special attention for the needs of MAX's * quick amendment for previous commit * switching from mount point check to seat checks in VehicleRemover; started refactoring of Cargo functions before realizing how complicated the full effort would be, so these changes are merely wrapping object identification by GUID * adding a minor server delay to terminal operations
2018-11-21 20:31:51 -05:00
pkt mustEqual string_akkan
}
}