Jump to content

ATTN Spidweb: Kink in the Machine


Recommended Posts

I just discovered a lovely little, if utterly fatal, bug in BoA.

 

beginstate 20;

if(char_ok((char_on_spot(char_loc_x(0)), (char_loc_y(0) - 5))) == 1)

{

message_dialog("Is this working?", "");

}

break;

 

Essentially, this piece of code checks to see if there are any monsters of any type five spaces north of the first member of the party. The code works fine, and if there is, the dialog "Is this working?" is displayed.

 

However, once the piece of code is run, and the player then reloads his save game, BoA crashes and quits itself. I thought this might simply be a problem in my machine, so I mailed it over to Drakey, and he has exactly the same problem.

 

If anybody would like to try it for themselves, to see if this is an across the board problem and not just limited to myself and Drakey's machines, then I would be grateful. Comments from Spidweb would be very helpful.

Link to comment
Share on other sites

By the way, here's the way to (probably) fix it. This is in pseudocode since I don't know Avernumscript:

 

Code:
y = char_loc_y(0) - 5;if (y < 0){  // do nothing...}else if(char_ok((char_on_spot(char_loc_x(0)), y)) == 1){  message_dialog("Is this working?", "");}break;
Link to comment
Share on other sites

I'm pretty sure it does that. Let me check.

 

Yeah, it does. For the less technologically savvy of us, what does this type of error mean? Is it a specific fault of BoA's engine, or a scripting limitation?

 

Yeah, that translates pretty well into Avernumscript. I'll try it.

Link to comment
Share on other sites

Quote:
Originally written by Morgan:
I'm pretty sure it does that. Let me check.

Yeah, it does. For the less technologically savvy of us, what does this type of error mean? Is it a specific fault of BoA's engine, or a scripting limitation?
Basically, a town in Avernum is a big grid, with the upper-left corner being (0, 0). As you move to the right, x increases. As you move down, y increases. Therefore, there are only positive numbers in the grid. You're trying to ask Avernum about a spot that's off the grid.
It would be nice if the Avernum engine handled this cleanly, but apparently it doesn't. You'll very likely get the same error if you check too far in any direction. Is there any simple way to get the size of the town? If not, that could be a problem.
Link to comment
Share on other sites

As far as I know, there isn't a way of checking town size (at least not cleanly).

 

What you say may be true, but I've used the same sort of calls to check if certain types of terrain and floors are five spaces in front of the character, and not experienced similar problems.

 

Unfortunately, your solution produces the same results.

Link to comment
Share on other sites

Actually, I think it might be Jeff's string handling that has some bounds checking problems. I had the same problem (crashing after load from a save) in one script where I was using string constants defined at init (then putting them in dialog by var name).

 

As soon as I cut and pasted the strings directly into the message_dialog() call, the problem went away.

 

Try doing something like play_sound(-57) instead of the message_dialog() and see what happens. I was thinking the problem was the string constants, but it could be something slightly screwy with message_dialog() itself, I guess...

Link to comment
Share on other sites

Quote:
Originally written by Morgan:
Unfortunately, your solution produces the same results.
Strange. Try printing out the x and y coordinates you're checking first (or maybe use a message box). Then you should be able to pinpoint which coordinate is making it crash.

Good luck,
N.
Link to comment
Share on other sites

Couldn't you just create another identical desert floor type without the special ability and put it into the areas where you want to allow the party to rest? To be able to differentiate between the two, you could put a red dot or something on the small icon dispayed in the editor window. That way you would be able to tell the difference between the two when editing.

Link to comment
Share on other sites

I tried that spyderbytes, but to no avail. I was personally thinking that it might be something to do with me calling a call within a call within a call. Maybe that's just one of the bounds of BoA.

 

Jeff - I'm not sure I quite understand you - I'm doing all this within the bounds of a town. It works perfectly (I get the message fine), until I reload the save game.

Link to comment
Share on other sites

Quote:
Originally written by Morgan:
Jeff - I'm not sure I quite understand you - I'm doing all this within the bounds of a town. It works perfectly (I get the message fine), until I reload the save game.
As I said, print out the coordinates you're checking before you check them. This will allow you to figure out when and why it crashes.
Link to comment
Share on other sites

I just fixed a bug which might have something to do with this. If a script had an error in which a call wasn't getting passed enough parameters, BoA would crash the next time a saved game was loaded.

 

Double check to make sure your script isn't giving you any errors. I know they can be easy to miss in the scrolling text.

 

- Jeff

Link to comment
Share on other sites

Got and processed. The crash is, indeed, the one I fixed yesterday. It happens when a call gets passed too few integers. The game will handle this error much more gracefully in the future.

 

If you look at this line hard:

 

if(char_ok((char_on_spot(char_loc_x(0)), (char_loc_y(0) - 5))) == 1)

 

you will see a subtle error in the parenthesis. One call is not getting as many integers as it wants ...

 

- Jeff

Link to comment
Share on other sites

"Hehe... as such things go, once you point it out, it practically jumps off the page at you, no? But that begs the question... how the heck did it work as expected up until the game was saved and reloaded?"

 

It's a good question. I am not sure how the script engine will work on the boundary conditions. I think that random data was being put into some of the internal variables, and that data happened to make it work. Stranger things have happened. smile

 

- Jeff

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...