mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 08:21:28 +00:00
LoadCurrentMerc converted to QueryDatabase
This commit is contained in:
parent
322cea7342
commit
b846d89b5d
@ -1352,60 +1352,55 @@ bool ZoneDatabase::LoadMercInfo(Client *client) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::LoadCurrentMerc(Client *c) {
|
bool ZoneDatabase::LoadCurrentMerc(Client *client) {
|
||||||
bool loaded = false;
|
|
||||||
|
|
||||||
if(c->GetEPP().merc_name[0] != 0) {
|
if(client->GetEPP().merc_name[0] == 0)
|
||||||
std::string errorMessage;
|
return false;
|
||||||
char* Query = 0;
|
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
//char name[64];
|
|
||||||
|
|
||||||
uint8 slot = c->GetMercSlot();
|
uint8 slot = client->GetMercSlot();
|
||||||
|
|
||||||
if(slot > MAXMERCS) {
|
if(slot > MAXMERCS)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT MercID, Name, TemplateID, SuspendedTime, IsSuspended, TimerRemaining, Gender, StanceID, HP, Mana, Endurance, Face, LuclinHairStyle, LuclinHairColor, LuclinEyeColor, LuclinEyeColor2, LuclinBeardColor, LuclinBeard, DrakkinHeritage, DrakkinTattoo, DrakkinDetails FROM mercs WHERE OwnerCharacterID = '%i' AND Slot = '%u'", c->CharacterID(), slot), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT MercID, Name, TemplateID, SuspendedTime, "
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
"IsSuspended, TimerRemaining, Gender, StanceID, HP, "
|
||||||
}
|
"Mana, Endurance, Face, LuclinHairStyle, LuclinHairColor, "
|
||||||
else {
|
"LuclinEyeColor, LuclinEyeColor2, LuclinBeardColor, "
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
"LuclinBeard, DrakkinHeritage, DrakkinTattoo, DrakkinDetails "
|
||||||
c->GetMercInfo(slot).mercid = atoi(DataRow[0]);
|
"FROM mercs WHERE OwnerCharacterID = '%i' AND Slot = '%u'",
|
||||||
c->GetMercInfo(slot).slot = slot;
|
client->CharacterID(), slot);
|
||||||
snprintf(c->GetMercInfo(slot).merc_name, 64, "%s", std::string(DataRow[1]).c_str());
|
auto results = database.QueryDatabase(query);
|
||||||
c->GetMercInfo(slot).MercTemplateID = atoi(DataRow[2]);
|
|
||||||
c->GetMercInfo(slot).SuspendedTime = atoi(DataRow[3]);
|
|
||||||
c->GetMercInfo(slot).IsSuspended = atoi(DataRow[4]) == 1 ? true : false;
|
|
||||||
c->GetMercInfo(slot).MercTimerRemaining = atoi(DataRow[5]);
|
|
||||||
c->GetMercInfo(slot).Gender = atoi(DataRow[6]);
|
|
||||||
c->GetMercInfo(slot).State = atoi(DataRow[7]);
|
|
||||||
c->GetMercInfo(slot).hp = atoi(DataRow[8]);
|
|
||||||
c->GetMercInfo(slot).mana = atoi(DataRow[9]);
|
|
||||||
c->GetMercInfo(slot).endurance = atoi(DataRow[10]);
|
|
||||||
c->GetMercInfo(slot).face = atoi(DataRow[11]);
|
|
||||||
c->GetMercInfo(slot).luclinHairStyle = atoi(DataRow[12]);
|
|
||||||
c->GetMercInfo(slot).luclinHairColor = atoi(DataRow[13]);
|
|
||||||
c->GetMercInfo(slot).luclinEyeColor = atoi(DataRow[14]);
|
|
||||||
c->GetMercInfo(slot).luclinEyeColor2 = atoi(DataRow[15]);
|
|
||||||
c->GetMercInfo(slot).luclinBeardColor = atoi(DataRow[16]);
|
|
||||||
c->GetMercInfo(slot).luclinBeard = atoi(DataRow[17]);
|
|
||||||
c->GetMercInfo(slot).drakkinHeritage = atoi(DataRow[18]);
|
|
||||||
c->GetMercInfo(slot).drakkinTattoo = atoi(DataRow[19]);
|
|
||||||
c->GetMercInfo(slot).drakkinDetails = atoi(DataRow[20]);
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
if(!results.Success())
|
||||||
}
|
return false;
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
client->GetMercInfo(slot).mercid = atoi(row[0]);
|
||||||
|
client->GetMercInfo(slot).slot = slot;
|
||||||
|
snprintf(client->GetMercInfo(slot).merc_name, 64, "%s", row[1]);
|
||||||
|
client->GetMercInfo(slot).MercTemplateID = atoi(row[2]);
|
||||||
|
client->GetMercInfo(slot).SuspendedTime = atoi(row[3]);
|
||||||
|
client->GetMercInfo(slot).IsSuspended = atoi(row[4]) == 1? true: false;
|
||||||
|
client->GetMercInfo(slot).MercTimerRemaining = atoi(row[5]);
|
||||||
|
client->GetMercInfo(slot).Gender = atoi(row[6]);
|
||||||
|
client->GetMercInfo(slot).State = atoi(row[7]);
|
||||||
|
client->GetMercInfo(slot).hp = atoi(row[8]);
|
||||||
|
client->GetMercInfo(slot).mana = atoi(row[9]);
|
||||||
|
client->GetMercInfo(slot).endurance = atoi(row[10]);
|
||||||
|
client->GetMercInfo(slot).face = atoi(row[11]);
|
||||||
|
client->GetMercInfo(slot).luclinHairStyle = atoi(row[12]);
|
||||||
|
client->GetMercInfo(slot).luclinHairColor = atoi(row[13]);
|
||||||
|
client->GetMercInfo(slot).luclinEyeColor = atoi(row[14]);
|
||||||
|
client->GetMercInfo(slot).luclinEyeColor2 = atoi(row[15]);
|
||||||
|
client->GetMercInfo(slot).luclinBeardColor = atoi(row[16]);
|
||||||
|
client->GetMercInfo(slot).luclinBeard = atoi(row[17]);
|
||||||
|
client->GetMercInfo(slot).drakkinHeritage = atoi(row[18]);
|
||||||
|
client->GetMercInfo(slot).drakkinTattoo = atoi(row[19]);
|
||||||
|
client->GetMercInfo(slot).drakkinDetails = atoi(row[20]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return loaded;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::SaveMerc(Merc *merc) {
|
bool ZoneDatabase::SaveMerc(Merc *merc) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user