Пример #1
0
void B_TempFree(int size)
{
	BG_TempFree(size);
}
Пример #2
0
//===========================================================================
// Routine      : AOTCTC_Holocron_Loadpositions
// Description  : Loads holocron positions from .hpf file on disk
void AOTCTC_Holocron_Loadpositions( void )
{// Does each online player's data.
	char *s, *t;
	int len;
	fileHandle_t	f;
	char *buf;
	//[DynamicMemoryTweaks]
	char	loadPath[MAX_QPATH];
	//[/DynamicMemoryTweaks]
	int statnum = 0;
	float stats[50*3]; // 1 extra.
	int holocron_number = 0;
	vmCvar_t		mapname;

	G_Printf("^5Loading holocron position table...");
	//loadPath = (char *)B_TempAlloc(1024*4);
	trap_Cvar_Register( &mapname, "mapname", "", CVAR_SERVERINFO | CVAR_ROM );

	Com_sprintf(loadPath, 1024*4, "holocron_positions/%s.hpf\0", mapname.string);

	len = trap_FS_FOpenFile( loadPath, &f, FS_READ );
	if ( !f )
	{
		G_Printf(" ^3FAILED!!!\n");
		G_Printf("^5No file exists! (^3%s^5)\n", loadPath);
		return;
	}
	if ( !len )
	{ //empty file
		G_Printf(" ^3FAILED!!!\n");
		G_Printf("^5Empty file!\n");
		trap_FS_FCloseFile( f );
		return;
	}

	if ( (buf = BG_TempAlloc(len+1)) == 0 )
	{//alloc memory for buffer
		G_Printf(" ^3FAILED!!!\n");
		G_Printf("^5Unable to allocate buffer.\n");
		return;
	}
	trap_FS_Read( buf, len, f );
	trap_FS_FCloseFile( f );

	for (t = s = buf; *t;) 
	{
		s = strchr(s, ' ');
		
		if (!s)
			break;

		while (*s == ' ')
			*s++ = 0;

		if (*t)
		{
			if (statnum == 0)
			{
				number_of_holocronpositions = atoi(t);
				
				if (number_of_holocronpositions <= 15)
				{
					G_Printf(" ^3FAILED!!!\n");
					G_Printf("^5You need at least 16 holocron points!\n");
					return;
				}
			}

			stats[statnum] = (float)atof(t);
			statnum++;
		}

		t = s;
	}

	statnum = 1;

	while (holocron_number < number_of_holocronpositions)
	{
		int reference = 0;

		while (reference <= 2)
		{
			holocrons[holocron_number].origin[reference] = stats[statnum];
			statnum++;
			reference++;
		}

		holocron_number++;
	}

	BG_TempFree(len+1);

	G_Printf(" ^3Completed OK.\n");
	G_Printf("^5Total Holocron Positions: ^7%i^5.\n", number_of_holocronpositions);
	holocrons_loaded = qtrue;
}