Fixes resulting from code analysis

This commit is contained in:
Walter Julius Hennecke 2013-08-28 19:46:05 +02:00
parent 181e463cbf
commit 51430fec77
8 changed files with 602 additions and 1718 deletions

View file

@ -300,6 +300,10 @@ static void Cmd_Give_f( gentity_t *ent ) {
for ( i = bg_numGiveItems - 1; i > -1; i-- ) { for ( i = bg_numGiveItems - 1; i > -1; i-- ) {
item = &bg_giveItem[i]; item = &bg_giveItem[i];
if(item == NULL) {
continue;
}
if ( !Q_stricmp( arg, item->consoleName ) ) { if ( !Q_stricmp( arg, item->consoleName ) ) {
break; break;
} }
@ -317,6 +321,10 @@ static void Cmd_Give_f( gentity_t *ent ) {
//Fuck this. Why does ioEF crash if you don't break a case statement with code in it? :S //Fuck this. Why does ioEF crash if you don't break a case statement with code in it? :S
if(item == NULL) {
return;
}
switch ( item->giveType ) { switch ( item->giveType ) {
case TYPE_ALL: case TYPE_ALL:
targEnt->health = ps->stats[STAT_MAX_HEALTH]; targEnt->health = ps->stats[STAT_MAX_HEALTH];
@ -1566,17 +1574,18 @@ static void Cmd_SayArea( gentity_t *ent, char* text)
OtherPlayer = &g_entities[i]; //Point OtherPlayer to next player OtherPlayer = &g_entities[i]; //Point OtherPlayer to next player
//Send message to admins warning about command being used.
//TiM - since double spamming is annoying, ensure that the target admin wants this alert
if ( !OtherPlayer->client->noAdminChat )
G_SayTo( ent, OtherPlayer, SAY_ADMIN, COLOR_CYAN, va("%s ^7said to area: ", pers->netname ), text ); //^2%s
//Check is OtherPlayer is valid //Check is OtherPlayer is valid
if ( !OtherPlayer || !OtherPlayer->inuse || !OtherPlayer->client ) if ( !OtherPlayer || !OtherPlayer->inuse || !OtherPlayer->client )
{ {
continue; continue;
} }
//Send message to admins warning about command being used.
//TiM - since double spamming is annoying, ensure that the target admin wants this alert
if ( !OtherPlayer->client->noAdminChat )
G_SayTo( ent, OtherPlayer, SAY_ADMIN, COLOR_CYAN, va("%s ^7said to area: ", pers->netname ), text ); //^2%s
//TiM - I have a better solution. the trap_inPVS function lets u see if two points are within the same Vis cluster //TiM - I have a better solution. the trap_inPVS function lets u see if two points are within the same Vis cluster
//in the BSP tree. That should mean as long as they're in the same room, regardless if they can see each other or not, //in the BSP tree. That should mean as long as they're in the same room, regardless if they can see each other or not,
//they'll get the message //they'll get the message
@ -2220,6 +2229,10 @@ static void Cmd_ForceKill_f( gentity_t *ent ) {
} }
} // end iterations } // end iterations
if(target == NULL) {
return;
}
Com_sprintf (send, sizeof(send), "%s ^7forced %s^7's death", ent->client->pers.netname, target->client->pers.netname); Com_sprintf (send, sizeof(send), "%s ^7forced %s^7's death", ent->client->pers.netname, target->client->pers.netname);
for (j = 0; j < MAX_CLIENTS - 1; j++) { for (j = 0; j < MAX_CLIENTS - 1; j++) {
@ -3725,7 +3738,7 @@ static void Cmd_EntList_f ( gentity_t *ent ) {
Com_sprintf( entBuffer, sizeof( entBuffer ), "ClassName: '%s', ID: %i\n", mapEnt->classname, i); Com_sprintf( entBuffer, sizeof( entBuffer ), "ClassName: '%s', ID: %i\n", mapEnt->classname, i);
} }
if ( strlen(mainBuffer) + strlen(entBuffer) > sizeof( mainBuffer ) ) { if ( strlen(mainBuffer) + strlen(entBuffer) >= sizeof( mainBuffer ) ) {
break; break;
} }
else { else {
@ -5262,7 +5275,7 @@ static void Cmd_MapsList_f( gentity_t *ent )
continue; continue;
} }
if ( strlen(mapList) + len + 20 > sizeof( mapList ) ) if ( strlen(mapList) + len + 20 >= sizeof( mapList ) )
break; break;
Q_strcat( mapList, sizeof( mapList ), filePtr ); Q_strcat( mapList, sizeof( mapList ), filePtr );

View file

@ -1113,7 +1113,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
if ( client ) if ( client )
{ {
if ( client->noclip ) { if ( client == NULL || client->noclip ) {
return; return;
} }
} }

View file

@ -2621,6 +2621,7 @@ void G_RunThink (gentity_t *ent) {
ent->nextthink = 0; ent->nextthink = 0;
if (!ent->think) { if (!ent->think) {
G_Error ( "NULL ent->think"); G_Error ( "NULL ent->think");
return;
} }
#ifdef G_LUA #ifdef G_LUA

View file

@ -607,10 +607,12 @@ void Svcmd_EntityList_f (void) {
gentity_t *check; gentity_t *check;
char arg[MAX_QPATH*4]; char arg[MAX_QPATH*4];
int length = 0; int length = 0;
qboolean args = qfalse;
if(trap_Argc() > 1) { if(trap_Argc() > 1) {
trap_Argv(1, arg, sizeof(arg)); trap_Argv(1, arg, sizeof(arg));
length = strlen(arg); length = strlen(arg);
args = qtrue;
} }
check = g_entities+1; check = g_entities+1;
@ -618,7 +620,7 @@ void Svcmd_EntityList_f (void) {
if ( !check->inuse ) { if ( !check->inuse ) {
continue; continue;
} }
if(!arg[0]) { if(args == qfalse) {
if ( check->classname && Q_stricmpn(check->classname, "noclass", 7) && Q_stricmpn(check->classname, "bodyque", 7) ) { if ( check->classname && Q_stricmpn(check->classname, "noclass", 7) && Q_stricmpn(check->classname, "bodyque", 7) ) {
G_Printf("%3i:", e); G_Printf("%3i:", e);
switch ( check->s.eType ) { switch ( check->s.eType ) {

View file

@ -1644,6 +1644,10 @@ void SP_target_turbolift ( gentity_t *self )
char mapRoute[MAX_QPATH]; char mapRoute[MAX_QPATH];
char serverInfo[MAX_TOKEN_CHARS]; char serverInfo[MAX_TOKEN_CHARS];
if(self == NULL) {
return;
}
//cache the moving sounds //cache the moving sounds
G_SpawnString( "soundLoop", "sound/movers/plats/turbomove.wav", &loopSound ); G_SpawnString( "soundLoop", "sound/movers/plats/turbomove.wav", &loopSound );
G_SpawnString( "soundEnd", "sound/movers/plats/turbostop.wav", &endSound ); G_SpawnString( "soundEnd", "sound/movers/plats/turbostop.wav", &endSound );

View file

@ -364,7 +364,7 @@ void Use_target_push( gentity_t *self, gentity_t *other, gentity_t *activator )
} }
/* RPG-X: J2J noclip use */ /* RPG-X: J2J noclip use */
if ( activator->client->ps.pm_type != PM_NORMAL || activator->client->ps.pm_type != PM_NOCLIP) { if ( (activator->client->ps.pm_type != PM_NORMAL) || (activator->client->ps.pm_type != PM_NOCLIP)) {
return; return;
} }

File diff suppressed because it is too large Load diff

View file

@ -918,6 +918,10 @@ char *Q_CleanStr( char *string ) {
char* s; char* s;
int c; int c;
if(string == NULL) {
return string;
}
s = string; s = string;
d = string; d = string;
while ((c = *s) != 0 ) { while ((c = *s) != 0 ) {