mirror of
https://github.com/nzp-team/glquake.git
synced 2025-01-31 13:30:33 +00:00
Avoid using strcmp every frame
This commit is contained in:
parent
26a413bd5e
commit
dbd7d0a193
11 changed files with 50 additions and 70 deletions
|
@ -597,7 +597,7 @@ char *Cmd_CompleteCommand (char *partial)
|
|||
|
||||
// check functions
|
||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||
if (!Q_strncmp (partial,cmd->name, len))
|
||||
if (!strncmp (partial,cmd->name, len))
|
||||
return cmd->name;
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -250,23 +250,6 @@ void Q_strcat (char *dest, char *src)
|
|||
Q_strcpy (dest, src);
|
||||
}
|
||||
|
||||
int Q_strncmp (char *s1, char *s2, int count)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (!count--)
|
||||
return 0;
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_strncasecmp (char *s1, char *s2, int n)
|
||||
{
|
||||
int c1, c2;
|
||||
|
|
|
@ -150,7 +150,6 @@ void Q_strncpy (char *dest, char *src, int count);
|
|||
int Q_strlen (char *str);
|
||||
char *Q_strrchr (char *s, char c);
|
||||
void Q_strcat (char *dest, char *src);
|
||||
int Q_strncmp (char *s1, char *s2, int count);
|
||||
int Q_strcasecmp (char *s1, char *s2);
|
||||
int Q_strncasecmp (char *s1, char *s2, int n);
|
||||
int Q_atoi (char *str);
|
||||
|
|
|
@ -89,7 +89,7 @@ char *Cvar_CompleteVariable (char *partial)
|
|||
|
||||
// check functions
|
||||
for (cvar=cvar_vars ; cvar ; cvar=cvar->next)
|
||||
if (!Q_strncmp (partial,cvar->name, len))
|
||||
if (!strncmp (partial,cvar->name, len))
|
||||
return cvar->name;
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -381,10 +381,10 @@ void Draw_Init (void)
|
|||
Cvar_RegisterVariable (&gl_max_size);
|
||||
Cvar_RegisterVariable (&gl_picmip);
|
||||
|
||||
// 3dfx can only handle 256 wide textures
|
||||
if (!Q_strncasecmp ((char *)gl_renderer, "3dfx",4) ||
|
||||
strstr((char *)gl_renderer, "Glide"))
|
||||
if (!new3ds_flag) {
|
||||
Cvar_SetValue("gl_picmip", 1);
|
||||
Cvar_Set ("gl_max_size", "256");
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("gl_texturemode", &Draw_TextureMode_f);
|
||||
|
||||
|
@ -1143,27 +1143,27 @@ void Draw_Crosshair (void)
|
|||
|
||||
x_value = (vid.width - 3)/2 - crosshair_offset_step;
|
||||
y_value = (vid.height - 1)/2;
|
||||
Draw_FillByColor(x_value, y_value, 3, 1, 255, (int)col, (int)col, crosshair_opacity);
|
||||
Draw_FillByColor(x_value, y_value, 3, 1, 255, (int)col, (int)col, (int)crosshair_opacity);
|
||||
|
||||
x_value = (vid.width - 3)/2 + crosshair_offset_step;
|
||||
y_value = (vid.height - 1)/2;
|
||||
Draw_FillByColor(x_value, y_value, 3, 1, 255, (int)col, (int)col, crosshair_opacity);
|
||||
Draw_FillByColor(x_value, y_value, 3, 1, 255, (int)col, (int)col, (int)crosshair_opacity);
|
||||
|
||||
x_value = (vid.width - 1)/2;
|
||||
y_value = (vid.height - 3)/2 - crosshair_offset_step;
|
||||
Draw_FillByColor(x_value, y_value, 1, 3, 255, (int)col, (int)col, crosshair_opacity);
|
||||
Draw_FillByColor(x_value, y_value, 1, 3, 255, (int)col, (int)col, (int)crosshair_opacity);
|
||||
|
||||
x_value = (vid.width - 1)/2;
|
||||
y_value = (vid.height - 3)/2 + crosshair_offset_step;
|
||||
Draw_FillByColor(x_value, y_value, 1, 3, 255, (int)col, (int)col, crosshair_opacity);
|
||||
Draw_FillByColor(x_value, y_value, 1, 3, 255, (int)col, (int)col, (int)crosshair_opacity);
|
||||
}
|
||||
// Area of Effect (o)
|
||||
else if (crosshair.value == 2) {
|
||||
Draw_CharacterRGBA((vid.width)/2-4, (vid.height)/2, 'O', 255, col, col, crosshair_opacity, 1);
|
||||
Draw_CharacterRGBA((vid.width)/2-4, (vid.height)/2, 'O', 255, (int)col, (int)col, (int)crosshair_opacity, 1);
|
||||
}
|
||||
// Dot crosshair (.)
|
||||
else if (crosshair.value == 3) {
|
||||
Draw_CharacterRGBA((vid.width - 8)/2, (vid.height - 8)/2, '.', 255, col, col, crosshair_opacity, 1);
|
||||
Draw_CharacterRGBA((vid.width - 8)/2, (vid.height - 8)/2, '.', 255, (int)col, (int)col, (int)crosshair_opacity, 1);
|
||||
}
|
||||
// Grenade crosshair
|
||||
else if (crosshair.value == 4) {
|
||||
|
|
|
@ -395,7 +395,7 @@ void Mod_LoadTextures (lump_t *l)
|
|||
memcpy ( tx+1, mt+1, pixels);
|
||||
|
||||
|
||||
if (loadmodel->bspversion != HL_BSPVERSION && !Q_strncmp(mt->name,"sky",3))
|
||||
if (loadmodel->bspversion != HL_BSPVERSION && !strncmp(mt->name,"sky",3))
|
||||
{
|
||||
R_InitSky (tx);
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ void Mod_LoadFaces (lump_t *l)
|
|||
|
||||
// set the drawing flags flag
|
||||
|
||||
if (!Q_strncmp(out->texinfo->texture->name,"sky",3)) // sky
|
||||
if (!strncmp(out->texinfo->texture->name,"sky",3)) // sky
|
||||
{
|
||||
out->flags |= (SURF_DRAWSKY | SURF_DRAWTILED);
|
||||
#ifndef QUAKE2
|
||||
|
@ -897,8 +897,18 @@ void Mod_LoadFaces (lump_t *l)
|
|||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(out->texinfo->texture->name,"nodraw",6) || !strncmp(out->texinfo->texture->name,"NODRAW",6)) {
|
||||
out->flags |= TEXFLAG_NODRAW;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strstr(fa->texinfo->texture->name,"light")) {
|
||||
out->flags |= TEXFLAG_LIGHT;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Q_strncmp(out->texinfo->texture->name,"*",1)) // turbulent
|
||||
if (!strncmp(out->texinfo->texture->name,"*",1)) // turbulent
|
||||
{
|
||||
out->flags |= (SURF_DRAWTURB | SURF_DRAWTILED);
|
||||
for (i=0 ; i<2 ; i++)
|
||||
|
|
|
@ -106,6 +106,9 @@ typedef struct texture_s
|
|||
#define SURF_DRAWBACKGROUND 0x40
|
||||
#define SURF_UNDERWATER 0x80
|
||||
|
||||
#define TEXFLAG_NODRAW 256
|
||||
#define TEXFLAG_LIGHT 512
|
||||
|
||||
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -468,9 +468,9 @@ void R_NewMap (void)
|
|||
{
|
||||
if (!cl.worldmodel->textures[i])
|
||||
continue;
|
||||
if (!Q_strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
|
||||
if (!strncmp(cl.worldmodel->textures[i]->name,"sky",3) )
|
||||
skytexturenum = i;
|
||||
if (!Q_strncmp(cl.worldmodel->textures[i]->name,"window02_1",10) )
|
||||
if (!strncmp(cl.worldmodel->textures[i]->name,"window02_1",10) )
|
||||
mirrortexturenum = i;
|
||||
cl.worldmodel->textures[i]->texturechain = NULL;
|
||||
}
|
||||
|
|
|
@ -788,33 +788,18 @@ void R_RenderBrushPoly (msurface_t *fa)
|
|||
EmitWaterPolys (fa);
|
||||
return;
|
||||
}
|
||||
//Diabolickal start
|
||||
if(!Q_strncmp(fa->texinfo->texture->name,"nodraw",6) || !Q_strncmp(fa->texinfo->texture->name,"NODRAW",6)) //Diabolickal nodraw support
|
||||
|
||||
if (fa->flags & TEXFLAG_NODRAW)
|
||||
return;
|
||||
// if (!strncmp(fa->texinfo->texture->name,"{",1)) //Diabolickal Alpha pixel support
|
||||
// {
|
||||
// glEnable(GL_ALPHA_TEST);
|
||||
// glEnable(GL_BLEND);
|
||||
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
// }
|
||||
if (strstr(fa->texinfo->texture->name,"light")) // Any texture with light in the name ignore lightmaps
|
||||
{
|
||||
DrawGLPoly (fa->polys);
|
||||
else if (fa->flags & TEXFLAG_LIGHT) {
|
||||
DrawGLPoly(fa->polys);
|
||||
return;
|
||||
}
|
||||
//Diabolickal end
|
||||
}
|
||||
|
||||
if (fa->flags & SURF_UNDERWATER)
|
||||
DrawGLWaterPoly (fa->polys);
|
||||
else
|
||||
DrawGLPoly (fa->polys);
|
||||
|
||||
//Diabolickal start
|
||||
// if (!strncmp(fa->texinfo->texture->name,"{",1)) //Diabolickal Alpha pixel support
|
||||
// {
|
||||
// glDisable(GL_ALPHA_TEST);
|
||||
// glDisable(GL_BLEND);
|
||||
// }
|
||||
//Diabolickal end
|
||||
|
||||
// add the poly to the proper lightmap chain
|
||||
|
||||
|
|
|
@ -607,9 +607,9 @@ static void Modem_Init(ComPort *p)
|
|||
response = Modem_Response(p);
|
||||
if (!response)
|
||||
continue;
|
||||
if (Q_strncmp(response, "OK", 2) == 0)
|
||||
if (strncmp(response, "OK", 2) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "ERROR", 5) == 0)
|
||||
if (strncmp(response, "ERROR", 5) == 0)
|
||||
{
|
||||
p->enabled = false;
|
||||
goto failed;
|
||||
|
@ -632,9 +632,9 @@ static void Modem_Init(ComPort *p)
|
|||
response = Modem_Response(p);
|
||||
if (!response)
|
||||
continue;
|
||||
if (Q_strncmp(response, "OK", 2) == 0)
|
||||
if (strncmp(response, "OK", 2) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "ERROR", 5) == 0)
|
||||
if (strncmp(response, "ERROR", 5) == 0)
|
||||
{
|
||||
p->enabled = false;
|
||||
goto failed;
|
||||
|
@ -819,7 +819,7 @@ int TTY_Connect(int handle, char *host)
|
|||
response = Modem_Response(p);
|
||||
if (!response)
|
||||
continue;
|
||||
if (Q_strncmp(response, "CONNECT", 7) == 0)
|
||||
if (strncmp(response, "CONNECT", 7) == 0)
|
||||
{
|
||||
disable();
|
||||
p->modemRang = true;
|
||||
|
@ -832,17 +832,17 @@ int TTY_Connect(int handle, char *host)
|
|||
m_return_onerror = false;
|
||||
return 0;
|
||||
}
|
||||
if (Q_strncmp(response, "NO CARRIER", 10) == 0)
|
||||
if (strncmp(response, "NO CARRIER", 10) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "NO DIALTONE", 11) == 0)
|
||||
if (strncmp(response, "NO DIALTONE", 11) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "NO DIAL TONE", 12) == 0)
|
||||
if (strncmp(response, "NO DIAL TONE", 12) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "NO ANSWER", 9) == 0)
|
||||
if (strncmp(response, "NO ANSWER", 9) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "BUSY", 4) == 0)
|
||||
if (strncmp(response, "BUSY", 4) == 0)
|
||||
break;
|
||||
if (Q_strncmp(response, "ERROR", 5) == 0)
|
||||
if (strncmp(response, "ERROR", 5) == 0)
|
||||
break;
|
||||
}
|
||||
key_dest = save_key_dest;
|
||||
|
@ -887,7 +887,7 @@ qboolean TTY_CheckForConnection(int handle)
|
|||
if (!Modem_Response(p))
|
||||
return false;
|
||||
|
||||
if (Q_strncmp(p->buffer, "RING", 4) == 0)
|
||||
if (strncmp(p->buffer, "RING", 4) == 0)
|
||||
{
|
||||
Modem_Command (p, "ATA");
|
||||
p->modemRang = true;
|
||||
|
@ -907,7 +907,7 @@ qboolean TTY_CheckForConnection(int handle)
|
|||
if (!Modem_Response(p))
|
||||
return false;
|
||||
|
||||
if (Q_strncmp (p->buffer, "CONNECT", 7) != 0)
|
||||
if (strncmp (p->buffer, "CONNECT", 7) != 0)
|
||||
return false;
|
||||
|
||||
disable();
|
||||
|
|
|
@ -211,7 +211,7 @@ void FindNextChunk(char *name)
|
|||
// Sys_Error ("FindNextChunk: %i length is past the 1 meg sanity limit", iff_chunk_len);
|
||||
data_p -= 8;
|
||||
last_chunk = data_p + 8 + ( (iff_chunk_len + 1) & ~1 );
|
||||
if (!Q_strncmp(data_p, name, 4))
|
||||
if (!strncmp(data_p, name, 4))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ wavinfo_t GetWavinfo (char *name, byte *wav, int wavlength)
|
|||
|
||||
// find "RIFF" chunk
|
||||
FindChunk("RIFF");
|
||||
if (!(data_p && !Q_strncmp(data_p+8, "WAVE", 4)))
|
||||
if (!(data_p && !strncmp(data_p+8, "WAVE", 4)))
|
||||
{
|
||||
Con_Printf("Missing RIFF/WAVE chunks\n");
|
||||
return info;
|
||||
|
|
Loading…
Reference in a new issue