Skip to content
Snippets Groups Projects
Commit 50df9387 authored by rswindell's avatar rswindell
Browse files

Support invocation/use from the terminal server (not JSexec).

parent 3a101890
No related branches found
No related tags found
No related merge requests found
#!/synchronet/src/src/sbbs3/gcc.freebsd.exe.stephen.hurd.local/jsexec // $Id$
// #!/synchronet/src/src/sbbs3/gcc.freebsd.exe.stephen.hurd.local/jsexec
var startup_path='.'; var startup_path='.';
try { throw barfitty.barf(barf) } catch(e) { startup_path=e.fileName } try { throw barfitty.barf(barf) } catch(e) { startup_path=e.fileName }
...@@ -99,21 +100,68 @@ function ConfigureSettings() ...@@ -99,21 +100,68 @@ function ConfigureSettings()
} }
} }
if(uifc == undefined) { var reset = false;
writeln("UIFC interface not available!"); if(this.uifc == undefined) {
exit(1);
while(!js.terminated && (!this.console || !console.aborted)) {
print("Configuration:");
print();
for(var i=0; i< GameSettingProperties.length; i++)
print(format("%2d: %-35s = %s", i + 1, GameSettingProperties[i].name, Settings[GameSettingProperties[i].prop]));
print();
var which = prompt("Which");
which = parseInt(which, 10);
if(isNaN(which))
break;
if(which < 1 || which > GameSettingProperties.length)
continue;
which--;
if(GameSettingProperties[which].type == "Boolean") {
if(Settings[GameSettingProperties[which].prop])
Settings[GameSettingProperties[which].prop] = confirm(GameSettingProperties[which].name);
else
Settings[GameSettingProperties[which].prop] = !deny(GameSettingProperties[which].name);
continue;
}
var val = prompt(GameSettingProperties[which].name);
switch(GameSettingProperties[which].type) {
case "String":
Settings[GameSettingProperties[which].prop] = val;
break;
case "Date":
Settings[GameSettingProperties[which].prop] = val;
break;
case "Integer":
Settings[GameSettingProperties[which].prop] = parseInt(val);
break;
}
} }
if(js.terminated || (this.console && console.aborted))
exit(0);
reset = confirm("Reset Game");
try {
db=new JSONClient(Settings.Server,Settings.Port);
db.connect();
Settings.save();
}
catch (e) {
alert("WARNING: Unable to connect to server: " + e);
}
} else {
uifc.init("TradeWars 2 Initialization", /* ciolibmode: */argv[0]); uifc.init("TradeWars 2 Initialization", /* ciolibmode: */argv[0]);
ConfigureSettings(); ConfigureSettings();
if(js.global.db != undefined) { if(js.global.db != undefined) {
if(uifc.list(WIN_MID|WIN_SAV, 0, 0, 0, 0, 0, "Reset Game?", ["No", "Yes"])!=1) { if(uifc.list(WIN_MID|WIN_SAV, 0, 0, 0, 0, 0, "Reset Game?", ["No", "Yes"]) == 1)
uifc.bail(); reset = true;
exit(1);
} }
} }
if(!reset)
exit(0);
print("Resetting game");
load(fname("ports.js")); load(fname("ports.js"));
load(fname("planets.js")); load(fname("planets.js"));
load(fname("teams.js")); load(fname("teams.js"));
...@@ -124,8 +172,6 @@ load(fname("messages.js")); ...@@ -124,8 +172,6 @@ load(fname("messages.js"));
load(fname("computer.js")); load(fname("computer.js"));
load(fname("input.js")); load(fname("input.js"));
var i;
ResetAllPlayers(); ResetAllPlayers();
ResetAllPlanets(); ResetAllPlanets();
ResetAllMessages(); ResetAllMessages();
...@@ -134,6 +180,7 @@ InitializeSectors(); ...@@ -134,6 +180,7 @@ InitializeSectors();
InitializePorts(); InitializePorts();
InitializeCabal(); InitializeCabal();
db.write(Settings.DB,'twopeng',[],LOCK_WRITE); db.write(Settings.DB,'twopeng',[],LOCK_WRITE);
if(this.uifc) {
uifc.pop(); uifc.pop();
uifc.bail(); uifc.bail();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment