From e7d309cb96c99189e3d02e1ba5416aa0dd1a9c5f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 1 Dec 2018 17:09:43 +0100 Subject: [PATCH] - code consolidation in invnext and invprev. --- src/g_game.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 1c4304f510..1428fa5a90 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -372,6 +372,14 @@ CCMD (weapprev) } } +static void DisplayNameTag(const char *tag) +{ + if ((displaynametags & 1) && StatusBar && SmallFont) + StatusBar->AttachMessage(Create(SmallFont, tag, + 1.5f, 0.80f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID('S', 'I', 'N', 'V')); + +} + CCMD (invnext) { AInventory *next; @@ -398,9 +406,7 @@ CCMD (invnext) who->InvSel = who->Inventory; } } - if ((displaynametags & 1) && StatusBar && SmallFont && who->InvSel) - StatusBar->AttachMessage (Create (SmallFont, who->InvSel->GetTag(), - 1.5f, 0.80f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID('S','I','N','V')); + if (who->InvSel) DisplayNameTag(who->InvSel->GetTag()); } who->player->inventorytics = 5*TICRATE; if (old != who->InvSel) @@ -433,9 +439,7 @@ CCMD (invprev) } who->InvSel = item; } - if ((displaynametags & 1) && StatusBar && SmallFont && who->InvSel) - StatusBar->AttachMessage (Create (SmallFont, who->InvSel->GetTag(), - 1.5f, 0.80f, 0, 0, (EColorRange)*nametagcolor, 2.f, 0.35f), MAKE_ID('S','I','N','V')); + if (who->InvSel) DisplayNameTag(who->InvSel->GetTag()); } who->player->inventorytics = 5*TICRATE; if (old != who->InvSel)