stephenjsweeney/blobwarsAttrition

Crash "ERROR: No such lookup value 2, prefix=FACING_"

Closed this issue · 7 comments

I was playing beach 3, I just got the heart and unlocked the battery powered doors, and the game crashed. Here is the output for the program:

2018-04-24 20:00:19.162 blobwarsAttrition[96592:673694] INFO: Locale is en_US
2018-04-24 20:00:19.163 blobwarsAttrition[96592:673694] INFO: Language is en
2018-04-24 20:00:19.163 blobwarsAttrition[96592:673694] INFO: Numeric is C
2018-04-24 20:00:19.163 blobwarsAttrition[96592:673694] INFO: atof(2.75) is 2.750000
2018-04-24 20:00:19.163 blobwarsAttrition[96592:673694] INFO: User home = /Users/leif
2018-04-24 20:00:19.636 blobwarsAttrition[96592:673694] INFO: 0 joysticks available
2018-04-24 20:16:47.863 blobwarsAttrition[96592:673694] WARN: WARNING:  (4) bad sprite frames - 3 > 1
2018-04-24 20:17:52.556 blobwarsAttrition[96592:673694] ERROR: No such lookup value 2, prefix=FACING_

I'd have to look at the code to be sure, but this almost looks like an of by one error.

Oh interesting. It looks like it was actually saving when it crashed. The only function that would be looking up "FACING_" is:

static void save(cJSON *root)
{
	cJSON_AddStringToObject(root, "type", "Bob");
	cJSON_AddNumberToObject(root, "x", world.bob->checkpoints[0].x);
	cJSON_AddNumberToObject(root, "y", world.bob->checkpoints[0].y);
	cJSON_AddStringToObject(root, "facing", getLookupName("FACING_", world.bob->facing));
}

Maybe it would make sense to have an optional default value that that function can take. And only call exit if one can't be found and no default value is given?

Also worth noting, when I restarted the game, it thought I had completed the mission, but forgot all of the items I'd collected. So I didn't get any mission complete screen, but could also quit and save any time I wanted.

I'm also not sure if it reset my life+battery counters. Or maybe its now permanently at +1 to what it was.

A value of 2 for FACING_ would imply that Bob was dying at the time that the game was saved:

https://github.com/stephenjsweeney/blobwarsAttrition/blob/master/src/defs.h#L158

Was this the case? It's the only reason he should've been in this state.

re: the mission inconsistent state - is this using the latest code in develop that is saving the game atomically?

Edit: now looking at the code, Bob may have also been in a stunned state. I'll see about resetting that when the game is saved.

Updated in the develop branch.

A value of 2 for FACING_ would imply that Bob was dying at the time that the game was saved:

I don't know for sure. I do know I got shot and was bouncing around(, or maybe it was enemies, the screen was very chaotic...) So its possible.

re: the mission inconsistent state - is this using the latest code in develop that is saving the game atomically?

IIRC, I was testing this under v1.1 in master.

Edit: now looking at the code, Bob may have also been in a stunned state. I'll see about resetting that when the game is saved.

Ah, okay, that would be more likely...being in a stunned state while winning the level.

Updated in the develop branch.

Okay cool. I'll see if I can reproduce there.

This seems to be fixed in the dev branch.