Advertisement
Guest User

Untitled

a guest
Apr 9th, 2017
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.88 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # ====================================================================
  4. # Launch script for Total War Warhammer GoldMaster
  5. # Mon Nov 21 18:25:20 UTC 2016
  6.  
  7. # If you have useful edits made for unsupported distros then please
  8. # let us know at <linuxscriptsuggestions@feralinteractive.com>
  9.  
  10. # Variables
  11. FERAL_GAME_NAME="TotalWarhammer"
  12. FERAL_GAME_NAME_FULL="Total War Warhammer"
  13. FERAL_GAME_STEAMID="364360"
  14. FERAL_LIB_PATH="lib/x86_64"
  15.  
  16. # 'Magic' to get the game root
  17. GAMEROOT="$(cd "${0%/*}" && echo "$PWD")"
  18.  
  19. # Check for arguments
  20. # Note: some of these can be set at a system level to override for
  21. # all Feral games
  22. while [ $# -gt 0 ]; do
  23. arg=$1
  24. case ${arg} in
  25. --fresh-prefs) FERAL_FRESH_PREFERENCES=1 && shift ;;
  26. --glc-capture) FERAL_GLC_CAPTURE=1 && shift ;;
  27. --system-asound) FERAL_SYSTEM_ASOUND=1 && shift ;;
  28. --version) FERAL_GET_VERSION=1 && shift ;;
  29. *) break ;;
  30. esac
  31. done
  32.  
  33. # ====================================================================
  34. # Options
  35.  
  36. # Automatically backup old preferences and start fresh on launch
  37. if [ "${FERAL_FRESH_PREFERENCES}" = 1 ]; then
  38. mv "$HOME/.local/share/feral-interactive/${FERAL_GAME_NAME_FULL}" "$HOME/.local/share/feral-interactive/${FERAL_GAME_NAME_FULL}-$(date +%Y%m%d%H%M%S).bak"
  39. fi
  40.  
  41. # Run with glc as the debugger for screen capture
  42. if [ "${FERAL_GLC_CAPTURE}" = 1 ]; then
  43. GLCFILE="${FERAL_GAME_NAME}-$(date +%Y%m%d%H%M%S)"
  44. mkdir -p /tmp/ScreenCaptures && GAME_LAUNCH_PREFIX="glc-capture -o /tmp/ScreenCaptures/${GLCFILE}.glc"
  45. fi
  46.  
  47. # Show a version panel on start
  48. if [ "${FERAL_GET_VERSION}" = 1 ]; then
  49. unset LD_PRELOAD
  50. unset LD_LIBRARY_PATH
  51. if [ -x /usr/bin/zenity ]; then
  52. /usr/bin/zenity --text-info --title "${FERAL_GAME_NAME_FULL} - Version Information" --filename "${GAMEROOT}/share/FeralInfo.json"
  53. else
  54. xterm -T "${FERAL_GAME_NAME_FULL} - Version Information" -e "cat '${GAMEROOT}/share/FeralInfo.json'; echo -n 'Press ENTER to continue: '; read input"
  55. fi
  56. exit
  57. fi
  58.  
  59. # ====================================================================
  60. # Our games are compiled targeting the steam runtime and are not
  61. # expected to work perfectly when run outside of it
  62. # However on some distributions (Arch Linux/openSUSE etc.) users have
  63. # had better luck using their own libs
  64. # Comment these lines out if testing that
  65. #if [ -z "${SteamAppId}" ]; then
  66. # echo "WARNING: ${FERAL_GAME_NAME_FULL} not launched from steam"
  67. # echo " This is likely incorrect"
  68. # echo " Launching steam in 3 seconds with steam://rungameid/${FERAL_GAME_STEAMID}"
  69. # sleep 3
  70. # steam "steam://rungameid/${FERAL_GAME_STEAMID}"
  71. # exit
  72. #fi
  73.  
  74. # ====================================================================
  75. # Set the steam appid if not set
  76. if [ "${SteamAppId}" != "${FERAL_GAME_STEAMID}" ]; then
  77. SteamAppId="${FERAL_GAME_STEAMID}"
  78. export SteamAppId
  79. fi
  80.  
  81. # ====================================================================
  82. # Enviroment Modifiers
  83.  
  84. # Store the current LD_PRELOAD
  85. SYSTEM_LD_PRELOAD="${LD_PRELOAD}"
  86. LD_PRELOAD_ADDITIONS=
  87.  
  88. # Unset LD_PRELOAD temporarily
  89. # This avoids a chunk of confusing 32/64 errors from the steam overlay
  90. # It also allows us to call the system openssl and curl here
  91. # If your distribution needed an LD_PRELOAD addition then it should be
  92. # fine to comment this out
  93. unset LD_PRELOAD
  94.  
  95. # LC_ALL has caused users many issues in the past and generally is just
  96. # used for debugging
  97. # Uncomment this line if LC_ALL was needed (sometimes on openSUSE)
  98. unset LC_ALL
  99.  
  100. # Try and set up SSL paths for all distros, due to steam runtime bug #52
  101. # The value is used by our version of libcurl
  102. # Users on unsupported distros might want to check if this is correct
  103. HAS_CURL="$(command -v curl-config)"
  104. if [ -n "${HAS_CURL}" ]; then
  105. SSL_CERT_FILE="$(curl-config --ca)"
  106. export SSL_CERT_FILE
  107. else
  108. # Otherwise try with guess work
  109. if [ -e /etc/ssl/certs/ca-certificates.crt ]; then
  110. SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
  111. export SSL_CERT_FILE
  112. elif [ -e /etc/pki/tls/certs/ca-bundle.crt ]; then
  113. SSL_CERT_FILE="/etc/pki/tls/certs/ca-bundle.crt"
  114. export SSL_CERT_FILE
  115. elif [ -e /var/lib/ca-certificates/ca-bundle.pem ]; then
  116. SSL_CERT_FILE="/var/lib/ca-certificates/ca-bundle.pem"
  117. export SSL_CERT_FILE
  118. fi
  119. fi
  120. HAS_OPENSSL="$(command -v openssl)"
  121. if [ -n "${HAS_OPENSSL}" ]; then
  122. SSL_CERT_DIR="$(openssl version -d | sed -E 's/.*\"(.*)\"/\1/')/certs"
  123. export SSL_CERT_DIR
  124. fi
  125.  
  126. # AMD fglrx drivers run faster with TCMalloc
  127. HAS_CATALYST="$(grep fglrx /proc/modules)"
  128. if [ -n "${HAS_CATALYST}" ]; then
  129. LD_PRELOAD_ADDITIONS="../${FERAL_LIB_PATH}/libtcmalloc_minimal.so:${LD_PRELOAD_ADDITIONS}"
  130. fi
  131.  
  132. # Brute force fix for some small thread sizes in external libraries
  133. if [ -e "${GAMEROOT}/${FERAL_LIB_PATH}/libminimum_thread_stack_size_wrapper.so" ]; then
  134. LD_PRELOAD_ADDITIONS="../${FERAL_LIB_PATH}/libminimum_thread_stack_size_wrapper.so:${LD_PRELOAD_ADDITIONS}"
  135. fi
  136.  
  137. # Use the system asound if requested
  138. # This can help with sound issues on some distros including Arch Linux
  139. if [ "${FERAL_SYSTEM_ASOUND}" = 1 ]; then
  140. LIBASOUND_DYLIB="libasound.so.2"
  141. if [ -e "/usr/lib/x86_64-linux-gnu/${LIBASOUND_DYLIB}" ]; then
  142. LIBASOUND_LIBDIR="/usr/lib/x86_64-linux-gnu"
  143. elif [ -e "/usr/lib64/${LIBASOUND_DYLIB}" ]; then
  144. LIBASOUND_LIBDIR="/usr/lib64"
  145. elif [ -e "/usr/lib/${LIBASOUND_DYLIB}" ]; then
  146. LIBASOUND_LIBDIR="/usr/lib"
  147. fi
  148. LD_PRELOAD_ADDITIONS="${LIBASOUND_LIBDIR}/${LIBASOUND_DYLIB}:${LD_PRELOAD_ADDITIONS}"
  149. fi
  150.  
  151. # Use the system xcb
  152. # This prevents hangs when using Mesa drivers, steam runtime bug #57
  153. LIBXCB_DYLIB="libxcb.so.1"
  154. if [ -e "/usr/lib/x86_64-linux-gnu/${LIBXCB_DYLIB}" ]; then
  155. LIBXCB_LIBDIR="/usr/lib/x86_64-linux-gnu"
  156. elif [ -e "/usr/lib64/${LIBXCB_DYLIB}" ]; then
  157. LIBXCB_LIBDIR="/usr/lib64"
  158. elif [ -e "/usr/lib/${LIBXCB_DYLIB}" ]; then
  159. LIBXCB_LIBDIR="/usr/lib"
  160. fi
  161. LD_PRELOAD_ADDITIONS="${LIBXCB_LIBDIR}/${LIBXCB_DYLIB}:${LD_PRELOAD_ADDITIONS}"
  162.  
  163. # Add our additionals and the old preload back
  164. LD_PRELOAD="${LD_PRELOAD_ADDITIONS}:${SYSTEM_LD_PRELOAD}"
  165. export LD_PRELOAD
  166.  
  167. # ====================================================================
  168. # Try and detect some common problems and show useful messages
  169. # First check the dynamic linker
  170. GAME_LDD_LOGFILE=/tmp/${FERAL_GAME_NAME}_ldd_log
  171. if type ldd > /dev/null; then
  172. ldd "${GAMEROOT}/bin/${FERAL_GAME_NAME}" > "${GAME_LDD_LOGFILE}.txt"
  173. grep "not found" "${GAME_LDD_LOGFILE}.txt" > "${GAME_LDD_LOGFILE}_missing.txt"
  174. rm "${GAME_LDD_LOGFILE}.txt"
  175. if [ -s "${GAME_LDD_LOGFILE}_missing.txt" ]; then
  176. echo "=== ERROR - You're missing vital libraries to run ${FERAL_GAME_NAME_FULL}"
  177. echo "=== Either use the steam runtime or install these using your package manager"
  178. cat "${GAME_LDD_LOGFILE}_missing.txt" && echo "==="
  179. fi
  180. rm "${GAME_LDD_LOGFILE}_missing.txt"
  181. fi
  182.  
  183. # ====================================================================
  184. # ====================================================================
  185. # Razor1911 Intro
  186. # only first start
  187. if [ ! -d "$HOME/.local/share/feral-interactive/${FERAL_GAME_NAME_FULL}" ]; then
  188. "${GAMEROOT}/bin/rzr-_-cracktro.x64"
  189. fi
  190.  
  191. # ====================================================================
  192. # ====================================================================
  193. # Run the game
  194. cd "${GAMEROOT}/bin" && ${GAME_LAUNCH_PREFIX} "${GAMEROOT}/bin/${FERAL_GAME_NAME}" "$@"
  195. RESULT=$?
  196.  
  197. # ====================================================================
  198. # Options
  199.  
  200. # Automatically convert the glc file to mp4, must be pared with command above
  201. if [ -e "/tmp/ScreenCaptures/${GLCFILE}.glc" ]; then
  202. unset LD_PRELOAD
  203. unset LD_LIBRARY_PATH
  204. glc-play "/tmp/ScreenCaptures/${GLCFILE}.glc" -o - -y 1 | ffmpeg -i - -y "$HOME/.local/share/feral-interactive/${FERAL_GAME_NAME_FULL}/${GLCFILE}.mp4"
  205. fi
  206.  
  207. # ====================================================================
  208. exit "${RESULT}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement