Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,7 @@ vcpkg_installed/
.vscode
generated/
.cmake/

# Project-specific
CONTEXT.md
out/
Comment thread
Tom2096 marked this conversation as resolved.
2 changes: 1 addition & 1 deletion gimuserver/gme/BadgeInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

HANDLEF(BadgeInfo)
{
::BadgeInfo resp{};
::BadgeInfoResp resp{};
std::string buffer{};
const auto& ec = glz::write_json(resp, buffer);
if (ec)
Expand Down
49 changes: 49 additions & 0 deletions gimuserver/gme/ChallengeArenaResetInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "App.hpp"
#include "Handlers.hpp"

// ChallengeArenaResetInfo
//
// By default the server returns GmeError{cmd=Close}, which the
// client interpreted as a connection failure. The connect scene never
// transitioned away, so the game loop re-fired the request every frame.
//
// With this handler returning empty timestamps (instead of an error), the client parses
// a valid response and stores server_time + a local snapshot. needServerRefresh() computes:
//
// server_time + now() - local_snapshot > daily_cooling_end
//
// Assume fields start at zero. After parsing the empty response, server_time stays 0,
// local_snapshot is set to the current time (via time()), and daily_cooling_end stays 0.
// So the check becomes: 0 + now() - local_snapshot > 0.
//
// Since local_snapshot == the time() value from just after parsing, this is false until
// now() ticks forward to the next second.
//
// To stop the client from retrying every second, we'll set daily_cooling_end to an hour in the
// future.
//
// TODO: figure out the actual intended cooldown time and use that instead.
HANDLEF(ChallengeArenaResetInfo)
{
using namespace std::chrono;
using namespace std::chrono_literals;

::ChallengeArenaResetInfoResp resp{};

// I've tested this with 5 seconds as well, which causes the client to retry every 6 seconds.
// This makes sense since its an explicit greater-than check.
// Using an hour here as a placeholder to prevent the client from constantly retrying and polluting
// our logs (and our disks :D).
resp.reset_info.server_time = floor<milliseconds>(system_clock::now());
resp.reset_info.daily_cooling_end = resp.reset_info.server_time + 1h;

std::string buffer{};
const auto& ec = glz::write_json(resp, buffer);
if (ec) {
const auto& glze = glz::format_error(ec, buffer);
LOG_DEBUG << "Gme ChallengeArenaResetInfo Error during JSON writing: " << glze;
co_return HandleResult::error("Serialization error", glze);
}

co_return HandleResult::success(buffer);
}
1 change: 1 addition & 0 deletions gimuserver/gme/GmeControllerHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static GmeHandler getHandler(std::string_view cmd)


REGISTER("MfZyu1q9", Initialize, "EmcshnQoDr20TZz1");
REGISTER("Zw3WIoWu", ChallengeArenaResetInfo, "KlwYMGF1");
REGISTER("nJ3A7qFp", BadgeInfo, "bGxX67KB");
REGISTER("uYF93Mhc", ControlCenterEnter, "d0k6LGUu");
REGISTER("m2Ve9PkJ", DeckEdit, "d7UuQsq8");
Expand Down
1 change: 1 addition & 0 deletions gimuserver/gme/Handlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace GmeHandlers
{
HANDLE(Initialize);
HANDLE(BadgeInfo);
HANDLE(ChallengeArenaResetInfo);
HANDLE(ControlCenterEnter);
HANDLE(DeckEdit);
HANDLE(FriendGet);
Expand Down