From 69a1d8d9534ef57911b28ce589da9dcd3384c7cc Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 25 Oct 2018 23:33:58 +0000 Subject: [PATCH] Very (very) slightly less terrible G_CheckPlayerColor() function. git-svn-id: https://svn.eduke32.com/eduke32@7133 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/menus.cpp | 8 ++++---- source/duke3d/src/menus.h | 2 +- source/duke3d/src/osdcmds.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index c7b0fcd36..7a9c9283a 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -4191,13 +4191,13 @@ int Menu_Change(MenuID_t cm) -void G_CheckPlayerColor(int32_t *color, int32_t prev_color) +int G_CheckPlayerColor(int color) { for (int i : MEOSV_PLAYER_COLOR) - if (*color == i) - return; + if (i == color) + return color; - *color = prev_color; + return -1; } diff --git a/source/duke3d/src/menus.h b/source/duke3d/src/menus.h index 649c0b368..9729512ae 100644 --- a/source/duke3d/src/menus.h +++ b/source/duke3d/src/menus.h @@ -461,7 +461,7 @@ extern int32_t voting; int Menu_Change(int32_t cm); void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype); int32_t Menu_IsTextInput(Menu_t *cm); -void G_CheckPlayerColor(int32_t *color,int32_t prev_color); +int G_CheckPlayerColor(int color); void Menu_Init(void); void Menu_Open(uint8_t playerID); void Menu_Close(uint8_t playerID); diff --git a/source/duke3d/src/osdcmds.cpp b/source/duke3d/src/osdcmds.cpp index 85050d7d0..d02bdc2f3 100644 --- a/source/duke3d/src/osdcmds.cpp +++ b/source/duke3d/src/osdcmds.cpp @@ -1544,7 +1544,7 @@ static int32_t osdcmd_cvar_set_game(osdfuncparm_t const * const parm) } else if (!Bstrcasecmp(parm->name, "color")) { - G_CheckPlayerColor((int32_t *)&ud.color,-1); + ud.color = G_CheckPlayerColor(ud.color); g_player[0].ps->palookup = g_player[0].pcolor = ud.color; } else if (!Bstrcasecmp(parm->name, "osdscale"))