예제 #1
0
inline void *dtAllocCustom( int size, dtAllocHint hint )
{
	return Z_TagMalloc( size, TAG_BOTLIB );
}
예제 #2
0
파일: zmem.c 프로젝트: Anters/Wolf3D-iOS
/*
-----------------------------------------------------------------------------
 Function: Z_Malloc -Allocates zone memory blocks.
 
 Parameters: size -[in] Bytes to allocate. 			
 
 Returns: 
 		A void pointer to the allocated space, or will shutdown application 
		if there is insufficient memory available.
 
 Notes: Calls Z_TagMalloc() with tag set to zero.
-----------------------------------------------------------------------------
*/
PUBLIC void *Z_Malloc( size_t size )
{
	return Z_TagMalloc( size, 0 );
}
예제 #3
0
/*
==================
BotImport_GetMemory
==================
*/
void *BotImport_GetMemory(int size) {
	void *ptr;

	ptr = Z_TagMalloc( size, TAG_BOTLIB );
	return ptr;
}
예제 #4
0
파일: sv_anticheat.c 프로젝트: Slipyx/r1q2
static void SV_AntiCheat_ParseHashLine (char *line, int line_number, const char *filename)
{
	filehash_t	*hashes;
	int			i;
	int			flags;
	char		*p, *hash;

	if (line[0] == '!')
	{
		strncpy (anticheat_hashlist_name, line + 1, sizeof(anticheat_hashlist_name)-1);
		ExpandNewLines (anticheat_hashlist_name);
		return;
	}

	p = strchr (line, '\t');
	if (!p)
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in %s\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line, filename);
		return;
	}

	p[0] = 0;
	p++;

	hash = p;

	p = strchr (hash, '\t');
	if (p)
	{
		p[0] = 0;
		p++;
	}

	if (strlen (hash) != 40)
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed hash '%s' in %s on line %d\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, hash, filename, line_number);
		return;
	}

	for (i = 0; i < 40; i++)
	{
		if (!isxdigit (hash[i]))
		{
			Com_Printf ("ANTICHEAT WARNING: Malformed hash '%s' in %s on line %d\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, hash, filename, line_number);
			return;
		}
	}

	if (strlen (line) >= MAX_QPATH || strchr (line, '\\') || !isalnum(line[0]))
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed quake path '%s' in %s on line %d\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line, filename, line_number);
		return;
	}

	Q_strlwr (line);

	flags = 0;

	if (p && p[0])
	{
		if (strstr (p, "required"))
			flags |= ACH_REQUIRED;
		if (strstr (p, "negative"))
			flags |= ACH_NEGATIVE;
	}

	hashes = &fileHashes;

	while (hashes->next)
		hashes = hashes->next;

	hashes->next = Z_TagMalloc (sizeof(*hashes), TAGMALLOC_ANTICHEAT);
	hashes = hashes->next;
	hashes->next = NULL;

	for (i = 0; i < 20; i++)
		hashes->hash[i] = HexToRaw (hash + i*2);
	
	hashes->flags = flags;

	strcpy (hashes->quakePath, line);
	antiCheatNumFileHashes++;
}
예제 #5
0
파일: sv_anticheat.c 프로젝트: Slipyx/r1q2
static void SV_AntiCheat_ParseFileViolation (byte *buff, int bufflen)
{
	linkednamelist_t	*bad;
	client_t			*cl;
	unsigned short		clientID;
	const char			*quakePath, *failedhash;
	int					len;
	uint32				challenge;

	if (bufflen < 7)
		return;

	clientID = *(unsigned short *)buff;
	buff += 2;
	bufflen -= 2;

	//we check challenge to ensure we don't get a race condition if a client reconnects.
	challenge = *(uint32 *)buff;
	buff += 4;
	bufflen -= 4;

	quakePath = (const char *)buff;

	len = (int)strlen(quakePath) + 1;

	buff += len;
	bufflen -= len;

	if (bufflen)
		failedhash = (const char *)buff;
	else
		failedhash = "no hash?";

	if (clientID >= maxclients->intvalue)
	{
		Com_Printf ("ANTICHEAT WARNING: ParseFileViolation with illegal client ID %d\n", LOG_ANTICHEAT|LOG_WARNING, clientID);
		return;
	}

	cl = &svs.clients[clientID];

	if (cl->challenge != challenge)
		return;

	if (cl->state >= cs_connected)
	{
		int			action;
		filehash_t	*f;

		cl->anticheat_file_failures++;

		action = sv_anticheat_badfile_action->intvalue;

		f = &fileHashes;
		while (f->next)
		{
			f = f->next;
			if (!strcmp (f->quakePath, quakePath))
			{
				if (f->flags & ACH_REQUIRED)
				{
					action = 0;
					break;
				}
			}
		}

		Com_Printf ("ANTICHEAT FILE VIOLATION: %s[%s] has a modified %s [%s]\n", LOG_SERVER|LOG_ANTICHEAT, cl->name, NET_AdrToString (&cl->netchan.remote_address), quakePath, failedhash);
		switch (action)
		{
			case 0:
				if (cl->state == cs_spawned)
					SV_BroadcastPrintf (PRINT_HIGH, ANTICHEATMESSAGE " %s was kicked for modified %s\n", cl->name, quakePath);
				else
					SV_ClientPrintf (cl, PRINT_HIGH, ANTICHEATMESSAGE " %s was kicked for modified %s\n", cl->name, quakePath);

				//show custom msg
				if (sv_anticheat_badfile_message->string[0])
					SV_ClientPrintf (cl, PRINT_HIGH, "%s\n", sv_anticheat_badfile_message->string);

				//hack to fix late zombies race condition
				cl->lastmessage = svs.realtime;
				
				SV_DropClient (cl, true);
				return;
			case 1:
				SV_ClientPrintf (cl, PRINT_HIGH, "WARNING: Your file %s has been modified. Please replace it with a known valid copy.\n", quakePath);

				//show custom msg
				if (sv_anticheat_badfile_message->string[0])
					SV_ClientPrintf (cl, PRINT_HIGH, "%s\n", sv_anticheat_badfile_message->string);
				break;
			case 2:
				//spamalicious :)
				if (cl->state == cs_spawned)
					SV_BroadcastPrintf (PRINT_HIGH, ANTICHEATMESSAGE " %s has a modified %s\n", cl->name, quakePath);
				else
					SV_ClientPrintf (cl, PRINT_HIGH, ANTICHEATMESSAGE " %s has a modified %s\n", cl->name, quakePath);

				//show custom msg
				if (sv_anticheat_badfile_message->string[0])
					SV_ClientPrintf (cl, PRINT_HIGH, "%s\n", sv_anticheat_badfile_message->string);
				break;
		}

		if (cl->state != cs_zombie && sv_anticheat_badfile_max->intvalue &&
			cl->anticheat_file_failures >= sv_anticheat_badfile_max->intvalue)
		{
			SV_BroadcastPrintf (PRINT_HIGH, ANTICHEATMESSAGE " %s was kicked for too many modified files\n", cl->name);

			//broadcasts are dropped until in-game, repeat if necessary so the client has a clue wtf is going on
			if (cl->state != cs_spawned)
				SV_ClientPrintf (cl, PRINT_HIGH, ANTICHEATMESSAGE " %s was kicked for too many modified files\n", cl->name);

			//hack to fix late zombies race condition
			cl->lastmessage = svs.realtime;

			SV_DropClient (cl, true);
			return;
		}

		bad = &cl->anticheat_bad_files;
		while (bad->next)
			bad = bad->next;

		bad->next = Z_TagMalloc (sizeof(*bad), TAGMALLOC_ANTICHEAT);
		bad = bad->next;
		bad->name = CopyString (quakePath, TAGMALLOC_ANTICHEAT);
		bad->next = NULL;
	}
	//else if (cl->state > cs_zombie)
	//	Com_Printf ("ANTICHEAT WARNING: File violation on %s[%s] in state %d: '%s'\n", LOG_SERVER|LOG_WARNING|LOG_ANTICHEAT, cl->name, NET_AdrToString (&cl->netchan.remote_address), cl->state, quakePath);
}
예제 #6
0
파일: cmd.c 프로젝트: Slipyx/r1q2
/*
===============
Cmd_Alias_f

Creates a new command that executes a command string (possibly ; seperated)
===============
*/
void Cmd_Alias_f (void)
{
	cmdalias_t	*a;
	char		cmd[1024];
	char		*s;
	void		**data;

	if (Cmd_Argc() == 1)
	{
		Com_Printf ("Current alias commands:\n", LOG_GENERAL);
		Cmd_Aliaslist_f ();
		return;
	}

	s = Cmd_Argv(1);
	if (strlen(s) >= MAX_ALIAS_NAME)
	{
		Com_Printf ("Alias name is too long\n", LOG_GENERAL);
		return;
	}

	// if the alias already exists, reuse it
	/*for (a = cmd_alias ; a ; a=a->next)
	{
		if (!strcmp(s, a->name))
		{
			Z_Free (a->value);
			break;
		}
	}*/

	data = rbfind (s, aliastree);
	if (data)
		a = *(cmdalias_t **)data;
	else
		a = NULL;


	if (!a)
	{
		a = Z_TagMalloc (sizeof(cmdalias_t), TAGMALLOC_ALIAS);
		a->next = cmd_alias;
		cmd_alias = a;

		strcpy (a->name, s);

		data = rbsearch (a->name, aliastree);
		*data = a;
	}
	else
	{
		//strcpy (a->name, s);
		//memleak fix, thanks Maniac-
		Z_Free (a->value);
	}

// copy the rest of the command line
	/*cmd[0] = 0;		// start out with a null string
	c = Cmd_Argc();
	for (i=2 ; i< c ; i++)
	{
		strcat (cmd, Cmd_Argv(i));
		if (i != (c - 1))
			strcat (cmd, " ");
	}*/

	Q_strncpy (cmd, Cmd_Args2(2), sizeof(cmd)-2);
	/*s = strchr (Cmd_Args(), ' ');
	if (s)
		s++;
	else
		s = Cmd_Args ();
	Q_strncpy (cmd, s, sizeof(cmd)-2);*/
	strcat (cmd, "\n");
	
	a->value = CopyString (cmd, TAGMALLOC_ALIAS);
}
예제 #7
0
파일: cl_cin.c 프로젝트: postfix/quake2vr
/*
==============
SCR_LoadPCX
==============
*/
void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int32_t *width, int32_t *height)
{
	byte	*raw;
	pcx_t	*pcx;
	int32_t		x, y;
	int32_t		len;
	int32_t		dataByte, runLength;
	byte	*out, *pix;

	*pic = NULL;

	//
	// load the file
	//
	len = FS_LoadFile (filename, (void **)&raw);
	if (!raw)
		return;	// Com_Printf ("Bad pcx file %s\n", filename);

	//
	// parse the PCX file
	//
	pcx = (pcx_t *)raw;
	raw = &pcx->data;

	if (pcx->manufacturer != 0x0a
		|| pcx->version != 5
		|| pcx->encoding != 1
		|| pcx->bits_per_pixel != 8
		|| pcx->xmax >= 640
		|| pcx->ymax >= 480)
	{
		Com_Printf ("Bad pcx file %s\n", filename);
		return;
	}

	out = Z_TagMalloc ( (pcx->ymax+1) * (pcx->xmax+1), TAG_CLIENT );

	*pic = out;

	pix = out;

	if (palette)
	{
		*palette = Z_TagMalloc(768, TAG_CLIENT);
		memcpy (*palette, (byte *)pcx + len - 768, 768);
	}

	if (width)
		*width = pcx->xmax+1;
	if (height)
		*height = pcx->ymax+1;

	for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
	{
		for (x=0 ; x<=pcx->xmax ; )
		{
			dataByte = *raw++;

			if((dataByte & 0xC0) == 0xC0)
			{
				runLength = dataByte & 0x3F;
				dataByte = *raw++;
			}
			else
				runLength = 1;

			while(runLength-- > 0)
				pix[x++] = dataByte;
		}

	}

	if ( raw - (byte *)pcx > len)
	{
		Com_Printf ("PCX file %s was malformed", filename);
		Z_Free (*pic);
		*pic = NULL;
	}

	FS_FreeFile (pcx);
}
예제 #8
0
/*
===============
CL_QueueHTTPDownload

Called from the precache check to queue a download. Return value of
false will cause standard UDP downloading to be used instead.
===============
*/
qboolean CL_QueueHTTPDownload (const char *quakePath)
{
	size_t		len;
	dlqueue_t	*q;
	qboolean	needList;

	// no http server (or we got booted)
	if (!cls.downloadServer[0] || abortDownloads || thisMapAbort || !cl_http_downloads->value)
		return false;

	needList = false;

	// first download queued, so we want the mod filelist
	if (!cls.downloadQueue.next && cl_http_filelists->value)
		needList = true;

	q = &cls.downloadQueue;

	while (q->next)
	{
		q = q->next;

		//avoid sending duplicate requests
		if (!strcmp (quakePath, q->quakePath))
			return true;
	}

//	q->next = Z_TagMalloc (sizeof(*q), TAGMALLOC_CLIENT_DOWNLOAD);
	q->next = Z_TagMalloc (sizeof(*q), 0);
	q = q->next;

	q->next = NULL;
	q->state = DLQ_STATE_NOT_STARTED;
	Q_strncpyz (q->quakePath, quakePath, sizeof(q->quakePath)-1);

	if (needList)
	{
		//grab the filelist
		CL_QueueHTTPDownload (va("%s.filelist", cl.gamedir));

		//this is a nasty hack to let the server know what we're doing so admins don't
		//get confused by a ton of people stuck in CNCT state. it's assumed the server
		//is running r1q2 if we're even able to do http downloading so hopefully this
		//won't spew an error msg.
	//	MSG_BeginWriting (clc_stringcmd);
	//	MSG_WriteString ("download http\n");
	//	MSG_EndWriting (&cls.netchan.message);
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		MSG_WriteString (&cls.netchan.message, "download http\n");
	}

	//special case for map file lists, i really wanted a server-push mechanism for this, but oh well
	len = strlen (quakePath);
	if (cl_http_filelists->value && len > 4 && !Q_stricmp ((char *)(quakePath + len - 4), ".bsp"))
	{
		char	listPath[MAX_OSPATH];
		char	filePath[MAX_OSPATH];

		Com_sprintf (filePath, sizeof(filePath), "%s/%s", cl.gamedir, quakePath);

		COM_StripExtension (filePath, listPath);
	//	strncat (listPath, ".filelist");
		Q_strncatz (listPath, ".filelist", sizeof(listPath));
		
		CL_QueueHTTPDownload (listPath);
	}

	//if a download entry has made it this far, CL_FinishHTTPDownload is guaranteed to be called.
	pendingCount++;

	return true;
}
예제 #9
0
/*
==================
SV_GameMap_f

Saves the state of the map just being exited and goes to a new map.

If the initial character of the map string is '*', the next map is
in a new unit, so the current savegame directory is cleared of
map files.

Example:

*inter.cin+jail

Clears the archived maps, plays the inter.cin cinematic, then
goes to map jail.bsp.
==================
*/
void SV_GameMap_f (void)
{
	char		*map;
	int32_t			i, l;
	client_t	*cl;
	qboolean	*savedInuse;

	if (Cmd_Argc() != 2)
	{
		Com_Printf ("USAGE: gamemap <map>\n");
		return;
	}

	Com_DPrintf("SV_GameMap(%s)\n", Cmd_Argv(1));

	FS_CreatePath (va("%s/save/current/", FS_Gamedir()));

	// check for clearing the current savegame
	map = Cmd_Argv(1);
	if (map[0] == '*')
	{
		// wipe all the *.sav files
		SV_WipeSavegame ("current");
	}
	else
	{
		// save the map just exited
		if (sv.state == ss_game)
		{
			// clear all the client inuse flags before saving so that
			// when the level is re-entered, the clients will spawn
			// at spawn points instead of occupying body shells
			savedInuse = (qboolean*)Z_TagMalloc(maxclients->value * sizeof(qboolean), TAG_SERVER);
			for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
			{
				savedInuse[i] = cl->edict->inuse;
				cl->edict->inuse = false;
			}

			SV_WriteLevelFile ();

			// we must restore these for clients to transfer over correctly
			for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
				cl->edict->inuse = savedInuse[i];
			Z_Free (savedInuse);
		}
	}

	// start up the next map
	SV_Map (false, Cmd_Argv(1), false );

	// archive server state
	strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1);

	// copy off the level to the autosave slot
	// Knightmare- don't do this in deathmatch or for cinematics
	l = strlen(map);
	//l = strcspn(map, "+");
	if (!dedicated->value && !Cvar_VariableValue("deathmatch")
		&& Q_strcasecmp (map+l-4, ".cin") && Q_strcasecmp (map+l-4, ".roq")
		&& Q_strcasecmp (map+l-4, ".pcx"))
	{
		SV_WriteServerFile (true);
		SV_CopySaveGame ("current", "vrsave00");
	}
}
예제 #10
0
파일: g_main.c 프로젝트: greck2908/qengine
void InitGame(void)
{
  PF_dprintf("Game is starting up.\n");
  PF_dprintf("Game is %s built on %s.\n", GAMEVERSION, BUILD_DATE);

  gun_x = Cvar_Get("gun_x", "0", 0);
  gun_y = Cvar_Get("gun_y", "0", 0);
  gun_z = Cvar_Get("gun_z", "0", 0);
  sv_rollspeed = Cvar_Get("sv_rollspeed", "200", 0);
  sv_rollangle = Cvar_Get("sv_rollangle", "2", 0);
  sv_maxvelocity = Cvar_Get("sv_maxvelocity", "2000", 0);
  sv_gravity = Cvar_Get("sv_gravity", "800", 0);

  /* noset vars */
  dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);

  /* latched vars */
  sv_cheats = Cvar_Get("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
  Cvar_Get("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
  Cvar_Get("gamedate", BUILD_DATE, CVAR_SERVERINFO | CVAR_LATCH);
  maxclients = Cvar_Get("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
  maxspectators = Cvar_Get("maxspectators", "4", CVAR_SERVERINFO);
  deathmatch = Cvar_Get("deathmatch", "0", CVAR_LATCH);
  coop = Cvar_Get("coop", "0", CVAR_LATCH);
  skill = Cvar_Get("skill", "1", CVAR_LATCH);
  maxentities = Cvar_Get("maxentities", "1024", CVAR_LATCH);

  /* change anytime vars */
  dmflags = Cvar_Get("dmflags", "0", CVAR_SERVERINFO);
  fraglimit = Cvar_Get("fraglimit", "0", CVAR_SERVERINFO);
  timelimit = Cvar_Get("timelimit", "0", CVAR_SERVERINFO);
  password = Cvar_Get("password", "", CVAR_USERINFO);
  spectator_password = Cvar_Get("spectator_password", "", CVAR_USERINFO);
  needpass = Cvar_Get("needpass", "0", CVAR_SERVERINFO);
  filterban = Cvar_Get("filterban", "1", 0);
  g_select_empty = Cvar_Get("g_select_empty", "0", CVAR_ARCHIVE);
  run_pitch = Cvar_Get("run_pitch", "0.002", 0);
  run_roll = Cvar_Get("run_roll", "0.005", 0);
  bob_up = Cvar_Get("bob_up", "0.005", 0);
  bob_pitch = Cvar_Get("bob_pitch", "0.002", 0);
  bob_roll = Cvar_Get("bob_roll", "0.002", 0);

  /* flood control */
  flood_msgs = Cvar_Get("flood_msgs", "4", 0);
  flood_persecond = Cvar_Get("flood_persecond", "4", 0);
  flood_waitdelay = Cvar_Get("flood_waitdelay", "10", 0);

  /* dm map list */
  sv_maplist = Cvar_Get("sv_maplist", "", 0);

  /* items */
  InitItems();

  /* initialize all entities for this game */
  game.maxentities = maxentities->value;
  g_edicts = Z_TagMalloc(game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
  globals.edicts = g_edicts;
  globals.max_edicts = game.maxentities;

  /* initialize all clients for this game */
  game.maxclients = maxclients->value;
  game.clients = Z_TagMalloc(game.maxclients * sizeof(game.clients[0]), TAG_GAME);
  globals.num_edicts = game.maxclients + 1;
  globals.edict_size = sizeof(edict_t);
}
예제 #11
0
파일: cvar.c 프로젝트: turol/webquake2
static void Cvar_List_f (void)
{
	const cvar_t	*var;
	int		i, j;
	int		len, num;
	cvar_t	*sortedList;
	int		argLen;

	argLen = (int)strlen(Cmd_Argv(1));

	for (var = cvar_vars, i = 0; var ; var = var->next, i++);
	num = i;

	len = num * sizeof(cvar_t);
	sortedList = (cvar_t *) Z_TagMalloc (len, TAGMALLOC_CVAR);
	//sortedList = alloca(len);
	
	for (var = cvar_vars, i = 0; var ; var = var->next, i++)
	{
		sortedList[i] = *var;
	}

	qsort (sortedList, num, sizeof(sortedList[0]), (int (EXPORT *)(const void *, const void *))cvarsort);

	for (j = 0; j < num; j++)
	{
		var = &sortedList[j];
		if (argLen && Q_strncasecmp (var->name, Cmd_Argv(1), argLen))
			continue;

		if (!argLen)
		{
			if (var->flags & CVAR_ARCHIVE)
				Com_Printf ("*", LOG_GENERAL);
			else
				Com_Printf (" ", LOG_GENERAL);
			if (var->flags & CVAR_USERINFO)
				Com_Printf ("U", LOG_GENERAL);
			else
				Com_Printf (" ", LOG_GENERAL);
			if (var->flags & CVAR_SERVERINFO)
				Com_Printf ("S", LOG_GENERAL);
			else
				Com_Printf (" ", LOG_GENERAL);
			if (var->flags & CVAR_NOSET)
				Com_Printf ("-", LOG_GENERAL);
			else if (var->flags & CVAR_LATCH)
				Com_Printf ("L", LOG_GENERAL);
			else
				Com_Printf (" ", LOG_GENERAL);
			Com_Printf (" %s \"%s\"\n", LOG_GENERAL, var->name, var->string);
		}
		else
		{
			Com_Printf ("v %s\n", LOG_GENERAL, var->name);
		}
	}
	if (!argLen)
		Com_Printf ("%i cvars\n", LOG_GENERAL, i);

	Z_Free (sortedList);
}
예제 #12
0
파일: snd_qal.c 프로젝트: raynorpat/cake
void QAL_Info(void)
{
	Com_Printf("AL_VENDOR: %s\n", qalGetString(AL_VENDOR));
	Com_Printf("AL_RENDERER: %s\n", qalGetString(AL_RENDERER));
	Com_Printf("AL_VERSION: %s\n", qalGetString(AL_VERSION));
	Com_DPrintf("AL_EXTENSIONS: %s\n", qalGetString(AL_EXTENSIONS));

	// print out available devices
	if (qalcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
	{
		const char *devs = qalcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);

		Com_Printf("\nAvailable OpenAL devices:\n");

		if (devs == NULL)
		{
			// no devices, might be an old OpenAL 1.0 or prior system...
			Com_Printf(S_COLOR_RED "- No devices found. Depending on your\n");
			Com_Printf(S_COLOR_RED "  platform this may be expected and\n");
			Com_Printf(S_COLOR_RED "  doesn't indicate a problem!\n");
		}
		else
		{
			while (devs && *devs)
			{
				Com_Printf("- %s\n", devs);
				devs += strlen(devs) + 1;
			}
		}
	}

	// print out current device
	if (qalcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT"))
	{
		const char *devs = qalcGetString(device, ALC_DEVICE_SPECIFIER);
		Com_Printf("\nCurrent OpenAL device:\n");
		if (devs == NULL)
			Com_Printf("- No OpenAL device in use\n");
		else
			Com_Printf("- %s\n", devs);
	}

	// grab frequency for device
	{
		ALCint attr_size;
		ALCint * attributes;
		int i = 0;
		qalcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, sizeof(attr_size), &attr_size);
		attributes = (ALCint *)Z_TagMalloc(attr_size * sizeof(ALCint), 0);
		qalcGetIntegerv(device, ALC_ALL_ATTRIBUTES, attr_size, attributes);
		for (i = 0; i < attr_size; i += 2)
		{
			if (attributes[i] == ALC_FREQUENCY)
				Com_Printf("ALC_FREQUENCY: %i\n", attributes[i + 1]);
		}
		Z_Free(attributes);
	}

	// check for hrtf support
	if (qalcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
	{
		alcGetIntegerv(device, ALC_HRTF_SOFT, 1, &hrtf_state);
		if (!hrtf_state)
		{
			Com_Printf(S_COLOR_RED "HRTF not enabled!\n");
		}
		else
		{
			const ALchar *name = alcGetString(device, ALC_HRTF_SPECIFIER_SOFT);
			Com_Printf(S_COLOR_GREEN "HRTF enabled, using %s\n", name);
		}
	}
}
예제 #13
0
파일: files.c 프로젝트: Slipyx/r1q2
/*
=================
FS_LoadPackFile

Takes an explicit (not game tree related) path to a pak file.

Loads the header and directory, adding the files at the beginning
of the list so they override previous pack files.
=================
*/
static pack_t /*@null@*/ *FS_LoadPackFile (const char *packfile, const char *ext)
{
	
	int				i;
	void			**newitem;
	pack_t			*pack = NULL;
	packfile_t		*info;

	if (!strcmp (ext, "pak"))
	{
		unsigned		pakLen;
		int				numpackfiles;
		FILE			*packhandle;
		dpackheader_t	header;

		packhandle = fopen(packfile, "rb");

		if (!packhandle)
			return NULL;

		fseek (packhandle, 0, SEEK_END);
		pakLen = ftell (packhandle);
		rewind (packhandle);

		if (fread (&header, sizeof(header), 1, packhandle) != 1)
			Com_Error (ERR_FATAL, "FS_LoadPackFile: Couldn't read pak header from %s", packfile);

		if (LittleLong(header.ident) != IDPAKHEADER)
			Com_Error (ERR_FATAL, "FS_LoadPackFile: %s is not a valid pak file.", packfile);
		
	#if YOU_HAVE_A_BROKEN_COMPUTER
		header.dirofs = LittleLong (header.dirofs);
		header.dirlen = LittleLong (header.dirlen);
	#endif

		if (header.dirlen % sizeof(packfile_t))
			Com_Error (ERR_FATAL, "FS_LoadPackFile: Bad pak file %s (directory length %u is not a multiple of %d)", packfile, header.dirlen, (int)sizeof(packfile_t));

		numpackfiles = header.dirlen / sizeof(packfile_t);

		if (numpackfiles > MAX_FILES_IN_PACK)
			//Com_Error (ERR_FATAL, "FS_LoadPackFile: packfile %s has %i files (max allowed %d)", packfile, numpackfiles, MAX_FILES_IN_PACK);
			Com_Printf ("WARNING: Pak file %s has %i files (max allowed %d) - may not be compatible with other clients\n", LOG_GENERAL, packfile, numpackfiles, MAX_FILES_IN_PACK);

		if (!numpackfiles)
		{
			fclose (packhandle);
			Com_Printf ("WARNING: Empty packfile %s\n", LOG_GENERAL|LOG_WARNING, packfile);
			return NULL;
		}

		//newfiles = Z_TagMalloc (numpackfiles * sizeof(packfile_t), TAGMALLOC_FSLOADPAK);
		info = Z_TagMalloc (numpackfiles * sizeof(packfile_t), TAGMALLOC_FSLOADPAK);

		if (fseek (packhandle, header.dirofs, SEEK_SET))
			Com_Error (ERR_FATAL, "FS_LoadPackFile: fseek() to offset %u in %s failed. Pak file is possibly corrupt.", header.dirofs, packfile);

		if ((int)fread (info, 1, header.dirlen, packhandle) != header.dirlen)
			Com_Error (ERR_FATAL, "FS_LoadPackFile: Error reading packfile directory from %s (failed to read %u bytes at %u). Pak file is possibly corrupt.", packfile, header.dirofs, header.dirlen);

		pack = Z_TagMalloc (sizeof (pack_t), TAGMALLOC_FSLOADPAK);
		pack->type = PAK_QUAKE;
		pack->rb = rbinit ((int (EXPORT *)(const void *, const void *))strcmp, numpackfiles);

		//entry = Z_TagMalloc (sizeof(packfile_t) * numpackfiles, TAGMALLOC_FSLOADPAK);

		for (i=0 ; i<numpackfiles ; i++)
		{
			fast_strlwr (info[i].name);
#if YOU_HAVE_A_BROKEN_COMPUTER
			info[i].filepos = LittleLong(info[i].filepos);
			info[i].filelen = LittleLong(info[i].filelen);
#endif
			if (info[i].filepos + info[i].filelen >= pakLen)
				Com_Error (ERR_FATAL, "FS_LoadPackFile: File '%.64s' in pak file %s has illegal offset %u past end of file %u. Pak file is possibly corrupt.", MakePrintable (info[i].name, 0), packfile, info[i].filepos, pakLen);
			
			newitem = rbsearch (info[i].name, pack->rb);
			*newitem = &info[i];
		}

		Q_strncpy (pack->filename, packfile, sizeof(pack->filename)-1);

		pack->h.handle = packhandle;
		pack->numfiles = numpackfiles;

		Com_Printf ("Added packfile %s (%i files)\n", LOG_GENERAL,  packfile, numpackfiles);
	}
#ifndef NO_ZLIB
	else if (!strcmp (ext, "pkz"))
	{
		unzFile			f;
		unz_global_info	zipinfo;
		char			zipFileName[56];
		unz_file_info	fileInfo;

		f = unzOpen (packfile);
		if (!f)
			return NULL;

		if (unzGetGlobalInfo (f, &zipinfo) != UNZ_OK)
			Com_Error (ERR_FATAL, "FS_LoadPackFile: Couldn't read .zip info from '%s'", packfile);

		info = Z_TagMalloc (zipinfo.number_entry * sizeof(*info), TAGMALLOC_FSLOADPAK);

		pack = Z_TagMalloc (sizeof (pack_t), TAGMALLOC_FSLOADPAK);
		pack->type = PAK_ZIP;
		pack->rb = rbinit ((int (EXPORT *)(const void *, const void *))strcmp, zipinfo.number_entry);

		if (unzGoToFirstFile (f) != UNZ_OK)
			Com_Error (ERR_FATAL, "FS_LoadPackFile: Couldn't seek to first .zip file in '%s'", packfile);

		zipFileName[sizeof(zipFileName)-1] = 0;
		i = 0;
		do
		{
			if (unzGetCurrentFileInfo (f, &fileInfo, zipFileName, sizeof(zipFileName)-1, NULL, 0, NULL, 0) == UNZ_OK)
			{
				//directory, ignored
				if (fileInfo.external_fa & 16)
					continue;
				strcpy (info[i].name, zipFileName);
				info[i].filepos = unzGetOffset (f);
				info[i].filelen = fileInfo.uncompressed_size;
				newitem = rbsearch (info[i].name, pack->rb);
				*newitem = &info[i];
				i++;
			}
		} while (unzGoToNextFile (f) == UNZ_OK);

		pack->h.zhandle = f;
		Com_Printf ("Added zpackfile %s (%i files)\n", LOG_GENERAL,  packfile, i);
	}
#endif
	else
	{
		Com_Error (ERR_FATAL, "FS_LoadPackFile: Unknown type %s", ext);
	}

	return pack;
}
예제 #14
0
파일: files.c 프로젝트: Slipyx/r1q2
static void FS_LoadPaks (const char *dir, const char *ext)
{
	int				i;
	int				total;
	int				totalpaks;
	size_t			pakmatchlen;

	char			pakfile[MAX_OSPATH];
	char			pakmatch[MAX_OSPATH];
	char			*s;

	char			*filenames[4096];
	int				pakfiles[1024];

	pack_t			*pak;
	searchpath_t	*search;

	//r1: load all *.pak files
	Com_sprintf (pakfile, sizeof(pakfile), "%s/*.%s", dir, ext);
	Com_sprintf (pakmatch, sizeof(pakmatch), "%s/pak", dir);
	pakmatchlen = strlen(pakmatch);

	total = 0;
	totalpaks = 0;

	if ((s = Sys_FindFirst (pakfile, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM)) != NULL)
	{
		while (s)
		{
			i = (int)strlen (s);
			if (*(s+(i-4)) == '.' && !Q_stricmp (s+(i-3), ext))
			{
				if (!Q_strncasecmp (s, pakmatch, pakmatchlen))
				{
					pakfiles[totalpaks++] = atoi(s+pakmatchlen);
				}
				else
				{
					filenames[total++] = strdup(s);
					//filenames[total] = alloca(strlen(s)+1);
					//strcpy (filenames[total], s);
					//total++;
				}
			}

			s = Sys_FindNext (0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);
		}
	}

	Sys_FindClose ();

	//sort for filenames designed to override earlier pak files
	qsort (filenames, total, sizeof(filenames[0]), filecmp);
	qsort (pakfiles, totalpaks, sizeof(pakfiles[0]), pakcmp);

	//r1: load pak*.pak first
	for (i = 0; i < totalpaks; i++)
	{
		Com_sprintf (pakfile, sizeof(pakfile), "%s/pak%d.%s", dir, pakfiles[i], ext);
		pak = FS_LoadPackFile (pakfile, ext);
		if (pak)
		{
			search = Z_TagMalloc (sizeof(searchpath_t), TAGMALLOC_SEARCHPATH);
			search->pack = pak;
			search->filename[0] = 0;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
	}

	//now the rest of them
	for (i = 0; i < total; i++)
	{
		pak = FS_LoadPackFile (filenames[i], ext);
		if (pak)
		{
			search = Z_TagMalloc (sizeof(searchpath_t), TAGMALLOC_SEARCHPATH);
			search->pack = pak;
			search->filename[0] = 0;
			search->next = fs_searchpaths;
			fs_searchpaths = search;
		}
		free (filenames[i]);
	}
}
예제 #15
0
파일: winamp.c 프로젝트: chrisnew/quake2
int MP3_ParsePlaylist_EXTM3U(char *playlist_buf, unsigned int length, mp3_tracks_t *songList, const char *filter)
{
	int i, skip = 0, playlist_size = 0;
	char *s, *t, *buf, *line;
	int trackNum = 0, songCount = 0, trackNum2 = 0, trackNumLen = 0, j;
	qboolean counted = false;

	for(i = 0; i < 2; i++)
	{
		buf = playlist_buf;
		trackNum = 0;
		for (;;) {
			for (s = line = buf; s - playlist_buf < length && *s && *s != '\n' && *s != '\r'; s++)
				;
			if (s - playlist_buf >= length)
				break;
			*s = 0;
			buf = s + 2;
			if (skip || !strncmp(line, "#EXTM3U", 7)) {
				skip = 0;
				continue;
			}
			if (!strncmp(line, "#EXTINF:", 8)) {
				if (!(s = strchr(line, ',')) || ++s - playlist_buf >= length) 
					break;
				
				skip = 1;
				goto print;
			}
		
			for (s = line + strlen(line); s > line && *s != '\\' && *s != '/'; s--)
				;
			if (s != line)
				s++;
		
			if ((t = strrchr(s, '.')) && t - playlist_buf < length)
				*t = 0;		
		
			for (t = s + strlen(s) - 1; t > s && *t == ' '; t--)
				*t = 0;

	print:
			trackNum++;

			if(!Q_stristr(s, filter))
				continue;

			if(!counted) {
				trackNum2 = trackNum;
				songCount++;
				continue;
			}

			if (strlen(s) >= MP3_MAXSONGTITLE-1)
				s[MP3_MAXSONGTITLE-1] = 0;

			COM_MakePrintable(s);
			songList->num[playlist_size] = trackNum;
			songList->name[playlist_size++] = CopyString(va("%*i. %s", trackNumLen, trackNum, s), TAG_MP3LIST);

			if(playlist_size >= songCount)
				break;
		}
		if(!counted)
		{
			if(!songCount)
				return 0;

			for(j = 1; ; j++)
			{
				if(trackNum2 < (int)pow(10, j))
				{
					trackNumLen = j;
					break;
				}
			}
			songList->name = Z_TagMalloc (sizeof(char *) * songCount, TAG_MP3LIST);
			songList->num = Z_TagMalloc (sizeof(int) * songCount, TAG_MP3LIST);
			counted = true;
		}
	}
	return playlist_size;
}
예제 #16
0
파일: sv_init.c 프로젝트: postfix/quake2vr
void SV_InitGame (void)
{
	int32_t		i;
	edict_t	*ent;
	char	idmaster[32];

	if (svs.initialized)
	{
		// cause any connected clients to reconnect
		SV_Shutdown ("Server restarted\n", true);
	}
	else
	{
		// make sure the client is down
		CL_Drop ();
		SCR_BeginLoadingPlaque ();
	}

	// get any latched variable changes (maxclients, etc)
	Cvar_GetLatchedVars ();

	svs.initialized = true;

	if (Cvar_VariableValue ("coop") && Cvar_VariableValue ("deathmatch"))
	{
		Com_Printf("Deathmatch and Coop both set, disabling Coop\n");
		Cvar_FullSet ("coop", "0",  CVAR_SERVERINFO | CVAR_LATCH);
	}

	// dedicated servers can't be single player and are usually DM
	// so unless they explicity set coop, force it to deathmatch
	if (dedicated->value)
	{
		if (!Cvar_VariableValue ("coop"))
			Cvar_FullSet ("deathmatch", "1",  CVAR_SERVERINFO | CVAR_LATCH);
	}

	// init clients
	if (Cvar_VariableValue ("deathmatch"))
	{
		if (maxclients->value <= 1)
			Cvar_FullSet ("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH);
		else if (maxclients->value > MAX_CLIENTS)
			Cvar_FullSet ("maxclients", va("%i", MAX_CLIENTS), CVAR_SERVERINFO | CVAR_LATCH);
	}
	else if (Cvar_VariableValue ("coop"))
	{
		if (maxclients->value <= 1 || maxclients->value > 4)
			Cvar_FullSet ("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
	}
	else	// non-deathmatch, non-coop is one player
	{
		Cvar_FullSet ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH);
	}

	svs.spawncount = rand();
	svs.clients = (client_t*)Z_TagMalloc (sizeof(client_t)*maxclients->value, TAG_SERVER);
	svs.num_client_entities = maxclients->value*UPDATE_BACKUP*64;
	svs.client_entities = (entity_state_t*)Z_TagMalloc (sizeof(entity_state_t)*svs.num_client_entities, TAG_SERVER);

	// init network stuff
	NET_Config ( (maxclients->value > 1) );

	// heartbeats will always be sent to the id master
	svs.last_heartbeat = -99999;		// send immediately
	Com_sprintf(idmaster, sizeof(idmaster), "192.246.40.37:%i", PORT_MASTER);
	NET_StringToAdr (idmaster, &master_adr[0]);

	// init game
	SV_InitGameProgs ();
	for (i = 0; i < maxclients->value; i++)
	{
		ent = EDICT_NUM(i+1);
		ent->s.number = i+1;
		svs.clients[i].edict = ent;
		memset (&svs.clients[i].lastcmd, 0, sizeof(svs.clients[i].lastcmd));
	}
}
예제 #17
0
파일: cmd.c 프로젝트: Slipyx/r1q2
/*
=================
Cbuf_AddLateCommands

Adds command line parameters as script statements
Commands lead with a + and continue until another + or -
quake +vid_ref gl +map amlev1

Returns true if any late commands were added, which
will keep the demoloop from immediately starting
=================
*/
qboolean Cbuf_AddLateCommands (void)
{
	int		i, j;
	int		s;
	char	*text, *build, c;
	int		argc;
	qboolean	ret;

	// build the combined string to parse from
	s = 0;
	argc = COM_Argc();
	for (i=1 ; i<argc ; i++)
	{
		s += (int)strlen (COM_Argv(i)) + 1;
	}
	if (!s)
		return false;
		
	text = Z_TagMalloc (s+1, TAGMALLOC_CMDBUFF);
	//text = alloca (s+1);
	text[0] = 0;
	for (i=1 ; i<argc ; i++)
	{
		strcat (text,COM_Argv(i));
		if (i != argc-1)
			strcat (text, " ");
	}

	//awful hack to prevent arbitrary cmd execution with quake2:// links due to q2s bad quote parser
	if (!strncmp (text, "+connect \"quake2://", 19))
	{
		if (strchr (text + 1, '+'))
			Com_Error (ERR_FATAL, "Attempt to use multiple commands in a quake2:// protocol handler:\n\n%s", text);
	}
	
	// pull out the commands
	build = Z_TagMalloc (s+1, TAGMALLOC_CMDBUFF);
	//build = alloca (s+1);
	build[0] = 0;
	
	for (i=0 ; i<s-1 ; i++)
	{
		if (text[i] == '+')
		{
			i++;

			for (j=i ; (text[j] != '+') && (text[j] != 0) ; j++)
				;

			c = text[j];
			text[j] = 0;
			
			strcat (build, text+i);
			strcat (build, "\n");
			text[j] = c;
			i = j-1;
		}
	}

	ret = (build[0] != 0);
	if (ret)
		Cbuf_AddText (build);
	
	Z_Free (text);
	Z_Free (build);

	return ret;
}
예제 #18
0
파일: sv_anticheat.c 프로젝트: Slipyx/r1q2
static void SV_AntiCheat_ParseCvarLine (char *line, int line_number, const char *filename)
{
	cvarcheck_t *checks;
	char		*p, *q;
	char		*var_name, *op, *var_value, *default_value;
	cvarop_e	eop;
	int			num_values, i;
	char		**tokens;

	p = strchr (line, '\t');
	if (!p)
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	var_name = line;

	p[0] = 0;
	p++;

	op = p;

	if (!p[0])
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	p = strchr (op, '\t');
	if (!p)
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	p[0] = 0;
	p++;

	var_value = p;

	if (!p[0])
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	p = strchr (var_value, '\t');
	if (!p)
	{
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	p[0] = 0;
	p++;

	default_value = p;

	if (strlen (var_name) >= 64 || !var_name[0])
	{
		Com_Printf ("ANTICHEAT WARNING: Invalid cvar name '%s' in anticheat-cvars.txt at line %d\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, var_name, line_number);
		return;
	}

	if (strlen (default_value) >= 64 || !default_value[0])
	{
		Com_Printf ("ANTICHEAT WARNING: Invalid default value '%s' in anticheat-cvars.txt at line %d\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, default_value, line_number);
		return;
	}

	num_values = 1;

	p = var_value;
	while (p)
	{
		p = strchr (p, ',');
		if (p)
		{
			num_values++;
			p++;
		}
	}

	if (num_values >= 255)
	{
		Com_Printf ("ANTICHEAT WARNING: Too many values on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line);
		return;
	}

	tokens = Z_TagMalloc (num_values * sizeof(char *), TAGMALLOC_ANTICHEAT);

	i = 0;
	p = q = var_value;
	while (p)
	{
		p = strchr (p, ',');
		if (p)
		{
			p[0] = 0;
			tokens[i++] = q;
			p++;
			q = p;
		}
		else
			tokens[i++] = q;
	}

	for (i = 0; i < num_values; i++)
	{
		if (strlen (tokens[i]) > 64 || !tokens[i][0])
		{
			Com_Printf ("ANTICHEAT WARNING: Bad value '%s' on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, tokens[i], line_number, line);
			Z_Free (tokens);
			return;
		}
	}

	if (!strcmp (op, "=") || !strcmp (op, "=="))
	{
		eop = OP_EQUAL;
	}
	else if (!strcmp (op, "!="))
	{
		eop = OP_NEQUAL;
	}
	else if (!strcmp (op, ">="))
	{
		if (num_values > 1)
		{
			Z_Free (tokens);
			Com_Printf ("ANTICHEAT WARNING: Unsupported multiple values with op '%s' on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, op, line_number, line);
			return;
		}
		eop = OP_GTEQUAL;
	}
	else if (!strcmp (op, "<="))
	{
		if (num_values > 1)
		{
			Z_Free (tokens);
			Com_Printf ("ANTICHEAT WARNING: Unsupported multiple values with op '%s' on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, op, line_number, line);
			return;
		}
		eop = OP_LTEQUAL;
	}
	else if (!strcmp (op, ">"))
	{
		if (num_values > 1)
		{
			Z_Free (tokens);
			Com_Printf ("ANTICHEAT WARNING: Unsupported multiple values with op '%s' on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, op, line_number, line);
			return;
		}
		eop = OP_GT;
	}
	else if (!strcmp (op, "<"))
	{
		if (num_values > 1)
		{
			Z_Free (tokens);
			Com_Printf ("ANTICHEAT WARNING: Unsupported multiple values with op '%s' on line %d '%s' in anticheat-cvars.txt\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, op, line_number, line);
			return;
		}
		eop = OP_LT;
	}
	else if (!strcmp (op, "eq"))
	{
		eop = OP_STREQUAL;
	}
	else if (!strcmp (op, "ne"))
	{
		eop = OP_STRNEQUAL;
	}
	else if (!strcmp (op, "~"))
	{
		eop = OP_STRSTR;
	}
	else
	{
		Z_Free (tokens);
		Com_Printf ("ANTICHEAT WARNING: Malformed line %d '%s' in anticheat-cvars.txt: unknown op '%s'\n", LOG_WARNING|LOG_ANTICHEAT|LOG_SERVER, line_number, line, op);
		return;
	}

	checks = &cvarChecks;

	while (checks->next)
		checks = checks->next;

	checks->next = Z_TagMalloc (sizeof (*checks), TAGMALLOC_ANTICHEAT);
	checks = checks->next;

	checks->next = NULL;
	checks->var_name = CopyString (var_name, TAGMALLOC_ANTICHEAT);
	checks->op = eop;

	checks->var_values = Z_TagMalloc (num_values * sizeof(char *), TAGMALLOC_ANTICHEAT);
	for (i = 0; i < num_values; i++)
		checks->var_values[i] = CopyString (tokens[i], TAGMALLOC_ANTICHEAT);
	
	checks->num_values = num_values;

	checks->default_value = CopyString (default_value, TAGMALLOC_ANTICHEAT);

	Z_Free (tokens);
	
	antiCheatNumCvarChecks++;
}
예제 #19
0
void OVR_CalculateState(vr_param_t *state)
{
	vr_param_t ovrState;
	float ovrScale = vr_ovr_supersample->value;
	int eye = 0;

	for (eye = 0; eye < 2; eye++) {
		ovrDistortionMesh meshData;
		ovr_vert_t *mesh = NULL;
		ovr_vert_t *v = NULL;
		ovrDistortionVertex *ov = NULL;
		unsigned int i = 0;
		float vignette_factor;
		if (vr_ovr_maxfov->value)
		{
			renderInfo[eye].eyeFov = hmd->MaxEyeFov[eye];
		} else
		{
			renderInfo[eye].eyeFov = hmd->DefaultEyeFov[eye];
		}

		ovrState.eyeFBO[eye] = &renderInfo[eye].eyeFBO;

		ovrState.renderParams[eye].projection.x.scale = 2.0f / ( renderInfo[eye].eyeFov.LeftTan + renderInfo[eye].eyeFov.RightTan );
		ovrState.renderParams[eye].projection.x.offset = ( renderInfo[eye].eyeFov.LeftTan - renderInfo[eye].eyeFov.RightTan ) * ovrState.renderParams[eye].projection.x.scale * 0.5f;
		ovrState.renderParams[eye].projection.y.scale = 2.0f / ( renderInfo[eye].eyeFov.UpTan + renderInfo[eye].eyeFov.DownTan );
		ovrState.renderParams[eye].projection.y.offset = ( renderInfo[eye].eyeFov.UpTan - renderInfo[eye].eyeFov.DownTan ) * ovrState.renderParams[eye].projection.y.scale * 0.5f;

		// set up rendering info
		eyeDesc[eye] = ovrHmd_GetRenderDesc(hmd,(ovrEyeType) eye,renderInfo[eye].eyeFov);

		VectorSet(ovrState.renderParams[eye].viewOffset,
			-eyeDesc[eye].HmdToEyeViewOffset.x,
			eyeDesc[eye].HmdToEyeViewOffset.y,
			eyeDesc[eye].HmdToEyeViewOffset.z);

		ovrHmd_CreateDistortionMesh(hmd, eyeDesc[eye].Eye, eyeDesc[eye].Fov, ovrDistortionCap_Chromatic | ovrDistortionCap_SRGB | ovrDistortionCap_TimeWarp | ovrDistortionCap_Vignette, &meshData);

		mesh = (ovr_vert_t *) Z_TagMalloc(sizeof(ovr_vert_t) * meshData.VertexCount, TAG_RENDERER);
		v = mesh;
		ov = meshData.pVertexData; 
		for (i = 0; i < meshData.VertexCount; i++)
		{

			// DK2 display not rotated - rotate the coordinates manually
			if (vid.width < vid.height) {
				v->pos.x = -ov->ScreenPosNDC.y;
				v->pos.y = ov->ScreenPosNDC.x;
			} else {
				v->pos.x = ov->ScreenPosNDC.x;
				v->pos.y = ov->ScreenPosNDC.y;
			}

			v->texR = (*(ovrVector2f*)&ov->TanEyeAnglesR); 
			v->texG = (*(ovrVector2f*)&ov->TanEyeAnglesG);
			v->texB = (*(ovrVector2f*)&ov->TanEyeAnglesB); 
			vignette_factor = ov->VignetteFactor;
			if (vignette_factor < 0) vignette_factor = 0;
			v->color[0] = v->color[1] = v->color[2] = (GLubyte)(vignette_factor  * 255.99f);
			v->color[3] = (GLubyte)( ov->TimeWarpFactor * 255.99f );
			v++; ov++;
		}

		R_BindIVBO(&renderInfo[eye].eye,NULL,0);
		R_VertexData(&renderInfo[eye].eye,sizeof(ovr_vert_t) * meshData.VertexCount, mesh);
		R_IndexData(&renderInfo[eye].eye,GL_TRIANGLES,GL_UNSIGNED_SHORT,meshData.IndexCount,sizeof(uint16_t) * meshData.IndexCount,meshData.pIndexData);
		R_ReleaseIVBO();
		Z_Free(mesh);
		ovrHmd_DestroyDistortionMesh( &meshData );
	}
	{
		// calculate this to give the engine a rough idea of the fov
		float combinedTanHalfFovHorizontal = max ( max ( renderInfo[0].eyeFov.LeftTan, renderInfo[0].eyeFov.RightTan ), max ( renderInfo[1].eyeFov.LeftTan, renderInfo[1].eyeFov.RightTan ) );
		float combinedTanHalfFovVertical = max ( max ( renderInfo[0].eyeFov.UpTan, renderInfo[0].eyeFov.DownTan ), max ( renderInfo[1].eyeFov.UpTan, renderInfo[1].eyeFov.DownTan ) );
		float horizontalFullFovInRadians = 2.0f * atanf ( combinedTanHalfFovHorizontal ); 
		float fovX = RAD2DEG(horizontalFullFovInRadians);
		float fovY = RAD2DEG(2.0 * atanf(combinedTanHalfFovVertical));
		ovrState.aspect = combinedTanHalfFovHorizontal / combinedTanHalfFovVertical;
		ovrState.viewFovY = fovY;
		ovrState.viewFovX = fovX;
		ovrState.pixelScale = ovrScale * vid.width / (float) hmd->Resolution.w;
	}

	*state = ovrState;
}
예제 #20
0
파일: cl_cin.c 프로젝트: postfix/quake2vr
/*
==================
Huff1Decompress
==================
*/
cblock_t Huff1Decompress (cblock_t in)
{
	byte		*input;
	byte		*out_p;
	int32_t			nodenum;
	int32_t			count;
	cblock_t	out;
	int32_t			inbyte;
	int32_t			*hnodes, *hnodesbase;
	//int32_t		i;

	// get decompressed count
	count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
	input = in.data + 4;
	out_p = out.data = Z_TagMalloc (count, TAG_CLIENT);

	// read bits

	hnodesbase = cin.hnodes1 - 256*2;	// nodes 0-255 aren't stored

	hnodes = hnodesbase;
	nodenum = cin.numhnodes1[0];
	while (count)
	{
		inbyte = *input++;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
		//-----------
		if (nodenum < 256)
		{
			hnodes = hnodesbase + (nodenum<<9);
			*out_p++ = nodenum;
			if (!--count)
				break;
			nodenum = cin.numhnodes1[nodenum];
		}
		nodenum = hnodes[nodenum*2 + (inbyte&1)];
		inbyte >>=1;
	}

	if (input - in.data != in.count && input - in.data != in.count+1)
	{
		Com_Printf ("Decompression overread by %i", (input - in.data) - in.count);
	}
	out.count = out_p - out.data;

	return out;
}