diff options
author | IronClawTrem <louie.nutman@gmail.com> | 2020-03-26 22:07:26 +0000 |
---|---|---|
committer | IronClawTrem <louie.nutman@gmail.com> | 2020-03-26 22:07:50 +0000 |
commit | f8defe0cf650088ff594082577e283fc77f4abbe (patch) | |
tree | c562abd00990d2badd9cc8a5513535f2c6928b73 /src | |
parent | 7243106c7048ebc9896061bfdffb031787e78f98 (diff) |
fix segfaults in G_Say
occurs when attempting to use /say_admins or /say_hadmins with the console
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_cmds.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 9d86fdf..7674c62 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1051,7 +1051,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) return; // Invisible players cannot use chat - if( ent->client->sess.invisible == qtrue ) + if( ent && ent->client->sess.invisible == qtrue ) { if( !G_admin_cmd_check( ent, qtrue ) ) trap_SendServerCommand( ent-g_entities, "print \"You cannot chat while invisible\n\"" ); @@ -1065,22 +1065,24 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) } // Spam limit: If they said this message recently, ignore it. - if( g_spamTime.integer ) + if( ent ) { - if ( ( level.time - ent->client->pers.lastMessageTime ) < ( g_spamTime.integer * 1000 ) && - !Q_stricmp( ent->client->pers.lastMessage, chatText) && - !G_admin_permission( ent, ADMF_NOCENSORFLOOD ) && - ent->client->pers.floodDemerits <= g_floodMaxDemerits.integer ) + if( g_spamTime.integer ) { - trap_SendServerCommand( ent-g_entities, "print \"Your message has been ignored to prevent spam\n\"" ); - return; - } - else - { - ent->client->pers.lastMessageTime = level.time; - - Q_strncpyz( ent->client->pers.lastMessage, chatText, - sizeof( ent->client->pers.lastMessage ) ); + if ( ( level.time - ent->client->pers.lastMessageTime ) < ( g_spamTime.integer * 1000 ) && + !Q_stricmp( ent->client->pers.lastMessage, chatText) && + !G_admin_permission( ent, ADMF_NOCENSORFLOOD ) && + ent->client->pers.floodDemerits <= g_floodMaxDemerits.integer ) + { + trap_SendServerCommand( ent-g_entities, "print \"Your message has been ignored to prevent spam\n\"" ); + return; + } + else + { + ent->client->pers.lastMessageTime = level.time; + Q_strncpyz( ent->client->pers.lastMessage, chatText, + sizeof( ent->client->pers.lastMessage ) ); + } } } |