Save Game File Decrypting

AuthorTopic: Save Game File Decrypting
Shock Trooper
Member # 7662
Profile #0
This is the first installment of decrypting the BoE save game file. It is based upon the source code file "global.h". Simply copy into the word processor of your choice and change all the tildes into tab stops. (Fine print, the save file uses an idiosyncratic system for recording values of letters and numbers. I have not fully decrypted it, but 0 thru 10 is usually:
k,j,i,h,o,n,m,l,c,b,a.)

PARTY RECORDS
Data type~name~length~starts at
(short)~(scenario flags)~6~0
long ~age;~4~6
short~gold, food;~4~10
unsigned char~stuff_done[310][10]~3,100~14
unsigned char~item_taken[200][8];~1,600~3114
short~light_level;~2~4714
location ~outdoor_corner, i_w_c, p_loc, loc_in_sec;~8~4716
boat_record_type ~boats[30];~300~4724
horse_record_type ~horses[30];~300~5024
creature_list_type ~creature_save[4];~33856~5324
short~in_boat, in_horse;~4~39180
outdoor_creature_type ~out_c[10];~290~39184
item_record_type ~magic_store_items[5][10];~3300~39474
short~imprisoned_monst[4];~8~42774
char~m_seen[256];~256~42782
char~journal_str[50];~50~43038
short~journal_day[50];~100~43088
short~special_notes_str[140][2];~560~43188
talk_save_type ~talk_save[120];~720~43748
short~direction, at_which_save_slot;~4~44468
char~alchemy[20];~20~44472
Boolean ~can_find_town[200];~200~44492
short~key_times[100];~200~44692
short~party_event_timers[30];~60~44892
short~global_or_town[30];~60~44952
short~node_to_call[30];~60~45012
char~spec_items[50]~50~45072
char~help_received[120];~120~45122
short~m_killed[200];~400~45242
long~total_m_killed, total_dam_done~8~45642
long~total_xp_gained, total_dam_taken;~8~45650
char~scen_name[256];~256~45658

"Age" means time, day of scenario&.

Lengths of data types in bytes:
1~Boolean
1~char
1~unsigned char
2~location
2~short
4~long
6~talk_save_type
10~boat_record_type
10~horse_record_type
29~outdoor_creature_type
66~item_record_type
8,464~creature_list_type

PC RECORDS
short ~main_status;~2~0
char ~name[20];~20~2
short ~skills[30];~60~22
short ~max_health~2~82
short ~cur_health~2~84
short ~max_sp~2~86
short ~cur_sp~2~88
short ~experience~2~90
short ~skill_pts~2~92
short ~level;~2~94
short ~status[15];~30~96
item_record_type ~items[24];~1584~126
Boolean ~equip[24];~24~1710
Boolean ~priest_spells[62]~62~1734
Boolean ~mage_spells[62];~62~1796
short ~which_graphic~2~1858
short ~weap_poisoned;~2~1860
Boolean ~advan[15]~15~1862
Boolean ~traits[15];~15~1877
short ~race~2~1892
short ~exp_adj~2~1894
short ~direction;~2~1896

A lot of the Debug functions don't work. "Actions.cpp" lines 1,586 onwards, Debug keystrokes are listed. Only the case > and case W work. Apart from minor message keys: &,*,(,).

[ Monday, April 21, 2008 05:10: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 10488
Profile #1
Is the structure of the Mac save file the same? Anyone know? I know it has an endian difference, but it's quite possible that's the only difference...
Posts: 334 | Registered: Friday, September 14 2007 07:00
Shock Trooper
Member # 7662
Profile #2
I imagine that it is the same. But I have yet to check the two different source files. If you have the official Spiderweb source code you will have both the Mac and the Windows versions of "global.h". In Windows the above tables come from the data structures "scenario_data_type" and "party_record_type".

A difference of endianness won't by itself affect the above tables.

Edit: I just checked the two source files and they both gave the same result, thus the above tables are valid for both Mac and Windows.

[ Monday, April 21, 2008 19:41: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 7662
Profile #3
Change of topic: hex editing.

The notes above are scary to people who are not programmers. But if you open an exs file in a hex editor they start to make sense. Perhaps I should include some notes on how to hex - edit, when I find the time.

How to Hex edit
Download a free hex editor. I personally use Hexplorer, found at http://hexplorer.sourceforge.net
Then install it and start it up.
Open the file you want, a good choice to start with is an exs file. You can compare what you see in the hex editor with what the Scenario Editor displays. (Also it lacks the encryption found in the save game files.)

The place that you are looking for is found in the left part of the status bar. Say you want to edit the Special Items in a password - protected Windows scenario. You are looking for place 3,028 which equals hexadecimal address BD4.

Edit: to hex-edit is easy enough, if you can understand Blades of Avernum you are clever enough to hex-edit.

From the BoE Compiled Suggestion List, what hex-editing enables you to do:

Character Editor
(Ishad Nha)Allow the player to add items from the scenario list rather than the default list.

Scenario Editor
(CM)Remove editing restrictions on the first 91 terrain types.
(CM)Allow the designer to resize the outdoors
(CM,Hrothgar)Allow the designer to import an outdoor section

[ Wednesday, April 23, 2008 19:33: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 7662
Profile #4
A new alphabet:
*)(/.-,#"! '&%$;:98?>=<321(These are the capital letters used to record the names of items in the PC records part of a save game file.)

Lower case letters are recorded by ASCII symbols with numerical values between 0 and 31. Now h,i,j,k have symbols with values of 3,2,1,0. In the numerical areas of item records 0,1,2,3 are represented by k,j,i,h.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 10488
Profile #5
Note: The whole point of the suggestion list is to make those things possible without hex-editing.
Posts: 334 | Registered: Friday, September 14 2007 07:00
Shock Trooper
Member # 7662
Profile #6
If you really want a Mac Editor that works you could try passing around the hat and hiring someone who actually knows how to program. (The Spiderweb fans may not be so wealthy being students and so on.)

You could learn programming and do it yourself.

But apart from those two options, there is only hex - editing. If you have not tried it, it is quite easy once you know what you are doing. You can consult my notes, which you will find in this forum. It is also relatively fast.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 10488
Profile #7
I've looked at the Mac source code, and I honestly can't figure out why it doesn
t
compile. I'll keep trying every so often, though.
Posts: 334 | Registered: Friday, September 14 2007 07:00
Shock Trooper
Member # 7662
Profile #8
Whenever I try to compile any Spiderweb source code I get 10 or 11 pages of errors and warnings. This is on Dev-C++. Borland is even worse.

I think Jeff uses Code Warrior, he has praised it in the Credits part of a help file somewhere. He may use some professional compiler for all I know.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Apprentice
Member # 9013
Profile #9
Hmmm. Is it possible to edit things like e.g. PCs' intrinsic speed?

(I just had an amusing thought involving an entirely naked god party...)

On a more serious note, I've wished for a while to introduce stat boosting/draining potions to BoE, and wholeheartedly approve of anything that might further that goal.

[ Friday, May 09, 2008 18:50: Message edited by: Miramor ]
Posts: 43 | Registered: Tuesday, June 19 2007 07:00
Shock Trooper
Member # 7662
Profile #10
Increase a PC's inherent speed? No, the monsters use the data structure "monster_record_type;", this is from the source file "global.h", there is mention of both speed and "ap", presumably the latter is action points. Meanwhile the PCs use
struct pc_record_type
{
short main_status;
char name[20];
short skills[30];
short max_health,cur_health,max_sp,cur_sp,experience,skill_pts,level;
short status[15];
item_record_type items[24];
Boolean equip[24];
Boolean priest_spells[62],mage_spells[62];
short which_graphic,weap_poisoned;
Boolean advan[15],traits[15];
short race,exp_adj,direction;

/* functions */
bool isAlive() { return (main_status == MAIN_STATUS_ALIVE); }
};

This does not mention speed or action points.
Posts: 292 | Registered: Monday, November 13 2006 08:00