mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-06 14:32:24 +00:00
Merge pull request #222 from addtheice/RunQueryToDatabaseQuery_zone_client
Run query to database query zone client
This commit is contained in:
commit
f2f5b4c1ad
@ -4002,54 +4002,38 @@ void Client::SendWindow(uint32 PopupID, uint32 NegativeID, uint32 Buttons, const
|
|||||||
|
|
||||||
void Client::KeyRingLoad()
|
void Client::KeyRingLoad()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
std::string query = StringFormat("SELECT item_id FROM keyring "
|
||||||
char *query = 0;
|
"WHERE char_id = '%i' ORDER BY item_id", character_id);
|
||||||
MYSQL_RES *result;
|
auto results = database.QueryDatabase(query);
|
||||||
MYSQL_ROW row;
|
if (!results.Success()) {
|
||||||
query = new char[256];
|
std::cerr << "Error in Client::KeyRingLoad query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
|
|
||||||
sprintf(query, "SELECT item_id FROM keyring WHERE char_id='%i' ORDER BY item_id",character_id);
|
|
||||||
if (database.RunQuery(query, strlen(query), errbuf, &result))
|
|
||||||
{
|
|
||||||
safe_delete_array(query);
|
|
||||||
while(0 != (row = mysql_fetch_row(result))){
|
|
||||||
keyring.push_back(atoi(row[0]));
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}else {
|
|
||||||
std::cerr << "Error in Client::KeyRingLoad query '" << query << "' " << errbuf << std::endl;
|
|
||||||
safe_delete_array(query);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
|
keyring.push_back(atoi(row[0]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::KeyRingAdd(uint32 item_id)
|
void Client::KeyRingAdd(uint32 item_id)
|
||||||
{
|
{
|
||||||
if(0==item_id)return;
|
if(0==item_id)
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
return;
|
||||||
char *query = 0;
|
|
||||||
uint32 affected_rows = 0;
|
|
||||||
query = new char[256];
|
|
||||||
bool bFound = KeyRingCheck(item_id);
|
|
||||||
if(!bFound){
|
|
||||||
sprintf(query, "INSERT INTO keyring(char_id,item_id) VALUES(%i,%i)",character_id,item_id);
|
|
||||||
if(database.RunQuery(query, strlen(query), errbuf, 0, &affected_rows)) {
|
|
||||||
Message(4,"Added to keyring.");
|
|
||||||
|
|
||||||
/* QS: PlayerLogKeyringAddition */
|
bool found = KeyRingCheck(item_id);
|
||||||
if (RuleB(QueryServ, PlayerLogKeyringAddition)){
|
if (found)
|
||||||
std::string event_desc = StringFormat("itemid:%i in zoneid:%i instid:%i", item_id, this->GetZoneID(), this->GetInstanceID());
|
return;
|
||||||
QServ->PlayerLogEvent(Player_Log_Keyring_Addition, this->CharacterID(), event_desc);
|
|
||||||
}
|
std::string query = StringFormat("INSERT INTO keyring(char_id, item_id) VALUES(%i, %i)", character_id, item_id);
|
||||||
safe_delete_array(query);
|
auto results = database.QueryDatabase(query);
|
||||||
}
|
if (!results.Success()) {
|
||||||
else {
|
std::cerr << "Error in Doors::HandleClick query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||||
std::cerr << "Error in Doors::HandleClick query '" << query << "' " << errbuf << std::endl;
|
return;
|
||||||
safe_delete_array(query);
|
}
|
||||||
return;
|
|
||||||
}
|
Message(4,"Added to keyring.");
|
||||||
keyring.push_back(item_id);
|
|
||||||
}
|
keyring.push_back(item_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Client::KeyRingCheck(uint32 item_id)
|
bool Client::KeyRingCheck(uint32 item_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user