Windows 3D editor ate my scenario!

AuthorTopic: Windows 3D editor ate my scenario!
Agent
Member # 27
Profile #0
When I added an outdoor section, little did I know that BoA 3D editor would eat my scenario:

1. Add +1 North Outdoor Section,
All the terrain in current section (not the floors) removed!
2. Replaced terrain including the @$#!ing cliff walls.
3. Save, ERROR!
4. Reload, terrain still missing. #$*@!
5. Test save, ERROR!
6. Reload, try to edit town.
ERROR, 3D editor shut down.
7. Reload, try again:

IMAGE(http://img209.imageshack.us/img209/4303/wtflolhv3.png)
ERROR!

This is pretty strange. It looks like I'm going to have to make another scenario and transfer the town into it (see if it's okay) as well as tranfer all the files. I'm just glad I hadn't gotten started on scripting yet.

Edit: I just wanted to mention that before the soldier transformed into a shield, he was shrouded in a black aura that slowly spread in all directions.

[ Sunday, January 27, 2008 16:31: Message edited by: Enraged Slith ]

--------------------
Enraged Slith's Blades of Avernum Website

Look out, there's a three-headed monkey behind you!
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Shaper
Member # 7472
Profile Homepage #1
Before you do that, go into your scenario folder and see if there isn't a file named [yourscenario].bas.bak. If there is, you can remove the .bak part of the extension and load it up in the editor like an ordinary scenario. Of course, keep a copy of the original .bas in case the 3D editor hasn't made a backup recently.

- This post brought to you by UBB. UBB: eating posts for your convenience!
Posts: 2686 | Registered: Friday, September 8 2006 07:00
Agent
Member # 27
Profile #2
Thanks, that did the trick. It's pretty odd too, the old .bas file was 1024kb while the backup was only 96kb.

--------------------
Enraged Slith's Blades of Avernum Website

Look out, there's a three-headed monkey behind you!
Posts: 1233 | Registered: Wednesday, October 3 2001 07:00
Infiltrator
Member # 5576
Profile Homepage #3
I'm glad to hear you were able to recover your work. This topic has, however, lead me to make the discovery that, unlike the Windows version, the Mac version of the editor seems to never leave backup files. On one hand I've never heard of a situation where it was needed, but on the other it could be good safety precaution.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Shock Trooper
Member # 7662
Profile #4
The Windows 3D Editor crashes totally during attempts to port BoE scenarios, it produces a 0Kb bas file.

It also crashes when you attempt to alter the outdoor sections. The good news is that it may actually make the intended alteration before crashing. Basically there are two other ways to alter the outdoor size of a scenario. The first is to make a new scenario with the desired outdoor dimensions, then import every outdoor zone and every town into it. The other is hex-editing, I have decrypted the bas file using the source code for the editor.
(Edit: I tried increasing the size of the outdoors on "A Visit to the Madhouse" and it didn't crash. Why didn't it crash?!)

Enraged Slith produced a fascinating graphic there, I don't know what it was intended to look like so I can't figure out what went wrong. Maybe the program inserted too many characters so the town records are starting on the wrong line.

[ Sunday, January 27, 2008 20:01: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Lifecrafter
Member # 6193
Profile Homepage #5
I've had this happen to me several times before, and it's always been caused by increasing outdoor size. It's fairly consistent (If I reload from the backup and try to increase outdoor size again, towns get corrupted in the same way), but I DO remember successfully increasing outdoor size once before, so hell if I know why for some scenarios it will consistently crash while for others it will work.

Apparently Isaac and company saw this one coming, because the .bas.bak files are always created when you try to increase outdoor size. wOOt

--------------------
"NOW PASS ME MY BOOTS. I HAVE AN APPOINTMENT WITH A FACE." -Nikki

Tales From the Tabard Inn: Now if only there was a 3600 Hour Contest.....
Posts: 900 | Registered: Monday, August 8 2005 07:00
Shock Trooper
Member # 7662
Profile #6
As for the apparent success of me increasing the outdoors of A Visit to the Madhouse: there is no terrain in the Honeycomb outdoor map. I have not spot - checked the scenario as a whole there may be other errors.

Here is my understanding of the first part of a bas file, the numbers on the right are the number of places occupied by the contents of each line.
unsigned char flag1, flag2, flag3, flag4; 4
// for mac, flags are 97 215 7 33
// for win, flags are 199 61 2 53
unsigned char ver[3]; 3
unsigned char min_run_ver; 1
unsigned char prog_make_ver[3]; 3
unsigned char num_towns; 1
short out_width, out_height; 4
short min_level, max_level; 4
short rating; 2

Line 107, 57-58: last outdoor section edited.
Line 107, 59-60: last town edited.
Here ends the fixed scenario entries, now the first or only outdoor section should start.

These figures assume that there are 70 ASCII characters per line.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shaper
Member # 3442
Profile Homepage #7
The moral of the story, as far as I can see, is to do what the BoA Editor Docs say: make your outdoors a few squares bigger than you want, just in case.

--------------------
Nikki's Nook - White, two sugars. :)
Posts: 2864 | Registered: Monday, September 8 2003 07:00
Infiltrator
Member # 5576
Profile Homepage #8
There's no reason that people should be forced to do that though. I'll look at the Win Editor code, compare it with the Mac code, and see if I can figure out why it tends to screw up.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Shock Trooper
Member # 7662
Profile #9
The size of the sections (scenario, outdoor, town) must be okay, otherwise the editor would wreck a scenario every time that anything was done. So I can only imagine that the fault is in the increase/decrease outdoor function itself. It must be something else if it can cause such weird effects.
Posts: 292 | Registered: Monday, November 13 2006 08:00
Infiltrator
Member # 5576
Profile Homepage #10
No, this is not quite right; you see, the entire scenario is never loaded in memory, and furthermore the outdoor sections must be written into the scenario file in a specific order, so the size changing function is enmeshed in its own save procedure, which is not the same as the standard one. It might be better to say that the change outdoor size feature is a save procedure. Thus the save operation used by changing the outdoor size is not the same as the normal save feature, and must be source of the trouble.

The function in question should be do_save_change_to_outdoor_size in Bl A Fileio.cpp.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Shock Trooper
Member # 7662
Profile #11
It is good that the error has been identified. Unfortunately the Windows 3D Editor source code can't be compiled, except possibly on the Linux program KDevelop. So it is not currently possible to write a corrected Windows 3D Editor.

Adding extra outdoor sections is easy in a hex editor, figure out where you want them to go and just start pasting them in.

Edit: the scenario part of the bas file occupies the first 7,480 places. Assuming that the hexadecimal address of the first place is 0, the first outdoor sections starts at hex address 1D38.

[ Monday, January 28, 2008 21:55: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Infiltrator
Member # 5576
Profile Homepage #12
Well, I wouldn't say I've identified the rror, just the function that it must be in. I'm working on it. Also I've compiled the Windows Editor in the past using Dev C++, so there no serious problem there.

I would be careful about adding sections via hex editing, remember that you have to keep the outdoors rectangular, correct the outdoor width and outdoor height numbers, and maintain correctness of the scenario starting location. It's not a procedure for the faint of heart. However, in case it helps:
The scenario data is indeed 7480 bytes, with the outdoor width being the 12th and 13th bytes and the outdoor height being the 14th and 15th. The x,y coordinates of the starting section are at offset 6374, each coordinat is a 2 byte field. Each outdoor section should be 12982 bytes, and begins with the outdoor section's name (which is 20 bytes long).

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Shock Trooper
Member # 7662
Profile #13
I have had no luck compiling anything on Dev-C++, using Windows XP, how do you do it?

I have worked it out, but what this forum needs is an easy way to attach a file to a post. Ironworks Forum has this ability. It also needs the ability to insert tab stops into posts, tabs or tables.

The numbering of hex addresses below starts at 0 not 1. There are four columns, type of character, its description, how many spaces it occupies and where it starts.

unsigned char flag1, flag2, flag3, flag4; 4 0
unsigned char ver[3]; 3 4
unsigned char min_run_ver; 1 7
unsigned char prog_make_ver[3]; 3 8
unsigned char num_towns; 1 11
short out_width, out_height; 4 12
short min_level, max_level; 4 16
short rating; 2 20
char scen_name[50]; 50 22
short scen_label_pic; 2 72
char scen_desc[256]; 256 74
char credits_text[2][256]; 512 330
char comments_text[2][256]; 512 842
short intro_pic_resources[3]; 6 1354
char intro_text[3][6][256]; 4608 1360
unsigned char town_size[200]; 200 5968
unsigned char town_starts_hidden[200]; 200 6168
short start_in_what_town; 2 6368
location what_start_loc_in_town; 2 6370
location what_outdoor_section_start_in; 2 6372
location start_where_in_outdoor_section; 2 6374
short town_to_add_to[10]; 20 6376
short flag_to_add_to_town[10][2]; 40 6396
boat_record_type scen_boats[30]; 300 6436
horse_record_type scen_horses[30]; 300 6736
item_storage_shortcut_type storage_shortcuts[10]; 440 7036
location last_out_edited; 2 7476
short last_town_edited; 2 7478

The same table, this time with an attempt to identify columns with tildes.

unsigned char ~ flag1, flag2, flag3, flag4; ~ 4 ~ 0
unsigned char ~ ver[3]; ~ 3 ~ 4
unsigned char ~ min_run_ver; ~ 1 ~ 7
unsigned char ~ prog_make_ver[3]; ~ 3 ~ 8
unsigned char ~ num_towns; ~ 1 ~ 11
short ~ out_width, out_height; ~ 4 ~ 12
short ~ min_level, max_level; ~ 4 ~ 16
short ~ rating; ~ 2 ~ 20
char ~ scen_name[50]; ~ 50 ~ 22
short ~ scen_label_pic; ~ 2 ~ 72
char ~ scen_desc[256]; ~ 256 ~ 74
char ~ credits_text[2][256]; ~ 512 ~ 330
char ~ comments_text[2][256]; ~ 512 ~ 842
short ~ intro_pic_resources[3]; ~ 6 ~ 1354
char ~ intro_text[3][6][256]; ~ 4608 ~ 1360
unsigned char ~ town_size[200]; ~ 200 ~ 5968
unsigned char ~ town_starts_hidden[200]; ~ 200 ~ 6168
short ~ start_in_what_town; ~ 2 ~ 6368
location ~ what_start_loc_in_town; ~ 2 ~ 6370
location ~ what_outdoor_section_start_in; ~ 2 ~ 6372
location ~ start_where_in_outdoor_section; ~ 2 ~ 6374
short ~ town_to_add_to[10]; ~ 20 ~ 6376
short ~ flag_to_add_to_town[10][2]; ~ 40 ~ 6396
boat_record_type ~ scen_boats[30]; ~ 300 ~ 6436
horse_record_type ~ scen_horses[30]; ~ 300 ~ 6736
item_storage_shortcut_type ~ storage_shortcuts[10]; ~ 440 ~ 7036
location ~ last_out_edited; ~ 2 ~ 7476
short ~ last_town_edited; ~ 2 ~ 7478

[ Tuesday, January 29, 2008 15:16: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Shock Trooper
Member # 7662
Profile #14
Like the records above, these are easiest to read if you import them into Word and change the tildes to tabs.

Outdoor Records
char ~ name[20]; ~ 20 ~ 0
unsigned char ~ floor[48][48] ~ 2304 ~ 20
unsigned char ~ height[48][48]; ~ 2304 ~ 2324
short ~ terrain[48][48]; ~ 4608 ~ 4628
macRECT ~ special_rects[30]; ~ 240 ~ 9236
short ~ spec_id[30]; ~ 60 ~ 9476
macRECT ~ exit_rects[8]; ~ 64 ~ 9536
short ~ exit_dests[8]; ~ 16 ~ 9476
location ~ sign_locs[8]; ~ 16 ~ 9616
char ~ sign_text[8][256]; ~ 2048 ~ 9632
out_wandering_type ~ wandering[4] ~ 216 ~ 11680
out_wandering_type ~ special_enc[4]; ~ 216 ~ 11896
out_wandering_type ~ preset[8]; ~ 432 ~ 12112
location ~ wandering_locs[4]; ~ 8 ~ 12544
macRECT ~ info_rect[8]; ~ 64 ~ 12552
char ~ info_rect_text[8][30]; ~ 240 ~ 12616
char ~ section_script[14]; ~ 14 ~ 12856
short ~ is_on_surface; ~ 2 ~ 12870
short ~ extra[10]; ~ 20 ~ 12872

Town Records

char ~ town_name[20]; ~ 20 ~ 0
short ~ respawn_monsts[4][6]; ~ 48 ~ 20
location ~ respawn_locs[6]; ~ 12 ~ 68
macRECT ~ special_rects[60]; ~ 480 ~ 80
unsigned char ~ spec_id[60]; ~ 60 ~ 560
short ~ lighting; ~ 2 ~ 620
location ~ sign_locs[15]; ~ 30 ~ 622
char ~ sign_text[15][256]; ~ 3840 ~ 652
location ~ start_locs[4]; ~ 8 ~ 4492
location ~ exit_locs[4]; ~ 8 ~ 4500
macRECT ~ in_town_rect; ~ 8 ~ 4508
item_type ~ preset_items[144]; ~ 1152 ~ 4516
preset_field_type ~ preset_fields[60]; ~ 240 ~ 5668
short ~ wall_1_sheet, wall_1_height; ~ 4 ~ 5908
short ~ wall_2_sheet, wall_2_height ~ 4 ~ 5912
short ~ cliff_sheet; ~ 2 ~ 5916
short ~ beam_type; ~ 2 ~ 5918
short ~ environmental_sound; ~ 2 ~ 5920
short ~ is_on_surface; ~ 2 ~ 5922
short ~ town_kill_day; ~ 2 ~ 5924
short ~ town_linked_event; ~ 2 ~ 5926
short ~ external_floor_type; ~ 2 ~ 5928
short ~ monster_respawn_chance; ~ 2 ~ 5930
char ~ town_script[14]; ~ 14 ~ 5932
in_town_on_ter_script_type ~ ter_scripts[100]; ~ 3800 ~ 5946
macRECT ~ room_rect[16]; ~ 128 ~ 9746
char ~ info_rect_text[16][30]; ~ 480 ~ 9874
creature_start_type ~ creatures[80]; ~ 5920 ~ 10354
short ~ extra[20]; ~ 40 ~ 16274
location ~ waypoints[10]; ~ 20 ~ 16314
short ~ exit_specs[4]; ~ 8 ~ 16334
short ~ spec_on_entry; ~ 2 ~ 16342
short ~ spec_on_entry_if_dead; ~ 2 ~ 16344

Size of Big_tr_type
Size of Big_tr_type ~ = 20480;
short ~ terrain[64][64]; ~ 8192 ~ 0
unsigned char ~ floor[64][64]; ~ 4096 ~ 8192
unsigned char ~ height[64][64]; ~ 4096 ~ 12288
unsigned char ~ lighting[64][64]; ~ 4096 ~ 16384

Size of Ave_tr_type
Size of Ave_tr_type ~ = 11520; ~ ~
short ~ terrain[48][48]; ~ 4608 ~ 0
unsigned char ~ floor[48][48]; ~ 2304 ~ 4608
unsigned char ~ height[48][48]; ~ 2304 ~ 6912
unsigned char ~ lighting[48][48]; ~ 2304 ~ 9216

Size of Tiny_tr_type
Size of Tiny_tr_type ~ = 5120; ~ ~
short ~ terrain[32][32]; ~ 2048 ~ 0
unsigned char ~ floor[32][32]; ~ 1024 ~ 2048
unsigned char ~ height[32][32]; ~ 1024 ~ 3072
unsigned char ~ lighting[32][32]; ~ 1024 ~ 4096

Town records have three different possible sizes.
Size of Town_record_type = ~ 16346
Size of Big_tr_type = ~ 16346 ~+ ~ 20480 ~=~ 36826
Size of Ave_tr_type = ~ 16346 ~+ ~ 11520 ~=~ 27866
Size of Tiny_tr_type = ~ 16346 ~+ ~ 5120 ~=~ 21466

[ Tuesday, January 29, 2008 15:50: Message edited by: Ishad Nha ]
Posts: 292 | Registered: Monday, November 13 2006 08:00
Infiltrator
Member # 5576
Profile Homepage #15
For the record, it's probably not worth going into all this detail, since all this information is in the editor code for anyone who wants it badly. (And I suspect that not too many will, really.)

As to compiling on Windows, I don't really remember what I did, I'm afraid, but it seemed pretty simple at the time.

--------------------
Überraschung des Dosenöffners!
"On guard, you musty sofa!"
Posts: 627 | Registered: Monday, March 7 2005 08:00
Shock Trooper
Member # 7662
Profile #16
As I said, I see no way to attach a file to any post. At some point I will have to upload something to my site and insert a hyperlink.

If you have the time, try recompiling the 3D code, that would be a blessing to all Windows users if it worked. We could then all have our own home - brewed editors, just like the Mac users. I suspect that it is simply language dependent features connected with Linux.
Posts: 292 | Registered: Monday, November 13 2006 08:00