Skip to content

Commit

Permalink
Remove hardcoded longturn ports in js
Browse files Browse the repository at this point in the history
  • Loading branch information
lonemadmax committed Sep 30, 2018
1 parent b0617a4 commit 486044f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
4 changes: 1 addition & 3 deletions ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ Freeciv has AI related

# Freeciv-web LongTurn

Activation of LongTurn support is configured as a list of port numbers in these files:
Activation of LongTurn support is configured as a list of port numbers in this file:
publite2/settings.ini
freeciv/patches/longturn.patch
freeciv-web\src\main\webapp\javascript\civcliet.js is_longturn()

# Rules

Expand Down
4 changes: 0 additions & 4 deletions README-One-Turn-Per-Day.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ LongTurn games require some manual configuration to work.
File: publite2\settings.ini
Config: Add LongTurn game server ports to the 'longturn_server_ports' variable.

File: freeciv-web\src\main\webapp\javascript\civclient.js
Add LongTurn game server ports to the 'longturn_server_port_list' variable.
(Changing this requires recompiling Freeciv-web using freeciv-web/build-js.sh)

LongTurn game specific server settings:
publite2\pubscript_longturn_6003.serv
publite2\pubscript_longturn_6004.serv
Expand Down
36 changes: 27 additions & 9 deletions freeciv-web/src/main/webapp/javascript/civclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var username = null;

var fc_seedrandom = null;

// List of ports which are reserved for LongTurn games.
var longturn_server_port_list = [6003,6004,6005,6006,6007];
// singleplayer, multiplayer, longturn, pbem
var game_type = "";

var music_list = [ "battle-epic",
"andrewbeck-ancient",
Expand Down Expand Up @@ -72,7 +72,30 @@ function civclient_init()
$.blockUI.defaults['css']['color'] = "#fff";
$.blockUI.defaults['theme'] = true;

if ($.getUrlVar('action') == "observe") {
var action = $.getUrlVar('action');
game_type = $.getUrlVar('type');
if (game_type == null) {
if (action == null || action == 'multi') {
swal({
title: "Unknown game type",
text: "For some reason the client can't determine what kind of game this is. Please <a href='https://github.com/freeciv/freeciv-web/issues'>open an issue</a> detailing how you got here",
html: true,
type: "error"
},
// Requires a parameter to also be called on cancel
function (unused) {
window.location.href ='/';
}
);
return;
} else if (action == 'pbem') {
game_type = 'pbem';
} else {
game_type = 'singleplayer';
}
}

if (action == "observe") {
observing = true;
$("#civ_tab").remove();
$("#cities_tab").remove();
Expand Down Expand Up @@ -636,10 +659,5 @@ function switch_renderer()
**************************************************************************/
function is_longturn()
{
for (var i = 0; i < longturn_server_port_list.length; i++) {
if (longturn_server_port_list[i] == civserverport || $.getUrlVar('civserverport') == longturn_server_port_list[i]) {
return true;
}
}
return false;
return game_type == "longturn";
}

0 comments on commit 486044f

Please sign in to comment.