.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 3: The Awakening

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old November 1st, 2006, 02:33 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: Automatic backup of turn files

Very nice. And excellent explanation.

One note. If your icon has a Target line like
"C:\Program Files\dominions3\dom3.exe"
with the quotes (windows puts the quotes because of the space in that line) then put the --preexec backup.bat outside of the second quote.

It also answers a question I had about windows variables that I was going to look up so that I could convert some of my linux scripts to windows batch files.
__________________
-- 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 November 1st, 2006, 02:57 PM

thejeff thejeff is offline
General
 
Join Date: Apr 2005
Posts: 3,327
Thanks: 4
Thanked 133 Times in 117 Posts
thejeff is on a distinguished road
Default Re: Automatic backup of turn files

Another thing I found useful is to pass the game name on the --preexec line.

--preexec "backup.bat GameName"

This way you can use the same script for every game you play and just change the line in properties.

If you also generate the score dump, you can parse that for the turn number and actually save each turn.

I had a fairly simple bash script version, but gave up on converting it to Windows, since the current version behaves badly when running the postexec, at least if it's full screen.
Reply With Quote
  #4  
Old November 1st, 2006, 04:45 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: Automatic backup of turn files

The passed name is a good thing. Thanks.
I can see it being useful since I tend to create a seperate icon for every server game Im in because it saves me changing the server and port when Im playing multiple games on multiple servers. With your hint I can have one bat file making backups of all of my MP games, and just have each icon telling it which game to save. Very handy since multiple games makes it hard to remember what I did last turn.
__________________
-- 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
  #5  
Old November 2nd, 2006, 10:12 AM

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 Re: Automatic backup of turn files

Quote:
thejeff said:
If you also generate the score dump, you can parse that for the turn number and actually save each turn.

Thanks, that was exactly what I was looking for.

I attached a python script. Instead of long winded explanations:

Code:
pia@Lollipop:~/dominions3$ ./dom3backup.py --help
usage: dom3backup.py [options]

options:
-h, --help show this help message and exit
-n NAME, --name=NAME Process file <name>. Otherwise latest file
-f FREQ, --freq=FREQ create a Zipfile every <n> turns. Default: 0 (no
zipfile)
-m MAXFILES, --maxfiles=MAXFILES
keep max. <n> Zipfiles. Delete oldest. Default: 0
(keep all)
-d ARCHDIR, --archdir=ARCHDIR
create Zipfiles in archdir. archdir must exists.
Default: <dom3>/archivedgames
--nocopy don't copy files to backup-dir. Default: False
--clean remove all zipfiles and the backup-dir

Reply With Quote
  #6  
Old November 2nd, 2006, 02:16 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: Automatic backup of turn files

I posted a batch file for playing with the map making commands. It makes it easy to generate map after map with the same settings. It also lets you play with things like the color settings. I posted it into the MOD/MAP subforum since I think it is more useful to that crowd.
__________________
-- 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
  #7  
Old November 3rd, 2006, 07:27 PM

PDF PDF is offline
Colonel
 
Join Date: Apr 2002
Location: Near Paris, France
Posts: 1,566
Thanks: 0
Thanked 0 Times in 0 Posts
PDF is on a distinguished road
Default Re: Automatic backup of turn files

Many thanks Lolly (can I call you that ? ) !
I've installed Python and copied the script, it works quite well as advertised. Only small problem is that if Dom3 runs in fullscreen mode it's automatically minimized when executing the script... I suppose it's a Windowze thingie and can live in windowed mode.
Would it be easy to not only backup the last turn but also make a file history, I mean having subdirs with each turn's saves ? I know the game doesn't pass the turn numbers, so the utility should assume the player uses it by turn 1..
Just an idea, but it'll be cool
Reply With Quote
  #8  
Old November 4th, 2006, 04:10 AM

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 Re: Automatic backup of turn files

Quote:
PDF said:
Many thanks Lolly (can I call you that ? ) !
By way of an exception, cause you was brave enough to try my script

Quote:
Only small problem is that if Dom3 runs in fullscreen mode it's automatically minimized when executing the script... I suppose it's a Windowze thingie
Yes, it is. I doubt there's a way around


Quote:
Would it be easy to not only backup the last turn but also make a file history, I mean having subdirs with each turn's saves ? I know the game doesn't pass the turn numbers, so the utility should assume the player uses it by turn 1..
Just an idea, but it'll be cool
The script already does it, kind of. I was in a hurry when posting cause my boss was approaching and I wasn't supposed to work on a dom3 script.

1) create a 'archivedgames' directory in your dom3 directory.

2) modify the dom3 link to:
dom3.exe --scoredump --preexec 'python dom3backup.py -f 1'

The script parses scores.html to get the turn number (assumes turn 1, if not found) and creates a zipfile (name-Turn<turnnumber>.zip) every '-f <n>' turns (in archivedgames, optionally use the -d arg), with '-f 1' every turn.

You can limit the number of zip-files kept with '-m <n>', default is to keep all.

I hope this isn't too confusing.

Caveat: I haven't tested it under xp. The pyhton-doc says, that you need zlib (prob. not present) only, when deflating, so I used a simple store mechanism. But who knows..

Thanks for testing

Pia

Edit: Gnu zlib for XP is here. Change the line:

zipFile = ZipFile(zipName,'w')

to:
zipFile = ZipFile(zipName,'w',ZIP_DEFLATED)

Compression ratio is 1:10, not bad.
Reply With Quote
  #9  
Old November 4th, 2006, 08:26 AM

PDF PDF is offline
Colonel
 
Join Date: Apr 2002
Location: Near Paris, France
Posts: 1,566
Thanks: 0
Thanked 0 Times in 0 Posts
PDF is on a distinguished road
Default Re: Automatic backup of turn files

Wunderbar !! That's just what we needed to have a real "save" feature in Dom3
Can I kiss you Lolly ?

In fact in my previous post I had just tested the first small script that you gave in your first post and didn't notice there was a second post with attachment !! I'm distracted...

About XP I had everything working but had to "spell" the shortcut command like this :
<dom3path>\dom3.exe --scoredump --preexec "<Dom3 path>\dom3backup.py -f 1"
With <dom3path> my Dom3 directory where I've also copied the .py file. Double apostrophs are required ("), simple ones (')don't work.

This tool give me ideas but I don't charm Pythons like you do so well , could you please continue this fine work ?
- I don't like much having the .backup reps directly under Dom3 rep, I'd prefer to have them underneath each game's rep, ie Dominions3/MyGame/MyGame.backup
I suppose it's rather easy to change ? Just tell me what lines/command to edit, I'm able to do that.
- For pbems, now that we got automatic numbered zipped turn files we just lack an automatic email sending to a list of addresses (the players) ! Do you think you could handle that ? (I'm sure you can ! )
For Dom2 I had a buddy who make scripts to use a small free command-line email tool called "postie", perhaps we could use it also ?
Reply With Quote
  #10  
Old November 4th, 2006, 09:53 AM

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 Re: Automatic backup of turn files

Quote:
PDF said:
Wunderbar !! That's just what we needed to have a real "save" feature in Dom3
Can I kiss you Lolly ?
I guess I have to ask my husband first.

Quote:
- I don't like much having the .backup reps directly under Dom3 rep, I'd prefer to have them underneath each game's rep, ie Dominions3/MyGame/MyGame.backup
I suppose it's rather easy to change ? Just tell me what lines/command to edit, I'm able to do that.
Very well, Master, your wish is my command. I'm working on it.

Quote:
- For pbems, now that we got automatic numbered zipped turn files we just lack an automatic email sending to a list of addresses (the players) ! Do you think you could handle that ? (I'm sure you can ! )
I lack any dom pbem experience, but I think, --pre/postexec only works when hosting. So this would be a stand-alone program. Like reading the addresses from <gamename>.pbem and sending the .2h file? Something like that?

However, I only used python cause it was available at work (which says something about my working morale). Python isn't my favorite language & if that thing gets bigger, I'll use ruby. No worries, it's a 1.x mb download iirc and called 'ruby-one-click-installer.exe'.

And could you do me a favor and test, if the zip file creation works under XP. TIA.

Pia
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 09:36 AM.


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