[d2x - Windows] 256 Extra Life limit?
It appears that once you get to 255 extra lives, the next one you get resets you to 0. If you die in this state, it says Game Over, but you still respawn with 254 lives. However, if you go from 0 to 1, and then die twice, the game truly does end. So long, 255 other lives!

And yes, I actually got that number legitimately  Big Grin Playing through Plutonian Shores on Insane, up to Fear Factory, is where I ran into it. On Insane, you do a LOT of killing, especially when farming matcens for items. So the extra lives roll in quite frequently, even if you die a few times in each level.

I'm running 0.59.100 on Windows, but given how unlikely it is for most people to ever run into this bug in the first place, I'm betting it's been a bug in Descent since the very beginning and someone just used a byte to track lives instead of an int or something, lol.

Since this is probably a huge pain to test without a level that has 500 extra lives in it, I'm attaching a save I'm using if you want to try it out. Just kill the Seeker right in front of you with a Mercury missile and it'll happen. Remove the .txt extension from the save beforehand, of course.

Plutonian Shores DL here: http://www.enspiar.com/dmdb/viewMission.php?id=1615

Attached Files
.zip   255LivesSave.zip (Size: 15.06 KB / Downloads: 1)
Confirmed through source inspection. You are correct: an unsigned byte was used for the counter. According to history, this was last touched when Bradley imported the original Parallax sources, so this almost certainly impacts the original game. I can fix the runtime part easily enough by raising it to an unsigned short (cap: 65535) or unsigned int (cap: 2**32 - 1), but I can't fix the savegame part so readily. Due to data layout, raising it to a short is free. There is a one-byte hole nearby that is currently unused. Raising to an int is also free, but requires a bit more reorganization.

I could rig the savegame to cap you at 255 lives on save, so as long as you don't reload while having so many spare lives, you would be fine. If you did reload, your count would be reduced, but that's still better than your current situation.

The "Game Over" and still respawn is weird. I see in the source how that would happen, I think. There is some strange logic that you get the message if your lives counter is < 2; the respawn itself is done by decrementing lives, then testing for zero and ending the game if the post-decrement count is exactly 0. So when you overflowed to exactly 0, the decrement brought you back down to 255, which was not 0, so it let you respawn.

Fixing that cosmetic issue should not be too hard.

Thank you for the level link, and for the save game. In this case, getting that many lives is very easy to do with a hacked build. Just make the player start with 255 lives instead of 3, and change the point threshold for the extra life bonus to a low value. Smile

This problem also impacts Descent 1.

Raise player life count storage from uint8_t to uint16_t should fix your problem. Fix bogus "Game Over" when dying with the maximum number of lives addresses the cosmetic issue. Try not to earn 64k extra lives. Wink
Excellent! Glad it was a simple fix (figured it probably would be).

I'd definitely appreciate a hacked save capped to 255 so it doesn't overflow if it's not too much trouble. Even if it doesn't increase anymore and can only start going back down, that's better than rolling over to 0 indeed. There's only about 8 more levels left for me in this run, so the odds of me needing to die ~30 times in each one are pretty low. Hopefully.
The fix above ("Raise player ...") includes that capping logic. Did you mean you want me to make and upload to you a hacked save restored to the correct life count?

With that change, your life counter can rise to UINT16_MAX (65535) during gameplay without issue. (You can still roll over to 0 if you exceed 64k extra lives, but I could clamp that if anyone hits that as a real problem.) At save time, I save the lesser of (your earned extra lives) or (255). You can save your game while your extra lives exceeds 255, and the running counter is preserved in memory. This allows you to save whenever you like, without penalty. You only lose those extras if you load that save game, since it cannot remember above 255. When you lose them, you drop down to 255 (approximately; the game has weird +/- 1 logic in places), not to ((actual lives) modulo 256) as mere truncation did. Additionally, once loaded, the counter is not clamped and you can rise above 255 again through your achievements in-game, again so long as you do not load. This is the best I can do without changing the savegame format in some way. Overhauling savegames has been on my task list for years, but I wanted to get other internal structures in order first.
Sure, that would be perfect!
Your saved life count looks reasonable as-is. I don't think there's anything I can do for you in that save file. Nothing I could change in it will encourage the game to do the right thing with future saves, and there is no data in the current save that seems to need modification. I could modify your saved life count downward in that save, so that you can gain a few more before you overflow. If that is not what you wanted, tell me what fields you want changed and their new values.

You need a new build of the game so that future save files are generated with the capping logic I added, and so that the runtime counter will not overflow as soon.
Ah, gotcha. Well don't worry about it then -- I'll just laugh this off for now and look for the next build when it becomes available. Thanks!

Forum Jump:

Users browsing this thread: 1 Guest(s)