summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2006-12-04 16:18:32 +0000
committerTony J. White <tjw@tjw.org>2006-12-04 16:18:32 +0000
commitd357d57d17bce82cf3017c323fd674efbf44d650 (patch)
treea0a8578cd2460c551892746a8453771c6f2ddcb8 /src
parent2632826fb90eb7b00f6a234cbb18b7152b9f90ac (diff)
* (bug 2934) cap health sent as eventParm at 255 to prevent too many tyrant
pain sounds from int8_t overflow/underrun ( Risujin ) * (bug 2934) prevent int8_t overflow/underrun on eventParm in G_AddEvent and print WARNING when this occurs.
Diffstat (limited to 'src')
-rw-r--r--src/game/g_active.c2
-rw-r--r--src/game/g_utils.c13
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 )
{