24 May 2008

Windows game high scores not saved

Something possessed me to install Snood on the kids' computer again. That's a great, little game. (If you want the same basic game in FreeBSD, take a look at "games/frozenbubble" or "games/monkeybubble" in ports.)

But, after a day of play, we noticed something horrible. Most high scores were not being saved! I've had this issue before with some other Windows games so it was no great mystery. On the kids' Windows XP, only I have administrative rights.* So, after I installed the game, the high scores file (whatever and wherever that was) was only writable by me. When they log in and play, their high scores are not saved.

So, let's fix this. As far as I know, this must be done via the command-line. (I'm doing all of this in XP, BTW. If you're running another version of Windows I don't know which parts of this will work, if any.) Open the "Command Prompt," found under "All Programs> Accessories" in the Windows menu.

Next, you've got to find the file where the high scores are saved. This is not necessarily as hard as it sounds. In the case at hand, I've played and saved a high score successfully, so the file in question should have a modification time that is later than any other file. I've installed the game in the directory "C:\Program Files\games\Snood 4" and if I "cd" there and then run "dir /o:d", I can easily see that "SnoodPrf.40W" is that file:
C:\Program Files\games\Snood 4>dir /o:d
Volume in drive C is SOMETHING
Volume Serial Number is X-YYYY

Directory of C:\Program Files\games\Snood 4

11/08/2001 03:27 AM 237,568 glut32.dll
07/31/2006 02:14 AM 38,928 Agency.fnt
08/08/2006 09:31 AM 6,022 HelpLB.txt
05/18/2007 12:41 AM 268,304 Lexia.fnt
01/22/2008 03:31 AM 77,204 Snood 4.0 ReadMe.rtf
03/15/2008 05:04 PM 18,182,144 Snood.exe
05/22/2008 12:37 AM 685,849 unins000.exe
05/22/2008 12:38 AM 2,332 unins000.dat
05/24/2008 08:40 PM <dir> .
05/24/2008 08:40 PM <dir> ..
05/24/2008 08:40 PM 10,820 SnoodPrf.40W
9 File(s) 19,509,171 bytes
2 Dir(s) 80,384,868,352 bytes free

Now for the fun part. We'll need to use the little known Windows program "cacls" to make that file world "changeable". Use some care with this utility. First, run "cacls /?" to see the basic usage. Of special note, always (always) use the "/E" switch so that your changes to the file ACLs don't replace ALL of the existing ACLs. (Yes, it's stupid by default.) Next, just run "cacls <file-of-interest>" to see what the existing ACLs are. There are several in most cases (and if you forget the "/e" switch, you'll have to replace them all, so be careful).

In my case, I can see that what I want is for the unprivileged "BUILTIN\Users" to change from "R" (read access) to "C" (change access). I say "in my case," only because some people may have a more complicated set-up with network users -- but I'd expect the vast majority of people to be in the same boat as myself. So, here's the command that made our high scores work correctly for Snood:
cacls SnoodPrf.40W /E /G "BUILTIN\Users:C"

I've done this once before for another old Windows game, Worms Armageddon (WA). (A great game, BTW. Check "games/wormux" in ports for an open source clone.) With WA, this process was a bit more difficult. First of all, it has a large, multi-directory structure, so it was tough to find the right file. (It was "<WA-top-level>\User\Teams\WG.WGT".) Second of all, the "C"/change access was not sufficient for the regular users to update the file. I don't know why, but in that case I had to grant full access to the file for the scores and saving to work correctly. Keep that in mind, in case you're trying to fix high scores on some other game. Good luck!

Update
I just (re)installed ThinkTanks for the kids. (Another fine game.) But, it also has score/profile saving issues in Windows. To fix, change to the "<TT-top-level>\game\client" directory and update the ACLs (as above) of these four files:

prefs.cs.dso
players.cs.dso
players.cs
prefs.cs


Update 2!
I'm not intending to catalog every Windows game with this issue. But, I've found another one that has put their save files in an unusual place. It is "Luxor 2" by MumboJumbo. It creates a directory, "C:\Documents and Settings\All Users\Application Data\MumboJumbo\luxor2", that all users need to have full access to. And, the files within and sub-directories as well. So, 'cacls luxor2 /t /e /g "BUILTIN\Users:F"' ought to do it.

* I'll have to write about Windows security some time. But, a big part of any reasonable security plan for Windows is ensuring that everyone logs in under their own username and not with administrator rights!

Labels: , ,

08 January 2008

Printing from Windows to CUPS

This is too good to wait on, even though it's late and I'm a little tired. May fill in more later. I have a printer. I hate the Windows drivers that come with it, they're full of ads, obnoxious automated update pop-ups, they hog a lot of memory and CPU, etc. That's alright, I usually use FreeBSD anyway and CUPS ends up working great. I had to find the linux drivers for my particular printer in another port (hpijs or hplip (YMMV)), but was not a big deal. I'm printing over the network from FreeBSD. Everybody's happy.

But, I have a Windows machine for the kids and now they're constantly wanting to print things for school. Sometimes they can use the FreeBSD machine, but sometimes it's not convenient. What I want is for the FreeBSD machine to be a print server to the Windows machine.

So, I know!, Windows means samba and there's a port named "cups-samba". This must be just what I'm looking for. ... Well, it was kind of what I was looking for. But, it was too much trying to do things the Windows way. A little painful. What I discovered in digging around was that I didn't need cups-samba or even samba. CUPS by default leaves a port open for printing and you can use IPP to print directly to a CUPS printer via the network, even from Windows, and using generic, Windows Postscript printer drivers already on your Windows machine (probably).

My breakthrough came from a Gentoo wiki (here) where I found this great wisdom on the subject:

I don't understand why this HOWTO includes Samba functionality. It seems to me to be an inappropriate security risk, especially if your goals are simply what this HOWTO is addressing -- setting up a printer on a Gentoo box using CUPS, and using that printer natively with Windows.

Using IPP, you can axe everything in this HOWTO regarding printing via Samba. CUPS setup as per the HOWTO looks good. I use [OPTION 1] setup in my mixed-OS environment:

[OPTION 1] Generic PS Driver using MS Publisher Imagesetter driver

Windows: run Add Printer, select "Connect to a printer on the Internet..." and enter the URL for your printer (http://<computer-ip>:631/printers/<cups-printer-name>). When it asks for a printer manufacturer, select "Generic", and the printer "MS Publisher Imagesetter".


There's not much more to say. It worked perfectly. I printed out a little sudoku puzzle to test it.

Labels: , ,