From 51ab62f6fb06b42c80c98ea71ab29d208d10e422 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Tue, 17 Feb 2015 12:00:04 +0100 Subject: setup: fix "control reaches end of non-void function" compiler warning Actually, it is impossible to reach the end of these two functions without return()ing earlier from one of the switch() statements' branches. But since the compiler cannot know this and warns about it, and since this warning can be escalated into an error in later compiler versions, silence it by return()ing a dummy value at the end of each function. Fixes #508 --- src/setup/txt_joyaxis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/setup/txt_joyaxis.c b/src/setup/txt_joyaxis.c index 4747a4ff..5e59b9f7 100644 --- a/src/setup/txt_joyaxis.c +++ b/src/setup/txt_joyaxis.c @@ -63,6 +63,8 @@ static char *CalibrationLabel(txt_joystick_axis_t *joystick_axis) "right, and press the button."; } } + + return NULL; } static void SetCalibrationLabel(txt_joystick_axis_t *joystick_axis) @@ -265,6 +267,8 @@ static int NextCalibrateStage(txt_joystick_axis_t *joystick_axis) case CONFIG_STAGE2: return CONFIG_CENTER; } + + return -1; } static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_axis)) -- cgit v1.2.3 From 714d7a29397b44fcb2b1fef2d675d296cb984264 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 19 Feb 2015 23:50:04 -0500 Subject: doom: Change weaponowned[] to an int array. The st_stuff.c status bar code passes pointer to an entry in weaponowned[] as an int pointer, but weaponowned[] is an array of booleans and booleans are not always represented as 32-bit ints. Remove the (int *) cast and ensure correct behavior. This fixes the immediate issue in #509 (thanks floppes). --- src/doom/d_player.h | 2 +- src/doom/st_stuff.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/doom/d_player.h b/src/doom/d_player.h index a72c2f5f..04e47109 100644 --- a/src/doom/d_player.h +++ b/src/doom/d_player.h @@ -111,7 +111,7 @@ typedef struct player_s // Is wp_nochange if not changing. weapontype_t pendingweapon; - boolean weaponowned[NUMWEAPONS]; + int weaponowned[NUMWEAPONS]; int ammo[NUMAMMO]; int maxammo[NUMAMMO]; diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c index 9a25865c..693b6ef2 100644 --- a/src/doom/st_stuff.c +++ b/src/doom/st_stuff.c @@ -1261,11 +1261,12 @@ void ST_createWidgets(void) // weapons owned for(i=0;i<6;i++) { - STlib_initMultIcon(&w_arms[i], - ST_ARMSX+(i%3)*ST_ARMSXSPACE, - ST_ARMSY+(i/3)*ST_ARMSYSPACE, - arms[i], (int *) &plyr->weaponowned[i+1], - &st_armson); + STlib_initMultIcon(&w_arms[i], + ST_ARMSX+(i%3)*ST_ARMSXSPACE, + ST_ARMSY+(i/3)*ST_ARMSYSPACE, + arms[i], + &plyr->weaponowned[i+1], + &st_armson); } // frags sum -- cgit v1.2.3 From 1f5ce047ad6cb709f746b794b4a2dea9e2f89fb6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Feb 2015 00:03:15 -0500 Subject: Fix game code that makes false boolean assumptions. Various bits of code assume that booleans are represented as 32-bit ints and that they can be assigned to from 32-bit values. This isn't true on all systems; fix code that does this to convert to boolean values properly. This is more progress towards fixing #509. --- src/doom/p_inter.c | 15 +++++++++------ src/doom/p_map.c | 2 +- src/doom/p_maputl.c | 2 +- src/heretic/p_map.c | 2 +- src/heretic/p_maputl.c | 2 +- src/hexen/p_map.c | 2 +- src/hexen/p_maputl.c | 2 +- src/hexen/p_spec.c | 2 +- src/strife/p_enemy.c | 4 ++-- src/strife/p_inter.c | 10 ++++++---- src/strife/p_map.c | 2 +- src/strife/p_maputl.c | 2 +- 12 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/doom/p_inter.c b/src/doom/p_inter.c index c9965799..633408fe 100644 --- a/src/doom/p_inter.c +++ b/src/doom/p_inter.c @@ -603,8 +603,9 @@ P_TouchSpecialThing break; case SPR_MGUN: - if (!P_GiveWeapon (player, wp_chaingun, special->flags&MF_DROPPED) ) - return; + if (!P_GiveWeapon(player, wp_chaingun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTCHAINGUN); sound = sfx_wpnup; break; @@ -631,15 +632,17 @@ P_TouchSpecialThing break; case SPR_SHOT: - if (!P_GiveWeapon (player, wp_shotgun, special->flags&MF_DROPPED ) ) - return; + if (!P_GiveWeapon(player, wp_shotgun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTSHOTGUN); sound = sfx_wpnup; break; case SPR_SGN2: - if (!P_GiveWeapon (player, wp_supershotgun, special->flags&MF_DROPPED ) ) - return; + if (!P_GiveWeapon(player, wp_supershotgun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTSHOTGUN2); sound = sfx_wpnup; break; diff --git a/src/doom/p_map.c b/src/doom/p_map.c index e371869a..9d3086fd 100644 --- a/src/doom/p_map.c +++ b/src/doom/p_map.c @@ -357,7 +357,7 @@ boolean PIT_CheckThing (mobj_t* thing) // check for special pickup if (thing->flags & MF_SPECIAL) { - solid = thing->flags&MF_SOLID; + solid = (thing->flags & MF_SOLID) != 0; if (tmflags&MF_PICKUP) { // can remove thing diff --git a/src/doom/p_maputl.c b/src/doom/p_maputl.c index 916f2b64..098c2c73 100644 --- a/src/doom/p_maputl.c +++ b/src/doom/p_maputl.c @@ -887,7 +887,7 @@ P_PathTraverse int count; - earlyout = flags & PT_EARLYOUT; + earlyout = (flags & PT_EARLYOUT) != 0; validcount++; intercept_p = intercepts; diff --git a/src/heretic/p_map.c b/src/heretic/p_map.c index 48db07e5..6f1e64d7 100644 --- a/src/heretic/p_map.c +++ b/src/heretic/p_map.c @@ -428,7 +428,7 @@ boolean PIT_CheckThing(mobj_t * thing) // Check for special thing if (thing->flags & MF_SPECIAL) { - solid = thing->flags & MF_SOLID; + solid = (thing->flags & MF_SOLID) != 0; if (tmflags & MF_PICKUP) { // Can be picked up by tmthing P_TouchSpecialThing(thing, tmthing); // Can remove thing diff --git a/src/heretic/p_maputl.c b/src/heretic/p_maputl.c index 577f527c..e2a71556 100644 --- a/src/heretic/p_maputl.c +++ b/src/heretic/p_maputl.c @@ -667,7 +667,7 @@ boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int mapx, mapy, mapxstep, mapystep; int count; - earlyout = flags & PT_EARLYOUT; + earlyout = (flags & PT_EARLYOUT) != 0; validcount++; intercept_p = intercepts; diff --git a/src/hexen/p_map.c b/src/hexen/p_map.c index 11aa23e0..b1c542ca 100644 --- a/src/hexen/p_map.c +++ b/src/hexen/p_map.c @@ -661,7 +661,7 @@ boolean PIT_CheckThing(mobj_t * thing) // Check for special thing if (thing->flags & MF_SPECIAL) { - solid = thing->flags & MF_SOLID; + solid = (thing->flags & MF_SOLID) != 0; if (tmflags & MF_PICKUP) { // Can be picked up by tmthing P_TouchSpecialThing(thing, tmthing); // Can remove thing diff --git a/src/hexen/p_maputl.c b/src/hexen/p_maputl.c index a48ea8fa..dcc7d5d2 100644 --- a/src/hexen/p_maputl.c +++ b/src/hexen/p_maputl.c @@ -699,7 +699,7 @@ boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int mapx, mapy, mapxstep, mapystep; int count; - earlyout = flags & PT_EARLYOUT; + earlyout = (flags & PT_EARLYOUT) != 0; validcount++; intercept_p = intercepts; diff --git a/src/hexen/p_spec.c b/src/hexen/p_spec.c index e2069fb9..d36d3e86 100644 --- a/src/hexen/p_spec.c +++ b/src/hexen/p_spec.c @@ -864,7 +864,7 @@ boolean P_ActivateLine(line_t * line, mobj_t * mo, int side, if (line->flags & ML_SECRET) return false; // never open secret doors } - repeat = line->flags & ML_REPEAT_SPECIAL; + repeat = (line->flags & ML_REPEAT_SPECIAL) != 0; buttonSuccess = false; // Construct args[] array to contain the arguments from the line, as we diff --git a/src/strife/p_enemy.c b/src/strife/p_enemy.c index 8aad08fc..e358e616 100644 --- a/src/strife/p_enemy.c +++ b/src/strife/p_enemy.c @@ -891,7 +891,7 @@ void A_Look (mobj_t* actor) // as a parameter to control allaround look behavior. Did they just run out of // flags, or what? // STRIFE-TODO: Needs serious verification. - if (!P_LookForPlayers (actor, actor->flags & MF_GIVEQUEST) ) + if (!P_LookForPlayers(actor, (actor->flags & MF_GIVEQUEST) != 0)) return; // go into chase state @@ -975,7 +975,7 @@ void A_FriendLook(mobj_t* actor) gamemap != 3 && gamemap != 34) { // STRIFE-TODO: Needs serious verification. - if(P_LookForPlayers(actor, actor->flags & MF_GIVEQUEST)) + if(P_LookForPlayers(actor, (actor->flags & MF_GIVEQUEST) != 0)) { P_SetMobjState(actor, actor->info->seestate); actor->flags |= MF_NODIALOG; diff --git a/src/strife/p_inter.c b/src/strife/p_inter.c index 71db6fe1..f2e16efb 100644 --- a/src/strife/p_inter.c +++ b/src/strife/p_inter.c @@ -537,7 +537,7 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // rifle case SPR_RIFL: - if(!P_GiveWeapon(player, wp_rifle, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_rifle, (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; @@ -560,7 +560,8 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // grenade launcher case SPR_GRND: - if(!P_GiveWeapon(player, wp_hegrenade, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_hegrenade, + (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; @@ -574,14 +575,15 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // electric bolt crossbow case SPR_CBOW: - if(!P_GiveWeapon(player, wp_elecbow, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_elecbow, + (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; // haleyjd 09/21/10: missed case: THE SIGIL! case SPR_SIGL: - if(!P_GiveWeapon(player, wp_sigil, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_sigil, (special->flags & MF_DROPPED) != 0)) { player->sigiltype = special->frame; return; diff --git a/src/strife/p_map.c b/src/strife/p_map.c index 13a1bb54..03b57edd 100644 --- a/src/strife/p_map.c +++ b/src/strife/p_map.c @@ -384,7 +384,7 @@ boolean PIT_CheckThing (mobj_t* thing) // check for special pickup if (thing->flags & MF_SPECIAL) { - solid = thing->flags&MF_SOLID; + solid = (thing->flags & MF_SOLID) != 0; if (tmthing->player) // villsa [STRIFE] no longer checks MF_PICKUP flag { // can remove thing diff --git a/src/strife/p_maputl.c b/src/strife/p_maputl.c index 4ecb5566..f1773858 100644 --- a/src/strife/p_maputl.c +++ b/src/strife/p_maputl.c @@ -941,7 +941,7 @@ P_PathTraverse int count; - earlyout = flags & PT_EARLYOUT; + earlyout = (flags & PT_EARLYOUT) != 0; validcount++; intercept_p = intercepts; -- cgit v1.2.3 From b39121c6a682eb8ae5efd29a875bd7c098185f04 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Feb 2015 00:31:09 -0500 Subject: Refactor config file API. The config file API previously relied on binding config variables using M_BindVariable() which took a void pointer. It occurred to me that if used on a boolean variable, this would be erroneous, but the void pointer would make it impossible to tell. Split this into separate M_Bind{Foo}Variable() functions based on type, which allows for proper type checking on the pointers that are passed. Vaguely related to #509. --- src/d_iwad.c | 2 +- src/doom/d_main.c | 22 ++-- src/gusconf.c | 2 +- src/gusconf.h | 2 +- src/heretic/d_main.c | 16 +-- src/hexen/h2_main.c | 19 ++-- src/i_joystick.c | 18 ++-- src/i_sound.c | 34 +++---- src/i_video.c | 34 +++---- src/m_config.c | 64 ++++++++---- src/m_config.h | 6 +- src/m_controls.c | 250 +++++++++++++++++++++++----------------------- src/net_client.c | 2 +- src/setup/compatibility.c | 4 +- src/setup/display.c | 26 ++--- src/setup/joystick.c | 18 ++-- src/setup/keyboard.c | 2 +- src/setup/mode.c | 19 ++-- src/setup/mouse.c | 12 +-- src/setup/multiplayer.c | 4 +- src/setup/sound.c | 50 +++++----- src/strife/d_main.c | 33 +++--- 22 files changed, 338 insertions(+), 301 deletions(-) diff --git a/src/d_iwad.c b/src/d_iwad.c index 7f512965..2d6460bc 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -332,7 +332,7 @@ static void CheckSteamGUSPatches(void) int len; // Already configured? Don't stomp on the user's choices. - current_path = M_GetStrVariable("gus_patch_path"); + current_path = M_GetStringVariable("gus_patch_path"); if (current_path != NULL && strlen(current_path) > 0) { return; diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 1e9e950e..ca722dc6 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -359,16 +359,16 @@ void D_BindVariables(void) NET_BindVariables(); #endif - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &sfxVolume); - M_BindVariable("music_volume", &musicVolume); - M_BindVariable("show_messages", &showMessages); - M_BindVariable("screenblocks", &screenblocks); - M_BindVariable("detaillevel", &detailLevel); - M_BindVariable("snd_channels", &snd_channels); - M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); - M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); - M_BindVariable("show_endoom", &show_endoom); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &sfxVolume); + M_BindIntVariable("music_volume", &musicVolume); + M_BindIntVariable("show_messages", &showMessages); + M_BindIntVariable("screenblocks", &screenblocks); + M_BindIntVariable("detaillevel", &detailLevel); + M_BindIntVariable("snd_channels", &snd_channels); + M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit); + M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit); + M_BindIntVariable("show_endoom", &show_endoom); // Multiplayer chat macros @@ -377,7 +377,7 @@ void D_BindVariables(void) char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); - M_BindVariable(buf, &chat_macros[i]); + M_BindStringVariable(buf, &chat_macros[i]); } } diff --git a/src/gusconf.c b/src/gusconf.c index a2dfdac3..f1575c41 100644 --- a/src/gusconf.c +++ b/src/gusconf.c @@ -39,7 +39,7 @@ typedef struct } gus_config_t; char *gus_patch_path = ""; -unsigned int gus_ram_kb = 1024; +int gus_ram_kb = 1024; static unsigned int MappingIndex(void) { diff --git a/src/gusconf.h b/src/gusconf.h index e0124266..4efbe995 100644 --- a/src/gusconf.h +++ b/src/gusconf.h @@ -21,7 +21,7 @@ #include "doomtype.h" extern char *gus_patch_path; -extern unsigned int gus_ram_kb; +extern int gus_ram_kb; boolean GUS_WriteConfig(char *path); diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c index 8389a23d..2a57016f 100644 --- a/src/heretic/d_main.c +++ b/src/heretic/d_main.c @@ -756,20 +756,20 @@ void D_BindVariables(void) M_BindMenuControls(); M_BindMapControls(); - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &snd_MaxVolume); - M_BindVariable("music_volume", &snd_MusicVolume); - M_BindVariable("screenblocks", &screenblocks); - M_BindVariable("snd_channels", &snd_Channels); - M_BindVariable("show_endoom", &show_endoom); - M_BindVariable("graphical_startup", &graphical_startup); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &snd_MaxVolume); + M_BindIntVariable("music_volume", &snd_MusicVolume); + M_BindIntVariable("screenblocks", &screenblocks); + M_BindIntVariable("snd_channels", &snd_Channels); + M_BindIntVariable("show_endoom", &show_endoom); + M_BindIntVariable("graphical_startup", &graphical_startup); for (i=0; i<10; ++i) { char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); - M_BindVariable(buf, &chat_macros[i]); + M_BindStringVariable(buf, &chat_macros[i]); } } diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index 23131e9b..9d92a65b 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -149,14 +149,15 @@ void D_BindVariables(void) key_multi_msgplayer[6] = CT_KEY_PLAYER7; key_multi_msgplayer[7] = CT_KEY_PLAYER8; - M_BindVariable("graphical_startup", &graphical_startup); - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &snd_MaxVolume); - M_BindVariable("music_volume", &snd_MusicVolume); - M_BindVariable("messageson", &messageson); - M_BindVariable("screenblocks", &screenblocks); - M_BindVariable("snd_channels", &snd_Channels); - M_BindVariable("savedir", &SavePath); + M_BindIntVariable("graphical_startup", &graphical_startup); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &snd_MaxVolume); + M_BindIntVariable("music_volume", &snd_MusicVolume); + M_BindIntVariable("messageson", &messageson); + M_BindIntVariable("screenblocks", &screenblocks); + M_BindIntVariable("snd_channels", &snd_Channels); + + M_BindStringVariable("savedir", &SavePath); // Multiplayer chat macros @@ -165,7 +166,7 @@ void D_BindVariables(void) char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); - M_BindVariable(buf, &chat_macros[i]); + M_BindStringVariable(buf, &chat_macros[i]); } } diff --git a/src/i_joystick.c b/src/i_joystick.c index 06531a0b..eba7f21a 100644 --- a/src/i_joystick.c +++ b/src/i_joystick.c @@ -328,20 +328,20 @@ void I_BindJoystickVariables(void) { int i; - M_BindVariable("use_joystick", &usejoystick); - M_BindVariable("joystick_index", &joystick_index); - M_BindVariable("joystick_x_axis", &joystick_x_axis); - M_BindVariable("joystick_y_axis", &joystick_y_axis); - M_BindVariable("joystick_strafe_axis", &joystick_strafe_axis); - M_BindVariable("joystick_x_invert", &joystick_x_invert); - M_BindVariable("joystick_y_invert", &joystick_y_invert); - M_BindVariable("joystick_strafe_invert",&joystick_strafe_invert); + M_BindIntVariable("use_joystick", &usejoystick); + M_BindIntVariable("joystick_index", &joystick_index); + M_BindIntVariable("joystick_x_axis", &joystick_x_axis); + M_BindIntVariable("joystick_y_axis", &joystick_y_axis); + M_BindIntVariable("joystick_strafe_axis", &joystick_strafe_axis); + M_BindIntVariable("joystick_x_invert", &joystick_x_invert); + M_BindIntVariable("joystick_y_invert", &joystick_y_invert); + M_BindIntVariable("joystick_strafe_invert",&joystick_strafe_invert); for (i = 0; i < NUM_VIRTUAL_BUTTONS; ++i) { char name[32]; M_snprintf(name, sizeof(name), "joystick_physical_button%i", i); - M_BindVariable(name, &joystick_physical_buttons[i]); + M_BindIntVariable(name, &joystick_physical_buttons[i]); } } diff --git a/src/i_sound.c b/src/i_sound.c index 4432a468..e70b9bc7 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -434,25 +434,25 @@ void I_BindSoundVariables(void) extern int use_libsamplerate; extern float libsamplerate_scale; - M_BindVariable("snd_musicdevice", &snd_musicdevice); - M_BindVariable("snd_sfxdevice", &snd_sfxdevice); - M_BindVariable("snd_sbport", &snd_sbport); - M_BindVariable("snd_sbirq", &snd_sbirq); - M_BindVariable("snd_sbdma", &snd_sbdma); - M_BindVariable("snd_mport", &snd_mport); - M_BindVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms); - M_BindVariable("snd_musiccmd", &snd_musiccmd); - M_BindVariable("snd_samplerate", &snd_samplerate); - M_BindVariable("snd_cachesize", &snd_cachesize); - M_BindVariable("opl_io_port", &opl_io_port); - - M_BindVariable("timidity_cfg_path", &timidity_cfg_path); - M_BindVariable("gus_patch_path", &gus_patch_path); - M_BindVariable("gus_ram_kb", &gus_ram_kb); + M_BindIntVariable("snd_musicdevice", &snd_musicdevice); + M_BindIntVariable("snd_sfxdevice", &snd_sfxdevice); + M_BindIntVariable("snd_sbport", &snd_sbport); + M_BindIntVariable("snd_sbirq", &snd_sbirq); + M_BindIntVariable("snd_sbdma", &snd_sbdma); + M_BindIntVariable("snd_mport", &snd_mport); + M_BindIntVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms); + M_BindStringVariable("snd_musiccmd", &snd_musiccmd); + M_BindIntVariable("snd_samplerate", &snd_samplerate); + M_BindIntVariable("snd_cachesize", &snd_cachesize); + M_BindIntVariable("opl_io_port", &opl_io_port); + + M_BindStringVariable("timidity_cfg_path", &timidity_cfg_path); + M_BindStringVariable("gus_patch_path", &gus_patch_path); + M_BindIntVariable("gus_ram_kb", &gus_ram_kb); #ifdef FEATURE_SOUND - M_BindVariable("use_libsamplerate", &use_libsamplerate); - M_BindVariable("libsamplerate_scale", &libsamplerate_scale); + M_BindIntVariable("use_libsamplerate", &use_libsamplerate); + M_BindFloatVariable("libsamplerate_scale", &libsamplerate_scale); #endif // Before SDL_mixer version 1.2.11, MIDI music caused the game diff --git a/src/i_video.c b/src/i_video.c index 76ad23af..8fb1f178 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -2161,23 +2161,23 @@ void I_InitGraphics(void) void I_BindVideoVariables(void) { - M_BindVariable("use_mouse", &usemouse); - M_BindVariable("autoadjust_video_settings", &autoadjust_video_settings); - M_BindVariable("fullscreen", &fullscreen); - M_BindVariable("aspect_ratio_correct", &aspect_ratio_correct); - M_BindVariable("startup_delay", &startup_delay); - M_BindVariable("screen_width", &screen_width); - M_BindVariable("screen_height", &screen_height); - M_BindVariable("screen_bpp", &screen_bpp); - M_BindVariable("grabmouse", &grabmouse); - M_BindVariable("mouse_acceleration", &mouse_acceleration); - M_BindVariable("mouse_threshold", &mouse_threshold); - M_BindVariable("video_driver", &video_driver); - M_BindVariable("window_position", &window_position); - M_BindVariable("usegamma", &usegamma); - M_BindVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping); - M_BindVariable("novert", &novert); - M_BindVariable("png_screenshots", &png_screenshots); + M_BindIntVariable("use_mouse", &usemouse); + M_BindIntVariable("autoadjust_video_settings", &autoadjust_video_settings); + M_BindIntVariable("fullscreen", &fullscreen); + M_BindIntVariable("aspect_ratio_correct", &aspect_ratio_correct); + M_BindIntVariable("startup_delay", &startup_delay); + M_BindIntVariable("screen_width", &screen_width); + M_BindIntVariable("screen_height", &screen_height); + M_BindIntVariable("screen_bpp", &screen_bpp); + M_BindIntVariable("grabmouse", &grabmouse); + M_BindFloatVariable("mouse_acceleration", &mouse_acceleration); + M_BindIntVariable("mouse_threshold", &mouse_threshold); + M_BindStringVariable("video_driver", &video_driver); + M_BindStringVariable("window_position", &window_position); + M_BindIntVariable("usegamma", &usegamma); + M_BindIntVariable("vanilla_keyboard_mapping", &vanilla_keyboard_mapping); + M_BindIntVariable("novert", &novert); + M_BindIntVariable("png_screenshots", &png_screenshots); // Windows Vista or later? Set screen color depth to // 32 bits per pixel, as 8-bit palettized screen modes diff --git a/src/m_config.c b/src/m_config.c index 083d298a..ad539a7f 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "config.h" @@ -64,7 +65,11 @@ typedef struct char *name; // Pointer to the location in memory of the variable - void *location; + union { + int *i; + char **s; + float *f; + } location; // Type of the variable default_type_t type; @@ -93,7 +98,7 @@ typedef struct } default_collection_t; #define CONFIG_VARIABLE_GENERIC(name, type) \ - { #name, NULL, type, 0, 0, false } + { #name, {NULL}, type, 0, 0, false } #define CONFIG_VARIABLE_KEY(name) \ CONFIG_VARIABLE_GENERIC(name, DEFAULT_KEY) @@ -1646,7 +1651,7 @@ static void SaveDefaultCollection(default_collection_t *collection) // the possibility of screwing up the user's config // file - v = * (int *) defaults[i].location; + v = *defaults[i].location.i; if (v == KEY_RSHIFT) { @@ -1687,19 +1692,19 @@ static void SaveDefaultCollection(default_collection_t *collection) break; case DEFAULT_INT: - fprintf(f, "%i", * (int *) defaults[i].location); + fprintf(f, "%i", *defaults[i].location.i); break; case DEFAULT_INT_HEX: - fprintf(f, "0x%x", * (int *) defaults[i].location); + fprintf(f, "0x%x", *defaults[i].location.i); break; case DEFAULT_FLOAT: - fprintf(f, "%f", * (float *) defaults[i].location); + fprintf(f, "%f", *defaults[i].location.f); break; case DEFAULT_STRING: - fprintf(f,"\"%s\"", * (char **) (defaults[i].location)); + fprintf(f,"\"%s\"", *defaults[i].location.s); break; } @@ -1732,12 +1737,12 @@ static void SetVariable(default_t *def, char *value) switch (def->type) { case DEFAULT_STRING: - * (char **) def->location = M_StringDuplicate(value); + *def->location.s = M_StringDuplicate(value); break; case DEFAULT_INT: case DEFAULT_INT_HEX: - * (int *) def->location = ParseIntParameter(value); + *def->location.i = ParseIntParameter(value); break; case DEFAULT_KEY: @@ -1757,11 +1762,11 @@ static void SetVariable(default_t *def, char *value) } def->original_translated = intparm; - * (int *) def->location = intparm; + *def->location.i = intparm; break; case DEFAULT_FLOAT: - * (float *) def->location = (float) atof(value); + *def->location.f = (float) atof(value); break; } } @@ -1957,13 +1962,38 @@ static default_t *GetDefaultForName(char *name) // Bind a variable to a given configuration file variable, by name. // -void M_BindVariable(char *name, void *location) +void M_BindIntVariable(char *name, int *location) { default_t *variable; variable = GetDefaultForName(name); + assert(variable->type == DEFAULT_INT + || variable->type == DEFAULT_INT_HEX + || variable->type == DEFAULT_KEY); - variable->location = location; + variable->location.i = location; + variable->bound = true; +} + +void M_BindFloatVariable(char *name, float *location) +{ + default_t *variable; + + variable = GetDefaultForName(name); + assert(variable->type == DEFAULT_FLOAT); + + variable->location.f = location; + variable->bound = true; +} + +void M_BindStringVariable(char *name, char **location) +{ + default_t *variable; + + variable = GetDefaultForName(name); + assert(variable->type == DEFAULT_STRING); + + variable->location.s = location; variable->bound = true; } @@ -2000,10 +2030,10 @@ int M_GetIntVariable(char *name) return 0; } - return *((int *) variable->location); + return *variable->location.i; } -const char *M_GetStrVariable(char *name) +const char *M_GetStringVariable(char *name) { default_t *variable; @@ -2015,7 +2045,7 @@ const char *M_GetStrVariable(char *name) return NULL; } - return *((const char **) variable->location); + return *variable->location.s; } float M_GetFloatVariable(char *name) @@ -2030,7 +2060,7 @@ float M_GetFloatVariable(char *name) return 0; } - return *((float *) variable->location); + return *variable->location.f; } // Get the path to the default configuration dir to use, if NULL diff --git a/src/m_config.h b/src/m_config.h index a17de2b4..43882a49 100644 --- a/src/m_config.h +++ b/src/m_config.h @@ -26,10 +26,12 @@ void M_LoadDefaults(void); void M_SaveDefaults(void); void M_SaveDefaultsAlternate(char *main, char *extra); void M_SetConfigDir(char *dir); -void M_BindVariable(char *name, void *variable); +void M_BindIntVariable(char *name, int *variable); +void M_BindFloatVariable(char *name, float *variable); +void M_BindStringVariable(char *name, char **variable); boolean M_SetVariable(char *name, char *value); int M_GetIntVariable(char *name); -const char *M_GetStrVariable(char *name); +const char *M_GetStringVariable(char *name); float M_GetFloatVariable(char *name); void M_SetConfigFilenames(char *main_config, char *extra_config); char *M_GetSaveGameDir(char *iwadname); diff --git a/src/m_controls.c b/src/m_controls.c index c05c8bda..35f848c7 100644 --- a/src/m_controls.c +++ b/src/m_controls.c @@ -204,70 +204,70 @@ int dclick_use = 1; void M_BindBaseControls(void) { - M_BindVariable("key_right", &key_right); - M_BindVariable("key_left", &key_left); - M_BindVariable("key_up", &key_up); - M_BindVariable("key_down", &key_down); - M_BindVariable("key_strafeleft", &key_strafeleft); - M_BindVariable("key_straferight", &key_straferight); - M_BindVariable("key_fire", &key_fire); - M_BindVariable("key_use", &key_use); - M_BindVariable("key_strafe", &key_strafe); - M_BindVariable("key_speed", &key_speed); - - M_BindVariable("mouseb_fire", &mousebfire); - M_BindVariable("mouseb_strafe", &mousebstrafe); - M_BindVariable("mouseb_forward", &mousebforward); - - M_BindVariable("joyb_fire", &joybfire); - M_BindVariable("joyb_strafe", &joybstrafe); - M_BindVariable("joyb_use", &joybuse); - M_BindVariable("joyb_speed", &joybspeed); - - M_BindVariable("joyb_menu_activate", &joybmenu); + M_BindIntVariable("key_right", &key_right); + M_BindIntVariable("key_left", &key_left); + M_BindIntVariable("key_up", &key_up); + M_BindIntVariable("key_down", &key_down); + M_BindIntVariable("key_strafeleft", &key_strafeleft); + M_BindIntVariable("key_straferight", &key_straferight); + M_BindIntVariable("key_fire", &key_fire); + M_BindIntVariable("key_use", &key_use); + M_BindIntVariable("key_strafe", &key_strafe); + M_BindIntVariable("key_speed", &key_speed); + + M_BindIntVariable("mouseb_fire", &mousebfire); + M_BindIntVariable("mouseb_strafe", &mousebstrafe); + M_BindIntVariable("mouseb_forward", &mousebforward); + + M_BindIntVariable("joyb_fire", &joybfire); + M_BindIntVariable("joyb_strafe", &joybstrafe); + M_BindIntVariable("joyb_use", &joybuse); + M_BindIntVariable("joyb_speed", &joybspeed); + + M_BindIntVariable("joyb_menu_activate", &joybmenu); // Extra controls that are not in the Vanilla versions: - M_BindVariable("joyb_strafeleft", &joybstrafeleft); - M_BindVariable("joyb_straferight", &joybstraferight); - M_BindVariable("mouseb_strafeleft", &mousebstrafeleft); - M_BindVariable("mouseb_straferight", &mousebstraferight); - M_BindVariable("mouseb_use", &mousebuse); - M_BindVariable("mouseb_backward", &mousebbackward); - M_BindVariable("dclick_use", &dclick_use); - M_BindVariable("key_pause", &key_pause); - M_BindVariable("key_message_refresh", &key_message_refresh); + M_BindIntVariable("joyb_strafeleft", &joybstrafeleft); + M_BindIntVariable("joyb_straferight", &joybstraferight); + M_BindIntVariable("mouseb_strafeleft", &mousebstrafeleft); + M_BindIntVariable("mouseb_straferight", &mousebstraferight); + M_BindIntVariable("mouseb_use", &mousebuse); + M_BindIntVariable("mouseb_backward", &mousebbackward); + M_BindIntVariable("dclick_use", &dclick_use); + M_BindIntVariable("key_pause", &key_pause); + M_BindIntVariable("key_message_refresh", &key_message_refresh); } void M_BindHereticControls(void) { - M_BindVariable("key_flyup", &key_flyup); - M_BindVariable("key_flydown", &key_flydown); - M_BindVariable("key_flycenter", &key_flycenter); + M_BindIntVariable("key_flyup", &key_flyup); + M_BindIntVariable("key_flydown", &key_flydown); + M_BindIntVariable("key_flycenter", &key_flycenter); - M_BindVariable("key_lookup", &key_lookup); - M_BindVariable("key_lookdown", &key_lookdown); - M_BindVariable("key_lookcenter", &key_lookcenter); + M_BindIntVariable("key_lookup", &key_lookup); + M_BindIntVariable("key_lookdown", &key_lookdown); + M_BindIntVariable("key_lookcenter", &key_lookcenter); - M_BindVariable("key_invleft", &key_invleft); - M_BindVariable("key_invright", &key_invright); - M_BindVariable("key_useartifact", &key_useartifact); + M_BindIntVariable("key_invleft", &key_invleft); + M_BindIntVariable("key_invright", &key_invright); + M_BindIntVariable("key_useartifact", &key_useartifact); } void M_BindHexenControls(void) { - M_BindVariable("key_jump", &key_jump); - M_BindVariable("mouseb_jump", &mousebjump); - M_BindVariable("joyb_jump", &joybjump); - - M_BindVariable("key_arti_all", &key_arti_all); - M_BindVariable("key_arti_health", &key_arti_health); - M_BindVariable("key_arti_poisonbag", &key_arti_poisonbag); - M_BindVariable("key_arti_blastradius", &key_arti_blastradius); - M_BindVariable("key_arti_teleport", &key_arti_teleport); - M_BindVariable("key_arti_teleportother", &key_arti_teleportother); - M_BindVariable("key_arti_egg", &key_arti_egg); - M_BindVariable("key_arti_invulnerability", &key_arti_invulnerability); + M_BindIntVariable("key_jump", &key_jump); + M_BindIntVariable("mouseb_jump", &mousebjump); + M_BindIntVariable("joyb_jump", &joybjump); + + M_BindIntVariable("key_arti_all", &key_arti_all); + M_BindIntVariable("key_arti_health", &key_arti_health); + M_BindIntVariable("key_arti_poisonbag", &key_arti_poisonbag); + M_BindIntVariable("key_arti_blastradius", &key_arti_blastradius); + M_BindIntVariable("key_arti_teleport", &key_arti_teleport); + M_BindIntVariable("key_arti_teleportother", &key_arti_teleportother); + M_BindIntVariable("key_arti_egg", &key_arti_egg); + M_BindIntVariable("key_arti_invulnerability", &key_arti_invulnerability); } void M_BindStrifeControls(void) @@ -282,95 +282,95 @@ void M_BindStrifeControls(void) key_invleft = KEY_INS; key_invright = KEY_DEL; - M_BindVariable("key_jump", &key_jump); - M_BindVariable("key_lookUp", &key_lookup); - M_BindVariable("key_lookDown", &key_lookdown); - M_BindVariable("key_invLeft", &key_invleft); - M_BindVariable("key_invRight", &key_invright); + M_BindIntVariable("key_jump", &key_jump); + M_BindIntVariable("key_lookUp", &key_lookup); + M_BindIntVariable("key_lookDown", &key_lookdown); + M_BindIntVariable("key_invLeft", &key_invleft); + M_BindIntVariable("key_invRight", &key_invright); // Custom Strife-only Keys: - M_BindVariable("key_useHealth", &key_usehealth); - M_BindVariable("key_invquery", &key_invquery); - M_BindVariable("key_mission", &key_mission); - M_BindVariable("key_invPop", &key_invpop); - M_BindVariable("key_invKey", &key_invkey); - M_BindVariable("key_invHome", &key_invhome); - M_BindVariable("key_invEnd", &key_invend); - M_BindVariable("key_invUse", &key_invuse); - M_BindVariable("key_invDrop", &key_invdrop); + M_BindIntVariable("key_useHealth", &key_usehealth); + M_BindIntVariable("key_invquery", &key_invquery); + M_BindIntVariable("key_mission", &key_mission); + M_BindIntVariable("key_invPop", &key_invpop); + M_BindIntVariable("key_invKey", &key_invkey); + M_BindIntVariable("key_invHome", &key_invhome); + M_BindIntVariable("key_invEnd", &key_invend); + M_BindIntVariable("key_invUse", &key_invuse); + M_BindIntVariable("key_invDrop", &key_invdrop); // Strife also supports jump on mouse and joystick, and in the exact same // manner as Hexen! - M_BindVariable("mouseb_jump", &mousebjump); - M_BindVariable("joyb_jump", &joybjump); + M_BindIntVariable("mouseb_jump", &mousebjump); + M_BindIntVariable("joyb_jump", &joybjump); } void M_BindWeaponControls(void) { - M_BindVariable("key_weapon1", &key_weapon1); - M_BindVariable("key_weapon2", &key_weapon2); - M_BindVariable("key_weapon3", &key_weapon3); - M_BindVariable("key_weapon4", &key_weapon4); - M_BindVariable("key_weapon5", &key_weapon5); - M_BindVariable("key_weapon6", &key_weapon6); - M_BindVariable("key_weapon7", &key_weapon7); - M_BindVariable("key_weapon8", &key_weapon8); - - M_BindVariable("key_prevweapon", &key_prevweapon); - M_BindVariable("key_nextweapon", &key_nextweapon); - - M_BindVariable("joyb_prevweapon", &joybprevweapon); - M_BindVariable("joyb_nextweapon", &joybnextweapon); - - M_BindVariable("mouseb_prevweapon", &mousebprevweapon); - M_BindVariable("mouseb_nextweapon", &mousebnextweapon); + M_BindIntVariable("key_weapon1", &key_weapon1); + M_BindIntVariable("key_weapon2", &key_weapon2); + M_BindIntVariable("key_weapon3", &key_weapon3); + M_BindIntVariable("key_weapon4", &key_weapon4); + M_BindIntVariable("key_weapon5", &key_weapon5); + M_BindIntVariable("key_weapon6", &key_weapon6); + M_BindIntVariable("key_weapon7", &key_weapon7); + M_BindIntVariable("key_weapon8", &key_weapon8); + + M_BindIntVariable("key_prevweapon", &key_prevweapon); + M_BindIntVariable("key_nextweapon", &key_nextweapon); + + M_BindIntVariable("joyb_prevweapon", &joybprevweapon); + M_BindIntVariable("joyb_nextweapon", &joybnextweapon); + + M_BindIntVariable("mouseb_prevweapon", &mousebprevweapon); + M_BindIntVariable("mouseb_nextweapon", &mousebnextweapon); } void M_BindMapControls(void) { - M_BindVariable("key_map_north", &key_map_north); - M_BindVariable("key_map_south", &key_map_south); - M_BindVariable("key_map_east", &key_map_east); - M_BindVariable("key_map_west", &key_map_west); - M_BindVariable("key_map_zoomin", &key_map_zoomin); - M_BindVariable("key_map_zoomout", &key_map_zoomout); - M_BindVariable("key_map_toggle", &key_map_toggle); - M_BindVariable("key_map_maxzoom", &key_map_maxzoom); - M_BindVariable("key_map_follow", &key_map_follow); - M_BindVariable("key_map_grid", &key_map_grid); - M_BindVariable("key_map_mark", &key_map_mark); - M_BindVariable("key_map_clearmark", &key_map_clearmark); + M_BindIntVariable("key_map_north", &key_map_north); + M_BindIntVariable("key_map_south", &key_map_south); + M_BindIntVariable("key_map_east", &key_map_east); + M_BindIntVariable("key_map_west", &key_map_west); + M_BindIntVariable("key_map_zoomin", &key_map_zoomin); + M_BindIntVariable("key_map_zoomout", &key_map_zoomout); + M_BindIntVariable("key_map_toggle", &key_map_toggle); + M_BindIntVariable("key_map_maxzoom", &key_map_maxzoom); + M_BindIntVariable("key_map_follow", &key_map_follow); + M_BindIntVariable("key_map_grid", &key_map_grid); + M_BindIntVariable("key_map_mark", &key_map_mark); + M_BindIntVariable("key_map_clearmark", &key_map_clearmark); } void M_BindMenuControls(void) { - M_BindVariable("key_menu_activate", &key_menu_activate); - M_BindVariable("key_menu_up", &key_menu_up); - M_BindVariable("key_menu_down", &key_menu_down); - M_BindVariable("key_menu_left", &key_menu_left); - M_BindVariable("key_menu_right", &key_menu_right); - M_BindVariable("key_menu_back", &key_menu_back); - M_BindVariable("key_menu_forward", &key_menu_forward); - M_BindVariable("key_menu_confirm", &key_menu_confirm); - M_BindVariable("key_menu_abort", &key_menu_abort); - - M_BindVariable("key_menu_help", &key_menu_help); - M_BindVariable("key_menu_save", &key_menu_save); - M_BindVariable("key_menu_load", &key_menu_load); - M_BindVariable("key_menu_volume", &key_menu_volume); - M_BindVariable("key_menu_detail", &key_menu_detail); - M_BindVariable("key_menu_qsave", &key_menu_qsave); - M_BindVariable("key_menu_endgame", &key_menu_endgame); - M_BindVariable("key_menu_messages", &key_menu_messages); - M_BindVariable("key_menu_qload", &key_menu_qload); - M_BindVariable("key_menu_quit", &key_menu_quit); - M_BindVariable("key_menu_gamma", &key_menu_gamma); - - M_BindVariable("key_menu_incscreen", &key_menu_incscreen); - M_BindVariable("key_menu_decscreen", &key_menu_decscreen); - M_BindVariable("key_menu_screenshot",&key_menu_screenshot); - M_BindVariable("key_demo_quit", &key_demo_quit); - M_BindVariable("key_spy", &key_spy); + M_BindIntVariable("key_menu_activate", &key_menu_activate); + M_BindIntVariable("key_menu_up", &key_menu_up); + M_BindIntVariable("key_menu_down", &key_menu_down); + M_BindIntVariable("key_menu_left", &key_menu_left); + M_BindIntVariable("key_menu_right", &key_menu_right); + M_BindIntVariable("key_menu_back", &key_menu_back); + M_BindIntVariable("key_menu_forward", &key_menu_forward); + M_BindIntVariable("key_menu_confirm", &key_menu_confirm); + M_BindIntVariable("key_menu_abort", &key_menu_abort); + + M_BindIntVariable("key_menu_help", &key_menu_help); + M_BindIntVariable("key_menu_save", &key_menu_save); + M_BindIntVariable("key_menu_load", &key_menu_load); + M_BindIntVariable("key_menu_volume", &key_menu_volume); + M_BindIntVariable("key_menu_detail", &key_menu_detail); + M_BindIntVariable("key_menu_qsave", &key_menu_qsave); + M_BindIntVariable("key_menu_endgame", &key_menu_endgame); + M_BindIntVariable("key_menu_messages", &key_menu_messages); + M_BindIntVariable("key_menu_qload", &key_menu_qload); + M_BindIntVariable("key_menu_quit", &key_menu_quit); + M_BindIntVariable("key_menu_gamma", &key_menu_gamma); + + M_BindIntVariable("key_menu_incscreen", &key_menu_incscreen); + M_BindIntVariable("key_menu_decscreen", &key_menu_decscreen); + M_BindIntVariable("key_menu_screenshot",&key_menu_screenshot); + M_BindIntVariable("key_demo_quit", &key_demo_quit); + M_BindIntVariable("key_spy", &key_spy); } void M_BindChatControls(unsigned int num_players) @@ -378,12 +378,12 @@ void M_BindChatControls(unsigned int num_players) char name[32]; // haleyjd: 20 not large enough - Thank you, come again! unsigned int i; // haleyjd: signedness conflict - M_BindVariable("key_multi_msg", &key_multi_msg); + M_BindIntVariable("key_multi_msg", &key_multi_msg); for (i=0; i screensize // * Added nickname, comport - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &sfxVolume); - M_BindVariable("music_volume", &musicVolume); - M_BindVariable("voice_volume", &voiceVolume); - M_BindVariable("show_talk", &dialogshowtext); - M_BindVariable("screensize", &screenblocks); - M_BindVariable("snd_channels", &snd_channels); - M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); - M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); - M_BindVariable("show_endoom", &show_endoom); - M_BindVariable("back_flat", &back_flat); - M_BindVariable("graphical_startup", &graphical_startup); - - M_BindVariable("nickname", &nickname); - M_BindVariable("comport", &comport); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &sfxVolume); + M_BindIntVariable("music_volume", &musicVolume); + M_BindIntVariable("voice_volume", &voiceVolume); + M_BindIntVariable("show_talk", &dialogshowtext); + M_BindIntVariable("screensize", &screenblocks); + M_BindIntVariable("snd_channels", &snd_channels); + M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit); + M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit); + M_BindIntVariable("show_endoom", &show_endoom); + M_BindIntVariable("graphical_startup", &graphical_startup); + + M_BindStringVariable("back_flat", &back_flat); + M_BindStringVariable("nickname", &nickname); + + M_BindIntVariable("comport", &comport); // Multiplayer chat macros @@ -454,7 +455,7 @@ void D_BindVariables(void) char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); - M_BindVariable(buf, &chat_macros[i]); + M_BindStringVariable(buf, &chat_macros[i]); } } -- cgit v1.2.3 From dcf2c6a09c97c284b6cdff8c791cce8fe03fd69d Mon Sep 17 00:00:00 2001 From: James Haley Date: Fri, 20 Feb 2015 19:50:58 -0600 Subject: Warning fixes Signed/unsigned comparison mismatches --- src/i_sdlmusic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c index e70b2c05..63a3467a 100644 --- a/src/i_sdlmusic.c +++ b/src/i_sdlmusic.c @@ -422,7 +422,7 @@ static char *GetSubstituteMusicFile(void *data, size_t data_len) sha1_context_t context; sha1_digest_t hash; char *filename; - int i; + unsigned int i; // Don't bother doing a hash if we're never going to find anything. if (subst_music_len == 0) @@ -734,7 +734,8 @@ static void DumpSubstituteConfig(char *filename) char name[9]; byte *data; FILE *fs; - int lumpnum, h; + unsigned int lumpnum; + size_t h; fs = fopen(filename, "w"); -- cgit v1.2.3 From 5160ceb4512b8bb5839df898a4aff0c6779578c5 Mon Sep 17 00:00:00 2001 From: James Haley Date: Fri, 20 Feb 2015 20:01:02 -0600 Subject: Strife sound priority fix The Strife binary has another priority check in the first loop inside S_GetChannel. TODO: Does DOS Doom have this as well? Find out. Resolves issue #506. --- src/strife/s_sound.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/strife/s_sound.c b/src/strife/s_sound.c index 7a919737..d22f84e4 100644 --- a/src/strife/s_sound.c +++ b/src/strife/s_sound.c @@ -277,7 +277,7 @@ static int S_GetChannel(mobj_t *origin, sfxinfo_t *sfxinfo, boolean isvoice) channel_t* c; // Find an open channel - for (cnum=0 ; cnumpriority > channels[cnum].sfxinfo->priority) + return -1; + S_StopChannel(cnum); break; } -- cgit v1.2.3 From 01a743cd351d146e9b9ea7f7ca5b1c05e01da68e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 22 Feb 2015 00:28:23 -0500 Subject: Fix mistaken uses of memcpy() on overlapping memory. The source and destination arguments to memcpy() cannot be overlapping as this is undefined behavior. In these situations memmove() must be used instead, and OpenBSD actually throws an error if this is done. Thanks to ryan-sg for reporting this. This fixes #510. --- src/net_client.c | 4 ++-- src/net_server.c | 3 ++- src/net_structrw.c | 2 +- textscreen/txt_io.c | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/net_client.c b/src/net_client.c index e0037e3e..ac81e367 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -279,8 +279,8 @@ static void NET_CL_AdvanceWindow(void) // Advance the window - memcpy(recvwindow, recvwindow + 1, - sizeof(net_server_recv_t) * (BACKUPTICS - 1)); + memmove(recvwindow, recvwindow + 1, + sizeof(net_server_recv_t) * (BACKUPTICS - 1)); memset(&recvwindow[BACKUPTICS-1], 0, sizeof(net_server_recv_t)); ++recvwindow_start; diff --git a/src/net_server.c b/src/net_server.c index b4496bb5..b3ec1693 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -514,7 +514,8 @@ static void NET_SV_AdvanceWindow(void) // Advance the window - memcpy(recvwindow, recvwindow + 1, sizeof(*recvwindow) * (BACKUPTICS - 1)); + memmove(recvwindow, recvwindow + 1, + sizeof(*recvwindow) * (BACKUPTICS - 1)); memset(&recvwindow[BACKUPTICS-1], 0, sizeof(*recvwindow)); ++recvwindow_start; diff --git a/src/net_structrw.c b/src/net_structrw.c index 60316dc7..a820df5f 100644 --- a/src/net_structrw.c +++ b/src/net_structrw.c @@ -316,7 +316,7 @@ void NET_TiccmdDiff(ticcmd_t *tic1, ticcmd_t *tic2, net_ticdiff_t *diff) void NET_TiccmdPatch(ticcmd_t *src, net_ticdiff_t *diff, ticcmd_t *dest) { - memcpy(dest, src, sizeof(ticcmd_t)); + memmove(dest, src, sizeof(ticcmd_t)); // Apply the diff diff --git a/textscreen/txt_io.c b/textscreen/txt_io.c index ed25503c..0c5e274f 100644 --- a/textscreen/txt_io.c +++ b/textscreen/txt_io.c @@ -39,8 +39,8 @@ static void NewLine(unsigned char *screendata) cur_y = TXT_SCREEN_H - 1; - memcpy(screendata, screendata + TXT_SCREEN_W * 2, - TXT_SCREEN_W * 2 * (TXT_SCREEN_H -1)); + memmove(screendata, screendata + TXT_SCREEN_W * 2, + TXT_SCREEN_W * 2 * (TXT_SCREEN_H -1)); // Clear the bottom line -- cgit v1.2.3 From 622653dde922a486a056b63d37dc6d7d6f26f3a4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 26 Feb 2015 00:21:25 -0500 Subject: Tweak HACKING style guide. There was no example for how to write function calls. Do this to make clear that there should be no space between the function name and the open paren. Give examples of assignments and if() conditions as well, and tweak the for() style - there's no reason to omit spaces around operators for the looping conditions. --- HACKING | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/HACKING b/HACKING index 3bbe23d0..db20f963 100644 --- a/HACKING +++ b/HACKING @@ -64,11 +64,15 @@ typedef struct void FunctionName(int argument, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) { - if (condition) + int assign_var; + + assign_var = arg2 + arg3 * arg4 * (arg5 + arg6); + + if (foo && !bar || baz && qux || !(foo && bar && baz)) { body; } - else if (condition) + else if (xyz + 4 < abc * 4 + 3) { body; } @@ -97,9 +101,10 @@ void FunctionName(int argument, int arg2, int arg3, int arg4, int arg5, break; } - for (a=0; a<10; ++a) + for (a = 0; a < 10; ++a) { - loop_body; + FunctionCall(arg1, arg2, arg3, arg4, + arg_split_onto_second_line); } while (a < 10) -- cgit v1.2.3 From bfda08cf5275a70a705b3d290ca5271d40481993 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 5 Mar 2015 20:43:06 +0100 Subject: Initialize floor->type and floor->crush fields in EV_BuildStairs() The floor->type and floor->crush fields of the floor thinkers added in EV_BuildStairs() were originally left uninitialized and thus contained random memory content. Initialize them to make sure the floor->type field does not trigger propagation of random content into the special and texture fields of the adjacent sector in T_MoveFloor(). That is, make sure its value is neither donutRaise, i.e. 11, nor lowerAndChange, i.e. 6. Also, the chances of 32 bit of random memory being "true", i.e. 0, are negligible. This is functionally equivalent to what PrBoom+ is doing. Fixes desync of mm09-512.lmp. Fixes #368. --- src/doom/p_floor.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/doom/p_floor.c b/src/doom/p_floor.c index 1384ee6b..c120d616 100644 --- a/src/doom/p_floor.c +++ b/src/doom/p_floor.c @@ -493,6 +493,9 @@ EV_BuildStairs floor->speed = speed; height = sec->floorheight + stairsize; floor->floordestheight = height; + // Initialize + floor->type = lowerFloor; + floor->crush = true; texture = sec->floorpic; @@ -536,6 +539,9 @@ EV_BuildStairs floor->sector = sec; floor->speed = speed; floor->floordestheight = height; + // Initialize + floor->type = lowerFloor; + floor->crush = true; ok = 1; break; } -- cgit v1.2.3 From ad027ef6dbfeebabe0e6701eec968e9d474e497f Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Wed, 25 Mar 2015 16:06:11 -0700 Subject: man: Use \- to denote dashes. Fixes #512 --- man/docgen | 2 ++ 1 file changed, 2 insertions(+) diff --git a/man/docgen b/man/docgen index d9535be8..3b11ad8c 100755 --- a/man/docgen +++ b/man/docgen @@ -425,6 +425,8 @@ def manpage_output(targets, template_file): for t in targets: content += t.manpage_output() + "\n" + content = content.replace("-", "\\-") + print_template(template_file, content) def wiki_output(targets, template): -- cgit v1.2.3