mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 09:28:21 +00:00
Merchant buying in flux but it works better now
This commit is contained in:
+1
-13
@@ -1035,24 +1035,12 @@ void Client::BuyAA(AA_Action* action)
|
||||
*/
|
||||
|
||||
/* Initial purchase of an AA ability */
|
||||
if (cur_level < 1){
|
||||
if (cur_level < 1) {
|
||||
Message(15, "You have gained the ability \"%s\" at a cost of %d ability %s.", aa2->name, real_cost, (real_cost>1) ? "points" : "point");
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)){
|
||||
std::string event_desc = StringFormat("Initial AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
/* Ranked purchase of an AA ability */
|
||||
else{
|
||||
Message(15, "You have improved %s %d at a cost of %d ability %s.", aa2->name, cur_level + 1, real_cost, (real_cost > 1) ? "points" : "point");
|
||||
|
||||
/* QS: Player_Log_AA_Purchases */
|
||||
if (RuleB(QueryServ, PlayerLogAAPurchases)){
|
||||
std::string event_desc = StringFormat("Ranked AA Purchase :: aa_name:%s aa_id:%i at cost:%i in zoneid:%i instid:%i", aa2->name, aa2->id, real_cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_AA_Purchases, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
SendAAStats();
|
||||
|
||||
@@ -1706,14 +1706,6 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes att
|
||||
GoToDeath();
|
||||
}
|
||||
|
||||
/* QS: PlayerLogDeaths */
|
||||
if (RuleB(QueryServ, PlayerLogDeaths)){
|
||||
const char * killer_name = "";
|
||||
if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); }
|
||||
std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage);
|
||||
QServ->PlayerLogEvent(Player_Log_Deaths, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
parse->EventPlayer(EVENT_DEATH_COMPLETE, this, buffer, 0);
|
||||
return true;
|
||||
}
|
||||
@@ -2180,27 +2172,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// QueryServ Logging - Raid Kills
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
|
||||
PlayerCount = 0;
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 2; // Raid Fight
|
||||
for (int i = 0; i < MAX_RAID_MEMBERS; i++) {
|
||||
if (kr->members[i].member != nullptr && kr->members[i].member->IsClient()) { // If Group Member is Client
|
||||
Client *c = kr->members[i].member;
|
||||
QS->Chars[PlayerCount].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
|
||||
}
|
||||
else if (give_exp_client->IsGrouped() && kg != nullptr)
|
||||
{
|
||||
@@ -2227,26 +2198,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// QueryServ Logging - Group Kills
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount));
|
||||
PlayerCount = 0;
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 1; // Group Fight
|
||||
for (int i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
||||
if (kg->members[i] != nullptr && kg->members[i]->IsClient()) { // If Group Member is Client
|
||||
Client *c = kg->members[i]->CastToClient();
|
||||
QS->Chars[PlayerCount].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2273,21 +2224,6 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillUseTypes attack
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
give_exp_client->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
// QueryServ Logging - Solo
|
||||
if(RuleB(QueryServ, PlayerLogNPCKills)){
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, sizeof(QSPlayerLogNPCKill_Struct) + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1));
|
||||
QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*) pack->pBuffer;
|
||||
QS->s1.NPCID = this->GetNPCTypeID();
|
||||
QS->s1.ZoneID = this->GetZoneID();
|
||||
QS->s1.Type = 0; // Solo Fight
|
||||
Client *c = give_exp_client;
|
||||
QS->Chars[0].char_id = c->CharacterID();
|
||||
PlayerCount++;
|
||||
worldserver.SendPacket(pack); // Send Packet to World
|
||||
safe_delete(pack);
|
||||
}
|
||||
// End QueryServ Logging
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+46
-104
@@ -2113,79 +2113,18 @@ bool Client::TakeMoneyFromPP(uint64 copper, bool updateclient) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::AddMoneyToPP(uint64 copper, bool updateclient){
|
||||
uint64 tmp;
|
||||
uint64 tmp2;
|
||||
tmp = copper;
|
||||
void Client::AddMoneyToPP(uint64 copper, bool updateclient) {
|
||||
|
||||
/* Add Amount of Platinum */
|
||||
tmp2 = tmp/1000;
|
||||
int32 new_val = m_pp.platinum + tmp2;
|
||||
if(new_val < 0) { m_pp.platinum = 0; }
|
||||
else { m_pp.platinum = m_pp.platinum + tmp2; }
|
||||
tmp-=tmp2*1000;
|
||||
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(3,tmp2);
|
||||
|
||||
/* Add Amount of Gold */
|
||||
tmp2 = tmp/100;
|
||||
new_val = m_pp.gold + tmp2;
|
||||
if(new_val < 0) { m_pp.gold = 0; }
|
||||
else { m_pp.gold = m_pp.gold + tmp2; }
|
||||
|
||||
tmp-=tmp2*100;
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(2,tmp2);
|
||||
|
||||
/* Add Amount of Silver */
|
||||
tmp2 = tmp/10;
|
||||
new_val = m_pp.silver + tmp2;
|
||||
if(new_val < 0) {
|
||||
m_pp.silver = 0;
|
||||
} else {
|
||||
m_pp.silver = m_pp.silver + tmp2;
|
||||
}
|
||||
tmp-=tmp2*10;
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(1,tmp2);
|
||||
|
||||
// Add Copper
|
||||
//tmp = tmp - (tmp2* 10);
|
||||
//if (updateclient)
|
||||
// SendClientMoneyUpdate(0,tmp);
|
||||
tmp2 = tmp;
|
||||
new_val = m_pp.copper + tmp2;
|
||||
if(new_val < 0) {
|
||||
m_pp.copper = 0;
|
||||
} else {
|
||||
m_pp.copper = m_pp.copper + tmp2;
|
||||
}
|
||||
|
||||
|
||||
//send them all at once, since the above code stopped working.
|
||||
if(updateclient)
|
||||
SendMoneyUpdate();
|
||||
|
||||
RecalcWeight();
|
||||
|
||||
SaveCurrency();
|
||||
|
||||
Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
uint64 plat = copper / 1000;
|
||||
copper -= plat * 1000;
|
||||
uint64 gold = copper / 100;
|
||||
copper -= gold * 100;
|
||||
uint64 silver = copper / 10;
|
||||
copper -= silver * 10;
|
||||
AddMoneyToPP(copper, silver, gold, plat, updateclient);
|
||||
}
|
||||
|
||||
void Client::ItemScriptStopReturn(){
|
||||
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
|
||||
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
|
||||
*/
|
||||
struct timeval read_time;
|
||||
char buffer[50];
|
||||
gettimeofday(&read_time, 0);
|
||||
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
|
||||
SetEntityVariable("Stop_Return", buffer);
|
||||
}
|
||||
|
||||
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient){
|
||||
void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, bool updateclient) {
|
||||
ItemScriptStopReturn();
|
||||
|
||||
int32 new_value = m_pp.platinum + platinum;
|
||||
@@ -2209,11 +2148,17 @@ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 plat
|
||||
|
||||
RecalcWeight();
|
||||
SaveCurrency();
|
||||
}
|
||||
|
||||
#if (EQDEBUG>=5)
|
||||
Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i",
|
||||
GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
#endif
|
||||
void Client::ItemScriptStopReturn() {
|
||||
/* Set a timestamp in an entity variable for plugin check_handin.pl in return_items
|
||||
This will stopgap players from items being returned if global_npc.pl has a catch all return_items
|
||||
*/
|
||||
struct timeval read_time;
|
||||
char buffer[50];
|
||||
gettimeofday(&read_time, 0);
|
||||
sprintf(buffer, "%li.%li \n", read_time.tv_sec, read_time.tv_usec);
|
||||
SetEntityVariable("Stop_Return", buffer);
|
||||
}
|
||||
|
||||
void Client::SendMoneyUpdate() {
|
||||
@@ -2517,31 +2462,32 @@ void Client::SetFeigned(bool in_feigned) {
|
||||
|
||||
void Client::LogMerchant(Client* player, Mob* merchant, uint32 quantity, uint32 price, const ItemData* item, bool buying)
|
||||
{
|
||||
if(!player || !merchant || !item)
|
||||
return;
|
||||
|
||||
std::string LogText = "Qty: ";
|
||||
|
||||
char Buffer[255];
|
||||
memset(Buffer, 0, sizeof(Buffer));
|
||||
|
||||
snprintf(Buffer, sizeof(Buffer)-1, "%3i", quantity);
|
||||
LogText += Buffer;
|
||||
snprintf(Buffer, sizeof(Buffer)-1, "%10i", price);
|
||||
LogText += " TotalValue: ";
|
||||
LogText += Buffer;
|
||||
snprintf(Buffer, sizeof(Buffer)-1, " ItemID: %7i", item->ID);
|
||||
LogText += Buffer;
|
||||
LogText += " ";
|
||||
snprintf(Buffer, sizeof(Buffer)-1, " %s", item->Name);
|
||||
LogText += Buffer;
|
||||
|
||||
if (buying==true) {
|
||||
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Buying from Merchant",LogText.c_str(),2);
|
||||
}
|
||||
else {
|
||||
database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Selling to Merchant",LogText.c_str(),3);
|
||||
}
|
||||
//Inv2 redo or remove
|
||||
//if(!player || !merchant || !item)
|
||||
// return;
|
||||
//
|
||||
//std::string LogText = "Qty: ";
|
||||
//
|
||||
//char Buffer[255];
|
||||
//memset(Buffer, 0, sizeof(Buffer));
|
||||
//
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, "%3i", quantity);
|
||||
//LogText += Buffer;
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, "%10i", price);
|
||||
//LogText += " TotalValue: ";
|
||||
//LogText += Buffer;
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, " ItemID: %7i", item->ID);
|
||||
//LogText += Buffer;
|
||||
//LogText += " ";
|
||||
//snprintf(Buffer, sizeof(Buffer)-1, " %s", item->Name);
|
||||
//LogText += Buffer;
|
||||
//
|
||||
//if (buying==true) {
|
||||
// database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Buying from Merchant",LogText.c_str(),2);
|
||||
//}
|
||||
//else {
|
||||
// database.logevents(player->AccountName(),player->AccountID(),player->admin,player->GetName(),merchant->GetName(),"Selling to Merchant",LogText.c_str(),3);
|
||||
//}
|
||||
}
|
||||
|
||||
bool Client::BindWound(Mob* bindmob, bool start, bool fail){
|
||||
@@ -6922,11 +6868,7 @@ void Client::AddAlternateCurrencyValue(uint32 currency_id, int32 amount, int8 me
|
||||
|
||||
/* Added via Quest, rest of the logging methods may be done inline due to information available in that area of the code */
|
||||
if (method == 1){
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Added via Quest :: Cursor to Item :: alt_currency_id:%i amount:%i in zoneid:%i instid:%i", currency_id, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(amount == 0) {
|
||||
|
||||
+5
-5
@@ -245,8 +245,6 @@ public:
|
||||
virtual bool IsClient() const { return true; }
|
||||
void CompleteConnect();
|
||||
bool TryStacking(ItemInst* item, uint8 type = ItemPacketTrade, bool try_worn = true, bool try_cursor = true);
|
||||
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, uint8 type = ItemPacketTrade, bool try_worn = true, bool try_cursor = true);
|
||||
bool TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, const EQEmu::InventorySlot &slot, uint8 type = ItemPacketTrade);
|
||||
void SendTraderPacket(Client* trader, uint32 Unknown72 = 51);
|
||||
void SendBuyerPacket(Client* Buyer);
|
||||
GetItems_Struct* GetTraderItems();
|
||||
@@ -818,7 +816,6 @@ public:
|
||||
void DeleteItemInInventory(int16 slot_id, int8 quantity = 0, bool client_update = false, bool update_db = true);
|
||||
bool SwapItem(MoveItemOld_Struct* move_in);
|
||||
void SwapItemResync(MoveItemOld_Struct* move_slots);
|
||||
void QSSwapItemAuditor(MoveItemOld_Struct* move_in, bool postaction_call = false);
|
||||
void PutLootInInventory(int16 slot_id, const ItemInst &inst, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool AutoPutLootInInventory(ItemInst& inst, bool try_worn = false, bool try_cursor = true, ServerLootItem_Struct** bag_item_data = 0);
|
||||
bool SummonItem(uint32 item_id, int16 charges = -1,
|
||||
@@ -844,7 +841,10 @@ public:
|
||||
uint32 ornament_icon = 0,
|
||||
uint32 ornament_idfile = 0,
|
||||
uint32 ornament_hero_model = 0);
|
||||
bool PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update = false);
|
||||
bool PutItemInInventory(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, bool client_update = false);
|
||||
bool CanPutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end);
|
||||
void StackItem(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update);
|
||||
void PutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update);
|
||||
|
||||
//
|
||||
// class Client::TextLink
|
||||
@@ -902,7 +902,7 @@ public:
|
||||
bool IsBankSlot(uint32 slot);
|
||||
|
||||
//inv2
|
||||
void SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type);
|
||||
void SendItemPacket(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, ItemPacketType packet_type);
|
||||
|
||||
inline bool IsTrader() const { return(Trader); }
|
||||
inline bool IsBuyer() const { return(Buyer); }
|
||||
|
||||
+80
-194
@@ -783,11 +783,6 @@ void Client::CompleteConnect()
|
||||
/* This sub event is for if a player logs in for the first time since entering world. */
|
||||
if (firstlogon == 1){
|
||||
parse->EventPlayer(EVENT_CONNECT, this, "", 0);
|
||||
/* QS: PlayerLogConnectDisconnect */
|
||||
if (RuleB(QueryServ, PlayerLogConnectDisconnect)){
|
||||
std::string event_desc = StringFormat("Connect :: Logged into zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone) {
|
||||
@@ -2585,12 +2580,6 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Merchant Purchase */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Merchant Purchase :: Spent alt_currency_id:%i cost:%i for itemid:%i in zoneid:%i instid:%i", alt_cur_id, cost, item->ID, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
AddAlternateCurrencyValue(alt_cur_id, -((int32)cost));
|
||||
int16 charges = 1;
|
||||
if (item->MaxCharges != 0)
|
||||
@@ -2628,12 +2617,6 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app)
|
||||
uint32 removed = NukeItem(item_id, invWhereWorn | invWherePersonal | invWhereCursor);
|
||||
if (removed > 0) {
|
||||
AddAlternateCurrencyValue(reclaim->currency_id, removed);
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Item to Currency */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Reclaim :: Item to Currency :: alt_currency_id:%i amount:%i to currency tab in zoneid:%i instid:%i", reclaim->currency_id, removed, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Cursor to Item storage */
|
||||
@@ -2652,11 +2635,6 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app)
|
||||
SummonItem(item_id, reclaim->count, 0, 0, 0, 0, 0, 0, false, MainCursor);
|
||||
AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count));
|
||||
}
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Reclaim :: Cursor to Item :: alt_currency_id:%i amount:-%i in zoneid:%i instid:%i", reclaim->currency_id, reclaim->count, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2746,12 +2724,6 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app)
|
||||
|
||||
sell->cost = cost;
|
||||
|
||||
/* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/
|
||||
if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){
|
||||
std::string event_desc = StringFormat("Sold to Merchant :: itemid:%u npcid:%u alt_currency_id:%u cost:%u in zoneid:%u instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
FastQueuePacket(&outapp);
|
||||
AddAlternateCurrencyValue(alt_cur_id, cost);
|
||||
Save(1);
|
||||
@@ -12000,22 +11972,23 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
Merchant_Sell_Struct* mp = (Merchant_Sell_Struct*)app->pBuffer;
|
||||
|
||||
|
||||
int merchantid;
|
||||
bool tmpmer_used = false;
|
||||
Mob* tmp = entity_list.GetMob(mp->npcid);
|
||||
|
||||
|
||||
if (!tmp || !tmp->IsNPC() || tmp->GetClass() != MERCHANT)
|
||||
return;
|
||||
|
||||
if (mp->quantity < 1) return;
|
||||
|
||||
|
||||
if (mp->quantity < 1)
|
||||
return;
|
||||
|
||||
//you have to be somewhat close to them to be properly using them
|
||||
if (DistanceSquared(m_Position, tmp->GetPosition()) > USE_NPC_RANGE2)
|
||||
return;
|
||||
|
||||
|
||||
merchantid = tmp->CastToNPC()->MerchantType;
|
||||
|
||||
|
||||
uint32 item_id = 0;
|
||||
std::list<MerchantList> merlist = zone->merchanttable[merchantid];
|
||||
std::list<MerchantList>::const_iterator itr;
|
||||
@@ -12024,18 +11997,18 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
if (GetLevel() < ml.level_required) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int32 fac = tmp->GetPrimaryFaction();
|
||||
if (fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (mp->itemslot == ml.slot){
|
||||
item_id = ml.item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const ItemData* item = nullptr;
|
||||
|
||||
uint32 prevcharges = 0;
|
||||
if (item_id == 0) { //check to see if its on the temporary table
|
||||
std::list<TempMerchantList> tmp_merlist = zone->tmpmerchanttable[tmp->GetNPCTypeID()];
|
||||
@@ -12051,7 +12024,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
}
|
||||
}
|
||||
}
|
||||
item = database.GetItem(item_id);
|
||||
|
||||
const ItemData* item = database.GetItem(item_id);
|
||||
if (!item){
|
||||
//error finding item, client didnt get the update packet for whatever reason, roleplay a tad
|
||||
Message(15, "%s tells you 'Sorry, that item is for display purposes only.' as they take the item off the shelf.", tmp->GetCleanName());
|
||||
@@ -12065,11 +12039,13 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
safe_delete(delitempacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_inventory.CheckLoreConflict(item))
|
||||
{
|
||||
Message(15, "You can only have one of a lore item.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (tmpmer_used && (mp->quantity > prevcharges || item->MaxCharges > 1))
|
||||
{
|
||||
if (prevcharges > item->MaxCharges && item->MaxCharges > 1)
|
||||
@@ -12077,88 +12053,75 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
else
|
||||
mp->quantity = prevcharges;
|
||||
}
|
||||
|
||||
|
||||
// Item's stackable, but the quantity they want to buy exceeds the max stackable quantity.
|
||||
if (item->Stackable && mp->quantity > item->StackSize)
|
||||
mp->quantity = item->StackSize;
|
||||
|
||||
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopPlayerBuy, sizeof(Merchant_Sell_Struct));
|
||||
Merchant_Sell_Struct* mpo = (Merchant_Sell_Struct*)outapp->pBuffer;
|
||||
mpo->quantity = mp->quantity;
|
||||
mpo->playerid = mp->playerid;
|
||||
mpo->npcid = mp->npcid;
|
||||
mpo->itemslot = mp->itemslot;
|
||||
|
||||
|
||||
EQEmu::InventorySlot free_slot;
|
||||
int16 charges = 0;
|
||||
int charges = 0;
|
||||
if (item->Stackable || item->MaxCharges > 1)
|
||||
charges = mp->quantity;
|
||||
else
|
||||
charges = item->MaxCharges;
|
||||
|
||||
auto inst = database.CreateItem(item->ID, charges);
|
||||
|
||||
|
||||
int SinglePrice = 0;
|
||||
if (RuleB(Merchant, UsePriceMod))
|
||||
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(tmp, false));
|
||||
else
|
||||
SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate);
|
||||
|
||||
|
||||
if (item->MaxCharges > 1)
|
||||
mpo->price = SinglePrice;
|
||||
else
|
||||
mpo->price = SinglePrice * mp->quantity;
|
||||
|
||||
|
||||
if (mpo->price < 0)
|
||||
{
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_inventory.Get(EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor))) {
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
auto inst = database.CreateItem(item->ID, charges);
|
||||
|
||||
if(!CanPutItemInInventory(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10)) {
|
||||
Message(13, "You do not have room for any more items.");
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
// this area needs some work..two inventory insertion check failure points
|
||||
// below do not return player's money..is this the intended behavior?
|
||||
|
||||
if (!TakeMoneyFromPP(mpo->price))
|
||||
{
|
||||
char *hacker_str = nullptr;
|
||||
MakeAnyLenString(&hacker_str, "Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n",
|
||||
std::string hacker_str = StringFormat("Vendor Cheat: attempted to buy %i of %i: %s that cost %d cp but only has %d pp %d gp %d sp %d cp\n",
|
||||
mpo->quantity, item->ID, item->Name,
|
||||
mpo->price, m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper);
|
||||
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str, zone->GetShortName());
|
||||
safe_delete_array(hacker_str);
|
||||
database.SetMQDetectionFlag(AccountName(), GetName(), hacker_str.c_str(), zone->GetShortName());
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
bool stacked = TryStacking(inst);
|
||||
if(!stacked) {
|
||||
free_slot = m_inventory.FindFreeSlot(false, true, item->Size);
|
||||
}
|
||||
|
||||
if(free_slot.IsCursor()) {
|
||||
Message(13, "You do not have room for any more items.");
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!stacked && !free_slot.IsValid())
|
||||
{
|
||||
Message(13, "You do not have room for any more items.");
|
||||
safe_delete(outapp);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string packet;
|
||||
if(!stacked && inst) {
|
||||
PutItemInInventory(free_slot, inst);
|
||||
SendItemPacket(free_slot, inst, ItemPacketTrade);
|
||||
}
|
||||
else if (!stacked){
|
||||
Log.Out(Logs::General, Logs::Error, "OP_ShopPlayerBuy: item->ItemClass Unknown! Type: %i", item->ItemClass);
|
||||
}
|
||||
|
||||
QueuePacket(outapp);
|
||||
if (inst && tmpmer_used){
|
||||
safe_delete(outapp);
|
||||
|
||||
PutItemInInventory(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10, true);
|
||||
|
||||
if (inst && tmpmer_used) {
|
||||
int32 new_charges = prevcharges - mp->quantity;
|
||||
zone->SaveTempItem(merchantid, tmp->GetNPCTypeID(), item_id, new_charges);
|
||||
if (new_charges <= 0){
|
||||
@@ -12181,12 +12144,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app)
|
||||
SendItemPacket(EQEmu::InventorySlot(EQEmu::InvTypeMerchant, mp->itemslot), inst, ItemPacketMerchant);
|
||||
}
|
||||
}
|
||||
safe_delete(outapp);
|
||||
|
||||
|
||||
if (RuleB(EventLog, RecordBuyFromMerchant))
|
||||
LogMerchant(this, tmp, mpo->quantity, mpo->price, item, true);
|
||||
|
||||
zone->LogEvent(EventLogItemBuy, this, StringFormat("Merc(%i) -> player %s(%i) %i charges for %ic", merchantid, item->Name, item->ID, mpo->quantity, mpo->price));
|
||||
if ((RuleB(Character, EnableDiscoveredItems)))
|
||||
{
|
||||
if (!GetGM() && !IsDiscovered(item_id))
|
||||
@@ -12288,38 +12247,38 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
// start QS code
|
||||
if (RuleB(QueryServ, PlayerLogMerchantTransactions)) {
|
||||
ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct)+sizeof(QSTransactionItems_Struct));
|
||||
QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer;
|
||||
|
||||
qsaudit->zone_id = zone->GetZoneID();
|
||||
qsaudit->merchant_id = vendor->CastToNPC()->MerchantType;
|
||||
qsaudit->merchant_money.platinum = (price / 1000);
|
||||
qsaudit->merchant_money.gold = (price / 100) % 10;
|
||||
qsaudit->merchant_money.silver = (price / 10) % 10;
|
||||
qsaudit->merchant_money.copper = price % 10;
|
||||
qsaudit->merchant_count = 0;
|
||||
qsaudit->char_id = character_id;
|
||||
qsaudit->char_money.platinum = 0;
|
||||
qsaudit->char_money.gold = 0;
|
||||
qsaudit->char_money.silver = 0;
|
||||
qsaudit->char_money.copper = 0;
|
||||
qsaudit->char_count = 1;
|
||||
|
||||
qsaudit->items[0].char_slot = mp->itemslot;
|
||||
qsaudit->items[0].item_id = itemid;
|
||||
qsaudit->items[0].charges = charges;
|
||||
qsaudit->items[0].aug_1 = m_inv[mp->itemslot]->GetAugmentItemID(1);
|
||||
qsaudit->items[0].aug_2 = m_inv[mp->itemslot]->GetAugmentItemID(2);
|
||||
qsaudit->items[0].aug_3 = m_inv[mp->itemslot]->GetAugmentItemID(3);
|
||||
qsaudit->items[0].aug_4 = m_inv[mp->itemslot]->GetAugmentItemID(4);
|
||||
qsaudit->items[0].aug_5 = m_inv[mp->itemslot]->GetAugmentItemID(5);
|
||||
|
||||
qspack->Deflate();
|
||||
if (worldserver.Connected()) { worldserver.SendPacket(qspack); }
|
||||
safe_delete(qspack);
|
||||
}
|
||||
// end QS code
|
||||
//if (RuleB(QueryServ, PlayerLogMerchantTransactions)) {
|
||||
// ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, sizeof(QSMerchantLogTransaction_Struct)+sizeof(QSTransactionItems_Struct));
|
||||
// QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer;
|
||||
//
|
||||
// qsaudit->zone_id = zone->GetZoneID();
|
||||
// qsaudit->merchant_id = vendor->CastToNPC()->MerchantType;
|
||||
// qsaudit->merchant_money.platinum = (price / 1000);
|
||||
// qsaudit->merchant_money.gold = (price / 100) % 10;
|
||||
// qsaudit->merchant_money.silver = (price / 10) % 10;
|
||||
// qsaudit->merchant_money.copper = price % 10;
|
||||
// qsaudit->merchant_count = 0;
|
||||
// qsaudit->char_id = character_id;
|
||||
// qsaudit->char_money.platinum = 0;
|
||||
// qsaudit->char_money.gold = 0;
|
||||
// qsaudit->char_money.silver = 0;
|
||||
// qsaudit->char_money.copper = 0;
|
||||
// qsaudit->char_count = 1;
|
||||
//
|
||||
// qsaudit->items[0].char_slot = mp->itemslot;
|
||||
// qsaudit->items[0].item_id = itemid;
|
||||
// qsaudit->items[0].charges = charges;
|
||||
// qsaudit->items[0].aug_1 = m_inv[mp->itemslot]->GetAugmentItemID(1);
|
||||
// qsaudit->items[0].aug_2 = m_inv[mp->itemslot]->GetAugmentItemID(2);
|
||||
// qsaudit->items[0].aug_3 = m_inv[mp->itemslot]->GetAugmentItemID(3);
|
||||
// qsaudit->items[0].aug_4 = m_inv[mp->itemslot]->GetAugmentItemID(4);
|
||||
// qsaudit->items[0].aug_5 = m_inv[mp->itemslot]->GetAugmentItemID(5);
|
||||
//
|
||||
// qspack->Deflate();
|
||||
// if (worldserver.Connected()) { worldserver.SendPacket(qspack); }
|
||||
// safe_delete(qspack);
|
||||
//}
|
||||
//// end QS code
|
||||
|
||||
// Now remove the item from the player, this happens regardless of outcome
|
||||
if (!inst->IsStackable())
|
||||
@@ -13107,46 +13066,8 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
|
||||
other->trade->LogTrade();
|
||||
trade->LogTrade();
|
||||
|
||||
// start QS code
|
||||
if (RuleB(QueryServ, PlayerLogTrades)) {
|
||||
QSPlayerLogTrade_Struct event_entry;
|
||||
std::list<void*> event_details;
|
||||
|
||||
memset(&event_entry, 0, sizeof(QSPlayerLogTrade_Struct));
|
||||
|
||||
// Perform actual trade
|
||||
this->FinishTrade(other, true, &event_entry, &event_details);
|
||||
other->FinishTrade(this, false, &event_entry, &event_details);
|
||||
|
||||
event_entry._detail_count = event_details.size();
|
||||
|
||||
ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct)+(sizeof(QSTradeItems_Struct)* event_entry._detail_count));
|
||||
QSPlayerLogTrade_Struct* qs_buf = (QSPlayerLogTrade_Struct*)qs_pack->pBuffer;
|
||||
|
||||
memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogTrade_Struct));
|
||||
|
||||
int offset = 0;
|
||||
|
||||
for (std::list<void*>::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) {
|
||||
QSTradeItems_Struct* detail = reinterpret_cast<QSTradeItems_Struct*>(*iter);
|
||||
qs_buf->items[offset] = *detail;
|
||||
safe_delete(detail);
|
||||
}
|
||||
|
||||
event_details.clear();
|
||||
|
||||
qs_pack->Deflate();
|
||||
|
||||
if (worldserver.Connected())
|
||||
worldserver.SendPacket(qs_pack);
|
||||
|
||||
safe_delete(qs_pack);
|
||||
// end QS code
|
||||
}
|
||||
else {
|
||||
this->FinishTrade(other);
|
||||
other->FinishTrade(this);
|
||||
}
|
||||
this->FinishTrade(other);
|
||||
other->FinishTrade(this);
|
||||
|
||||
other->trade->Reset();
|
||||
trade->Reset();
|
||||
@@ -13163,42 +13084,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app)
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
if (with->IsNPC()) {
|
||||
// Audit trade to database for player trade stream
|
||||
if (RuleB(QueryServ, PlayerLogHandins)) {
|
||||
QSPlayerLogHandin_Struct event_entry;
|
||||
std::list<void*> event_details;
|
||||
|
||||
memset(&event_entry, 0, sizeof(QSPlayerLogHandin_Struct));
|
||||
|
||||
FinishTrade(with->CastToNPC(), false, &event_entry, &event_details);
|
||||
|
||||
event_entry._detail_count = event_details.size();
|
||||
|
||||
ServerPacket* qs_pack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct)+(sizeof(QSHandinItems_Struct)* event_entry._detail_count));
|
||||
QSPlayerLogHandin_Struct* qs_buf = (QSPlayerLogHandin_Struct*)qs_pack->pBuffer;
|
||||
|
||||
memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogHandin_Struct));
|
||||
|
||||
int offset = 0;
|
||||
|
||||
for (std::list<void*>::iterator iter = event_details.begin(); iter != event_details.end(); ++iter, ++offset) {
|
||||
QSHandinItems_Struct* detail = reinterpret_cast<QSHandinItems_Struct*>(*iter);
|
||||
qs_buf->items[offset] = *detail;
|
||||
safe_delete(detail);
|
||||
}
|
||||
|
||||
event_details.clear();
|
||||
|
||||
qs_pack->Deflate();
|
||||
|
||||
if (worldserver.Connected())
|
||||
worldserver.SendPacket(qs_pack);
|
||||
|
||||
safe_delete(qs_pack);
|
||||
}
|
||||
else {
|
||||
FinishTrade(with->CastToNPC());
|
||||
}
|
||||
FinishTrade(with->CastToNPC());
|
||||
}
|
||||
#ifdef BOTS
|
||||
// TODO: Log Bot trades
|
||||
|
||||
@@ -782,12 +782,6 @@ void Client::OnDisconnect(bool hard_disconnect) {
|
||||
MyRaid->MemberZoned(this);
|
||||
|
||||
parse->EventPlayer(EVENT_DISCONNECT, this, "", 0);
|
||||
|
||||
/* QS: PlayerLogConnectDisconnect */
|
||||
if (RuleB(QueryServ, PlayerLogConnectDisconnect)){
|
||||
std::string event_desc = StringFormat("Disconnect :: in zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
Mob *Other = trade->With();
|
||||
|
||||
@@ -547,8 +547,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
{
|
||||
Seperator sep(message, ' ', 10, 100, true); // "three word argument" should be considered 1 arg
|
||||
|
||||
command_logcommand(c, message);
|
||||
|
||||
std::string cstr(sep.arg[0]+1);
|
||||
|
||||
if(commandlist.count(cstr) != 1) {
|
||||
@@ -561,12 +559,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Issued_Commands */
|
||||
if (RuleB(QueryServ, PlayerLogIssuedCommandes)){
|
||||
std::string event_desc = StringFormat("Issued command :: '%s' in zoneid:%i instid:%i", message, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Issued_Commands, c->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
if(cur->access >= COMMANDS_LOGGING_MIN_STATUS) {
|
||||
Log.Out(Logs::General, Logs::Commands, "%s (%s) used command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE");
|
||||
}
|
||||
@@ -582,71 +574,6 @@ int command_realdispatch(Client *c, const char *message)
|
||||
|
||||
}
|
||||
|
||||
void command_logcommand(Client *c, const char *message)
|
||||
{
|
||||
int admin=c->Admin();
|
||||
|
||||
bool continueevents=false;
|
||||
switch (zone->loglevelvar){ //catch failsafe
|
||||
case 9: { // log only LeadGM
|
||||
if ((admin>= 150) && (admin <200))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 8: { // log only GM
|
||||
if ((admin>= 100) && (admin <150))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if ((admin>= 200))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if ((admin>= 150))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
if ((admin>= 100))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
if ((admin>= 80))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
if ((admin>= 20))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
if ((admin>= 10))
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
continueevents=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (continueevents)
|
||||
database.logevents(
|
||||
c->AccountName(),
|
||||
c->AccountID(),
|
||||
admin,c->GetName(),
|
||||
c->GetTarget()?c->GetTarget()->GetName():"None",
|
||||
"Command",
|
||||
message,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* commands go below here
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,6 @@ void command_deinit(void);
|
||||
int command_add(const char *command_string, const char *desc, int access, CmdFuncPtr function);
|
||||
int command_notavail(Client *c, const char *message);
|
||||
int command_realdispatch(Client *c, char const *message);
|
||||
void command_logcommand(Client *c, const char *message);
|
||||
|
||||
//commands
|
||||
void command_resetaa(Client* c,const Seperator *sep);
|
||||
|
||||
@@ -3520,10 +3520,11 @@ XS(XS__qs_player_event)
|
||||
if (items != 2){
|
||||
Perl_croak(aTHX_ "Usage: qs_player_event(char_id, event_desc)");
|
||||
}
|
||||
else{
|
||||
else {
|
||||
int char_id = (int)SvIV(ST(0));
|
||||
std::string event_desc = (std::string)SvPV_nolen(ST(1));
|
||||
QServ->PlayerLogEvent(Player_Log_Quest, char_id, event_desc);
|
||||
Client *c = entity_list.GetClientByCharID(char_id);
|
||||
zone->LogEvent(EventLogQuest, c, event_desc);
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
@@ -430,13 +430,6 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) {
|
||||
//Message(15, "You have gained %d skill points!!", m_pp.aapoints - last_unspentAA);
|
||||
char val1[20]={0};
|
||||
Message_StringID(MT_Experience, GAIN_ABILITY_POINT,ConvertArray(m_pp.aapoints, val1),m_pp.aapoints == 1 ? "" : "(s)"); //You have gained an ability point! You now have %1 ability point%2.
|
||||
|
||||
/* QS: PlayerLogAARate */
|
||||
if (RuleB(QueryServ, PlayerLogAARate)){
|
||||
int add_points = (m_pp.aapoints - last_unspentAA);
|
||||
std::string query = StringFormat("INSERT INTO `qs_player_aa_rate_hourly` (char_id, aa_count, hour_time) VALUES (%i, %i, UNIX_TIMESTAMP() - MOD(UNIX_TIMESTAMP(), 3600)) ON DUPLICATE KEY UPDATE `aa_count` = `aa_count` + %i", this->CharacterID(), add_points, add_points);
|
||||
QServ->SendQuery(query.c_str());
|
||||
}
|
||||
|
||||
//Message(15, "You now have %d skill points available to spend.", m_pp.aapoints);
|
||||
}
|
||||
@@ -571,18 +564,6 @@ void Client::SetLevel(uint8 set_level, bool command)
|
||||
}
|
||||
if(set_level > m_pp.level) {
|
||||
parse->EventPlayer(EVENT_LEVEL_UP, this, "", 0);
|
||||
/* QS: PlayerLogLevels */
|
||||
if (RuleB(QueryServ, PlayerLogLevels)){
|
||||
std::string event_desc = StringFormat("Leveled UP :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
else if (set_level < m_pp.level){
|
||||
/* QS: PlayerLogLevels */
|
||||
if (RuleB(QueryServ, PlayerLogLevels)){
|
||||
std::string event_desc = StringFormat("Leveled DOWN :: to Level:%i from Level:%i in zoneid:%i instid:%i", set_level, m_pp.level, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Levels, this->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
m_pp.level = set_level;
|
||||
|
||||
+148
-156
@@ -20,6 +20,7 @@
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/string_util.h"
|
||||
#include "../common/data_verification.h"
|
||||
#include "../common/item_data.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "worldserver.h"
|
||||
#include "zonedb.h"
|
||||
@@ -981,47 +982,6 @@ bool Client::TryStacking(ItemInst* item, uint8 type, bool try_worn, bool try_cur
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, uint8 type, bool try_worn, bool try_cursor) {
|
||||
if(!item || !item->IsStackable() || item->GetCharges() >= item->GetItem()->StackSize)
|
||||
return false;
|
||||
|
||||
if(try_worn) {
|
||||
for(int i = EQEmu::PersonalSlotCharm; i <= EQEmu::PersonalSlotAmmo; ++i) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, i), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = EQEmu::PersonalSlotGeneral1; i <= EQEmu::PersonalSlotGeneral10; ++i) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, i), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(try_cursor) {
|
||||
if(TryStacking(item, EQEmu::InventorySlot(EQEmu::InvTypePersonal, EQEmu::PersonalSlotCursor), type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Client::TryStacking(std::shared_ptr<EQEmu::ItemInstance> item, const EQEmu::InventorySlot &slot, uint8 type) {
|
||||
//make this a function
|
||||
uint32 item_id = item->GetItem()->ID;
|
||||
auto tmp_inst = m_inventory.Get(slot);
|
||||
if(tmp_inst && tmp_inst->GetItem()->ID == item_id && tmp_inst->GetCharges() < tmp_inst->GetItem()->StackSize) {
|
||||
bool v = m_inventory.TryStacking(item, slot);
|
||||
if(v) {
|
||||
SendItemPacket(slot, item, ItemPacketTrade);
|
||||
}
|
||||
}
|
||||
|
||||
return item->GetCharges() == 0;
|
||||
}
|
||||
|
||||
// Locate an available space in inventory to place an item
|
||||
// and then put the item there
|
||||
// The change will be saved to the database
|
||||
@@ -1416,7 +1376,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
}
|
||||
|
||||
if (move_in->from_slot == move_in->to_slot) { // Item summon, no further processing needed
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
if (GetClientVersion() >= ClientVersion::RoF) { return true; } // Can't do RoF+
|
||||
|
||||
if (move_in->to_slot == MainCursor) {
|
||||
@@ -1448,7 +1408,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
if (move_in->to_slot == (uint32)INVALID_INDEX) {
|
||||
if (move_in->from_slot == (uint32)MainCursor) {
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Client destroyed item from cursor slot %d", move_in->from_slot);
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
ItemInst *inst = m_inv.GetItem(MainCursor);
|
||||
if(inst) {
|
||||
@@ -1462,7 +1422,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Inventory, "Deleted item from slot %d as a result of an inventory container tradeskill combine.", move_in->from_slot);
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
DeleteItemInInventory(move_in->from_slot);
|
||||
return true; // Item deletion
|
||||
}
|
||||
@@ -1623,7 +1583,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
safe_delete(inst);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1693,7 +1653,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
database.SaveInventory(character_id, m_inv[src_slot_id], src_slot_id);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1715,7 +1675,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
|
||||
// Add cursor item to trade bucket
|
||||
// Also sends trade information to other client of trade session
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
trade->AddEntity(dst_slot_id, move_in->number_in_stack);
|
||||
if (dstitemid == 0)
|
||||
@@ -1725,7 +1685,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
|
||||
|
||||
|
||||
SummonItem(src_inst->GetID(), src_inst->GetCharges(), 0);
|
||||
DeleteItemInInventory(MainCursor);
|
||||
@@ -1859,7 +1819,7 @@ bool Client::SwapItem(MoveItemOld_Struct* move_in) {
|
||||
database.SaveInventory(character_id, m_inv.GetItem(dst_slot_id), dst_slot_id);
|
||||
}
|
||||
|
||||
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in, true); } // QS Audit
|
||||
|
||||
|
||||
// Step 8: Re-calc stats
|
||||
CalcBonuses();
|
||||
@@ -1960,104 +1920,6 @@ void Client::SwapItemResync(MoveItemOld_Struct* move_slots) {
|
||||
}
|
||||
}
|
||||
|
||||
void Client::QSSwapItemAuditor(MoveItemOld_Struct* move_in, bool postaction_call) {
|
||||
int16 from_slot_id = static_cast<int16>(move_in->from_slot);
|
||||
int16 to_slot_id = static_cast<int16>(move_in->to_slot);
|
||||
int16 move_amount = static_cast<int16>(move_in->number_in_stack);
|
||||
|
||||
if(!m_inv[from_slot_id] && !m_inv[to_slot_id]) { return; }
|
||||
|
||||
uint16 move_count = 0;
|
||||
|
||||
if(m_inv[from_slot_id]) { move_count += m_inv[from_slot_id]->GetTotalItemCount(); }
|
||||
if(to_slot_id != from_slot_id) { if(m_inv[to_slot_id]) { move_count += m_inv[to_slot_id]->GetTotalItemCount(); } }
|
||||
|
||||
ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogMoves, sizeof(QSPlayerLogMove_Struct) + (sizeof(QSMoveItems_Struct) * move_count));
|
||||
QSPlayerLogMove_Struct* qsaudit = (QSPlayerLogMove_Struct*)qspack->pBuffer;
|
||||
|
||||
qsaudit->char_id = character_id;
|
||||
qsaudit->stack_size = move_amount;
|
||||
qsaudit->char_count = move_count;
|
||||
qsaudit->postaction = postaction_call;
|
||||
qsaudit->from_slot = from_slot_id;
|
||||
qsaudit->to_slot = to_slot_id;
|
||||
|
||||
move_count = 0;
|
||||
|
||||
const ItemInst* from_inst = m_inv[postaction_call?to_slot_id:from_slot_id];
|
||||
|
||||
if(from_inst) {
|
||||
qsaudit->items[move_count].from_slot = from_slot_id;
|
||||
qsaudit->items[move_count].to_slot = to_slot_id;
|
||||
qsaudit->items[move_count].item_id = from_inst->GetID();
|
||||
qsaudit->items[move_count].charges = from_inst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = from_inst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = from_inst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = from_inst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = from_inst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = from_inst->GetAugmentItemID(5);
|
||||
|
||||
if(from_inst->IsType(ItemClassContainer)) {
|
||||
for(uint8 bag_idx = SUB_BEGIN; bag_idx < from_inst->GetItem()->BagSlots; bag_idx++) {
|
||||
const ItemInst* from_baginst = from_inst->GetItem(bag_idx);
|
||||
|
||||
if(from_baginst) {
|
||||
qsaudit->items[move_count].from_slot = InventoryOld::CalcSlotId(from_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].to_slot = InventoryOld::CalcSlotId(to_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].item_id = from_baginst->GetID();
|
||||
qsaudit->items[move_count].charges = from_baginst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = from_baginst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = from_baginst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = from_baginst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = from_baginst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = from_baginst->GetAugmentItemID(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(to_slot_id != from_slot_id) {
|
||||
const ItemInst* to_inst = m_inv[postaction_call?from_slot_id:to_slot_id];
|
||||
|
||||
if(to_inst) {
|
||||
qsaudit->items[move_count].from_slot = to_slot_id;
|
||||
qsaudit->items[move_count].to_slot = from_slot_id;
|
||||
qsaudit->items[move_count].item_id = to_inst->GetID();
|
||||
qsaudit->items[move_count].charges = to_inst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = to_inst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = to_inst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = to_inst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = to_inst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = to_inst->GetAugmentItemID(5);
|
||||
|
||||
if(to_inst->IsType(ItemClassContainer)) {
|
||||
for(uint8 bag_idx = SUB_BEGIN; bag_idx < to_inst->GetItem()->BagSlots; bag_idx++) {
|
||||
const ItemInst* to_baginst = to_inst->GetItem(bag_idx);
|
||||
|
||||
if(to_baginst) {
|
||||
qsaudit->items[move_count].from_slot = InventoryOld::CalcSlotId(to_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].to_slot = InventoryOld::CalcSlotId(from_slot_id, bag_idx);
|
||||
qsaudit->items[move_count].item_id = to_baginst->GetID();
|
||||
qsaudit->items[move_count].charges = to_baginst->GetCharges();
|
||||
qsaudit->items[move_count].aug_1 = to_baginst->GetAugmentItemID(1);
|
||||
qsaudit->items[move_count].aug_2 = to_baginst->GetAugmentItemID(2);
|
||||
qsaudit->items[move_count].aug_3 = to_baginst->GetAugmentItemID(3);
|
||||
qsaudit->items[move_count].aug_4 = to_baginst->GetAugmentItemID(4);
|
||||
qsaudit->items[move_count++].aug_5 = to_baginst->GetAugmentItemID(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(move_count && worldserver.Connected()) {
|
||||
qspack->Deflate();
|
||||
worldserver.SendPacket(qspack);
|
||||
}
|
||||
|
||||
safe_delete(qspack);
|
||||
}
|
||||
|
||||
void Client::DyeArmor(DyeStruct* dye){
|
||||
int16 slot=0;
|
||||
for (int i = EmuConstants::MATERIAL_BEGIN; i <= EmuConstants::MATERIAL_TINT_END; i++) {
|
||||
@@ -2710,7 +2572,7 @@ void Client::SendItemPacket(int16 slot_id, const ItemInst* inst, ItemPacketType
|
||||
// FastQueuePacket(&outapp);
|
||||
}
|
||||
|
||||
void Client::SendItemPacket(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, ItemPacketType packet_type) {
|
||||
void Client::SendItemPacket(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, ItemPacketType packet_type) {
|
||||
if(!inst) {
|
||||
return;
|
||||
}
|
||||
@@ -3462,13 +3324,13 @@ bool Client::SummonItem(uint32 item_id,
|
||||
uint32 ornament_idfile,
|
||||
uint32 ornament_hero_model)
|
||||
{
|
||||
std::shared_ptr<EQEmu::ItemInstance> inst = database.CreateItem(item_id, charges);
|
||||
EQEmu::ItemInstance::pointer &inst = database.CreateItem(item_id, charges);
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
if(inst->GetBaseItem()->ItemClass == ItemClassCommon) {
|
||||
if(aug1) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug1);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug1);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3478,7 +3340,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug2) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug2);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug2);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3488,7 +3350,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug3) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug3);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug3);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3498,7 +3360,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug4) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug4);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug4);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3508,7 +3370,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug5) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug5);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug5);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3518,7 +3380,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
}
|
||||
|
||||
if(aug6) {
|
||||
std::shared_ptr<EQEmu::ItemInstance> aug = database.CreateItem(aug6);
|
||||
EQEmu::ItemInstance::pointer aug = database.CreateItem(aug6);
|
||||
if(!aug)
|
||||
return false;
|
||||
|
||||
@@ -3536,7 +3398,7 @@ bool Client::SummonItem(uint32 item_id,
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_ptr<EQEmu::ItemInstance> inst, bool client_update) {
|
||||
bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, EQEmu::ItemInstance::pointer &inst, bool client_update) {
|
||||
if(!inst)
|
||||
return false;
|
||||
|
||||
@@ -3555,4 +3417,134 @@ bool Client::PutItemInInventory(const EQEmu::InventorySlot &slot, std::shared_pt
|
||||
}
|
||||
|
||||
CalcBonuses();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Client::CanPutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end) {
|
||||
if(inst->IsStackable()) {
|
||||
int charges = m_inventory.FindFreeStackSlots(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10);
|
||||
|
||||
if(charges < inst->GetCharges()) {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
|
||||
if(!slot.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
if(!slot.IsValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Client::StackItem(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update) {
|
||||
auto item_id = inst->GetBaseItem()->ID;
|
||||
|
||||
//not the most efficient of functions but in reality it's fast enough
|
||||
|
||||
//go through the top level slots first
|
||||
for(int i = slot_id_start; i < slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
auto item = m_inventory.Get(slot);
|
||||
|
||||
if(!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item->GetBaseItem()->ID == item_id) {
|
||||
auto free_charges = item->GetItem()->StackSize - item->GetCharges();
|
||||
|
||||
if(inst->GetCharges() > free_charges) {
|
||||
item->SetCharges(item->GetCharges() + free_charges);
|
||||
inst->SetCharges(inst->GetCharges() - free_charges);
|
||||
|
||||
m_inventory.UpdateSlot(slot, item);
|
||||
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
} else {
|
||||
item->SetCharges(item->GetCharges() + inst->GetCharges());
|
||||
inst->SetCharges(0);
|
||||
|
||||
m_inventory.UpdateSlot(slot, item);
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//go through the top level slots bag slots
|
||||
for(int i = slot_id_start; i < slot_id_end; ++i) {
|
||||
EQEmu::InventorySlot slot(container_id, i);
|
||||
auto item = m_inventory.Get(slot);
|
||||
|
||||
if(!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(item->GetBaseItem()->ItemClass != ItemClassContainer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int sz = item->GetBaseItem()->BagSlots;
|
||||
bool update_bag = false;
|
||||
for(int j = 0; j < sz; ++j) {
|
||||
auto sub_item = item->Get(j);
|
||||
|
||||
if(!sub_item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(sub_item->GetBaseItem()->ID == item_id) {
|
||||
EQEmu::InventorySlot bag_slot(container_id, i, j);
|
||||
auto free_charges = sub_item->GetItem()->StackSize - sub_item->GetCharges();
|
||||
|
||||
if(inst->GetCharges() > free_charges) {
|
||||
sub_item->SetCharges(sub_item->GetCharges() + free_charges);
|
||||
inst->SetCharges(inst->GetCharges() - free_charges);
|
||||
|
||||
m_inventory.UpdateSlot(bag_slot, sub_item);
|
||||
update_bag = true;
|
||||
}
|
||||
else {
|
||||
sub_item->SetCharges(sub_item->GetCharges() + inst->GetCharges());
|
||||
inst->SetCharges(0);
|
||||
|
||||
m_inventory.UpdateSlot(bag_slot, sub_item);
|
||||
if(client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(update_bag && client_update) {
|
||||
SendItemPacket(slot, item, slot.IsCursor() ? ItemPacketSummonItem : ItemPacketTrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client::PutItemInInventory(EQEmu::ItemInstance::pointer &inst, int container_id, int slot_id_start, int slot_id_end, bool client_update) {
|
||||
if(inst->IsStackable()) {
|
||||
StackItem(inst, EQEmu::InvTypePersonal, EQEmu::PersonalSlotGeneral1, EQEmu::PersonalSlotGeneral10, client_update);
|
||||
|
||||
if(inst->GetCharges() > 0) {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
PutItemInInventory(slot, inst, client_update);
|
||||
}
|
||||
} else {
|
||||
EQEmu::InventorySlot slot = m_inventory.FindFreeSlot(inst, container_id, slot_id_start, slot_id_end);
|
||||
PutItemInInventory(slot, inst, client_update);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,3 @@ void QueryServ::SendQuery(std::string Query)
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
void QueryServ::PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc)
|
||||
{
|
||||
std::string query = StringFormat(
|
||||
"INSERT INTO `qs_player_events` (event, char_id, event_desc, time) VALUES (%i, %i, '%s', UNIX_TIMESTAMP(now()))",
|
||||
Event_Type, Character_ID, EscapeString(Event_Desc).c_str());
|
||||
SendQuery(query);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ class QueryServ{
|
||||
QueryServ();
|
||||
~QueryServ();
|
||||
void SendQuery(std::string Query);
|
||||
void PlayerLogEvent(int Event_Type, int Character_ID, std::string Event_Desc);
|
||||
};
|
||||
|
||||
#endif /* QUERYSERV_ZONE_H */
|
||||
@@ -1370,12 +1370,6 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
}
|
||||
|
||||
InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, newvalue, QGVarDuration(duration));
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Update :: qglobal:%s to qvalue:%s zoneid:%i instid:%i", varname, newvalue, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Inserts global variable into quest_globals table */
|
||||
@@ -1462,12 +1456,6 @@ void QuestManager::delglobal(const char *varname) {
|
||||
else
|
||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
|
||||
std::string query = StringFormat("DELETE FROM quest_globals "
|
||||
"WHERE name = '%s' "
|
||||
"&& (npcid=0 || npcid=%i) "
|
||||
|
||||
@@ -1821,11 +1821,6 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
||||
buf[23] = '\0';
|
||||
parse->EventPlayer(EVENT_TASK_STAGE_COMPLETE, c, buf, 0);
|
||||
}
|
||||
/* QS: PlayerLogTaskUpdates :: Update */
|
||||
if (RuleB(QueryServ, PlayerLogTaskUpdates)){
|
||||
std::string event_desc = StringFormat("Task Stage Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
||||
}
|
||||
}
|
||||
|
||||
// If this task is now complete, the Completed tasks will have been
|
||||
@@ -1837,12 +1832,6 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T
|
||||
buf[23] = '\0';
|
||||
parse->EventPlayer(EVENT_TASK_COMPLETE, c, buf, 0);
|
||||
|
||||
/* QS: PlayerLogTaskUpdates :: Complete */
|
||||
if (RuleB(QueryServ, PlayerLogTaskUpdates)){
|
||||
std::string event_desc = StringFormat("Task Complete :: taskid:%i activityid:%i donecount:%i in zoneid:%i instid:%i", ActiveTasks[TaskIndex].TaskID, ActiveTasks[TaskIndex].Activity[ActivityID].ActivityID, ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, c->GetZoneID(), c->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Task_Updates, c->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
taskmanager->SendCompletedTasksToClient(c, this);
|
||||
c->SendTaskActivityComplete(ActiveTasks[TaskIndex].TaskID, 0, TaskIndex, false);
|
||||
taskmanager->SaveClientState(c, this);
|
||||
|
||||
@@ -1091,12 +1091,6 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
||||
entity_list.MessageGroup(this, true, MT_Skills, "%s has successfully fashioned %s!", GetName(), item->Name);
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Trade_Skill_Events */
|
||||
if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){
|
||||
std::string event_desc = StringFormat("Success :: fashioned recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityTradeSkill, itr->first, itr->second);
|
||||
++itr;
|
||||
@@ -1119,12 +1113,6 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
||||
|
||||
}
|
||||
|
||||
/* QS: Player_Log_Trade_Skill_Events */
|
||||
if (RuleB(QueryServ, PlayerLogTradeSkillEvents)){
|
||||
std::string event_desc = StringFormat("Failed :: recipe_id:%i tskillid:%i trivial:%i chance:%4.2f in zoneid:%i instid:%i", spec->recipe_id, spec->tradeskill, spec->trivial, chance, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Trade_Skill_Events, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
itr = spec->onfail.begin();
|
||||
while(itr != spec->onfail.end()) {
|
||||
//should we check these arguments?
|
||||
|
||||
+101
-341
@@ -189,107 +189,107 @@ void Trade::SendItemData(const ItemInst* inst, int16 dest_slot_id)
|
||||
// Audit trade: The part logged is what travels owner -> with
|
||||
void Trade::LogTrade()
|
||||
{
|
||||
Mob* with = With();
|
||||
if (!owner->IsClient() || !with)
|
||||
return; // Should never happen
|
||||
|
||||
Client* trader = owner->CastToClient();
|
||||
bool logtrade = false;
|
||||
int admin_level = 0;
|
||||
uint8 item_count = 0;
|
||||
|
||||
if (zone->tradevar != 0) {
|
||||
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
if (trader->GetInv().GetItem(i))
|
||||
item_count++;
|
||||
}
|
||||
|
||||
if (((this->cp + this->sp + this->gp + this->pp)>0) || (item_count>0))
|
||||
admin_level = trader->Admin();
|
||||
else
|
||||
admin_level = 999;
|
||||
|
||||
if (zone->tradevar == 7) {
|
||||
logtrade = true;
|
||||
}
|
||||
else if ((admin_level>=10) && (admin_level<20)) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>5))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=20) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>4))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=80) {
|
||||
if ((zone->tradevar<8) && (zone->tradevar>3))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=100){
|
||||
if ((zone->tradevar<9) && (zone->tradevar>2))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=150){
|
||||
if (((zone->tradevar<8) && (zone->tradevar>1)) || (zone->tradevar==9))
|
||||
logtrade = true;
|
||||
}
|
||||
else if (admin_level<=255){
|
||||
if ((zone->tradevar<8) && (zone->tradevar>0))
|
||||
logtrade = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (logtrade == true) {
|
||||
char logtext[1000] = {0};
|
||||
uint32 cash = 0;
|
||||
bool comma = false;
|
||||
|
||||
// Log items offered by owner
|
||||
cash = this->cp + this->sp + this->gp + this->pp;
|
||||
if ((cash>0) || (item_count>0)) {
|
||||
sprintf(logtext, "%s gave %s ", trader->GetName(), with->GetName());
|
||||
|
||||
if (item_count > 0) {
|
||||
strcat(logtext, "items {");
|
||||
|
||||
for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
const ItemInst* inst = trader->GetInv().GetItem(i);
|
||||
|
||||
if (!comma)
|
||||
comma = true;
|
||||
else {
|
||||
if (inst)
|
||||
strcat(logtext, ",");
|
||||
}
|
||||
|
||||
if (inst) {
|
||||
char item_num[15] = {0};
|
||||
sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
strcat(logtext, item_num);
|
||||
|
||||
if (inst->IsType(ItemClassContainer)) {
|
||||
for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
|
||||
inst = trader->GetInv().GetItem(i, j);
|
||||
if (inst) {
|
||||
strcat(logtext, ",");
|
||||
sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
strcat(logtext, item_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cash > 0) {
|
||||
char money[100] = {0};
|
||||
sprintf(money, " %ipp, %igp, %isp, %icp", trader->trade->pp, trader->trade->gp, trader->trade->sp, trader->trade->cp);
|
||||
strcat(logtext, money);
|
||||
}
|
||||
|
||||
database.logevents(trader->AccountName(), trader->AccountID(),
|
||||
trader->Admin(), trader->GetName(), with->GetName(), "Trade", logtext, 6);
|
||||
}
|
||||
}
|
||||
//Mob* with = With();
|
||||
//if (!owner->IsClient() || !with)
|
||||
// return; // Should never happen
|
||||
//
|
||||
//Client* trader = owner->CastToClient();
|
||||
//bool logtrade = false;
|
||||
//int admin_level = 0;
|
||||
//uint8 item_count = 0;
|
||||
//
|
||||
//if (zone->tradevar != 0) {
|
||||
// for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
// if (trader->GetInv().GetItem(i))
|
||||
// item_count++;
|
||||
// }
|
||||
//
|
||||
// if (((this->cp + this->sp + this->gp + this->pp)>0) || (item_count>0))
|
||||
// admin_level = trader->Admin();
|
||||
// else
|
||||
// admin_level = 999;
|
||||
//
|
||||
// if (zone->tradevar == 7) {
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if ((admin_level>=10) && (admin_level<20)) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>5))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=20) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>4))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=80) {
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>3))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=100){
|
||||
// if ((zone->tradevar<9) && (zone->tradevar>2))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=150){
|
||||
// if (((zone->tradevar<8) && (zone->tradevar>1)) || (zone->tradevar==9))
|
||||
// logtrade = true;
|
||||
// }
|
||||
// else if (admin_level<=255){
|
||||
// if ((zone->tradevar<8) && (zone->tradevar>0))
|
||||
// logtrade = true;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//if (logtrade == true) {
|
||||
// char logtext[1000] = {0};
|
||||
// uint32 cash = 0;
|
||||
// bool comma = false;
|
||||
//
|
||||
// // Log items offered by owner
|
||||
// cash = this->cp + this->sp + this->gp + this->pp;
|
||||
// if ((cash>0) || (item_count>0)) {
|
||||
// sprintf(logtext, "%s gave %s ", trader->GetName(), with->GetName());
|
||||
//
|
||||
// if (item_count > 0) {
|
||||
// strcat(logtext, "items {");
|
||||
//
|
||||
// for (uint16 i = EmuConstants::TRADE_BEGIN; i <= EmuConstants::TRADE_END; i++) {
|
||||
// const ItemInst* inst = trader->GetInv().GetItem(i);
|
||||
//
|
||||
// if (!comma)
|
||||
// comma = true;
|
||||
// else {
|
||||
// if (inst)
|
||||
// strcat(logtext, ",");
|
||||
// }
|
||||
//
|
||||
// if (inst) {
|
||||
// char item_num[15] = {0};
|
||||
// sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
// strcat(logtext, item_num);
|
||||
//
|
||||
// if (inst->IsType(ItemClassContainer)) {
|
||||
// for (uint8 j = SUB_BEGIN; j < EmuConstants::ITEM_CONTAINER_SIZE; j++) {
|
||||
// inst = trader->GetInv().GetItem(i, j);
|
||||
// if (inst) {
|
||||
// strcat(logtext, ",");
|
||||
// sprintf(item_num, "%i", inst->GetItem()->ID);
|
||||
// strcat(logtext, item_num);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (cash > 0) {
|
||||
// char money[100] = {0};
|
||||
// sprintf(money, " %ipp, %igp, %isp, %icp", trader->trade->pp, trader->trade->gp, trader->trade->sp, trader->trade->cp);
|
||||
// strcat(logtext, money);
|
||||
// }
|
||||
//
|
||||
// database.logevents(trader->AccountName(), trader->AccountID(),
|
||||
// trader->Admin(), trader->GetName(), with->GetName(), "Trade", logtext, 6);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -454,38 +454,12 @@ void Client::ResetTrade() {
|
||||
void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, std::list<void*>* event_details) {
|
||||
if(tradingWith && tradingWith->IsClient()) {
|
||||
Client* other = tradingWith->CastToClient();
|
||||
QSPlayerLogTrade_Struct* qs_audit = nullptr;
|
||||
bool qs_log = false;
|
||||
|
||||
if(other) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Finishing trade with client %s", other->GetName());
|
||||
|
||||
this->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 = (QSPlayerLogTrade_Struct*)event_entry;
|
||||
qs_log = true;
|
||||
|
||||
if (finalizer) {
|
||||
qs_audit->char2_id = this->character_id;
|
||||
|
||||
qs_audit->char2_money.platinum = this->trade->pp;
|
||||
qs_audit->char2_money.gold = this->trade->gp;
|
||||
qs_audit->char2_money.silver = this->trade->sp;
|
||||
qs_audit->char2_money.copper = this->trade->cp;
|
||||
}
|
||||
else {
|
||||
qs_audit->char1_id = this->character_id;
|
||||
|
||||
qs_audit->char1_money.platinum = this->trade->pp;
|
||||
qs_audit->char1_money.gold = this->trade->gp;
|
||||
qs_audit->char1_money.silver = this->trade->sp;
|
||||
qs_audit->char1_money.copper = this->trade->cp;
|
||||
}
|
||||
}
|
||||
|
||||
// step 1: process bags
|
||||
for (int16 trade_slot = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_END; ++trade_slot) {
|
||||
const ItemInst* inst = m_inv[trade_slot];
|
||||
@@ -500,56 +474,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (free_slot != INVALID_INDEX) {
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_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->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
|
||||
//for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items
|
||||
const ItemInst* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = InventoryOld::CalcSlotId(trade_slot, sub_slot);
|
||||
detail->to_id = other->CharacterID();
|
||||
detail->to_slot = InventoryOld::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->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@@ -611,28 +535,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (other->PutItemInInventory(partial_slot, *partial_inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.",
|
||||
inst->GetItem()->Name, inst->GetItem()->ID, (old_charges - inst->GetCharges()));
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_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->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.",
|
||||
@@ -679,24 +581,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
inst->SetCharges(0);
|
||||
}
|
||||
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_id = this->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;
|
||||
@@ -719,57 +603,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
if (free_slot != INVALID_INDEX) {
|
||||
if (other->PutItemInInventory(free_slot, *inst, true)) {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID);
|
||||
if (qs_log) {
|
||||
QSTradeItems_Struct* detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_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->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
|
||||
// 'step 3' should never really see containers..but, just in case...
|
||||
//for (uint8 sub_slot = SUB_BEGIN; ((sub_slot < inst->GetItem()->BagSlots) && (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE)); ++sub_slot) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; (sub_slot < EmuConstants::ITEM_CONTAINER_SIZE); ++sub_slot) { // this is to catch ALL items
|
||||
const ItemInst* bag_inst = inst->GetItem(sub_slot);
|
||||
|
||||
if (bag_inst) {
|
||||
detail = new QSTradeItems_Struct;
|
||||
|
||||
detail->from_id = this->character_id;
|
||||
detail->from_slot = trade_slot;
|
||||
detail->to_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->char2_count += detail->charges;
|
||||
else
|
||||
qs_audit->char1_count += detail->charges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.Out(Logs::Detail, Logs::Trading, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName());
|
||||
@@ -794,79 +627,6 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
}
|
||||
}
|
||||
else if(tradingWith && 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 = EmuConstants::TRADE_BEGIN; trade_slot <= EmuConstants::TRADE_NPC_END; ++trade_slot) {
|
||||
const ItemInst* trade_inst = m_inv[trade_slot];
|
||||
|
||||
if(trade_inst) {
|
||||
QSHandinItems_Struct* 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->IsType(ItemClassContainer)) {
|
||||
for (uint8 sub_slot = SUB_BEGIN; sub_slot < trade_inst->GetItem()->BagSlots; ++sub_slot) {
|
||||
const ItemInst* trade_baginst = trade_inst->GetItem(sub_slot);
|
||||
|
||||
if(trade_baginst) {
|
||||
detail = new QSHandinItems_Struct;
|
||||
|
||||
strcpy(detail->action_type, "HANDIN");
|
||||
|
||||
detail->char_slot = InventoryOld::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)) {
|
||||
// This is a quest NPC
|
||||
|
||||
+69
-35
@@ -51,6 +51,7 @@
|
||||
#include "worldserver.h"
|
||||
#include "zone.h"
|
||||
#include "zone_config.h"
|
||||
#include "queryserv.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <ctime>
|
||||
@@ -62,8 +63,6 @@
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern bool staticzone;
|
||||
extern NetConnection net;
|
||||
extern PetitionList petition_list;
|
||||
@@ -72,6 +71,7 @@ extern uint16 adverrornum;
|
||||
extern uint32 numclients;
|
||||
extern WorldServer worldserver;
|
||||
extern Zone* zone;
|
||||
extern QueryServ* QServ;
|
||||
|
||||
Mutex MZoneShutdown;
|
||||
|
||||
@@ -104,34 +104,6 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
||||
zone->zonemap = Map::LoadMapFile(zone->map_name);
|
||||
zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name);
|
||||
zone->pathing = PathManager::LoadPathFile(zone->map_name);
|
||||
|
||||
char tmp[10];
|
||||
if (database.GetVariable("loglevel",tmp, 9)) {
|
||||
int log_levels[4];
|
||||
if (atoi(tmp)>9){ //Server is using the new code
|
||||
for(int i=0;i<4;i++){
|
||||
if (((int)tmp[i]>=48) && ((int)tmp[i]<=57))
|
||||
log_levels[i]=(int)tmp[i]-48; //get the value to convert it to an int from the ascii value
|
||||
else
|
||||
log_levels[i]=0; //set to zero on a bogue char
|
||||
}
|
||||
zone->loglevelvar = log_levels[0];
|
||||
Log.Out(Logs::General, Logs::Status, "General logging level: %i", zone->loglevelvar);
|
||||
zone->merchantvar = log_levels[1];
|
||||
Log.Out(Logs::General, Logs::Status, "Merchant logging level: %i", zone->merchantvar);
|
||||
zone->tradevar = log_levels[2];
|
||||
Log.Out(Logs::General, Logs::Status, "Trade logging level: %i", zone->tradevar);
|
||||
zone->lootvar = log_levels[3];
|
||||
Log.Out(Logs::General, Logs::Status, "Loot logging level: %i", zone->lootvar);
|
||||
}
|
||||
else {
|
||||
zone->loglevelvar = uint8(atoi(tmp)); //continue supporting only command logging (for now)
|
||||
zone->merchantvar = 0;
|
||||
zone->tradevar = 0;
|
||||
zone->lootvar = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ZoneLoaded = true;
|
||||
|
||||
worldserver.SetZone(iZoneID, iInstanceID);
|
||||
@@ -762,11 +734,6 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name)
|
||||
|
||||
is_zone_time_localized = false;
|
||||
|
||||
loglevelvar = 0;
|
||||
merchantvar = 0;
|
||||
tradevar = 0;
|
||||
lootvar = 0;
|
||||
|
||||
if(RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
taskmanager->LoadProximities(zoneid);
|
||||
}
|
||||
@@ -2299,3 +2266,70 @@ void Zone::UpdateHotzone()
|
||||
is_hotzone = atoi(row[0]) == 0 ? false: true;
|
||||
}
|
||||
|
||||
void Zone::LogEvent(EventLogTypes type, Client *c, const std::string &desc) {
|
||||
if(!c)
|
||||
return;
|
||||
|
||||
int zone_id = GetZoneID();
|
||||
int zone_instance = GetInstanceID();
|
||||
int zone_version = GetInstanceVersion();
|
||||
|
||||
int account_id = c->AccountID();
|
||||
std::string name = c->GetName();
|
||||
int id = c->CharacterID();
|
||||
|
||||
int target_account_id;
|
||||
std::string target_name;
|
||||
int target_id;
|
||||
|
||||
Mob *target = c->GetTarget();
|
||||
if(target && target->IsClient()) {
|
||||
Client *target_c = target->CastToClient();
|
||||
|
||||
target_account_id = target_c->AccountID();
|
||||
target_name = target_c->GetName();
|
||||
target_id = target_c->CharacterID();
|
||||
}
|
||||
else if(target && target->IsNPC()) {
|
||||
NPC *target_n = target->CastToNPC();
|
||||
|
||||
target_account_id = 0;
|
||||
target_name = target_n->GetName();
|
||||
target_id = target_n->GetNPCTypeID();
|
||||
}
|
||||
else if(target) {
|
||||
target_account_id = 0;
|
||||
target_name = target->GetName();
|
||||
target_id = 0;
|
||||
}
|
||||
else {
|
||||
target_account_id = 0;
|
||||
target_name = "";
|
||||
target_id = 0;
|
||||
}
|
||||
|
||||
|
||||
std::string query = StringFormat("INSERT INTO event_log "
|
||||
"(type, zone_id, zone_instance, zone_version, player_account_id, "
|
||||
"player_id, player_name, target_account_id, target_id, target_name, `desc`)"
|
||||
" VALUES "
|
||||
"(%i, %i, %i, %i, %i, %i, '%s', %i, %i, '%s', '%s')",
|
||||
(int)type,
|
||||
zone_id,
|
||||
zone_instance,
|
||||
zone_version,
|
||||
account_id,
|
||||
id,
|
||||
EscapeString(name).c_str(),
|
||||
target_account_id,
|
||||
target_id,
|
||||
EscapeString(target_name).c_str(),
|
||||
EscapeString(desc).c_str()
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
Log.Out(Logs::General, Logs::Error, "Log Error: %s", results.ErrorMessage().c_str());
|
||||
}
|
||||
//QServ->SendQuery(query);
|
||||
}
|
||||
+10
-5
@@ -69,6 +69,14 @@ struct item_tick_struct {
|
||||
std::string qglobal;
|
||||
};
|
||||
|
||||
enum EventLogTypes
|
||||
{
|
||||
EventLogItemSummon = 0,
|
||||
EventLogItemBuy = 1,
|
||||
EventLogQuest = 500,
|
||||
EventLogMax
|
||||
};
|
||||
|
||||
class Client;
|
||||
class Map;
|
||||
class Mob;
|
||||
@@ -227,11 +235,6 @@ public:
|
||||
uint8 weather_intensity;
|
||||
uint8 zone_weather;
|
||||
|
||||
uint8 loglevelvar;
|
||||
uint8 merchantvar;
|
||||
uint8 tradevar;
|
||||
uint8 lootvar;
|
||||
|
||||
bool HasGraveyard();
|
||||
void SetGraveyard(uint32 zoneid, const glm::vec4& graveyardPosition);
|
||||
|
||||
@@ -282,6 +285,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void LogEvent(EventLogTypes type, Client *c, const std::string &desc);
|
||||
|
||||
//MODDING HOOKS
|
||||
void mod_init();
|
||||
void mod_repop();
|
||||
|
||||
@@ -311,33 +311,6 @@ void ZoneDatabase::UpdateSpawn2Status(uint32 id, uint8 new_status)
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
bool ZoneDatabase::logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname, const char* target,const char* descriptiontype, const char* description,int event_nid){
|
||||
|
||||
uint32 len = strlen(description);
|
||||
uint32 len2 = strlen(target);
|
||||
char* descriptiontext = new char[2*len+1];
|
||||
char* targetarr = new char[2*len2+1];
|
||||
memset(descriptiontext, 0, 2*len+1);
|
||||
memset(targetarr, 0, 2*len2+1);
|
||||
DoEscapeString(descriptiontext, description, len);
|
||||
DoEscapeString(targetarr, target, len2);
|
||||
|
||||
std::string query = StringFormat("INSERT INTO eventlog (accountname, accountid, status, "
|
||||
"charname, target, descriptiontype, description, event_nid) "
|
||||
"VALUES('%s', %i, %i, '%s', '%s', '%s', '%s', '%i')",
|
||||
accountname, accountid, status, charname, targetarr,
|
||||
descriptiontype, descriptiontext, event_nid);
|
||||
safe_delete_array(descriptiontext);
|
||||
safe_delete_array(targetarr);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ZoneDatabase::UpdateBug(BugStruct* bug) {
|
||||
|
||||
uint32 len = strlen(bug->bug);
|
||||
|
||||
@@ -488,7 +488,6 @@ public:
|
||||
* PLEASE DO NOT ADD TO THIS COLLECTION OF CRAP UNLESS YOUR METHOD
|
||||
* REALLY HAS NO BETTER SECTION
|
||||
*/
|
||||
bool logevents(const char* accountname,uint32 accountid,uint8 status,const char* charname,const char* target, const char* descriptiontype, const char* description,int event_nid);
|
||||
void GetEventLogs(const char* name,char* target,uint32 account_id=0,uint8 eventid=0,char* detail=0,char* timestamp=0, CharacterEventLog_Struct* cel=0);
|
||||
uint32 GetKarma(uint32 acct_id);
|
||||
void UpdateKarma(uint32 acct_id, uint32 amount);
|
||||
|
||||
@@ -335,12 +335,6 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc
|
||||
|
||||
SendLogoutPackets();
|
||||
|
||||
/* QS: PlayerLogZone */
|
||||
if (RuleB(QueryServ, PlayerLogZone)){
|
||||
std::string event_desc = StringFormat("Zoning :: zoneid:%u instid:%u x:%4.2f y:%4.2f z:%4.2f h:%4.2f zonemode:%d from zoneid:%u instid:%i", zone_id, instance_id, dest_x, dest_y, dest_z, dest_h, zone_mode, this->GetZoneID(), this->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_Zoning, this->CharacterID(), event_desc);
|
||||
}
|
||||
|
||||
/* Dont clear aggro until the zone is successful */
|
||||
entity_list.RemoveFromHateLists(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user