[Server Scripting] Fatal! player called for non existing ID 1

Discussion in 'Server and Client Scripting' started by Homura, Nov 5, 2014.

  1. Homura

    Homura Member

    Joined:
    May 22, 2012
    Messages:
    43
    Likes Received:
    0
    Abstract:
    Server crashes on logout due to two simultaneous logout events per player logout.

    This is could be a script error, could be a server error. That PO Main runs fine seems to indicate the former, but the logs I have taken a look at indicate the latter. I am running this off a fresh 2.5.0 install. The client works perfectly, so I doubt it's a faulty installation problem. This is what the server looks like:
    Code (text):
    1. Setting home dir to :  "C:/Users/[snip]/Pokemon Online 2.5/./"
    2.  
    3. -----------------------
    4. New Server, starting logs
    5. -----------------------
    6.  
    7. Server is running in windowed mode
    8. "Connection to the database established!"
    9. "Starting loading pokemon database..."
    10. "Pokemon database loaded"
    11. Running sanity check for gen  0
    12. Running sanity check for gen  1
    13. Running sanity check for gen  2
    14. Running sanity check for gen  3
    15. Running sanity check for gen  4
    16. Running sanity check for gen  5
    17. "Members loaded"
    18. "Starting to listen to port 5080"
    19. "Channel The Restaurant was created"
    20. "Running Daily Run for tier All"
    21. "0 alts removed from the ladder."
    22. "0 secs"
    23. " "
    24. Set daily run days to  182
    25. Processing daily run for members with limit  "2014-05-06T17:11:45"
    26. Daily run for members finished
    27. "Script Check: OK"
    28. "Channel Auth Cave was created"
    29. "Channel Watch was created"
    30. "Channel Party Time! was created"
    31. "Channel Elsewhere was created"
    32. "Channel League was created"
    33. "Channel The Mosh Pit was created"
    34. "Channel Role Playing was created"
    35. "Channel Goldenrod City was created"
    36. loading member in memory not with a thread
    37. loading member in memory not with a thread
    38. loading member in memory not with a thread
    39. loading member in memory not with a thread
    40. loading member in memory not with a thread
    41. loading member in memory not with a thread
    42. loading member in memory not with a thread
    43. loading member in memory not with a thread
    44. loading member in memory not with a thread
    45. loading member in memory not with a thread
    46. loading member in memory not with a thread
    47. loading member in memory not with a thread
    48. loading member in memory not with a thread
    49. "Announcement changed."
    50. "<font color=blue><timestamp/></font><b><i><font size=4><font color=blue>Script Update:</font> Pizza Delivery for I C Weiner!</font></i></b>"
    51. Warning: QObject::connect: No such slot ScriptEngine::battleConnectionLost()
    52. "The server is now public."
    53. "Connecting to registry..."
    54. "Connected to registry! Sending server info..."
    55. "Connecting to battle server on port 5096..."
    56. "Connected to battle server!"
    57. "Received pending connection on slot 1 from 127.0.0.1"
    58. "Player 1 set name to pan"
    59. "pan joined channel The Restaurant."
    60. "[#Watch] <font style='color:#06AA50'><timestamp/>-&gt;<b><i>WelcomeBot:</i></b> #1: pan (127.0.0.1) logged in.</font>"
    61. "[#The Restaurant] <font style='color:#06AA50'><timestamp/>-&gt;<b><i>WelcomeBot:</i></b> <font color=black><b>A wild <font color=#005500>pan</font> appeared!</b></font></font>"
    62. "[#Watch] <font style='color:#006888'><timestamp/>-&gt;<b><i>CommandBot:</i></b> [<b><font color=orange>#The Restaurant</font></b>] -- </font><font color=#005500><b>pan</b></font> (100 pp) -- <b><font color=black>/idle</font></b> off</font>"
    63. "Received logout from pan (1)"
    64. "[#Watch] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> #1: pan (127.0.0.1) logged out.</font>"
    65. "[#The Restaurant] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> <font color=black><b><font color=black>The wild <font color=#005500>pan</font> used Teleport!</b></font></font>"
    66. "pan left channel The Restaurant."
    67. "Received logout from pan (1)"
    68. "[#Watch] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> #1: pan (127.0.0.1) logged out.</font>"
    69. "[#The Restaurant] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> <font color=black><b><font color=black>The wild <font color=#005500>pan</font> used Teleport!</b></font></font>"
    70. "Removed player pan (1)"
    71. Fatal: Fatal! player called for non existing ID 1
    72. Warning: QWaitCondition: Destroyed while threads are still waiting
    The relevant section in the script:
    Code (text):
    1. beforeLogOut : function (source) {
    2.     sys.writeToFile("somestuff.txt", "before 1");
    3.     if (players[source] == undefined) {
    4.         newPlayer(source);
    5.     }
    6.     if (players[source].showgoodbye) {
    7.         WelcomeBot.afterLogOut(source);
    8.     }
    9.     players[source].online = false;
    10.     sys.writeToFile("somestuff.txt", "before 2");
    11. },
    12.  
    13. afterLogOut : function (source) {
    14.     sys.writeToFile("somestuff.txt", "after");
    15. },
    Contents of "somestuff.txt":
    Code (text):
    1. after
    Allow me to break it down for readability.

    loading member in memory not with a thread
    Bunches of these- but are they important?

    Warning: QObject::connect: No such slot ScriptEngine::battleConnectionLost()
    I don't know what this means... but it's probably not the problem.

    Here's a big reason why I doubt it's just a server thing
    "Received logout from pan (1)"
    "[#Watch] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> #1: pan (127.0.0.1) logged out.</font>"
    "[#The Restaurant] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> <font color=black><b><font color=black>The wild <font color=#005500>pan</font> used Teleport!</b></font></font>"
    "pan left channel The Restaurant."
    "Received logout from pan (1)"
    "[#Watch] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> #1: pan (127.0.0.1) logged out.</font>"
    "[#The Restaurant] <font style='color:orange'><timestamp/>-&gt;<b><i>GoodByeBot:</i></b> <font color=black><b><font color=black>The wild <font color=#005500>pan</font> used Teleport!</b></font></font>"
    "Removed player pan (1)"
    Fatal: Fatal! player called for non existing ID 1

    This was not a copy-paste error! Two logOut events were fired. If I was to make a guess, I'd say this part:
    Fatal: Fatal! player called for non existing ID 1
    was actually trying to run whatever would normally fire this:
    "Removed player pan (1)"
    The second logOut event triggered for the same player's logout.

    Here's a screenshot.
    Capture.PNG

    See that window? Clicking OK or X causes the server to crash and then post this into the log:
    Warning: QWaitCondition: Destroyed while threads are still waiting

    Of course, if I don't close this window, the server continues to "work" and the alert messages pile up. Ignoring this causes several problems: First, it still attempts to log a player out twice per logout (which we can live with except that the windows pile up pretty fast). Second, it makes it impossible to configure the server settings.


    If the answer to this thread is "Install from source" or "Use an older version of Qt", then I request either fixing the Windowed server releases or not bothering to include the server in the client releases. This was the answer in 2.4.1/2.4.2. I understand that PO Main's server may run in a different environment and from a possibly different build, but if PO Main's script has some workaround for this then I would gladly accept advice on this. I have looked at the PO-Server-Goodies on GitHub, finding nothing that addresses this issue.
     
  2. Kase

    Kase Member

    Joined:
    Mar 12, 2014
    Messages:
    148
    Likes Received:
    3
    Did you use the same scripts with 2.4.2? If you did, it should be a script error, right?

    The Id could be missing because the players disconnected. Maybe to fix this you might want to add something so the it remembers the Id until it has do all the events (Not sure about this, just an idea).
     
    Last edited: Nov 5, 2014
  3. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Main server runs on qt 4.8. There is an alternative download for PO which is qt5.0.2 which should fix the problem.
    Finding the issue isn't as easy as just "fixing it"
     
  4. Homura

    Homura Member

    Joined:
    May 22, 2012
    Messages:
    43
    Likes Received:
    0
    Kasa- The ID is obviously missing because the logoff event is fired twice.

    Moogle- I'll look into the alternative download this time. On 2.4.2, I tried the download links I could find as well as compiling from source (using qt5.0.2), but the only answer I got working was to guess-and-check which files from 2.4.2 I could sneak in without the 2.4.1 server freaking out. I don't want to have to compile from source, because while I can do that on my computer, I'm not the main host.