From 0f35221820e8b2cc0e5d0627974936ed1f6e822f Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 6 Nov 2012 23:06:44 +0000 Subject: [PATCH] Prettify some code where I felt was necessary. git-svn-id: https://svn.eduke32.com/eduke32@3127 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/config.c | 7 ++++--- polymer/eduke32/source/jmact/control.c | 4 ++-- polymer/eduke32/source/jmact/keyboard.c | 2 +- polymer/eduke32/source/jmact/keyboard.h | 2 +- polymer/eduke32/source/osdcmds.c | 28 ++++++++++++------------- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 436f5affe..4f1cdb61e 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -150,6 +150,7 @@ void CONFIG_SetDefaultKeys(int32_t type) int32_t i,f; Bmemset(ud.config.KeyboardKeys, 0xff, sizeof(ud.config.KeyboardKeys)); + Bmemset(&KeyBindings,0,sizeof(KeyBindings)); Bmemset(&MouseBindings,0,sizeof(MouseBindings)); @@ -157,10 +158,10 @@ void CONFIG_SetDefaultKeys(int32_t type) { for (i=0; i < (int32_t)(sizeof(oldkeydefaults)/sizeof(oldkeydefaults[0])); i+=3) { - f = CONFIG_FunctionNameToNum((char *)oldkeydefaults[i+0]); + f = CONFIG_FunctionNameToNum(oldkeydefaults[i+0]); if (f == -1) continue; - ud.config.KeyboardKeys[f][0] = KB_StringToScanCode((char *)oldkeydefaults[i+1]); - ud.config.KeyboardKeys[f][1] = KB_StringToScanCode((char *)oldkeydefaults[i+2]); + ud.config.KeyboardKeys[f][0] = KB_StringToScanCode(oldkeydefaults[i+1]); + ud.config.KeyboardKeys[f][1] = KB_StringToScanCode(oldkeydefaults[i+2]); if (f == gamefunc_Show_Console) OSD_CaptureKey(ud.config.KeyboardKeys[f][0]); else CONFIG_MapKey(f, ud.config.KeyboardKeys[f][0], 0, ud.config.KeyboardKeys[f][1], 0); diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c index b05cdc481..94adcf680 100644 --- a/polymer/eduke32/source/jmact/control.c +++ b/polymer/eduke32/source/jmact/control.c @@ -745,9 +745,9 @@ void CONTROL_ProcessBinds(void) if (KB_KeyPressed(i) && (KeyBindings[i].repeat || (KeyBindings[i].laststate == 0))) { OSD_Dispatch(KeyBindings[i].cmd); - KeyBindings[i].laststate = KB_KeyPressed(i); } - else KeyBindings[i].laststate = KB_KeyPressed(i); + + KeyBindings[i].laststate = KB_KeyPressed(i); } } while (i--); diff --git a/polymer/eduke32/source/jmact/keyboard.c b/polymer/eduke32/source/jmact/keyboard.c index 4d5b68b47..4811f9f0e 100644 --- a/polymer/eduke32/source/jmact/keyboard.c +++ b/polymer/eduke32/source/jmact/keyboard.c @@ -243,7 +243,7 @@ const char *KB_ScanCodeToString(kb_scancode scancode) return ""; } -kb_scancode KB_StringToScanCode(char * string) +kb_scancode KB_StringToScanCode(const char * string) { uint32_t s; diff --git a/polymer/eduke32/source/jmact/keyboard.h b/polymer/eduke32/source/jmact/keyboard.h index 1a80c2800..4b8dffc42 100644 --- a/polymer/eduke32/source/jmact/keyboard.h +++ b/polymer/eduke32/source/jmact/keyboard.h @@ -93,7 +93,7 @@ char KB_Getch( void ); // Gets the next keypress void KB_FlushKeyboardQueue( void ); // Empties the keyboard queue of all waiting characters. void KB_ClearKeysDown( void ); // Clears all keys down flags. const char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string -kb_scancode KB_StringToScanCode( char * string ); // convert a string into a scancode +kb_scancode KB_StringToScanCode( const char * string ); // convert a string into a scancode void KB_TurnKeypadOn( void ); // turn the keypad on void KB_TurnKeypadOff( void ); // turn the keypad off int32_t KB_KeypadActive( void ); // check whether keypad is active diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 65fc4c8fd..b971ed400 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -727,17 +727,11 @@ void onvideomodechange(int32_t newmode) { uint8_t palid; - if (newmode) - { - if (g_player[screenpeek].ps->palette < BASEPALCOUNT) - palid = g_player[screenpeek].ps->palette; - else - palid = BASEPAL; - } - else - { + // XXX? + if (!newmode || g_player[screenpeek].ps->palette < BASEPALCOUNT) palid = g_player[screenpeek].ps->palette; - } + else + palid = BASEPAL; #ifdef POLYMER if (getrendermode() == 4) @@ -912,7 +906,7 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) { int32_t i, j; - if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys")) + if (parm->numparms==1 && !Bstrcasecmp(parm->parms[0],"showkeys")) { for (i=0; ConsoleKeys[i].name; i++) OSD_Printf("%s\n",ConsoleKeys[i].name); @@ -930,14 +924,16 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) if (KeyBindings[i].cmd[0] && KeyBindings[i].key) { j++; - OSD_Printf("%-9s %s\"%s\"\n",KeyBindings[i].key, KeyBindings[i].repeat?"":"norepeat ", KeyBindings[i].cmd); + OSD_Printf("%-9s %s\"%s\"\n", KeyBindings[i].key, KeyBindings[i].repeat?"":"norepeat ", + KeyBindings[i].cmd); } for (i=0; inumparms < 2) { - OSD_Printf("%-9s %s\"%s\"\n",ConsoleButtons[i], MouseBindings[i].repeat?"":"norepeat ",MouseBindings[i].cmd); + OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], MouseBindings[i].repeat?"":"norepeat ", + MouseBindings[i].cmd); return OSDCMD_OK; } @@ -989,7 +986,8 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) if (parm->numparms < 2) { - OSD_Printf("%-9s %s\"%s\"\n",ConsoleKeys[i].name, KeyBindings[ConsoleKeys[i].id].repeat?"":"norepeat ", KeyBindings[ConsoleKeys[i].id].cmd); + OSD_Printf("%-9s %s\"%s\"\n", ConsoleKeys[i].name, KeyBindings[ConsoleKeys[i].id].repeat?"":"norepeat ", + KeyBindings[ConsoleKeys[i].id].cmd); return OSDCMD_OK; }