mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-05 02:52:25 +00:00
CreateNewPlayerSuffix converted to QueryDatabase
This commit is contained in:
parent
81cf748b2b
commit
9a4d01da8f
@ -268,48 +268,37 @@ void TitleManager::CreateNewPlayerTitle(Client *client, const char *title)
|
|||||||
safe_delete(pack);
|
safe_delete(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleManager::CreateNewPlayerSuffix(Client *c, const char *Suffix)
|
void TitleManager::CreateNewPlayerSuffix(Client *client, const char *suffix)
|
||||||
{
|
{
|
||||||
if(!c || !Suffix)
|
if(!client || !suffix)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
client->SetTitleSuffix(suffix);
|
||||||
char *query = nullptr;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
|
|
||||||
char *EscSuffix = new char[strlen(Suffix) * 2 + 1];
|
char *escSuffix = new char[strlen(suffix) * 2 + 1];
|
||||||
|
database.DoEscapeString(escSuffix, suffix, strlen(suffix));
|
||||||
|
|
||||||
c->SetTitleSuffix(Suffix);
|
std::string query = StringFormat("SELECT `id` FROM titles "
|
||||||
|
"WHERE `suffix` = '%s' AND char_id = %i",
|
||||||
database.DoEscapeString(EscSuffix, Suffix, strlen(Suffix));
|
escSuffix, client->CharacterID());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
if (database.RunQuery(query, MakeAnyLenString(&query,
|
if (results.Success() && results.RowCount() > 0) {
|
||||||
"SELECT `id` from titles where `suffix` = '%s' and char_id = %i", EscSuffix, c->CharacterID()), errbuf, &result))
|
safe_delete_array(escSuffix);
|
||||||
{
|
|
||||||
if(mysql_num_rows(result) > 0)
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
safe_delete_array(query);
|
|
||||||
safe_delete_array(EscSuffix);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete_array(query);
|
query = StringFormat("INSERT INTO titles (`char_id`, `suffix`) VALUES(%i, '%s')",
|
||||||
|
client->CharacterID(), escSuffix);
|
||||||
if(!database.RunQuery(query,MakeAnyLenString(&query, "INSERT into titles (`char_id`, `suffix`) VALUES(%i, '%s')",
|
safe_delete_array(escSuffix);
|
||||||
c->CharacterID(), EscSuffix), errbuf))
|
results = database.QueryDatabase(query);
|
||||||
LogFile->write(EQEMuLog::Error, "Error adding title suffix: %s %s", query, errbuf);
|
if(!results.Success()) {
|
||||||
else
|
LogFile->write(EQEMuLog::Error, "Error adding title suffix: %s %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
{
|
return;
|
||||||
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
}
|
||||||
worldserver.SendPacket(pack);
|
|
||||||
safe_delete(pack);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
safe_delete_array(EscSuffix);
|
|
||||||
|
|
||||||
|
ServerPacket* pack = new ServerPacket(ServerOP_ReloadTitles, 0);
|
||||||
|
worldserver.SendPacket(pack);
|
||||||
|
safe_delete(pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::SetAATitle(const char *Title)
|
void Client::SetAATitle(const char *Title)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user