Jump to content


Photo

[Not a bug] - Lunch script


  • Please log in to reply
65 replies to this topic

#1 Congelli501

Congelli501

    Newbie

  • Pre-Order
  • Pip
  • 2 posts

Posted 11 March 2011 - 10:28 PM

Hi !
I'm new on this forum (I have just bought the game pre release).
I have made a script to lunch the game with the current desktop resolution and with the native arch.
If you are interested :
#!/bin/sh

# Resolution...
width=1024
height=768
resolution=$(xrandr -q | grep '*' | grep -o "[0-9]*x[0-9]*")
if [ -n "$resolution" ]; then
	width=$(echo "$resolution" | cut -d'x' -f1)
	height=$(echo "$resolution" | cut -d'x' -f2)
fi

# Arch...
execName='OilRush_x86d'
if [ "$(uname -m)" = 'x86_64' ]; then
	execName='OilRush_x64d'
fi

export LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH
"./bin/$execName"	-video_app opengl \
					-sound_app openal \
					-extern_plugin Network \
					-data_path ../ \
					-engine_config ../oilrush-0.6.cfg \
					-system_script waterwar/unigine.cpp \
					-console_command "world_load waterwar/waterwar" \
					-video_multisample 0 \
					-video_fullscreen 1 \
					-video_mode -1 \
					-video_width "$width" \
					-video_height "$height"

Note: I don't know if posted this topic in the good section but as far as it only concerns Linux...

#2 binstream

binstream

    Producer

  • Pre-Order
  • PipPipPip
  • 668 posts
  • LocationTomsk, Russia

Posted 11 March 2011 - 11:06 PM

We were thinking about a full-fledged config tool but your idea is cool for default launch in native resolution, thank you.

#3 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 16 March 2011 - 08:12 PM

*EDIT*
This topic grows and I think it is a bit cluttered now, so from now on I will use this post to always point to the latest version.
When you want to post a link to the lunch script, please use the topic link or the link to this post.
Please use the zip download file(or do a 'like'), so that i know how many users actually use this script(it just interests me). Updates will always be available as a download and as a simple plain text postet here(as code snippets hidden in the Spoiler)
======
Latest Lunch script version:

[LINK]DOWNLOAD IT HERE

Compatible game versions:

1.07 and above (not downwards compatible)


Full feature list:
Spoiler


======
old post available here:
Spoiler

Edited by luziferius, 01 May 2012 - 11:00 AM.

Posted Image
*My System*
Spoiler

Posted Image

#4 Urfoex

Urfoex

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 322 posts
  • LocationGermany

Posted 16 March 2011 - 09:25 PM

i really like the script, so i took it and improved it a bit so that it works on my system:
now you have:
- basic support for multi-monitor systems (original script returned for width e.g. "1400 1680" which is not a screen width ;) )
- the default behavior can be overwritten by setting the variables at the beginning


Nice one!

Some little improvement-things would be nice:
- switch for fullscreen ( ok, could be done by changing video_fullscreento 0 but would be nice to have that on top with the other self-to-set settings)
- maybe a more dynamic cfg ( for now it loads ../oilrush-0.6.cfg ; that could change with the next version ; couldn't it be made a little bit more dynamic ? (there is only one cfg in the parent directory ;)))
- debug-gdb-mode switch ( to switch between with and without using gdb to grep more information with backtrace and stuff from a crash)
(Would it be possible to automate the gdb stuff? So we wouldn't need to do: 'run; bt; ...; put all in files' - stuff. Would be nice if the script could automate this commands and grepping of information and putting that to a file. User could start the game by clicking on the script and after crash he/she could upload it.)

#5 Congelli501

Congelli501

    Newbie

  • Pre-Order
  • Pip
  • 2 posts

Posted 16 March 2011 - 10:13 PM

Hi,
Thanks for your improvements, the script is becoming really nice !

#6 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 17 March 2011 - 09:42 AM

Spoiler

Posted Image
*My System*
Spoiler

Posted Image

#7 Urfoex

Urfoex

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 322 posts
  • LocationGermany

Posted 17 March 2011 - 10:28 AM

ok thats a hard thing.... grepping the information in a file is simple, but gdb has an own command prompt... i don't even know how to influence/automate it at all...
maybe I could pipe it in somehow...


Found it :lol:

My short debug.sh looks like this:
#!/bin/sh
echo "+-------------------------------- please do ----------------------------"
echo "| run"
echo "| bt"
echo "| info registers"
echo "| disass $pc-32, $pc+32"
echo "+-------------------------------- crash --------------------------------"
export LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH
gdb --batch -x cmd.txt --args bin/OilRush_x64d -video_app opengl -sound_app openal -extern_plugin Network -data_path ../ -engine_config ../oilrush-0.6.cfg -system_script waterwar/unigine.cpp -console_command "world_load waterwar/waterwar" -video_multisample 0 -video_fullscreen 0 -video_mode -1 -video_width 1024 -video_height 768 > debug.out.log

The new parts are these "--batch -x cmd.txt" and " > debug.out.log"
The debug.out.log file could be a bit more dynamic maybe with some date-time information.

The cmd.txt looks like this one:
run
bt
info registers
disass $pc-32, $pc+32
quit

That could do the trick.

#8 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 17 March 2011 - 10:49 AM

Spoiler

Posted Image
*My System*
Spoiler

Posted Image

#9 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 17 March 2011 - 03:37 PM

OK there's it!
now:
  • you can make the script clickable in the file manager
  • you have autodetection for the version (doesn't work with the above because for this you have to know the version for the games root dir (e.g. OilRush-0.6))
  • you can enable automated debugging (thanks to Urfoex for hinting to the batch mode) and generation of logs in $HOME/.Oil Rush
  • you can set fullscreen/windowed mode
as always you can overwrite the default behavior by setting the variables to your favorite values
please note that i haven't tested every possible configuration... if something does not work, please let me know
EDIT: I modified the script a bit to reflect the changes in 0.61
[OUTDATED] Please look here for a more recent version
Spoiler

Edited by luziferius, 24 June 2011 - 08:46 PM.

Posted Image
*My System*
Spoiler

Posted Image

#10 Urfoex

Urfoex

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 322 posts
  • LocationGermany

Posted 17 March 2011 - 03:40 PM

OK there's it!
now:

  • you can make the script clickable in the file manager
  • you have autodetection for the version (doesn't work with the above because for this you have to know the version for the games root dir (e.g. OilRush-0.6))
  • you can enable automated debugging (thanks to Urfoex for hinting to the batch mode) and generation of logs in $HOME/.Oil Rush
as always you can overwrite the default behavior by setting the variables to your favorite values


Very nice!
A real big "THANK YOU" :lol:

#11 Naib

Naib

    Member

  • Pre-Order
  • PipPip
  • 17 posts

Posted 18 March 2011 - 03:06 AM

resolution=$(xrandr -q 2>/dev/null | grep '*' | grep -o "[0-9]*x[0-9]*")
width="${resolution%x*}"
height="${resolution#*x}"


[[ $(uname -m) = x86_64 ]] && execName='OilRush_x64d' || execName='OilRush_x32d'

a couple of snippits.
NOTE this and the previous actually is using BASH features while the shebang is for /bin/sh. this only works because most distros ln -s /bin/bash /bin/sh. if /bin/dash was present you may be in trouble

#12 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 18 March 2011 - 09:07 PM

ah, ok
are these snippets suggestions for an improvement or a correction for proper usage of /bin/sh?
i just changed the shebang to #!/bin/bash
i assume that every modern distribution is shipped with bash (even when not used by default)
Posted Image
*My System*
Spoiler

Posted Image

#13 Naib

Naib

    Member

  • Pre-Order
  • PipPip
  • 17 posts

Posted 20 March 2011 - 01:15 AM

Snippits for improving and correcting.
A quick throwdown.
Basically cleaner POSIX code for getting res as well as what executable to use. You were testing too many time, might as well just test once and have the fallback -ie why bother testing for 32bit, 64bit and then fallback to 32bit when you could just test for 64bit and then default to 32bit. Likewise with res, why bother distinguing between multimon, just get it to loop through all the results.

I really don't like how the version number is being fetched, especially via parsing the output of ls I am thinking of a better way plus a bit more future-proof but without any nice way to determine version number (I tried string over the binary) might have to rely on the cfg filename
fullscreen=1
multimonitor=false

if [ $gamefolder -a -d $gamefolder ]; then
        cd $gamefolder
else
        #get the game version; if not set, get it from the filename 
        if [ -z $gameversion ]; then
                gameversion=$(ls oilrush-*.cfg)
                gameversion=${gameversion%.*} 
                gameversion=${gameversion##*-} 
        fi
fi
echo "Game version is: $gameversion"



if [ "$debug" = "true" ]; then
# change this for the next version of Oil Rush because it WILL break
        debugdir="$HOME/.Oil Rush"
        echo "run" > ./cmd.txt
        echo "bt" >> ./cmd.txt
        echo "info registers" >> ./cmd.txt
        echo "disass $pc-32, $pc+32" >> ./cmd.txt
        echo "quit" >> ./cmd.txt
        echo "start the game with gdb"
else
        echo "start the game without gdb"
fi



for i in $(xrandr -q 2>/dev/null | grep '*' | grep -o "[0-9]*x[0-9]*"); do
    oIFS="$IFS"
    IFS="x"
    read -r width height <<< "$i"
done
IFS="$oIFS"
echo $width $height


[ $(uname -m) = x86_64 ] && execName='OilRush_x64d' || execName='OilRush_x32d'

export LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH
if [ "$debug" = "true" ]; then
        gdb --batch -x cmd.txt --args "./bin/$execName"   -video_app opengl -sound_app openal -extern_plugin Network \
                -data_path ../ \
                -engine_config ../oilrush-$gameversion.cfg \
                -system_script waterwar/unigine.cpp \
                -console_command "world_load waterwar/waterwar" \
                -video_multisample 0 \
                -video_mode -1 \
                -video_fullscreen $fullscreen -video_width $width -video_height $height \
                | tee "$debugdir/oilrush-debug.$(date --rfc-3339=seconds).log"
        rm ./cmd.txt
else
        "./bin/$execName"   -video_app opengl -sound_app openal -extern_plugin Network \
                -data_path ../ \
                -engine_config ../oilrush-$gameversion.cfg \
                -system_script waterwar/unigine.cpp \
                -console_command "world_load waterwar/waterwar" \
                -video_multisample 0 \
                -video_mode -1 \
                -video_fullscreen $fullscreen -video_width $width -video_height $height
fi



#14 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 21 March 2011 - 01:19 PM

Spoiler

Posted Image
*My System*
Spoiler

Posted Image

#15 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 31 March 2011 - 08:52 PM

**UPDATE**
the well known Lunch script just got hotter! (but please do not eat it all alone :D )
i updated the script for compatibility with 0.61
I updated my previous post, you can find the updated script HERE so that the topic isn't blown up for easier overview
I only did small changes... I
  • moved the $debugdir variable up, so that it can be changed easier
  • put 0.61 to the gameversion presets
  • removed the space in the $debugdir (to reflect the change in 0.61)
  • moved the cmd.txt into the user's $debugdir (so that the game's folder isn't changed, it could be read-only)
i am a little bit lazy (it's already a little bit late today ;) ), so i didn't implement a bigger version control for the debugdir... if you want to use the updated script with 0.6, you will have to change that in the script..
(and think POSIX :P )
Posted Image
*My System*
Spoiler

Posted Image

#16 neph

neph

    Member

  • Pre-Order
  • PipPip
  • 10 posts

Posted 01 April 2011 - 10:55 PM

While trying to use the script i encountered the following

execName='OilRush_x32d'

does not work, because the file seems to be called OilRush_x86d in the bin directory.
After changing that in the script everything seems to work fine...

#17 luziferius

luziferius

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 269 posts
  • LocationGermany

Posted 02 April 2011 - 01:14 PM

thank you for reporting
i assumed that it is OilRush_x64d for 64Bit and OilRush_x32dfor 32Bit...
I didn't check this, because i have only 64Bit systems
i'll change it now
Posted Image
*My System*
Spoiler

Posted Image

#18 Defense

Defense

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 191 posts

Posted 30 April 2011 - 06:28 AM

thank you for reporting
i assumed that it is OilRush_x64d for 64Bit and OilRush_x32dfor 32Bit...
I didn't check this, because i have only 64Bit systems
i'll change it now


For 0.62 we need to change
-console_command "world_load waterwar/waterwar"
to
-console_command "world_load waterwar/menu"

and maybe add
unset LIBGL_ALWAYS_INDIRECT

(haven't uploaded a version since currently I haven't the latest version, just wanted to report)

EDIT: Another suggestion for this wonderful script would be to integrate the screenshot format (http://oilrush-game....eenshot-format/)

Edited by Defense, 01 May 2011 - 05:33 PM.


#19 Defense

Defense

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 191 posts

Posted 01 May 2011 - 09:29 PM

**UPDATE**
the well known Lunch script just got hotter! (but please do not eat it all alone :D )
i updated the script for compatibility with 0.61
I updated my previous post, you can find the updated script HERE so that the topic isn't blown up for easier overview
I only did small changes... I

  • moved the $debugdir variable up, so that it can be changed easier
  • put 0.61 to the gameversion presets
  • removed the space in the $debugdir (to reflect the change in 0.61)
  • moved the cmd.txt into the user's $debugdir (so that the game's folder isn't changed, it could be read-only)
i am a little bit lazy (it's already a little bit late today ;) ), so i didn't implement a bigger version control for the debugdir... if you want to use the updated script with 0.6, you will have to change that in the script..
(and think POSIX :P )


Today I added the required changes to luziferius' Lunch script to use it with 0.62. Maybe luziferius can check it and update the current version. Somehow I did not manage to get the screenshot format working... By changing the config everything is fine, but in the Lunch script it doesn't work :-/

#!/bin/bash

# Game version: you'll have to set this properly if you want to set the gamefolder
# if you only want to use the console and cd to the directory by yourself, you can ignore this
#gameversion=0.6
#gameversion=0.61
#gameversion=0.62

# Path to game folder: set it to your local OIlRush game folder to make this script "clickable" in your file manager
# remember that you have to set $gameversion above for this to work
#gamefolder=/usr/local/share/games/OilRush-$gameversion
#gamefolder=/opt/OilRush-$gameversion
#gamefolder=$HOME/OilRush-$gameversion

# set to 0 to use the windowed mode
# if set to 0 you should force a custom resolution, otherwise the game will use your desktop resolution for the window
# and that is a bit too big(because of window borders, docks, panels, etc...)
fullscreen=1

# Resolution: to force one, uncomment the following line and set it to your favorite resolution
# setting it to non-native resolutions seems to break Unigine's nice monitor auto selection on multi-monitor systems
#resolution=1024x768

# Arch: to force one, uncomment the following line and set it to your architecture
#execName="OilRush_x86d"

# The following only works with native resolutions:

# on multimonitor-systems use last monitor reported by xrandr for the single-monitor mode
#( with 2 monitors it uses the second; it depends on Unigine's monitor autoselection -> it works only with different resolution on both monitors)
#use_monitor=last

# Set to "true" if you have a multi-monitor-system and want to enable the usage of all monitors
# The script assumes that the monitors have same height and horizontal alignment
# Setting it to true on a single-monitor system should not do something special
#multimonitor=true
multimonitor=false

# Debug mode: use gdb to automatically debug the game
# logs will be written into "$HOME/.Oil Rush/"
# uncomment the fllowing line to enable debug mode
debug=true

# use this for Versions > 0.61
debugdir="$HOME/.OilRush"
# use this for Version 0.6
#debugdir="$HOME/.Oil Rush"

# goto game folder
if [ $gamefolder -a -d $gamefolder ]; then
        cd $gamefolder
else
        #get the game version; if not set, get it from the filename 
        if [ -z $gameversion ]; then
                gameversion=$(ls oilrush-*.cfg)
                gameversion=${gameversion%.*} 
                gameversion=${gameversion##*-} 
        fi
fi
echo "Game version is: $gameversion"

# Set the debug variables properly
if [ "$debug" = "true" ]; then
        echo "run" > $debugdir/cmd.txt
        echo "bt" >> $debugdir/cmd.txt
        echo "info registers" >> $debugdir/cmd.txt
        echo "disass $pc-32, $pc+32" >> $debugdir/cmd.txt
        echo "quit" >> $debugdir/cmd.txt
        echo "start the game with gdb"
else
        echo "start the game without gdb"
fi
unset width
unset height
# Set Resolution...
if [ -z $resolution ]; then
        if [ "$multimonitor" = "true" ]; then
                resolution=$(xrandr -q | grep '*' | grep -o "[0-9]*x[0-9]*")
                for i in $resolution; do
                        width=$(($width+$(echo "$i" | cut -d'x' -f1)))
                        height=$(echo "$i" | cut -d'x' -f2)
                done
        else
                resolution=$(echo $(xrandr -q | grep '*' | grep -o "[0-9]*x[0-9]*") | tr " " "_")
                if [ "$use_monitor" = "last" ]; then
#                       use resolution of the last reported monitor, autoselection does the rest
                        resolution=${resolution%%_*} 
                else
#                       use resolution of the first reported monitor, autoselection does the rest
                        resolution=${resolution##*_} 
                fi
                width=$(echo "$resolution" | cut -d'x' -f1)
                height=$(echo "$resolution" | cut -d'x' -f2)
        fi
else
                width=$(echo "$resolution" | cut -d'x' -f1)
                height=$(echo "$resolution" | cut -d'x' -f2)
fi


# Set Arch...
if [ -z $execName ]; then
# uname -m can return different values for 32 Bit systems due to different optimisations (could be i386, i586, i686 or even something different)
# using architecture of init process should be sufficient and work on all distibutions
        if [ -n "$(file /sbin/init | grep "ELF 64")" ]; then
                execName='OilRush_x64d'
                echo "64 bit system detected: use 64 bit version"
        elif [ -n "$(file /sbin/init | grep "ELF 32")" ]; then 
                execName='OilRush_x86d'
                echo "32 bit system detected: use 32 bit version"
        else
                echo "Unknown architecture(?): $(uname -m)"
                echo "Setting default version to 32Bit"
                execName='OilRush_x86d'
        fi
fi

export LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH
unset LIBGL_ALWAYS_INDIRECT
if [ "$debug" = "true" ]; then
        gdb --batch -x $debugdir/cmd.txt --args "./bin/$execName"   -video_app opengl -sound_app openal -extern_plugin Network \
                -data_path ../ \
                -engine_config ../oilrush-$gameversion.cfg \
                -system_script waterwar/unigine.cpp \
                -console_command "world_load waterwar/menu" \
                -video_multisample 0 \
                -video_mode -1 \
                -video_fullscreen $fullscreen -video_width $width -video_height $height \
                | tee "$debugdir/oilrush-debug.$(date --rfc-3339=seconds).log"
        rm $debugdir/cmd.txt
else
        "./bin/$execName"   -video_app opengl -sound_app openal -extern_plugin Network \
                -data_path ../ \
                -engine_config ../oilrush-$gameversion.cfg \
                -system_script waterwar/unigine.cpp \
                -console_command "world_load waterwar/menu" \
                -video_multisample 0 \
                -video_mode -1 \
                -video_fullscreen $fullscreen -video_width $width -video_height $height
fi


#20 maizuddin

maizuddin

    Advanced Member

  • Pre-Order
  • PipPipPip
  • 282 posts
  • LocationKuala Lumpur , Malaysia

Posted 03 May 2011 - 10:50 AM

can anyone show/teach me the noob on how actually to use this launcher script? :)
using....
ubuntu 12.04 & windows 7




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users