Exemplo n.º 1
0
int ini_read_int(STRING *filename, char* section, STRING *entry, int defaultValue)
{
	STRING *tmp = "#64";
	STRING *def = "#64";
	ini_read(tmp, filename, section, entry, str_for_int(def, defaultValue));
	return str_to_int(tmp);
}
Exemplo n.º 2
0
function dialogs_init()
{
	STRING *file = "#256";
	make_path(file, "messages.ini");
	int i;
	for(i = 0; i < MAX_DIALOG_ENTRIES; i++)
	{
		/*
		[Message 0]
		text=Oh man, nice bell!
		sound=just_stupid_sound.wav
		*/
		STRING *section = "#64";
		str_cpy(section, "Message ");
		str_cat(section, str_for_int(NULL, i));
		char buffer[256];
		ini_read_buffer(file, section, "text", "FIXIT: You forgot a message here!", buffer, 256);
		
		if(strlen(buffer) > 0)
		{
			dialogEntries[i].initialized = 1;
			dialogEntries[i].text = str_create(buffer);
			
			ini_read_buffer(file, section, "sound", "", buffer, 256);
			if(strlen(buffer) > 0)
				dialogEntries[i].sound = snd_create(buffer);
			else
				dialogEntries[i].sound = NULL;
		}
	}
	
	dialogText = txt_create(1, 20);
	dialogText->flags |= CENTER_X | TRANSLUCENT | OUTLINE;
	dialogText->font = dialogFont;
}
Exemplo n.º 3
0
void ini_write_int(STRING *filename, char* section, STRING *entry, int value)
{
	ini_write(filename, section, entry, str_for_int(NULL, value));
}
Exemplo n.º 4
0
void qlevel_save(STRING *filename)
{
	STRING *file = "#256";
	make_path(file, filename);
	
	STRING *backup = "#256";
	str_cpy(backup, file);
	str_cat(backup, ".bak");
	file_delete(backup);
	file_rename(file, backup);
	
	ini_write_int(file, "Level Information", "EntityCount", 0);
	ini_write_int(file, "Level Information", "LightCount", 0);
	ini_write_int(file, "Level Information", "FogCount", 0);
	
	int countEntity = 0;
	int countLight = 0;
	int countFog = 0;
	
	STRING *section = "#64";
	for(you = ent_next(NULL); you != NULL; you = ent_next(you))
	{
		switch(you->group)
		{
			case GROUP_LEVEL:
				str_cpy(section, "Entity ");
				str_cat(section, str_for_int(NULL, countEntity));
				
				ini_write_string(file, section, "Model", you->type);
				ini_write_int(file, section, "ActionCount", 0);
				int actionCount = 0;
				STRING *actionName = "#64";
				ActionInformation *entry;
				for(entry = list_first(you->string1); entry != NULL; entry = list_next(you->string1, entry))
				{
					str_cpy(actionName, "Action");
					str_cat(actionName, str_for_int(NULL, actionCount));
					ini_write_string(file, section, actionName, _str(entry->actionname));
					actionCount++;
				}
				ini_write_int(file, section, "ActionCount", actionCount);
				
				ini_write_float(file, section, "X", you->x);
				ini_write_float(file, section, "Y", you->y);
				ini_write_float(file, section, "Z", you->z);
				ini_write_float(file, section, "Pan", cycle(you->pan, 0, 360));
				ini_write_float(file, section, "Tilt", cycle(you->tilt, 0, 360));
				ini_write_float(file, section, "Roll", cycle(you->roll, 0, 360));
				ini_write_float(file, section, "ScaleX", you->scale_x);
				ini_write_float(file, section, "ScaleY", you->scale_y);
				ini_write_float(file, section, "ScaleZ", you->scale_z);
				ini_write_float(file, section, "Lightrange", you->lightrange);

				countEntity++;
				break;
		}
	}
	
	ini_write_int(file, "Level Information", "EntityCount", countEntity);
	ini_write_int(file, "Level Information", "LightCount", countLight);
	ini_write_int(file, "Level Information", "FogCount", countFog);
}
Exemplo n.º 5
0
void qlevel_load(STRING *filename)
{
	STRING *file = "#256";
	make_path(file, filename);
	if(!file_exists(file))
	{
		error("FIXIT! qlevel_load: File does not exist!");
		return;
	}
		
	level_load(NULL);
	
	int countEntity = ini_read_int(file, "Level Information", "EntityCount", 0);
	int countLight = ini_read_int(file, "Level Information", "LightCount", 0);
	int countFog = ini_read_int(file, "Level Information", "FogCount", 0);
	
	STRING *section = "#64";
	
	int i;
	char buffer[256];
	STRING *strTemp = "#128";
	for(i = 0; i < countEntity; i++)
	{
		diag("\nLoad :");
		str_cpy(section, "Entity ");
		str_cat(section, str_for_int(NULL, i));
		diag(section);
		
		ini_read_buffer(file, section, "Model", "error.mdl", buffer, 256);
		ENTITY *ent = ent_create(buffer, nullvector, qlevel_entity_init);
		ent->group = GROUP_LEVEL;
		ent->x = ini_read_float(file, section, "X", 0);
		ent->y = ini_read_float(file, section, "Y", 0);
		ent->z = ini_read_float(file, section, "Z", 0);
		
		ent->pan = ini_read_float(file, section, "Pan", 0);
		ent->tilt = ini_read_float(file, section, "Tilt", 0);
		ent->roll = ini_read_float(file, section, "Roll", 0);
		
		ent->scale_x = ini_read_float(file, section, "ScaleX", 0);
		ent->scale_y = ini_read_float(file, section, "ScaleY", 0);
		ent->scale_z = ini_read_float(file, section, "ScaleZ", 0);
		
		ent->lightrange = ini_read_float(file, section, "Lightrange", 0);
		
		int iActionCount = ini_read_int(file, section, "ActionCount", 0);
		int iA = 0;
		STRING *actionName = "#64";
		for(iA = 0; iA < iActionCount; iA++)
		{
			str_cpy(actionName, "Action");
			str_cat(actionName, str_for_int(NULL, iA));
			ini_read_buffer(file, section, actionName, "", buffer, 256);
			str_cpy(strTemp, buffer);
			diag("\nTry adding action '");
			diag(strTemp);
			diag("'...");
			if(actinfo_add(ent->string1, strTemp))
			{
				diag(" SUCCESS!\n\tTry getting function pointer...");
				void *fn = action_getptr(strTemp);
				if(fn != NULL)
				{
					diag(" SUCCESS!");
					scheduler_add(fn, ent);
				}
				else
				{
					diag(" FAILED!");				
				}
			}
			else
			{
				diag(" FAILED!");
			}
		}
		diag("\nEntity loaded!");
	}
}