Skip to content

Commit

Permalink
Utilize diff-compressed scores.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebarlas committed May 8, 2024
1 parent e55e11d commit 5e38ad9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/net/Score.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,18 @@ namespace trippin {
}
};

inline void to_json(nlohmann::json& j, const Score& score) {
inline void to_json(nlohmann::json &j, const Score &score) {
j = score.to_json();
}

// this function assumes diff-compressed form
inline void from_json(const nlohmann::json &j, std::vector<Score::InputEvent> &points) {
int lastTick = 0;
for (auto i = j.cbegin(); i != j.cend(); i++) {
int ticket = *i;
int tickDiff = *i;
lastTick += tickDiff;
if (++i != j.cend()) {
points.push_back({ticket, *i});
points.push_back({lastTick, *i});
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/net/Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ trippin::Transport::Scores trippin::Transport::sendRequest(const std::string &ur
req << "GET " << uri
<< "?version=" << version
<< "&limit=" << limit
<< "&compression=diff"
<< " HTTP/1.0\r\n"
<< "Host: " << host << "\r\n"
<< "Accept: */*\r\n\r\n";
Expand Down

0 comments on commit 5e38ad9

Please sign in to comment.