-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathopenarena-q3e
58 lines (53 loc) · 2.42 KB
/
openarena-q3e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# Set the necessary variables
OA_DIR="${XDG_DATA_HOME}"
OA_CVARS="+set fs_basegame baseoa +set fs_game oax +set protocol 71 +set fs_homepath ${OA_DIR} +set con_title OpenArena +set cl_title OpenArena"
DISABLED_CVARS="+set com_protocol 72 +set cl_voip 1"
CONFIG_FILE="${XDG_CONFIG_HOME}/cfg"
CFG_COMMENT="#----# You can change engine options by modifying these variables, or adding the variable 'CVARS', also, you can change the game engine using the variable Q3ENGINE."
RED='[1;31m' # Sets color to red
NC='[0m' # No Color
# Determine the architecture of the system
arch=$(uname -m)
case "$arch" in
x86_64)
q3e_arch="x64"
;;
aarch64)
q3e_arch="aarch64"
;;
esac
# Check if the configuration file exists
if [ ! -f "$CONFIG_FILE" ]; then
# Create the configuration file with the comment
printf "%s\n" "$CFG_COMMENT" > "$CONFIG_FILE"
printf "export OA_DIR=\"%s\"\n" "$OA_DIR" >> "$CONFIG_FILE"
printf "export OA_CVARS=\"%s\"\n" "$OA_CVARS" >> "$CONFIG_FILE"
printf "export DISABLED_CVARS=\"%s\"\n" "$DISABLED_CVARS" >> "$CONFIG_FILE"
printf "${RED}It seems this is your first run... There's a config file you can check out $CONFIG_FILE ${NC}\n"
fi
# Source the configuration file and dispose of current variables
unset OA_DIR OA_CVARS DISABLED_CVARS
. "$CONFIG_FILE"
# Check if the Q3ENGINE variable is set
if [ -n "$Q3ENGINE" ]; then
# Check if the CVARS variable is set
if [ -n "$CVARS" ]; then
# Execute the Q3ENGINE with the provided CVARS and arguments
exec "$Q3ENGINE" $CVARS "$@"
else
printf "${RED}Change the CVARS variable before starting in order to change the basegame or other game variables. To add CVARS to OA, simply add them as arguments.${NC}\n"
# Execute the Q3ENGINE with the default OA_CVARS and arguments
exec "$Q3ENGINE" $OA_CVARS "$@"
fi
else
# Check if the CVARS variable is set
if [ -n "$CVARS" ]; then
# Execute the quake3e binary with the provided CVARS and arguments
exec /app/share/openarena/quake3e.$q3e_arch $CVARS "$@"
else
# Execute the quake3e binary with the default OA_CVARS and arguments
exec /app/share/openarena/quake3e.$q3e_arch $OA_CVARS "$@"
printf "${RED}Change the CVARS variable before starting in order to change the basegame. To add CVARS to OA, simply add them as arguments. You can also use the config file to do so ($CONFIG_FILE)${NC}\n"
fi
fi