-
Notifications
You must be signed in to change notification settings - Fork 5
fix: BadgeInfo response wrapping + ChallengeArenaResetInfo handler (stops client spam) #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tom2096
wants to merge
3
commits into
decompfrontier:main
Choose a base branch
from
Tom2096:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -486,3 +486,7 @@ vcpkg_installed/ | |
| .vscode | ||
| generated/ | ||
| .cmake/ | ||
|
|
||
| # Project-specific | ||
| CONTEXT.md | ||
| out/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule packet-generator
updated
4 files
| +3 −0 | .gitignore | |
| +1 −2 | assets/net/badge_info.kdl | |
| +25 −0 | assets/net/challenge_arena.kdl | |
| +18 −0 | assets/net/handlers.kdl |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.