Page MenuHomeWildfire Games

Fix gamesetup.js crash if game compiled without lobby
ClosedPublic

Authored by nwtour on Jan 5 2018, 7:43 AM.

Details

Summary

Patch fixed:
ERROR: JavaScript error: gui/gamesetup/gamesetup.js line 240
TypeError: Engine.LobbyGetNick is not a function
/gamesetup.js:240:18
__eventhandler11 (press)@__internal(12) press:0:1

Test Plan

Steps to reproduce:

  • compile with option --without-lobby
  • run New Game -> Single player
  • game interface full freeze

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

nwtour created this revision.Jan 5 2018, 7:43 AM
elexis added a subscriber: elexis.

Engine.LobbyGetNick would be a bit more symmetrical condition. Also looks like an && would be sufficient.
Oh, maybe even better we could nuke the global since it's only used in one place and I assume that call doesn't consume any time. Then we don't need a condition.
I would assume there are other places where we didn't took care of that too. Can you check?

Finally add a gui/credits/programming.json entry, you can leave out the realname if you want to.

nwtour added a comment.Jan 5 2018, 2:12 PM
In D1196#48463, @elexis wrote:

Oh, maybe even better we could nuke the global since it's only used in one place and I assume that call doesn't consume any time. Then we don't need a condition.
I would assume there are other places where we didn't took care of that too. Can you check?

Yes, g_Username used in one place with endpoint in dummy function:
void JSI_Lobby::SendRegisterGame(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue data)
{

if (!g_XmppClient)
        return;

Finally add a gui/credits/programming.json entry, you can leave out the realname if you want to.

Ok

nwtour updated this revision to Diff 5087.Jan 5 2018, 2:20 PM

Patch updated

nwtour updated this revision to Diff 5088.Jan 5 2018, 2:27 PM

Updated

elexis accepted this revision.Jan 5 2018, 2:33 PM

Alright, thanks for the patch!

If I recall correctly, the other functions in JSInterface_Lobby.cpp are only used when registering an account or doing something in the lobby.
Especially the ingame GUI session.js seems to not have the same bug.
If someone wants to take a closer look, that wouldn't hurt.

This revision is now accepted and ready to land.Jan 5 2018, 2:33 PM

Testing: I've compiled --without-lobby and can confirm that it's broken without the patch in the gamesetup, but that the lobby button in the mainmenu is correctly disabled and that the patch fixes the gamesetup. I've searched the code for Engine.GetLobby and all calls were conditional, i.e. patch is correct and complete.

This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Jan 5 2018, 5:47 PM