コード例 #1
0
ファイル: map_q1.c プロジェクト: morsik/war-territory
//===========================================================================
// water, slime and lava brush textures names always start with a *
// followed by the type: "slime", "lava" or otherwise water
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int Q1_TextureContents(char *name)
{
	if (!Q_strcasecmp(name, "clip"))
	{
		return CONTENTS_SOLID;
	}
	if (name[0] == '*')
	{
		if (!Q_strncasecmp(name + 1, "lava", 4))
		{
			return CONTENTS_LAVA;
		}
		else if (!Q_strncasecmp(name + 1, "slime", 5))
		{
			return CONTENTS_SLIME;
		}
		else
		{
			return CONTENTS_WATER;
		}
	} //end if
	else if (!Q_strncasecmp(name, "sky", 3))
	{
		return CONTENTS_SOLID;
	}
	else
	{
		return CONTENTS_SOLID;
	}
} //end of the function Q1_TextureContents
コード例 #2
0
int Q_strcasecmp (const char *s1, const char *s2)
{
	AssertValidStringPtr(s1);
	AssertValidStringPtr(s2);

	return Q_strncasecmp (s1, s2, 99999);
}
コード例 #3
0
ファイル: map.c プロジェクト: kellyrm/Q1
/*
===============
FindTexinfo

Returns a global texinfo number
===============
*/
int	FindTexinfo (texinfo_t *t)
{
	int			i, j;
	texinfo_t	*tex;

// set the special flag
	if (miptex[t->miptex][0] == '*' ||
	    !options.SolidMap && !Q_strncasecmp (miptex[t->miptex], "sky",3) )
		t->flags |= TEX_SPECIAL;


	tex = texinfo;
	for (i=0 ; i<numtexinfo;i++, tex++)
	{
		if (t->miptex != tex->miptex)
			continue;
		if (t->flags != tex->flags)
			continue;

		for (j=0 ; j<8 ; j++)
			if (t->vecs[0][j] != tex->vecs[0][j])
				break;
		if (j != 8)
			continue;

		return i;
	}

// allocate a new texture
	ExtendArray(texinfo, i);
	texinfo[i] = *t;
	numtexinfo++;

	return i;
}
コード例 #4
0
ファイル: cl_http.c プロジェクト: Kiln707/KMQuake2
/*
===============
CL_HTTP_Header

libcurl callback to update header info.
===============
*/
static size_t /*EXPORT*/ CL_HTTP_Header (void *ptr, size_t size, size_t nmemb, void *stream)
{
	char	headerBuff[1024];
	size_t	bytes;
	size_t	len;

	bytes = size * nmemb;

	if (bytes <= 16)
		return bytes;

	//memset (headerBuff, 0, sizeof(headerBuff));
	//memcpy (headerBuff, ptr, min(bytes, sizeof(headerBuff)-1));
	if (bytes < sizeof(headerBuff)-1)
		len = bytes;
	else
		len = sizeof(headerBuff)-1;

	Q_strncpyz (headerBuff, ptr, len);

	if (!Q_strncasecmp (headerBuff, "Content-Length: ", 16))
	{
		dlhandle_t	*dl;

		dl = (dlhandle_t *)stream;

		if (dl->file)
			dl->fileSize = strtoul (headerBuff + 16, NULL, 10);
	}

	return bytes;
}
コード例 #5
0
//-----------------------------------------------------------------------------
// Purpose: Convert "chan_xxx" into integer value for channel
// Input  : *name - 
// Output : static int
//-----------------------------------------------------------------------------
int TextToChannel( const char *name )
{
	if ( !name )
	{
		Assert( 0 );
		// CHAN_AUTO
		return CHAN_AUTO;
	}

	if ( Q_strncasecmp( name, "chan_", strlen( "chan_" ) ) )
	{
		return atoi( name );
	}

	int c = ARRAYSIZE( g_pChannelNames );
	int i;

	for ( i = 0; i < c; i++ )
	{
		if ( !Q_strcasecmp( name, g_pChannelNames[ i ].name ) )
		{
			return g_pChannelNames[ i ].channel;
		}
	}

	// At this point, it starts with chan_ but is not recognized
	// atoi would return 0, so just do chan auto
	DevMsg( "CSoundEmitterSystem:  Warning, unknown channel type in sounds.txt (%s)\n", name );

	return CHAN_AUTO;
}
コード例 #6
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseObject::AddAndParseBuildPoint( int iAttachmentNumber, KeyValues *pkvBuildPoint )
{
	int iPoint = AddBuildPoint( iAttachmentNumber );

	
	m_BuildPoints[iPoint].m_bPutInAttachmentSpace = (pkvBuildPoint->GetInt( "PutInAttachmentSpace", 0 ) != 0);

	// Now see if we've got a set of valid objects specified
	KeyValues *pkvValidObjects = pkvBuildPoint->FindKey( "valid_objects" );
	if ( pkvValidObjects )
	{
		KeyValues *pkvObject = pkvValidObjects->GetFirstSubKey();
		while ( pkvObject )
		{
			const char *pSpecifiedObject = pkvObject->GetName();
			int iLenObjName = Q_strlen( pSpecifiedObject );

			// Find the object index for the name
			for ( int i = 0; i < OBJ_LAST; i++ )
			{
				if ( !Q_strncasecmp( GetObjectInfo( i )->m_pClassName, pSpecifiedObject, iLenObjName) )
				{
					AddValidObjectToBuildPoint( iPoint, i );
					break;
				}
			}

			pkvObject = pkvObject->GetNextKey();
		}
	}
}
コード例 #7
0
ファイル: cl_http.c プロジェクト: Bad-ptr/q2pro
// libcurl callback to update header info.
static size_t header_func (void *ptr, size_t size, size_t nmemb, void *stream) {
    size_t len, bytes = size * nmemb;
    dlhandle_t *dl = (dlhandle_t *)stream;
    char buffer[64];

    if (dl->size)
        return bytes;

    if (bytes <= 16)
        return bytes;

    if (bytes > sizeof(buffer)-1)
        bytes = sizeof(buffer)-1;

    memcpy (buffer, ptr, bytes);
    buffer[bytes] = 0;

    if (!Q_strncasecmp (buffer, "Content-Length: ", 16)) {
        //allocate buffer based on what the server claims content-length is. +1 for nul
        len = strtoul (buffer + 16, NULL, 10);
        if (len >= MAX_DLSIZE) {
            Com_DPrintf ("[HTTP] Oversize file while trying to download '%s'\n", dl->url);
            return 0;
        }
        dl->size = len + 1;
        dl->buffer = Z_Malloc (dl->size);
    }

    return bytes;
}
コード例 #8
0
ファイル: map.c プロジェクト: dommul/super8
/*
===============
FindTexinfo

Returns a global texinfo number
===============
*/
int	FindTexinfo( texinfo_t *t )
{
	int			i, j;
	texinfo_t	*tex;

	// set the special flag
	if( (miptex[t->miptex][0] == '*' && !waterlightmap) || !Q_strncasecmp (miptex[t->miptex], "sky", 3) )
		t->flags |= TEX_SPECIAL;

	tex = texinfo;
	for( i = 0; i < numtexinfo; i++, tex++ ) {
		if( t->miptex != tex->miptex )
			continue;
		if( t->flags != tex->flags )
			continue;

		for( j = 0; j < 8; j++ ) {
			if( t->vecs[0][j] != tex->vecs[0][j] )
				break;
		}
		if( j != 8 )
			continue;

		return i;
	}

	// allocate a new texture
	if( numtexinfo == MAX_MAP_TEXINFO )
		Error( "numtexinfo == MAX_MAP_TEXINFO" );

	texinfo[i] = *t;

	return numtexinfo++;
}
コード例 #9
0
int Q_strnicmp (const char *s1, const char *s2, int n)
{
	Assert( n >= 0 );
	AssertValidStringPtr(s1);
	AssertValidStringPtr(s2);

	return Q_strncasecmp( s1, s2, n );
}
コード例 #10
0
ファイル: writebsp.cpp プロジェクト: Filip98/source-sdk-2013
void SetLightStyles (void)
{
    int		stylenum;
    char	*t;
    entity_t	*e;
    int		i, j;
    char	value[10];
    char	lighttargets[MAX_SWITCHED_LIGHTS][64];


    // any light that is controlled (has a targetname)
    // must have a unique style number generated for it

    stylenum = 0;
    for (i=1 ; i<num_entities ; i++)
    {
        e = &entities[i];

        t = ValueForKey (e, "classname");
        if (Q_strncasecmp (t, "light", 5))
            continue;

        // This is not true for dynamic lights
        if (!Q_strcasecmp (t, "light_dynamic"))
            continue;

        t = ValueForKey (e, "targetname");
        if (!t[0])
            continue;

        // find this targetname
        for (j=0 ; j<stylenum ; j++)
            if (!strcmp (lighttargets[j], t))
                break;
        if (j == stylenum)
        {
            if (stylenum == MAX_SWITCHED_LIGHTS)
                Error ("Too many switched lights (error at light %s), max = %d", t, MAX_SWITCHED_LIGHTS);
            strcpy (lighttargets[j], t);
            stylenum++;
        }
        sprintf (value, "%i", 32 + j);
        char *pCurrentStyle = ValueForKey( e, "style" );
        // the designer has set a default lightstyle as well as making the light switchable
        if ( pCurrentStyle )
        {
            int oldStyle = atoi(pCurrentStyle);
            if ( oldStyle != 0 )
            {
                // save off the default style so the game code can make a switchable copy of it
                SetKeyValue( e, "defaultstyle", pCurrentStyle );
            }
        }
        SetKeyValue (e, "style", value);
    }

}
コード例 #11
0
ファイル: cmd.c プロジェクト: Rinnegatamante/ctrHexenII
void ListCommands (char *prefix)
{
	cmd_function_t	*cmd;
	int preLen = strlen(prefix);

	for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
	{
		if(!Q_strncasecmp(prefix,cmd->name,preLen))
			Con_Printf ("%s\n", cmd->name);
	}
}
コード例 #12
0
ファイル: shared.cpp プロジェクト: Isaacssv552/ufoai
const char* Q_stristr (const char* str, const char* substr)
{
	const size_t sublen = strlen(substr);
	while (*str) {
		if (!Q_strncasecmp(str, substr, sublen))
			break;
		str++;
	}
	if (!(*str))
		str = nullptr;
	return str;
}
コード例 #13
0
void CSoundParametersInternal::SoundLevelFromString( const char *sz )
{
	if ( !Q_strncasecmp( sz, "SNDLVL_", strlen( "SNDLVL_" ) ) )
	{
		soundlevel.start = TextToSoundLevel( sz );
		soundlevel.range = 0;
	}
	else
	{
		soundlevel.FromInterval( ReadInterval( sz ) );
	}
}
コード例 #14
0
void CSoundEmitterSystemBase::CSoundParametersInternal::SoundLevelFromString( const char *sz )
{
	if ( !Q_strncasecmp( sz, "SNDLVL_", strlen( "SNDLVL_" ) ) )
	{
		soundlevel.start = TextToSoundLevel( sz );
		soundlevel.range = 0.0f;
	}
	else
	{
		soundlevel = ReadInterval( sz );
	}

	Q_strncpy( m_szSoundLevel, sz, sizeof( m_szSoundLevel ) );
}
コード例 #15
0
ファイル: map.c プロジェクト: kellyrm/Q1
int FindMiptex (char *name)
{
	int		i;

	for (i=0 ; i<nummiptex ; i++)
	{
		if (!Q_strncasecmp(name, miptex[i], sizeof(char16)))
			return i;
	}
        ExtendArray(miptex, i);
	CleanupName (name, miptex[i]);
	nummiptex++;
	return i;
}
コード例 #16
0
void Movie_Demo_Capture_f(void) {
	int argc;
	double time;
	char *error;
	
	error = va("Usage: %s <start time | stop>\n", Cmd_Argv(0));
	if ((argc = Cmd_Argc()) != 2 && argc != 3) {
		Com_Printf(error);
		return;
	}
	if (argc == 2) {
		if (Q_strncasecmp("stop", Cmd_Argv(1), 4))
			Com_Printf(error);
		else if (Movie_IsCapturing())
			Movie_Stop();
		else
			Com_Printf("%s : Not capturing\n", Cmd_Argv(0));
		return;
	}
	if (Q_strncasecmp("start", Cmd_Argv(1), 5)) {
		Com_Printf(error);
		return;
	} else if (Movie_IsCapturing()) {
		Com_Printf("%s : Already capturing\n", Cmd_Argv(0));
		return;
	}
	if (!cls.demoplayback || cls.timedemo) {
		Com_Printf("%s : Must be playing a demo to capture\n", Cmd_Argv(0));
		return;
	}
	if ((time = Q_atof(Cmd_Argv(2))) <= 0) {
		Com_Printf("%s : Time argument must be positive\n", Cmd_Argv(0));
		return;
	}
	Movie_Start(time);
}
コード例 #17
0
ファイル: prompt.c プロジェクト: Bad-ptr/q2pro
qboolean Prompt_AddMatch( genctx_t *ctx, const char *s ) {
    int r;

    if( ctx->count >= ctx->size ) {
        return qfalse;
    }
    if( ctx->ignorecase ) {
        r = Q_strncasecmp( ctx->partial, s, ctx->length );
    } else {
        r = strncmp( ctx->partial, s, ctx->length );
    }
    if( !r ) {
        ctx->matches[ctx->count++] = Z_CopyString( s );
    }
    return qtrue;
}
コード例 #18
0
ファイル: cmdlib.cpp プロジェクト: chrizonix/RCBot2
bool CmdLib_HasBasePath( const char *pFileName_, int &pathLength )
{
	char *pFileName = ( char * )_alloca( strlen( pFileName_ ) + 1 );
	strcpy( pFileName, pFileName_ );
	Q_FixSlashes( pFileName );
	pathLength = 0;
	int i;
	for( i = 0; i < g_NumBasePaths; i++ )
	{
		// see if we can rip the base off of the filename.
		if( Q_strncasecmp( g_pBasePaths[i], pFileName, strlen( g_pBasePaths[i] ) ) == 0 )
		{
			pathLength = strlen( g_pBasePaths[i] );
			return true;
		}
	}
	return false;
}
コード例 #19
0
ファイル: qdata.c プロジェクト: clbr/netradiant
void ReleaseTexture (char *name)
{
	int		i;
	char	path[1024];

	for (i=0 ; i<numrtex ; i++)
		if (!Q_strncasecmp(name, rtex[i], strlen(name)))
			return;

	if (numrtex == MAX_RTEX)
		Error ("numrtex == MAX_RTEX");

	strcpy (rtex[i], name);
	numrtex++;

	sprintf (path, "textures/%s.wal", name);
	ReleaseFile (path);
}
コード例 #20
0
ファイル: writebsp.c プロジェクト: Garux/netradiant-custom
void SetLightStyles( void ){
	int stylenum;
	char    *t;
	entity_t    *e;
	int i, j;
	char value[10];
	char lighttargets[MAX_SWITCHED_LIGHTS][64];


	// any light that is controlled (has a targetname)
	// must have a unique style number generated for it

	stylenum = 0;
	for ( i = 1 ; i < num_entities ; i++ )
	{
		e = &entities[i];

		t = ValueForKey( e, "classname" );
		if ( Q_strncasecmp( t, "light", 5 ) ) {
			continue;
		}
		t = ValueForKey( e, "targetname" );
		if ( !t[0] ) {
			continue;
		}

		// find this targetname
		for ( j = 0 ; j < stylenum ; j++ )
			if ( !strcmp( lighttargets[j], t ) ) {
				break;
			}
		if ( j == stylenum ) {
			if ( stylenum == MAX_SWITCHED_LIGHTS ) {
				Error( "stylenum == MAX_SWITCHED_LIGHTS" );
			}
			strcpy( lighttargets[j], t );
			stylenum++;
		}
		sprintf( value, "%i", 32 + j );
		SetKeyValue( e, "style", value );
	}

}
コード例 #21
0
ファイル: q_shared.c プロジェクト: Bad-ptr/q2pro
char *Q_strcasestr( const char *s1, const char *s2 ) {
    size_t l1, l2;

    l2 = strlen( s2 );
    if( !l2 ) {
        return ( char * )s1;
    }

    l1 = strlen( s1 );
    while( l1 >= l2 ) {
        l1--;
        if( !Q_strncasecmp( s1, s2, l2 ) ) {
            return ( char * )s1;
        }
        s1++;
    }

    return NULL;
}
コード例 #22
0
ファイル: prompt.c プロジェクト: Jenco420/q2pro
qboolean Prompt_AddMatch(genctx_t *ctx, const char *s)
{
    int r;

    if (ctx->count >= ctx->size)
        return qfalse;

    if (ctx->ignorecase)
        r = Q_strncasecmp(ctx->partial, s, ctx->length);
    else
        r = strncmp(ctx->partial, s, ctx->length);

    if (r)
        return qtrue;

    if (ctx->ignoredups && find_dup(ctx, s))
        return qtrue;

    ctx->matches[ctx->count++] = Z_CopyString(s);
    return qtrue;
}
コード例 #23
0
ファイル: files.c プロジェクト: qbism/qbq2
/*
=================
FS_FileInPakBlacklist

Checks against a blacklist to see if a file
should not be loaded from a pak.
=================
*/
qboolean FS_FileInPakBlacklist(char *filename)
{
	int			i;
	char		*compare;
	qboolean	ignore = false;

	compare = filename;
	if (compare[0] == '/')	// remove leading slash
		compare++;

	for (i = 0; pakfile_ignore_names[i]; i++) {
		if (!Q_strncasecmp(compare, pakfile_ignore_names[i], strlen(pakfile_ignore_names[i])))
			ignore = true;
	}

	//	if (ignore)
	//		Com_Printf ("FS_LoadPackFile: file %s blacklisted!\n", filename);
	//	else if ( !strncmp (filename, "save/", 5) )
	//		Com_Printf ("FS_LoadPackFile: file %s not blacklisted.\n", filename);
	return ignore;
}
コード例 #24
0
ファイル: cmd.c プロジェクト: Slipyx/r1q2
void Cmd_Aliaslist_f (void)
{
	cmdalias_t	*a;
	int argLen;
	int i, j;
	int len, num;
	cmdalias_t *sortedList;

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

	for (a = cmd_alias, i = 0; a ; a = a->next, i++);
	num = i;

	len = num * sizeof(cmdalias_t);
	sortedList = Z_TagMalloc (len, TAGMALLOC_CMD);
	//sortedList = alloca(len);
	
	for (a = cmd_alias, i = 0; a ; a = a->next, i++)
	{
		sortedList[i] = *a;
	}

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

	//for (a = cmd_alias ; a ; a=a->next)
	for (j = 0; j < num; j++)
	{
		a = &sortedList[j];

		if (argLen && Q_strncasecmp (a->name, Cmd_Argv(1), argLen))
			continue;

		if (argLen)
			Com_Printf ("a %s\n", LOG_GENERAL, a->name);
		else
			Com_Printf ("%s : %s\n", LOG_GENERAL, a->name, a->value);
	}

	Z_Free (sortedList);
}
コード例 #25
0
ファイル: cmd.c プロジェクト: Slipyx/r1q2
void Cmd_List_f (void)
{
	cmd_function_t	*cmd;
	int				i, j;
	int				len, num;
	int				argLen;
	cmd_function_t	*sortedList;

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

	for (cmd = cmd_functions, i = 0; cmd ; cmd = cmd->next, i++);
	num = i;

	len = num * sizeof(cmd_function_t);
	sortedList = Z_TagMalloc (len, TAGMALLOC_CMD);
	//sortedList = alloca(len);
	
	for (cmd = cmd_functions, i = 0; cmd ; cmd = cmd->next, i++)
	{
		sortedList[i] = *cmd;
	}

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

	//for (cmd=cmd_functions ; cmd ; cmd=cmd->next, i++)
	for (j = 0; j < num; j++)
	{
		cmd = &sortedList[j];

		if (argLen && Q_strncasecmp (cmd->name, Cmd_Argv(1), argLen))
			continue;
		Com_Printf ("c %s\n", LOG_GENERAL, cmd->name);
	}

	if (!argLen)
		Com_Printf ("%i commands\n", LOG_GENERAL, i);

	Z_Free (sortedList);
}
コード例 #26
0
ファイル: g_tdm_curl.c プロジェクト: notr1ch/opentdm
/*
===============
HTTP_Header

libcurl callback to update header info.
===============
*/
static size_t EXPORT HTTP_Header (void *ptr, size_t size, size_t nmemb, void *stream)
{
	char	headerBuff[1024];
	size_t	bytes;
	size_t	len;

	bytes = size * nmemb;

	if (bytes <= 16)
		return bytes;

	if (bytes < sizeof(headerBuff)-1)
		len = bytes;
	else
		len = sizeof(headerBuff)-1;

	Q_strncpy (headerBuff, ptr, len);

	if (!Q_strncasecmp (headerBuff, "Content-Length: ", 16))
	{
		dlhandle_t	*dl;

		dl = (dlhandle_t *)stream;

		//allocate buffer based on what the server claims content-length is. +1 for nul
		dl->fileSize = strtoul (headerBuff + 16, NULL, 10);
		if (!dl->tempBuffer)
		{
			if (dl->fileSize < 1048576)
				dl->tempBuffer = gi.TagMalloc (dl->fileSize + 1, TAG_GAME);
			else
				gi.dprintf ("Suspiciously large file while trying to download %s!\n", dl->URL);
		}
	}

	return bytes;
}
コード例 #27
0
ファイル: BRUSH.C プロジェクト: ChunHungLiu/Quake-Tools
/*
===============
LoadBrush

Converts a mapbrush to a bsp brush
===============
*/
brush_t *LoadBrush (mbrush_t *mb, int hullnum)
{
	brush_t		*b;
	int			contents;
	char		*name;
	mface_t		*f;

//
// check texture name for attributes
//	
	name = miptex[texinfo[mb->faces->texinfo].miptex];

	if (!Q_strcasecmp(name, "clip") && hullnum == 0)
		return NULL;		// "clip" brushes don't show up in the draw hull
	
	if (name[0] == '*' && worldmodel)		// entities never use water merging
	{
		if (!Q_strncasecmp(name+1,"lava",4))
			contents = CONTENTS_LAVA;
		else if (!Q_strncasecmp(name+1,"slime",5))
			contents = CONTENTS_SLIME;
		else			
			contents = CONTENTS_WATER;
	}
	else if (!Q_strncasecmp (name, "sky",3) && worldmodel && hullnum == 0)
		contents = CONTENTS_SKY;
	else
		contents = CONTENTS_SOLID;

	if (hullnum && contents != CONTENTS_SOLID && contents != CONTENTS_SKY)
		return NULL;		// water brushes don't show up in clipping hulls

// no seperate textures on clip hull

//
// create the faces
//
	brush_faces = NULL;
	
	numbrushfaces = 0;
	for (f=mb->faces ; f ; f=f->next)
	{
		faces[numbrushfaces] = *f;
		if (hullnum)
			faces[numbrushfaces].texinfo = 0;
		numbrushfaces++;
	}
		
	CreateBrushFaces ();
	
	if (!brush_faces)
	{
		printf ("WARNING: couldn't create brush faces\n");
		return NULL;
	}

	if (hullnum)
	{
		ExpandBrush (hullnum);
		CreateBrushFaces ();
	}
	
//
// create the brush
//
	b = AllocBrush ();
	
	b->contents = contents;
	b->faces = brush_faces;
	VectorCopy (brush_mins, b->mins);
	VectorCopy (brush_maxs, b->maxs);

	return b;
}
コード例 #28
0
ファイル: writebsp.c プロジェクト: ChunHungLiu/GtkRadiant
void SetLightStyles( void )
{
	int			i, j, style, numStyles;
	qboolean	keepLights;
	const char	*t;
	entity_t	*e;
	epair_t		*ep, *next;
	char		value[ 10 ];
	char		lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
	int			lightStyles[ MAX_SWITCHED_LIGHTS ];
	
	
	/* ydnar: determine if we keep lights in the bsp */
	t = ValueForKey( &entities[ 0 ], "_keepLights" );
	keepLights = (t[ 0 ] == '1') ? qtrue : qfalse;
	
	/* any light that is controlled (has a targetname) must have a unique style number generated for it */
	numStyles = 0;
	for( i = 1; i < numEntities; i++ )
	{
		e = &entities[ i ];

		t = ValueForKey( e, "classname" );
		if( Q_strncasecmp( t, "light", 5 ) )
			continue;
		t = ValueForKey( e, "targetname" );
		if( t[ 0 ] == '\0' )
		{
			/* ydnar: strip the light from the BSP file */
			if( keepLights == qfalse )
			{
				ep = e->epairs;
				while( ep != NULL )
				{
					next = ep->next;
					free( ep->key );
					free( ep->value );
					free( ep );
					ep = next;
				}
				e->epairs = NULL;
				numStrippedLights++;
			}
			
			/* next light */
			continue;
		}
		
		/* get existing style */
		style = IntForKey( e, "style" );
		if( style < LS_NORMAL || style > LS_NONE )
			Error( "Invalid lightstyle (%d) on entity %d", style, i );
		
		/* find this targetname */
		for( j = 0; j < numStyles; j++ )
			if( lightStyles[ j ] == style && !strcmp( lightTargets[ j ], t ) )
				break;
		
		/* add a new style */
		if( j >= numStyles )
		{
			if( numStyles == MAX_SWITCHED_LIGHTS )
				Error( "MAX_SWITCHED_LIGHTS (%d) exceeded, reduce the number of lights with targetnames", MAX_SWITCHED_LIGHTS );
			strcpy( lightTargets[ j ], t );
			lightStyles[ j ] = style;
			numStyles++;
		}
		
		/* set explicit style */
		sprintf( value, "%d", 32 + j );
		SetKeyValue( e, "style", value );
		
		/* set old style */
		if( style != LS_NORMAL )
		{
			sprintf( value, "%d", style );
			SetKeyValue( e, "switch_style", value );
		}
	}
	
	/* emit some statistics */
	Sys_FPrintf( SYS_VRB, "%9d light entities stripped\n", numStrippedLights );
}
コード例 #29
0
ファイル: path_init.c プロジェクト: clbr/netradiant
void InitPaths( int *argc, char **argv )
{
	int		i, j, k, len, len2;
	char	temp[ MAX_OS_PATH ];
	
	
	/* note it */
	Sys_FPrintf( SYS_VRB, "--- InitPaths ---\n" );
	
	/* get the install path for backup */
	LokiInitPaths( argv[ 0 ] );
	
	/* set game to default (q3a) */
	game = &games[ 0 ];
	numBasePaths = 0;
	numGamePaths = 0;
	
	/* parse through the arguments and extract those relevant to paths */
	for( i = 0; i < *argc; i++ )
	{
		/* check for null */
		if( argv[ i ] == NULL )
			continue;
		
		/* -game */
		if( strcmp( argv[ i ], "-game" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No game specified after %s", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			game = GetGame( argv[ i ] );
			if( game == NULL )
				game = &games[ 0 ];
			argv[ i ] = NULL;
		}

		/* -fs_forbiddenpath */
		else if( strcmp( argv[ i ], "-fs_forbiddenpath" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			if(g_numForbiddenDirs < VFS_MAXDIRS)
			{
				strncpy(g_strForbiddenDirs[g_numForbiddenDirs], argv[i], PATH_MAX);
				g_strForbiddenDirs[g_numForbiddenDirs][PATH_MAX] = 0;
				++g_numForbiddenDirs;
			}
			argv[ i ] = NULL;
		}

		/* -fs_basepath */
		else if( strcmp( argv[ i ], "-fs_basepath" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			AddBasePath( argv[ i ] );
			argv[ i ] = NULL;
		}
		
		/* -fs_game */
		else if( strcmp( argv[ i ], "-fs_game" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			AddGamePath( argv[ i ] );
			argv[ i ] = NULL;
		}
		
		/* -fs_home */
		else if( strcmp( argv[ i ], "-fs_home" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			homePath = argv[i];
			argv[ i ] = NULL;
		}
		
		/* -fs_homebase */
		else if( strcmp( argv[ i ], "-fs_homebase" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			homeBasePath = argv[i];
			argv[ i ] = NULL;
		}

		/* -fs_homepath - sets both of them */
		else if( strcmp( argv[ i ], "-fs_homepath" ) == 0 )
		{
			if( ++i >= *argc )
				Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
			argv[ i - 1 ] = NULL;
			homePath = argv[i];
			homeBasePath = ".";
			argv[ i ] = NULL;
		}
	}
	
	/* remove processed arguments */
	for( i = 0, j = 0, k = 0; i < *argc && j < *argc; i++, j++ )
	{
		for( ; j < *argc && argv[ j ] == NULL; j++ );
		argv[ i ] = argv[ j ];
		if( argv[ i ] != NULL )
			k++;
	}
	*argc = k;
	
	/* add standard game path */
	AddGamePath( game->gamePath );
	
	/* if there is no base path set, figure it out */
	if( numBasePaths == 0 )
	{
		/* this is another crappy replacement for SetQdirFromPath() */
		len2 = strlen( game->magic );
		for( i = 0; i < *argc && numBasePaths == 0; i++ )
		{
			/* extract the arg */
			strcpy( temp, argv[ i ] );
			CleanPath( temp );
			len = strlen( temp );
			Sys_FPrintf( SYS_VRB, "Searching for \"%s\" in \"%s\" (%d)...\n", game->magic, temp, i );
			
			/* this is slow, but only done once */
			for( j = 0; j < (len - len2); j++ )
			{
				/* check for the game's magic word */
				if( Q_strncasecmp( &temp[ j ], game->magic, len2 ) == 0 )
				{
					/* now find the next slash and nuke everything after it */
					while( temp[ ++j ] != '/' && temp[ j ] != '\0' );
					temp[ j ] = '\0';
					
					/* add this as a base path */
					AddBasePath( temp );
					break;
				}
			}
		}
		
		/* add install path */
		if( numBasePaths == 0 )
			AddBasePath( installPath );
		
		/* check again */
		if( numBasePaths == 0 )
			Error( "Failed to find a valid base path." );
	}
	
	/* this only affects unix */
	if(homeBasePath)
		AddHomeBasePath( homeBasePath );
	else
		AddHomeBasePath( game->homeBasePath );
	
	/* initialize vfs paths */
	if( numBasePaths > MAX_BASE_PATHS )
		numBasePaths = MAX_BASE_PATHS;
	if( numGamePaths > MAX_GAME_PATHS )
		numGamePaths = MAX_GAME_PATHS;
	
	/* walk the list of game paths */
	for( j = 0; j < numGamePaths; j++ )
	{
		/* walk the list of base paths */
		for( i = 0; i < numBasePaths; i++ )
		{
			/* create a full path and initialize it */
			sprintf( temp, "%s/%s/", basePaths[ i ], gamePaths[ j ] );
			vfsInitDirectory( temp );
		}
	}
	
	/* done */
	Sys_Printf( "\n" );
}
コード例 #30
0
ファイル: textures.cpp プロジェクト: 0xFEEDC0DE64/UltraGame
int	FindMiptex (const char *name)
{
	int		i;
	MaterialSystemMaterial_t matID;
	const char *propVal, *propVal2;
	int opacity;
	bool found;
		
	for (i=0 ; i<nummiptex ; i++)
	{
		if (!strcmp (name, textureref[i].name))
		{
			return i;
		}
	}
	if (nummiptex == MAX_MAP_TEXTURES)
		Error ("Too many unique textures, max %d", MAX_MAP_TEXTURES);
	strcpy (textureref[i].name, name);

	textureref[i].lightmapWorldUnitsPerLuxel = 0.0f;
	textureref[i].flags = 0;
	textureref[i].contents = 0;

	matID = FindOriginalMaterial( name, &found );
	if( matID == MATERIAL_NOT_FOUND )
	{
		return 0;
	}

	if (!found)
		Warning("Material not found!: %s\n", name );

	// HANDLE ALL OF THE STUFF THAT ISN'T RENDERED WITH THE MATERIAL THAT IS ONE IT.
	
	// handle sky
	if( ( propVal = GetMaterialVar( matID, "%compileSky" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_SKY | SURF_NOLIGHT;
	}
	else if( ( propVal = GetMaterialVar( matID, "%compile2DSky" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_SKY | SURF_SKY2D | SURF_NOLIGHT;
	}
	// handle hint brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileHint" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_HINT;
	}
	// handle skip faces
	else if ( ( propVal = GetMaterialVar( matID, "%compileSkip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT | SURF_SKIP;
	}
	// handle origin brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileOrigin" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_ORIGIN | CONTENTS_DETAIL;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_PLAYERCLIP | CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	else if ( ( propVal = GetMaterialVar( matID, "%playerClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_PLAYERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle npc clip brushes
	else if ( ( propVal = GetMaterialVar( matID, "%compileNpcClip" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].contents |= CONTENTS_MONSTERCLIP;
		textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
	}
	// handle surface lights which are meant to 
	else if ( ( propVal = GetMaterialVar( matID, "%compileNoChop" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= SURF_NOCHOP;
	}
	// handle triggers
	else if ( ( propVal = GetMaterialVar( matID, "%compileTrigger" ) ) &&
		StringIsTrue( propVal ) )
	{
		textureref[i].flags |= ( SURF_NOLIGHT | SURF_TRIGGER );
		if ( g_NodrawTriggers )
		{
			textureref[i].flags |= SURF_NODRAW;
		}
	}
	// handle nolight surfs (except water)
	else if ( (( propVal = GetMaterialVar( matID, "%compileNoLight" ) ) && StringIsTrue( propVal )) && 
		!(( propVal2 = GetMaterialVar( matID, "%compileWater" ) ) && StringIsTrue( propVal2 ) ) )
	{
		textureref[i].flags |= SURF_NOLIGHT;
	}
	else
	{
		// HANDLE ALL OF THE STUFF THAT IS RENDERED WITH THE MATERIAL THAT IS ON IT.

		// Handle ladders.
		if ( ( propVal = GetMaterialVar( matID, "%compileLadder" ) ) &&	StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_LADDER;
		}

		// handle wet materials
		if ( ( propVal = GetMaterialVar( matID, "%noPortal" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].flags |= SURF_NOPORTAL;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compilePassBullets" ) ) && StringIsTrue( propVal ) )
		{
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
		}

		if( g_BumpAll || GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_BUMPED_LIGHTMAPS ) )
		{
			textureref[i].flags |= SURF_BUMPLIGHT;
		}
		
		if( GetMaterialShaderPropertyBool( matID, UTILMATLIB_NEEDS_LIGHTMAP ) )
		{
			textureref[i].flags &= ~SURF_NOLIGHT;
		}
		else if( !g_bLightIfMissing )
		{
			textureref[i].flags |= SURF_NOLIGHT;
		}
		// handle nodraw faces/brushes
		if ( ( propVal = GetMaterialVar( matID, "%compileNoDraw" ) ) && StringIsTrue( propVal ) )
		{								    
			//		textureref[i].contents |= CONTENTS_DETAIL;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		// Just a combination of nodraw + pass bullets, makes things easier
		if ( ( propVal = GetMaterialVar( matID, "%compileInvisible" ) ) && StringIsTrue( propVal ) )
		{								    
			// change contents to grate, so bullets pass through
			// NOTE: This has effects on visibility too!
			textureref[i].contents &= ~CONTENTS_SOLID;
			textureref[i].contents |= CONTENTS_GRATE;
			textureref[i].flags |= SURF_NODRAW | SURF_NOLIGHT;
		}

		bool checkWindow = true;
		// handle non solid
		if ( ( propVal = GetMaterialVar( matID, "%compileNonsolid" ) ) && StringIsTrue( propVal ) )
		{
			textureref[i].contents = CONTENTS_OPAQUE;
			// Non-Solid can't be a window either!
			checkWindow = false;
		}
		// handle block LOS
		if ( ( propVal = GetMaterialVar( matID, "%compileBlockLOS" ) ) && StringIsTrue( propVal ) )
		{
			textureref[i].contents = CONTENTS_BLOCKLOS;

			// BlockLOS can't be a window either!
			checkWindow = false;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compileDetail" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents |= CONTENTS_DETAIL;
		}

		bool bKeepLighting = ( ( propVal = GetMaterialVar( matID, "%compileKeepLight" ) ) &&
			StringIsTrue( propVal ) );

		// handle materials that want to be treated as water.
		if ( ( propVal = GetMaterialVar( matID, "%compileWater" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_WATER;
			textureref[i].flags |= SURF_WARP | SURF_NOSHADOWS | SURF_NODECALS;

			if ( g_DisableWaterLighting && !bKeepLighting )
			{
				textureref[i].flags |= SURF_NOLIGHT;
			}

			// Set this so that we can check at the end of the process the presence of a a WaterLODControl entity.
			g_bHasWater = true;
		}
		const char *pShaderName = GetMaterialShaderName(matID);
		if ( !bKeepLighting && !Q_strncasecmp( pShaderName, "water", 5 ) || !Q_strncasecmp( pShaderName, "UnlitGeneric", 12 ) )
		{
			//if ( !(textureref[i].flags & SURF_NOLIGHT) )
			//	Warning("Forcing lit materal %s to nolight\n", name );
			textureref[i].flags |= SURF_NOLIGHT;
		}

		if ( ( propVal = GetMaterialVar( matID, "%compileSlime" ) ) &&
			StringIsTrue( propVal ) )
		{
			textureref[i].contents &= ~(CONTENTS_SOLID|CONTENTS_DETAIL);
			textureref[i].contents |= CONTENTS_SLIME;
			textureref[i].flags |= SURF_NODECALS;
			// Set this so that we can check at the end of the process the presence of a a WaterLODControl entity.
			g_bHasWater = true;
		}
	
		opacity = GetMaterialShaderPropertyInt( matID, UTILMATLIB_OPACITY );
		
		if ( checkWindow && opacity != UTILMATLIB_OPAQUE )
		{
			// transparent *and solid* brushes that aren't grates or water must be windows
			if ( !(textureref[i].contents & (CONTENTS_GRATE|CONTENTS_WATER)) )
			{
				textureref[i].contents |= CONTENTS_WINDOW;
			}

			textureref[i].contents &= ~CONTENTS_SOLID;
			
			// this affects engine primitive sorting, SURF_TRANS means sort as a translucent primitive
			if ( opacity == UTILMATLIB_TRANSLUCENT )
			{
				textureref[i].flags |= SURF_TRANS;
			}
			
		}
		if ( textureref[i].flags & SURF_NOLIGHT )
		{
			textureref[i].flags &= ~SURF_BUMPLIGHT;
		}
	}

	nummiptex++;

	return i;
}