Fix #28: stash live stats for beforeunload so leaderboard gets real score #31
Reference in New Issue
Block a user
Delete Branch "fix/28-leaderboard-score-zero"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The beforeunload fallback in shell.html sends session-end data when a player closes the tab. Module._analyticsLastStats was only populated by doEnd(), which runs when C explicitly ends a session. For the common case of closing the tab mid-game (especially first session), the field was null and the fallback sent score 0. Added analytics_stash_stats() which serialises current stats into _analyticsLastStats every frame, so beforeunload always has up-to-date data. Closes #28
5517834dd4to478c44212bPR Review
Two issues need fixing before merge:
1. Build-breaking: Implicit function declarations (C11 error)
enter_gameover()(defined line 691) andgameover_update()(defined line 702) are called before their definitions (lines 613 and 531). C11 does not allow implicit function declarations. Add forward declarations near the top of main.c:2. Missing camera snap on respawn
The original respawn code in level.c had
camera_follow()to snap the camera to the player after respawn. The newlevel_respawn_player()omits this, which may cause a one-frame visual glitch where the camera lingers at the death location.Minor: Line 798 comment says 'cursor arrow above' but
cy + 10draws it below the character.Please fix the forward declarations (build-breaking) and camera snap, then this is good to merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.