@Add service.h #define ENABLE_EXCHANGE_LOG_RENEWAL @Find exchange.cpp CExchange::Done() @Change #ifdef ENABLE_EXCHANGE_LOG_RENEWAL bool CExchange::Done(DWORD tradeID, bool firstPlayer) #else bool CExchange::Done() #endif @Find exchange.cpp CExchange::Done(DWORD tradeID, bool firstPlayer) @Find Second item->SetExchanging(false); @Add #ifdef ENABLE_EXCHANGE_LOG_RENEWAL LogManager::instance().ExchangeItemLog(tradeID, item, firstPlayer ? "A" : "B"); #endif @Find exchange.cpp CExchange::Done(DWORD tradeID, bool firstPlayer) @Find Second char exchange_buf[51]; snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), GetOwner()->GetPlayerID(), item->GetCount()); LogManager::instance().ItemLog(victim, item, "EXCHANGE_TAKE", exchange_buf); snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), victim->GetPlayerID(), item->GetCount()); LogManager::instance().ItemLog(GetOwner(), item, "EXCHANGE_GIVE", exchange_buf); @Change #ifndef ENABLE_EXCHANGE_LOG_RENEWAL char exchange_buf[51]; snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), GetOwner()->GetPlayerID(), item->GetCount()); LogManager::instance().ItemLog(victim, item, "EXCHANGE_TAKE", exchange_buf); snprintf(exchange_buf, sizeof(exchange_buf), "%s %u %u", item->GetName(), victim->GetPlayerID(), item->GetCount()); LogManager::instance().ItemLog(GetOwner(), item, "EXCHANGE_GIVE", exchange_buf); #endif @Find exchange.cpp CExchange::Accept(bool bAccept) @Find Second if (Done()) @Change #ifdef ENABLE_EXCHANGE_LOG_RENEWAL DWORD tradeID = LogManager::instance().ExchangeLog(EXCHANGE_TYPE_TRADE, GetOwner()->GetPlayerID(), victim->GetPlayerID(), GetOwner()->GetX(), GetOwner()->GetY(), m_lGold, GetCompany()->m_lGold); if (Done(tradeID, true)) #else if (Done()) #endif @Find exchange.cpp CExchange::Accept(bool bAccept) @Find Second if (GetCompany()->Done()) @Change #ifdef ENABLE_EXCHANGE_LOG_RENEWAL if (GetCompany()->Done(tradeID, false)) #else if (GetCompany()->Done()) #endif @Find exchange.h bool Done(); @Find Second #ifdef ENABLE_EXCHANGE_LOG_RENEWAL bool Done(DWORD tradeID, bool firstPlayer); #else bool Done(); #endif @Find log.cpp @ Add End #ifdef ENABLE_EXCHANGE_LOG_RENEWAL SQLMsg* LogManager::DirectQuery(const char* c_pszFormat, ...) { char szQuery[4096]; va_list args; va_start(args, c_pszFormat); vsnprintf(szQuery, sizeof(szQuery), c_pszFormat, args); va_end(args); if (test_server) sys_log(1, "LOG: %s", szQuery); return m_sql.DirectQuery(szQuery); } DWORD LogManager::ExchangeLog(int type, DWORD dwPID1, DWORD dwPID2, long x, long y, int goldA /*=0*/, int goldB /*=0*/) { char szQuery[QUERY_MAX_LEN]; snprintf(szQuery, sizeof(szQuery), "INSERT INTO log_exchanges (type, playerA, playerB, goldA, goldB, x, y, date) VALUES (%d, %u, %u, %d, %d, %ld, %ld, NOW())", type, dwPID1, dwPID2, goldA, goldB, x, y); std::unique_ptr msg(DirectQuery(szQuery)); if (!msg || msg->Get()->uiAffectedRows == 0 || msg->Get()->uiAffectedRows == (my_ulonglong)-1) { sys_err("Issue logging trade. Query: %s", szQuery); return 0; } return (DWORD)msg->Get()->uiInsertID; } void LogManager::ExchangeItemLog(DWORD tradeID, LPITEM item, const char* player) { if (!item) return; if (!tradeID) { sys_err("Lost trade due to mysql error (tradeID = 0)"); return; } Query("INSERT INTO log_exchange_items" "(trade_id, `toPlayer`, `item_id`, `vnum`, count, socket0, socket1, socket2, socket3," " attrtype0, attrtype1, attrtype2, attrtype3, attrtype4, attrtype5, attrtype6, attrtype7, attrtype8, attrtype9, attrtype10, attrtype11, attrtype12, attrtype13, attrtype14," " attrvalue0, attrvalue1, attrvalue2, attrvalue3, attrvalue4, attrvalue5, attrvalue6, attrvalue7, attrvalue8, attrvalue9, attrvalue10, attrvalue11, attrvalue12, attrvalue13, attrvalue14," " date)" "VALUES (" "%lu,'%s',%lu,%lu,%lu," "%ld,%ld,%ld,%ld," "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d," "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d," "NOW())" , tradeID, player, item->GetID(), item->GetVnum(), item->GetCount() , item->GetSocket(0), item->GetSocket(1), item->GetSocket(2), item->GetSocket(3) , item->GetAttributeType(0), item->GetAttributeType(1), item->GetAttributeType(2), item->GetAttributeType(3), item->GetAttributeType(4), item->GetAttributeType(5), item->GetAttributeType(6), item->GetAttributeType(7), item->GetAttributeType(8), item->GetAttributeType(9), item->GetAttributeType(10), item->GetAttributeType(11), item->GetAttributeType(12), item->GetAttributeType(13), item->GetAttributeType(14) , item->GetAttributeValue(0), item->GetAttributeValue(1), item->GetAttributeValue(2), item->GetAttributeValue(3), item->GetAttributeValue(4), item->GetAttributeValue(5), item->GetAttributeValue(6), item->GetAttributeValue(7), item->GetAttributeValue(8), item->GetAttributeValue(9), item->GetAttributeValue(10), item->GetAttributeValue(11), item->GetAttributeValue(12), item->GetAttributeValue(13), item->GetAttributeValue(14) ); } @Find log.h @Add Non Class In File #ifdef ENABLE_EXCHANGE_LOG_RENEWAL enum ExchangeType //Matches Enum in table { EXCHANGE_TYPE_SHOP = 1, EXCHANGE_TYPE_TRADE = 2, }; #endif @Find log.h @Add Class In File #ifdef ENABLE_EXCHANGE_LOG_RENEWAL DWORD ExchangeLog(int type, DWORD dwPID1, DWORD dwPID2, long x, long y, int goldA = 0, int goldB = 0); void ExchangeItemLog(DWORD tradeID, LPITEM item, const char* player); SQLMsg* DirectQuery(const char* c_pszFormat, ...); #endif