• Most people probably don't realise this, but this forum has had two editors for a number of years. One is the xenForo default editor, and the other is a custom editor I made years back I called BBCEd.

    All the settings for which editor you use was lost during the upgrade. You can find the setting under Account Settings > Preferences > Editor.

Cave Story Python save converter

Old topic!
The last post in this thread is over 60 days old. Posting in this thread will be considered a bump, so please make an attempt to be courteous if you go ahead with it.

If the last post is over 6 months old, it may instead be a better idea to start a new topic. If you aren't sure about what to do, feel free to ask a staff member for help, or try to locate a 'general questions'-type thread if it exists in this (sub-)forum.
Mar 15, 2009 at 3:32 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#1
Okay, so I've finally finished this:

A script to convert between Mac and Windows save files.

It should be considered a "beta" version.

It requires Python 2.6 to run. Mac users are likely to have this already; if you don't have it, it's downloadable from <http://python.org>.

It's meant to be run from the command line, so mac users will have to launch Terminal, make sure the file has execution permission ("chmod +x cavesaveconv.py") and run it (something like "./cavesaveconv.py" or, alternatively, "python cavesaveconv.py").

Please report any bugs that may occur. Any suggestions would be welcome also.

(No longer an attachment, because it's a .tgz which this forum doesn't accept.)

csc_beta.tgz
 
Mar 15, 2009 at 4:51 PM
Been here way too long...
"Life begins and ends with Nu."
Join Date: Jan 4, 2008
Location: Lingerie, but also, like, fancy curtains
Posts: 3054
#2
nug nug.
sounds really useful, but could you make it simpler to use...?
 
Mar 15, 2009 at 5:22 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#3
Probably. Not right at this moment though.
 
Mar 16, 2009 at 2:02 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6161
Age: 34
#4
Permission to host it on the site?

Also the download link doesn't work. You need to go here and then right-click on the file, save as.

EDIT: Nevermind. The file doesn't save properly when you do that.
 
Mar 16, 2009 at 12:30 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#5
I'm guessing that's just a problem with the server that will fix itself at some point. At least, I hope it is. Perhaps I'll put it up as a text file in the meantime... once I get back home, anyway. And I'll re-upload the zip, in case the problem was an upload error.

Yes, you can host it on the site, but it might be better to wait until it's not beta. That's up to you, though. Obviously you'll also have to wait until I re-upload it.
 
Mar 16, 2009 at 6:55 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#6
Well, I have a link that actually works now. It requires you to change the file extension from .txt to .py, but at least you can get it.

Andwhy, if you do choose to put it on your site, please do it as a zipped .py file. Remember that it's beta, though.
 
Mar 17, 2009 at 3:49 AM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#7
Whee! Already I have made major changes!

...Well, mostly they are internal changes unnoticeable to users (like putting everything in functions and refactoring stuff). However, the program will no longer quit after doing exactly one thing, so that's one plus. Also the command-line parameters appear to work now (they didn't seem to work before) and there are command-line parameters to extract and convert or convert and store at the same time.
 
Mar 20, 2009 at 2:34 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#9
You're welcome. :p

And thanks for putting it up. :)

A later release may have a) a Readme file and b) ability to edit the save file. But for now, the conversion is fully functional.

Just one thing that should be mentioned: the "Extract" and "Store" functions won't work on Windows even if you happen to have a Mac Cave Story plist available, because they rely on a utility (plutil if I recall correctly) which comes with MacOSX. It's possible that this will also cause problems with Macs – I don't know whether plutil is part of the main package or whether it's part of the developer package. If the latter, you may need to install XCode Tools from your install disk (or download it from the Apple site).

(XCode itself is not needed, though.)
 
Mar 21, 2009 at 11:45 PM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6161
Age: 34
#10
Celtic Minstrel said:
A later release may have a) a Readme file
I actually copy-pasted your first post as a readme. :D
 
Mar 22, 2009 at 4:40 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#11
Well, a later release may have an proper readme file. :)
 
Apr 6, 2009 at 7:15 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#12
No new release yet, but I've written code to add a weapon to the save file. That was probably the most complicated editing task to deal with; adding an item should be fairly simple and removing an item or weapon shouldn't be too hard either.

I'm wondering how the flags are stored... are they stored as bitfields, or is each byte a flag, or what? Can flags be only on or off, or do they store numbers? How many flags are there? Etcetera...

Once those five editing functions are written, I'll add code to access them from the interactive menus. I also thought about doing a "view" function...


Oh, and I've decided to remove the "convert" capability as it is in the current release, in order to keep a single save format for distribution. The next release will take a Windows save file, convert it to Mac format, and store it in the preferences as a single operation; the intermediate Mac format file is omitted.
 
Apr 7, 2009 at 4:36 AM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#13
Update #2: Adding and removing weapons works; adding and removing items works; I also added a function to change current and max hp.

Ammo and hit points currently don't accept values greater than 255, though, because that requires a little extra work to break the number into bytes. I'll fix that at some point.

I still need to know whether flags are a simple on/off thing, with each bit representing a different field.

Does anyone know how the teleporter stuff in the save file works? I have that each one is 8 bytes, the first 4 being "Teleporter Menu" and the second 4 being "Teleporter Location".

What are sensible values for weapon energy? I think 12 or something caused one weapon to go off the bar. Does that depend on the weapon?

What's the format for the "Equipped Items" portion (offset 0x2C)? There's a partial list on the website, but it's clearly missing some (I think the air tank, counter, and mask are equippable, right?)

Anyway, I'll upload the new version once I update the interactive code so that all features can be accessed without command-line arguments.
 
Apr 8, 2009 at 2:17 AM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#14
I've edited the first post to reflect the new version, which is now available as an attachment to said post.

It now involves several files; if you get errors like "ImportError: No module named csc_interface", it's because you've lost or misplaced one of the files. (All the necessary files begin with "csc_".)

It's still a beta version.
 
Apr 8, 2009 at 5:11 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6161
Age: 34
#15
Flags and equipment are an on/off thing using bits, not bytes.

It might be a good idea to separate save editing and save conversion into two programs. Not everyone will like the idea of being able to cheat when they convert their save files, or that others might assume that they did. I know that the trainer that was tagged on top of the ff9 protection disabling patch still annoys me to this very day.

Flag info:
http://lotlot.net/misc/doukutsu/flags.txt

Other stuff:
http://lotlot.net/misc/doukutsu/profile.txt

Look in here for equip info, basically just add the listed decimal values for each equipped item together and convert it to a 4-byte long hexadecimal value.

..with the appropriate byte order of course.

Though it would be easier for your program to just look at the individual bits.
 
Apr 8, 2009 at 3:18 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#16
I'll probably work with the individual bits using XORs and ANDs and ORs (whichever are applicable).

Editing and converting are separated despite being in the same program. Conversion and editing are two separate operations. If you edit and convert on the command line with a single call, you need to repeat the filename for conversion.

The conversion part isn't available on Windows.

In flags.txt... the FLAG column is offset/bit and the TSC column is the corresponding flag for TSC? It looks like the list is unsorted...
 
Apr 9, 2009 at 12:26 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6161
Age: 34
#17
Celtic Minstrel said:
The conversion part isn't available on Windows.
But it was beforehand if I recall. What changed?
 
Apr 9, 2009 at 3:01 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#18
It uses plutil, which is a program only available on the Mac, to convert the binary plist file into an XML plist file that Python can actually work with.

The game itself can read XML plists just as well as binary plists, but it always writes as a binary plist.


So basically I disabled it because it wouldn't work anyway.
 
Jun 30, 2009 at 12:36 AM
Neophyte Member
"Fresh from the Bakery"
Join Date: Jun 30, 2009
Location:
Posts: 2
#19
Hello Celtic Minstrel (or anyone else that can help),

I'm a PC user (and new to Cave Story!) and it looks like your program is exactly what I need to make Cave Story (which I run off of a flash drive) truly portable between work, home, school. I'm having trouble using cavesaveconv as the following errors pop up (lets call my source file profile.dat):

error 1:
./cavesaveconv.py
[('interactive',)]
Which operation would you like to perform?
E - Extract a save from a Macintosh property list and save it to a file.
S - Store a save in a Macintosh property list, overwriting the existing one.
X - Edit a save file.
Q - Quit the program.
e
Enter the filename to extract the profile to:
Or type Q to cancel.
profile.dat
[('extract-mac-profile', '/Users/niki/Library/Preferences/com.nakiwo.Doukutsu.plist', '.pycs_temp'), ('convert-profile', '.pycs_temp', 'profile.dat'), ('clean-temp-file', '.pycs_temp'), ('interactive',)]
Traceback (most recent call last):
File "./cavesaveconv.py", line 188, in ?
main()
File "./cavesaveconv.py", line 23, in main
functions[curTask[0]](*curTask[1:])
File "/Users/niki/Desktop/cs/cavesave/csc_convert.py", line 8, in extract
import subprocess as fork
ImportError: No module named subprocess

error2:
./cavesaveconv.py
[('interactive',)]
Which operation would you like to perform?
E - Extract a save from a Macintosh property list and save it to a file.
S - Store a save in a Macintosh property list, overwriting the existing one.
X - Edit a save file.
Q - Quit the program.
s
Enter the filename of the profile to store:
Or type Q to cancel.
profile.dat
[('convert-profile', 'profile.dat', '.pycs_temp'), ('store-mac-profile', '.pycs_temp', '/Users/niki/Library/Preferences/com.nakiwo.Doukutsu.plist'), ('clean-temp-file', '.pycs_temp'), ('interactive',)]
--> Profile converted.
[('store-mac-profile', '.pycs_temp', '/Users/niki/Library/Preferences/com.nakiwo.Doukutsu.plist'), ('clean-temp-file', '.pycs_temp'), ('interactive',)]
Traceback (most recent call last):
File "./cavesaveconv.py", line 188, in ?
main()
File "./cavesaveconv.py", line 23, in main
functions[curTask[0]](*curTask[1:])
File "/Users/niki/Desktop/cs/cavesave/csc_convert.py", line 22, in store
import subprocess as fork
ImportError: No module named subprocess
nicole-ralph-fortons-computer:~/desktop/cs/cavesave niki$

I get similar errors when I try to use the command line arguments and "@".
Please let me know if my errors are due to my inexperience with terminal (very, very likely) or something else?

Thanks for your time!
Strtpls3
 
Jul 7, 2009 at 3:41 PM
In front of a computer
"Man, if only I had an apple..."
Join Date: Mar 1, 2008
Location: Grasstown
Posts: 1435
#20
My guess would be that you do not have a recent enough version of Python. The subprocess module is part of the Python library in the version I have.

To find out what version of Python you have, go to the terminal and type "python --version". I have version 2.5.1, so anything earlier is likely not to work.

Since you say you're a PC user, am I right in guessing you use Macs at work or school? In which case, updating Python may not be an option. There are probably a few ways you can work around this (such as installing Python somewhere else, or editing the plist file manually to include the converted save file, which will be in a temporary file in the same folder).

Also, it seems I haven't removed the debugging code. Oh well. It's still "beta" anyway.
 
Top