mirror of
https://github.com/nzp-team/quakespasm.git
synced 2024-11-10 06:32:03 +00:00
NX/VITA: Micro-optimizations
This commit is contained in:
parent
46e1838d96
commit
0ed6300efb
13 changed files with 44 additions and 27 deletions
|
@ -684,7 +684,7 @@ void Cmd_AddCommand (const 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;
|
||||||
|
@ -727,7 +727,7 @@ qboolean Cmd_Exists (const 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1244,7 +1244,7 @@ int COM_CheckParm (const 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,7 +1303,7 @@ void COM_InitArgv (int argc, char **argv)
|
||||||
for (com_argc = 0; (com_argc < MAX_NUM_ARGVS) && (com_argc < argc); com_argc++)
|
for (com_argc = 0; (com_argc < MAX_NUM_ARGVS) && (com_argc < 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]))
|
||||||
safemode = 1;
|
safemode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1030,7 +1030,7 @@ void Con_TabComplete (void)
|
||||||
match = keydown[K_SHIFT] ? t->prev->name : t->name;
|
match = keydown[K_SHIFT] ? t->prev->name : t->name;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!Q_strcmp(t->name, partial))
|
if (!strcmp(t->name, partial))
|
||||||
{
|
{
|
||||||
match = keydown[K_SHIFT] ? t->prev->name : t->next->name;
|
match = keydown[K_SHIFT] ? t->prev->name : t->next->name;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -251,7 +251,7 @@ cvar_t *Cvar_FindVar (const char *var_name)
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ static void TexMgr_TextureMode_f (cvar_t *var)
|
||||||
|
|
||||||
for (i = 0; i < NUM_GLMODES; i++)
|
for (i = 0; i < NUM_GLMODES; i++)
|
||||||
{
|
{
|
||||||
if (!Q_strcmp (glmodes[i].name, gl_texturemode.string))
|
if (!strcmp (glmodes[i].name, gl_texturemode.string))
|
||||||
{
|
{
|
||||||
if (glmode_idx != i)
|
if (glmode_idx != i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ void FileList_Add (const char *name, filelist_item_t **list)
|
||||||
// ignore duplicate
|
// ignore duplicate
|
||||||
for (item = *list; item; item = item->next)
|
for (item = *list; item; item = item->next)
|
||||||
{
|
{
|
||||||
if (!Q_strcmp (name, item->name))
|
if (!strcmp (name, item->name))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,7 +1286,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)
|
||||||
|
@ -1296,7 +1296,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);
|
||||||
|
@ -1778,7 +1778,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)
|
||||||
|
|
|
@ -32,6 +32,23 @@ float _mathlib_temp_float1, _mathlib_temp_float2, _mathlib_temp_float3;
|
||||||
//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F
|
//#define DEG2RAD( a ) ( a * M_PI ) / 180.0F
|
||||||
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz
|
#define DEG2RAD( a ) ( (a) * M_PI_DIV_180 ) //johnfitz
|
||||||
|
|
||||||
|
float rsqrt( float number )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float x, y;
|
||||||
|
|
||||||
|
if( number == 0.0f )
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
|
x = number * 0.5f;
|
||||||
|
i = *(int *)&number; // evil floating point bit level hacking
|
||||||
|
i = 0x5f3759df - (i >> 1); // what the fuck?
|
||||||
|
y = *(float *)&i;
|
||||||
|
y = y * (1.5f - (x * y * y)); // first iteration
|
||||||
|
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
void SinCos( float radians, float *sine, float *cosine )
|
void SinCos( float radians, float *sine, float *cosine )
|
||||||
{
|
{
|
||||||
*sine = sin(radians);
|
*sine = sin(radians);
|
||||||
|
@ -335,20 +352,18 @@ vec_t Length(vec3_t v)
|
||||||
|
|
||||||
float VectorNormalize (vec3_t v)
|
float VectorNormalize (vec3_t v)
|
||||||
{
|
{
|
||||||
float length, ilength;
|
float ilength;
|
||||||
|
|
||||||
length = sqrt(DotProduct(v,v));
|
ilength = rsqrt(DotProduct(v,v));
|
||||||
|
|
||||||
if (length)
|
if (ilength)
|
||||||
{
|
{
|
||||||
ilength = 1/length;
|
|
||||||
v[0] *= ilength;
|
v[0] *= ilength;
|
||||||
v[1] *= ilength;
|
v[1] *= ilength;
|
||||||
v[2] *= ilength;
|
v[2] *= ilength;
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return ilength;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VectorInverse (vec3_t v)
|
void VectorInverse (vec3_t v)
|
||||||
|
|
|
@ -2055,9 +2055,9 @@ forward:
|
||||||
goto forward;
|
goto forward;
|
||||||
|
|
||||||
// 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);
|
||||||
if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
|
if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
|
||||||
Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
|
Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
|
||||||
|
|
|
@ -458,7 +458,7 @@ static 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);
|
||||||
|
@ -891,7 +891,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);
|
||||||
|
@ -980,7 +980,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)
|
||||||
|
|
|
@ -54,7 +54,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);
|
||||||
|
@ -68,7 +68,7 @@ void Loop_SearchForHosts (qboolean xmit)
|
||||||
|
|
||||||
qsocket_t *Loop_Connect (const char *host)
|
qsocket_t *Loop_Connect (const char *host)
|
||||||
{
|
{
|
||||||
if (Q_strcmp(host,"local") != 0)
|
if (strcmp(host,"local") != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
localconnectpending = true;
|
localconnectpending = true;
|
||||||
|
|
|
@ -1158,6 +1158,7 @@ static void PF_findradius (void)
|
||||||
|
|
||||||
org = G_VECTOR(OFS_PARM0);
|
org = G_VECTOR(OFS_PARM0);
|
||||||
rad = G_FLOAT(OFS_PARM1);
|
rad = G_FLOAT(OFS_PARM1);
|
||||||
|
rad *= rad;
|
||||||
|
|
||||||
ent = NEXT_EDICT(sv.edicts);
|
ent = NEXT_EDICT(sv.edicts);
|
||||||
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT(ent))
|
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT(ent))
|
||||||
|
@ -1168,7 +1169,8 @@ static void PF_findradius (void)
|
||||||
continue;
|
continue;
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
eorg[j] = org[j] - (ent->v.origin[j] + (ent->v.mins[j] + ent->v.maxs[j]) * 0.5);
|
eorg[j] = org[j] - (ent->v.origin[j] + (ent->v.mins[j] + ent->v.maxs[j]) * 0.5);
|
||||||
if (VectorLength(eorg) > rad)
|
|
||||||
|
if (DotProduct(eorg, eorg) > rad)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ent->v.chain = EDICT_TO_PROG(chain);
|
ent->v.chain = EDICT_TO_PROG(chain);
|
||||||
|
|
|
@ -278,7 +278,7 @@ static sfx_t *S_FindName (const 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];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ qboolean SV_SendClientDatagram (client_t *client)
|
||||||
msg.cursize = 0;
|
msg.cursize = 0;
|
||||||
|
|
||||||
//johnfitz -- if client is nonlocal, use smaller max size so packets aren't fragmented
|
//johnfitz -- if client is nonlocal, use smaller max size so packets aren't fragmented
|
||||||
if (Q_strcmp(NET_QSocketGetAddressString(client->netconnection), "LOCAL") != 0)
|
if (strcmp(NET_QSocketGetAddressString(client->netconnection), "LOCAL") != 0)
|
||||||
msg.maxsize = DATAGRAM_MTU;
|
msg.maxsize = DATAGRAM_MTU;
|
||||||
//johnfitz
|
//johnfitz
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue