- Mesaj
- 118
- Beğeni
- 84
- Puan
- 351
- Ticaret Puanı
- 0
Her iki oyuncu da takası kabul ettiğinde denetim günlüğü tetiklenir ve kayıt altına alınır
ardından aynı dosyada bulunur
altına ekle
exchange.h ekle void LogExchangeSnapshot() const;
C++:
void CExchange::LogExchangeSnapshot() const
{
if (!GetCompany())
return;
LPCHARACTER victim = GetCompany()->GetOwner();
if (!victim)
return;
if (GetOwner()->GetPlayerID() > victim->GetPlayerID())
return;
nlohmann::json exchange_entry;
exchange_entry["timestamp"] = static_cast<long>(time(NULL));
exchange_entry["participants"] = nlohmann::json::array();
auto serializeParticipant = [](const CExchange* exchange) {
nlohmann::json participant;
participant["player_id"] = exchange->GetOwner()->GetPlayerID();
participant["name"] = exchange->GetOwner()->GetName();
participant["gold_offered"] = exchange->m_lGold;
participant["items"] = nlohmann::json::array();
for (int i = 0; i < EXCHANGE_ITEM_MAX_NUM; ++i)
{
if (!exchange->m_apItems[i])
continue;
nlohmann::json item;
item["id"] = exchange->m_apItems[i]->GetID();
item["vnum"] = exchange->m_apItems[i]->GetVnum();
item["count"] = exchange->m_apItems[i]->GetCount();
item["display_pos"] = exchange->m_abItemDisplayPos[i];
item["inventory_window"] = exchange->m_aItemPos[i].window_type;
item["inventory_cell"] = exchange->m_aItemPos[i].cell;
participant["items"].push_back(item);
}
return participant;
};
exchange_entry["participants"].push_back(serializeParticipant(this));
exchange_entry["participants"].push_back(serializeParticipant(GetCompany()));
exchange_entry["trusted_source"] = "server";
std::ofstream output("exchange_audit.jsonl", std::ios::app | std::ios::binary);
if (!output.is_open())
{
sys_err("Failed to open exchange audit log for writing");
return;
}
output << exchange_entry.dump() << '\n';
}
ardından aynı dosyada bulunur
aratılacak:
if (db_clientdesc->GetSocket() == INVALID_SOCKET)
{
sys_err("Cannot use exchange feature while DB cache connection is dead.");
victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
GetOwner()->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
goto EXCHANGE_END;
altına ekle
aratılacak:
if (db_clientdesc->GetSocket() == INVALID_SOCKET)
{
sys_err("Cannot use exchange feature while DB cache connection is dead.");
victim->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
GetOwner()->ChatPacket(CHAT_TYPE_INFO, "Unknown error");
goto EXCHANGE_END
LogExchangeSnapshot();