mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 23:01:30 +00:00
ShowBuyLines converted to QueryDatabase
This commit is contained in:
parent
36c1d88eac
commit
a8b8f71092
@ -2402,60 +2402,44 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) {
|
|||||||
|
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("SELECT * FROM buyer WHERE charid = %i", Buyer->CharacterID());
|
||||||
char* Query = 0;
|
auto results = database.QueryDatabase(query);
|
||||||
char ItemName[64];
|
if (!results.Success() || results.RowCount() == 0)
|
||||||
std::string Search, Values;
|
return;
|
||||||
MYSQL_RES *Result;
|
|
||||||
MYSQL_ROW Row;
|
|
||||||
|
|
||||||
if (database.RunQuery(Query,MakeAnyLenString(&Query, "select * from buyer where charid = %i",
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
Buyer->CharacterID()),errbuf,&Result)){
|
char ItemName[64];
|
||||||
|
uint32 BuySlot = atoi(row[1]);
|
||||||
|
uint32 ItemID = atoi(row[2]);
|
||||||
|
strcpy(ItemName, row[3]);
|
||||||
|
uint32 Quantity = atoi(row[4]);
|
||||||
|
uint32 Price = atoi(row[5]);
|
||||||
|
|
||||||
if(mysql_num_rows(Result) == 0) {
|
EQApplicationPacket* outapp = new EQApplicationPacket(OP_Barter, 936);
|
||||||
|
|
||||||
safe_delete_array(Query);
|
char *Buf = (char *)outapp->pBuffer;
|
||||||
|
|
||||||
mysql_free_result(Result);
|
const Item_Struct* item = database.GetItem(ItemID);
|
||||||
|
|
||||||
return;
|
if(!item)
|
||||||
}
|
continue;
|
||||||
|
|
||||||
while ((Row = mysql_fetch_row(Result))) {
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Barter_BuyerInspectWindow);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, BuySlot);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint8, Buf, 1); // Flag
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, ItemID);
|
||||||
|
VARSTRUCT_ENCODE_STRING(Buf, ItemName);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, item->Icon);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint8, Buf, 1); // Flag
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Price);
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Buyer->GetID());
|
||||||
|
VARSTRUCT_ENCODE_TYPE(uint32, Buf, 0);
|
||||||
|
VARSTRUCT_ENCODE_STRING(Buf, Buyer->GetName());
|
||||||
|
|
||||||
uint32 BuySlot = atoi(Row[1]);
|
_pkt(TRADING__BARTER, outapp);
|
||||||
uint32 ItemID = atoi(Row[2]);
|
QueuePacket(outapp);
|
||||||
strcpy(ItemName, Row[3]);
|
}
|
||||||
uint32 Quantity = atoi(Row[4]);
|
|
||||||
uint32 Price = atoi(Row[5]);
|
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_Barter, 936);
|
|
||||||
|
|
||||||
char *Buf = (char *)outapp->pBuffer;
|
|
||||||
|
|
||||||
const Item_Struct* item = database.GetItem(ItemID);
|
|
||||||
|
|
||||||
if(!item) continue;
|
|
||||||
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Barter_BuyerInspectWindow);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, BuySlot);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint8, Buf, 1); // Flag
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, ItemID);
|
|
||||||
VARSTRUCT_ENCODE_STRING(Buf, ItemName);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, item->Icon);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Quantity);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint8, Buf, 1); // Flag
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Price);
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, Buyer->GetID());
|
|
||||||
VARSTRUCT_ENCODE_TYPE(uint32, Buf, 0);
|
|
||||||
VARSTRUCT_ENCODE_STRING(Buf, Buyer->GetName());
|
|
||||||
|
|
||||||
_pkt(TRADING__BARTER, outapp);
|
|
||||||
QueuePacket(outapp);
|
|
||||||
}
|
|
||||||
mysql_free_result(Result);
|
|
||||||
}
|
|
||||||
safe_delete_array(Query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SellToBuyer(const EQApplicationPacket *app) {
|
void Client::SellToBuyer(const EQApplicationPacket *app) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user