Ejemplo n.º 1
0
void loadGame(void)
{
	cJSON *root, *gameJSON;
	char *text;

	text = readFile(getSaveFilePath(SAVE_FILENAME));
	root = cJSON_Parse(text);

	gameJSON = cJSON_GetObjectItem(root, "game");

	STRNCPY(game.selectedStarSystem, cJSON_GetObjectItem(gameJSON, "selectedStarSystem")->valuestring, MAX_NAME_LENGTH);

	loadStarSystems(cJSON_GetObjectItem(gameJSON, "starSystems"));

	loadChallenges(cJSON_GetObjectItem(gameJSON, "challenges"));

	loadStats(cJSON_GetObjectItem(gameJSON, "stats"));
	
	loadTrophies(cJSON_GetObjectItem(gameJSON, "trophies"));
	
	loadFighterStats(cJSON_GetObjectItem(gameJSON, "fighterStats"));

	cJSON_Delete(root);
	free(text);
}
Ejemplo n.º 2
0
Archivo: load.c Proyecto: nnesse/tbftss
static void loadMissions(cJSON *missionsCJSON)
{
	Mission *mission;
	cJSON *missionCJSON;
	
	for (missionCJSON = missionsCJSON->child ; missionCJSON != NULL ; missionCJSON = missionCJSON->next)
	{
		mission = getMission(cJSON_GetObjectItem(missionCJSON, "filename")->valuestring);
		
		mission->completed = cJSON_GetObjectItem(missionCJSON, "completed")->valueint;
		
		if (cJSON_GetObjectItem(missionCJSON, "challenges"))
		{
			loadChallenges(mission, cJSON_GetObjectItem(missionCJSON, "challenges"));
		}
	}
}