Fix initialization issues with loading 'disable_timer' from the database for doors

This commit is contained in:
Akkadius 2017-04-10 19:55:17 -05:00
parent 080f6c5c3e
commit b5b6145786
4 changed files with 102 additions and 82 deletions

View File

@ -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;
} }
@ -458,21 +462,21 @@ void Doors::NPCOpen(NPC* sender, bool alt_mode)
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;
} }
} }
} }
@ -487,21 +491,21 @@ void Doors::ForceOpen(Mob *sender, bool alt_mode)
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;
} }
} }
@ -515,18 +519,18 @@ void Doors::ForceClose(Mob *sender, bool alt_mode)
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());
@ -665,8 +669,6 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
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].zone_name, row[2], 32);
strn0cpy(into[rowIndex].door_name, row[3], 32); strn0cpy(into[rowIndex].door_name, row[3], 32);
@ -695,7 +697,13 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name
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;

View File

@ -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;

View File

@ -890,29 +890,41 @@ 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"),
door->GetDoorID(),
(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 - 1) = 0x01;
*(ptr - 3) = 0x01; *(ptr - 3) = 0x01;
} }

View File

@ -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;