diff --git a/.astylerc b/.astylerc new file mode 100644 index 0000000..c0e7be1 --- /dev/null +++ b/.astylerc @@ -0,0 +1,21 @@ +# try to mimic the original gsc provided +mode=c +style=allman + +indent=tab +lineend=windows + +pad-oper +pad-paren-in +pad-header + +# delete-empty-lines + +break-blocks +# remove-braces + +indent-switches +indent-cases +indent-after-parens + +remove-comment-prefix diff --git a/.gitignore b/.gitignore index 2a98f8c..7e02e22 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,11 @@ /mods/* !/mods/bots +!/deploy.js +!/deploy.bat +!/z_deploy.bat +!/.astylerc + *.dat *.log players/ diff --git a/deploy.bat b/deploy.bat new file mode 100644 index 0000000..729bb6f --- /dev/null +++ b/deploy.bat @@ -0,0 +1,3 @@ +xcopy cod2m_bot_warfare\mods\bots\maps mods\bots\maps\ /Y /I /E /H /C +xcopy cod2m_bot_warfare\mods\bots\scriptdata mods\bots\scriptdata\ /Y /I /E /H /C +xcopy cod2m_bot_warfare\mods\bots\bots.txt mods\bots\ /Y /I /H /C diff --git a/deploy.js b/deploy.js new file mode 100644 index 0000000..6a2d4b5 --- /dev/null +++ b/deploy.js @@ -0,0 +1,51 @@ +// nodejs 14+ + +const exec = require('util').promisify(require('child_process').exec) + +const repo_name = 'cod2m_bot_warfare' +const repo_url = `https://github.com/ineedbots/${repo_name}` +const deploy_check_rate = 60000 +const title = 'CoD2M Bot Warfare Git Deployer' + +function printToConsole(what, error = false) +{ + log = error ? console.error : console.log + + log(`[${new Date().toISOString()}]:`, what) +} + +async function doDeploy() { + try { + const { stdout, stderr } = await exec(`cd ${repo_name} && git fetch`) + + if (stderr.length <= 0) + return + + if (stderr.startsWith('From ')) + { + printToConsole('git fetched! Pulling...') + await exec(`cd ${repo_name} && git pull && git submodule update --init --recursive`) + printToConsole('Deploying...') + await exec('deploy.bat') + printToConsole('Deployed!') + } + } catch (e) { + printToConsole(e, true) + + if (!e.stderr.startsWith('The system cannot find the path specified')) + return + + printToConsole('Cloning repo...') + try { + await exec(`git clone ${repo_url} && cd ${repo_name} && git submodule update --init --recursive`) + + printToConsole('Cloned!') + } catch (f) { + printToConsole(f, true) + } + } +} + +process.stdout.write(`${String.fromCharCode(27)}]0;${title}${String.fromCharCode(7)}`) +doDeploy() +setInterval(doDeploy, deploy_check_rate) diff --git a/z_deploy.bat b/z_deploy.bat new file mode 100644 index 0000000..05197ae --- /dev/null +++ b/z_deploy.bat @@ -0,0 +1 @@ +start "" "node" deploy.js \ No newline at end of file