sanitize all money when saving session data to server (#4485)

* sanitize all money when saving session data to server

* update money sanitization

---------

Co-authored-by: ImperialSympathizer <imperialsympathizer@gmail.com>
This commit is contained in:
ImperialSympathizer 2024-09-27 23:48:15 -04:00 committed by GitHub
parent 3def9fc15d
commit 5d819aacf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View File

@ -238,7 +238,7 @@ export class GameOverPhase extends BattlePhase {
enemyModifiers: this.scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
arena: new ArenaData(this.scene.arena),
pokeballCounts: this.scene.pokeballCounts,
money: this.scene.money,
money: Math.floor(this.scene.money),
score: this.scene.score,
waveIndex: this.scene.currentBattle.waveIndex,
battleType: this.scene.currentBattle.battleType,

View File

@ -957,7 +957,7 @@ export class GameData {
enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
arena: new ArenaData(scene.arena),
pokeballCounts: scene.pokeballCounts,
money: scene.money,
money: Math.floor(scene.money),
score: scene.score,
waveIndex: scene.currentBattle.waveIndex,
battleType: scene.currentBattle.battleType,
@ -1047,7 +1047,7 @@ export class GameData {
scene.pokeballCounts = Overrides.POKEBALL_OVERRIDE.pokeballs;
}
scene.money = sessionData.money || 0;
scene.money = Math.floor(sessionData.money || 0);
scene.updateMoneyText();
if (scene.money > this.gameStats.highestMoney) {

View File

@ -6,6 +6,10 @@ const LATEST_VERSION = "1.0.5";
export function applySessionDataPatches(data: SessionSaveData) {
const curVersion = data.gameVersion;
// Always sanitize money as a safeguard
data.money = Math.floor(data.money);
if (curVersion !== LATEST_VERSION) {
switch (curVersion) {
case "1.0.0":