diff --git a/freeciv-web/src/main/webapp/javascript/civclient.js b/freeciv-web/src/main/webapp/javascript/civclient.js index 5b0403d8f..61e0b933f 100644 --- a/freeciv-web/src/main/webapp/javascript/civclient.js +++ b/freeciv-web/src/main/webapp/javascript/civclient.js @@ -226,6 +226,37 @@ function init_common_intro_dialog() { show_intro_dialog("Welcome to Freeciv-web", msg); } + } else if ($.getUrlVar('action') == "hack") { + var hack_port; + var hack_username; + + if ($.getUrlVar('civserverport') != null) { + hack_port = $.getUrlVar('civserverport'); + } else { + show_intro_dialog("Welcome to Freeciv-web", + "Hack mode disabled because civserverport wasn't specified. " + + "Falling back to regular mode."); + return; + } + + if ($.getUrlVar("username") != null) { + hack_username = $.getUrlVar("username"); + } else if (simpleStorage.hasKey("username")) { + hack_username = simpleStorage.get("username"); + } else { + show_intro_dialog("Welcome to Freeciv-web", + "Hack mode disabled because \"username\" wasn't specified and no " + + "stored user name was found. " + + "Falling back to regular mode."); + return; + } + + if ($.getUrlVar('autostart') == "true") { + autostart = true; + } + + network_init_manual_hack(hack_port, hack_username, + $.getUrlVar("savegame")); } else { show_intro_dialog("Welcome to Freeciv-web", "You are about to join this game server, where you can " + diff --git a/freeciv-web/src/main/webapp/javascript/clinet.js b/freeciv-web/src/main/webapp/javascript/clinet.js index a66376218..3b10981aa 100644 --- a/freeciv-web/src/main/webapp/javascript/clinet.js +++ b/freeciv-web/src/main/webapp/javascript/clinet.js @@ -33,6 +33,24 @@ var ping_last = new Date().getTime(); var pingtime_check = 240000; var ping_timer = null; +/************************************************************************** + Initialize the network communication with the server manually. +**************************************************************************/ +function network_init_manual_hack(civserverport_manual, username_manual, + savegame) +{ + civserverport = civserverport_manual; + username = username_manual; + + websocket_init(); + + if (savegame != null) { + wait_for_text("You are logged in as", function () { + load_game_real(savegame); + }); + } +} + /**************************************************************************** Initialized the Network communication, by requesting a valid server port. ****************************************************************************/ diff --git a/freeciv-web/src/main/webapp/javascript/packhand.js b/freeciv-web/src/main/webapp/javascript/packhand.js index dbbe0be6a..3d3eaa07f 100644 --- a/freeciv-web/src/main/webapp/javascript/packhand.js +++ b/freeciv-web/src/main/webapp/javascript/packhand.js @@ -79,7 +79,7 @@ function handle_server_join_reply(packet) set_client_state(C_S_PREPARING); - if ($.getUrlVar('action') == "new" + if (($.getUrlVar('action') == "new" || $.getUrlVar('action') == "hack") && $.getUrlVar('ruleset') != null) { change_ruleset($.getUrlVar('ruleset')); }