Skip to content

Commit

Permalink
Merge pull request #164 from freeciv/hack_mode
Browse files Browse the repository at this point in the history
Introduce hack mode for web client only testing.
  • Loading branch information
andreasrosdal committed Jun 8, 2018
2 parents 1299c7b + 46ae5b6 commit feec997
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
31 changes: 31 additions & 0 deletions freeciv-web/src/main/webapp/javascript/civclient.js
Expand Up @@ -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 " +
Expand Down
18 changes: 18 additions & 0 deletions freeciv-web/src/main/webapp/javascript/clinet.js
Expand Up @@ -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.
****************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion freeciv-web/src/main/webapp/javascript/packhand.js
Expand Up @@ -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'));
}
Expand Down

0 comments on commit feec997

Please sign in to comment.