mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Repositories] Use repositories to load doors (#1572)
Remove Door struct that was being used to map db columns
This commit is contained in:
+32
-119
@@ -42,38 +42,38 @@
|
||||
extern EntityList entity_list;
|
||||
extern WorldServer worldserver;
|
||||
|
||||
Doors::Doors(const Door *door) :
|
||||
Doors::Doors(const DoorsRepository::Doors& door) :
|
||||
close_timer(5000),
|
||||
m_Position(door->pos_x, door->pos_y, door->pos_z, door->heading),
|
||||
m_Destination(door->dest_x, door->dest_y, door->dest_z, door->dest_heading) {
|
||||
m_Position(door.pos_x, door.pos_y, door.pos_z, door.heading),
|
||||
m_Destination(door.dest_x, door.dest_y, door.dest_z, door.dest_heading)
|
||||
{
|
||||
strn0cpy(zone_name, door.zone.c_str(), sizeof(zone_name));
|
||||
strn0cpy(door_name, door.name.c_str(), sizeof(door_name));
|
||||
strn0cpy(destination_zone_name, door.dest_zone.c_str(), sizeof(destination_zone_name));
|
||||
|
||||
strn0cpy(zone_name, door->zone_name, 32);
|
||||
strn0cpy(door_name, door->door_name, 32);
|
||||
strn0cpy(destination_zone_name, door->dest_zone, 16);
|
||||
|
||||
this->database_id = door->db_id;
|
||||
this->door_id = door->door_id;
|
||||
this->incline = door->incline;
|
||||
this->open_type = door->opentype;
|
||||
this->guild_id = door->guild_id;
|
||||
this->lockpick = door->lock_pick;
|
||||
this->key_item_id = door->keyitem;
|
||||
this->no_key_ring = door->nokeyring;
|
||||
this->trigger_door = door->trigger_door;
|
||||
this->trigger_type = door->trigger_type;
|
||||
this->triggered = false;
|
||||
this->door_param = door->door_param;
|
||||
this->size = door->size;
|
||||
this->invert_state = door->invert_state;
|
||||
this->destination_instance_id = door->dest_instance_id;
|
||||
this->is_ldon_door = door->is_ldon_door;
|
||||
this->client_version_mask = door->client_version_mask;
|
||||
database_id = door.id;
|
||||
door_id = door.doorid;
|
||||
incline = door.incline;
|
||||
open_type = door.opentype;
|
||||
guild_id = door.guild;
|
||||
lockpick = door.lockpick;
|
||||
key_item_id = door.keyitem;
|
||||
no_key_ring = door.nokeyring;
|
||||
trigger_door = door.triggerdoor;
|
||||
trigger_type = door.triggertype;
|
||||
triggered = false;
|
||||
door_param = door.door_param;
|
||||
size = door.size;
|
||||
invert_state = door.invert_state;
|
||||
destination_instance_id = door.dest_instance;
|
||||
is_ldon_door = door.is_ldon_door;
|
||||
client_version_mask = door.client_version_mask;
|
||||
|
||||
SetOpenState(false);
|
||||
|
||||
close_timer.Disable();
|
||||
|
||||
disable_timer = (door->disable_timer == 1 ? true : false);
|
||||
disable_timer = (door.disable_timer == 1 ? true : false);
|
||||
}
|
||||
|
||||
Doors::Doors(const char *model, const glm::vec4 &position, uint8 open_type, uint16 size) :
|
||||
@@ -682,106 +682,19 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version)
|
||||
return atoi(row[0]) + 1;
|
||||
}
|
||||
|
||||
bool ZoneDatabase::LoadDoors(int32 door_count, Door *into, const char *zone_name, int16 version) {
|
||||
std::vector<DoorsRepository::Doors> ZoneDatabase::LoadDoors(const std::string& zone_name, int16 version)
|
||||
{
|
||||
LogInfo("Loading Doors from database");
|
||||
|
||||
std::string query = StringFormat(
|
||||
" SELECT "
|
||||
" id, "
|
||||
" doorid, "
|
||||
" zone, "
|
||||
" NAME, "
|
||||
" pos_x, "
|
||||
" pos_y, "
|
||||
" pos_z, "
|
||||
" heading, "
|
||||
" opentype, "
|
||||
" guild, "
|
||||
" lockpick, "
|
||||
" keyitem, "
|
||||
" nokeyring, "
|
||||
" triggerdoor, "
|
||||
" triggertype, "
|
||||
" dest_zone, "
|
||||
" dest_instance, "
|
||||
" dest_x, "
|
||||
" dest_y, "
|
||||
" dest_z, "
|
||||
" dest_heading, "
|
||||
" door_param, "
|
||||
" invert_state, "
|
||||
" incline, "
|
||||
" size, "
|
||||
" is_ldon_door, "
|
||||
" client_version_mask, "
|
||||
" disable_timer "
|
||||
" FROM "
|
||||
" doors "
|
||||
" WHERE "
|
||||
" zone = '%s' "
|
||||
" AND ( version = % u OR version = - 1 ) "
|
||||
" %s "
|
||||
" ORDER BY "
|
||||
" doorid ASC ",
|
||||
zone_name,
|
||||
version,
|
||||
ContentFilterCriteria::apply().c_str()
|
||||
);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
auto door_entries = DoorsRepository::GetWhere(*this, fmt::format(
|
||||
"zone = '{}' AND (version = {} OR version = -1) {} ORDER BY doorid ASC",
|
||||
zone_name, version, ContentFilterCriteria::apply()));
|
||||
|
||||
int32 row_index = 0;
|
||||
for (auto row = results.begin(); row != results.end(); ++row, ++row_index) {
|
||||
if (row_index >= door_count) {
|
||||
std::cerr << "Error, Door Count of " << door_count << " exceeded." << std::endl;
|
||||
break;
|
||||
}
|
||||
LogDoors("Loaded [{}] doors for [{}] version [{}]", door_entries.size(), zone_name, version);
|
||||
|
||||
memset(&into[row_index], 0, sizeof(Door));
|
||||
|
||||
strn0cpy(into[row_index].zone_name, row[2], 32);
|
||||
strn0cpy(into[row_index].door_name, row[3], 32);
|
||||
strn0cpy(into[row_index].dest_zone, row[15], 32);
|
||||
|
||||
into[row_index].db_id = static_cast<uint32>(atoi(row[0]));
|
||||
into[row_index].door_id = static_cast<uint8>(atoi(row[1]));
|
||||
into[row_index].pos_x = (float) atof(row[4]);
|
||||
into[row_index].pos_y = (float) atof(row[5]);
|
||||
into[row_index].pos_z = (float) atof(row[6]);
|
||||
into[row_index].heading = (float) atof(row[7]);
|
||||
into[row_index].opentype = static_cast<uint8>(atoi(row[8]));
|
||||
into[row_index].guild_id = static_cast<uint32>(atoi(row[9]));
|
||||
into[row_index].lock_pick = static_cast<uint16>(atoi(row[10]));
|
||||
into[row_index].keyitem = static_cast<uint32>(atoi(row[11]));
|
||||
into[row_index].nokeyring = static_cast<uint8>(atoi(row[12]));
|
||||
into[row_index].trigger_door = static_cast<uint8>(atoi(row[13]));
|
||||
into[row_index].trigger_type = static_cast<uint8>(atoi(row[14]));
|
||||
into[row_index].dest_instance_id = static_cast<uint32>(atoi(row[16]));
|
||||
into[row_index].dest_x = (float) atof(row[17]);
|
||||
into[row_index].dest_y = (float) atof(row[18]);
|
||||
into[row_index].dest_z = (float) atof(row[19]);
|
||||
into[row_index].dest_heading = (float) atof(row[20]);
|
||||
into[row_index].door_param = static_cast<uint32>(atoi(row[21]));
|
||||
into[row_index].invert_state = atoi(row[22]);
|
||||
into[row_index].incline = atoi(row[23]);
|
||||
into[row_index].size = static_cast<uint16>(atoi(row[24]));
|
||||
into[row_index].is_ldon_door = static_cast<uint8>(atoi(row[25]));
|
||||
into[row_index].client_version_mask = (uint32) strtoul(row[26], nullptr, 10);
|
||||
into[row_index].disable_timer = static_cast<uint8>(atoi(row[27]));
|
||||
|
||||
Log(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u disable_timer: %i",
|
||||
into[row_index].db_id,
|
||||
into[row_index].door_id,
|
||||
into[row_index].disable_timer
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
return door_entries;
|
||||
}
|
||||
|
||||
|
||||
void Doors::SetLocation(float x, float y, float z)
|
||||
{
|
||||
entity_list.DespawnAllDoors();
|
||||
|
||||
Reference in New Issue
Block a user