wrap Q_strncasecmp use
This commit is contained in:
parent
c7f1391177
commit
9048028faa
|
|
@ -162,7 +162,7 @@ void SetQdirFromPath( const char *path ){
|
||||||
len = strlen( BASEDIRNAME );
|
len = strlen( BASEDIRNAME );
|
||||||
for ( c = path + strlen( path ) - 1 ; c != path ; c-- )
|
for ( c = path + strlen( path ) - 1 ; c != path ; c-- )
|
||||||
{
|
{
|
||||||
if ( !Q_strncasecmp( c, BASEDIRNAME, len ) ) {
|
if ( strniEqual( c, BASEDIRNAME, len ) ) {
|
||||||
//
|
//
|
||||||
//strncpy (qdir, path, c+len+2-path);
|
//strncpy (qdir, path, c+len+2-path);
|
||||||
// the +2 assumes a 2 or 3 following quake which is not the
|
// the +2 assumes a 2 or 3 following quake which is not the
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,10 @@ static inline char *copystring( const char *src ){ // version of strdup() with s
|
||||||
char* strIstr( const char* haystack, const char* needle );
|
char* strIstr( const char* haystack, const char* needle );
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define Q_stricmp stricmp
|
#define Q_stricmp stricmp
|
||||||
#define Q_strncasecmp strnicmp
|
#define Q_strnicmp strnicmp
|
||||||
#else
|
#else
|
||||||
#define Q_stricmp strcasecmp
|
#define Q_stricmp strcasecmp
|
||||||
#define Q_strncasecmp strncasecmp
|
#define Q_strnicmp strncasecmp
|
||||||
#endif
|
#endif
|
||||||
static inline bool strEqual( const char* string, const char* other ){
|
static inline bool strEqual( const char* string, const char* other ){
|
||||||
return strcmp( string, other ) == 0;
|
return strcmp( string, other ) == 0;
|
||||||
|
|
@ -110,7 +110,7 @@ static inline bool striEqual( const char* string, const char* other ){
|
||||||
return Q_stricmp( string, other ) == 0;
|
return Q_stricmp( string, other ) == 0;
|
||||||
}
|
}
|
||||||
static inline bool strniEqual( const char* string, const char* other, size_t n ){
|
static inline bool strniEqual( const char* string, const char* other, size_t n ){
|
||||||
return Q_strncasecmp( string, other, n ) == 0;
|
return Q_strnicmp( string, other, n ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool strEqualPrefix( const char* string, const char* prefix ){
|
static inline bool strEqualPrefix( const char* string, const char* prefix ){
|
||||||
|
|
|
||||||
|
|
@ -309,8 +309,8 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
|
for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
|
||||||
{
|
{
|
||||||
if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
|
if ( striEqualPrefix( ep->key, "vertexremapshader" ) ) {
|
||||||
sscanf( ep->value, "%*[^;] %*[;] %s", str );
|
sscanf( ep->value, "%*[^;] %*[;] %s", str ); // textures/remap/from;textures/remap/to
|
||||||
res2list( pk3Shaders, str );
|
res2list( pk3Shaders, str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -588,7 +588,7 @@ int pk3BSPMain( int argc, char **argv ){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
|
else if ( striEqualPrefix( token, "implicit" ) ){
|
||||||
Sys_FPrintf( SYS_WRN, "WARNING5: %s : line %d : unsupported %s shader\n", scriptFile, scriptline, token );
|
Sys_FPrintf( SYS_WRN, "WARNING5: %s : line %d : unsupported %s shader\n", scriptFile, scriptline, token );
|
||||||
}
|
}
|
||||||
/* skip the shader */
|
/* skip the shader */
|
||||||
|
|
@ -981,8 +981,8 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
epair_t *ep;
|
epair_t *ep;
|
||||||
for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
|
for ( ep = entities[0].epairs; ep != NULL; ep = ep->next )
|
||||||
{
|
{
|
||||||
if ( !Q_strncasecmp( ep->key, "vertexremapshader", 17 ) ) {
|
if ( striEqualPrefix( ep->key, "vertexremapshader" ) ) {
|
||||||
sscanf( ep->value, "%*[^;] %*[;] %s", str );
|
sscanf( ep->value, "%*[^;] %*[;] %s", str ); // textures/remap/from;textures/remap/to
|
||||||
res2list( pk3Shaders, str );
|
res2list( pk3Shaders, str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1378,7 +1378,7 @@ int repackBSPMain( int argc, char **argv ){
|
||||||
GetToken( false );
|
GetToken( false );
|
||||||
StrBuf_cat2( shaderText, " ", token );
|
StrBuf_cat2( shaderText, " ", token );
|
||||||
}
|
}
|
||||||
else if ( !Q_strncasecmp( token, "implicit", 8 ) ){
|
else if ( striEqualPrefix( token, "implicit" ) ){
|
||||||
Sys_FPrintf( SYS_WRN, "WARNING5: %s : %s shader\n", pk3Shaders->s[shader], token );
|
Sys_FPrintf( SYS_WRN, "WARNING5: %s : %s shader\n", pk3Shaders->s[shader], token );
|
||||||
hasmap = true;
|
hasmap = true;
|
||||||
if ( line == scriptline ){
|
if ( line == scriptline ){
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,7 @@ static void ConvertBrushFast( FILE *f, int num, bspBrush_t *brush, vec3_t origin
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get texture name */
|
/* get texture name */
|
||||||
if ( !Q_strncasecmp( buildSide->shaderInfo->shader, "textures/", 9 ) ) {
|
if ( striEqualPrefix( buildSide->shaderInfo->shader, "textures/" ) ) {
|
||||||
texture = buildSide->shaderInfo->shader + 9;
|
texture = buildSide->shaderInfo->shader + 9;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -484,7 +484,7 @@ static void ConvertBrush( FILE *f, int num, bspBrush_t *brush, vec3_t origin, bo
|
||||||
GetBestSurfaceTriangleMatchForBrushside( buildSide, vert );
|
GetBestSurfaceTriangleMatchForBrushside( buildSide, vert );
|
||||||
|
|
||||||
/* get texture name */
|
/* get texture name */
|
||||||
if ( !Q_strncasecmp( buildSide->shaderInfo->shader, "textures/", 9 ) ) {
|
if ( striEqualPrefix( buildSide->shaderInfo->shader, "textures/" ) ) {
|
||||||
texture = buildSide->shaderInfo->shader + 9;
|
texture = buildSide->shaderInfo->shader + 9;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -777,7 +777,7 @@ for ( i = 0; i < brush->numSides; i++ )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get texture name */
|
/* get texture name */
|
||||||
if ( !Q_strncasecmp( shader->shader, "textures/", 9 ) ) {
|
if ( striEqualPrefix( shader->shader, "textures/" ) ) {
|
||||||
texture = shader->shader + 9;
|
texture = shader->shader + 9;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -852,7 +852,7 @@ static void ConvertPatch( FILE *f, int num, bspDrawSurface_t *ds, vec3_t origin
|
||||||
shader = &bspShaders[ ds->shaderNum ];
|
shader = &bspShaders[ ds->shaderNum ];
|
||||||
|
|
||||||
/* get texture name */
|
/* get texture name */
|
||||||
if ( !Q_strncasecmp( shader->shader, "textures/", 9 ) ) {
|
if ( striEqualPrefix( shader->shader, "textures/" ) ) {
|
||||||
texture = shader->shader + 9;
|
texture = shader->shader + 9;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
|
|
@ -235,10 +235,10 @@ void CreateEntityLights( void ){
|
||||||
name = ValueForKey( e, "classname" );
|
name = ValueForKey( e, "classname" );
|
||||||
|
|
||||||
/* ydnar: check for lightJunior */
|
/* ydnar: check for lightJunior */
|
||||||
if ( Q_strncasecmp( name, "lightJunior", 11 ) == 0 ) {
|
if ( striEqualPrefix( name, "lightJunior" ) ) {
|
||||||
junior = true;
|
junior = true;
|
||||||
}
|
}
|
||||||
else if ( Q_strncasecmp( name, "light", 5 ) == 0 ) {
|
else if ( striEqualPrefix( name, "light" ) ) {
|
||||||
junior = false;
|
junior = false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
||||||
|
|
@ -1796,7 +1796,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups ){
|
||||||
classname = ValueForKey( mapEnt, "classname" );
|
classname = ValueForKey( mapEnt, "classname" );
|
||||||
|
|
||||||
/* ydnar: only lights? */
|
/* ydnar: only lights? */
|
||||||
if ( onlyLights && Q_strncasecmp( classname, "light", 5 ) ) {
|
if ( onlyLights && !striEqualPrefix( classname, "light" ) ) {
|
||||||
numEntities--;
|
numEntities--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -378,14 +378,10 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, remap
|
||||||
if ( rm->from[ 0 ] == '*' && rm->from[ 1 ] == '\0' ) {
|
if ( rm->from[ 0 ] == '*' && rm->from[ 1 ] == '\0' ) {
|
||||||
glob = rm;
|
glob = rm;
|
||||||
}
|
}
|
||||||
else{
|
else if( striEqualSuffix( picoShaderName, rm->from ) ){
|
||||||
const size_t shaderLen = strlen( picoShaderName );
|
rmto = rm;
|
||||||
const size_t suffixLen = strlen( rm->from );
|
if( strlen( picoShaderName ) == strlen( rm->from ) ) // exact match priority
|
||||||
if( shaderLen >= suffixLen && !Q_strncasecmp( picoShaderName + shaderLen - suffixLen, rm->from, suffixLen ) ){
|
break;
|
||||||
rmto = rm;
|
|
||||||
if( shaderLen == suffixLen ) // exact match priority
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( rmto ){
|
if( rmto ){
|
||||||
|
|
@ -1501,7 +1497,7 @@ void AddTriangleModels( entity_t *e ){
|
||||||
/* look for keys prefixed with "_remap" */
|
/* look for keys prefixed with "_remap" */
|
||||||
if ( ep->key != NULL && ep->value != NULL &&
|
if ( ep->key != NULL && ep->value != NULL &&
|
||||||
ep->key[ 0 ] != '\0' && ep->value[ 0 ] != '\0' &&
|
ep->key[ 0 ] != '\0' && ep->value[ 0 ] != '\0' &&
|
||||||
!Q_strncasecmp( ep->key, "_remap", 6 ) ) {
|
striEqualPrefix( ep->key, "_remap" ) ) {
|
||||||
/* create new remapping */
|
/* create new remapping */
|
||||||
remap2 = remap;
|
remap2 = remap;
|
||||||
remap = safe_malloc( sizeof( *remap ) );
|
remap = safe_malloc( sizeof( *remap ) );
|
||||||
|
|
|
||||||
|
|
@ -1122,7 +1122,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
GetTokenAppend( shaderText, false );
|
GetTokenAppend( shaderText, false );
|
||||||
|
|
||||||
/* deformVertexes autosprite(2) */
|
/* deformVertexes autosprite(2) */
|
||||||
if ( !Q_strncasecmp( token, "autosprite", 10 ) ) {
|
if ( striEqualPrefix( token, "autosprite" ) ) {
|
||||||
/* set it as autosprite and detail */
|
/* set it as autosprite and detail */
|
||||||
si->autosprite = true;
|
si->autosprite = true;
|
||||||
ApplySurfaceParm( "detail", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
ApplySurfaceParm( "detail", &si->contentFlags, &si->surfaceFlags, &si->compileFlags );
|
||||||
|
|
@ -1333,7 +1333,7 @@ static void ParseShaderFile( const char *filename ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* match q3map_ */
|
/* match q3map_ */
|
||||||
else if ( !Q_strncasecmp( token, "q3map_", 6 ) ) {
|
else if ( striEqualPrefix( token, "q3map_" ) ) {
|
||||||
/* ydnar: q3map_baseShader <shader> (inherit this shader's parameters) */
|
/* ydnar: q3map_baseShader <shader> (inherit this shader's parameters) */
|
||||||
if ( striEqual( token, "q3map_baseShader" ) ) {
|
if ( striEqual( token, "q3map_baseShader" ) ) {
|
||||||
shaderInfo_t *si2;
|
shaderInfo_t *si2;
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ void SetLightStyles( void ){
|
||||||
e = &entities[ i ];
|
e = &entities[ i ];
|
||||||
|
|
||||||
t = ValueForKey( e, "classname" );
|
t = ValueForKey( e, "classname" );
|
||||||
if ( Q_strncasecmp( t, "light", 5 ) ) {
|
if ( !striEqualPrefix( t, "light" ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
t = ValueForKey( e, "targetname" );
|
t = ValueForKey( e, "targetname" );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user