mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-10 06:31:40 +00:00
Stop using Q_strcmp, trust that the standard strcmp is faster
This commit is contained in:
parent
97435772b4
commit
0bfbc51838
13 changed files with 31 additions and 47 deletions
|
@ -713,7 +713,7 @@ void Cmd_AddCommand (char *cmd_name, xcommand_t function)
|
||||||
// fail if the command already exists
|
// fail if the command already exists
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||||
{
|
{
|
||||||
if (!Q_strcmp (cmd_name, cmd->name))
|
if (!strcmp (cmd_name, cmd->name))
|
||||||
{
|
{
|
||||||
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
||||||
return;
|
return;
|
||||||
|
@ -738,7 +738,7 @@ qboolean Cmd_Exists (char *cmd_name)
|
||||||
|
|
||||||
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
||||||
{
|
{
|
||||||
if (!Q_strcmp (cmd_name,cmd->name))
|
if (!strcmp (cmd_name,cmd->name))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,21 +207,6 @@ void Q_strcat (char *dest, char *src)
|
||||||
Q_strcpy (dest, src);
|
Q_strcpy (dest, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Q_strcmp (char *s1, char *s2)
|
|
||||||
{
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
if (*s1 != *s2)
|
|
||||||
return -1; // strings not equal
|
|
||||||
if (!*s1)
|
|
||||||
return 0; // strings are equal
|
|
||||||
s1++;
|
|
||||||
s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Q_strncmp (char *s1, char *s2, int count)
|
int Q_strncmp (char *s1, char *s2, int count)
|
||||||
{
|
{
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -1083,7 +1068,7 @@ int COM_CheckParm (char *parm)
|
||||||
{
|
{
|
||||||
if (!com_argv[i])
|
if (!com_argv[i])
|
||||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||||
if (!Q_strcmp (parm,com_argv[i]))
|
if (!strcmp (parm,com_argv[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1114,7 @@ void COM_InitArgv (int argc, char **argv)
|
||||||
com_argc++)
|
com_argc++)
|
||||||
{
|
{
|
||||||
largv[com_argc] = argv[com_argc];
|
largv[com_argc] = argv[com_argc];
|
||||||
if (!Q_strcmp ("-safe", argv[com_argc]))
|
if (!strcmp ("-safe", argv[com_argc]))
|
||||||
safe = true;
|
safe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,6 @@ void Q_strncpy (char *dest, char *src, int count);
|
||||||
int Q_strlen (char *str);
|
int Q_strlen (char *str);
|
||||||
char *Q_strrchr (char *s, char c);
|
char *Q_strrchr (char *s, char c);
|
||||||
void Q_strcat (char *dest, char *src);
|
void Q_strcat (char *dest, char *src);
|
||||||
int Q_strcmp (char *s1, char *s2);
|
|
||||||
int Q_strncmp (char *s1, char *s2, int count);
|
int Q_strncmp (char *s1, char *s2, int count);
|
||||||
int Q_strcasecmp (char *s1, char *s2);
|
int Q_strcasecmp (char *s1, char *s2);
|
||||||
int Q_strncasecmp (char *s1, char *s2, int n);
|
int Q_strncasecmp (char *s1, char *s2, int n);
|
||||||
|
|
|
@ -34,7 +34,7 @@ cvar_t *Cvar_FindVar (char *var_name)
|
||||||
cvar_t *var;
|
cvar_t *var;
|
||||||
|
|
||||||
for (var=cvar_vars ; var ; var=var->next)
|
for (var=cvar_vars ; var ; var=var->next)
|
||||||
if (!Q_strcmp (var_name, var->name))
|
if (!strcmp (var_name, var->name))
|
||||||
return var;
|
return var;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -113,7 +113,7 @@ void Cvar_Set (char *var_name, char *value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
changed = Q_strcmp(var->string, value);
|
changed = strcmp(var->string, value);
|
||||||
|
|
||||||
Z_Free (var->string); // free the old value string
|
Z_Free (var->string); // free the old value string
|
||||||
|
|
||||||
|
|
|
@ -682,7 +682,7 @@ void Host_Name_f (void)
|
||||||
|
|
||||||
if (cmd_source == src_command)
|
if (cmd_source == src_command)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(cl_name.string, newName) == 0)
|
if (strcmp(cl_name.string, newName) == 0)
|
||||||
return;
|
return;
|
||||||
Cvar_Set ("_cl_name", newName);
|
Cvar_Set ("_cl_name", newName);
|
||||||
if (cls.state == ca_connected)
|
if (cls.state == ca_connected)
|
||||||
|
@ -691,7 +691,7 @@ void Host_Name_f (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
|
if (host_client->name[0] && strcmp(host_client->name, "unconnected") )
|
||||||
if (Q_strcmp(host_client->name, newName) != 0)
|
if (strcmp(host_client->name, newName) != 0)
|
||||||
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
|
Con_Printf ("%s renamed to %s\n", host_client->name, newName);
|
||||||
Q_strcpy (host_client->name, newName);
|
Q_strcpy (host_client->name, newName);
|
||||||
host_client->edict->v.netname = host_client->name - pr_strings;
|
host_client->edict->v.netname = host_client->name - pr_strings;
|
||||||
|
@ -1103,7 +1103,7 @@ void Host_Kick_f (void)
|
||||||
|
|
||||||
save = host_client;
|
save = host_client;
|
||||||
|
|
||||||
if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0)
|
if (Cmd_Argc() > 2 && strcmp(Cmd_Argv(1), "#") == 0)
|
||||||
{
|
{
|
||||||
i = Q_atof(Cmd_Argv(2)) - 1;
|
i = Q_atof(Cmd_Argv(2)) - 1;
|
||||||
if (i < 0 || i >= svs.maxclients)
|
if (i < 0 || i >= svs.maxclients)
|
||||||
|
|
|
@ -1927,9 +1927,9 @@ void M_Setup_Key (int k)
|
||||||
// break;
|
// break;
|
||||||
|
|
||||||
// setup_cursor == 4 (OK)
|
// setup_cursor == 4 (OK)
|
||||||
if (Q_strcmp(cl_name.string, setup_myname) != 0)
|
if (strcmp(cl_name.string, setup_myname) != 0)
|
||||||
Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
|
Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
|
||||||
if (Q_strcmp(hostname.string, setup_hostname) != 0)
|
if (strcmp(hostname.string, setup_hostname) != 0)
|
||||||
Cvar_Set("hostname", setup_hostname);
|
Cvar_Set("hostname", setup_hostname);
|
||||||
m_entersound = true;
|
m_entersound = true;
|
||||||
M_Menu_MultiPlayer_f ();
|
M_Menu_MultiPlayer_f ();
|
||||||
|
|
|
@ -403,7 +403,7 @@ void NET_Stats_f (void)
|
||||||
Con_Printf("shortPacketCount = %i\n", shortPacketCount);
|
Con_Printf("shortPacketCount = %i\n", shortPacketCount);
|
||||||
Con_Printf("droppedDatagrams = %i\n", droppedDatagrams);
|
Con_Printf("droppedDatagrams = %i\n", droppedDatagrams);
|
||||||
}
|
}
|
||||||
else if (Q_strcmp(Cmd_Argv(1), "*") == 0)
|
else if (strcmp(Cmd_Argv(1), "*") == 0)
|
||||||
{
|
{
|
||||||
for (s = net_activeSockets; s; s = s->next)
|
for (s = net_activeSockets; s; s = s->next)
|
||||||
PrintStats(s);
|
PrintStats(s);
|
||||||
|
@ -781,7 +781,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
|
||||||
command = MSG_ReadByte();
|
command = MSG_ReadByte();
|
||||||
if (command == CCREQ_SERVER_INFO)
|
if (command == CCREQ_SERVER_INFO)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
SZ_Clear(&net_message);
|
SZ_Clear(&net_message);
|
||||||
|
@ -884,7 +884,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
|
||||||
if (command != CCREQ_CONNECT)
|
if (command != CCREQ_CONNECT)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
|
if (strcmp(MSG_ReadString(), "QUAKE") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)
|
if (MSG_ReadByte() != NET_PROTOCOL_VERSION)
|
||||||
|
|
|
@ -50,7 +50,7 @@ void Loop_SearchForHosts (qboolean xmit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
hostCacheCount = 1;
|
hostCacheCount = 1;
|
||||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
if (strcmp(hostname.string, "UNNAMED") == 0)
|
||||||
Q_strcpy(hostcache[0].name, "local");
|
Q_strcpy(hostcache[0].name, "local");
|
||||||
else
|
else
|
||||||
Q_strcpy(hostcache[0].name, hostname.string);
|
Q_strcpy(hostcache[0].name, hostname.string);
|
||||||
|
@ -64,7 +64,7 @@ void Loop_SearchForHosts (qboolean xmit)
|
||||||
|
|
||||||
qsocket_t *Loop_Connect (char *host)
|
qsocket_t *Loop_Connect (char *host)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(host,"local") != 0)
|
if (strcmp(host,"local") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
localconnectpending = true;
|
localconnectpending = true;
|
||||||
|
|
|
@ -185,7 +185,7 @@ int CheckParm (char **args, int argc, char *parm)
|
||||||
{
|
{
|
||||||
if (!args[i])
|
if (!args[i])
|
||||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||||
if (!Q_strcmp (parm,args[i]))
|
if (!strcmp (parm,args[i]))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ namespace quake
|
||||||
my_addr = inet_addr(szMyIPAddr);
|
my_addr = inet_addr(szMyIPAddr);
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// if the quake hostname isn't set, set it to the machine name
|
||||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
if (strcmp(hostname.string, "UNNAMED") == 0)
|
||||||
{
|
{
|
||||||
buff[15] = 0;
|
buff[15] = 0;
|
||||||
Cvar_Set ("hostname", buff);
|
Cvar_Set ("hostname", buff);
|
||||||
|
|
|
@ -173,7 +173,7 @@ namespace quake
|
||||||
my_addr = inet_addr(szMyIPAddr);
|
my_addr = inet_addr(szMyIPAddr);
|
||||||
|
|
||||||
// if the quake hostname isn't set, set it to the machine name
|
// if the quake hostname isn't set, set it to the machine name
|
||||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
if (strcmp(hostname.string, "UNNAMED") == 0)
|
||||||
{
|
{
|
||||||
buff[15] = 0;
|
buff[15] = 0;
|
||||||
Cvar_Set ("hostname", buff);
|
Cvar_Set ("hostname", buff);
|
||||||
|
@ -652,7 +652,7 @@ namespace quake
|
||||||
}
|
}
|
||||||
|
|
||||||
gethostname(buff, MAXHOSTNAMELEN);
|
gethostname(buff, MAXHOSTNAMELEN);
|
||||||
if (Q_strcmp(hostname.string, "UNNAMED") == 0)
|
if (strcmp(hostname.string, "UNNAMED") == 0)
|
||||||
{
|
{
|
||||||
buff[15] = 0;
|
buff[15] = 0;
|
||||||
Cvar_Set ("hostname", buff);
|
Cvar_Set ("hostname", buff);
|
||||||
|
|
|
@ -2026,16 +2026,16 @@ void Mod_FloodFillSkin( byte *skin, int skinwidth, int skinheight )
|
||||||
|
|
||||||
qboolean model_is_zombie(char name[MAX_QPATH])
|
qboolean model_is_zombie(char name[MAX_QPATH])
|
||||||
{
|
{
|
||||||
if (Q_strcmp(name, "models/ai/zb#.mdl") == 0 ||
|
if (strcmp(name, "models/ai/zb#.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zbc#.mdl") == 0 ||
|
strcmp(name, "models/ai/zbc#.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zcfull.mdl") == 0 ||
|
strcmp(name, "models/ai/zcfull.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zhc^.mdl") == 0 ||
|
strcmp(name, "models/ai/zhc^.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zalc(.mdl") == 0 ||
|
strcmp(name, "models/ai/zalc(.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zarc(.mdl") == 0 ||
|
strcmp(name, "models/ai/zarc(.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zfull.mdl") == 0 ||
|
strcmp(name, "models/ai/zfull.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zh^.mdl") == 0 ||
|
strcmp(name, "models/ai/zh^.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zal(.mdl") == 0 ||
|
strcmp(name, "models/ai/zal(.mdl") == 0 ||
|
||||||
Q_strcmp(name, "models/ai/zar(.mdl") == 0)
|
strcmp(name, "models/ai/zar(.mdl") == 0)
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
|
||||||
return qfalse;
|
return qfalse;
|
||||||
|
|
|
@ -285,7 +285,7 @@ sfx_t *S_FindName (char *name)
|
||||||
|
|
||||||
// see if already loaded
|
// see if already loaded
|
||||||
for (i=0 ; i < num_sfx ; i++)
|
for (i=0 ; i < num_sfx ; i++)
|
||||||
if (!Q_strcmp(known_sfx[i].name, name))
|
if (!strcmp(known_sfx[i].name, name))
|
||||||
{
|
{
|
||||||
return &known_sfx[i];
|
return &known_sfx[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue