Debugging Work: The Palborough Mines Elevator Issue
Posted: Sun Apr 06, 2014 12:41 pm
So I hit the bug with the elevator when attempting to run San'dOria Mission 2-3 (client: 30140319_0) - http://bugs.dspt.info/show_bug.cgi?id=952
Since this bug blocked me from proceeding further without using GM commands, I tried to troubleshoot it further, and ultimately got stuck. So I'm going to summarize my findings here and hope that someone who knows more than me can make something of it.
First, I added a ton of debug logging specific to this elevator (elevator id = 22), so that I could watch its behavior in the console log. I'll attach my transport.cpp with debug logging if someone is interested.
After reviewing the logging, I noticed the following:
With the current code, startElevator gets called for this elevator by the RunElevator lua command. However, the elevator never triggers arriveElevator.
After reviewing the code further, it seems that the reason for this relates to this elevator not being a permanently moving elevator. If the elevator is not permanently moving, the TransportTimer sets IsStarted to false once it thinks its done moving it:
One problem is, it seems like nothing ever can set this elevator to isStarted = true. After tracing the Lua command RunElevator, which is triggered when you pull the lever, I couldn't find anywhere in the code where this was done. So this elevator appeared to be "stuck", because even after I pull the lever, it doesn't get set to isStarted = true;
After I found this out, I added the following to the startElevator function (reflected in my transport.cpp) -
After this was added, the elevator would now trigger arriveElevator shortly after starting like it should. At this point, if I compared my debug logs for this elevator (id = 22), against one of the elevators in metalworks (id=26), then they look like the same basic flow now.
The problem was, the platform still didn't move. So next I compared the elevator entry in the db to one of the other working elevators. The logging told me that the npc it was trying to move was "_3zz", so I looked it up in the NPC list. I noticed that the starting animation for this elevator was listed as "9" for its animation. That was interesting, cause according to the animation enum I see this:
"_3zz" was in one of the door states. When I compared to the Metalworks elevator id=26, which after debugging, I found out was id npc id "@6l0". Both this elevator and the other elevator were in states 10 and 11.
I tried swapping "_3zz"'s animation to 11 (since it starts at the top), but this was no good. In fact, it caused me to not even hear the sound of the elevator moving anymore. So I reverted that...
Then finally I noticed one last interesting thing: both of the other elevator's npc name started with "@". In the very next line after "_3zz"'s definition in npc_list.sql, there exists an "@3z0", which is in elevator state 11, which happens to be the top state which is where the elevator starts off at. The positioning to "_3zz" is similar as well.
So I guess my question is....
Is it possible that the reason the elevator doesn't move is that we're trying to move the wrong npc? I don't know enough to know how we associate "_3zz" as being the elevator npc, but it seems to me that that might be the door and "@3z0" might be the elevator, but I don't know how to try this out.
Thoughts?
-SLK
Since this bug blocked me from proceeding further without using GM commands, I tried to troubleshoot it further, and ultimately got stuck. So I'm going to summarize my findings here and hope that someone who knows more than me can make something of it.
First, I added a ton of debug logging specific to this elevator (elevator id = 22), so that I could watch its behavior in the console log. I'll attach my transport.cpp with debug logging if someone is interested.
After reviewing the logging, I noticed the following:
With the current code, startElevator gets called for this elevator by the RunElevator lua command. However, the elevator never triggers arriveElevator.
After reviewing the code further, it seems that the reason for this relates to this elevator not being a permanently moving elevator. If the elevator is not permanently moving, the TransportTimer sets IsStarted to false once it thinks its done moving it:
Code: Select all
if (!elevator->isPermanent)
{
elevator->isStarted = false;
}
After I found this out, I added the following to the startElevator function (reflected in my transport.cpp) -
Code: Select all
if (!elevator->isPermanent)
{
elevator->isStarted = true;
}
The problem was, the platform still didn't move. So next I compared the elevator entry in the db to one of the other working elevators. The logging told me that the npc it was trying to move was "_3zz", so I looked it up in the NPC list. I noticed that the starting animation for this elevator was listed as "9" for its animation. That was interesting, cause according to the animation enum I see this:
Code: Select all
ANIMATION_OPEN_DOOR = 8,
ANIMATION_CLOSE_DOOR = 9,
ANIMATION_ELEVATOR_UP = 10,
ANIMATION_ELEVATOR_DOWN = 11,
I tried swapping "_3zz"'s animation to 11 (since it starts at the top), but this was no good. In fact, it caused me to not even hear the sound of the elevator moving anymore. So I reverted that...
Then finally I noticed one last interesting thing: both of the other elevator's npc name started with "@". In the very next line after "_3zz"'s definition in npc_list.sql, there exists an "@3z0", which is in elevator state 11, which happens to be the top state which is where the elevator starts off at. The positioning to "_3zz" is similar as well.
So I guess my question is....
Is it possible that the reason the elevator doesn't move is that we're trying to move the wrong npc? I don't know enough to know how we associate "_3zz" as being the elevator npc, but it seems to me that that might be the door and "@3z0" might be the elevator, but I don't know how to try this out.
Thoughts?
-SLK