mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
Merge pull request #199 from addtheice/RunQueryToDatabaseQuery_zone_horse
Run query to database query zone horse
This commit is contained in:
commit
d03232ce1b
@ -67,21 +67,21 @@ const NPCType *Horse::GetHorseType(uint16 spell_id) {
|
||||
|
||||
const NPCType *Horse::BuildHorseType(uint16 spell_id) {
|
||||
|
||||
const char* FileName = spells[spell_id].teleport_zone;
|
||||
const char* fileName = spells[spell_id].teleport_zone;
|
||||
|
||||
char mount_color = 0;
|
||||
std::string query = StringFormat("SELECT race, gender, texture, mountspeed FROM horses WHERE filename = '%s'", fileName);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
if (results.RowCount() != 1) {
|
||||
LogFile->write(EQEMuLog::Error, "No Database entry for mount: %s, check the horses table", fileName);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (database.RunQuery(query,MakeAnyLenString(&query, "SELECT race,gender,texture,mountspeed FROM horses WHERE filename='%s'", FileName), errbuf, &result)) {
|
||||
|
||||
safe_delete_array(query);
|
||||
if (mysql_num_rows(result) == 1) {
|
||||
|
||||
row = mysql_fetch_row(result);
|
||||
auto row = results.begin();
|
||||
|
||||
NPCType* npc_type = new NPCType;
|
||||
memset(npc_type, 0, sizeof(NPCType));
|
||||
@ -97,12 +97,10 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) {
|
||||
npc_type->level = 1;
|
||||
npc_type->npc_id = 0;
|
||||
npc_type->loottable_id = 0;
|
||||
npc_type->texture = atoi(row[2]);
|
||||
npc_type->helmtexture = atoi(row[2]);
|
||||
npc_type->texture = atoi(row[2]); // mount color
|
||||
npc_type->helmtexture = atoi(row[2]); // mount color
|
||||
npc_type->runspeed = atof(row[3]);
|
||||
|
||||
mount_color = atoi(row[2]);
|
||||
|
||||
npc_type->light = 0;
|
||||
npc_type->STR = 75;
|
||||
npc_type->STA = 75;
|
||||
@ -111,26 +109,9 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) {
|
||||
npc_type->INT = 75;
|
||||
npc_type->WIS = 75;
|
||||
npc_type->CHA = 75;
|
||||
|
||||
horses_auto_delete.Insert(npc_type);
|
||||
|
||||
mysql_free_result(result);
|
||||
return(npc_type);
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "No Database entry for mount: %s, check the horses table", FileName);
|
||||
//Message(13, "Unable to find data for mount %s", FileName);
|
||||
safe_delete_array(query);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in Mount query '%s': %s", query, errbuf);
|
||||
safe_delete_array(query);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return npc_type;
|
||||
}
|
||||
|
||||
void Client::SummonHorse(uint16 spell_id) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user