mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Player Event Logs] Migrate and Deprecate QS Legacy Logging (#4542)
* First pass of player_event_loot_items * Second pass of player_event_loot_items * Third pass of player_event_loot_items * Example without RecordDetailEvent template * Cleanup the removal of the template * Fourth Pass Add retention for etl tables Rename tables/fields to etl nomenclature Combine database work to one atomic load * Reposition to reduce db tasks * Refactor etl processing for easier additions * Add merchant purchase event testing passed though appears that the event itself has a few bugs. Will fix them in another commit * Fix PlayerEventMerchantPurchase in client_packet.cpp * WIP - Handin * Handin Event added * Cleanup * All a rentention period of 0 days which deletes all current records. * Updates Cleanup and refactor a few items. * Cleanup and Formatting Cleanup and Formatting * Add etl for Playerevent::Trade PlayerEvent::Speech (new event to mirror functionality of qs_speech * Add etl for Playerevent::KilledNPC, KilledNamedNPC and KilledRaidNPC * Add etl for Playerevent::AA_purchase Add etl for Playerevent::AA_purchase * Cleanup before PR * Review comment updates. * Add world cli etl:settings to output a json on all player event details. * Add reserve for all etl_queues Correct a failed test case for improper next id for etl tables when table is first created. * Potential solution for a dedicated database connection for player events. * Simple thread for player_events. Likely there is a better way to do this. * Add zone to qs communications for recordplayerevents First pass of enabling zone to qs direct transport to allow for PlayerEvents to bypass world. * Cleanup a linux compile issue * Add augments to LOOT ITEM and DESTROY ITEM * Add augments to ITEMCREATION, FORAGESUCCESS, FISHSUCCESS, DESTROYITEM, LOOTITEM, DROPPEDITEM, TRADERPURCHASE, TRADERSELL, GUILDTRIBUTEDONATE and cleaned up the naming convention of augments * Formatting fixes * Swap out GetNextTableId * Statically load counter * Add counter.clear() since the counter is static * Upload optional QS conversion scripts * Remove all qs_tables and code referencing them * Update database.cpp * Simplify ProcessBatchQueue * Simplify PorcessBatchQueue * Simplify event truncation * Build event truncation to bulk query by retention groups * Post rebase * Update player_events.h * Fix build * Update npc.cpp * First pass of direct zone to qs sending for player events * Remove keepalive logic * Fix event ordering * Cleanup * Update player_event_logs.cpp * Wipe event data after ETL processed * Split up database connections, hot reload logs for QS * Load rules from database vs qs_database * Update player_event_logs.cpp * Hot toggle queryserv connect --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+47
-267
@@ -326,38 +326,12 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
|
||||
if (tradingWith->IsClient()) {
|
||||
Client * other = tradingWith->CastToClient();
|
||||
PlayerLogTrade_Struct * qs_audit = nullptr;
|
||||
bool qs_log = false;
|
||||
|
||||
if(other) {
|
||||
LogTrading("Finishing trade with client [{}]", other->GetName());
|
||||
|
||||
AddMoneyToPP(other->trade->cp, other->trade->sp, other->trade->gp, other->trade->pp, true);
|
||||
|
||||
// step 0: pre-processing
|
||||
// QS code
|
||||
if (RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) {
|
||||
qs_audit = (PlayerLogTrade_Struct*)event_entry;
|
||||
qs_log = true;
|
||||
|
||||
if (finalizer) {
|
||||
qs_audit->character_2_id = character_id;
|
||||
|
||||
qs_audit->character_2_money.platinum = trade->pp;
|
||||
qs_audit->character_2_money.gold = trade->gp;
|
||||
qs_audit->character_2_money.silver = trade->sp;
|
||||
qs_audit->character_2_money.copper = trade->cp;
|
||||
}
|
||||
else {
|
||||
qs_audit->character_1_id = character_id;
|
||||
|
||||
qs_audit->character_1_money.platinum = trade->pp;
|
||||
qs_audit->character_1_money.gold = trade->gp;
|
||||
qs_audit->character_1_money.silver = trade->sp;
|
||||
qs_audit->character_1_money.copper = trade->cp;
|
||||
}
|
||||
}
|
||||
|
||||
// step 1: process bags
|
||||
for (int16 trade_slot = EQ::invslot::TRADE_BEGIN; trade_slot <= EQ::invslot::TRADE_END; ++trade_slot) {
|
||||
const EQ::ItemInstance* inst = m_inv[trade_slot];
|
||||
@@ -377,55 +351,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
inst->TransferOwnership(database, other->CharacterID());
|
||||
LogTrading("Container [{}] ([{}]) successfully transferred, deleting from trade slot", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
auto detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_character_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = 1;
|
||||
detail->aug_1 = inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->character_2_item_count += detail->charges;
|
||||
else
|
||||
qs_audit->character_1_item_count += detail->charges;
|
||||
|
||||
for (uint8 sub_slot = EQ::invbag::SLOT_BEGIN; (sub_slot <= EQ::invbag::SLOT_END); ++sub_slot) { // this is to catch ALL items
|
||||
const EQ::ItemInstance* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = EQ::InventoryProfile::CalcSlotId(trade_slot, sub_slot);
|
||||
detail->to_character_id = other->CharacterID();
|
||||
detail->to_slot = EQ::InventoryProfile::CalcSlotId(free_slot, sub_slot);
|
||||
detail->item_id = bag_inst->GetID();
|
||||
detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges());
|
||||
detail->aug_1 = bag_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = bag_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = bag_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = bag_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = bag_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->character_2_item_count += detail->charges;
|
||||
else
|
||||
qs_audit->character_1_item_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogTrading("Transfer of container [{}] ([{}]) to [{}] failed, returning to giver", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@@ -492,28 +417,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
(old_charges - inst->GetCharges())
|
||||
);
|
||||
inst->TransferOwnership(database, other->CharacterID());
|
||||
if (qs_log) {
|
||||
auto detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_character_id = other->CharacterID();
|
||||
detail->to_slot = partial_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (old_charges - inst->GetCharges());
|
||||
detail->aug_1 = 0;
|
||||
detail->aug_2 = 0;
|
||||
detail->aug_3 = 0;
|
||||
detail->aug_4 = 0;
|
||||
detail->aug_5 = 0;
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->character_2_item_count += detail->charges;
|
||||
else
|
||||
qs_audit->character_1_item_count += detail->charges;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogTrading("Transfer of partial stack [{}] ([{}]) to [{}] failed, returning [{}] charges to trade slot",
|
||||
@@ -560,24 +463,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
inst->SetCharges(0);
|
||||
}
|
||||
|
||||
if (qs_log) {
|
||||
auto detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_character_id = character_id;
|
||||
detail->to_slot = bias_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (old_charges - inst->GetCharges());
|
||||
detail->aug_1 = 0;
|
||||
detail->aug_2 = 0;
|
||||
detail->aug_3 = 0;
|
||||
detail->aug_4 = 0;
|
||||
detail->aug_5 = 0;
|
||||
|
||||
event_details->push_back(detail);
|
||||
}
|
||||
|
||||
if (inst->GetCharges() == 0) {
|
||||
DeleteItemInInventory(trade_slot);
|
||||
break;
|
||||
@@ -601,56 +486,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
inst->TransferOwnership(database, other->CharacterID());
|
||||
LogTrading("Item [{}] ([{}]) successfully transferred, deleting from trade slot", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
auto detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_character_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = inst->GetID();
|
||||
detail->charges = (!inst->IsStackable() ? 1 : inst->GetCharges());
|
||||
detail->aug_1 = inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->character_2_item_count += detail->charges;
|
||||
else
|
||||
qs_audit->character_1_item_count += detail->charges;
|
||||
|
||||
// 'step 3' should never really see containers..but, just in case...
|
||||
for (uint8 sub_slot = EQ::invbag::SLOT_BEGIN; (sub_slot <= EQ::invbag::SLOT_END); ++sub_slot) { // this is to catch ALL items
|
||||
const EQ::ItemInstance* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new PlayerLogTradeItemsEntry_Struct;
|
||||
|
||||
detail->from_character_id = character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_character_id = other->CharacterID();
|
||||
detail->to_slot = free_slot;
|
||||
detail->item_id = bag_inst->GetID();
|
||||
detail->charges = (!bag_inst->IsStackable() ? 1 : bag_inst->GetCharges());
|
||||
detail->aug_1 = bag_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = bag_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = bag_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = bag_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = bag_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
|
||||
if (finalizer)
|
||||
qs_audit->character_2_item_count += detail->charges;
|
||||
else
|
||||
qs_audit->character_1_item_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
LogTrading("Transfer of Item [{}] ([{}]) to [{}] failed, returning to giver", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@@ -676,79 +511,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
}
|
||||
else if(tradingWith->IsNPC()) {
|
||||
|
||||
QSPlayerLogHandin_Struct* qs_audit = nullptr;
|
||||
bool qs_log = false;
|
||||
|
||||
// QS code
|
||||
if(RuleB(QueryServ, PlayerLogTrades) && event_entry && event_details) {
|
||||
// Currently provides only basic functionality. Calling method will also
|
||||
// need to be modified before item returns and rewards can be logged.
|
||||
qs_audit = (QSPlayerLogHandin_Struct*)event_entry;
|
||||
qs_log = true;
|
||||
|
||||
qs_audit->quest_id = 0;
|
||||
qs_audit->char_id = character_id;
|
||||
qs_audit->char_money.platinum = trade->pp;
|
||||
qs_audit->char_money.gold = trade->gp;
|
||||
qs_audit->char_money.silver = trade->sp;
|
||||
qs_audit->char_money.copper = trade->cp;
|
||||
qs_audit->char_count = 0;
|
||||
qs_audit->npc_id = tradingWith->GetNPCTypeID();
|
||||
qs_audit->npc_money.platinum = 0;
|
||||
qs_audit->npc_money.gold = 0;
|
||||
qs_audit->npc_money.silver = 0;
|
||||
qs_audit->npc_money.copper = 0;
|
||||
qs_audit->npc_count = 0;
|
||||
}
|
||||
|
||||
if(qs_log) { // This can be incorporated below when revisions are made
|
||||
for (int16 trade_slot = EQ::invslot::TRADE_BEGIN; trade_slot <= EQ::invslot::TRADE_NPC_END; ++trade_slot) {
|
||||
const EQ::ItemInstance* trade_inst = m_inv[trade_slot];
|
||||
|
||||
if(trade_inst) {
|
||||
auto detail = new QSHandinItems_Struct;
|
||||
|
||||
strcpy(detail->action_type, "HANDIN");
|
||||
|
||||
detail->char_slot = trade_slot;
|
||||
detail->item_id = trade_inst->GetID();
|
||||
detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges());
|
||||
detail->aug_1 = trade_inst->GetAugmentItemID(1);
|
||||
detail->aug_2 = trade_inst->GetAugmentItemID(2);
|
||||
detail->aug_3 = trade_inst->GetAugmentItemID(3);
|
||||
detail->aug_4 = trade_inst->GetAugmentItemID(4);
|
||||
detail->aug_5 = trade_inst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
qs_audit->char_count += detail->charges;
|
||||
|
||||
if (trade_inst->IsClassBag()) {
|
||||
for (uint8 sub_slot = EQ::invbag::SLOT_BEGIN; sub_slot < trade_inst->GetItem()->BagSlots; ++sub_slot) {
|
||||
const EQ::ItemInstance* trade_baginst = trade_inst->GetItem(sub_slot);
|
||||
|
||||
if(trade_baginst) {
|
||||
detail = new QSHandinItems_Struct;
|
||||
|
||||
strcpy(detail->action_type, "HANDIN");
|
||||
|
||||
detail->char_slot = EQ::InventoryProfile::CalcSlotId(trade_slot, sub_slot);
|
||||
detail->item_id = trade_baginst->GetID();
|
||||
detail->charges = (!trade_inst->IsStackable() ? 1 : trade_inst->GetCharges());
|
||||
detail->aug_1 = trade_baginst->GetAugmentItemID(1);
|
||||
detail->aug_2 = trade_baginst->GetAugmentItemID(2);
|
||||
detail->aug_3 = trade_baginst->GetAugmentItemID(3);
|
||||
detail->aug_4 = trade_baginst->GetAugmentItemID(4);
|
||||
detail->aug_5 = trade_baginst->GetAugmentItemID(5);
|
||||
|
||||
event_details->push_back(detail);
|
||||
qs_audit->char_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool quest_npc = false;
|
||||
if (parse->HasQuestSub(tradingWith->GetNPCTypeID(), EVENT_TRADE)) {
|
||||
quest_npc = true;
|
||||
@@ -1684,34 +1446,46 @@ void Client::BuyTraderItem(TraderBuy_Struct *tbs, Client *Trader, const EQApplic
|
||||
Trader->AddMoneyToPP(copper, silver, gold, platinum, true);
|
||||
|
||||
if (player_event_logs.IsEventEnabled(PlayerEvent::TRADER_PURCHASE)) {
|
||||
auto e = PlayerEvent::TraderPurchaseEvent{
|
||||
.item_id = buy_item->GetID(),
|
||||
.item_name = buy_item->GetItem()->Name,
|
||||
.trader_id = Trader->CharacterID(),
|
||||
.trader_name = Trader->GetCleanName(),
|
||||
.price = tbs->price,
|
||||
.charges = outtbs->quantity,
|
||||
.total_cost = (tbs->price * outtbs->quantity),
|
||||
.player_money_balance = GetCarriedMoney(),
|
||||
};
|
||||
auto e = PlayerEvent::TraderPurchaseEvent{
|
||||
.item_id = buy_item->GetID(),
|
||||
.augment_1_id = buy_item->GetAugmentItemID(0),
|
||||
.augment_2_id = buy_item->GetAugmentItemID(1),
|
||||
.augment_3_id = buy_item->GetAugmentItemID(2),
|
||||
.augment_4_id = buy_item->GetAugmentItemID(3),
|
||||
.augment_5_id = buy_item->GetAugmentItemID(4),
|
||||
.augment_6_id = buy_item->GetAugmentItemID(5),
|
||||
.item_name = buy_item->GetItem()->Name,
|
||||
.trader_id = Trader->CharacterID(),
|
||||
.trader_name = Trader->GetCleanName(),
|
||||
.price = tbs->price,
|
||||
.charges = outtbs->quantity,
|
||||
.total_cost = (tbs->price * outtbs->quantity),
|
||||
.player_money_balance = GetCarriedMoney(),
|
||||
};
|
||||
|
||||
RecordPlayerEventLog(PlayerEvent::TRADER_PURCHASE, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (player_event_logs.IsEventEnabled(PlayerEvent::TRADER_SELL)) {
|
||||
auto e = PlayerEvent::TraderSellEvent{
|
||||
.item_id = buy_item->GetID(),
|
||||
.item_name = buy_item->GetItem()->Name,
|
||||
.buyer_id = CharacterID(),
|
||||
.buyer_name = GetCleanName(),
|
||||
.price = tbs->price,
|
||||
.charges = outtbs->quantity,
|
||||
.total_cost = (tbs->price * outtbs->quantity),
|
||||
.player_money_balance = Trader->GetCarriedMoney(),
|
||||
};
|
||||
auto e = PlayerEvent::TraderSellEvent{
|
||||
.item_id = buy_item->GetID(),
|
||||
.augment_1_id = buy_item->GetAugmentItemID(0),
|
||||
.augment_2_id = buy_item->GetAugmentItemID(1),
|
||||
.augment_3_id = buy_item->GetAugmentItemID(2),
|
||||
.augment_4_id = buy_item->GetAugmentItemID(3),
|
||||
.augment_5_id = buy_item->GetAugmentItemID(4),
|
||||
.augment_6_id = buy_item->GetAugmentItemID(5),
|
||||
.item_name = buy_item->GetItem()->Name,
|
||||
.buyer_id = CharacterID(),
|
||||
.buyer_name = GetCleanName(),
|
||||
.price = tbs->price,
|
||||
.charges = outtbs->quantity,
|
||||
.total_cost = (tbs->price * outtbs->quantity),
|
||||
.player_money_balance = Trader->GetCarriedMoney(),
|
||||
};
|
||||
|
||||
RecordPlayerEventLogWithClient(Trader, PlayerEvent::TRADER_SELL, e);
|
||||
}
|
||||
RecordPlayerEventLogWithClient(Trader, PlayerEvent::TRADER_SELL, e);
|
||||
}
|
||||
|
||||
LogTrading("Trader Received: [{}] Platinum, [{}] Gold, [{}] Silver, [{}] Copper", platinum, gold, silver, copper);
|
||||
ReturnTraderReq(app, outtbs->quantity, item_id);
|
||||
@@ -3167,6 +2941,12 @@ void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicati
|
||||
if (player_event_logs.IsEventEnabled(PlayerEvent::TRADER_PURCHASE)) {
|
||||
auto e = PlayerEvent::TraderPurchaseEvent{
|
||||
.item_id = buy_item->GetID(),
|
||||
.augment_1_id = buy_item->GetAugmentItemID(0),
|
||||
.augment_2_id = buy_item->GetAugmentItemID(1),
|
||||
.augment_3_id = buy_item->GetAugmentItemID(2),
|
||||
.augment_4_id = buy_item->GetAugmentItemID(3),
|
||||
.augment_5_id = buy_item->GetAugmentItemID(4),
|
||||
.augment_6_id = buy_item->GetAugmentItemID(5),
|
||||
.item_name = buy_item->GetItem()->Name,
|
||||
.trader_id = tbs->trader_id,
|
||||
.trader_name = tbs->seller_name,
|
||||
@@ -3231,12 +3011,12 @@ void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicati
|
||||
e.from_player_name = parcel_out.from_name;
|
||||
e.to_player_name = GetCleanName();
|
||||
e.item_id = parcel_out.item_id;
|
||||
e.aug_slot_1 = parcel_out.aug_slot_1;
|
||||
e.aug_slot_2 = parcel_out.aug_slot_2;
|
||||
e.aug_slot_3 = parcel_out.aug_slot_3;
|
||||
e.aug_slot_4 = parcel_out.aug_slot_4;
|
||||
e.aug_slot_5 = parcel_out.aug_slot_5;
|
||||
e.aug_slot_6 = parcel_out.aug_slot_6;
|
||||
e.augment_1_id = parcel_out.aug_slot_1;
|
||||
e.augment_2_id = parcel_out.aug_slot_2;
|
||||
e.augment_3_id = parcel_out.aug_slot_3;
|
||||
e.augment_4_id = parcel_out.aug_slot_4;
|
||||
e.augment_5_id = parcel_out.aug_slot_5;
|
||||
e.augment_6_id = parcel_out.aug_slot_6;
|
||||
e.quantity = parcel_out.quantity;
|
||||
e.sent_date = parcel_out.sent_date;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user