Source: src/cl_config.cc


Annotated List
Files
Globals
Hierarchy
Index
//global configuration of game si_config is based on this code :)
//class for reading configuration of game

using namespace std;

#include "cl_config.h"


void CONFIGURATION::init()
{
#ifdef HARD_DEBUG
	cout << "Configuration constructor" << endl;
#endif
	data[PARAM_DATAFILE] 	= DEFAULT_DATAFILE;
	data[PARAM_LANGUAGE] 	= DEFAULT_LANGUAGE;
	data[PARAM_FONT] 	= DEFAULT_FONT;
	data[PARAM_HERO_ANIM] 	= DEFAULT_HERO_ANIM;
	data[PARAM_SCREEN] 	= DEFAULT_SCREEN;
}

int CONFIGURATION::load(string fname)
{
	FILE *fp;
	char buff[MAX_LINE_LENGTH];
	string s;
	string a,b;
	int p;
	
	if(!exists(fname.c_str())) {
		cout << endl << "Warning: file doesn't exist (using"
			<< "implicit configuration)" << endl;
		return 1;
	}
	
	fp = fopen(fname.c_str(),"rb");
	while(fgets(buff, MAX_LINE_LENGTH - 1, fp)) {
		chop(buff);
		s = buff;
		if(check_syntax(s)) {
			p = s.find('=');
			a = remove_spaces(s.substr(0,p));
			b = remove_spaces(s.substr(p+1, s.length()));
			//cout << "[" <

Generated by: georgik on armada on Sat Jul 24 07:07:15 2004, using kdoc 2.0a54.