mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Merge pull request #208 from addtheice/RunQueryToDatabaseQuery_zone_trap
Run query to database query zone trap
This commit is contained in:
commit
339b8e37a6
@ -262,45 +262,36 @@ Mob* EntityList::GetTrapTrigger(Trap* trap) {
|
|||||||
|
|
||||||
//todo: rewrite this to not need direct access to trap members.
|
//todo: rewrite this to not need direct access to trap members.
|
||||||
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
// int char_num = 0;
|
std::string query = StringFormat("SELECT id, x, y, z, effect, effectvalue, effectvalue2, skill, "
|
||||||
unsigned long* lengths;
|
"maxzdiff, radius, chance, message, respawn_time, respawn_var, level "
|
||||||
|
"FROM traps WHERE zone='%s' AND version=%u", zonename, version);
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id,x,y,z,effect,effectvalue,effectvalue2,skill,maxzdiff,radius,chance,message,respawn_time,respawn_var,level FROM traps WHERE zone='%s' AND version=%u", zonename, version), errbuf, &result)) {
|
auto results = QueryDatabase(query);
|
||||||
safe_delete_array(query);
|
if (!results.Success()) {
|
||||||
while ((row = mysql_fetch_row(result)))
|
LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||||
{
|
|
||||||
lengths = mysql_fetch_lengths(result);
|
|
||||||
Trap* trap = new Trap();
|
|
||||||
trap->trap_id = atoi(row[0]);
|
|
||||||
trap->x = atof(row[1]);
|
|
||||||
trap->y = atof(row[2]);
|
|
||||||
trap->z = atof(row[3]);
|
|
||||||
trap->effect = atoi(row[4]);
|
|
||||||
trap->effectvalue = atoi(row[5]);
|
|
||||||
trap->effectvalue2 = atoi(row[6]);
|
|
||||||
trap->skill = atoi(row[7]);
|
|
||||||
trap->maxzdiff = atof(row[8]);
|
|
||||||
trap->radius = atof(row[9]);
|
|
||||||
trap->chance = atoi(row[10]);
|
|
||||||
trap->message = row[11];
|
|
||||||
trap->respawn_time = atoi(row[12]);
|
|
||||||
trap->respawn_var = atoi(row[13]);
|
|
||||||
trap->level = atoi(row[14]);
|
|
||||||
entity_list.AddTrap(trap);
|
|
||||||
trap->CreateHiddenTrigger();
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in LoadTraps query '%s': %s", query, errbuf);
|
|
||||||
safe_delete_array(query);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
Trap* trap = new Trap();
|
||||||
|
trap->trap_id = atoi(row[0]);
|
||||||
|
trap->x = atof(row[1]);
|
||||||
|
trap->y = atof(row[2]);
|
||||||
|
trap->z = atof(row[3]);
|
||||||
|
trap->effect = atoi(row[4]);
|
||||||
|
trap->effectvalue = atoi(row[5]);
|
||||||
|
trap->effectvalue2 = atoi(row[6]);
|
||||||
|
trap->skill = atoi(row[7]);
|
||||||
|
trap->maxzdiff = atof(row[8]);
|
||||||
|
trap->radius = atof(row[9]);
|
||||||
|
trap->chance = atoi(row[10]);
|
||||||
|
trap->message = row[11];
|
||||||
|
trap->respawn_time = atoi(row[12]);
|
||||||
|
trap->respawn_var = atoi(row[13]);
|
||||||
|
trap->level = atoi(row[14]);
|
||||||
|
entity_list.AddTrap(trap);
|
||||||
|
trap->CreateHiddenTrigger();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user