mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-11 23:42:24 +00:00
LoadStance converted to QueryDatabase
This commit is contained in:
parent
a67255475c
commit
14c642a3f7
36
zone/bot.cpp
36
zone/bot.cpp
@ -2787,38 +2787,18 @@ void Bot::DeletePetStats(uint32 botPetSaveId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bot::LoadStance() {
|
void Bot::LoadStance() {
|
||||||
int Result = 0;
|
|
||||||
bool loaded = false;
|
|
||||||
std::string errorMessage;
|
|
||||||
char* Query = 0;
|
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "select StanceID from botstances where BotID = %u;", GetBotID()), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT StanceID FROM botstances WHERE BotID = %u;", GetBotID());
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
auto results = database.QueryDatabase(query);
|
||||||
}
|
if(!results.Success() || results.RowCount() == 0) {
|
||||||
else {
|
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
|
||||||
Result = atoi(DataRow[0]);
|
|
||||||
loaded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete(Query);
|
|
||||||
Query = 0;
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadStance()");
|
LogFile->write(EQEMuLog::Error, "Error in Bot::LoadStance()");
|
||||||
|
SetDefaultBotStance();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loaded)
|
auto row = results.begin();
|
||||||
SetBotStance((BotStanceType)Result);
|
|
||||||
else
|
SetBotStance((BotStanceType)atoi(row[0]));
|
||||||
SetDefaultBotStance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SaveStance() {
|
void Bot::SaveStance() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user