.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Illwinter Game Design > Dominions 2: The Ascension Wars

Reply
 
Thread Tools Display Modes
  #1  
Old June 15th, 2004, 04:21 PM

guybrush threepwood guybrush threepwood is offline
Corporal
 
Join Date: Mar 2004
Location: Copenhagen, Denmark
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
guybrush threepwood is on a distinguished road
Default Useful linux script when hosting PBEM.

Hi there,

I just made a somewhat useful script for my own purposes and thought I would share it here.

The script (which is a simple bash script) is invoked as:

dom2-host-game my-game-name

The script then carefully checks (using output from dom2 --verify) whether all .2h files are alright, that there are no stale turns, etc. If everything is fine, it then hosts.

Let me know if anyone finds it useful :-)


Install by putting the following inside ~/bin/dom2-host-game (you might need to change the variable DOMINIONS2EXECUTABLE):

code:
#!/bin/bash

DOMINIONS2SAVEDIR=$HOME/dominions2
DOMINIONS2EXECUTABLE=/usr/local/bin/dom2
HOSTFLAGS="--host -xxx --statfile"
#could add --scoredump, but scoredump outputs info even though statistics on other nations is off!!!

if [ $# -ne 1 ]; then
echo Usage: $0 gamename
exit 1
fi

GAMENAME=$1

GAMEDIR="$DOMINIONS2SAVEDIR/$GAMENAME"

if [ ! -d "$GAMEDIR" ]; then
echo Game \"$GAMENAME\" does not appear to exist in $DOMINIONS2SAVEDIR
exit 1
fi

OK=1;
for nationtrn in $GAMEDIR/*.trn; do
nationname=`basename $nationtrn .trn`
file_2h=$GAMEDIR/$nationname.2h
if [ ! -f $file_2h ]; then
echo missing .2h file for $nationname
OK=0
fi
done

if [ $OK -eq 0 ]; then
exit 1
fi

#remove old .chk files
rm -f $GAMEDIR/*.chk

#invoke dom2 -verify to produce new .chk files.
$DOMINIONS2EXECUTABLE --verify $GAMENAME
if [ ! $? ]; then
echo Errors when invoking \"dom2 --verify $GAMENAME\"
exit 1
fi

# A non-existing ftherlnd.chk file means something was wrong with the ftherlnd file.
if [ ! -f $GAMEDIR/ftherlnd.chk ]; then
echo Something is wrong with the ftherlnd file.
exit 1
fi

#ftherlnd defines turn number and game number:
FATHERGAMENUMBER=`grep gamenbr $GAMEDIR/ftherlnd.chk|sed 's/ *//'|cut -d ' ' -f 2`
FATHERTURNNUMBER=`grep turnnbr $GAMEDIR/ftherlnd.chk|sed 's/ *//'|cut -d ' ' -f 2`

#Now, let us check all the chk files.
OK=1;
for nationtrn in $GAMEDIR/*.trn; do
nationname=`basename $nationtrn .trn`
file_chk=$GAMEDIR/$nationname.chk
GREPCHK=`/bin/grep '2h file is OK!' $file_chk`
if [ "$GREPCHK" != "2h file is OK!" ]; then
echo Something is wrong with $nationname.2h
OK=0
else
GAMENUMBER=`grep gamenbr $file_chk|sed 's/ *//'|cut -d ' ' -f 2`
TURNNUMBER=`grep turnnbr $file_chk|sed 's/ *//'|cut -d ' ' -f 2`
if [ "$GAMENUMBER" != "$FATHERGAMENUMBER" ]; then
echo $nationname.2h file appears to belong to a different game!
OK=0
else
if [ "$TURNNUMBER" != "$FATHERTURNNUMBER" ]; then
echo $nationname.2h file appears to be from a wrong turn. Maybe $nationname did not play their turn yet.
OK=0
fi
fi
fi
done

if [ $OK -eq 0 ]; then
exit 1
fi

$DOMINIONS2EXECUTABLE $HOSTFLAGS $GAMENAME

if [ $? ]; then
echo Hosted $GAMENAME succesfully.
exit 0
fi

Reply With Quote
  #2  
Old June 16th, 2004, 02:28 AM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Useful linux script when hosting PBEM.

Nice script. Id have to force a text mode but other than that it looks good.

Care to work on a project to create a linux web-page game-signup and starter?
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
  #3  
Old June 16th, 2004, 08:38 AM

guybrush threepwood guybrush threepwood is offline
Corporal
 
Join Date: Mar 2004
Location: Copenhagen, Denmark
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
guybrush threepwood is on a distinguished road
Default Re: Useful linux script when hosting PBEM.

Quote:
Originally posted by Gandalf Parker:
Nice script. Id have to force a text mode but other than that it looks good.
I would like that very much also. But how can I do that? It seems to me that I can only run text-only mode when running a tcpserver (I would be glad to be corrected on this).

Quote:

Care to work on a project to create a linux web-page game-signup and starter?
I might be interested, but is that not exactly what Mose Hansen's server is already?

Cheers,
Thomas
Reply With Quote
  #4  
Old June 16th, 2004, 03:18 PM
Gandalf Parker's Avatar

Gandalf Parker Gandalf Parker is offline
Shrapnel Fanatic
 
Join Date: Oct 2003
Location: Vacaville, CA, USA
Posts: 13,736
Thanks: 341
Thanked 479 Times in 326 Posts
Gandalf Parker is on a distinguished road
Default Re: Useful linux script when hosting PBEM.

Yes text mode applies to server. Its just my own quirk. I tend to seperate my stuff between GUI stuff (which I run on Windows XP) and server stuff (which I run on a pretty bare linux).

As to the game server thing, yes its what Mosehanson has done (and very well) but Im still interested in doing one of my own.

His kindof came from a programmer side. Top down. Answers all done in modules of a single programming code. System level answers were chosen Last, if at all.

Im more SysAdmin than programmer. Id like to do one system-up with programming answers chosen Last, if at all. Cant hurt to have 2 Versions. 3 actually if anyone tackles doing a Windows Version.

[ June 16, 2004, 14:19: Message edited by: Gandalf Parker ]
__________________
-- DISCLAIMER:
This game is NOT suitable for students, interns, apprentices, or anyone else who is expected to pass tests on a regular basis. Do not think about strategies while operating heavy machinery. Before beginning this game make arrangements for someone to check on you daily. If you find that your game has continued for more than 36 hours straight then you should consult a physician immediately (Do NOT show him the game!)
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 10:23 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.