Separate looted currency and preserve growing realm state in atomic chunks
Core tests / core (push) Successful in 49s

This commit is contained in:
Codex
2026-09-24 03:16:52 +12:00
parent e7b9df9e08
commit 8e01cdee22
13 changed files with 54 additions and 17 deletions
+10 -1
View File
@@ -4,6 +4,12 @@ AuthDBExecute([[CREATE TABLE IF NOT EXISTS azerothai_outcomes (
abandoned INT UNSIGNED NOT NULL DEFAULT 0,loot_events INT UNSIGNED NOT NULL DEFAULT 0,
loot_items INT UNSIGNED NOT NULL DEFAULT 0,party_kills INT UNSIGNED NOT NULL DEFAULT 0,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP)]])
AuthDBExecute([[CREATE TABLE IF NOT EXISTS azerothai_currency (
guid INT UNSIGNED PRIMARY KEY,looted_copper BIGINT UNSIGNED NOT NULL DEFAULT 0)]])
local money={}
RegisterPlayerEvent(37,function(_,p,amount)
if p:IsPlayerbot() and amount and amount>0 then local id=p:GetGUIDLow();money[id]=(money[id] or 0)+amount end
end)
local pending={}
local function add(p,key,amount)
if not p:IsPlayerbot() then return end
@@ -28,7 +34,10 @@ local function flush()
for guid,r in pairs(pending) do
AuthDBExecute('INSERT INTO azerothai_outcomes(guid,quests,abandoned,loot_events,loot_items,party_kills) VALUES ('..guid..','..r.quests..','..r.abandoned..','..r.loot_events..','..r.loot_items..','..r.party_kills..') ON DUPLICATE KEY UPDATE quests=quests+VALUES(quests),abandoned=abandoned+VALUES(abandoned),loot_events=loot_events+VALUES(loot_events),loot_items=loot_items+VALUES(loot_items),party_kills=party_kills+VALUES(party_kills),updated_at=NOW()')
end
pending={}
for guid,amount in pairs(money) do
AuthDBExecute('INSERT INTO azerothai_currency(guid,looted_copper) VALUES ('..guid..','..amount..') ON DUPLICATE KEY UPDATE looted_copper=looted_copper+VALUES(looted_copper)')
end
money={};pending={}
end
CreateLuaEvent(flush,60000,0)
-- Native profiler JSON is generated every five minutes; enabling it is an operator setting.