/*
 * GENERAL CONFIG
 *
 * to setup startup map and gametype please check Server-TacticalOps.ini
 * [URL]
 * .
 * .
 * LocalMap=....
 *
 */
var UTBINARY="tacticalops.exe";

/*
 * How many seconds should we wait before we restart the server
 */
var SLEEPTIME=10;

/*
 * if you use ucc to start set "server"
 * else ""
 */
var UCCOPTIONS="";

/*
 * -nohomedir dont use ~/.unrealtournament/
 * add -server here if you use Tacticalops/unrealtournament binary for running
 *
 */
var OPTIONS="-nohomedir -server";

/*
 * INI FILES
 */
var SERVERINI="Server-TacticalOps.ini";
var USERINI="Server-User.ini";

/*
 * LOG OPTIONS
 */
var LOGPREFIX="TacticalOpsServer-Windows";
var LOGDIR="../Logs";
var SYSTEMLOGS=LOGDIR + "/system";

function padWithZero (Number) {
    if ( Number  < 9 ) {
        return "0" + Number;
    }
    else {
        return Number
    }
}

function getDateString(){
    var dateStr;
    dt = new Date();
    dateStr = dt.getFullYear();
    dateStr += "-";
    dateStr += padWithZero ( dt.getMonth() + 1 );
    dateStr += "-";
    dateStr += padWithZero ( dt.getDate() );
    dateStr += "T";
    dateStr += padWithZero ( dt.getHours() );
    dateStr += "-";
    dateStr += padWithZero ( dt.getMinutes() );

    return dateStr;
}
while ( true ) {
    SD=getDateString();
    CMDLINE=UTBINARY + " " + UCCOPTIONS + " -INI=" + SERVERINI + " -USERINI=" + USERINI + " -LOG=" + SYSTEMLOGS + "/" + LOGPREFIX +"-"+ SD +".log " + OPTIONS;
    var WshShell = new ActiveXObject ( "WScript.Shell" );
    var oExec = WshShell.Exec ( CMDLINE );
    while ( oExec.Status == 0 ) {
      WScript.Sleep ( 100 );
    }
    WScript.Sleep ( SLEEPTIME * 1000 );

}
