Fixed changes

This commit is contained in:
mathusummut
2018-11-09 13:02:55 +01:00
parent a065cf374f
commit b1426df716
11 changed files with 52 additions and 790 deletions

View File

@@ -1,187 +1,64 @@
# ChangeLog.md
# ZetaGlest ChangeLog
This documents notable or significant changes to
[ZetaGlest](https://zetaglest.github.io/). If you are looking for
information about the game from which it was forked, please see the
[MegaGlest home page](https://megaglest.org/).
v1.0
## 2018-09-18
* Update [miniz](https://github.com/richgel999/miniz) library. Thanks
- The new logo is polished
- Buildings will now still be built even when units are in the way
- Special effects added to fading/vanishing corpses
- Zoom-out restriction during network play removed
- Maximum unit selection cap has been removed
- Size of attack and move icons increased
- Forest tilesets are more animated
- You can leave and re-join network games, even if you experience lag
- [Default command is changed to "attack" instead of "move", which is much more intuitive](https://github.com/ZetaGlest/zetaglest-source/commit/2c4fc340de958f6b94b40ee62eabff015625e62b)
(pressing "a" not needed anymore); ["m" key can be used for "move"](https://github.com/ZetaGlest/zetaglest-source/commit/bf5a04be18f2b16b8a565acff4baabc5fbfed293).
- Updated UI to look more modern
- Improved OOS detection, which also helps detect cheating
- [Transparency of the alpha component of textures can now be set](https://zetaglest.github.io/docs/modelling/textures.html#Transparency)/
- Updated [miniz](https://github.com/richgel999/miniz) library. Thanks
to [richgel999](https://github.com/richgel999) and the miniz contributors.
## 2018-09-17
* CMakeLists.txt files have had a major tune-up (doesn't affect Windows users)
* BSD build instructions updated
* [INSTALL.md](https://github.com/ZetaGlest/zetaglest-source/blob/develop/INSTALL.md) document created
* man pages are no longer generated each time a build is performed.
They must be manually generated when the help usage output is changed.
* debugging scripts have been moved to a scripts/ directory (they'll
need reviewing and editing before use)
## 2018-09-07
Upgrade [libircclient](https://sourceforge.net/projects/libircclient/) embedded library from 1.3 to 1.10/
[view ChangeLog](https://github.com/ZetaGlest/zetaglest-source/commit/64cc6c3cb10c7fd6d97fa0af4a10b431100c58b0#diff-2a35002207d9e074987b668f273e598d)
## 2018-09-05
* Special effects added to fading/vanishing corpses
## 2018-09-04
* zoom-out restriction during network play removed
* added support for Windows 10 SDK
## 2018-09-03
* [[203]](https://github.com/ZetaGlest/zetaglest-source/issues/203)
Buildings will now still be built even when units are in the way
## 2018-06-28
* [transparency of the alpha component of textures can now be set](https://zetaglest.github.io/docs/modelling/textures.html#Transparency)/
[view patch](https://github.com/ZetaGlest/zetaglest-source/commit/b1760253fdb3e5b9b38c3bcf3d5f154044536b0c)
## 2018-06-10
* [[80]](https://github.com/ZetaGlest/zetaglest-source/issues/80)
Double right-clicking now sends a move command instead of attack
* [[#28]](https://github.com/ZetaGlest/zetaglest-source/issues/28)
Maximum unit selection removed
* [[#75]](https://github.com/ZetaGlest/zetaglest-source/issues/75)
Size of attack and move icons increased
## 2018-05-16
* [16 maps added](https://github.com/ZetaGlest/zetaglest-data/compare/4c67d4bfba21...9dfb37450e07)
## 2018-05-08
* OpenBSD build instructions added
## 2018-05-06
* [[d1acd87](https://github.com/ZetaGlest/zetaglest-source/commit/d1acd8742395bca8b37656e9e8065022902586fe)]Lua
can now be used in scripts tag in faction tag within XML
## 2018-03-31
* [[bugfix:835c6ef](https://github.com/ZetaGlest/zetaglest-source/commit/835c6efd924ed7e62ccd43e064bc6b7f5cdecbfc)]Fixed
"x" key getting stuck on Windows
## 2018-03-20
* [[045b0b8](https://github.com/ZetaGlest/zetaglest-source/commit/045b0b88e051f7163fbef42fa0adc63a326ca186)]Removed "MG_" and "xxx" (3 digit extension) on nicknames in lobby player list
## 2018-03-14
* [Windows](https://github.com/ZetaGlest/zetaglest-source/commits/develop/mk/windows) build
system, dependencies, and documentation updated
## 2018-02-22
* Some sound effects can now be customized by players. See
[diff](https://github.com/ZetaGlest/zetaglest-source/commit/73aa999de7f257b706f94c448a2fb7c2505fb746)
for detailed information, and see comments in
[glest.ini](https://github.com/ZetaGlest/zetaglest-source/blob/73aa999de7f257b706f94c448a2fb7c2505fb746/mk/linux/glest.ini#L98)
* These units can now heal mobile units from their own factions that are
in range
nurse (British, radius of 15)
archmage_tower (Magic, radius of 8)
See
[comparison](https://github.com/ZetaGlest/zetaglest-data/compare/e2d1ca55cb88...8762e708669e)
for detailed information and other related changes.
## 2018-02-16
* auto-healing radius changed from 8 to 15 (with the exception of Valhalla)
* Units standing near Valhalla (norse) are auto-healed (radius of 8)
## 2018-02-15
These units can now heal mobile units from their own factions that are
in range (radius of 8)
priest (Egypt)
wartime mechanic (Rome)
minstrel (Elves)
engineer (Greece)
magician (Persia)
For more information about this change, see
https://github.com/ZetaGlest/zetaglest-data/compare/ac7d2af266cb...579ce1539bbb
## 2018-02-14
* default command changed to "attack"
## 2018-02-03
* Temporarily (or maybe permanently) reverted the default command back to
"move" (see entry dated 2018-01-27).
Hotkey changes:
M -> H (Show console/chat history)
H -> T (Toggle team chat
T -> Z (Cycle between store units)
M is now the hotkey for "move" when units are selected
## 2018-01-31
* [Replaced the sphinx with the scarab](https://github.com/ZetaGlest/zetaglest-data/commit/60e734180ecb7f925144c94bef339e6130f9ae20)
- CMakeLists.txt files have had a major tune-up (doesn't affect Windows users)
- OpenBSD build instructions added and updated
- [INSTALL.md](https://github.com/ZetaGlest/zetaglest-source/blob/develop/INSTALL.md) document created
- man pages are no longer generated each time a build is performed. They must be manually generated when the help usage output is changed.
- Upgraded [libircclient](https://sourceforge.net/projects/libircclient/) embedded library from 1.3 to 1.10
- Added support for Windows 10 SDK
- [16 maps added](https://github.com/ZetaGlest/zetaglest-data/compare/4c67d4bfba21...9dfb37450e07)
- [[d1acd87](https://github.com/ZetaGlest/zetaglest-source/commit/d1acd8742395bca8b37656e9e8065022902586fe)]Lua can now be used in scripts tag in faction tag within XML
- [[bugfix:835c6ef](https://github.com/ZetaGlest/zetaglest-source/commit/835c6efd924ed7e62ccd43e064bc6b7f5cdecbfc)]Fixed "x" key getting stuck on Windows
- [[045b0b8](https://github.com/ZetaGlest/zetaglest-source/commit/045b0b88e051f7163fbef42fa0adc63a326ca186)]Removed "MG_" and "xxx" (3 digit extension) on nicknames in lobby player list
- [Windows](https://github.com/ZetaGlest/zetaglest-source/commits/develop/mk/windows) build system, dependencies, and documentation updated
- These units can now heal mobile units from their own factions that are in range: nurse (British, radius of 15), archmage_tower (Magic, radius of 8)
- Auto-healing radius changed from 8 to 15 (with the exception of Valhalla)
- Units standing near Valhalla (norse) are auto-healed (radius of 8)
- These units can now heal mobile units from their own factions that are in range (radius of 8):
priest (Egypt)
wartime mechanic (Romans)
minstrel (Elves)
engineer (Greece)
magician (Persia)
- Hotkey changes:
M -> H (Show console/chat history)
H -> T (Toggle team chat)
T -> Z (Cycle between store units)
M is now the hotkey for "move" when units are selected
- [Replaced the sphinx with the scarab](https://github.com/ZetaGlest/zetaglest-data/commit/60e734180ecb7f925144c94bef339e6130f9ae20)
(Egypt's starting units)
## 2018-01-27
* [Changed default mouse right-click command: attack!](https://github.com/ZetaGlest/zetaglest-source/commit/2c4fc340de958f6b94b40ee62eabff015625e62b)
(pressing "a" not needed anymore); ["m" key can be used for "move"](https://github.com/ZetaGlest/zetaglest-source/commit/bf5a04be18f2b16b8a565acff4baabc5fbfed293).
## 2018-01-24
4 new tactical scenarios were added / Thanks @ [Julie Marchant](https://github.com/onpon4)
* Witches' Hunt
* Native Unrest
* Warlock Overlords
* Death Road
[#13](https://github.com/ZetaGlest/zetaglest-source/issues/13)
- 4 new tactical scenarios were added / Thanks @ [Julie Marchant](https://github.com/onpon4)
Witches' Hunt
Native Unrest
Warlock Overlords
Death Road
- [#13](https://github.com/ZetaGlest/zetaglest-source/issues/13)
Observers no longer take up slots on a map. For instance, a map being
played by 4 players can have a 5th person observing; a map being played
by 8 people can have a 9th person observing. Up to 10 people can
connect, which mean you can have up to 6 observers with a 4-player map,
and 2 with an 8-player map.
There are some details to be worked out, but this feature seems to be
stable during testing. See the ticket (link above) for more
information.
## 2018-01-24
* [#6](https://github.com/ZetaGlest/zetaglest-source/issues/6) Players
- [#6](https://github.com/ZetaGlest/zetaglest-source/issues/6) Players
can now enter the multiplayer lobby unconditionally (i.e.
"InternetGamesAllowed" will no longer be used)
## 2018-01-14
* Added Elves faction (https://forum.megaglest.org/index.php?topic=3944.0)
* [#1] Replaced the Egypt graphics with Archmage's remaster: https://github.com/virtushda/EgyptRemaster
- Replaced the Egypt graphics with Archmage's remaster: https://github.com/virtushda/EgyptRemaster
# MegaGlest ChangeLog
@@ -995,15 +872,4 @@ v3.5.2
0.1.6
- Unit models have been redesigned, now they have more polygons and detailed animations.
- Minor bug fixes.
The following earlier versions have been released, but no changelog is available:
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.3
0.0.2
0.0.1
- Minor bug fixes.

View File

@@ -1,5 +1,5 @@
#!/bin/bash
# Use this script to Analyze world synchronization log files between two or
# Use this script to analyze world synchronization log files between two or
# more networked players
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>

View File

@@ -1,3 +0,0 @@
/lib-x86/
/lib-x86_64/
/megaglest-mini-update.sh

View File

@@ -1,120 +0,0 @@
#!/bin/bash
set -e
# Use this script to copy shared (libs) files to specified location
# ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/>
# Copyright (c) 2006 nixCraft under GNU GPL v2.0+
# Last updated on: Apr/06/2010 by Vivek Gite
# ----------------------------------------------------------------------------
# + Modified for megaglest deployment - Softcoder
# + Added ld-linux support
# + Added error checking support
# + Added for loop so that we can process all files on cmd
# ----------------------------------------------------------------------------
# Set libs output directory name
BASE="lib"
file="$@"
sync_support_libs(){
local d="$1" # folder to copy dependencies to
local pFILE="$2" # bin file to scan for dependencies from
local files=""
local _cp="/bin/cp"
#local skip_deps="libm.so libpthread.so libstdc++.so libgcc_s.so libc.so libdl.so libX11.so libpulse libfusion libdirect libnvidia libXext librt libxcb libICE libSM libXtst libwrap libdbus libXau libXdmcp libnsl libFLAC libGL"
local skip_deps=""
local keep_deps="libcurl libgnu libgcrypt libnghttp libidn libpsl libunistring librtmp libssh libnettle libicu liblua libjpeg libpng libvorbis libogg libircclient libminiupnpc libwx_ libGLEW libftgl libfreetype libfribidi libvlc libopenal libSDL2-"
# libwx_ - recommended to keep always just because API/ABI compatibility, huge impact for map editor
# libGLEW - most likely safe to keep embedded everywhere, its version matters with tools
# libopenal - safe to keep but if any version is available locally then should be replaced
# libSDL2 - safe to keep on .deb family only and even there, if any version is available locally then should be replaced
# liblber & libldap_r - aren't safe to keep, very nasty secondary dependencies
# libunistring - is it enough popular to not be necessary there? not sure
# libfribidi - not enough popular to be installed by default on the "every fresh OS"
local scan_via_skiplist=1
if [ -n "$skip_deps" ]; then
scan_via_skiplist=1
echo "scanning for deps TO SKIP for '$pFILE'..."
elif [ -n "$keep_deps" ]; then
scan_via_skiplist=0
echo "scanning for deps TO KEEP for '$pFILE'..."
fi
# get rid of blanks and (0x00007fff0117f000)
files="$(ldd $pFILE | awk '{ print $3 }' | sed -e '/^$/d' -e '/(*)$/d')"
for i in $files
do
dcc="${i%/*}" # get dirname only
# [ ! -d ${d}${dcc} ] && mkdir -p ${d}${dcc}
# ${_cp} -f $i ${d}${dcc}
# ${_cp} -f $i ${d}
# echo ${_cp} -f $i ${d}
skipfile=0
if [ $scan_via_skiplist -eq 1 ]; then
for j in $(echo $skip_deps)
do
if [ `awk "BEGIN {print index(\"$i\", \"$j\")}"` -ne 0 ]; then
# echo Skipping file = [$i]
skipfile=1
break
fi
done
elif [ $scan_via_skiplist -eq 0 ]; then
skipfile=1
for j in $(echo $keep_deps)
do
if [ `awk "BEGIN {print index(\"$i\", \"$j\")}"` -ne 0 ]; then
# echo Skipping file = [$i]
skipfile=0
break
fi
done
fi
if [ "$skipfile" -eq "0" ] && [ ! -e "$d/$(basename "$i")" ]; then
echo Including file = [$i]
${_cp} -f $i ${d}
fi
done
# Works with 32 and 64 bit ld-linux
#sldl="$(ldd $pFILE | grep 'ld-linux' | awk '{ print $1}')"
#sldlsubdir="${sldl%/*}"
# [ ! -f ${d}${sldl} ] && ${_cp} -f ${sldl} ${d}${sldlsubdir}
#if [ ! -f ${d}${sldl} ] ; then
# echo Including file = [${sldl}]
# ${_cp} -f ${sldl} ${d}
#fi
}
usage(){
echo "Error: Wrong syntax. Example: $0 megaglest"
exit 1
}
[ $# -eq 0 ] && usage
if [ ! -d "$BASE" ]; then mkdir -p "$BASE"; fi
# copy all files
for f in $file
do
sync_support_libs "${BASE}" "${f}"
done
# copy vlc's plugins if libvlc was copied
if [ "$(find $BASE -type f -name "libvlc.*")" != "" ]; then
LIBVLC_DIR_CHECK="$( ldd "$1" | grep "libvlc\." | sort -u | awk '{print $3}' | head -1 )"
if [ "$LIBVLC_DIR_CHECK" != "" ]; then
LIBVLC_DIR="$(dirname "$LIBVLC_DIR_CHECK")"
if [ -d "$LIBVLC_DIR/vlc/plugins" ]; then
mkdir -p "$BASE/vlc"
echo "Including plugins directory for VLC from = [$LIBVLC_DIR/vlc]"
cp -f -r "$LIBVLC_DIR/vlc/plugins" "$BASE/vlc/"
fi
fi
fi

View File

@@ -1,20 +0,0 @@
#!/bin/bash
# Use this script to produce a google-breakpad stacktrace from a megaglest dmp file
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2013 Mark Vejvoda under GNU GPL v3.0+
CURRENTDIR="$(dirname $(readlink -f $0))"
SYMBOLS_DIR=${CURRENTDIR}/"linux_symbols"
usage(){
echo "Syntax : $0 yourcrashfile.dmp
echo "Example: $0 ./328eaddc-c1d5-9eee-3ca1e6a4-0ce3f6a6.dmp
exit 1
}
[ $# -eq 0 ] && usage
echo "About to produce stack trace for $1"
echo "Symbols folder: ${SYMBOLS_DIR}"
${CURRENTDIR}/../../google-breakpad/src/processor/minidump_stackwalk $1 ${CURRENTDIR}/${SYMBOLS_DIR}

View File

@@ -1,13 +0,0 @@
#!/bin/bash
# Use this script to produce a google-breakpad symbol file for megaglest
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2013 Mark Vejvoda under GNU GPL v3.0+
CURRENTDIR="$(dirname $(readlink -f $0))"
SYMBOLS_DIR=${CURRENTDIR}/"linux_symbols"
mkdir -p ${SYMBOLS_DIR}
echo "Symbols folder: ${SYMBOLS_DIR}"
python ${CURRENTDIR}/symbolstore.py ${CURRENTDIR}/../../google-breakpad/src/tools/linux/dump_syms/dump_syms ${SYMBOLS_DIR} ${CURRENTDIR}/megaglest

View File

@@ -1,18 +0,0 @@
#! /bin/sh
# Use this script to test performance while running MegaGlest
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2011 Mark Vejvoda under GNU GPL v3.0+
exec 3>&1
export GLIBCPP_FORCE_NEW=1
export GLIBCXX_FORCE_NEW=1
export G_SLICE=always-malloc
exec valgrind --tool=callgrind \
"$@" 2>&1 1>&3 3>&- |
sed 's/^==[0-9]*==/==/' >&2 1>&2 3>&-
echo 'Look for a generated file called callgrind.out.x.'
echo 'You can then use kcachegrind tool to read this file.'
echo 'It will give you a graphical analysis of things with results like which lines cost how much.'

View File

@@ -1,40 +0,0 @@
#!/bin/bash
# Use this script to check MegaGlest Source Code for errors using cppcheck
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2011 Mark Vejvoda under GNU GPL v3.0+
if ! cppcheck_loc="$(type -p "cppcheck")" || [ -z "$cppcheck_loc" ]; then
# install cppcheck
echo "CPPCHECK is not installed, installing now..."
sudo apt install cppcheck
fi
# (Actual) Location of the cppcheck binary
CPPCHECK=$(readlink -f $(which cppcheck))
# cppcheck now depends on this library (see 'cppcheck --help' for the '--library' option)
# If you use the Debian / Ubuntu package set this to: /usr/share/cppcheck/cfg/std.cfg
if [ -e "$(dirname $CPPCHECK)/cfg/std.cfg" ]; then
CPPCHECKLIB=$(dirname $CPPCHECK)/cfg/std.cfg
elif [ -e "/usr/share/cppcheck/cfg/std.cfg" ]; then
CPPCHECKLIB=/usr/share/cppcheck/cfg/std.cfg
fi
# File to write results to
LOGFILE=/tmp/cppcheck.log
$CPPCHECK ../../source/ \
-i ../../source/win32_deps \
-i ../../source/configurator \
-i ../../source/shared_lib/sources/libircclient \
-i ../../source/shared_lib/sources/platform/miniupnpc \
-i ../../source/shared_lib/sources/streflop \
--library=$CPPCHECKLIB \
--enable=all \
--force \
--verbose \
2> $LOGFILE
echo "Results from cppcheck were written to $LOGFILE"

View File

@@ -1,18 +0,0 @@
#!/bin/bash
# Use this script to gather MegaGlest performance stats
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2012 Mark Vejvoda under GNU GPL v3.0+
echo 'Recording performnce stats...'
echo 'cat /proc/sys/kernel/kptr_restrict'
echo '1'
#echo 'echo 0 > /proc/sys/kernel/kptr_restrict'
echo 'sudo sh -c "echo 0 > /proc/sys/kernel/kptr_restrict"'
echo 'cat /proc/sys/kernel/kptr_restrict'
echo '0'
perf record ./megaglest $@
perf report

View File

@@ -1,18 +0,0 @@
#! /bin/sh
# Use this script to track memory use and errors while running MegaGlest
# ----------------------------------------------------------------------------
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
# Copyright (c) 2011 Mark Vejvoda under GNU GPL v3.0+
exec 3>&1
export GLIBCPP_FORCE_NEW=1
export GLIBCXX_FORCE_NEW=1
export G_SLICE=always-malloc
exec valgrind --num-callers=20 \
--leak-check=yes \
--leak-resolution=high \
--show-reachable=yes \
"$@" 2>&1 1>&3 3>&- |
sed 's/^==[0-9]*==/==/' >&2 1>&2 3>&-

View File

@@ -1,354 +0,0 @@
#!/bin/sh
#
# Start a headless game server (and keep it running)
#
# Using this script, a headless game server is started, waiting for players to
# connect (if your firewall configuration permits). Players connect and start a
# game. As soon as the game ends, the server will quit, and this script will
# start up a new server again. This is a stability measure to rule out
# the unlikely case where side effects (such as memory leaks or corruption)
# could drain on system resources.
#
# For this to work, Internet originated traffic must be able to reach the
# server on the following ports:
# TCP port 61357: game protocol port
# TCP port 61358: FTP control port
# TCP ports 61359 to 61366: FTP data ports
#
# Once publishing to the master server succeeded (this can be verified at
# master server's site) you may connect to your headless game server
# using a copy of game you have installed on a Desktop computer. The first
# user connecting to a headless server controls it. If this user disconnects,
# the next user who connects (or had already connected) takes control.
#
# ----------------------------------------------------------------------------
# 2013 Written by Tom Reynolds <tomreyn[at]zetaglest.org>
# 2015 Rewritten by filux <heross(@@)o2.pl>
# Copyright (c) 2013-2017 under GNU GPL v3.0+
# ----------------------------------------------------------------------------
LANG=C
trap "kill -- -$$" HUP INT QUIT TERM EXIT
KERNEL="$(uname -s | tr '[A-Z]' '[a-z]')"
if [ "$KERNEL" = "linux" ] || [ "$(echo "$(readlink -f "$0" >/dev/null 2>&1; echo $?)" | grep '^[0-9]$')" -eq "0" ]; then
GAMEDIR="$(dirname "$(readlink -f "$0")")"
else
GAMEDIR="$(cd "$(dirname "$0")"; pwd)"
fi
HOME_DIR="$HOME"
B_SCRIPT_DIR="$GAMEDIR"
# -------
# useful for mods
BASIC_SCRIPT="start_zetaglest"
FAKE_EXC_BINARY_MAC="ZetaGlest"
EXC_BINARY="zetaglest"
EXC_BINARY_DISTRO="zetaglest"
SHORT_GAME_NAME="zetaglest"
# -------
PORTSTART=62001
NUM_OM_SERVERS=2
NUM_OA_SERVERS=1
SERVER_HARDW_MAX_LOAD_PERC="100"
# Log file location (beware, this can grow large)
# LOG_SERVER=/dev/null
if [ "$(which curl 2>/dev/null)" = "" ]; then
echo "WARNING: Downloading tool 'curl' DOES NOT EXIST on this system, please install it." >&2
fi
if [ "$KERNEL" = "darwin" ]; then
if [ -e "$GAMEDIR/../../MacOS/$FAKE_EXC_BINARY_MAC" ]; then
BASIC_SCRIPT="$FAKE_EXC_BINARY_MAC"; B_SCRIPT_DIR="$(cd "${GAMEDIR}/../../MacOS/"; pwd)"
elif [ -e "$GAMEDIR/$FAKE_EXC_BINARY_MAC.sh" ]; then
BASIC_SCRIPT="$FAKE_EXC_BINARY_MAC.sh"
fi
fi
if [ "$(which lscpu 2>/dev/null)" != "" ]; then NUMCORES="$(lscpu -p | grep -cv '^#')"
elif [ "$(which sysctl 2>/dev/null)" != "" ]; then NUMCORES="$(sysctl -n hw.ncpu)"; fi
if [ "$NUMCORES" = "" ]; then NUMCORES=1; fi
echo "Notice: Detected processor with $NUMCORES cores." >&2
case $NUMCORES in
1) MAX_LOAD_MULT="0.65";; 2) MAX_LOAD_MULT="0.75";; 3) MAX_LOAD_MULT="0.82";;
4) MAX_LOAD_MULT="0.88";; 5) MAX_LOAD_MULT="0.92";; *) MAX_LOAD_MULT="0.95";;
esac
if [ "$SERVER_HARDW_MAX_LOAD_PERC" -gt "100" ]; then SERVER_HARDW_MAX_LOAD_PERC=100; fi
MAX_LOAD="$(echo "$NUMCORES $MAX_LOAD_MULT $SERVER_HARDW_MAX_LOAD_PERC" | awk '{print $1*$2*($3/100)}')"
if [ "$1" != "" ] && [ "$(echo "$1" | grep '^[0-9]\+$')" != "" ]; then SERVERCOUNT="$1"
else SERVERCOUNT=0; fi
if [ "$2" != "" ] && [ "$(echo "$2" | grep '[0-9.:]\+' | grep -v '[A-Za-z]')" != "" ]; then
SERVER_GREP_IP="$(echo "$2" | sed 's/\./\\./g')"; else SERVER_GREP_IP=""; fi
if [ "$3" != "" ] && [ "$(echo "$3" | grep '^[0-9]\+$')" != "" ]; then PORTSTART="$3"; fi
if [ "$4" != "" ]; then SERVERTITLE="$4"; fi
PORT="$(($PORTSTART + (($SERVERCOUNT - 1) * 11)))"; STATUSPORT="$(($PORT - 1))"
PORT_FD="$(echo "$PORT" | cut -c1-2)"; PORT_NLD="$((${#PORT} - ${#PORT_FD}))"
PORT_FDX="$PORT_FD"; c=1; while [ "$c" -le "$PORT_NLD" ]; do PORT_FDX="$(echo "${PORT_FDX}X")"; c="$(($c + 1))"; done
IDLE_TIME_MOD=12
if [ "$NUM_OA_SERVERS" -ge "$NUM_OM_SERVERS" ]; then NUM_OS_MOD="$NUM_OA_SERVERS"
else NUM_OS_MOD="$NUM_OM_SERVERS"; fi
if [ "$NUM_OS_MOD" -lt "3" ]; then NUM_OS_SMOD="$(($NUM_OS_MOD + 1))"
else NUM_OS_SMOD="$(($NUM_OS_MOD + ($NUM_OS_MOD / 3)))"; fi
if [ "$SERVERCOUNT" -ge "1" ]; then
IDLE_TIME_MOD="$((18 + ($NUM_OS_MOD * 2) - ($SERVERCOUNT * 2)))"
if [ "$IDLE_TIME_MOD" -lt "2" ]; then IDLE_TIME_MOD=2
elif [ "$IDLE_TIME_MOD" -gt "24" ]; then IDLE_TIME_MOD=24; fi
fi
MAX_IDLE_TIME="$(($IDLE_TIME_MOD * 3600))"
SERVER_SCRIPT="$(basename "$0")"
if [ -f "$GAMEDIR/glest.ini" ]; then
GLEST_INI="$(cat "$GAMEDIR/glest.ini" | sed -e 's:\$HOME:'"$HOME_DIR"':g')"
LOG_DIR="$(echo "$GLEST_INI" | grep '^LogPath=' | awk -F '=' '{print $2}')"
# e.g. on macos are problems with more advanced using awk ^
if [ "$LOG_DIR" != "" ] && [ "$(echo "$LOG_DIR" | grep '/$')" ]; then LOG_DIR="${LOG_DIR%?}"; fi
MASTER_SERVER="$(echo "$GLEST_INI" | grep '^Masterserver=' | awk -F '=' '{print $2}')"
if [ "$(echo "$MASTER_SERVER" | grep '/$')" ]; then CLEAR_M_SERVER="${MASTER_SERVER}showServersForGlest.php"
else CLEAR_M_SERVER="$MASTER_SERVER/showServersForGlest.php"; fi
if [ "$SERVERCOUNT" -gt "0" ]; then
USER_DATA_DIR="$(echo "$GLEST_INI" | grep '^UserData_Root=' | awk -F '=' '{print $2}')"
if [ "$USER_DATA_DIR" != "" ] && [ "$(echo "$USER_DATA_DIR" | grep '/$')" ]; then
USER_DATA_DIR="${USER_DATA_DIR%?}"
fi
if [ "$SERVERTITLE" = "" ] && [ -f "$USER_DATA_DIR/glestuser.ini" ]; then
GLEST_USER_INI="$(cat "$USER_DATA_DIR/glestuser.ini")"
SERVERNAME="$(echo "$GLEST_USER_INI" | grep '^NetPlayerName=' | awk -F '=' '{print $2}')"
if [ "$SERVERNAME" = "" ]; then SERVERNAME="Unknown"; fi
fi
fi
elif [ "$SERVER_GREP_IP" != "" ]; then
echo "WARNING: file 'glest.ini' not found, maybe '$SERVER_SCRIPT' script is placed in the wrong location." >&2
fi
EXC_BINARY_FPID="$EXC_BINARY"; EXC_BINARY_DISTRO_W="$(which "$EXC_BINARY_DISTRO" 2>/dev/null)"
if [ -e "$B_SCRIPT_DIR/$BASIC_SCRIPT" ]; then SERVER_EXEC="$B_SCRIPT_DIR/$BASIC_SCRIPT"
elif [ -e "$GAMEDIR/$EXC_BINARY" ]; then SERVER_EXEC="$GAMEDIR/$EXC_BINARY"
else SERVER_EXEC="$EXC_BINARY_DISTRO_W"; EXC_BINARY_FPID="$EXC_BINARY_DISTRO"; fi
if [ "$SERVERCOUNT" -eq "0" ]; then
#if [ "$SERVER_EXEC" != "$EXC_BINARY_DISTRO_W" ]; then ulimit -c unlimited; fi
USED_PORTS=""; LOG_FILE="server.log"
RestartMarker="${SHORT_GAME_NAME}-server-restart.log"
else
USED_PORTS="--use-ports=$PORT,$PORT,$STATUSPORT "
RestartMarker="${SHORT_GAME_NAME}-server-restart-${PORT}.log"
WaitMarker="${SHORT_GAME_NAME}-server-wait-${PORT_FDX}.log"
LOG_FILE="server_${SERVERCOUNT}.log"
SERVERNAME="$SERVERNAME-${SERVERCOUNT}"
fi
SingleSMarker=".${SHORT_GAME_NAME}-server-single.log"
if [ "$LOG_DIR" != "" ]; then
if [ ! -f "$LOG_DIR/$SingleSMarker" ] && [ "$SERVERCOUNT" -le "1" ]; then
echo "#" > "$LOG_DIR/$SingleSMarker"; sleep 1s
elif [ -f "$LOG_DIR/$SingleSMarker" ] && [ "$SERVERCOUNT" -gt "1" ]; then
sleep 1s; rm -f "$LOG_DIR/$SingleSMarker"
fi
fi
if [ "$SERVERTITLE" = "" ] && [ "$SERVERNAME" != "" ]; then SERVERTITLE="$SERVERNAME"; fi
if [ "$SERVERCOUNT" -gt "0" ]; then
echo "Info: Server '$SERVERTITLE' nr. $SERVERCOUNT ($2 ; $PORT)." >&2
sleep "$(($SERVERCOUNT * 5))"s
fi
SER_PARAMETERS="--headless-server-mode=vps,exit"
#^ parameters without spaces and numbers inside
SER_GREP_PARAMETERS="$(echo "${USED_PORTS}$SER_PARAMETERS" | sed 's/--/\\--/g')"
if [ "$LOG_SERVER" != "" ]; then :
elif [ "$LOG_DIR" != "" ]; then
mkdir -p "$LOG_DIR"
LOG_SERVER="$LOG_DIR/$LOG_FILE"
else
LOG_SERVER=/dev/null
fi
cd "$GAMEDIR"
AVG_LOAD="unknown"; SER_SITUATION="unknown"; CHECK_AVG_LOAD_M=0
if [ -e "/proc/loadavg" ]; then CHECK_AVG_LOAD_M=1
elif [ "$(which sysctl 2>/dev/null)" != "" ]; then CHECK_AVG_LOAD_M=2; fi
while true; do
if [ "$LOG_SERVER" != "/dev/null" ] && [ -f "$LOG_SERVER" ] && [ "$(wc -c < "$LOG_SERVER")" -gt "250000" ]; then
mv -f "$LOG_SERVER" "$LOG_SERVER.1"; fi
if [ -e "core" ]; then mv -f "core" "core.1"; fi
date >> "$LOG_SERVER"
while true; do
if [ "$CHECK_AVG_LOAD_M" -eq "1" ]; then
AVG_LOAD="$(awk '{print $2}' /proc/loadavg)"
elif [ "$CHECK_AVG_LOAD_M" -eq "2" ]; then
AVG_LOAD="$(sysctl -n vm.loadavg | awk -F '{' '{print $2}' | awk '{print $2}')"
fi
if [ "$AVG_LOAD" != "unknown" ]; then
SER_SITUATION="$(echo "$AVG_LOAD $MAX_LOAD" | awk '{if ($1 > $2) print "highload"}')"
fi
if [ "$SER_SITUATION" = "highload" ]; then
if [ "$OLD_SER_SITUATION_STATUS" = "" ]; then
echo "WARNING: Detected high load on the server." >&2
OLD_SER_SITUATION_STATUS="yes"
fi
sleep 2.5m; sleep "$((RANDOM % 30))"s
else
OLD_SER_SITUATION_STATUS=""; NUM_O_FREE_SER=""
if [ "$LOG_DIR" != "" ] && [ ! -f "$LOG_DIR/$SingleSMarker" ]; then
if [ "$MASTER_SERVER" != "" ] && [ "$SERVER_GREP_IP" != "" ]; then
if [ "$WaitMarker" != "" ] && [ ! -f "$LOG_DIR/$WaitMarker" ]; then
echo "#" > "$LOG_DIR/$WaitMarker"; sleep 1s
fi
if [ -f "$LOG_DIR/$WaitMarker" ]; then
InWaitMarker="$(cat "$LOG_DIR/$WaitMarker" | tail -1 | grep '^[0-9]*$')"
if [ "$InWaitMarker" = "" ] || \
[ "$(find "$LOG_DIR/" -maxdepth 1 -name "$WaitMarker" -mmin +30)" ]; then
InWaitMarker=100; NUM_O_FREE_SER=103
fi
if [ "$SERVERCOUNT" -lt "$InWaitMarker" ]; then
echo "$SERVERCOUNT" >> "$LOG_DIR/$WaitMarker"; InWaitMarker="$SERVERCOUNT"
fi
fi
fi
if [ -f "$LOG_DIR/$WaitMarker" ] && [ "$NUM_O_FREE_SER" != "103" ] && \
[ "$(($(date +%s)-$(date +%s -r "$LOG_DIR/$WaitMarker")))" -le "30" ]; then
NUM_O_FREE_SER=102
elif [ "$MASTER_SERVER" != "" ] && [ "$SERVER_GREP_IP" != "" ]; then
if [ "$SERVERCOUNT" -ne "$InWaitMarker" ]; then
NUM_O_FREE_SER=101
elif [ "$OLD_InWaitMarker" = "" ] || [ "$InWaitMarker" -ne "$OLD_InWaitMarker" ]; then
NUM_O_FREE_SER=100; OLD_InWaitMarker="$InWaitMarker"
fi
if [ "$NUM_O_FREE_SER" = "" ]; then
FIND_ALL_SER="$(curl -s -L "$CLEAR_M_SERVER")"; M_SERVER_STATUS="$?"
FIND_OUR_SER="$(echo "$FIND_ALL_SER" | grep '^\([^|]*|\)\{4\}'"$SERVER_GREP_IP"'|' \
| grep '^\([^|]*|\)\{11\}'"$PORT_FD"'[0-9]\{'"$PORT_NLD"'\}|')"
NUM_O_O_SER="$(echo "$FIND_OUR_SER" | wc -l)"
if [ "$NUM_O_O_SER" -eq "0" ]; then M_SERVER_STATUS=111; fi
if [ "$NUM_O_O_SER" != "" ] && [ "$NUM_O_O_SER" -lt "$NUM_OM_SERVERS" ]; then :
elif [ "$SERVERCOUNT" -le "$NUM_OS_SMOD" ]; then
NUM_O_FREE_SER="$(echo "$FIND_OUR_SER" | grep '^\([^|]*|\)\{10\}0|' -c)"
else
NUM_O_FREE_SER="$(echo "$FIND_OUR_SER" | grep '^\([^|]*|\)\{13\}0|' -c)"
fi
fi
fi
fi
if [ "$NUM_O_FREE_SER" != "" ] && [ "$NUM_O_FREE_SER" -ge "$NUM_OA_SERVERS" ]; then
if [ "$OLD_NUM_OFS_STATUS" = "" ] && [ "$NUM_O_FREE_SER" -ne "100" ]; then
echo "Notice: Waiting for situation when server may be really needed." >&2
OLD_NUM_OFS_STATUS="yes"
fi
else
if [ "$M_SERVER_STATUS" = "" ] || [ "$M_SERVER_STATUS" -eq "0" ] || [ "$SERVERCOUNT" -le "1" ]; then
OLD_NUM_OFS_STATUS=""
if [ -f "$LOG_DIR/$WaitMarker" ]; then echo "#" > "$LOG_DIR/$WaitMarker"; fi
break
else
echo "WARNING: Detected some problems with connection to master server." >&2
M_SERVER_STATUS=""
fi
fi
sleep 32s
fi
done
if [ "$SERVERCOUNT" -eq "1" ] && [ ! -e "$GAMEDIR/${SHORT_GAME_NAME}-mini-update.sh" ] && \
[ -e "$GAMEDIR/../${SHORT_GAME_NAME}-dev_version-update.sh" ]; then
if [ ! -f "$GAMEDIR/${SHORT_GAME_NAME}-dev_version-update-done.log" ]; then
echo "... dev_version update:" >&2
"$GAMEDIR/../${SHORT_GAME_NAME}-dev_version-update.sh" "$GAMEDIR"; sleep 1s
echo "#" > "$GAMEDIR/${SHORT_GAME_NAME}-dev_version-update-done.log"; sleep 1s
#"$GAMEDIR/$SERVER_SCRIPT" "$@" &
#break
else
rm -f "$GAMEDIR/${SHORT_GAME_NAME}-dev_version-update-done.log"
fi
fi
echo 'Starting server...' | tee -a "$LOG_SERVER"
if [ "$MASTER_SERVER" != "" ] && [ "$SERVER_GREP_IP" != "" ]; then
( check_nr=0; force_restart=0; loop_start="yes"; BeginTime="$(date +"%s")"; sleep 4m
while true; do
SER_PID="$(ps -ef | grep "[ \t/]$EXC_BINARY_FPID $SER_GREP_PARAMETERS" | grep -v 'grep' | awk '{print $2}')"
if [ "$loop_start" = "yes" ]; then SER_PID_S="$SER_PID"; loop_start="no"; fi
CheckTime="$(date +"%s")"; DiffTime="$(($CheckTime-$BeginTime))"
if [ "$SER_PID" != "" ] && [ "$SER_PID" = "$SER_PID_S" ]; then
FIND_SER="$(curl -s -L "$CLEAR_M_SERVER" | grep '^\([^|]*|\)\{4\}'"$SERVER_GREP_IP"'|' \
| grep '^\([^|]*|\)\{11\}'"$PORT"'|')"
if [ "$FIND_SER" = "" ]; then
check_nr="$(($check_nr + 1))"
if [ "$OLD_FIND_SER_STATUS" = "" ]; then
echo "WARNING: The master server doesn't see this server." >&2
OLD_FIND_SER_STATUS="yes"
elif [ "$check_nr" -eq "120" ]; then
echo "ERROR: The master server doesn't see this server for over 4 hours." >&2; force_restart=1
fi
else
OLD_FIND_SER_STATUS=""
SER_STATUS="$(echo "$FIND_SER" | awk -F '|' '{print $14}')"
if [ "$SER_STATUS" = "" ] || [ "$(echo "$SER_STATUS" | grep '^[0-9]\+$')" = "" ]; then
echo "ERROR: Server status cannot be determined." >&2
fi
fi
if [ "$SER_STATUS" != "2" ] && [ "$DiffTime" -gt "$MAX_IDLE_TIME" ]; then
echo "Notice: The server is working continuously for over $IDLE_TIME_MOD hour(s)." >&2; force_restart=1
elif [ "$SER_STATUS" != "" ] && [ "$SER_STATUS" -eq "2" ]; then
if [ "$OLD_PROG_STATUS" = "" ]; then
echo "Status: Game in progress..." >&2
OLD_PROG_STATUS="yes"; BeginTime2="$(date +"%s")"
fi
DiffTime2="$(($CheckTime-$BeginTime2))"
if [ "$DiffTime2" -gt "14400" ]; then
echo "WARNING: The game is in progress for over 4 hours." >&2; force_restart=1
else
sleep 8m
fi
elif [ "$SER_STATUS" != "" ] && [ "$SER_STATUS" -eq "1" ]; then
if [ "$OLD_READY_STATUS" = "" ]; then
OLD_READY_STATUS="yes"; BeginTime3="$(date +"%s")"
fi
DiffTime3="$(($CheckTime-$BeginTime3))"
if [ "$DiffTime3" -gt "3600" ]; then
echo "WARNING: The game seems to waiting for start for over an hour." >&2; force_restart=1
fi
else
OLD_READY_STATUS=""
fi
if [ "$SER_STATUS" != "" ] && [ "$SER_STATUS" -ne "2" ]; then OLD_PROG_STATUS=""; fi
if [ "$force_restart" -eq "1" ]; then
if [ "$check_nr" -lt "120" ]; then check_nr=120; fi
if [ "$LOG_DIR" != "" ]; then echo "#" > "$LOG_DIR/$RestartMarker"; sleep 2s; fi
if [ "$check_nr" -ge "123" ]; then kill -9 "$SER_PID"
else kill "$SER_PID"; fi
elif [ "$FIND_SER" != "" ]; then
check_nr=0
fi
sleep 2m
else
break
fi
done
) &
fi
if [ "$SERVERTITLE" != "" ]; then
"$SERVER_EXEC" ${USED_PORTS}"$SER_PARAMETERS" --server-title="Headless (${SERVERTITLE})" >> "$LOG_SERVER" 2>&1
else
"$SERVER_EXEC" ${USED_PORTS}"$SER_PARAMETERS" >> "$LOG_SERVER" 2>&1
fi
if [ "$?" -ne "0" ]; then
if [ ! -f "$LOG_DIR/$RestartMarker" ]; then
echo 'ERROR: Server has quit unexpectedly.' >> "$LOG_SERVER"
echo 'ERROR: Server has quit unexpectedly.' >&2
if [ "$SERVERCOUNT" -eq "0" ]; then
echo ' Please inspect '"$LOG_SERVER"'.' >&2
exit 1
fi
sleep 5s
if [ "$SERVERCOUNT" -eq "1" ] && [ -e "$GAMEDIR/${SHORT_GAME_NAME}-mini-update.sh" ] && \
[ "$SERVER_GREP_IP" != "" ] && [ "$MINI_UPDATE_USED" = "" ]; then
echo "... attempt to perform mini update, which may solve tiny problems:" >&2
"$GAMEDIR/${SHORT_GAME_NAME}-mini-update.sh"; sleep 1s
MINI_UPDATE_USED="yes"
fi
else
echo 'Notice: Server was restarted by script.' >> "$LOG_SERVER"
if [ "$LOG_DIR" != "" ]; then rm -f "$LOG_DIR/$RestartMarker"; fi
fi
sleep 2s
else
echo 'Server has quit.' | tee -a "$LOG_SERVER"
fi
done