From d299afbb2a8ab44aeba20df2f5e1f10299d590dd Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 7 Jun 2022 01:48:26 -0700 Subject: [PATCH] Use follower name in cv_follower --- src/d_netcmd.c | 20 ++++++++------------ src/m_menu.c | 12 +++++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd03e1e22..b37154a38 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5302,7 +5302,6 @@ static void Follower_OnChange(void) { char str[SKINNAMESIZE+1], cpy[SKINNAMESIZE+1]; INT32 num; - char set[10]; // This isn't Lua and mixed declarations in the middle of code make caveman compilers scream. // there is a slight chance that we will actually use a string instead so... // let's investigate the string... @@ -5327,8 +5326,8 @@ static void Follower_OnChange(void) if (num == -1) // that's an error. CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found\n"), str); - sprintf(set, "%d", num); - CV_StealthSet(&cv_follower[0], set); // set it to a number. It's easier for us to send later :) + CV_StealthSet(&cv_follower[0], str); + cv_follower[0].value = num; } if (!Playing()) @@ -5356,7 +5355,6 @@ static void Follower2_OnChange(void) { char str[SKINNAMESIZE+1], cpy[SKINNAMESIZE+1]; INT32 num; - char set[10]; // This isn't Lua and mixed declarations in the middle of code make caveman compilers scream. // there is a slight chance that we will actually use a string instead so... // let's investigate the string... @@ -5381,8 +5379,8 @@ static void Follower2_OnChange(void) if (num == -1) // that's an error. CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found\n"), str); - sprintf(set, "%d", num); - CV_StealthSet(&cv_follower[1], set); // set it to a number. It's easier for us to send later :) + CV_StealthSet(&cv_follower[1], str); + cv_follower[1].value = num; } if (!Playing()) @@ -5407,7 +5405,6 @@ static void Follower3_OnChange(void) { char str[SKINNAMESIZE+1], cpy[SKINNAMESIZE+1]; INT32 num; - char set[10]; // This isn't Lua and mixed declarations in the middle of code make caveman compilers scream. // there is a slight chance that we will actually use a string instead so... // let's investigate the string... @@ -5432,8 +5429,8 @@ static void Follower3_OnChange(void) if (num == -1) // that's an error. CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found\n"), str); - sprintf(set, "%d", num); - CV_StealthSet(&cv_follower[2], set); // set it to a number. It's easier for us to send later :) + CV_StealthSet(&cv_follower[2], str); + cv_follower[2].value = num; } if (!Playing()) @@ -5458,7 +5455,6 @@ static void Follower4_OnChange(void) { char str[SKINNAMESIZE+1], cpy[SKINNAMESIZE+1]; INT32 num; - char set[10]; // This isn't Lua and mixed declarations in the middle of code make caveman compilers scream. // there is a slight chance that we will actually use a string instead so... // let's investigate the string... @@ -5483,8 +5479,8 @@ static void Follower4_OnChange(void) if (num == -1) // that's an error. CONS_Alert(CONS_WARNING, M_GetText("Follower '%s' not found\n"), str); - sprintf(set, "%d", num); - CV_StealthSet(&cv_follower[3], set); // set it to a number. It's easier for us to send later :) + CV_StealthSet(&cv_follower[3], str); + cv_follower[3].value = num; } if (!Playing()) diff --git a/src/m_menu.c b/src/m_menu.c index dc753db68..b7299fc9b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9855,7 +9855,7 @@ static void M_SetupMultiPlayer(INT32 choice) setupm_cvname = &cv_playername[0]; setupm_cvfollower = &cv_follower[0]; - setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value + setupm_fakefollower = setupm_cvfollower->value; // yikes, we don't want none of that... if (setupm_fakefollower >= numfollowers) @@ -9898,7 +9898,7 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_cvname = &cv_playername[1]; setupm_cvfollower = &cv_follower[1]; - setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value + setupm_fakefollower = setupm_cvfollower->value; // yikes, we don't want none of that... if (setupm_fakefollower >= numfollowers) @@ -9941,7 +9941,7 @@ static void M_SetupMultiPlayer3(INT32 choice) setupm_cvname = &cv_playername[2]; setupm_cvfollower = &cv_follower[2]; - setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value + setupm_fakefollower = setupm_cvfollower->value; // yikes, we don't want none of that... if (setupm_fakefollower >= numfollowers) @@ -9984,7 +9984,7 @@ static void M_SetupMultiPlayer4(INT32 choice) setupm_cvname = &cv_playername[3]; setupm_cvfollower = &cv_follower[3]; - setupm_fakefollower = atoi(setupm_cvfollower->string); // update fake follower value + setupm_fakefollower = setupm_cvfollower->value; // yikes, we don't want none of that... if (setupm_fakefollower >= numfollowers) @@ -10014,6 +10014,8 @@ static void M_SetupMultiPlayer4(INT32 choice) static boolean M_QuitMultiPlayerMenu(void) { size_t l; + const char *followername = setupm_fakefollower == -1 ? + "None" : followers[setupm_fakefollower].skinname; // send name if changed if (strcmp(setupm_name, setupm_cvname->string)) { @@ -10026,7 +10028,7 @@ static boolean M_QuitMultiPlayerMenu(void) // you know what? always putting these in the buffer won't hurt anything. COM_BufAddText (va("%s \"%s\"\n",setupm_cvskin->name,skins[setupm_fakeskin].name)); COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor->color)); - COM_BufAddText (va("%s %d\n",setupm_cvfollower->name,setupm_fakefollower)); + COM_BufAddText (va("%s %s\n",setupm_cvfollower->name,followername)); return true; }