feat(stats): coins, bricks and smashes counted by the server as live did

The passport totals for coins, bricks and enemies came from the client's
ModifyPlayerZoneStatistic, which live's client sent for its per-zone counts;
live's server counted the totals itself and told the client
(UpdatePlayerStatistic). Now:

- CurrencyCollected (the amount gained) right after every SetCurrency that
  raised the coins (pickups, missions, achievements, selling, activities);
  none for losses. Captures: 15,815 pickups + mission/achievement/vendor/
  activity gains, all with the stat; no loss had one.
- BricksCollected (the count) after every add to the bricks inventory the
  client is told about (captures: 999 of 1,010, pickups and relocations).
- The kill counts go to the killer right after Die, before the loot:
  EnemiesSmashed when the DestructibleComponent's isnpc is set, else
  SmashablesSmashed for a smashable (captures: 2,766 NPC kills and 538
  smashables; faction or AI don't decide it, e.g. the Banana Cluster has AI
  and counted as a smashable). Neither while racing. Before, every kill was
  a SmashablesSmashed.
- ModifyPlayerZoneStatistic from the client only updates the zone counts,
  so nothing is counted twice.

Check in game: pick up coins, sell an item, finish a mission, pick up
bricks, smash a stromling and a crate; each passport number goes up by the
right amount at once and stays the same after relogging (no double counts).
The per-zone statistics still go up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-29 02:17:48 -05:00
parent 752f079100
commit 1f29e9604a
9 changed files with 107 additions and 10 deletions

View File

@@ -10,6 +10,7 @@
#include <chrono>
#include "Entity.h"
#include "EntityManager.h"
#include "CharacterComponent.h"
#include "GameMessages.h"
#include "EffectsMessages.h"
#include "MissionMessages.h"
@@ -595,6 +596,7 @@ void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
}
EconomyLedger::RecordCoins(m_ID, newCoins - m_Coins, lootSource);
const auto gained = newCoins > m_Coins ? static_cast<uint64_t>(newCoins - m_Coins) : 0;
m_Coins = newCoins;
auto* entity = Game::entityManager->GetEntity(m_ObjectID);
@@ -607,6 +609,10 @@ void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
setCurrency.sourceTradeID = 0;
setCurrency.sourceType = lootSource;
setCurrency.SendToClient(entity->GetSystemAddress());
// Live followed every coin gain with CurrencyCollected (the amount gained); losses had none
auto* characterComponent = entity->GetComponent<CharacterComponent>();
if (gained > 0 && characterComponent) characterComponent->UpdatePlayerStatistic(CurrencyCollected, gained);
}
bool Character::HasBeenToWorld(LWOMAPID mapID) const {