diff options
-rw-r--r-- | src/game/g_active.c | 2 | ||||
-rw-r--r-- | src/game/g_utils.c | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index fe8368a1..a08d9e48 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -73,7 +73,7 @@ void P_DamageFeedback( gentity_t *player ) if( ( level.time > player->pain_debounce_time ) && !( player->flags & FL_GODMODE ) ) { player->pain_debounce_time = level.time + 700; - G_AddEvent( player, EV_PAIN, player->health ); + G_AddEvent( player, EV_PAIN, player->health > 255 ? 255 : player->health ); client->ps.damageEvent++; } diff --git a/src/game/g_utils.c b/src/game/g_utils.c index a3b2cb42..f125f085 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -639,6 +639,19 @@ void G_AddEvent( gentity_t *ent, int event, int eventParm ) return; } + // eventParm is converted to int8_t in msg.c, so prevent rollover since + // this would never be the intent of game code + if( eventParm > 255 ) + { + eventParm = 255; + G_Printf( S_COLOR_YELLOW "WARNING: G_AddEvent: eventParm overflow\n" ); + } + else if( eventParm < -255 ) + { + eventParm = -255; + G_Printf( S_COLOR_YELLOW "WARNING: G_AddEvent: eventParm underrun\n" ); + } + // clients need to add the event in playerState_t instead of entityState_t if( ent->client ) { |