Skip to content

Commit

Permalink
First RocketAnalytics Release version
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldoylecs committed Aug 26, 2018
2 parents d7041f8 + 7445967 commit b711682
Show file tree
Hide file tree
Showing 48 changed files with 19,840 additions and 1,941 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Checks: '*,-fuchsia-default-arguments,-fuchsia-overloaded-operator,-google-runtime-references'
FormatStyle: 'llvm'
39 changes: 25 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Initial CMake configurations
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)
endif()

# CMakeLists for RocketAnalytics
cmake_minimum_required (VERSION 3.9)
project (
RocketAnalyticsLib
RocketAnalytics
VERSION 0.2
DESCRIPTION "Rocket League replay parsing library"
)
Expand Down Expand Up @@ -49,45 +49,56 @@ if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories ("${gtest_SOURCE_DIR}/include")
endif ()

# Compiler flags
# set (CMAKE_CXX_FLAGS
# "-std=c++14 -Wall -Wextra -Wpedantic -Wzero-as-null-pointer-constant"
# )

# Configure RocketAnalyticsLib Build
add_library (RocketAnalyticsLib
add_library (RocketAnalytics
"RocketAnalyticsLib/src/BinaryReader.cpp"
"RocketAnalyticsLib/src/Byte.cpp"
"RocketAnalyticsLib/src/ClassNetCacheObject.cpp"
"RocketAnalyticsLib/src/Keyframe.cpp"
"RocketAnalyticsLib/src/Netstream.cpp"
"RocketAnalyticsLib/src/ReplayFile.cpp"
"RocketAnalyticsLib/src/ReplayFileReader.cpp"
"RocketAnalyticsLib/src/ReplayHeader.cpp"
"RocketAnalyticsLib/src/ReplayLevels.cpp"
"RocketAnalyticsLib/src/ReplayTick.cpp"
"RocketAnalyticsLib/src/RocketAnalytics.cpp"
"RocketAnalyticsLib/src/Version.cpp"
"RocketAnalyticsLib/src/properties/ByteValue.cpp"
"RocketAnalyticsLib/src/properties/Property.cpp"
"RocketAnalyticsLib/src/properties/PropertyType.cpp"
"RocketAnalyticsLib/src/properties/PropertyValue.cpp"
)

# TODO: Add public interface header
# RocketAnalyticsLib header files
target_include_directories (RocketAnalyticsLib
target_include_directories (RocketAnalytics
PRIVATE
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include
${PROJECT_SOURCE_DIR}/RocketAnalyticsLib/include/properties
)

# RocketAnalyticsLib properties
set_target_properties (RocketAnalyticsLib PROPERTIES
set_target_properties (RocketAnalytics PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD_REQUIRED 17
CXX_STANDARD_REQUIRED ON
)

# Configure RocketAnalytics Test Application
add_executable (RocketAnalyticsApp
"RocketAnalyticsApp/src/RocketAnalyticsApp.cpp"
)

set_target_properties (RocketAnalyticsApp PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD_REQUIRED 17
CXX_STANDARD_REQUIRED ON
)

target_link_libraries (RocketAnalyticsApp RocketAnalytics)

# Configure Tests Build
add_executable (unitTests
"RocketAnalyticsTests/src/BinaryReaderTests.cpp"
"RocketAnalyticsTests/src/ByteTests.cpp"
"RocketAnalyticsTests/src/KeyframeTests.cpp"
"RocketAnalyticsTests/src/ReplayHeaderTests.cpp"
"RocketAnalyticsTests/src/RocketAnalyticsTests.cpp"
"RocketAnalyticsTests/src/VersionTests.cpp"
Expand All @@ -97,7 +108,7 @@ add_executable (unitTests
"RocketAnalyticsTests/src/properties/PropertyValueTests.cpp"
)

target_link_libraries (unitTests gtest gmock_main RocketAnalyticsLib)
target_link_libraries (unitTests gtest gmock_main RocketAnalytics)

# Tests header files
target_include_directories (unitTests
Expand Down
149 changes: 147 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,148 @@
# RocketAnalytics
This Rocket League Replay Parser is in very early development. If you are
interested in the project, please come back at another time.
> Parse Rocket League replay files *fast*.
RocketAnalytics is a Rocket League replay parsing static library. The goal of
this library is to enable the ability to parse large quantities of replay
files as fast as possible for statistical analysis purposes. This library
would not have been possible if it were not for the hard work of the people
found in [this thread](https://www.psyonix.com/forum/viewtopic.php?f=33&t=13656)
on the offical Rocket League forums. Thank you very much for your hard work.

## Installation
There are two ways to access the library: downloading a release version, or
building the library from source.

### Release Version
Library releases are tagged and released
[here](https://github.com/michaeldoylecs/RocketAnalytics/releases).

### Source building
*Requires CMake 3.6+*

Create a `build` directory in the root of the project folder:

```sh
$ mkdir build
```

Enter the `build` directory and type the following commands to create the make
file and build the project:

```sh
$ cmake ..
$ make
```

This will create a few relevant files (among some less relevant ones):
* `libRocketAnalytics` - The Rocket League parsing library
* `unitTests` - The unitTests for libRocketAnalytics using gtest
* `RocketAnalyticsApp` - A small app I use to test replay output

The most important of these is `libRocketAnalytics`, which you will use along
with the header files located in `RocketAnalyticsLib/include` to utitize the
library.

*Note: This library is currently only tested on Arch Linux, please report any
issues in building or using on alternate systems.*

## Usage
The library is contained inside of the `rocketanalytics` namespace. The only
header file that needs to be included is `RocketAnalytics.hpp`. It contains
all of the necessary implementations to handle the replay file parsing.

Starting out, parsing a replay is very simple. All we need to do is give
the `ReplayFile` constructor a valid path to a replay file.

```cpp
#include "../include/RocketAnalytics.hpp" // Include the header file
#include <string> // (And the necessary STL headers)

int main() {
std::string filename = "rocketleague.replay"; // An absolute or relative replay filepath.
auto replay = rocketanalytics::ReplayFile(filename); // Open and parse the replay file.
return 0;
}
```

We now have a parsed replay file. So, what can we do with it? We can access
individual parts of the replay, or we can serialize the whole thing to JSON.
An example of the JSON output can be found
[here](https://gist.github.com/michaeldoylecs/55b8c9fce9d9370adb95b4c2a58ae134).

```cpp
#include "../include/RocketAnalytics.hpp" // Include the header file
#include <iostream> //
#include <string> // (And the necessary STL headers)

int main() {
std::string filename = "rocketleague.replay"; // An absolute or relative replay filepath.
auto replay = rocketanalytics::ReplayFile(filename); // Open and parse the replay file.

auto replay_header = replay.header(); // Get replay header information
auto replay_keyframes = replay.keyframes(); // Get replay keyframe information
std::cout << replay.serialize_to_json() << std::endl; // Print the replay JSON to standard output
return 0;
}
```

Now we know how to get information out of the replay, but there is one last
important thing. Parsing a replay (or opening a file) can fail. Thus, we need
to include exception handling.

```cpp
#include "../include/RocketAnalytics.hpp" // Include the header file
#include <iostream> //
#include <string> // (And the necessary STL headers)

int main() {
try {
std::string filename = "rocketleague.replay"; // An absolute or relative replay filepath.
auto replay = rocketanalytics::ReplayFile(filename); // Open and parse the replay file.
std::cout << replay.serialize_to_json() << std::endl; // Send the parsed information to standard output
return 0;
} catch (const std::runtime_error& e) {
std::cout << "Replay file failed to parse" << std::endl;
}
}
```

## Features

Does the library currently support a specific feature? Lets finds out!

| Does it parse... | Answer |
| ------------------- |:------------------:|
| Header CRC | YES |
| Replay version | YES |
| Replay ID | YES |
| Replay Properties | YES |
| Body CRC | YES |
| Levels | YES |
| Keyframes | YES |
| Netstream | **NO**<sup>1</sup> |
| Tick Information | YES |
| Replicated Packages | YES |
| Object Table | YES |
| Name Table | YES |
| Class Index Map | YES |
| Class Net Cache | YES |

| Can it... | Answer |
| ---------------------- |:------:|
| Verify header CRC | **NO** |
| Verify Body CRC | **NO** |
| Parse Netstream frames | **NO** |

*<sup>1</sup> Netstream byte data is accessible, but individual frames are not
parsed.*

The function signatures for a ReplayFile can be found in
`include/ReplayFile.hpp`. Additional function signatures for class-specific
values returned from a ReplayFile can also be found in their respective header
files (e.g. `ReplayHeader.hpp`, `Keyframe.hpp`, `ReplayTick.hpp`,
`ClassNetCacheObject.hpp`, etc).

## Issues
If you have any issues, please open a ticket
[here](https://github.com/michaeldoylecs/RocketAnalytics/issues). These could
be, but is not limited to, technical issues or feature requests.
Loading

0 comments on commit b711682

Please sign in to comment.