90 lines · 2.1 KB · C
RawDownload
#include "data.h" #include <string.h>#include "util.h"#include "loader.h"#include "datatypes.h"#include "doors.h"#include "terminals.h"#include "mazes.h"#include "chapters.h"#include "nodes.h"#include "walkthrough.h" /*Copyright (c) 2013-2021 Devine Lu Linvega2018 web port by rezmason2021 C89 port by rezmason Permission to use, copy, modify, and distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE.*/ static char *sectionDelimeters = "/*"; intData_Init(){	int success = 1;	char *data = NULL; 	if(Loader_LoadText(&data, "data/data.txt")) {		char *sectionSave = NULL;		char *headerSection;		char *section; 		headerSection = getNextToken(data, sectionDelimeters, &sectionSave);		while(headerSection != NULL && success) {			section = getNextToken(NULL, sectionDelimeters, &sectionSave);			if(strcmp(headerSection, "TERMINALS") == 0) {				success &= Terminals_Init(section);			} else if(strcmp(headerSection, "DOORS") == 0) {				success &= Doors_Init(section);			} else if(strcmp(headerSection, "MAZES") == 0) {				success &= Mazes_Init(section);			} else if(strcmp(headerSection, "NODES") == 0) {				success &= Nodes_Init(section);			} else if(strcmp(headerSection, "CHAPTERS") == 0) {				success &= Chapters_Init(section);			} else if(strcmp(headerSection, "WALKTHROUGH") == 0) {				success &= Walkthrough_Init(section);			}			headerSection = getNextToken(NULL, sectionDelimeters, &sectionSave);		}	} else {		success = 0;	}	free(data); 	return success;} voidData_Quit(){	Nodes_Quit();	Doors_Quit();	Terminals_Quit();	Mazes_Quit();	Chapters_Quit();	Walkthrough_Quit();} voidData_ResetState(GameState *state){	int windowW = state->windowW;	int windowH = state->windowH;	memset(state, 0, sizeof(GameState));	state->windowW = windowW;	state->windowH = windowH;	state->audio = 1;	Nodes_Reset(state);	Terminals_Reset(state);	Mazes_Reset(state);	Chapters_Reset(state);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t