Make missiles more powerful. Save name of last mission star system.

This commit is contained in:
Steve 2015-10-30 07:22:49 +00:00
parent 2d5b346230
commit c506ad32cf
7 changed files with 21 additions and 10 deletions

View File

@ -17,7 +17,7 @@
{ {
"type" : "BT_MISSILE", "type" : "BT_MISSILE",
"damage" : 25, "damage" : 75,
"textureName" : "gfx/bullets/missile.png", "textureName" : "gfx/bullets/missile.png",
"sound" : "SND_MISSILE", "sound" : "SND_MISSILE",
"flags" : "BF_ENGINE+BF_EXPLODES" "flags" : "BF_ENGINE+BF_EXPLODES"

View File

@ -78,10 +78,7 @@ void initGalacticMap(void)
arrowTexture = getTexture("gfx/galaxy/arrow.png"); arrowTexture = getTexture("gfx/galaxy/arrow.png");
if (!selectedStarSystem) selectedStarSystem = getStarSystem(game.selectedStarSystem);
{
selectedStarSystem = game.starSystemHead.next;
}
updateStarSystemDescriptions(); updateStarSystemDescriptions();
@ -428,7 +425,11 @@ static void selectStarSystem(void)
missionListStart = 0; missionListStart = 0;
selectedMissionIndex = 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) static void drawStarSystemDetail(void)

View File

@ -65,6 +65,7 @@ extern void blitRotated(SDL_Texture *texture, int x, int y, int angle);
extern void initStatsDisplay(void); extern void initStatsDisplay(void);
extern void handleStatsKB(void); extern void handleStatsKB(void);
extern void updateStarSystemMissions(void); extern void updateStarSystemMissions(void);
extern StarSystem *getStarSystem(char *name);
extern App app; extern App app;
extern Colors colors; extern Colors colors;

View File

@ -25,6 +25,8 @@ void initGame(void)
memset(&game, 0, sizeof(Game)); memset(&game, 0, sizeof(Game));
game.starSystemTail = &game.starSystemHead; game.starSystemTail = &game.starSystemHead;
STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH);
} }
void resetGame(void) void resetGame(void)
@ -47,6 +49,8 @@ void resetGame(void)
} }
} }
} }
STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH);
} }
void destroyGame(void) void destroyGame(void)

View File

@ -239,6 +239,7 @@ typedef struct {
typedef struct { typedef struct {
StarSystem starSystemHead, *starSystemTail; StarSystem starSystemHead, *starSystemTail;
Mission *currentMission; Mission *currentMission;
char selectedStarSystem[MAX_NAME_LENGTH];
unsigned int stats[STAT_MAX]; unsigned int stats[STAT_MAX];
} Game; } Game;

View File

@ -27,17 +27,19 @@ static void loadChallenges(Mission *mission, cJSON *challengesCJSON);
void loadGame(void) void loadGame(void)
{ {
cJSON *root, *game; cJSON *root, *gameJSON;
char *text; char *text;
text = readFile(getSaveFilePath("game.save")); text = readFile(getSaveFilePath("game.save"));
root = cJSON_Parse(text); 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); cJSON_Delete(root);
free(text); free(text);

View File

@ -36,6 +36,8 @@ void saveGame(void)
gameJSON = cJSON_CreateObject(); gameJSON = cJSON_CreateObject();
cJSON_AddItemToObject(root, "game", gameJSON); cJSON_AddItemToObject(root, "game", gameJSON);
cJSON_AddStringToObject(gameJSON, "selectedStarSystem", game.selectedStarSystem);
saveStarSystems(gameJSON); saveStarSystems(gameJSON);
saveStats(gameJSON); saveStats(gameJSON);