From 7f73f62f1f6287565be601acc3fde9735cc28928 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Sun, 11 Jan 2015 23:38:47 -0800 Subject: [PATCH] make cvar for guidebot_name, remove it from plr file --- main/config.c | 4 ++++ main/escort.c | 5 ++--- main/escort.h | 2 +- main/gamecntl.c | 3 ++- main/inferno.h | 2 ++ main/playsave.c | 19 +------------------ 6 files changed, 12 insertions(+), 23 deletions(-) diff --git a/main/config.c b/main/config.c index 995fcc45..2104c929 100644 --- a/main/config.c +++ b/main/config.c @@ -181,6 +181,7 @@ static void config_init(void) cvar_registervariable(&Config_vr_resolution); cvar_registervariable(&Config_vr_tracking); cvar_registervariable(&MovieHires); + cvar_registervariable(&real_guidebot_name); config_initialized = 1; } @@ -327,6 +328,9 @@ int ReadConfigFile() digi_set_volume( (Config_digi_volume.intval * 32768) / 8, (Config_midi_volume.intval * 128) / 8 ); + strncpy(guidebot_name, real_guidebot_name.string, GUIDEBOT_NAME_LEN); + guidebot_name[GUIDEBOT_NAME_LEN] = 0; + #if 0 printf( "DigiDeviceID: 0x%x\n", digi_driver_board ); printf( "DigiPort: 0x%x\n", digi_driver_port.intval ); diff --git a/main/escort.c b/main/escort.c index 6c09564e..5f289b78 100644 --- a/main/escort.c +++ b/main/escort.c @@ -110,7 +110,7 @@ int Last_buddy_key; fix Last_buddy_message_time; char guidebot_name[GUIDEBOT_NAME_LEN+1] = "GUIDE-BOT"; -char real_guidebot_name[GUIDEBOT_NAME_LEN+1] = "GUIDE-BOT"; +cvar_t real_guidebot_name = { "guidebot_name", "GUIDE-BOT", 1 }; void init_buddy_for_level(void) { @@ -386,8 +386,7 @@ void change_guidebot_name() if (item != -1) { strcpy(guidebot_name,text); - strcpy(real_guidebot_name,text); - write_player_file(); + cvar_set_cvar(&real_guidebot_name, text); } } diff --git a/main/escort.h b/main/escort.h index 3d0e1a25..835560f5 100644 --- a/main/escort.h +++ b/main/escort.h @@ -13,7 +13,7 @@ extern int Buddy_dude_cheat; #define GUIDEBOT_NAME_LEN 9 extern char guidebot_name[]; -extern char real_guidebot_name[]; +extern cvar_t real_guidebot_name; extern void change_guidebot_name(void); diff --git a/main/gamecntl.c b/main/gamecntl.c index f2413394..d4c03f15 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -2045,7 +2045,8 @@ void FinalCheats(int key) strcpy(guidebot_name,"Wingnut"); } else { - strcpy(guidebot_name,real_guidebot_name); + strncpy(guidebot_name, real_guidebot_name.string, GUIDEBOT_NAME_LEN); + guidebot_name[GUIDEBOT_NAME_LEN] = 0; HUD_init_message ("%s calms down",guidebot_name); } } diff --git a/main/inferno.h b/main/inferno.h index 3721d725..9a832d0f 100644 --- a/main/inferno.h +++ b/main/inferno.h @@ -21,6 +21,8 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #define _INFERNO_H #include "pstypes.h" +#include "console.h" +#include "escort.h" // MACRO for single line #ifdef WINDOWS #else DOS diff --git a/main/playsave.c b/main/playsave.c index 680f8dc9..9098a08e 100644 --- a/main/playsave.c +++ b/main/playsave.c @@ -112,7 +112,7 @@ hli highest_levels[MAX_MISSIONS]; //version 21 -> 22: save lifetime netstats //version 22 -> 23: ?? //version 23 -> 24: add name of joystick for windows version. -//version 24 -> 25: removed kconfig data +//version 24 -> 25: removed kconfig data, joy name, guidebot name #define COMPATIBLE_PLAYER_FILE_VERSION 17 @@ -247,12 +247,6 @@ RetrySelection: extern int Guided_in_big_window,Automap_always_hires; -//this length must match the value in escort.c -#define GUIDEBOT_NAME_LEN 9 -extern char guidebot_name[]; -extern char real_guidebot_name[]; - - uint32_t legacy_display_mode[] = { SM(320,200), SM(640,480), SM(320,400), SM(640,400), SM(800,600), SM(1024,768), SM(1280,1024) }; //read in the player's saved games. returns errno (0 == no error) @@ -450,14 +444,6 @@ int read_player_file() #endif } - //read guidebot name - if (player_file_version >= 18) - PHYSFSX_readString(file, guidebot_name); - else - strcpy(guidebot_name,"GUIDE-BOT"); - - strcpy(real_guidebot_name,guidebot_name); - if (!PHYSFS_close(file)) goto read_player_file_failed; @@ -638,9 +624,6 @@ int write_player_file() PHYSFS_writeULE32(file, i); } - //write guidebot name - PHYSFSX_writeString(file, real_guidebot_name); - if (!PHYSFS_close(file)) goto write_player_file_failed; -- 2.39.2