Use app.saveGame rather than forcing a save (trophy unlocks can cause saving to happen twice in a row).

This commit is contained in:
Steve 2016-05-12 11:41:03 +01:00
parent 2aa917ac59
commit 64d88faec8
10 changed files with 14 additions and 6 deletions

View File

@ -390,7 +390,7 @@ static void postBattle(void)
game.currentMission->completed = (battle.status == MS_COMPLETE || !battle.numObjectivesTotal);
saveGame();
app.saveGame = 1;
}
void destroyBattle(void)

View File

@ -87,7 +87,6 @@ extern void runScriptFunction(const char *format, ...);
extern void doSpawners(void);
extern void doTrophyAlerts(void);
extern void drawTrophyAlert(void);
extern void saveGame(void);
extern App app;
extern Battle battle;

View File

@ -71,7 +71,7 @@ void initChallengeHome(void)
awardStatsTrophies();
saveGame();
app.saveGame = 1;
app.delegate.logic = &logic;
app.delegate.draw = &draw;

View File

@ -44,7 +44,6 @@ extern void drawText(int x, int y, int size, int align, SDL_Color c, const char
extern void drawWidgets(char *groupName);
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
extern Widget *getWidget(const char *name, const char *group);
extern void saveGame(void);
extern void initTitle(void);
extern void initStatsDisplay(void);
extern void drawOptions(void);

View File

@ -93,7 +93,7 @@ void initGalacticMap(void)
awardStatsTrophies();
saveGame();
app.saveGame = 1;
pulseTimer = 0;

View File

@ -33,7 +33,6 @@ extern void loadMission(char *filename);
extern SDL_Texture *getTexture(char *filename);
extern void startSectionTransition(void);
extern void endSectionTransition(void);
extern void saveGame(void);
extern void blit(SDL_Texture *t, int x, int y, int centered);
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
extern void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a);

View File

@ -218,6 +218,8 @@ void awardTrophy(char *id)
t->notify = 1;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Awarding trophy '%s'", id);
app.saveGame = 1;
}
if (!t->awarded)

View File

@ -163,6 +163,13 @@ int main(int argc, char *argv[])
expireTextTimer = SDL_GetTicks() + (1000 * 10);
}
/* trophy unlocks might cause the game to save several times in one frame */
if (app.saveGame)
{
saveGame();
app.saveGame = 0;
}
/* always zero the mouse motion */
app.mouse.dx = app.mouse.dy = 0;

View File

@ -51,6 +51,7 @@ extern void doKeyUp(SDL_KeyboardEvent *event);
extern void createScreenshotFolder(void);
extern int isControl(int type);
extern void clearControl(int type);
extern void saveGame(void);
App app;
Colors colors;

View File

@ -460,6 +460,7 @@ typedef struct {
typedef struct {
int resetTimeDelta;
char saveDir[MAX_FILENAME_LENGTH];
int saveGame;
int winWidth;
int winHeight;
float scaleX;