From 3d1ad2b674bca1b1608f2b9a63afbc1b76af20a7 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Tue, 3 Mar 2015 19:28:15 -0500 Subject: [PATCH] Autosave when changing planets and when buying/selling. Previously, it just saved after completing a mission, so it wasn't something you could really rely on. Now it saves every time something changes. --- src/game.cpp | 1 - src/intermission.cpp | 19 ++++++++++++++----- src/missions.cpp | 7 +++++-- src/player.cpp | 26 ++++++++++++++++++++++++++ src/script.cpp | 6 ++++-- src/shop.cpp | 2 ++ 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 0e08fe1..2c0cf93 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -335,7 +335,6 @@ int mainGameLoop() if (currentGame.area < 26) { updateSystemStatus(); - saveGame(0); } diff --git a/src/intermission.cpp b/src/intermission.cpp index 0bc20eb..bc3baaf 100644 --- a/src/intermission.cpp +++ b/src/intermission.cpp @@ -273,7 +273,10 @@ static bool showSystem(float x, float y, bool selectable) r.y -= (systemPlanet[planet].image->h / 2); blit(systemPlanet[planet].image, r.x, r.y); - if (selectable && collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, r.x, r.y, systemPlanet[planet].image->w, systemPlanet[planet].image->h)) + if (selectable && + collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, + r.x, r.y, systemPlanet[planet].image->w, + systemPlanet[planet].image->h)) { drawString(systemPlanet[planet].name, -1, 545, FONT_WHITE); if ((engine.keyState[KEY_FIRE])) @@ -284,6 +287,7 @@ static bool showSystem(float x, float y, bool selectable) currentGame.destinationPlanet = planet; currentGame.area = systemPlanet[currentGame.stationedPlanet].missionNumber; strcpy(currentGame.stationedName, systemPlanet[currentGame.stationedPlanet].name); + saveGame(0); } else { @@ -740,13 +744,16 @@ int galaxyMap() currentGame.stationedPlanet = currentGame.destinationPlanet; currentGame.distanceCovered = 0; player.shield = player.maxShield; - sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name); - strcpy(currentGame.stationedName, systemPlanet[currentGame.stationedPlanet].name); + sprintf(string, "Stationed At: %s", + systemPlanet[currentGame.stationedPlanet].name); + strcpy(currentGame.stationedName, + systemPlanet[currentGame.stationedPlanet].name); SDL_FreeSurface(iconInfo[9].image); iconInfo[9].image = textSurface(string, FONT_WHITE); updateCommsSurface(commsSurface); section = 1; redrawBackGround = true; + saveGame(0); } else if (interceptionChance > 0) { @@ -768,10 +775,12 @@ int galaxyMap() { for (int i = 0 ; i < 8 ; i++) { - // if the mission has been completed, there is no "Start Next Mission" icon + // if the mission has been completed, there is no + // "Start Next Mission" icon if (i == 0) { - if ((currentGame.stationedPlanet == currentGame.destinationPlanet) && (systemPlanet[currentGame.stationedPlanet].missionCompleted != 0)) + if ((currentGame.stationedPlanet == currentGame.destinationPlanet) && + (systemPlanet[currentGame.stationedPlanet].missionCompleted != 0)) continue; else if (currentGame.stationedPlanet == currentGame.destinationPlanet) blit(shape[1], 80 + (i * 90), 500); diff --git a/src/missions.cpp b/src/missions.cpp index 27d4ff4..aefb8e2 100644 --- a/src/missions.cpp +++ b/src/missions.cpp @@ -776,19 +776,22 @@ void missionBriefScreen() if (currentGame.area != MAX_MISSIONS - 1) { - drawString("PRESS CTRL TO CONTINUE...", -1, 550, FONT_WHITE); + drawString("PRESS ENTER TO CONTINUE...", -1, 550, FONT_WHITE); updateScreen(); flushInput(); engine.done = 0; engine.keyState[KEY_FIRE] = 0; + engine.keyState[KEY_ALTFIRE] = 0; + engine.keyState[KEY_ESCAPE] = 0; while (true) { delayFrame(); getPlayerInput(); - if ((engine.keyState[KEY_FIRE])) + if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) || + (engine.keyState[KEY_ESCAPE])) break; } diff --git a/src/player.cpp b/src/player.cpp index d8db72e..75c4c93 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -367,25 +367,51 @@ void flushInput() static enum keys mapkey(uint32_t code) { switch (code) { case SDLK_UP: + case SDLK_KP_8: return KEY_UP; case SDLK_DOWN: + case SDLK_KP_2: + case SDLK_KP_5: return KEY_DOWN; case SDLK_LEFT: + case SDLK_KP_4: return KEY_LEFT; case SDLK_RIGHT: + case SDLK_KP_6: return KEY_RIGHT; case SDLK_LCTRL: case SDLK_RCTRL: case SDLK_RETURN: + case SDLK_z: + case SDLK_c: + case SDLK_f: + case SDLK_a: + case SDLK_SLASH: + case SDLK_COMMA: + case SDLK_1: + case SDLK_3: + case SDLK_KP_0: return KEY_FIRE; case SDLK_SPACE: + case SDLK_x: + case SDLK_s: + case SDLK_d: + case SDLK_PERIOD: + case SDLK_2: + case SDLK_KP_1: return KEY_ALTFIRE; case SDLK_LSHIFT: case SDLK_RSHIFT: + case SDLK_LALT: + case SDLK_RALT: + case SDLK_KP_7: + case SDLK_KP_9: return KEY_SWITCH; case SDLK_p: return KEY_PAUSE; case SDLK_ESCAPE: + case SDLK_q: + case SDLK_BACKSPACE: return KEY_ESCAPE; case SDLK_F11: return KEY_FULLSCREEN; diff --git a/src/script.cpp b/src/script.cpp index 64d39f7..a49d8b5 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -186,7 +186,8 @@ void doCutscene(int scene) updateScreen(); clearScreen(black); - engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0; + engine.keyState[KEY_FIRE] = 0; + engine.keyState[KEY_ALTFIRE] = 0; engine.ssx = -0.5; engine.ssy = 0; @@ -300,7 +301,8 @@ void doCutscene(int scene) delayFrame(); - if (engine.keyState[KEY_ESCAPE]) + if ((engine.keyState[KEY_ESCAPE]) || (engine.keyState[KEY_FIRE]) || + (engine.keyState[KEY_ALTFIRE])) break; } diff --git a/src/shop.cpp b/src/shop.cpp index 9fa0a69..d04abbb 100644 --- a/src/shop.cpp +++ b/src/shop.cpp @@ -615,6 +615,7 @@ static void buy(int i) if (!engine.cheatCash) currentGame.cash -= shopItems[i].price; + saveGame(0); } static void sell(int i) @@ -724,6 +725,7 @@ static void sell(int i) adjustShopPrices(); currentGame.cash += (shopItems[i].price / 2); + saveGame(0); } void showShop()