mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 19:51:29 +00:00
[Fix] Add trader/buyer cleanup actions (#4843)
* Add trader/buyer cleanup actions Add trader/buyer db cleanup for - on zone idle - on client first login - when world drops a zone connection - in Client::ProcessMovePC Cleanup several compiler warnings * Formatting Updates
This commit is contained in:
parent
a2b28b2e16
commit
1221e88d92
@ -106,13 +106,8 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto buy_lines = BaseBuyerBuyLinesRepository::GetWhere(
|
auto buy_lines =
|
||||||
db,
|
BaseBuyerBuyLinesRepository::GetWhere(db, fmt::format("`buyer_id` = {}", buyer.front().id));
|
||||||
fmt::format("`buyer_id` = '{}'", buyer.front().id)
|
|
||||||
);
|
|
||||||
if (buy_lines.empty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> buy_line_ids{};
|
std::vector<std::string> buy_line_ids{};
|
||||||
for (auto const &bl: buy_lines) {
|
for (auto const &bl: buy_lines) {
|
||||||
@ -121,23 +116,65 @@ public:
|
|||||||
|
|
||||||
DeleteWhere(db, fmt::format("`char_id` = '{}';", char_id));
|
DeleteWhere(db, fmt::format("`char_id` = '{}';", char_id));
|
||||||
if (buy_line_ids.empty()) {
|
if (buy_line_ids.empty()) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseBuyerBuyLinesRepository::DeleteWhere(
|
BaseBuyerBuyLinesRepository::DeleteWhere(
|
||||||
db,
|
db, fmt::format("`id` IN({})", Strings::Implode(", ", buy_line_ids))
|
||||||
fmt::format("`id` IN({})", Strings::Implode(", ", buy_line_ids))
|
|
||||||
);
|
);
|
||||||
BaseBuyerTradeItemsRepository::DeleteWhere(
|
BaseBuyerTradeItemsRepository::DeleteWhere(
|
||||||
db,
|
db, fmt::format("`buyer_buy_lines_id` IN({})", Strings::Implode(", ", buy_line_ids))
|
||||||
fmt::format(
|
|
||||||
"`buyer_buy_lines_id` IN({})",
|
|
||||||
Strings::Implode(", ", buy_line_ids))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool DeleteBuyers(Database &db, uint32 char_zone_id, uint32 char_zone_instance_id)
|
||||||
|
{
|
||||||
|
auto buyers = GetWhere(
|
||||||
|
db,
|
||||||
|
fmt::format(
|
||||||
|
"`char_zone_id` = {} AND `char_zone_instance_id` = {}", char_zone_id, char_zone_instance_id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (buyers.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> buyer_ids{};
|
||||||
|
std::vector<std::string> buy_line_ids{};
|
||||||
|
|
||||||
|
for (auto const &b: buyers) {
|
||||||
|
buyer_ids.push_back(std::to_string(b.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto buy_lines = BaseBuyerBuyLinesRepository::GetWhere(
|
||||||
|
db, fmt::format("`buyer_id` IN({})", Strings::Implode(", ", buyer_ids))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!buy_lines.empty()) {
|
||||||
|
for (auto const &bl: buy_lines) {
|
||||||
|
buy_line_ids.push_back(std::to_string(bl.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DeleteWhere(db, fmt::format("`id` IN({});", Strings::Implode(", ", buyer_ids)));
|
||||||
|
if (buy_line_ids.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseBuyerBuyLinesRepository::DeleteWhere(
|
||||||
|
db,
|
||||||
|
fmt::format("`id` IN({})", Strings::Implode(", ", buy_line_ids))
|
||||||
|
);
|
||||||
|
BaseBuyerTradeItemsRepository::DeleteWhere(
|
||||||
|
db,
|
||||||
|
fmt::format("`buyer_buy_lines_id` IN({})", Strings::Implode(", ", buy_line_ids))
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //EQEMU_BUYER_REPOSITORY_H
|
#endif //EQEMU_BUYER_REPOSITORY_H
|
||||||
|
|||||||
@ -37,6 +37,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "dynamic_zone_manager.h"
|
#include "dynamic_zone_manager.h"
|
||||||
#include "ucs.h"
|
#include "ucs.h"
|
||||||
#include "clientlist.h"
|
#include "clientlist.h"
|
||||||
|
#include "../common/repositories/trader_repository.h"
|
||||||
|
#include "../common/repositories/buyer_repository.h"
|
||||||
|
|
||||||
extern uint32 numzones;
|
extern uint32 numzones;
|
||||||
extern EQ::Random emu_random;
|
extern EQ::Random emu_random;
|
||||||
@ -84,6 +86,8 @@ void ZSList::Remove(const std::string &uuid)
|
|||||||
while (iter != zone_server_list.end()) {
|
while (iter != zone_server_list.end()) {
|
||||||
if ((*iter)->GetUUID().compare(uuid) == 0) {
|
if ((*iter)->GetUUID().compare(uuid) == 0) {
|
||||||
auto port = (*iter)->GetCPort();
|
auto port = (*iter)->GetCPort();
|
||||||
|
(*iter)->CheckToClearTraderAndBuyerTables();
|
||||||
|
|
||||||
zone_server_list.erase(iter);
|
zone_server_list.erase(iter);
|
||||||
|
|
||||||
if (port != 0) {
|
if (port != 0) {
|
||||||
|
|||||||
@ -50,6 +50,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
#include "../common/repositories/guild_tributes_repository.h"
|
#include "../common/repositories/guild_tributes_repository.h"
|
||||||
#include "../common/skill_caps.h"
|
#include "../common/skill_caps.h"
|
||||||
#include "../common/server_reload_types.h"
|
#include "../common/server_reload_types.h"
|
||||||
|
#include "../common/repositories/trader_repository.h"
|
||||||
|
#include "../common/repositories/buyer_repository.h"
|
||||||
|
|
||||||
extern ClientList client_list;
|
extern ClientList client_list;
|
||||||
extern GroupLFPList LFPGroupList;
|
extern GroupLFPList LFPGroupList;
|
||||||
@ -1860,3 +1862,19 @@ void ZoneServer::IncomingClient(Client* client) {
|
|||||||
SendPacket(pack);
|
SendPacket(pack);
|
||||||
delete pack;
|
delete pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneServer::CheckToClearTraderAndBuyerTables()
|
||||||
|
{
|
||||||
|
if (GetZoneID() == Zones::BAZAAR) {
|
||||||
|
TraderRepository::DeleteWhere(
|
||||||
|
database,
|
||||||
|
fmt::format("`char_zone_id` = {} AND `char_zone_instance_id` = {}", GetZoneID(), GetInstanceID()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
BuyerRepository::DeleteBuyers(database, GetZoneID(), GetInstanceID());
|
||||||
|
|
||||||
|
LogTradingDetail(
|
||||||
|
"Removed trader and buyer entries for Zone ID [{}] and Instance ID [{}]", GetZoneID(), GetInstanceID()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ public:
|
|||||||
inline const char* GetZoneName() const { return zone_name; }
|
inline const char* GetZoneName() const { return zone_name; }
|
||||||
inline const char* GetZoneLongName() const { return long_name; }
|
inline const char* GetZoneLongName() const { return long_name; }
|
||||||
inline std::string GetCurrentVersion() const { return CURRENT_VERSION; }
|
inline std::string GetCurrentVersion() const { return CURRENT_VERSION; }
|
||||||
|
void CheckToClearTraderAndBuyerTables();
|
||||||
inline std::string GetCompileDate() const { return COMPILE_DATE; }
|
inline std::string GetCompileDate() const { return COMPILE_DATE; }
|
||||||
const char* GetCompileTime() const{ return compiled; }
|
const char* GetCompileTime() const{ return compiled; }
|
||||||
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
|
void SetCompile(char* in_compile){ strcpy(compiled,in_compile); }
|
||||||
|
|||||||
@ -808,6 +808,13 @@ void Client::CompleteConnect()
|
|||||||
|
|
||||||
/* This sub event is for if a player logs in for the first time since entering world. */
|
/* This sub event is for if a player logs in for the first time since entering world. */
|
||||||
if (firstlogon == 1) {
|
if (firstlogon == 1) {
|
||||||
|
TraderRepository::DeleteWhere(database, fmt::format("`char_id` = '{}'", CharacterID()));
|
||||||
|
BuyerRepository::DeleteBuyer(database, CharacterID());
|
||||||
|
LogTradingDetail(
|
||||||
|
"Removed trader abd buyer entries for Character ID {} on first logon to ensure table consistency.",
|
||||||
|
CharacterID()
|
||||||
|
);
|
||||||
|
|
||||||
RecordPlayerEventLog(PlayerEvent::WENT_ONLINE, PlayerEvent::EmptyEvent{});
|
RecordPlayerEventLog(PlayerEvent::WENT_ONLINE, PlayerEvent::EmptyEvent{});
|
||||||
|
|
||||||
if (parse->PlayerHasQuestSub(EVENT_CONNECT)) {
|
if (parse->PlayerHasQuestSub(EVENT_CONNECT)) {
|
||||||
@ -15567,7 +15574,9 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app)
|
|||||||
switch (in->Code) {
|
switch (in->Code) {
|
||||||
case ClickTrader: {
|
case ClickTrader: {
|
||||||
LogTrading("Handle_OP_TraderShop case ClickTrader [{}]", in->Code);
|
LogTrading("Handle_OP_TraderShop case ClickTrader [{}]", in->Code);
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_TraderShop, sizeof(TraderClick_Struct));
|
auto outapp =
|
||||||
|
std::make_unique<EQApplicationPacket>(OP_TraderShop, static_cast<uint32>(sizeof(TraderClick_Struct))
|
||||||
|
);
|
||||||
auto data = (TraderClick_Struct *) outapp->pBuffer;
|
auto data = (TraderClick_Struct *) outapp->pBuffer;
|
||||||
auto trader_client = entity_list.GetClientByID(in->TraderID);
|
auto trader_client = entity_list.GetClientByID(in->TraderID);
|
||||||
|
|
||||||
|
|||||||
@ -505,6 +505,9 @@ void EntityList::MobProcess()
|
|||||||
zone->GetSecondsBeforeIdle(),
|
zone->GetSecondsBeforeIdle(),
|
||||||
zone->GetSecondsBeforeIdle() != 1 ? "s" : ""
|
zone->GetSecondsBeforeIdle() != 1 ? "s" : ""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CheckToClearTraderAndBuyerTables();
|
||||||
|
|
||||||
mob_settle_timer->Disable();
|
mob_settle_timer->Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2335,7 +2338,7 @@ void EntityList::QueueClientsGuild(const EQApplicationPacket *app, uint32 guild_
|
|||||||
void EntityList::QueueClientsGuildBankItemUpdate(GuildBankItemUpdate_Struct *gbius, uint32 guild_id)
|
void EntityList::QueueClientsGuildBankItemUpdate(GuildBankItemUpdate_Struct *gbius, uint32 guild_id)
|
||||||
{
|
{
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_GuildBank, sizeof(GuildBankItemUpdate_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_GuildBank, sizeof(GuildBankItemUpdate_Struct));
|
||||||
auto data = reinterpret_cast<GuildBankItemUpdate_Struct *>(outapp->pBuffer);
|
auto data = reinterpret_cast<GuildBankItemUpdate_Struct *>(outapp->pBuffer);
|
||||||
|
|
||||||
memcpy(data, gbius, sizeof(GuildBankItemUpdate_Struct));
|
memcpy(data, gbius, sizeof(GuildBankItemUpdate_Struct));
|
||||||
|
|
||||||
@ -6009,3 +6012,22 @@ void EntityList::RestoreCorpse(NPC *npc, uint32_t decay_time)
|
|||||||
c->SetDecayTimer(decay_time);
|
c->SetDecayTimer(decay_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityList::CheckToClearTraderAndBuyerTables()
|
||||||
|
{
|
||||||
|
if (zone->GetZoneID() == Zones::BAZAAR) {
|
||||||
|
TraderRepository::DeleteWhere(
|
||||||
|
database,
|
||||||
|
fmt::format(
|
||||||
|
"`char_zone_id` = {} AND `char_zone_instance_id` = {}", zone->GetZoneID(), zone->GetInstanceID()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
BuyerRepository::DeleteBuyers(database, zone->GetZoneID(), zone->GetInstanceID());
|
||||||
|
|
||||||
|
LogTradingDetail(
|
||||||
|
"Removed trader and buyer entries for Zone ID [{}] and Instance ID [{}]",
|
||||||
|
zone->GetZoneID(),
|
||||||
|
zone->GetInstanceID()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -581,6 +581,7 @@ public:
|
|||||||
void SendMerchantEnd(Mob* merchant);
|
void SendMerchantEnd(Mob* merchant);
|
||||||
void SendMerchantInventory(Mob* m, int32 slot_id = -1, bool is_delete = false);
|
void SendMerchantInventory(Mob* m, int32 slot_id = -1, bool is_delete = false);
|
||||||
void RestoreCorpse(NPC* npc, uint32_t decay_time);
|
void RestoreCorpse(NPC* npc, uint32_t decay_time);
|
||||||
|
void CheckToClearTraderAndBuyerTables();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Zone;
|
friend class Zone;
|
||||||
|
|||||||
@ -1351,12 +1351,12 @@ void Client::BuyTraderItem(TraderBuy_Struct *tbs, Client *Trader, const EQApplic
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto in = (TraderBuy_Struct *) app->pBuffer;
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, static_cast<uint32>(sizeof(TraderBuy_Struct)));
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, sizeof(TraderBuy_Struct));
|
auto outtbs = (TraderBuy_Struct *) outapp->pBuffer;
|
||||||
auto outtbs = (TraderBuy_Struct *) outapp->pBuffer;
|
outtbs->item_id = tbs->item_id;
|
||||||
outtbs->item_id = tbs->item_id;
|
|
||||||
const EQ::ItemInstance *buy_item = nullptr;
|
const EQ::ItemInstance *buy_item = nullptr;
|
||||||
uint32 item_id = 0;
|
uint32 item_id = 0;
|
||||||
|
|
||||||
if (ClientVersion() >= EQ::versions::ClientVersion::RoF) {
|
if (ClientVersion() >= EQ::versions::ClientVersion::RoF) {
|
||||||
tbs->item_id = Strings::ToUnsignedBigInt(tbs->serial_number);
|
tbs->item_id = Strings::ToUnsignedBigInt(tbs->serial_number);
|
||||||
@ -1557,15 +1557,15 @@ void Client::BuyTraderItem(TraderBuy_Struct *tbs, Client *Trader, const EQApplic
|
|||||||
|
|
||||||
void Client::SendBazaarWelcome()
|
void Client::SendBazaarWelcome()
|
||||||
{
|
{
|
||||||
const auto results = TraderRepository::GetWelcomeData(database);
|
const auto results = TraderRepository::GetWelcomeData(database);
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_BazaarSearch, sizeof(BazaarWelcome_Struct));
|
EQApplicationPacket outapp(OP_BazaarSearch, static_cast<uint32>(sizeof(BazaarWelcome_Struct)));
|
||||||
auto data = (BazaarWelcome_Struct *) outapp->pBuffer;
|
auto data = (BazaarWelcome_Struct *) outapp.pBuffer;
|
||||||
|
|
||||||
data->action = BazaarWelcome;
|
data->action = BazaarWelcome;
|
||||||
data->traders = results.count_of_traders;
|
data->traders = results.count_of_traders;
|
||||||
data->items = results.count_of_items;
|
data->items = results.count_of_items;
|
||||||
|
|
||||||
QueuePacket(outapp.get());
|
QueuePacket(&outapp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SendBarterWelcome()
|
void Client::SendBarterWelcome()
|
||||||
@ -1798,7 +1798,10 @@ void Client::SendBuyerResults(BarterSearchRequest_Struct& bsr)
|
|||||||
|
|
||||||
{ ar(results); }
|
{ ar(results); }
|
||||||
|
|
||||||
auto packet = std::make_unique<EQApplicationPacket>(OP_BuyerItems, ss.str().length() + sizeof(BuyerGeneric_Struct));
|
auto packet = std::make_unique<EQApplicationPacket>(
|
||||||
|
OP_BuyerItems,
|
||||||
|
static_cast<uint32>(ss.str().length()) + static_cast<uint32>(sizeof(BuyerGeneric_Struct))
|
||||||
|
);
|
||||||
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
||||||
|
|
||||||
emu->action = Barter_BuyerSearch;
|
emu->action = Barter_BuyerSearch;
|
||||||
@ -1851,7 +1854,10 @@ void Client::ShowBuyLines(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
{ ar(l); }
|
{ ar(l); }
|
||||||
|
|
||||||
auto packet = std::make_unique<EQApplicationPacket>(OP_BuyerItems, ss.str().length() + sizeof(BuyerGeneric_Struct));
|
auto packet = std::make_unique<EQApplicationPacket>(
|
||||||
|
OP_BuyerItems,
|
||||||
|
static_cast<uint32>(ss.str().length()) + static_cast<uint32>(sizeof(BuyerGeneric_Struct))
|
||||||
|
);
|
||||||
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
||||||
|
|
||||||
emu->action = Barter_BuyerInspectBegin;
|
emu->action = Barter_BuyerInspectBegin;
|
||||||
@ -2075,7 +2081,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
auto server_packet = std::make_unique<ServerPacket>(
|
auto server_packet = std::make_unique<ServerPacket>(
|
||||||
ServerOP_BuyerMessaging,
|
ServerOP_BuyerMessaging,
|
||||||
sizeof(BuyerMessaging_Struct)
|
static_cast<uint32>(sizeof(BuyerMessaging_Struct))
|
||||||
);
|
);
|
||||||
|
|
||||||
auto data = (BuyerMessaging_Struct *) server_packet->pBuffer;
|
auto data = (BuyerMessaging_Struct *) server_packet->pBuffer;
|
||||||
@ -2123,7 +2129,10 @@ void Client::SendBuyerPacket(Client* Buyer) {
|
|||||||
|
|
||||||
void Client::ToggleBuyerMode(bool status)
|
void Client::ToggleBuyerMode(bool status)
|
||||||
{
|
{
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_Barter, sizeof(BuyerSetAppearance_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
|
OP_Barter,
|
||||||
|
static_cast<uint32>(sizeof(BuyerSetAppearance_Struct))
|
||||||
|
);
|
||||||
auto data = (BuyerSetAppearance_Struct *) outapp->pBuffer;
|
auto data = (BuyerSetAppearance_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
data->action = Barter_BuyerAppearance;
|
data->action = Barter_BuyerAppearance;
|
||||||
@ -2319,8 +2328,7 @@ void Client::ModifyBuyLine(const EQApplicationPacket *app)
|
|||||||
|
|
||||||
auto packet = std::make_unique<EQApplicationPacket>(
|
auto packet = std::make_unique<EQApplicationPacket>(
|
||||||
OP_BuyerItems,
|
OP_BuyerItems,
|
||||||
ss_customer.str().length() +
|
static_cast<uint32>(ss_customer.str().length()) + static_cast<uint32>(sizeof(BuyerGeneric_Struct))
|
||||||
sizeof(BuyerGeneric_Struct)
|
|
||||||
);
|
);
|
||||||
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
auto emu = (BuyerGeneric_Struct *) packet->pBuffer;
|
||||||
|
|
||||||
@ -2813,7 +2821,10 @@ void Client::DoBazaarInspect(BazaarInspect_Struct &in)
|
|||||||
|
|
||||||
void Client::SendBazaarDeliveryCosts()
|
void Client::SendBazaarDeliveryCosts()
|
||||||
{
|
{
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_BazaarSearch, sizeof(BazaarDeliveryCost_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
|
OP_BazaarSearch,
|
||||||
|
static_cast<uint32>(sizeof(BazaarDeliveryCost_Struct))
|
||||||
|
);
|
||||||
auto data = (BazaarDeliveryCost_Struct *) outapp->pBuffer;
|
auto data = (BazaarDeliveryCost_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
data->action = DeliveryCostUpdate;
|
data->action = DeliveryCostUpdate;
|
||||||
@ -3074,7 +3085,9 @@ void Client::BuyTraderItemOutsideBazaar(TraderBuy_Struct *tbs, const EQApplicati
|
|||||||
BazaarAuditTrail(tbs->seller_name, GetName(), buy_item->GetItem()->Name, tbs->quantity, tbs->price, 0);
|
BazaarAuditTrail(tbs->seller_name, GetName(), buy_item->GetItem()->Name, tbs->quantity, tbs->price, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto out_server = std::make_unique<ServerPacket>(ServerOP_BazaarPurchase, sizeof(BazaarPurchaseMessaging_Struct));
|
auto out_server = std::make_unique<ServerPacket>(
|
||||||
|
ServerOP_BazaarPurchase, static_cast<uint32>(sizeof(BazaarPurchaseMessaging_Struct))
|
||||||
|
);
|
||||||
auto out_data = (BazaarPurchaseMessaging_Struct *) out_server->pBuffer;
|
auto out_data = (BazaarPurchaseMessaging_Struct *) out_server->pBuffer;
|
||||||
|
|
||||||
out_data->trader_buy_struct = *tbs;
|
out_data->trader_buy_struct = *tbs;
|
||||||
@ -3111,7 +3124,7 @@ void Client::SendBuyerGreeting(uint32 buyer_id)
|
|||||||
|
|
||||||
void Client::SendSellerBrowsing(const std::string &browser)
|
void Client::SendSellerBrowsing(const std::string &browser)
|
||||||
{
|
{
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_Barter, sizeof(BuyerBrowsing_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_Barter, static_cast<uint32>(sizeof(BuyerBrowsing_Struct)));
|
||||||
auto eq = (BuyerBrowsing_Struct *) outapp->pBuffer;
|
auto eq = (BuyerBrowsing_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
eq->action = Barter_SellerBrowsing;
|
eq->action = Barter_SellerBrowsing;
|
||||||
@ -3309,7 +3322,7 @@ void Client::SendWindowUpdatesToSellerAndBuyer(BuyerLineSellItem_Struct &blsi)
|
|||||||
if (blsi.item_quantity - blsi.seller_quantity <= 0) {
|
if (blsi.item_quantity - blsi.seller_quantity <= 0) {
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
OP_BuyerItems,
|
OP_BuyerItems,
|
||||||
sizeof(BuyerRemoveItemFromMerchantWindow_Struct)
|
static_cast<uint32>(sizeof(BuyerRemoveItemFromMerchantWindow_Struct))
|
||||||
);
|
);
|
||||||
auto data = (BuyerRemoveItemFromMerchantWindow_Struct *) outapp->pBuffer;
|
auto data = (BuyerRemoveItemFromMerchantWindow_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
@ -3399,7 +3412,7 @@ void Client::SendBuyerToBarterWindow(Client *buyer, uint32 action)
|
|||||||
{
|
{
|
||||||
auto server_packet = std::make_unique<ServerPacket>(
|
auto server_packet = std::make_unique<ServerPacket>(
|
||||||
ServerOP_BuyerMessaging,
|
ServerOP_BuyerMessaging,
|
||||||
sizeof(BuyerMessaging_Struct)
|
static_cast<uint32>(sizeof(BuyerMessaging_Struct))
|
||||||
);
|
);
|
||||||
auto data = (BuyerMessaging_Struct *) server_packet->pBuffer;
|
auto data = (BuyerMessaging_Struct *) server_packet->pBuffer;
|
||||||
|
|
||||||
@ -3420,7 +3433,10 @@ void Client::SendBulkBazaarBuyers()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_Barter, sizeof(BuyerAddBuyertoBarterWindow_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
|
OP_Barter,
|
||||||
|
static_cast<uint32>(sizeof(BuyerAddBuyertoBarterWindow_Struct))
|
||||||
|
);
|
||||||
auto emu = (BuyerAddBuyertoBarterWindow_Struct *) outapp->pBuffer;
|
auto emu = (BuyerAddBuyertoBarterWindow_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
for (auto const &b: results) {
|
for (auto const &b: results) {
|
||||||
@ -3663,11 +3679,11 @@ bool Client::ValidateBuyLineItems(std::map<uint32, BuylineItemDetails_Struct> &i
|
|||||||
|
|
||||||
int64 Client::ValidateBuyLineCost(std::map<uint32, BuylineItemDetails_Struct> &item_map)
|
int64 Client::ValidateBuyLineCost(std::map<uint32, BuylineItemDetails_Struct> &item_map)
|
||||||
{
|
{
|
||||||
int64 proposed_total_cost = std::accumulate(
|
uint64 proposed_total_cost = std::accumulate(
|
||||||
item_map.cbegin(),
|
item_map.cbegin(),
|
||||||
item_map.cend(),
|
item_map.cend(),
|
||||||
0,
|
static_cast<uint64>(0),
|
||||||
[](auto prev_sum, const std::pair<uint32, BuylineItemDetails_Struct> &x) {
|
[](uint64 prev_sum, const std::pair<uint32, BuylineItemDetails_Struct> &x) {
|
||||||
return prev_sum + x.second.item_cost;
|
return prev_sum + x.second.item_cost;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3794,7 +3794,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto item_sn = Strings::ToUnsignedBigInt(in->trader_buy_struct.serial_number);
|
auto item_sn = Strings::ToUnsignedBigInt(in->trader_buy_struct.serial_number);
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, sizeof(TraderBuy_Struct));
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_Trader, static_cast<uint32>(sizeof(TraderBuy_Struct)));
|
||||||
auto data = (TraderBuy_Struct *) outapp->pBuffer;
|
auto data = (TraderBuy_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
memcpy(data, &in->trader_buy_struct, sizeof(TraderBuy_Struct));
|
memcpy(data, &in->trader_buy_struct, sizeof(TraderBuy_Struct));
|
||||||
@ -3841,7 +3841,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
case Barter_AddToBarterWindow: {
|
case Barter_AddToBarterWindow: {
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
OP_Barter,
|
OP_Barter,
|
||||||
sizeof(BuyerAddBuyertoBarterWindow_Struct)
|
static_cast<uint32>(sizeof(BuyerAddBuyertoBarterWindow_Struct))
|
||||||
);
|
);
|
||||||
auto emu = (BuyerAddBuyertoBarterWindow_Struct *) outapp->pBuffer;
|
auto emu = (BuyerAddBuyertoBarterWindow_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
@ -3858,7 +3858,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
case Barter_RemoveFromBarterWindow: {
|
case Barter_RemoveFromBarterWindow: {
|
||||||
auto outapp = std::make_unique<EQApplicationPacket>(
|
auto outapp = std::make_unique<EQApplicationPacket>(
|
||||||
OP_Barter,
|
OP_Barter,
|
||||||
sizeof(BuyerRemoveBuyerFromBarterWindow_Struct)
|
static_cast<uint32>(sizeof(BuyerRemoveBuyerFromBarterWindow_Struct))
|
||||||
);
|
);
|
||||||
auto emu = (BuyerRemoveBuyerFromBarterWindow_Struct *) outapp->pBuffer;
|
auto emu = (BuyerRemoveBuyerFromBarterWindow_Struct *) outapp->pBuffer;
|
||||||
|
|
||||||
|
|||||||
@ -681,9 +681,20 @@ void Client::MoveZoneInstanceRaid(uint16 instance_id, const glm::vec4 &location)
|
|||||||
|
|
||||||
void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm)
|
void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm)
|
||||||
{
|
{
|
||||||
// From what I have read, dragged corpses should stay with the player for Intra-zone summons etc, but we can implement that later.
|
// From what I have read, dragged corpses should stay with the player for Intra-zone summons etc, but we can
|
||||||
|
// implement that later.
|
||||||
ClearDraggedCorpses();
|
ClearDraggedCorpses();
|
||||||
|
|
||||||
|
// Added to ensure that if a player is moved (ported, gmmove, etc) and they are an active trader or buyer, they will
|
||||||
|
// be removed from future transactions.
|
||||||
|
if (IsTrader()) {
|
||||||
|
TraderEndTrader();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsBuyer()) {
|
||||||
|
ToggleBuyerMode(false);
|
||||||
|
}
|
||||||
|
|
||||||
if(zoneID == 0)
|
if(zoneID == 0)
|
||||||
zoneID = zone->GetZoneID();
|
zoneID = zone->GetZoneID();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user