From 9f1c40f8812e7e66215d41ae4129d45a5fca3381 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 11 Nov 2018 08:19:44 -0500 Subject: [PATCH 1/2] G_CopyControls and G_GetControlScheme adjustment (take input list of gc's to check) --- src/g_input.c | 38 ++++++++++++++++++++++---------------- src/g_input.h | 7 +++++-- src/m_misc.c | 10 ++++++++-- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index b1511fcd9..77239621c 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -47,6 +47,14 @@ INT32 gamecontrol[num_gamecontrols][2]; INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention +// lists of GC codes for selective operation +INT32 gcmovement[num_gcmovement] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight, + gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview, + gc_jump, gc_use + // , gc_fire, gc_firenormal +}; + typedef struct { UINT8 time; @@ -673,25 +681,21 @@ void G_DefineDefaultControls(void) } } -INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly) +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen) { INT32 i, j, gc; boolean skipscheme; - gamecontrols_e movement[] = { - gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview, - gc_jump, gc_use - // , gc_fire, gc_firenormal - }; - for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) { skipscheme = false; - for (j = 0; j < (movementonly ? sizeof(movement) : num_gamecontrols); j++) + for (j = 0; j < (gclist && gclen ? gclen : num_gamecontrols); j++) { - gc = (movementonly) ? movement[j] : j; - if (fromcontrols[gc][0] != gamecontroldefault[i][gc][0] && fromcontrols[gc][1] != gamecontroldefault[i][gc][1]) + gc = (gclist && gclen) ? gclist[j] : j; + if (((fromcontrols[gc][0] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][0] : true) && + ((fromcontrols[gc][0] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][1] : true) && + ((fromcontrols[gc][1] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][0] : true) && + ((fromcontrols[gc][1] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][1] : true)) { skipscheme = true; break; @@ -704,13 +708,15 @@ INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly) return gcs_custom; } -void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2]) +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen) { - INT32 i; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, gc; + + for (i = 0; i < (gclist && gclen ? gclen : num_gamecontrols); i++) { - setupcontrols[i][0] = fromcontrols[i][0]; - setupcontrols[i][1] = fromcontrols[i][1]; + gc = (gclist && gclen) ? gclist[i] : i; + setupcontrols[gc][0] = fromcontrols[gc][0]; + setupcontrols[gc][1] = fromcontrols[gc][1]; } } diff --git a/src/g_input.h b/src/g_input.h index af52bbd65..f8989fc6c 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -128,6 +128,9 @@ extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) +#define num_gcmovement 11 // 13 +extern INT32 gcmovement[num_gcmovement]; + // peace to my little coder fingers! // check a gamecontrol being active or not @@ -143,8 +146,8 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); void Command_Setcontrol_f(void); void Command_Setcontrol2_f(void); void G_DefineDefaultControls(void); -INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], boolean movementonly); -void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2]); +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen); +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen); void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]); void G_CheckDoubleUsage(INT32 keynum); diff --git a/src/m_misc.c b/src/m_misc.c index 8211239ef..cc9ae2999 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -476,7 +476,7 @@ void M_FirstLoadConfig(void) // load default control G_DefineDefaultControls(); - G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps]); + G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], NULL, 0); // load config, make sure those commands doesnt require the screen... COM_BufInsertText(va("exec \"%s\"\n", configfile)); @@ -540,7 +540,13 @@ void M_SaveConfig(const char *filename) // FIXME: save key aliases if ever implemented.. CV_SaveVariables(f); - if (!dedicated) G_SaveKeySetting(f, gamecontrol, gamecontrolbis); + if (!dedicated) + { + if (tutorialmode) + G_SaveKeySetting(f, gamecontroldefault[gcs_custom], gamecontrolbis); // using gcs_custom as temp storage + else + G_SaveKeySetting(f, gamecontrol, gamecontrolbis); + } fclose(f); } From 3f72e1bacf9e3f87c2471e7df4838d6ee6f68ee3 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Sun, 11 Nov 2018 08:44:08 -0500 Subject: [PATCH 2/2] New gclists and const modifier; added tutorialmode declarations to this branch --- src/doomstat.h | 3 +++ src/g_game.c | 3 +++ src/g_input.c | 24 ++++++++++++++++++------ src/g_input.h | 17 +++++++++++++---- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 7678c86b7..421b6579f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -129,6 +129,9 @@ extern INT16 titlemap; extern boolean hidetitlepics; extern INT16 bootmap; //bootmap for loading a map on startup +extern INT16 tutorialmap; // map to load for tutorial +extern boolean tutorialmode; // are we in a tutorial right now? + extern boolean looptitle; // CTF colors. diff --git a/src/g_game.c b/src/g_game.c index 0a392fa85..38289bcb2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -127,6 +127,9 @@ INT16 titlemap = 0; boolean hidetitlepics = false; INT16 bootmap; //bootmap for loading a map on startup +INT16 tutorialmap = 0; // map to load for tutorial +boolean tutorialmode = false; // are we in a tutorial right now? + boolean looptitle = false; UINT8 skincolor_redteam = SKINCOLOR_RED; diff --git a/src/g_input.c b/src/g_input.c index 77239621c..1e3b83b56 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -48,13 +48,25 @@ INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention // lists of GC codes for selective operation -INT32 gcmovement[num_gcmovement] = { +const INT32 gclist_tutorial[num_gclist_tutorial] = { gc_forward, gc_backward, gc_strafeleft, gc_straferight, - gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview, - gc_jump, gc_use - // , gc_fire, gc_firenormal + gc_lookup, gc_lookdown, gc_turnleft, gc_turnright//, gc_centerview, + //gc_jump, gc_use, + //gc_fire, gc_firenormal }; +const INT32 gclist_movement[num_gclist_movement] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight +}; + +const INT32 gclist_camera[num_gclist_camera] = { + gc_lookup, gc_lookdown, gc_turnleft, gc_turnright +}; + +const INT32 gclist_jump[num_gclist_jump] = { gc_jump }; + +const INT32 gclist_use[num_gclist_use] = { gc_use }; + typedef struct { UINT8 time; @@ -681,7 +693,7 @@ void G_DefineDefaultControls(void) } } -INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen) +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen) { INT32 i, j, gc; boolean skipscheme; @@ -708,7 +720,7 @@ INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen) return gcs_custom; } -void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen) +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen) { INT32 i, gc; diff --git a/src/g_input.h b/src/g_input.h index f8989fc6c..a70ff9104 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -128,8 +128,17 @@ extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) -#define num_gcmovement 11 // 13 -extern INT32 gcmovement[num_gcmovement]; +#define num_gclist_tutorial 8 // 13 +#define num_gclist_movement 4 +#define num_gclist_camera 4 +#define num_gclist_jump 1 +#define num_gclist_use 1 + +extern const INT32 gclist_tutorial[num_gclist_tutorial]; +extern const INT32 gclist_movement[num_gclist_movement]; +extern const INT32 gclist_camera[num_gclist_camera]; +extern const INT32 gclist_jump[num_gclist_jump]; +extern const INT32 gclist_use[num_gclist_use]; // peace to my little coder fingers! // check a gamecontrol being active or not @@ -146,8 +155,8 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); void Command_Setcontrol_f(void); void Command_Setcontrol2_f(void); void G_DefineDefaultControls(void); -INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen); -void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], INT32 gclist[], INT32 gclen); +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]); void G_CheckDoubleUsage(INT32 keynum);