From c506ad32cf8b99acfc0acbd2e276038921aa0401 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 30 Oct 2015 07:22:49 +0000 Subject: [PATCH] Make missiles more powerful. Save name of last mission star system. --- data/battle/bullets.json | 2 +- src/galaxy/galacticMap.c | 11 ++++++----- src/galaxy/galacticMap.h | 1 + src/game/game.c | 4 ++++ src/structs.h | 1 + src/system/load.c | 10 ++++++---- src/system/save.c | 2 ++ 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/data/battle/bullets.json b/data/battle/bullets.json index 7fca7fa..0eeeefd 100644 --- a/data/battle/bullets.json +++ b/data/battle/bullets.json @@ -17,7 +17,7 @@ { "type" : "BT_MISSILE", - "damage" : 25, + "damage" : 75, "textureName" : "gfx/bullets/missile.png", "sound" : "SND_MISSILE", "flags" : "BF_ENGINE+BF_EXPLODES" diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 6d44f71..7b37fe1 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -78,10 +78,7 @@ void initGalacticMap(void) arrowTexture = getTexture("gfx/galaxy/arrow.png"); - if (!selectedStarSystem) - { - selectedStarSystem = game.starSystemHead.next; - } + selectedStarSystem = getStarSystem(game.selectedStarSystem); updateStarSystemDescriptions(); @@ -428,7 +425,11 @@ static void selectStarSystem(void) missionListStart = 0; selectedMissionIndex = 0; - viewingSystem = selectedStarSystem->totalMissions > 0; + if (selectedStarSystem->totalMissions > 0) + { + viewingSystem = 1; + STRNCPY(game.selectedStarSystem, selectedStarSystem->name, MAX_NAME_LENGTH); + } } static void drawStarSystemDetail(void) diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 1e9388a..f7a3489 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -65,6 +65,7 @@ extern void blitRotated(SDL_Texture *texture, int x, int y, int angle); extern void initStatsDisplay(void); extern void handleStatsKB(void); extern void updateStarSystemMissions(void); +extern StarSystem *getStarSystem(char *name); extern App app; extern Colors colors; diff --git a/src/game/game.c b/src/game/game.c index 638afb5..96d5531 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -25,6 +25,8 @@ void initGame(void) memset(&game, 0, sizeof(Game)); game.starSystemTail = &game.starSystemHead; + + STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH); } void resetGame(void) @@ -47,6 +49,8 @@ void resetGame(void) } } } + + STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH); } void destroyGame(void) diff --git a/src/structs.h b/src/structs.h index 71ef9e0..8f2fd94 100644 --- a/src/structs.h +++ b/src/structs.h @@ -239,6 +239,7 @@ typedef struct { typedef struct { StarSystem starSystemHead, *starSystemTail; Mission *currentMission; + char selectedStarSystem[MAX_NAME_LENGTH]; unsigned int stats[STAT_MAX]; } Game; diff --git a/src/system/load.c b/src/system/load.c index 7281667..79bab6c 100644 --- a/src/system/load.c +++ b/src/system/load.c @@ -27,17 +27,19 @@ static void loadChallenges(Mission *mission, cJSON *challengesCJSON); void loadGame(void) { - cJSON *root, *game; + cJSON *root, *gameJSON; char *text; text = readFile(getSaveFilePath("game.save")); root = cJSON_Parse(text); - game = cJSON_GetObjectItem(root, "game"); + gameJSON = cJSON_GetObjectItem(root, "game"); - loadStarSystems(cJSON_GetObjectItem(game, "starSystems")); + STRNCPY(game.selectedStarSystem, cJSON_GetObjectItem(gameJSON, "selectedStarSystem")->valuestring, MAX_NAME_LENGTH); - loadStats(cJSON_GetObjectItem(game, "stats")); + loadStarSystems(cJSON_GetObjectItem(gameJSON, "starSystems")); + + loadStats(cJSON_GetObjectItem(gameJSON, "stats")); cJSON_Delete(root); free(text); diff --git a/src/system/save.c b/src/system/save.c index d95ae5d..bf16617 100644 --- a/src/system/save.c +++ b/src/system/save.c @@ -36,6 +36,8 @@ void saveGame(void) gameJSON = cJSON_CreateObject(); cJSON_AddItemToObject(root, "game", gameJSON); + cJSON_AddStringToObject(gameJSON, "selectedStarSystem", game.selectedStarSystem); + saveStarSystems(gameJSON); saveStats(gameJSON);