Skip to content

Commit

Permalink
Merge pull request #36 from tfausak/gh-35-dropshot
Browse files Browse the repository at this point in the history
Handle Dropshot replays
  • Loading branch information
tfausak authored Mar 24, 2017
2 parents d891865 + d14afa1 commit 6664c2f
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 6 deletions.
Binary file not shown.
33 changes: 33 additions & 0 deletions source/library/Rattletrap/Attribute/AppliedDamage.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Rattletrap.Attribute.AppliedDamage where

import Rattletrap.Primitive

import qualified Data.Binary.Bits.Get as BinaryBit
import qualified Data.Binary.Bits.Put as BinaryBit

data AppliedDamageAttribute = AppliedDamageAttribute
{ appliedDamageAttributeUnknown1 :: Word8
, appliedDamageAttributeLocation :: Vector
, appliedDamageAttributeUnknown3 :: Int32
, appliedDamageAttributeUnknown4 :: Int32
} deriving (Eq, Ord, Show)

getAppliedDamageAttribute :: BinaryBit.BitGet AppliedDamageAttribute
getAppliedDamageAttribute = do
unknown1 <- getWord8Bits
location <- getVector
unknown3 <- getInt32Bits
unknown4 <- getInt32Bits
pure
(AppliedDamageAttribute
unknown1
location
unknown3
unknown4)

putAppliedDamageAttribute :: AppliedDamageAttribute -> BinaryBit.BitPut ()
putAppliedDamageAttribute appliedDamageAttribute = do
putWord8Bits (appliedDamageAttributeUnknown1 appliedDamageAttribute)
putVector (appliedDamageAttributeLocation appliedDamageAttribute)
putInt32Bits (appliedDamageAttributeUnknown3 appliedDamageAttribute)
putInt32Bits (appliedDamageAttributeUnknown4 appliedDamageAttribute)
41 changes: 41 additions & 0 deletions source/library/Rattletrap/Attribute/DamageState.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Rattletrap.Attribute.DamageState where

import Rattletrap.Primitive

import qualified Data.Binary.Bits.Get as BinaryBit
import qualified Data.Binary.Bits.Put as BinaryBit

data DamageStateAttribute = DamageStateAttribute
{ damageStateAttributeUnknown1 :: Word8
, damageStateAttributeUnknown2 :: Bool
, damageStateAttributeUnknown3 :: Int32
, damageStateAttributeUnknown4 :: Vector
, damageStateAttributeUnknown5 :: Bool
, damageStateAttributeUnknown6 :: Bool
} deriving (Eq, Ord, Show)

getDamageStateAttribute :: BinaryBit.BitGet DamageStateAttribute
getDamageStateAttribute = do
unknown1 <- getWord8Bits
unknown2 <- BinaryBit.getBool
unknown3 <- getInt32Bits
unknown4 <- getVector
unknown5 <- BinaryBit.getBool
unknown6 <- BinaryBit.getBool
pure
(DamageStateAttribute
unknown1
unknown2
unknown3
unknown4
unknown5
unknown6)

putDamageStateAttribute :: DamageStateAttribute -> BinaryBit.BitPut ()
putDamageStateAttribute damageStateAttribute = do
putWord8Bits (damageStateAttributeUnknown1 damageStateAttribute)
BinaryBit.putBool (damageStateAttributeUnknown2 damageStateAttribute)
putInt32Bits (damageStateAttributeUnknown3 damageStateAttribute)
putVector (damageStateAttributeUnknown4 damageStateAttribute)
BinaryBit.putBool (damageStateAttributeUnknown5 damageStateAttribute)
BinaryBit.putBool (damageStateAttributeUnknown6 damageStateAttribute)
4 changes: 3 additions & 1 deletion source/library/Rattletrap/AttributeType.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module Rattletrap.AttributeType where

data AttributeType
= BooleanAttributeType
= AppliedDamageAttributeType
| BooleanAttributeType
| ByteAttributeType
| CamSettingsAttributeType
| ClubColorsAttributeType
| DamageStateAttributeType
| DemolishAttributeType
| EnumAttributeType
| ExplosionAttributeType
Expand Down
16 changes: 15 additions & 1 deletion source/library/Rattletrap/AttributeValue.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module Rattletrap.AttributeValue
( module Rattletrap.AttributeValue
, module Rattletrap.Attribute.AppliedDamage
, module Rattletrap.Attribute.Boolean
, module Rattletrap.Attribute.Byte
, module Rattletrap.Attribute.CamSettings
, module Rattletrap.Attribute.ClubColors
, module Rattletrap.Attribute.DamageState
, module Rattletrap.Attribute.Demolish
, module Rattletrap.Attribute.Enum
, module Rattletrap.Attribute.Explosion
Expand All @@ -29,10 +31,12 @@ module Rattletrap.AttributeValue
, module Rattletrap.Attribute.WeldedInfo
) where

import Rattletrap.Attribute.AppliedDamage
import Rattletrap.Attribute.Boolean
import Rattletrap.Attribute.Byte
import Rattletrap.Attribute.CamSettings
import Rattletrap.Attribute.ClubColors
import Rattletrap.Attribute.DamageState
import Rattletrap.Attribute.Demolish
import Rattletrap.Attribute.Enum
import Rattletrap.Attribute.Explosion
Expand Down Expand Up @@ -65,10 +69,12 @@ import qualified Data.Binary.Bits.Put as BinaryBit
import qualified Data.Map.Strict as Map

data AttributeValue
= BooleanAttributeValue BooleanAttribute
= AppliedDamageAttributeValue AppliedDamageAttribute
| BooleanAttributeValue BooleanAttribute
| ByteAttributeValue ByteAttribute
| CamSettingsAttributeValue CamSettingsAttribute
| ClubColorsAttributeValue ClubColorsAttribute
| DamageStateAttributeValue DamageStateAttribute
| DemolishAttributeValue DemolishAttribute
| EnumAttributeValue EnumAttribute
| ExplosionAttributeValue ExplosionAttribute
Expand Down Expand Up @@ -99,6 +105,9 @@ getAttributeValue version name =
case Map.lookup name attributeTypes of
Just constructor ->
case constructor of
AppliedDamageAttributeType -> do
x <- getAppliedDamageAttribute
pure (AppliedDamageAttributeValue x)
BooleanAttributeType -> do
x <- getBooleanAttribute
pure (BooleanAttributeValue x)
Expand All @@ -111,6 +120,9 @@ getAttributeValue version name =
ClubColorsAttributeType -> do
x <- getClubColorsAttribute
pure (ClubColorsAttributeValue x)
DamageStateAttributeType -> do
x <- getDamageStateAttribute
pure (DamageStateAttributeValue x)
DemolishAttributeType -> do
x <- getDemolishAttribute
pure (DemolishAttributeValue x)
Expand Down Expand Up @@ -188,10 +200,12 @@ attributeTypes = Map.mapKeys stringToText (Map.fromList rawAttributeTypes)
putAttributeValue :: AttributeValue -> BinaryBit.BitPut ()
putAttributeValue value =
case value of
AppliedDamageAttributeValue x -> putAppliedDamageAttribute x
BooleanAttributeValue x -> putBooleanAttribute x
ByteAttributeValue x -> putByteAttribute x
CamSettingsAttributeValue x -> putCamSettingsAttribute x
ClubColorsAttributeValue x -> putClubColorsAttribute x
DamageStateAttributeValue x -> putDamageStateAttribute x
DemolishAttributeValue x -> putDemolishAttribute x
EnumAttributeValue x -> putEnumAttribute x
ExplosionAttributeValue x -> putExplosionAttribute x
Expand Down
5 changes: 4 additions & 1 deletion source/library/Rattletrap/ClassAttributeMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ normalizeObjectName objectName =
crowdManager = Text.pack "TheWorld:PersistentLevel.CrowdManager_TA"
boostPickup = Text.pack "TheWorld:PersistentLevel.VehiclePickup_Boost_TA"
mapScoreboard = Text.pack "TheWorld:PersistentLevel.InMapScoreboard_TA"
breakout = Text.pack "TheWorld:PersistentLevel.BreakOutActor_Platform_TA"
in if Text.isInfixOf crowdActor name
then Text crowdActor
else if Text.isInfixOf crowdManager name
Expand All @@ -243,7 +244,9 @@ normalizeObjectName objectName =
then Text boostPickup
else if Text.isInfixOf mapScoreboard name
then Text mapScoreboard
else objectName
else if Text.isInfixOf breakout name
then Text breakout
else objectName

objectClasses :: Map.Map Text Text
objectClasses =
Expand Down
15 changes: 13 additions & 2 deletions source/library/Rattletrap/Data.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ rawParentClasses =

rawClassesWithLocation :: [String]
rawClassesWithLocation =
[ "TAGame.Ball_TA"
[ "TAGame.Ball_Breakout_TA"
, "TAGame.Ball_TA"
, "TAGame.CameraSettingsActor_TA"
, "TAGame.Car_Season_TA"
, "TAGame.Car_TA"
Expand Down Expand Up @@ -91,7 +92,8 @@ rawClassesWithLocation =

rawClassesWithRotation :: [String]
rawClassesWithRotation =
[ "TAGame.Ball_TA"
[ "TAGame.Ball_Breakout_TA"
, "TAGame.Ball_TA"
, "TAGame.Car_Season_TA"
, "TAGame.Car_TA"
]
Expand All @@ -100,6 +102,7 @@ rawObjectClasses :: [(String, String)]
rawObjectClasses =
[ ("Archetypes.Ball.Ball_BasketBall_Mutator", "TAGame.Ball_TA")
, ("Archetypes.Ball.Ball_Basketball", "TAGame.Ball_TA")
, ("Archetypes.Ball.Ball_Breakout", "TAGame.Ball_Breakout_TA")
, ("Archetypes.Ball.Ball_Default", "TAGame.Ball_TA")
, ("Archetypes.Ball.Ball_Puck", "TAGame.Ball_TA")
, ("Archetypes.Ball.CubeBall", "TAGame.Ball_TA")
Expand All @@ -112,6 +115,7 @@ rawObjectClasses =
, ("Archetypes.GameEvent.GameEvent_Basketball", "TAGame.GameEvent_Soccar_TA")
, ("Archetypes.GameEvent.GameEvent_BasketballPrivate", "TAGame.GameEvent_SoccarPrivate_TA")
, ("Archetypes.GameEvent.GameEvent_BasketballSplitscreen", "TAGame.GameEvent_SoccarSplitscreen_TA")
, ("Archetypes.GameEvent.GameEvent_Breakout", "TAGame.GameEvent_Soccar_TA")
, ("Archetypes.GameEvent.GameEvent_Hockey", "TAGame.GameEvent_Soccar_TA")
, ("Archetypes.GameEvent.GameEvent_HockeyPrivate", "TAGame.GameEvent_SoccarPrivate_TA")
, ("Archetypes.GameEvent.GameEvent_HockeySplitscreen", "TAGame.GameEvent_SoccarSplitscreen_TA")
Expand All @@ -136,12 +140,14 @@ rawObjectClasses =
, ("Archetypes.Teams.Team0", "TAGame.Team_Soccar_TA")
, ("Archetypes.Teams.Team1", "TAGame.Team_Soccar_TA")
, ("GameInfo_Basketball.GameInfo.GameInfo_Basketball:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("GameInfo_Breakout.GameInfo.GameInfo_Breakout:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("Gameinfo_Hockey.GameInfo.Gameinfo_Hockey:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("GameInfo_Items.GameInfo.GameInfo_Items:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("GameInfo_Season.GameInfo.GameInfo_Season:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("GameInfo_Soccar.GameInfo.GameInfo_Soccar:GameReplicationInfoArchetype", "TAGame.GRI_TA")
, ("TAGame.Default__CameraSettingsActor_TA", "TAGame.CameraSettingsActor_TA")
, ("TAGame.Default__PRI_TA", "TAGame.PRI_TA")
, ("TheWorld:PersistentLevel.BreakOutActor_Platform_TA", "TAGame.BreakOutActor_Platform_TA")
, ("TheWorld:PersistentLevel.CrowdActor_TA", "TAGame.CrowdActor_TA")
, ("TheWorld:PersistentLevel.CrowdManager_TA", "TAGame.CrowdManager_TA")
, ("TheWorld:PersistentLevel.InMapScoreboard_TA", "TAGame.InMapScoreboard_TA")
Expand Down Expand Up @@ -176,13 +182,17 @@ rawAttributeTypes =
, ("ProjectX.GRI_X:ReplicatedGameMutatorIndex", IntAttributeType)
, ("ProjectX.GRI_X:ReplicatedGamePlaylist", IntAttributeType)
, ("ProjectX.GRI_X:Reservations", ReservationAttributeType)
, ("TAGame.Ball_Breakout_TA:AppliedDamage", AppliedDamageAttributeType)
, ("TAGame.Ball_Breakout_TA:DamageIndex", IntAttributeType)
, ("TAGame.Ball_Breakout_TA:LastTeamTouch", ByteAttributeType)
, ("TAGame.Ball_TA:GameEvent", FlaggedIntAttributeType)
, ("TAGame.Ball_TA:HitTeamNum", ByteAttributeType)
, ("TAGame.Ball_TA:ReplicatedAddedCarBounceScale", FloatAttributeType)
, ("TAGame.Ball_TA:ReplicatedBallMaxLinearSpeedScale", FloatAttributeType)
, ("TAGame.Ball_TA:ReplicatedBallScale", FloatAttributeType)
, ("TAGame.Ball_TA:ReplicatedExplosionData", ExplosionAttributeType)
, ("TAGame.Ball_TA:ReplicatedWorldBounceScale", FloatAttributeType)
, ("TAGame.BreakOutActor_Platform_TA:DamageState", DamageStateAttributeType)
, ("TAGame.CameraSettingsActor_TA:bUsingBehindView", BooleanAttributeType)
, ("TAGame.CameraSettingsActor_TA:bUsingSecondaryCamera", BooleanAttributeType)
, ("TAGame.CameraSettingsActor_TA:CameraPitch", ByteAttributeType)
Expand Down Expand Up @@ -250,6 +260,7 @@ rawAttributeTypes =
, ("TAGame.PRI_TA:ClientLoadouts", LoadoutsAttributeType)
, ("TAGame.PRI_TA:ClientLoadoutsOnline", LoadoutsOnlineAttributeType)
, ("TAGame.PRI_TA:MatchAssists", IntAttributeType)
, ("TAGame.PRI_TA:MatchBreakoutDamage", IntAttributeType)
, ("TAGame.PRI_TA:MatchGoals", IntAttributeType)
, ("TAGame.PRI_TA:MatchSaves", IntAttributeType)
, ("TAGame.PRI_TA:MatchScore", IntAttributeType)
Expand Down
4 changes: 3 additions & 1 deletion source/library/Rattletrap/Json.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ $(let optionsFor name =
newDeclarations <- Aeson.deriveJSON (optionsFor name) name
pure (newDeclarations ++ declarations)
names =
[ ''Attribute
[ ''AppliedDamageAttribute
, ''Attribute
, ''AttributeMapping
, ''AttributeValue
, ''BooleanAttribute
Expand All @@ -51,6 +52,7 @@ $(let optionsFor name =
, ''CompressedWord
, ''CompressedWordVector
, ''Content
, ''DamageStateAttribute
, ''DemolishAttribute
, ''DestroyedReplication
, ''Dictionary
Expand Down
1 change: 1 addition & 0 deletions source/tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ replays =
, ("1EF90FCC4F719F606A5327B3CDD782A4", "a private hoops match")
, ("1F3798E540B0C37A946561ABBB3037F9", "splitscreen players")
, ("211466D04B983F5A33CC2FA1D5928672", "a match save")
, ("22660E3649FC7971E5653692473D4318", "dropshot")
, ("22BACD794ABE7B92E50E9CBDBD9C59CE", "a vote to forfeit")
, ("27B6A7B64553F0F685874584F96BAB1B", "some UTF-16 text")
, ("29F582C34A65EB34D358A784CBE3C189", "frames")
Expand Down

0 comments on commit 6664c2f

Please sign in to comment.