From abf1ef37dc3a2e0c3fc7bea317f2fa23318d5bf5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 6 Aug 2002 03:52:38 +0000 Subject: [PATCH] convert the flag offset calculation from switch to a lookup table. this should be a touch faster avoiding the extra jumps --- qw/source/cl_ents.c | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index b000bcf8b..0fb0b87cf 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -728,6 +728,10 @@ CL_ParsePlayerinfo (void) void CL_AddFlagModels (entity_t *ent, int team, int key) { + static float flag_offsets[] = { + 16.0, 22.0, 26.0, 25.0, 24.0, 18.0, // 29-34 axpain + 16.0, 24.0, 24.0, 22.0, 18.0, 16.0, // 35-40 pain + }; float f; int i; entity_t **newent; @@ -738,45 +742,7 @@ CL_AddFlagModels (entity_t *ent, int team, int key) f = 14.0; if (ent->frame >= 29 && ent->frame <= 40) { - switch (ent->frame) { - case 29: // 29-34 axpain - f = 16.0; - break; - case 30: - f = 22.0; - break; - case 31: - f = 26.0; - break; - case 32: - f = 25.0; - break; - case 33: - f = 24.0; - break; - case 34: - f = 18.0; - break; - - case 35: // 35-40 pain - f = 16.0; - break; - case 36: - f = 24.0; - break; - case 37: - f = 24.0; - break; - case 38: - f = 22.0; - break; - case 39: - f = 18.0; - break; - case 40: - f = 16.0; - break; - } + f = flag_offsets[ent->frame - 29]; } else if (ent->frame >= 103 && ent->frame <= 118) { if (ent->frame <= 106) // 103-104 nailattack f = 20.0; // 105-106 light