.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Dominions 3: The Awakening (http://forum.shrapnelgames.com/forumdisplay.php?f=138)
-   -   Utility: Linux Admining (http://forum.shrapnelgames.com/showthread.php?t=30044)

Gandalf Parker October 21st, 2013 06:41 PM

Re: Linux Admining
 
YAY! after DAYS of messing with it I finally got an ugly ugly script that works!
Code:

AI="diffai "
t=0

cp /home/gandalf/dominions4/Files_EA.txt paste.txt
rm done.txt

# add uploaded gods as team leaders
for FYL in `ls -1 *.2h | cut -f1 -d.`
 do
  let t=t+1
  sed -i  "/$FYL/s/^/--team / ; s/$FYL.*$/$t 1 \\\/"  paste.txt
 done


# add one AI team
let t=t+1
  cnt=`grep -c _ paste.txt`
  chc=`echo $RANDOM % $cnt + 1 | bc`
  PRET=`grep _ paste.txt |head -$chc |tail -1|cut -f2 -d' '`
  grep $PRET paste.txt | sed "s/^/--$AI/;s/$PRET.*$/\\\/" >>done.txt
  sed -i  "/$PRET/s/^/--team / ; s/$PRET.*$/$t 1 \\\/"  paste.txt

for TT in `seq 1 $t`
 do
  cnt=`grep -c _ paste.txt`
  chc=`echo $RANDOM % $cnt + 1 | bc`
  DISC=`grep _ paste.txt |head -$chc |tail -1|cut -f2 -d' '`
echo $chc
echo $DISC
  grep $DISC paste.txt | sed "s/^/--$AI/;s/$DISC.*$/\\\/" >>done.txt
  sed -i  "/$DISC/s/^/--team / ; s/$DISC.*$/$TT 2 \\\/"  paste.txt
 done

for TT in `seq 1 $t`
 do
  cnt=`grep -c _ paste.txt`
  chc=`echo $RANDOM % $cnt + 1 | bc`
  DISC=`grep _ paste.txt |head -$chc |tail -1|cut -f2 -d' '`
echo $chc
echo $DISC
  grep $DISC paste.txt | sed "s/^/--$AI/;s/$DISC.*$/\\\/" >>done.txt
  sed -i  "/$DISC/s/^/--team / ; s/$DISC.*$/$TT 2 \\\/"  paste.txt
 done

grep "\-\-team" paste.txt >>done.txt

It is so that a --teamplay game of Dom4 can be started allowing everyone to send a full pretender. When the start button is pressed the game should crash (using --mapfile foo.map will do it). Then run this script and add the done.txt to the start script for the game.

What it does is:
if 4 pretender files were uploaded then it treats those as team leaders 1 2 3 4 and it adds an AI leader for a +1 team (in this case team 5). Then it randomly assigns 2 nations as AI Disciples for each team. So the 4 people that signed up all become pretenders with 2 AI disciples clustered near them.

UNFORTUNATELY I now have to figure out why Dom4 has a problem starting a game with AIs. :(

Gandalf Parker November 15th, 2013 01:59 PM

Re: Linux Admining
 
OK another brain fart that worked out well... :)

Code:

#!/bin/bash

while [ ! -f ftherlnd ]

 do
  ls -1 *.2h |sort >list.txt

  if  ! diff list.txt oldlist.txt
  then
    zip -9 GodSaves *
    mv list.txt oldlist.txt
    else
    sleep 3
  fi
 done

figlet GAME START

What it does:
This is a script I can start in a games directory as soon as I have set it up for someone. It gets around the problem that pre.sh and post.sh do not activate for initial hosting.

It sits and watches for the fatherland file to exist (meaning the game has started and created its initial hosting).

If fatherland does NOT exist yet, then it watches for new pretender files (*.2h) to show up. And when a new one does then it updates the GodSave.zip file. As soon as the fatherland file appears, it shouts GAME START and quits running.

Im thinking of adding a no-clobber to the zip command to help insure first-come-first-served. Other people overwriting uploaded gods has been a problem in some games. And the recognition of fatherland could create the games first backup which has always been missing.

In any case it has proven quite useful in restarting bad starts without forcing people to re-upload their gods.


All times are GMT -4. The time now is 04:51 PM.

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