From 3b0fb43d6e79c7a240464f8d145bf605c0fefe75 Mon Sep 17 00:00:00 2001 From: Nikolay Borodin Date: Thu, 22 Feb 2024 14:18:37 +0200 Subject: [PATCH] Use castDroid/castStructure --- src/display3d.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/display3d.cpp b/src/display3d.cpp index 69a7434f0eb..39568975457 100644 --- a/src/display3d.cpp +++ b/src/display3d.cpp @@ -3628,8 +3628,8 @@ enum GROUPNUMBER_TYPE GN_DAMAGED, GN_FACTORY }; -/// rendering of the unit's group next to the unit itself, -/// or the group that will be assigned to the unit after production in the factory +/// rendering of the object's group next to the object itself, +/// or the group that will be assigned to the object after production in the factory static void drawGroupNumber(BASE_OBJECT *psObject) { UWORD id = UWORD_MAX; @@ -3637,7 +3637,7 @@ static void drawGroupNumber(BASE_OBJECT *psObject) int32_t x = 0, y = 0; GROUPNUMBER_TYPE groupNumberType = GN_NORMAL; - if (auto *psDroid = dynamic_cast(psObject)) + if (auto *psDroid = castDroid(psObject)) { int32_t xShift = psDroid->sDisplay.screenR + GN_X_OFFSET; int32_t yShift = psDroid->sDisplay.screenR; @@ -3645,14 +3645,16 @@ static void drawGroupNumber(BASE_OBJECT *psObject) x = psDroid->sDisplay.screenX - xShift; y = psDroid->sDisplay.screenY + yShift; - if (psDroid->repairGroup != UBYTE_MAX) { + if (psDroid->repairGroup != UBYTE_MAX) + { groupNumber = psDroid->repairGroup; groupNumberType = GN_DAMAGED; - } else { + } else + { groupNumber = psDroid->group; } } - else if (auto *psStruct = dynamic_cast(psObject)) + else if (auto *psStruct = castStructure(psObject)) { // same as in queueStructureHealth int32_t scale = static_cast(MAX(psStruct->pStructureType->baseWidth, psStruct->pStructureType->baseBreadth));