View Single Post
  #1  
Old November 1st, 2006, 02:22 PM

Lollipop Lollipop is offline
Private
 
Join Date: Sep 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Lollipop is on a distinguished road
Default Automatic backup of turn files

This is my first post and I hope I don't get a bad rep as 'the gal who propagates cheating tools', but 1) it was useful during my 'what? only 20 devils! Pretender, let's go!" phase, and 2) I want to contribute something (semi) useful, before I start bothering you with my 20000 questions.

Okay first the windows version for the mortals:

1) create a link of your dom3.exe (right drag to a location of your choice and select 'create link here')

2) right click on your link, select 'properties' and find the line containing 'dom3.exe'

3) add ' --preexec backup.bat'

4) open notepad

5) copy & paste the following lines:

Code:
set Game=<name>
cd savedgames
del /S /Q "%Game%.backup"
mkdir "%Game%.backup"
copy "%Game%\" "%Game%.backup\"



save in your dom3 install directory as 'backup.bat'

You have to substitute "<name>" with the name of the game you're currently playing. It's clumsy but it's windows. So if your last game was called 'trash' and you start a new game called 'MoreTrash', you have to edit 'backup.bat' and set the appropriate name.

Now whenever something goes horribly wrong (power failure, your husband mentioning that the kitchen looks like a battle field or simply walking your mages while sneaking your meatshield), go to the 'savedgames' directory, delete the <name> directory and rename <name>.backup to <name>.

A much nicer version which finds the last played game, but requires python (though if you have Civ IV, you probably have python installed):


Code:
#!/usr/bin/python
from os import *
from os.path import *
import shutil

def checkDate(name):
turnFile = join(name,"ftherlnd")
if access (turnFile,F_OK):
return getmtime(turnFile)
return 0

def findLastGame():
lastTime = 0
lastName = ""
chdir("savedgames")
for file in listdir("."):
if isdir(file):
time = checkDate(file)
if time > lastTime:
lastTime = time
lastName = file
return lastName

def doCopy(name):
backup = name + ".backup"
shutil.rmtree(backup,True)
shutil.copytree(name,backup)

last = findLastGame()
if len(last) > 0:
doCopy(last)



Use sparingly.

Hopefully someone find this useful..

kind regards
Pia Kraft
Reply With Quote