Fix Xonotic

This commit is contained in:
DeathByDenim 2022-02-03 19:50:55 -05:00
parent efe8d35bc7
commit a2a57e2624
Signed by: DeathByDenim
GPG Key ID: 4A475283D925365B
4 changed files with 31 additions and 23 deletions

View File

@ -8,7 +8,10 @@ mkdir -p "${xonotic_directory}"
unzip -f -o -d ${xonotic_directory} ${TMPDIR:-/tmp}/xonotic.zip
rm -f ${TMPDIR:-/tmp}/xonotic.zip
cat > /etc/xonotic.cfg <<EOF
mkdir -p ${systemuserhome}/xonotic/data
chown -R ${systemuser}: ${systemuserhome}/xonotic
cat > ${systemuserhome}/xonotic/data/server.cfg <<EOF
sv_public 0
hostname "onFOSS"
maxplayers 64
@ -36,8 +39,8 @@ Description=Unvanguished server
After=network.target
[Service]
WorkingDirectory=${xonotic_directory}
ExecStart=/usr/bin/console2web -p 62550 ${xonotic_directory}/daemonded -pakpath ${unvanquished_directory}/share/pkg/ -libpath ${unvanquished_directory}/bin/ -homepath \${HOME}/unvanguished_home/ +exec unvanguished.cfg
WorkingDirectory=${xonotic_directory}/Xonotic
ExecStart=/usr/bin/console2web -p 62550 ${xonotic_directory}/Xonotic/xonotic-linux64-dedicated +serverconfig server.cfg -userdir ${systemuserhome}/xonotic
Restart=on-failure
User=${systemuser}

View File

@ -7,24 +7,30 @@ function convertTerminalCodeToHtml(line) {
let code = line[++i]
if(code == '[') {
// This means it's a colour
let colour_code = "";
for(i++; i < line.length && line[i] != 'm'; i++) {
colour_code += line[i];
}
colour_code = parseInt(colour_code);
if(colour_code === 0) {
for(let i = 0; i < open_spans; i++) {
htmlline += "</span>";
while(i < line.length && line[i] != 'm') {
let colour_code = "";
for(i++; i < line.length && line[i] != 'm' && line[i] != ';'; i++) {
colour_code += line[i];
}
colour_code = parseInt(colour_code);
if(colour_code === 0) {
for(let i = 0; i < open_spans; i++) {
htmlline += "</span>";
}
open_spans = 0;
}
if(colour_code === 1) {
htmlline += '<span class="TERM_FOREGROUND_BOLD">';
open_spans++;
}
else if(colour_code >= 30 && colour_code <= 37) {
htmlline += '<span class="TERM_FOREGROUND_'+(colour_code-30)+'">';
open_spans++;
}
else if(colour_code >= 90 && colour_code <= 97) {
htmlline += '<span class="TERM_FOREGROUND_'+(colour_code-90)+'_INTENSE">';
open_spans++;
}
open_spans = 0;
}
else if(colour_code >= 30 && colour_code <= 37) {
htmlline += '<span class="TERM_FOREGROUND_'+(colour_code-30)+'">';
open_spans++;
}
else if(colour_code >= 90 && colour_code <= 97) {
htmlline += '<span class="TERM_FOREGROUND_'+(colour_code-90)+'_INTENSE">';
open_spans++;
}
}
}

View File

@ -23,7 +23,6 @@ function unvanguished_init() {
// Listen for messages
socket.addEventListener('message', function (event) {
console.log(event);
const unvanguished_output = document.getElementById('unvanguished_output');
let line = document.createElement('p')
line.innerHTML = convertDaemonedCodeToHtml(event.data);

View File

@ -18,14 +18,14 @@ function xonotic_init() {
// Connection opened
socket.addEventListener('open', function (event) {
socket.send('/status');
socket.send('who');
});
// Listen for messages
socket.addEventListener('message', function (event) {
const xonotic_output = document.getElementById('xonotic_output');
let line = document.createElement('p')
line.innerHTML = convertDaemonedCodeToHtml(event.data);
line.innerHTML = convertTerminalCodeToHtml(event.data);
xonotic_output.prepend(line);
});
}