From ee19a928a08636504fda5d0362b3310a447633b7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 16 May 2022 20:59:07 +0900 Subject: [PATCH] [model] Make the miptex toupper clearer That bit of code got me every time I looked at it. --- libs/models/brush/model_brush.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/models/brush/model_brush.c b/libs/models/brush/model_brush.c index 7632c07f2..34863d573 100644 --- a/libs/models/brush/model_brush.c +++ b/libs/models/brush/model_brush.c @@ -322,9 +322,13 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp) memset (anims, 0, sizeof (anims)); memset (altanims, 0, sizeof (altanims)); +// convert to uppercase, avoiding toupper (table lookup, +// localization issues, etc) +#define QTOUPPER(x) ((x) - ('a' - 'A')) + max = tx->name[1]; if (max >= 'a' && max <= 'z') - max -= 'a' - 'A'; + max = QTOUPPER (max); if (max >= '0' && max <= '9') { max -= '0'; altmax = 0; @@ -347,7 +351,7 @@ Mod_LoadTextures (model_t *mod, bsp_t *bsp) num = tx2->name[1]; if (num >= 'a' && num <= 'z') - num -= 'a' - 'A'; + num = QTOUPPER (num); if (num >= '0' && num <= '9') { num -= '0'; anims[num] = tx2;