]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
Merge branch 'bones_was_here/xoncompat' into 'master'
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 28 May 2023 05:07:03 +0000 (05:07 +0000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 28 May 2023 05:07:03 +0000 (05:07 +0000)
Package xoncompat repo containing assets from removed maps

See merge request xonotic/xonotic!102

misc/tools/fov-calc.py [new file with mode: 0755]
xonotic-linux-sdl.sh

diff --git a/misc/tools/fov-calc.py b/misc/tools/fov-calc.py
new file mode 100755 (executable)
index 0000000..84d3bd5
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+
+import math
+import argparse
+
+
+def calculate_fov(fov, horizontal, vertical, viewzoom):
+    viewzoom_multiplier = 1 / viewzoom
+    frustumy = math.tan(fov * math.pi / 360) * 0.75 * viewzoom_multiplier
+    frustumx = frustumy * horizontal / vertical
+
+    fovx = math.atan2(frustumx, 1) / math.pi * 360
+    fovy = math.atan2(frustumy, 1) / math.pi * 360
+
+    print(fov, "degrees of hfov with 4:3 resolution (unstretched without black bars) actually gives:")
+    print("Horizontal FOV =", fovx)
+    print("Vertical   FOV =", fovy)
+
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description='Process in-game fov cvars to horizontal and vertical degrees.')
+    parser.add_argument('fov', type=float,
+                        help="in-game fov cvar, degrees of hfov with 4:3 resolution, required field")
+    parser.add_argument('horizontalAspectRatio', type=float, default=16, nargs='?',
+                        help="Horizontal num of the aspect ratio, for 16:9 that is 16, default: 16")
+    parser.add_argument('verticalAspectRatio', type=float, default=9, nargs='?',
+                        help="Vertical num of the aspect ratio, for 16:9 that is 9, default: 9")
+    parser.add_argument('viewzoom', type=float, default=1, nargs='?',
+                        help="Zoom amount, default: 1 / no zoom")
+    args = parser.parse_args()
+
+    if (args.fov < 1 or args.fov > 170):
+        print("WARNING: Xonotic's fov is currently restricted between 1 and 170, calculations might be broken with this number.")
+    if (args.viewzoom < 1 or args.viewzoom > 30):
+        print("WARNING: Xonotic's zoom is currently restricted between 1 and 30, calculations might be broken with this number.")
+
+    calculate_fov(args.fov, args.horizontalAspectRatio, args.verticalAspectRatio, args.viewzoom)
+
index f96c83f9d0af0ed70632c8e1c517f1a0875c4b13..bec83477f0dc65f5bd66a3ca6e76d38b59645b85 100755 (executable)
@@ -1,26 +1,26 @@
 #!/bin/sh
 
-path=`dirname "${0}"`
-link=`readlink -f "${0}"`
+path=$(dirname "${0}")
+link=$(readlink -f "${0}")
 
-[ -n "${link}" ] && path=`dirname "${link}"`
-cd "${path}"
+[ -n "${link}" ] && path=$(dirname "${link}")
+cd "${path}" || exit 1
 
 case "${0##*/}" in
-  *dedicated*) mode="dedicated" ;;
-  *glx*)       mode="glx" ;;
-  *)           mode="sdl" ;;
+  *dedicated*)  mode="dedicated" ;;
+  *glx*)        mode="glx" ;;
+  *)            mode="sdl" ;;
 esac
 
-case "$(uname -m)" in
-  i?86)        arch="linux32" ;;  # Not supported anymore but you can build your own.
-  *)   arch="linux64" ;;
+case $(uname):$(uname -m) in
+  Linux:x86_64)  arch="linux64" ;;
+  *)             arch="local"   ;;  # Not pre-built but you can build your own
 esac
 
 # prefer locally built binary if available (see: Makefile)
 xonotic="xonotic-local-${mode}"
 [ -x "$xonotic" ] || xonotic="xonotic-${arch}-${mode}"
-echo "Executing: $xonotic ${@}"
+echo "Executing: $xonotic ${*}"
 
 set -- ./${xonotic} "${@}"
 
@@ -122,4 +122,14 @@ case "$xserver" in
                ;;
 esac
 
-exec "$@"
+if which "$1" > /dev/null
+then
+       exec "$@"
+else
+       echo "Could not find $1 to exec"
+       if [ "$arch" = "local" ]
+       then
+               printf "%b\n%b\n" "Xonotic does not currently provide pre-built $(uname):$(uname -m) builds, please compile one using make" \
+                       "More info is available at \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m"
+       fi
+fi