- refactored wchoice and sensitivity CVARS

This is all that's needed for now, the remaining ones can wait.
This commit is contained in:
Christoph Oelckers 2019-10-23 17:21:14 +02:00
parent 18430c6c9f
commit 02fff2df06
17 changed files with 59 additions and 303 deletions

View file

@ -346,9 +346,6 @@ void CONFIG_SetDefaults(void)
memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions));
memset(JoystickFunctions, -1, sizeof(JoystickFunctions));
memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions));
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
for (int i=0; i<MAXMOUSEBUTTONS; i++)
{
MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);

View file

@ -1450,7 +1450,7 @@ void SetMessages(CGameMenuItemZBool *pItem)
void SetMouseSensitivity(CGameMenuItemSliderFloat *pItem)
{
CONTROL_MouseSensitivity = pItem->fValue;
in_mousesensitivity = pItem->fValue;
}
void SetMouseAimFlipped(CGameMenuItemZBool *pItem)

View file

@ -790,13 +790,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
videoSetPalette(gBrightness>>2,gLastPal,0);
}
#if 0
else if (!Bstrcasecmp(parm->name, "skill"))
{
if (numplayers > 1)
return r;
ud.player_skill = ud.m_player_skill;
}
else if (!Bstrcasecmp(parm->name, "color"))
{
ud.color = G_CheckPlayerColor(ud.color);
@ -809,54 +802,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
if (xdim && ydim)
OSD_ResizeDisplay(xdim, ydim);
}
else if (!Bstrcasecmp(parm->name, "wchoice"))
{
if (parm->numparms == 1)
{
if (g_forceWeaponChoice) // rewrite ud.wchoice because osdcmd_cvar_set already changed it
{
int j = 0;
while (j < 10)
{
ud.wchoice[j] = g_player[myconnectindex].wchoice[j] + '0';
j++;
}
ud.wchoice[j] = 0;
}
else
{
char const *c = parm->parms[0];
if (*c)
{
int j = 0;
while (*c && j < 10)
{
g_player[myconnectindex].wchoice[j] = *c - '0';
c++;
j++;
}
while (j < 10)
{
if (j == 9)
g_player[myconnectindex].wchoice[9] = 1;
else
g_player[myconnectindex].wchoice[j] = 2;
j++;
}
}
}
g_forceWeaponChoice = 0;
}
/* Net_SendClientInfo();*/
}
#endif
return r;

View file

@ -4,6 +4,7 @@
#include "baselayer.h"
#include "gameconfigfile.h"
#include "control.h"
#include "_control.h"
/* Notes
@ -257,6 +258,14 @@ CUSTOM_CVARD(Bool, in_mousesmoothing, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE, "en
CONTROL_SmoothMouse = self;
}
CUSTOM_CVARD(Float, in_mousesensitivity, DEFAULTMOUSESENSITIVITY, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "changes the mouse sensitivity")
{
if (self < 0) self = 0;
else if (self > 25) self = 25;
else CONTROL_MouseSensitivity = self;
}
CUSTOM_CVARD(Int, r_drawweapon, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable weapon drawing")
{
if (self < 0 || self > 2) self = 1;
@ -323,19 +332,48 @@ int G_FPSLimit(void)
return 0;
}
CUSTOM_CVARD(String, wchoice, "3457860291", CVAR_ARCHIVE|CVAR_NOINITCALL|CVAR_FRONTEND_DUKELIKE, "sets weapon autoselection order")
{
char dest[11];
char const *c = self;
if (*c)
{
int j = 0;
while (*c && j < 10)
{
dest[j] = *c - '0';
c++;
j++;
}
while (j < 10)
{
if (j == 9)
dest[9] = 1;
else
dest[j] = 2;
j++;
}
// if (!gi->SetWeaponChoice(dest)) OSD_Printf("Weapon ordering not supported\n");
}
else
{
OSD_Printf("Using default weapon orders.\n");
self = "3457860291";
}
#if 0
// DN3D
static osdcvardata_t cvars_game[] =
{
{ "sensitivity","changes the mouse sensitivity", (void *)&CONTROL_MouseSensitivity, CVAR_FLOAT|CVAR_FUNCPTR, 0, 25 },
{ "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR|CVAR_NOSAVE/*|CVAR_NOMULTI*/, 0, 5 },
{ "team","change team in multiplayer", (void *)&ud.team, CVAR_INT|CVAR_MULTI, 0, 3 },
{ "wchoice","sets weapon autoselection order", (void *)ud.wchoice, CVAR_STRING|CVAR_FUNCPTR, 0, MAX_WEAPONS },
};
// These I don't care about.
@ -369,5 +407,9 @@ int G_FPSLimit(void)
// This option is not really useful anymore
{ "r_camrefreshdelay", "minimum delay between security camera sprite updates, 120 = 1 second", (void *)&ud.camera_time, CVAR_INT, 1, 240 },
*/
// This requires a different approach, because it got used like a CCMD, not a CVAR.
{ "skill","changes the game skill setting", (void *)&ud.m_player_skill, CVAR_INT|CVAR_FUNCPTR|CVAR_NOSAVE/*|CVAR_NOMULTI*/, 0, 5 },
// requires cleanup first
//{ "team","change team in multiplayer", (void *)&ud.team, CVAR_INT|CVAR_MULTI, 0, 3 },
#endif

View file

@ -73,8 +73,10 @@ EXTERN_CVAR(Int, in_mousedeadzone)
EXTERN_CVAR(Bool, in_mouseflip)
EXTERN_CVAR(Bool, in_mousemode)
EXTERN_CVAR(Bool, in_mousesmoothing)
EXTERN_CVAR(Float, in_mousesensitivity)
extern int32_t g_MyAimMode;
EXTERN_CVAR(Bool, in_mousemode)
EXTERN_CVAR(String, wchoice)
extern float r_ambientlightrecip;
extern int hud_statusbarrange; // will be set by the game's configuration setup.

View file

@ -37,7 +37,6 @@ int32_t g_noSound = 0;
int32_t g_noMusic = 0;
const char *CommandMap = NULL;
const char *CommandName = NULL;
int32_t g_forceWeaponChoice = 0;
int32_t g_fakeMultiMode = 0;
void G_ShowParameterHelp(void)
@ -169,17 +168,8 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
ud.cashman = 0;
ud.m_ffire = 1;
ud.m_player_skill = ud.player_skill = 2;
g_player[0].wchoice[0] = 3;
g_player[0].wchoice[1] = 4;
g_player[0].wchoice[2] = 5;
g_player[0].wchoice[3] = 7;
g_player[0].wchoice[4] = 8;
g_player[0].wchoice[5] = 6;
g_player[0].wchoice[6] = 0;
g_player[0].wchoice[7] = 2;
g_player[0].wchoice[8] = 9;
g_player[0].wchoice[9] = 1;
Bsprintf(ud.wchoice, "3457860291");
memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
wchoice.Callback();
#ifdef HAVE_CLIPSHAPE_FEATURE
// pre-form the default 10 clipmaps
@ -687,52 +677,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
initprintf("Respawn on.\n");
break;
case 'u':
g_forceWeaponChoice = 1;
c++;
j = 0;
if (*c)
{
initprintf("Using favorite weapon order(s).\n");
while (*c)
{
g_player[0].wchoice[j] = *c-'0';
ud.wchoice[j] = *c;
c++;
j++;
}
while (j < 10)
{
if (j == 9)
{
g_player[0].wchoice[9] = 1;
ud.wchoice[9] = '1';
}
else
{
g_player[0].wchoice[j] = 2;
ud.wchoice[j] = '2';
}
j++;
}
}
else
{
initprintf("Using default weapon orders.\n");
g_player[0].wchoice[0] = 3;
g_player[0].wchoice[1] = 4;
g_player[0].wchoice[2] = 5;
g_player[0].wchoice[3] = 7;
g_player[0].wchoice[4] = 8;
g_player[0].wchoice[5] = 6;
g_player[0].wchoice[6] = 0;
g_player[0].wchoice[7] = 2;
g_player[0].wchoice[8] = 9;
g_player[0].wchoice[9] = 1;
Bsprintf(ud.wchoice, "3457860291");
}
break;
case 'v':
c++;

View file

@ -39,7 +39,6 @@ extern int32_t g_noSound;
extern int32_t g_noMusic;
extern const char *CommandMap;
extern const char *CommandName;
extern int32_t g_forceWeaponChoice;
extern int32_t g_fakeMultiMode;
END_DUKE_NS

View file

@ -295,8 +295,6 @@ void CONFIG_SetDefaults(void)
memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
memset(ud.config.JoystickDigitalFunctions, -1, sizeof(ud.config.JoystickDigitalFunctions));
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
for (int i=0; i<MAXMOUSEBUTTONS; i++)
{
ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);

View file

@ -251,7 +251,6 @@ typedef struct {
char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
char display_bonus_screen;
char show_level_text;
char wchoice[MAX_WEAPONS];
uint8_t user_map;
uint8_t screenfade, menubackground;

View file

@ -1455,13 +1455,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
{
videoSetPalette(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
else if (!Bstrcasecmp(parm->name, "skill"))
{
if (numplayers > 1)
return r;
ud.player_skill = ud.m_player_skill;
}
else if (!Bstrcasecmp(parm->name, "color"))
{
ud.color = G_CheckPlayerColor(ud.color);
@ -1474,54 +1467,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
if (xdim && ydim)
OSD_ResizeDisplay(xdim, ydim);
}
else if (!Bstrcasecmp(parm->name, "wchoice"))
{
if (parm->numparms == 1)
{
if (g_forceWeaponChoice) // rewrite ud.wchoice because osdcmd_cvar_set already changed it
{
int j = 0;
while (j < 10)
{
ud.wchoice[j] = g_player[myconnectindex].wchoice[j] + '0';
j++;
}
ud.wchoice[j] = 0;
}
else
{
char const *c = parm->parms[0];
if (*c)
{
int j = 0;
while (*c && j < 10)
{
g_player[myconnectindex].wchoice[j] = *c - '0';
c++;
j++;
}
while (j < 10)
{
if (j == 9)
g_player[myconnectindex].wchoice[9] = 1;
else
g_player[myconnectindex].wchoice[j] = 2;
j++;
}
}
}
g_forceWeaponChoice = 0;
}
/* Net_SendClientInfo();*/
}
return r;
}

View file

@ -37,7 +37,6 @@ int32_t g_noSound = 0;
int32_t g_noMusic = 0;
const char *CommandMap = NULL;
const char *CommandName = NULL;
int32_t g_forceWeaponChoice = 0;
int32_t g_fakeMultiMode = 0;
void G_ShowParameterHelp(void)
@ -160,17 +159,9 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
ud.warp_on = 0;
ud.cashman = 0;
ud.m_player_skill = ud.player_skill = 2;
g_player[0].wchoice[0] = 3;
g_player[0].wchoice[1] = 4;
g_player[0].wchoice[2] = 5;
g_player[0].wchoice[3] = 7;
g_player[0].wchoice[4] = 8;
g_player[0].wchoice[5] = 6;
g_player[0].wchoice[6] = 0;
g_player[0].wchoice[7] = 2;
g_player[0].wchoice[8] = 9;
g_player[0].wchoice[9] = 1;
Bsprintf(ud.wchoice, "3457860291");
memcpy(g_player[0].wchoice, "\3\4\5\7\0x8\6\0\2\0x9\1", 10);
wchoice.Callback();
#ifdef HAVE_CLIPSHAPE_FEATURE
// pre-form the default 10 clipmaps
@ -664,52 +655,6 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
initprintf("Respawn on.\n");
break;
case 'u':
g_forceWeaponChoice = 1;
c++;
j = 0;
if (*c)
{
initprintf("Using favorite weapon order(s).\n");
while (*c)
{
g_player[0].wchoice[j] = *c-'0';
ud.wchoice[j] = *c;
c++;
j++;
}
while (j < 10)
{
if (j == 9)
{
g_player[0].wchoice[9] = 1;
ud.wchoice[9] = '1';
}
else
{
g_player[0].wchoice[j] = 2;
ud.wchoice[j] = '2';
}
j++;
}
}
else
{
initprintf("Using default weapon orders.\n");
g_player[0].wchoice[0] = 3;
g_player[0].wchoice[1] = 4;
g_player[0].wchoice[2] = 5;
g_player[0].wchoice[3] = 7;
g_player[0].wchoice[4] = 8;
g_player[0].wchoice[5] = 6;
g_player[0].wchoice[6] = 0;
g_player[0].wchoice[7] = 2;
g_player[0].wchoice[8] = 9;
g_player[0].wchoice[9] = 1;
Bsprintf(ud.wchoice, "3457860291");
}
break;
case 'v':
c++;

View file

@ -38,7 +38,6 @@ extern int32_t g_noSound;
extern int32_t g_noMusic;
extern const char *CommandMap;
extern const char *CommandName;
extern int32_t g_forceWeaponChoice;
extern int32_t g_fakeMultiMode;
END_RR_NS

View file

@ -337,8 +337,6 @@ void CONFIG_SetDefaults(void)
ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
}
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
memset(ud.config.JoystickFunctions, -1, sizeof(ud.config.JoystickFunctions));
for (i=0; i<MAXJOYBUTTONSANDHATS; i++)
{
@ -467,7 +465,7 @@ void CONFIG_SetupMouse(void)
{
tempbuf[0] = 0;
SCRIPT_GetString(ud.config.scripthandle, "Controls","Mouse_Sensitivity",&tempbuf[0]);
if (tempbuf[0]) CONTROL_MouseSensitivity = atof(tempbuf);
if (tempbuf[0]) in_mousesensitivity = atof(tempbuf);
}
for (i=0; i<MAXMOUSEBUTTONS; i++)

View file

@ -225,7 +225,6 @@ typedef struct {
char pwlockout[MAXPWLOCKOUT],rtsname[MAXRTSNAME];
char display_bonus_screen;
char show_level_text;
char wchoice[MAX_WEAPONS];
uint8_t user_map;
uint8_t screenfade, menubackground;

View file

@ -1242,13 +1242,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
{
videoSetPalette(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
else if (!Bstrcasecmp(parm->name, "skill"))
{
if (numplayers > 1)
return r;
ud.player_skill = ud.m_player_skill;
}
else if (!Bstrcasecmp(parm->name, "color"))
{
ud.color = G_CheckPlayerColor(ud.color);
@ -1261,55 +1254,6 @@ static int osdcmd_cvar_set_game(osdcmdptr_t parm)
if (xdim && ydim)
OSD_ResizeDisplay(xdim, ydim);
}
else if (!Bstrcasecmp(parm->name, "wchoice"))
{
if (parm->numparms == 1)
{
if (g_forceWeaponChoice) // rewrite ud.wchoice because osdcmd_cvar_set already changed it
{
int j = 0;
while (j < 10)
{
ud.wchoice[j] = g_player[myconnectindex].wchoice[j] + '0';
j++;
}
ud.wchoice[j] = 0;
}
else
{
char const *c = parm->parms[0];
if (*c)
{
int j = 0;
while (*c && j < 10)
{
g_player[myconnectindex].wchoice[j] = *c - '0';
c++;
j++;
}
while (j < 10)
{
if (j == 9)
g_player[myconnectindex].wchoice[9] = 1;
else
g_player[myconnectindex].wchoice[j] = 2;
j++;
}
}
}
g_forceWeaponChoice = 0;
}
/* Net_SendClientInfo();*/
}
return r;
}

View file

@ -255,7 +255,7 @@ void CONFIG_SetDefaults(void)
MouseAnalogAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]);
}
CONTROL_MouseSensitivity = float(gs.MouseSpeed); // [JM] Temporary !CHECKME!
in_mousesensitivity = float(gs.MouseSpeed); // [JM] Temporary !CHECKME!
memset(JoystickButtons, -1, sizeof(JoystickButtons));
memset(JoystickButtonsClicked, -1, sizeof(JoystickButtonsClicked));
@ -476,7 +476,7 @@ void CONFIG_SetupMouse(void)
CONTROL_SetAnalogAxisScale(i, MouseAnalogScale[i], controldevice_mouse);
}
CONTROL_MouseSensitivity = float(gs.MouseSpeed); // [JM] Temporary !CHECKME!
in_mousesensitivity = float(gs.MouseSpeed); // [JM] Temporary !CHECKME!
}
/*

View file

@ -3615,7 +3615,7 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw)
slidersettings[sldr_mouse] = offset;
gs.MouseSpeed = offset * (MOUSE_SENS_MAX_VALUE/SLDR_MOUSESENSEMAX);
CONTROL_MouseSensitivity = float(gs.MouseSpeed); // [JM] Will need to verify this. !CHECKME!
in_mousesensitivity = float(gs.MouseSpeed); // [JM] Will need to verify this. !CHECKME!
break;
case sldr_sndfxvolume: