Never done this before, but the diff file, patch action and build appear valid, and the game works as intended.
doors.cpp.patch
Code:
Index: doors.cpp
===================================================================
--- doors.cpp (revision 2145)
+++ doors.cpp (working copy)
@@ -31,6 +31,8 @@
#define OPEN_DOOR 0x02
#define CLOSE_DOOR 0x03
+#define INVOPEN_DOOR 0x03 // U: Added inverted action definitions
+#define INVCLOSE_DOOR 0x02 // for ease of discernment
extern EntityList entity_list;
extern WorldServer worldserver;
@@ -143,6 +145,12 @@
//TODO: add check for other lockpick items
//////////////////////////////////////////////////////////////////
+ // U: I left this test code in case someone wants to work on trigger doors in the database
+ //sender->Message(4, "door:%i->doorst (ds:%s | ti:%s)", door_id, IsDoorOpen() ? "O" : "C", close_timer.Enabled() ? "E" : "D");
+ //sender->Message(4, "door:%i->trigdr (tdid:%i)", door_id, GetTriggerDoorID());
+ //sender->Message(4, "door:%i->trigger (trid:%i | trs:%s | trt:%i)", door_id, trigger, triggered ? "T" : "F", GetTriggerType());
+ //sender->Message(4, "door:%i->client (xp:%f | yp:%f | zp:%f)", door_id, sender->GetX(), sender->GetY(), sender->GetZ());
+
//TODO: ADVENTURE DOOR
if(IsLDoNDoor())
{
@@ -200,11 +208,11 @@
{ // this door is only triggered by an object
if(!IsDoorOpen() || (opentype == 58))
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
}
else
@@ -221,11 +229,11 @@
{ //door not locked
if(!IsDoorOpen() || (opentype == 58))
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
}
else
@@ -243,20 +251,23 @@
strcpy(tmpmsg, "Door is locked by an unknown guild");
}
sender->Message(4, tmpmsg);
+ // safe_delete(outapp); // U: does this need to be added here?
return;
}
// a key is required or the door is locked but can be picked or both
sender->Message(4, "This is locked..."); // debug spam - should probably go
+
+ // U: If anyone is considering keys for GM, make sure they can't be passed out or created on client cursor
if(sender->GetGM()) // GM can always open locks - should probably be changed to require a key
{
sender->Message_StringID(4,DOORS_GM);
if(!IsDoorOpen() || (opentype == 58))
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
}
else if(playerkey)
@@ -270,11 +281,11 @@
sender->Message(4, "You got it open!");
if(!IsDoorOpen() || (opentype == 58))
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
}
}
@@ -295,11 +306,11 @@
{
if(!IsDoorOpen())
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
sender->Message_StringID(4, DOORS_SUCCESSFUL_PICK);
}
@@ -333,11 +344,11 @@
sender->Message(4, "You got it open!"); // more debug spam
if(!IsDoorOpen() || (opentype == 58))
{
- md->action = OPEN_DOOR;
+ md->action = invert_state == 0 ? OPEN_DOOR : INVOPEN_DOOR;
}
else
{
- md->action = CLOSE_DOOR;
+ md->action = invert_state == 0 ? CLOSE_DOOR : INVCLOSE_DOOR;
}
}
else
@@ -349,6 +360,9 @@
}
}
+ // U: This was also left in to mark the end of door processing
+ //sender->Message(4, "---end of call---");
+
entity_list.QueueClients(sender, outapp, false);
if(!IsDoorOpen() || (opentype == 58))
{
@@ -365,7 +379,7 @@
//and met all the reqs for opening
//everything to do with closed doors has already been taken care of
//we return because we don't want people using teleports on an unlocked door (exploit!)
- if(md->action == CLOSE_DOOR)
+ if((md->action == CLOSE_DOOR && invert_state == 0) || (md->action == INVCLOSE_DOOR && invert_state == 1))
{
safe_delete(outapp);
return;
If you're looking to run over to Greater Faydark and test the lifts out, just remember that the lifts themselves are still buggy.
If you are waiting to go up the lift, you need to be about 3/5ths or more onto the lift or it will leave without you. The reverse
is true for coming down - no more than 2/5ths way coming from Kelethin. Cycling the actuator seems to bypass this particular bug.
The lift in 'Vergalid' and the 4-part Doors in 'Gyrospire' are not fixed by this, nor is 'Stonehive.' The 'Stonehive' lift actuators
are not assigned trigger doors in my db (and are also exhibiting some really erractic behavior), and the other two will
probably require a scripted action to work correctly. (They can be assigned as triggerdoors in sequential order, but if someone
clicks a door somewhere down the chain than the 'starting' one, all preceding doors will not be triggered.)
Since I have no experience with the scripted door actions for quests and npc's, I will need to parse out the logic states
before I submit fixed versions of 'NPCOpen', 'ForceOpen' and 'ForceClose.'
U