Bug: Crash on new game when @shortcut in inventory (v0.96a)

These are old bug reports that have been closed.
Locked
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Change an item's unid to use the @shortcut. Now place that item into the inventory of a playership. Start the game and select that shiptype. Watch the game crash quickly and silently. (No error message onscreen or in the debug log.)

Interestingly, if the item is equipped or otherwise not in the ship's cargo hold on startup, the game seems to run fine.

UPDATE: The crash also happens if the item is in a station's inventory on startup.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Good catch! I believe that is fixed in the next version (because I re-did some of that code).

But just to make sure, could you send me an Extension that shows the problem so I can test it? Thank you!

(send to [email protected])
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Sure thing. File sent.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Thanks--that helped me to track it down.

I've fixed the problem in the next version.

Unfortunately, I also found a new problem: If you try to use @shortcuts for ships classes inside station definitions (e.g., to define the guard ships for a station) then the game also crashes.

This second bug is more difficult to fix because I have to redo the way I store ship encounter tables. It will likely not get fixed until the version after next.

Thank you for helping me find the problem!
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Wow, it's great to see these bugs get fixed so quickly! I've worked a bit on other games, and it's such a huge difference having an experienced professional programmer at the helm.

I'm curious how these bugs exist at all. If an @shortcut is simply a text alias for a unid, then shouldn't there be no difference in the end--or even immediately after an @shortcut is read and mapped to a unid? In other words, once the game gets past the reading and parsing the files stage, shouldn't there be just unids left in memory as object identifiers? I guess I don't understand why using shortcut aliases in files would require the ship encounter data table to be changed.
george moromisato
Developer
Developer
Posts: 2997
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Karl wrote:I'm curious how these bugs exist at all.
The problem is that in the "reading and parsing" stage I sometimes keep the generic XML representation (rather than read into a specific datastructure).

In other words, rather than creating a datastructure for representing (e.g.) the random ship table for a station, I just keep it in XML and use that.

Unfortunately, in this case, by the time I need to use the XML, I've lost the association with the Extension that the XML lived in, so I don't know what the base UNID is.

Over time, I've been converting most of those uses of XML into an intermediate datastructure (which has the UNID already computed, as you would expect). For this version I replaced the item table (which is why I was able to fix the bug quickly).

In some future version (hopefully soon) I will rewrite the ship table too.

Thanks for the kind words!
User avatar
Karl
Militia Lieutenant
Militia Lieutenant
Posts: 219
Joined: Fri Jul 14, 2006 11:47 pm

Oh, I see now. Using the XML as a data structure sounds pretty convenient, actually. I wish I'd thought of that.

:idea: :idea: :idea: I have an idea--one that you've probably already considered and rejected--but I'll say it anyway just in case... I'm wondering how hard it would be to do a first pass through the XML before keeping it as a data structure, swapping the @shortcuts with full unids. I was thinking that this could be implemented with an XML file preprocessor that loads the file into memory and does a search and replace on the entity section.

I think that this would solve all existing and future anomalies with the @shortcuts. Though I suppose if you already have most of the data structures converted it might not be needed.
Locked