mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-10 10:12:24 +00:00
Fix initialization issues with loading 'disable_timer' from the database for doors
This commit is contained in:
parent
080f6c5c3e
commit
b5b6145786
122
zone/doors.cpp
122
zone/doors.cpp
@ -70,6 +70,8 @@ m_Destination(door->dest_x, door->dest_y, door->dest_z, door->dest_heading)
|
|||||||
|
|
||||||
is_ldon_door = door->is_ldon_door;
|
is_ldon_door = door->is_ldon_door;
|
||||||
client_version_mask = door->client_version_mask;
|
client_version_mask = door->client_version_mask;
|
||||||
|
|
||||||
|
disable_timer = (door->disable_timer == 1 ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Doors::Doors(const char *dmodel, const glm::vec4& position, uint8 dopentype, uint16 dsize) :
|
Doors::Doors(const char *dmodel, const glm::vec4& position, uint8 dopentype, uint16 dsize) :
|
||||||
@ -102,6 +104,8 @@ m_Destination(glm::vec4())
|
|||||||
|
|
||||||
is_ldon_door = 0;
|
is_ldon_door = 0;
|
||||||
client_version_mask = 4294967295u;
|
client_version_mask = 4294967295u;
|
||||||
|
|
||||||
|
disable_timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,34 +449,34 @@ void Doors::HandleClick(Client* sender, uint8 trigger)
|
|||||||
|
|
||||||
void Doors::NPCOpen(NPC* sender, bool alt_mode)
|
void Doors::NPCOpen(NPC* sender, bool alt_mode)
|
||||||
{
|
{
|
||||||
if(sender) {
|
if (sender) {
|
||||||
if(GetTriggerType() == 255 || GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || opentype == 59 || opentype == 58 || !sender->IsNPC()) { // this object isnt triggered or door is locked - NPCs should not open locked doors!
|
if (GetTriggerType() == 255 || GetTriggerDoorID() > 0 || GetLockpick() != 0 || GetKeyItem() != 0 || opentype == 59 || opentype == 58 || !sender->IsNPC()) { // this object isnt triggered or door is locked - NPCs should not open locked doors!
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
||||||
MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
|
MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
|
||||||
md->doorid = door_id;
|
md->doorid = door_id;
|
||||||
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
||||||
entity_list.QueueCloseClients(sender,outapp,false,200);
|
entity_list.QueueCloseClients(sender, outapp, false, 200);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(!alt_mode) { // original function
|
if (!alt_mode) { // original function
|
||||||
if(!isopen) {
|
if (!is_open) {
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
close_timer.Start();
|
close_timer.Start();
|
||||||
isopen=true;
|
is_open = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
close_timer.Disable();
|
close_timer.Disable();
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
isopen=false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // alternative function
|
else { // alternative function
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
close_timer.Start();
|
close_timer.Start();
|
||||||
isopen=true;
|
is_open = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,53 +484,53 @@ void Doors::NPCOpen(NPC* sender, bool alt_mode)
|
|||||||
void Doors::ForceOpen(Mob *sender, bool alt_mode)
|
void Doors::ForceOpen(Mob *sender, bool alt_mode)
|
||||||
{
|
{
|
||||||
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
||||||
MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
|
MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
|
||||||
md->doorid = door_id;
|
md->doorid = door_id;
|
||||||
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
||||||
entity_list.QueueClients(sender,outapp,false);
|
entity_list.QueueClients(sender, outapp, false);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(!alt_mode) { // original function
|
if (!alt_mode) { // original function
|
||||||
if(!isopen) {
|
if (!is_open) {
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
close_timer.Start();
|
close_timer.Start();
|
||||||
isopen=true;
|
is_open = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
close_timer.Disable();
|
close_timer.Disable();
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
isopen=false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // alternative function
|
else { // alternative function
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
close_timer.Start();
|
close_timer.Start();
|
||||||
isopen=true;
|
is_open = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Doors::ForceClose(Mob *sender, bool alt_mode)
|
void Doors::ForceClose(Mob *sender, bool alt_mode)
|
||||||
{
|
{
|
||||||
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct));
|
||||||
MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
|
MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer;
|
||||||
md->doorid = door_id;
|
md->doorid = door_id;
|
||||||
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR; // change from original (open to close)
|
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR; // change from original (open to close)
|
||||||
entity_list.QueueClients(sender,outapp,false);
|
entity_list.QueueClients(sender, outapp, false);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(!alt_mode) { // original function
|
if (!alt_mode) { // original function
|
||||||
if(!isopen) {
|
if (!is_open) {
|
||||||
if (!disable_timer)
|
if (!disable_timer)
|
||||||
close_timer.Start();
|
close_timer.Start();
|
||||||
isopen=true;
|
is_open = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
close_timer.Disable();
|
close_timer.Disable();
|
||||||
isopen=false;
|
is_open = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // alternative function
|
else { // alternative function
|
||||||
if(isopen)
|
if (is_open)
|
||||||
close_timer.Trigger();
|
close_timer.Trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -541,14 +545,14 @@ void Doors::ToggleState(Mob *sender)
|
|||||||
MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
|
MoveDoor_Struct* md=(MoveDoor_Struct*)outapp->pBuffer;
|
||||||
md->doorid = door_id;
|
md->doorid = door_id;
|
||||||
|
|
||||||
if(!isopen) {
|
if(!is_open) {
|
||||||
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
md->action = invert_state == 0 ? OPEN_DOOR : OPEN_INVDOOR;
|
||||||
isopen=true;
|
is_open=true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
|
md->action = invert_state == 0 ? CLOSE_DOOR : CLOSE_INVDOOR;
|
||||||
isopen=false;
|
is_open=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity_list.QueueClients(sender,outapp,false);
|
entity_list.QueueClients(sender,outapp,false);
|
||||||
@ -561,7 +565,7 @@ void Doors::DumpDoor(){
|
|||||||
db_id, door_id, zone_name, door_name, to_string(m_Position).c_str());
|
db_id, door_id, zone_name, door_name, to_string(m_Position).c_str());
|
||||||
Log(Logs::General, Logs::None,
|
Log(Logs::General, Logs::None,
|
||||||
"opentype:%i guild_id:%i lockpick:%i keyitem:%i nokeyring:%i trigger_door:%i trigger_type:%i door_param:%i open:%s",
|
"opentype:%i guild_id:%i lockpick:%i keyitem:%i nokeyring:%i trigger_door:%i trigger_type:%i door_param:%i open:%s",
|
||||||
opentype, guild_id, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param, (isopen) ? "open":"closed");
|
opentype, guild_id, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param, (is_open) ? "open":"closed");
|
||||||
Log(Logs::General, Logs::None,
|
Log(Logs::General, Logs::None,
|
||||||
"dest_zone:%s destination:%s ",
|
"dest_zone:%s destination:%s ",
|
||||||
dest_zone, to_string(m_Destination).c_str());
|
dest_zone, to_string(m_Destination).c_str());
|
||||||
@ -641,34 +645,32 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
|
|||||||
Log(Logs::General, Logs::Status, "Loading Doors from database...");
|
Log(Logs::General, Logs::Status, "Loading Doors from database...");
|
||||||
|
|
||||||
|
|
||||||
// Door tmpDoor;
|
// Door tmpDoor;
|
||||||
std::string query = StringFormat("SELECT id, doorid, zone, name, pos_x, pos_y, pos_z, heading, "
|
std::string query = StringFormat("SELECT id, doorid, zone, name, pos_x, pos_y, pos_z, heading, "
|
||||||
"opentype, guild, lockpick, keyitem, nokeyring, triggerdoor, triggertype, "
|
"opentype, guild, lockpick, keyitem, nokeyring, triggerdoor, triggertype, "
|
||||||
"dest_zone, dest_instance, dest_x, dest_y, dest_z, dest_heading, "
|
"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 "
|
"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) "
|
"FROM doors WHERE zone = '%s' AND (version = %u OR version = -1) "
|
||||||
"ORDER BY doorid asc", zone_name, version);
|
"ORDER BY doorid asc", zone_name, version);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()){
|
if (!results.Success()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 rowIndex = 0;
|
int32 rowIndex = 0;
|
||||||
for(auto row = results.begin(); row != results.end(); ++row, ++rowIndex) {
|
for (auto row = results.begin(); row != results.end(); ++row, ++rowIndex) {
|
||||||
if(rowIndex >= iDoorCount) {
|
if (rowIndex >= iDoorCount) {
|
||||||
std::cerr << "Error, Door Count of " << iDoorCount << " exceeded." << std::endl;
|
std::cerr << "Error, Door Count of " << iDoorCount << " exceeded." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&into[rowIndex], 0, sizeof(Door));
|
memset(&into[rowIndex], 0, sizeof(Door));
|
||||||
|
|
||||||
into[rowIndex].db_id = atoi(row[0]);
|
into[rowIndex].db_id = atoi(row[0]);
|
||||||
into[rowIndex].door_id = atoi(row[1]);
|
into[rowIndex].door_id = atoi(row[1]);
|
||||||
|
|
||||||
Log(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u", into[rowIndex].db_id, into[rowIndex].door_id);
|
strn0cpy(into[rowIndex].zone_name, row[2], 32);
|
||||||
|
strn0cpy(into[rowIndex].door_name, row[3], 32);
|
||||||
strn0cpy(into[rowIndex].zone_name,row[2],32);
|
|
||||||
strn0cpy(into[rowIndex].door_name,row[3],32);
|
|
||||||
|
|
||||||
into[rowIndex].pos_x = (float)atof(row[4]);
|
into[rowIndex].pos_x = (float)atof(row[4]);
|
||||||
into[rowIndex].pos_y = (float)atof(row[5]);
|
into[rowIndex].pos_y = (float)atof(row[5]);
|
||||||
@ -685,18 +687,24 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
|
|||||||
strn0cpy(into[rowIndex].dest_zone, row[15], 32);
|
strn0cpy(into[rowIndex].dest_zone, row[15], 32);
|
||||||
|
|
||||||
into[rowIndex].dest_instance_id = atoi(row[16]);
|
into[rowIndex].dest_instance_id = atoi(row[16]);
|
||||||
into[rowIndex].dest_x = (float) atof(row[17]);
|
into[rowIndex].dest_x = (float)atof(row[17]);
|
||||||
into[rowIndex].dest_y = (float) atof(row[18]);
|
into[rowIndex].dest_y = (float)atof(row[18]);
|
||||||
into[rowIndex].dest_z = (float) atof(row[19]);
|
into[rowIndex].dest_z = (float)atof(row[19]);
|
||||||
into[rowIndex].dest_heading = (float) atof(row[20]);
|
into[rowIndex].dest_heading = (float)atof(row[20]);
|
||||||
into[rowIndex].door_param=atoi(row[21]);
|
into[rowIndex].door_param = atoi(row[21]);
|
||||||
into[rowIndex].invert_state=atoi(row[22]);
|
into[rowIndex].invert_state = atoi(row[22]);
|
||||||
into[rowIndex].incline=atoi(row[23]);
|
into[rowIndex].incline = atoi(row[23]);
|
||||||
into[rowIndex].size=atoi(row[24]);
|
into[rowIndex].size = atoi(row[24]);
|
||||||
into[rowIndex].is_ldon_door=atoi(row[25]);
|
into[rowIndex].is_ldon_door = atoi(row[25]);
|
||||||
into[rowIndex].client_version_mask = (uint32)strtoul(row[26], nullptr, 10);
|
into[rowIndex].client_version_mask = (uint32)strtoul(row[26], nullptr, 10);
|
||||||
into[rowIndex].disable_timer = (atoi(row[27]) ? true : false);
|
into[rowIndex].disable_timer = atoi(row[27]);
|
||||||
}
|
|
||||||
|
Log(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u disable_timer: %i",
|
||||||
|
into[rowIndex].db_id,
|
||||||
|
into[rowIndex].door_id,
|
||||||
|
into[rowIndex].disable_timer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,8 @@ public:
|
|||||||
const glm::vec4& GetPosition() const{ return m_Position; }
|
const glm::vec4& GetPosition() const{ return m_Position; }
|
||||||
int GetIncline() { return incline; }
|
int GetIncline() { return incline; }
|
||||||
bool triggered;
|
bool triggered;
|
||||||
void SetOpenState(bool st) { isopen = st; }
|
void SetOpenState(bool st) { is_open = st; }
|
||||||
bool IsDoorOpen() { return isopen; }
|
bool IsDoorOpen() { return is_open; }
|
||||||
|
|
||||||
uint8 GetTriggerDoorID() { return trigger_door; }
|
uint8 GetTriggerDoorID() { return trigger_door; }
|
||||||
uint8 GetTriggerType() { return trigger_type; }
|
uint8 GetTriggerType() { return trigger_type; }
|
||||||
@ -93,7 +93,7 @@ private:
|
|||||||
int invert_state;
|
int invert_state;
|
||||||
uint32 entity_id;
|
uint32 entity_id;
|
||||||
bool disable_timer;
|
bool disable_timer;
|
||||||
bool isopen;
|
bool is_open;
|
||||||
Timer close_timer;
|
Timer close_timer;
|
||||||
//Timer trigger_timer;
|
//Timer trigger_timer;
|
||||||
|
|
||||||
|
|||||||
@ -877,12 +877,12 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
|
|||||||
auto it = door_list.begin();
|
auto it = door_list.begin();
|
||||||
while (it != door_list.end()) {
|
while (it != door_list.end()) {
|
||||||
if ((it->second->GetClientVersionMask() & mask_test) &&
|
if ((it->second->GetClientVersionMask() & mask_test) &&
|
||||||
strlen(it->second->GetDoorName()) > 3)
|
strlen(it->second->GetDoorName()) > 3)
|
||||||
count++;
|
count++;
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count == 0 || count > 500)
|
if (count == 0 || count > 500)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint32 length = count * sizeof(Door_Struct);
|
uint32 length = count * sizeof(Door_Struct);
|
||||||
@ -890,31 +890,43 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
|
|||||||
memset(packet_buffer, 0, length);
|
memset(packet_buffer, 0, length);
|
||||||
uchar *ptr = packet_buffer;
|
uchar *ptr = packet_buffer;
|
||||||
Doors *door;
|
Doors *door;
|
||||||
Door_Struct nd;
|
Door_Struct new_door;
|
||||||
|
|
||||||
it = door_list.begin();
|
it = door_list.begin();
|
||||||
while (it != door_list.end()) {
|
while (it != door_list.end()) {
|
||||||
door = it->second;
|
door = it->second;
|
||||||
if (door && (door->GetClientVersionMask() & mask_test) &&
|
if (door && (door->GetClientVersionMask() & mask_test) &&
|
||||||
strlen(door->GetDoorName()) > 3) {
|
strlen(door->GetDoorName()) > 3) {
|
||||||
memset(&nd, 0, sizeof(nd));
|
memset(&new_door, 0, sizeof(new_door));
|
||||||
memcpy(nd.name, door->GetDoorName(), 32);
|
memcpy(new_door.name, door->GetDoorName(), 32);
|
||||||
|
|
||||||
auto position = door->GetPosition();
|
auto position = door->GetPosition();
|
||||||
nd.xPos = position.x;
|
|
||||||
nd.yPos = position.y;
|
new_door.xPos = position.x;
|
||||||
nd.zPos = position.z;
|
new_door.yPos = position.y;
|
||||||
nd.heading = position.w;
|
new_door.zPos = position.z;
|
||||||
nd.incline = door->GetIncline();
|
new_door.heading = position.w;
|
||||||
nd.size = door->GetSize();
|
|
||||||
nd.doorId = door->GetDoorID();
|
new_door.incline = door->GetIncline();
|
||||||
nd.opentype = door->GetOpenType();
|
new_door.size = door->GetSize();
|
||||||
nd.state_at_spawn = door->GetInvertState() ? !door->IsDoorOpen() : door->IsDoorOpen();
|
new_door.doorId = door->GetDoorID();
|
||||||
nd.invert_state = door->GetInvertState();
|
new_door.opentype = door->GetOpenType();
|
||||||
nd.door_param = door->GetDoorParam();
|
|
||||||
memcpy(ptr, &nd, sizeof(nd));
|
Log(Logs::General, Logs::Doors, "Door timer_disable: %s door_id: %u is_open: %s invert_state: %i",
|
||||||
ptr+=sizeof(nd);
|
(door->GetDisableTimer() ? "true" : "false"),
|
||||||
*(ptr-1)=0x01;
|
door->GetDoorID(),
|
||||||
*(ptr-3)=0x01;
|
(door->IsDoorOpen() ? "true" : "false"),
|
||||||
|
door->GetInvertState()
|
||||||
|
);
|
||||||
|
|
||||||
|
new_door.state_at_spawn = (door->GetInvertState() ? !door->IsDoorOpen() : door->IsDoorOpen());
|
||||||
|
new_door.invert_state = door->GetInvertState();
|
||||||
|
|
||||||
|
new_door.door_param = door->GetDoorParam();
|
||||||
|
memcpy(ptr, &new_door, sizeof(new_door));
|
||||||
|
ptr += sizeof(new_door);
|
||||||
|
*(ptr - 1) = 0x01;
|
||||||
|
*(ptr - 3) = 0x01;
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -202,7 +202,7 @@ struct Door {
|
|||||||
uint8 nokeyring;
|
uint8 nokeyring;
|
||||||
uint8 trigger_door;
|
uint8 trigger_door;
|
||||||
uint8 trigger_type;
|
uint8 trigger_type;
|
||||||
bool disable_timer;
|
uint8 disable_timer;
|
||||||
uint32 door_param;
|
uint32 door_param;
|
||||||
int invert_state;
|
int invert_state;
|
||||||
uint16 size;
|
uint16 size;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user