示例#1
0
bool CCourse::LoadTerrainTypes () {
	CSPList list(MAX_TERR_TYPES +10);

	if (!list.Load (param.terr_dir, "terrains.lst")) {
		Message ("could not load terrain types");
		return false;
	}

	TerrList.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		TerrList[i].textureFile = SPStrN (line, "texture", "");
		TerrList[i].sound = SPStrN (line, "sound", "");
		TerrList[i].starttex = SPIntN (line, "starttex", -1);
		TerrList[i].tracktex = SPIntN (line, "tracktex", -1);
		TerrList[i].stoptex = SPIntN (line, "stoptex", -1);
		TerrList[i].col = SPColor3N (line, "col", TColor3(1, 1, 1));
		TerrList[i].friction = SPFloatN (line, "friction", 0.5);
		TerrList[i].depth = SPFloatN (line, "depth", 0.01);
		TerrList[i].particles = SPBoolN (line, "part", false);
		TerrList[i].trackmarks = SPBoolN (line, "trackmarks", false);
		TerrList[i].texture = NULL;
		TerrList[i].shiny = SPBoolN(line, "shiny", false);
		TerrList[i].vol_type = SPIntN (line, "vol_type", 1);
	}
	return true;
}
示例#2
0
void CTexture::LoadTextureList () {
    int rep, id;
    string texfile, line, name;

    TextureIndex = "";
    CSPList list (200);
    if (list.Load (param.tex_dir, "textures.lst")) {
        for (int i=0; i<list.Count(); i++) {
            line = list.Line (i);
            name = SPStrN (line, "name", "");
            id = SPIntN (line, "id", 0);
            texfile = SPStrN (line, "file", "");
            rep = SPIntN (line, "repeat", 0);
            if (id >= 0 && id < MAX_COMMON_TEX) {
                if (rep>0) CommonTex[id] =
                        LoadMipmapTexture (param.tex_dir.c_str(), texfile.c_str(), rep);
                else CommonTex[id] =
                        LoadTexture (param.tex_dir.c_str(), texfile.c_str());
                if (CommonTex[id] > 0) {
                    TextureIndex = TextureIndex + "[" + name + "]" + Int_StrN (CommonTex[id]);
                    numTextures++;
                }
            } else Message ("wrong texture id in textures.lst");
        }
    } else Message ("failed to load common textures");
}
示例#3
0
bool CScore::LoadHighScore () {
	CSPList list (520);

	Scorelist.resize(Course.CourseList.size());

	if (!list.Load (param.config_dir, "highscore")) {
		Message ("could not load highscore list");
		return false;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		string course = SPStrN (line, "course", "unknown");
		TCourse* cidx = Course.GetCourse(course);

		TScore score;
		score.player = SPStrN (line, "plyr", "unknown");
		score.points = SPIntN (line, "pts", 0);
		score.herrings = SPIntN (line, "herr", 0);
		score.time = SPFloatN (line, "time", 0);

		AddScore (cidx, score);
	}
	return true;
}
示例#4
0
bool Str_BoolNX (const string &s, const bool def) {
	string decode = "[0]0[1]1[true]1[false]0";
	string valstr;
	if (def == true) valstr = SPStrN (decode, s, "1");
	else valstr = SPStrN (decode, s, "0");
	int val;
	istringstream is(valstr);
	is >> val;
	if (is.fail()) return def;
	return (val != 0);
}
示例#5
0
void CCharacter::LoadCharacterList () {
	CSPList list (MAX_CHARACTERS+2);
	string line, typestr, charpath, previewfile;
	int i;
	GLuint texid;

	if (!list.Load (param.char_dir, "characters.lst")) {
		Message ("could not load characters.lst");
		return;
	}

	numCharacters = 0;
	TCharacter *ch;
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		CharList[i].name = SPStrN (line, "name", "");
		CharList[i].dir = SPStrN (line, "dir", "");
		typestr = SPStrN (line, "type", "unknown");
		CharList[i].type = SPIntN (char_type_index, typestr, -1);

		charpath = param.char_dir + SEP + CharList[i].dir;
		if (DirExists (charpath.c_str())) {
			previewfile = charpath + SEP + "preview.png";
			texid = Tex.LoadMipmapTexture (previewfile.c_str(), 0);
			if (texid < 1) {
				Message ("could not load previewfile of character");					
//				texid = Tex.TexID (NO_PREVIEW);
			}
			
			ch = &CharList[i];
			ch->preview = texid;

			ch->shape = new CCharShape;
			if (ch->shape->Load (charpath, "shape.lst", false) == false) {
				free (ch->shape);
				ch->shape = NULL;
				Message ("could not load character shape");
			} else numCharacters++;

			ch->frames[0].Load (charpath, "start.lst"); 
			ch->finishframesok = true;
			ch->frames[1].Load (charpath, "finish.lst"); 
			if (ch->frames[1].loaded == false) ch->finishframesok = false;
			ch->frames[2].Load (charpath, "wonrace.lst"); 
			if (ch->frames[2].loaded == false) ch->finishframesok = false;
			ch->frames[3].Load (charpath, "lostrace.lst"); 
			if (ch->frames[3].loaded == false) ch->finishframesok = false;
		}
	}
}
示例#6
0
void CPlayers::LoadAvatars () {
	CSPList list (MAX_AVATARS);
	int i;
	string line, filename;
	GLuint texid;

	if (!list.Load (param.player_dir, "avatars.lst")) {
		Message ("could not load avators.lst");
		return;
	}

	AvatarIndex = "";
	numAvatars = 0;
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		filename = SPStrN (line, "file", "unknown");
		texid = Tex.LoadTexture (param.player_dir, filename);
		if (texid > 0) {
			avatars[numAvatars].filename = filename;
			avatars[numAvatars].texid = texid;
			AvatarIndex += "[" + filename + "]";
			AvatarIndex += Int_StrN (texid);
			numAvatars++;
		}
	}
}
示例#7
0
void LoadCreditList () {
	CSPList list(MAX_CREDITS);

	string creditfile;
	int i;
	double offset;
	string item;
	string line;

	if (!list.Load (param.data_dir, "credits.lst")) {
		Message ("could not load credits list");
		return;
	}

	for (i=0; i<list.Count(); i++) {
		line = list.Line(i);
		CreditList[i].text = SPStrN (line, "text", "");

		offset = SPFloatN (line, "offs", 0) * OFFS_SCALE_FACTOR * param.scale;
		if (i>0) CreditList[i].offs = CreditList[i-1].offs + (int)offset;
		else CreditList[i].offs = offset;

		CreditList[i].col = SPIntN (line, "col", 0);
		CreditList[i].size = SPFloatN (line, "size", 1.0);
		numCredits = i + 1;
	}
}
示例#8
0
void CEnvironment::LoadLight () {
	static const string idxstr = "[fog]-1[0]0[1]1[2]2[3]3[4]4[5]5[6]6";

	CSPList list(24);
	if (!list.Load (EnvDir, "light.lst")) {
		Message ("could not load light file", "");
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		string item = SPStrN (line, "light", "none");
		int idx = SPIntN (idxstr, item, -1);
		if (idx < 0) {
			fog.is_on = SPBoolN (line, "fog", true);
			fog.start = SPFloatN (line, "fogstart", 20);
			fog.end = SPFloatN (line, "fogend", param.forward_clip_distance);
			fog.height = SPFloatN (line, "fogheight", 0);
			SPArrN (line, "fogcol", fog.color, 4, 1);
			fog.part_color = SPColorN (line, "partcol", def_partcol);
		} else if (idx < 4) {
			lights[idx].is_on = true;
			SPArrN (line, "amb", lights[idx].ambient, 4, 1);
			SPArrN (line, "diff", lights[idx].diffuse, 4, 1);
			SPArrN (line, "spec", lights[idx].specular, 4, 1);
			SPArrN (line, "pos", lights[idx].position, 4, 1);
		}
	}
}
void CCharacter::LoadCharacterList () {
	CSPList list (MAX_CHARACTERS);

	if (!list.Load (param.char_dir, "characters.lst")) {
		Message ("could not load characters.lst");
		return;
	}

	CharList.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		CharList[i].name = SPStrN (line, "name");
		CharList[i].dir = SPStrN (line, "dir");
		string typestr = SPStrN (line, "type", "unknown");
		CharList[i].type = SPIntN (char_type_index, typestr, -1);

		string charpath = param.char_dir + SEP + CharList[i].dir;
		if (DirExists (charpath.c_str())) {
			string previewfile = charpath + SEP "preview.png";

			TCharacter* ch = &CharList[i];
			ch->preview = new TTexture();
			if (!ch->preview->LoadMipmap(previewfile, false)) {
				Message ("could not load previewfile of character");
//				texid = Tex.TexID (NO_PREVIEW);
			}


			ch->shape = new CCharShape;
			if (ch->shape->Load (charpath, "shape.lst", false) == false) {
				delete ch->shape;
				ch->shape = NULL;
				Message ("could not load character shape");
			}

			ch->frames[0].Load (charpath, "start.lst");
			ch->finishframesok = true;
			ch->frames[1].Load (charpath, "finish.lst");
			if (ch->frames[1].loaded == false) ch->finishframesok = false;
			ch->frames[2].Load (charpath, "wonrace.lst");
			if (ch->frames[2].loaded == false) ch->finishframesok = false;
			ch->frames[3].Load (charpath, "lostrace.lst");
			if (ch->frames[3].loaded == false) ch->finishframesok = false;
		}
	}
}
示例#10
0
bool CFont::LoadFontlist() {
	CSPList list;
	if (!list.Load(param.font_dir, "fonts.lst")) {
		fonts.push_back(new sf::Font()); // Insert an empty font, otherwise ETR will crash
		return false;
	}

	for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
		std::string fontfile = SPStrN(*line, "file");
		std::string name = SPStrN(*line, "name");

		int ftidx = LoadFont(name, param.font_dir, fontfile);
		if (ftidx < 0) {
			Message("couldn't load font", name);
		}
	}
	return true;
}
示例#11
0
void LoadConfigFile () {
	CSPList list(4);
	string line;
	if (!list.Load (param.configfile)) {
		Message ("Could not load 'options'");
		return;
	}

	for (int i=0; i<list.Count(); i++) {
		line = list.Line(i);

		param.fullscreen = SPIntN (line, "fullscreen", 0);
		param.res_type = SPIntN (line, "res_type", 0);
		param.perf_level = SPIntN (line, "detail_level", 0);
		param.language = SPIntN (line, "language", 0);
		param.sound_volume = SPIntN (line, "sound_volume", 100);
		param.music_volume = SPIntN (line, "music_volume", 20);

		param.forward_clip_distance = SPIntN (line, "forward_clip_distance", 75);
		param.backward_clip_distance = SPIntN (line, "backward_clip_distance", 20);
		param.fov = SPIntN (line, "fov", 60);
		param.bpp_mode = SPIntN (line, "bpp_mode", 1);
		param.tree_detail_distance = SPIntN (line, "tree_detail_distance", 20);
		param.tux_sphere_divisions = SPIntN (line, "tux_sphere_divisions", 10);
		param.tux_shadow_sphere_divisions = SPIntN (line, "tux_shadow_sphere_div", 3);
		param.course_detail_level = SPIntN (line, "course_detail_level", 75);

		param.use_papercut_font = SPIntN (line, "use_papercut_font", true);
		param.ice_cursor = SPIntN (line, "ice_cursor", true);
		param.full_skybox = SPIntN (line, "full_skybox", false);
		param.audio_freq = SPIntN (line, "audio_freq", 22050);
		param.audio_buffer_size = SPIntN (line, "audio_buffer_size", 512);
		param.restart_on_res_change = SPIntN (line, "restart_on_res_change", 0);
		param.use_quad_scale = SPIntN (line, "use_quad_scale", 0);

		param.menu_music = SPStrN (line, "menu_music", "start_1");
		param.credits_music = SPStrN (line, "credits_music", "credits_1");
		param.config_music = SPStrN (line, "config_music", "options_1");
	}		
}
示例#12
0
bool CCourse::LoadObjectTypes () {
	CSPList list (MAX_OBJECT_TYPES+10);

	if (!list.Load (param.obj_dir, "object_types.lst")) {
		Message ("could not load object types");
		return false;
	}

	ObjTypes.resize(list.Count());

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
	    ObjTypes[i].name = SPStrN (line, "name", "");
		ObjTypes[i].textureFile = ObjTypes[i].name;
		ObjTypes[i].texture = NULL;

		ObjTypes[i].drawable = SPBoolN (line, "draw", true);
		if (ObjTypes[i].drawable) {
			ObjTypes[i].textureFile = SPStrN (line, "texture", "");
		}
		ObjTypes[i].collectable = SPBoolN (line, "snap", -1) != 0;
		if (ObjTypes[i].collectable == 0) {
			ObjTypes[i].collectable = -1;
		}

		ObjTypes[i].collidable = SPBoolN (line, "coll", false);
		ObjTypes[i].reset_point = SPBoolN (line, "reset", false);
		ObjTypes[i].use_normal = SPBoolN (line, "usenorm", false);

		if (ObjTypes[i].use_normal) {
			ObjTypes[i].normal = SPVector3N (line, "norm", TVector3(0, 1, 0));
			NormVector ((ObjTypes[i].normal));
		}
		ObjTypes[i].poly = 1;
	}
	list.MakeIndex (ObjectIndex, "name");
	return true;
}
示例#13
0
bool CPlayers::LoadPlayers () {
	if (FileExists (param.config_dir, "players") == false) {
		SetDefaultPlayers ();
		Message ("file 'players' does not exist, set default players");
		return false;
	}

	CSPList list(MAX_PLAYERS);
	if (list.Load (param.config_dir, "players") == false) {
		SetDefaultPlayers ();
		Message ("could not load players list, set default players");
		return false;
	}

	g_game.start_player = 0;
	g_game.start_character = 0;
	plyr.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		plyr[i].name = SPStrN (line, "name", "unknown");
		plyr[i].funlocked = SPStrN (line, "unlocked");
		plyr[i].avatar = FindAvatar(SPStrN(line, "avatar"));
		plyr[i].ctrl = NULL;
		int active = SPIntN (line, "active", 0);
		int ch = SPIntN(line, "character", 0);
		if (ch > 0) plyr[i].character = ch;
		if (active > 0) {
			g_game.start_player = i;
			if (ch > 0) g_game.start_character = ch;
		}
	}
	if (plyr.empty()) {
		SetDefaultPlayers ();
		Message ("player file doesn't contain a player, set default players");
		return false;
	}
	return true;
}
void CTranslation::LoadLanguages () {
	CSPList list (MAX_LANGUAGES);

	languages_ok = false;
	if (!list.Load (param.trans_dir, "languages.lst")) {
		Message ("could not load language list");
		return;
	}

	languages.resize(list.Count()+1);
	languages[0].lang = "en_GB";
	languages[0].language = "English";
	for (size_t i=1; i<list.Count()+1; i++) {
		const string& line = list.Line(i-1);
		languages[i].lang = SPStrN (line, "lang", "en_GB");
		languages[i].language = SPStrN (line, "language", "English");
		LangIndex[languages[i].lang] = i;
	}
	if (!languages.empty()) languages_ok = true;

	if(param.language == string::npos)
		param.language = GetSystemDefaultLangIdx();
}
示例#15
0
void CCourse::LoadItemList () {
	CSPList list (16000);

	if (!list.Load (CourseDir, "items.lst")) {
		Message ("could not load items list");
		return;
	}

	CollArr.clear();
	NocollArr.clear();
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int x = SPIntN (line, "x", 0);
		int z = SPIntN (line, "z", 0);
		double height = SPFloatN (line, "height", 1);
		double diam = SPFloatN (line, "diam", 1);
		double xx = (nx - x) / (double)(nx - 1.0) * curr_course->size.x;
		double zz = -(ny - z) / (double)(ny - 1.0) * curr_course->size.y;

		string name = SPStrN (line, "name", "");
		size_t type = ObjectIndex[name];
		if (ObjTypes[type].texture == NULL && ObjTypes[type].drawable) {
			string terrpath = param.obj_dir + SEP + ObjTypes[type].textureFile;
			ObjTypes[type].texture = new TTexture();
			ObjTypes[type].texture->LoadMipmap(terrpath, 0);
		}
		bool coll = ObjTypes[type].collidable;
		if (coll == 1) {
			CollArr.push_back(TCollidable());
		    CollArr.back().pt.x = xx;
		    CollArr.back().pt.z = zz;
		    CollArr.back().pt.y = FindYCoord (xx, zz);
		    CollArr.back().height = height;
		    CollArr.back().diam = diam;
		    CollArr.back().tree_type = type;
		} else if (coll == 0) {
			NocollArr.push_back(TItem());
		    NocollArr.back().pt.x = xx;
		    NocollArr.back().pt.z = zz;
		    NocollArr.back().pt.y = FindYCoord (xx, zz);
			NocollArr.back().height = height;
		    NocollArr.back().diam = diam;
		    NocollArr.back().item_type = type;
			NocollArr.back().collectable = ObjTypes[type].collectable;
			NocollArr.back().drawable = ObjTypes[type].drawable;
			ObjTypes[type].num_items++;
		}
	}
}
示例#16
0
bool CPlayers::LoadPlayers () {
	CSPList list(MAX_PLAYERS);
	string line;
	int active;

	if (FileExists (param.config_dir, "players") == false) {
		SetDefaultPlayers ();
		Message ("file 'players' does not exist, set default players");
		return false; 
	}

	if (list.Load (param.config_dir, "players") == false) {
		SetDefaultPlayers ();
		Message ("coule not load players list, set default players");
		return false; 
	}

	numPlayers = 0;
	g_game.start_player = 0;
	for (int i=0; i<list.Count(); i++) {
		line = list.Line(i);
		plyr[numPlayers].name = SPStrN (line, "name", "unknown");
		plyr[numPlayers].funlocked = SPStrN (line, "unlocked", "");
		plyr[numPlayers].avatar = SPStrN (line, "avatar", "");
		plyr[numPlayers].texid = SPIntN (AvatarIndex, plyr[numPlayers].avatar, 0);
		active = SPIntN (line, "active", 0);
		if (active > 0) g_game.start_player = numPlayers;
		numPlayers++;
	}
	if (numPlayers < 1) {
		SetDefaultPlayers ();
		Message ("player file doesn't contain a player, set default players");
		return false;
	}
	return true;
}
示例#17
0
bool CEnvironment::LoadEnvironmentList () {
	CSPList list (32, true);
	if (!list.Load (param.env_dir2, "environment.lst")) {
		Message ("could not load environment.lst");
		return false;
	}

	locs.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		locs[i].name = SPStrN (line, "location", "");
	}
	list.MakeIndex (EnvIndex, "location");
	return true;
}
示例#18
0
void CPlayers::LoadAvatars () {
	CSPList list (MAX_AVATARS);

	if (!list.Load (param.player_dir, "avatars.lst")) {
		Message ("could not load avators.lst");
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		string filename = SPStrN (line, "file", "unknown");
		TTexture* texture = new TTexture();
		if (texture && texture->Load(param.player_dir, filename)) {
			avatars.push_back(TAvatar(filename, texture));
		} else
			delete texture;
	}
}
示例#19
0
bool CEnvironment::LoadEnvironmentList () {
	int i;
	string line;

	CSPList list (32, true);
	if (!list.Load (param.env_dir2, "environment.lst")) {
		Message ("could not load environment.lst");
		return false;
	}

	numLocs = 0;
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		locs[i].name = SPStrN (line, "location", "");
		numLocs++;
	}
	list.MakeIndex (EnvIndex, "location");
	return true;
}
示例#20
0
bool CTexture::LoadTextureList() {
	FreeTextureList();
	CSPList list;
	if (list.Load(param.tex_dir, "textures.lst")) {
		for (CSPList::const_iterator line = list.cbegin(); line != list.cend(); ++line) {
			int id = SPIntN(*line, "id", -1);
			CommonTex.resize(std::max(CommonTex.size(), (std::size_t)id+1));
			std::string texfile = SPStrN(*line, "file");
			bool rep = SPBoolN(*line, "repeat", false);
			if (id >= 0) {
				CommonTex[id] = new TTexture();
				CommonTex[id]->Load(param.tex_dir, texfile, rep);
			} else Message("wrong texture id in textures.lst");
		}
	} else {
		Message("failed to load common textures");
		return false;
	}
	return true;
}
void CTranslation::LoadTranslations (size_t langidx) {
	SetDefaultTranslations ();
	if (!languages_ok) return;
	if (langidx == 0 || langidx >= languages.size()) return;

	CSPList list(MAX_COMMON_TEXT_LINES);
	string filename = languages[langidx].lang + ".lst";
	if (!list.Load (param.trans_dir, filename)) {
		Message ("could not load translations list:", filename);
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int idx = SPIntN (line, "idx", -1);
		if (idx >= 0 && idx < NUM_COMMON_TEXTS) {
			texts[idx] = SPStrN (line, "trans", texts[idx]);
		}
	}
}
示例#22
0
void CCharShape::CreateMaterial (const string& line) {
	TVector3d diff = SPVector3d(line, "diff");
	TVector3d spec = SPVector3d(line, "spec");
	float exp = SPFloatN (line, "exp", 50);
	std::string mat = SPStrN(line, "mat");

	Materials.push_back(TCharMaterial());
	Materials.back().diffuse.r = diff.x;
	Materials.back().diffuse.g = diff.y;
	Materials.back().diffuse.b = diff.z;
	Materials.back().diffuse.a = 1.0;
	Materials.back().specular.r = spec.x;
	Materials.back().specular.g = spec.y;
	Materials.back().specular.b = spec.z;
	Materials.back().specular.a = 1.0;
	Materials.back().exp = exp;
	if (useActions)
		Materials.back().matline = line;

	MaterialIndex[mat] = Materials.size()-1;
}
示例#23
0
void CCredits::LoadCreditList () {
	CSPList list(MAX_CREDITS);

	if (!list.Load (param.data_dir, "credits.lst")) {
		Message ("could not load credits list");
		return;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		TCredits credit;
		credit.text = SPStrN (line, "text", "");

		ETR_DOUBLE offset = SPFloatN (line, "offs", 0) * OFFS_SCALE_FACTOR * Winsys.scale;
		if (i>0) credit.offs = CreditList.back().offs + (int)offset;
		else credit.offs = offset;

		credit.col = SPIntN (line, "col", 0);
		credit.size = SPFloatN (line, "size", 1.0);
		CreditList.push_back(credit);
	}
}
示例#24
0
bool CEvents::LoadEventList () {
	CSPList list(256);
	int i, ii, type;
	string line, item, race, cup;
	int num;

	if (!list.Load (param.common_course_dir, "events.lst")) {
		Message ("could not load events.lst");
		return false;
	}

	// pass 1: races
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 0) {
			if (numRaces < MAX_RACES2) {
				RaceList[numRaces].race = SPStrN (line, "race", "error");
				item = SPStrN (line, "course", "");
				RaceList[numRaces].course = Course.GetCourseIdx (item);
				item = SPStrN (line, "light", "");
				RaceList[numRaces].light = Env.GetLightIdx (item);
				RaceList[numRaces].snow = SPIntN (line, "snow", 0);
				RaceList[numRaces].wind = SPIntN (line, "wind", 0);
				RaceList[numRaces].time = SPVector3N (line, "time", MakeVector (0, 0, 0));
				RaceList[numRaces].herrings = SPIndex3N (line, "herring", MakeIndex3 (0, 0, 0));
				RaceList[numRaces].music_theme = Music.GetThemeIdx (SPStrN (line, "theme", "normal"));
				numRaces++;
			}
		}
	}
	list.MakeIndex (RaceIndex, "race");

	// pass 2: cups
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 1) {
			if (numCups < MAX_CUPS2) {
				CupList[numCups].cup = SPStrN (line, "cup", "error");
				CupList[numCups].name = SPStrN (line, "name", "unknown");
				CupList[numCups].desc = SPStrN (line, "desc", "unknown");
				num = SPIntN (line, "num", 0);
				CupList[numCups].num_races = num;
				for (ii=0; ii<num; ii++) {
					race = SPStrN (line, Int_StrN (ii+1), "");
					CupList[numCups].races[ii] = GetRaceIdx (race);
				}
				numCups++;
			}
		}
	}
	list.MakeIndex (CupIndex, "cup");

	// pass 3: events
	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		type = SPIntN (line, "struct", -1);
		if (type == 2) {
			if (numEvents < MAX_EVENTS2) {
				EventList[numEvents].name = SPStrN (line, "name", "unknown");
				num = SPIntN (line, "num", 0);
				EventList[numEvents].num_cups = num;
				for (ii=0; ii<num; ii++) {
					cup = SPStrN (line, Int_StrN (ii+1), "");
					EventList[numEvents].cups[ii] = GetCupIdx (cup);
				}
				numEvents++;
			}
		}
	}
	list.MakeIndex (EventIndex, "event");

	return true;
}
示例#25
0
bool CCharShape::Load (string dir, string filename, bool with_actions) {
	CSPList list (500);
	int i, ii, act;
	string line, order, name, mat_name, fullname;
	TVector3 scale, trans, rot;
	double visible;
	bool shadow;
	int node_name, parent_name;

	useActions = with_actions;
	CreateRootNode ();
	newActions = true;

	file_name = filename;
 	if (!list.Load (dir, filename)) {
		Message ("could not load character", filename.c_str());
		return false;
	}

	for (i=0; i<list.Count(); i++) {
		line = list.Line (i);
		node_name = SPIntN (line, "node", -1); 
		parent_name = SPIntN (line, "par", -1);		
		mat_name = SPStrN (line, "mat", "");
		name = SPStrN (line, "joint", "");	
		fullname = SPStrN (line, "name", "");

		if (SPIntN (line, "material", 0) > 0) {
			CreateMaterial (line.c_str());
			if (useActions) {
				Matlines[numMatlines] = line;
				numMatlines++;
			}
		} else {
			visible = SPFloatN (line, "vis", -1.0);	
			shadow = SPBoolN (line, "shad", false);
			order = SPStrN (line, "order", "");
 			CreateCharNode (parent_name, node_name, name, fullname, order, shadow);					
			rot = SPVector3N (line, "rot", NullVec);
			MaterialNode (node_name, mat_name);
			for (ii=0; ii<(int)order.size(); ii++) {
				act = order.at(ii)-48;	
				switch (act) {
					case 0:
						trans = SPVector3N (line, "trans", MakeVector (0,0,0));
						TranslateNode (node_name, trans);
						break;
					case 1: RotateNode (node_name, 1, rot.x); break;
					case 2: RotateNode (node_name, 2, rot.y); break;
					case 3: RotateNode (node_name, 3, rot.z); break;
					case 4:
						scale = SPVector3N (line, "scale", MakeVector (1,1,1));
						ScaleNode (node_name, scale);
						break;
					case 5: VisibleNode (node_name, visible); break;
					case 9: RotateNode (node_name, 2, rot.z); break;
					default: break;
				}
			}
		}
	}
	newActions = false;
	return true;
}
示例#26
0
bool CCharShape::Load (const string& dir, const string& filename, bool with_actions) {
	CSPList list (500);

	useActions = with_actions;
	CreateRootNode ();
	newActions = true;

	if (!list.Load (dir, filename)) {
		Message ("could not load character", filename);
		return false;
	}

	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int node_name = SPIntN (line, "node", -1);
		int parent_name = SPIntN (line, "par", -1);
		string mat_name = SPStrN (line, "mat");
		string name = SPStrN (line, "joint");
		string fullname = SPStrN (line, "name");

		if (SPIntN (line, "material", 0) > 0) {
			CreateMaterial (line);
		} else {
			float visible = SPFloatN (line, "vis", -1.0);
			bool shadow = SPBoolN (line, "shad", false);
			string order = SPStrN (line, "order");
			CreateCharNode (parent_name, node_name, name, fullname, order, shadow);
			TVector3d rot = SPVector3d(line, "rot");
			MaterialNode (node_name, mat_name);
			for (size_t ii = 0; ii < order.size(); ii++) {
				int act = order[ii]-48;
				switch (act) {
					case 0: {
						TVector3d trans = SPVector3d(line, "trans");
						TranslateNode (node_name, trans);
						break;
					}
					case 1:
						RotateNode (node_name, 1, rot.x);
						break;
					case 2:
						RotateNode (node_name, 2, rot.y);
						break;
					case 3:
						RotateNode (node_name, 3, rot.z);
						break;
					case 4: {
						TVector3d scale = SPVector3(line, "scale", TVector3d(1, 1, 1));
						ScaleNode (node_name, scale);
						break;
					}
					case 5:
						VisibleNode (node_name, visible);
						break;
					case 9:
						RotateNode (node_name, 2, rot.z);
						break;
					default:
						break;
				}
			}
		}
	}
	newActions = false;
	return true;
}
示例#27
0
bool CEvents::LoadEventList () {
	CSPList list(256);

	if (!list.Load (param.common_course_dir, "events.lst")) {
		Message ("could not load events.lst");
		return false;
	}

	// pass 1: races
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int type = SPIntN (line, "struct", -1);
		if (type == 0) {
			RaceList.push_back(TRace(
			                       Course.GetCourse(SPStrN(line, "course")),
			                       Env.GetLightIdx(SPStrN(line, "light")),
			                       SPIntN(line, "snow", 0),
			                       SPIntN(line, "wind", 0),
			                       SPVector3i(line, "herring"),
			                       SPVector3d(line, "time"),
			                       Music.GetThemeIdx(SPStrN(line, "theme", "normal"))));
		}
	}
	list.MakeIndex (RaceIndex, "race");

	// pass 2: cups
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int type = SPIntN (line, "struct", -1);
		if (type == 1) {
			CupList.push_back(TCup(
			                      SPStrN(line, "cup", errorString),
			                      SPStrN(line, "name", "unknown"),
			                      SPStrN(line, "desc", "unknown")));
			int num = SPIntN (line, "num", 0);
			CupList.back().races.resize(num);
			for (int ii=0; ii<num; ii++) {
				string race = SPStrN (line, Int_StrN (ii+1));
				CupList.back().races[ii] = &RaceList[GetRaceIdx(race)];
			}
		}
	}
	list.MakeIndex (CupIndex, "cup");

	// pass 3: events
	for (size_t i=0; i<list.Count(); i++) {
		const string& line = list.Line(i);
		int type = SPIntN (line, "struct", -1);
		if (type == 2) {
			EventList.push_back(TEvent(SPStrN(line, "name", "unknown")));
			int num = SPIntN (line, "num", 0);
			EventList.back().cups.resize(num);
			for (int ii=0; ii<num; ii++) {
				string cup = SPStrN (line, Int_StrN (ii+1));
				EventList.back().cups[ii] = &CupList[GetCupIdx(cup)];
			}
		}
	}
	list.MakeIndex (EventIndex, "event");

	return true;
}
示例#28
0
bool CCourse::LoadCourseList () {
	CSPList list (128);

	if (!list.Load (param.common_course_dir, "courses.lst")) {
		Message ("could not load courses.lst");
		return false;
	}

	CSPList paramlist (48);

	CourseList.resize(list.Count());
	for (size_t i=0; i<list.Count(); i++) {
		const string& line1 = list.Line(i);
		CourseList[i].name = SPStrN (line1, "name", "noname");
		CourseList[i].dir = SPStrN (line1, "dir", "nodir");

		string desc = SPStrN (line1, "desc", "");
		FT.AutoSizeN (2);
		vector<string> desclist = FT.MakeLineList (desc.c_str(), 335 * Winsys.scale - 16.0);
		size_t cnt = desclist.size();
		if (cnt > MAX_DESCRIPTION_LINES) cnt = MAX_DESCRIPTION_LINES;
		CourseList[i].num_lines = cnt;
		for (size_t ll=0; ll<cnt; ll++) {
			CourseList[i].desc[ll] = desclist[ll];
		}

		string coursepath = param.common_course_dir + SEP + CourseList[i].dir;
		if (DirExists (coursepath.c_str())) {
			// preview
			string previewfile = coursepath + SEP + "preview.png";
			CourseList[i].preview = new TTexture();
			if (!CourseList[i].preview->LoadMipmap(previewfile, 0)) {
				Message ("couldn't load previewfile");
//				texid = Tex.TexID (NO_PREVIEW);
			}

			// params
			string paramfile = coursepath + SEP + "course.dim";
			if (!paramlist.Load (paramfile)) {
				Message ("could not load course.dim");
			}

			const string& line2 = paramlist.Line (0);
			CourseList[i].author = SPStrN (line2, "author", "unknown");
			CourseList[i].size.x = SPFloatN (line2, "width", 100);
			CourseList[i].size.y = SPFloatN (line2, "length", 1000);
			CourseList[i].play_size.x = SPFloatN (line2, "play_width", 90);
			CourseList[i].play_size.y = SPFloatN (line2, "play_length", 900);
			CourseList[i].angle = SPFloatN (line2, "angle", 10);
			CourseList[i].scale = SPFloatN (line2, "scale", 10);
			CourseList[i].start.x = SPFloatN (line2, "startx", 50);
			CourseList[i].start.y = SPFloatN (line2, "starty", 5);
			CourseList[i].env = Env.GetEnvIdx (SPStrN (line2, "env", "etr"));
			CourseList[i].music_theme = Music.GetThemeIdx (SPStrN (line2, "theme", "normal"));
			CourseList[i].use_keyframe = SPBoolN (line2, "use_keyframe", false);
			CourseList[i].finish_brake = SPFloatN (line2, "finish_brake", 20);
			paramlist.Clear ();	// the list is used several times
		}
	}
	list.MakeIndex (CourseIndex, "dir");
	return true;
}