The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
September 25, 2022, 06:27:56 am
Home Help Search Login Register
News: Paul & Fred have reached a settlement with Stardock!

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  Adding game states?
« previous next »
Pages: [1] Print
Author Topic: Adding game states?  (Read 1641 times)
waywardoctagon
*Many bubbles*
***
Offline Offline

Gender: Female
Posts: 142


More information...


View Profile
Adding game states?
« on: December 16, 2006, 05:15:16 am »

I want to add new game states.  (I think that's what they're called; I mean SHOFIXTI_VISITS, MAIDENS_ON_SHIP and the like.)  I tried just going into globdata.h and adding them into the list in the same format as the existing ones, but when I ran it and went to load a savegame(I get to the screen where you choose a game to load; it does this when I choose one and hit enter), it brings up an error message:

Quote
Microsoft Visual C++ Debug Library
Debug error!

Program: C:\build/sc2/uqmdebug.exe

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

(Press Retry to debug the application)

Abort   Retry   Ignore

(If I hit Abort or Ignore, it just exits; if I hit Retry it does the "[program] has encountered a problem and needs to close... Please tell Microsoft about this problem.  Send/Don't send" thing and closes.)

and

Code:
Assertion failed: sizeof (GSPtr->GameState) % 4 == 3, file ..\sc2code\load.c, line 354

appears in the debug window.  I looked at load.c and I don't understand what it's doing there--it kind of looks like it's checking that the number of bits allotted to those two is three more than divisible by four, but I don't see the significance.  (Is that what it's actually doing?  If so, why?  If not, what?)

What am I missing? 
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Adding game states?
« Reply #1 on: December 16, 2006, 05:55:23 am »

It's a sanity check.
When saving, one extra byte of padding is written to align the data that follows on a multiple of 4 bytes.
When loading, that extra byte needs to be read (or at least skipped), which is what the line after the assertion you mentioned does.
The assertion just makes sure that that byte of padding is appropriate. The assertion being triggered indicates an inconsistency in the program.

By adding extra "states" you increased the size of GameState, and in this case it changed the amount of padding that is required to make that size a multiple of 4 bytes.

As your savegames will be incompatible with the straight UQM savegames anyhow, you might as well forget about padding altogether; the 4 byte alignment is just there to ensure compatibility with existing savegames and serves no other practical purpose anymore.
Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
waywardoctagon
*Many bubbles*
***
Offline Offline

Gender: Female
Posts: 142


More information...


View Profile
Re: Adding game states?
« Reply #2 on: December 16, 2006, 06:02:14 am »

Ah, I see.  Thanks!

So, it's only a problem if I want to use old saves to test stuff.
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Adding game states?
« Reply #3 on: December 16, 2006, 06:11:15 am »

Well, the assertion is still there, and the size of your GameState has changed.
You can just rip out the assertion to make it work with your own save games.
You can also rip out the saving and loading of padding altogether.
Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
waywardoctagon
*Many bubbles*
***
Offline Offline

Gender: Female
Posts: 142


More information...


View Profile
Re: Adding game states?
« Reply #4 on: December 16, 2006, 06:18:20 am »

*nod*  I think I may do that.  It's just too convenient to be able to use the savegames.
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!