Use saveDelay, to prevent premature saving while manually quitting levels.
This commit is contained in:
parent
6b2139b6ce
commit
74383264c2
|
@ -84,8 +84,7 @@ static void tick(void)
|
||||||
|
|
||||||
m = (MIA*)self;
|
m = (MIA*)self;
|
||||||
|
|
||||||
m->shudderTimer--;
|
if (--m->shudderTimer <= 0)
|
||||||
if (m->shudderTimer <= 0)
|
|
||||||
{
|
{
|
||||||
m->x = (m->tx + rand() % 4);
|
m->x = (m->tx + rand() % 4);
|
||||||
m->shudderTimer = 2;
|
m->shudderTimer = 2;
|
||||||
|
@ -93,12 +92,13 @@ static void tick(void)
|
||||||
|
|
||||||
if (!m->isMissionTarget)
|
if (!m->isMissionTarget)
|
||||||
{
|
{
|
||||||
m->starTimer--;
|
if (--m->starTimer <= 0)
|
||||||
if (m->starTimer <= 0)
|
|
||||||
{
|
{
|
||||||
addMIATeleportStars(m->x + rand() % m->w, m->y + rand() % m->h);
|
addMIATeleportStars(m->x + rand() % m->w, m->y + rand() % m->h);
|
||||||
m->starTimer = 1;
|
m->starTimer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.saveDelay = FPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,8 @@ static void preTeleport(void)
|
||||||
m->flags |= (EF_NO_CLIP | EF_WEIGHTLESS);
|
m->flags |= (EF_NO_CLIP | EF_WEIGHTLESS);
|
||||||
m->dy = -5;
|
m->dy = -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.saveDelay = FPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void teleport(void)
|
static void teleport(void)
|
||||||
|
@ -147,6 +149,8 @@ static void teleport(void)
|
||||||
updateObjective("MIA");
|
updateObjective("MIA");
|
||||||
m->alive = ALIVE_DEAD;
|
m->alive = ALIVE_DEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.saveDelay = FPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void load(cJSON *root)
|
static void load(cJSON *root)
|
||||||
|
|
|
@ -467,6 +467,7 @@ typedef struct {
|
||||||
int helperItemTimer;
|
int helperItemTimer;
|
||||||
int spawnInterval;
|
int spawnInterval;
|
||||||
int numToSpawn;
|
int numToSpawn;
|
||||||
|
int saveDelay;
|
||||||
Bob *bob;
|
Bob *bob;
|
||||||
Boss *boss;
|
Boss *boss;
|
||||||
Entity *entityToTrack;
|
Entity *entityToTrack;
|
||||||
|
|
|
@ -138,6 +138,7 @@ void doEntities(void)
|
||||||
|
|
||||||
if (self->flags & EF_TELEPORTING)
|
if (self->flags & EF_TELEPORTING)
|
||||||
{
|
{
|
||||||
|
world.saveDelay = FPS;
|
||||||
handleTeleport();
|
handleTeleport();
|
||||||
prev = self;
|
prev = self;
|
||||||
continue;
|
continue;
|
||||||
|
@ -235,6 +236,11 @@ void doEntities(void)
|
||||||
self->die();
|
self->die();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self->alive == ALIVE_DYING)
|
||||||
|
{
|
||||||
|
world.saveDelay = FPS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(self->flags & (EF_TELEPORTING | EF_GONE)))
|
if (!(self->flags & (EF_TELEPORTING | EF_GONE)))
|
||||||
|
|
|
@ -139,6 +139,12 @@ void initWorld(void)
|
||||||
app.restrictTrophyAlert = 1;
|
app.restrictTrophyAlert = 1;
|
||||||
|
|
||||||
endSectionTransition();
|
endSectionTransition();
|
||||||
|
|
||||||
|
/*
|
||||||
|
startMission();
|
||||||
|
world.bob->x = 17 * MAP_TILE_SIZE;
|
||||||
|
world.bob->y = 89 * MAP_TILE_SIZE;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
|
@ -147,6 +153,8 @@ static void logic(void)
|
||||||
{
|
{
|
||||||
world.betweenTimer = 0;
|
world.betweenTimer = 0;
|
||||||
|
|
||||||
|
world.saveDelay = limit(world.saveDelay - 1, 0, FPS);
|
||||||
|
|
||||||
switch (world.state)
|
switch (world.state)
|
||||||
{
|
{
|
||||||
case WS_START:
|
case WS_START:
|
||||||
|
@ -166,6 +174,7 @@ static void logic(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_COMPLETE:
|
case WS_COMPLETE:
|
||||||
|
case WS_QUIT:
|
||||||
doWorldComplete();
|
doWorldComplete();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -516,13 +525,14 @@ static void doWorldComplete(void)
|
||||||
{
|
{
|
||||||
world.missionCompleteTimer--;
|
world.missionCompleteTimer--;
|
||||||
|
|
||||||
if (world.missionCompleteTimer == 0)
|
if (world.missionCompleteTimer <= 0 && world.saveDelay <= 0)
|
||||||
{
|
{
|
||||||
|
dropCarriedItems();
|
||||||
|
|
||||||
initPostMission();
|
initPostMission();
|
||||||
}
|
}
|
||||||
else if (world.missionCompleteTimer == FPS * 1.5)
|
else if (world.missionCompleteTimer == FPS * 1.5)
|
||||||
{
|
{
|
||||||
dropCarriedItems();
|
|
||||||
world.bob->flags |= EF_GONE;
|
world.bob->flags |= EF_GONE;
|
||||||
addTeleportStars((Entity*)world.bob);
|
addTeleportStars((Entity*)world.bob);
|
||||||
playSound(SND_TELEPORT, world.bob->uniqueId % MAX_SND_CHANNELS);
|
playSound(SND_TELEPORT, world.bob->uniqueId % MAX_SND_CHANNELS);
|
||||||
|
@ -878,7 +888,7 @@ void quitMission(void)
|
||||||
{
|
{
|
||||||
resume();
|
resume();
|
||||||
stopMusic();
|
stopMusic();
|
||||||
world.state = WS_COMPLETE;
|
world.state = WS_QUIT;
|
||||||
world.missionCompleteTimer = (FPS * 1.5) + 1;
|
world.missionCompleteTimer = (FPS * 1.5) + 1;
|
||||||
|
|
||||||
if (world.missionType == MT_TRAINING)
|
if (world.missionType == MT_TRAINING)
|
||||||
|
@ -926,6 +936,8 @@ void autoCompleteMission(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
world.state = WS_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroyWorld(void)
|
void destroyWorld(void)
|
||||||
|
|
|
@ -116,6 +116,7 @@ extern int rrnd(int low, int high);
|
||||||
extern void showWidgetGroup(char *group);
|
extern void showWidgetGroup(char *group);
|
||||||
extern void startSectionTransition(void);
|
extern void startSectionTransition(void);
|
||||||
extern void stopMusic(void);
|
extern void stopMusic(void);
|
||||||
|
extern float limit(float i, float a, float b);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Camera camera;
|
extern Camera camera;
|
||||||
|
|
Loading…
Reference in New Issue