From 61446c099551beff30300d1ad99d6c6ebbdece1e Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Mon, 8 Apr 2019 06:25:22 +0000 Subject: [PATCH] SW: Fix const correctness issues. Patch from Striker. git-svn-id: https://svn.eduke32.com/eduke32@7499 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/sw/src/_functio.h | 28 +++++++++++++------------- source/sw/src/anim.cpp | 2 +- source/sw/src/bldscript.cpp | 6 +++--- source/sw/src/brooms.cpp | 4 ++-- source/sw/src/cheats.cpp | 8 ++++---- source/sw/src/config.cpp | 4 ++-- source/sw/src/console.cpp | 2 +- source/sw/src/function.h | 2 +- source/sw/src/game.cpp | 16 +++++++-------- source/sw/src/game.h | 40 ++++++++++++++++++------------------- source/sw/src/inv.h | 2 +- source/sw/src/jbhlp.cpp | 4 ++-- source/sw/src/jnstub.cpp | 16 +++++++-------- source/sw/src/jplayer.cpp | 7 ++++--- source/sw/src/menus.cpp | 34 +++++++++++++++---------------- source/sw/src/menus.h | 4 ++-- source/sw/src/network.cpp | 2 +- source/sw/src/network.h | 2 +- source/sw/src/panel.cpp | 4 ++-- source/sw/src/parse.h | 2 +- source/sw/src/player.cpp | 2 +- source/sw/src/rooms.cpp | 2 +- source/sw/src/scrip2.cpp | 12 +++++------ source/sw/src/sounds.cpp | 8 ++++---- source/sw/src/sprite.cpp | 4 ++-- source/sw/src/sprite.h | 2 +- source/sw/src/sync.cpp | 2 +- source/sw/src/text.cpp | 2 +- source/sw/src/weapon.cpp | 2 +- 29 files changed, 113 insertions(+), 112 deletions(-) diff --git a/source/sw/src/_functio.h b/source/sw/src/_functio.h index 3b83a3efa..2a7efe775 100644 --- a/source/sw/src/_functio.h +++ b/source/sw/src/_functio.h @@ -34,7 +34,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #ifndef function_private_ #define function_private_ -char *gamefunctions[] = +const char *gamefunctions[] = { "Move_Forward", "Move_Backward", @@ -91,7 +91,7 @@ char *gamefunctions[] = #define NUMKEYENTRIES 50 -static char *keydefaults[] = +static const char *keydefaults[] = { "Move_Forward", "Up", "Kpad8", "Move_Backward", "Down", "Kpad2", @@ -145,7 +145,7 @@ static char *keydefaults[] = "Show_Console", "NumLck", "", }; -static char *keydefaults_modern[] = +static const char *keydefaults_modern[] = { "Move_Forward", "W", "", "Move_Backward", "S", "", @@ -200,7 +200,7 @@ static char *keydefaults_modern[] = }; -static char *mousedefaults[] = +static const char *mousedefaults[] = { "Fire", "Strafe", @@ -209,7 +209,7 @@ static char *mousedefaults[] = "" }; -static char *mousedefaults_modern[] = +static const char *mousedefaults_modern[] = { "Fire", "Open", @@ -220,7 +220,7 @@ static char *mousedefaults_modern[] = }; -static char *mouseclickeddefaults[] = +static const char *mouseclickeddefaults[] = { "", "Open", @@ -229,7 +229,7 @@ static char *mouseclickeddefaults[] = "" }; -static char *mouseclickeddefaults_modern[] = +static const char *mouseclickeddefaults_modern[] = { "", "", @@ -240,7 +240,7 @@ static char *mouseclickeddefaults_modern[] = }; -static char *joystickdefaults[] = +static const char *joystickdefaults[] = { "Fire", "Strafe", @@ -281,7 +281,7 @@ static char *joystickdefaults[] = }; -static char *joystickclickeddefaults[] = +static const char *joystickclickeddefaults[] = { "", "Inventory", @@ -322,14 +322,14 @@ static char *joystickclickeddefaults[] = }; -static char *mouseanalogdefaults[] = +static const char *mouseanalogdefaults[] = { "analog_turning", "analog_moving", }; -static char *mousedigitaldefaults[] = +static const char *mousedigitaldefaults[] = { "", "", @@ -339,7 +339,7 @@ static char *mousedigitaldefaults[] = #if 0 -static char *gamepaddigitaldefaults[] = +static const char *gamepaddigitaldefaults[] = { "Turn_Left", "Turn_Right", @@ -349,7 +349,7 @@ static char *gamepaddigitaldefaults[] = #endif -static char *joystickanalogdefaults[] = +static const char *joystickanalogdefaults[] = { "analog_turning", "analog_moving", @@ -362,7 +362,7 @@ static char *joystickanalogdefaults[] = }; -static char *joystickdigitaldefaults[] = +static const char *joystickdigitaldefaults[] = { "", "", diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index 3ee89acb6..be3df4aa2 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -54,7 +54,7 @@ unsigned char ANIMpal[3*256]; unsigned char ANIMnum = 0; short SoundState; -char *ANIMname[] = +const char *ANIMname[] = { "sw.anm", "swend.anm", diff --git a/source/sw/src/bldscript.cpp b/source/sw/src/bldscript.cpp index 6eb46d91b..1674de753 100644 --- a/source/sw/src/bldscript.cpp +++ b/source/sw/src/bldscript.cpp @@ -48,7 +48,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms ============================================================================= */ -void Error(char *error, ...) +void Error(const char *error, ...) { va_list argptr; @@ -84,7 +84,7 @@ SWBOOL tokenready; // only TRUE if UnGetToken was just ca ============== */ -SWBOOL LoadScriptFile(char *filename) +SWBOOL LoadScriptFile(const char *filename) { int size, readsize; int fp; @@ -396,7 +396,7 @@ extern int nextvoxid; // 1804 1 shotgun.kvx // etc.... -void LoadKVXFromScript(char *filename) +void LoadKVXFromScript(const char *filename) { int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being // replaced. diff --git a/source/sw/src/brooms.cpp b/source/sw/src/brooms.cpp index 7ebea19e7..57974eabb 100644 --- a/source/sw/src/brooms.cpp +++ b/source/sw/src/brooms.cpp @@ -39,11 +39,11 @@ extern int qsetmode; SWBOOL FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum); SWBOOL FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum); short ViewSectorInScene(short cursectnum, short type, short level); -void Message(char *string, char color); +void Message(const char *string, char color); void -_Assert(char *expr, char *strFile, unsigned uLine) +_Assert(const char *expr, const char *strFile, unsigned uLine) { printf(ds, "Assertion failed: %s %s, line %u\n", expr, strFile, uLine); //DSPRINTF(ds, "Assertion failed: %s %s, line %u", expr, strFile, uLine); diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp index a87193cbf..231c864f0 100644 --- a/source/sw/src/cheats.cpp +++ b/source/sw/src/cheats.cpp @@ -261,10 +261,10 @@ void BlackburnFunc(PLAYERp pp, char *UNUSED(cheat_string)) PlayerSound(DIGI_TAUNTAI3,&pp->posx,&pp->posy,&pp->posz,v3df_dontpan|v3df_doppler|v3df_follow,pp); } -int cheatcmp(char *str1, char *str2, int len) +int cheatcmp(const char *str1, const char *str2, int len) { - char *cp1 = str1; - char *cp2 = str2; + const char *cp1 = str1; + const char *cp2 = str2; do { @@ -288,7 +288,7 @@ int cheatcmp(char *str1, char *str2, int len) typedef struct { - char *CheatInputCode; + const char *CheatInputCode; void (*CheatInputFunc)(PLAYERp, char *); char flags; } CHEAT_INFO, *CHEAT_INFOp; diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp index 07c543230..cfd8c2ad2 100644 --- a/source/sw/src/config.cpp +++ b/source/sw/src/config.cpp @@ -269,7 +269,7 @@ void CONFIG_SetDefaults(void) void SetDefaultKeyDefinitions(int style) { int numkeydefaults; - char **keydefaultset; + const char **keydefaultset; int i, f, k1, k2; if (style) @@ -301,7 +301,7 @@ void SetDefaultKeyDefinitions(int style) void SetMouseDefaults(int style) { int nummousedefaults; - char **mousedefaultset, **mouseclickeddefaultset; + const char **mousedefaultset, **mouseclickeddefaultset; int i; if (style) diff --git a/source/sw/src/console.cpp b/source/sw/src/console.cpp index b5732f27a..b81476633 100644 --- a/source/sw/src/console.cpp +++ b/source/sw/src/console.cpp @@ -1163,7 +1163,7 @@ void CON_LoadSetup(void) CON_ConMessage("JonoF: Maybe later"); } -char *damagename[] = +const char *damagename[] = { "WPN_STAR","WPN_UZI", "WPN_SHOTGUN","WPN_MICRO", diff --git a/source/sw/src/function.h b/source/sw/src/function.h index 1ee57a2a8..c43ede065 100644 --- a/source/sw/src/function.h +++ b/source/sw/src/function.h @@ -37,7 +37,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #define NUMGAMEFUNCTIONS 51 -extern char *gamefunctions[]; +extern const char *gamefunctions[]; enum { diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 404309394..ed69d3122 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -691,7 +691,7 @@ TerminateGame(void) } void -LoadLevel(char *filename) +LoadLevel(const char *filename) { int pos; @@ -712,7 +712,7 @@ LoadLevel(char *filename) } void -LoadImages(char *filename) +LoadImages(const char *filename) { short ndx; FILE *fin; @@ -2905,7 +2905,7 @@ Control(int32_t argc, char const * const * argv) void -_Assert(char *expr, char *strFile, unsigned uLine) +_Assert(const char *expr, const char *strFile, unsigned uLine) { sprintf(ds, "Assertion failed: %s %s, line %u", expr, strFile, uLine); MONO_PRINT(ds); @@ -2920,7 +2920,7 @@ _Assert(char *expr, char *strFile, unsigned uLine) void -_ErrMsg(char *strFile, unsigned uLine, char *format, ...) +_ErrMsg(const char *strFile, unsigned uLine, const char *format, ...) { va_list arglist; @@ -2960,7 +2960,7 @@ dsprintf(char *str, char *format, ...) } void -dsprintf_null(char *str, char *format, ...) +dsprintf_null(char *str, const char *format, ...) { va_list arglist; } @@ -3262,10 +3262,10 @@ void AlphaMessage(void) typedef struct { char notshareware; - char *arg_switch; + const char *arg_switch; short arg_match_len; - char *arg_fmt; - char *arg_descr; + const char *arg_fmt; + const char *arg_descr; } CLI_ARG; #if DEBUG diff --git a/source/sw/src/game.h b/source/sw/src/game.h index c0fb188b3..274a0b09f 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -56,7 +56,7 @@ extern char isShareware, useDarts; void HeapCheck(char *, int); #define HEAP_CHECK() HeapCheck(__FILE__, __LINE__) -void _Assert(char *, char *, unsigned); +void _Assert(const char *expr, const char *strFile, unsigned uLine); #define ASSERT(f) \ if (f) \ do { } while(0); \ @@ -74,7 +74,7 @@ void PokeStringMono(uint8_t Attr, uint8_t* String); extern int DispMono; #define MONO_PRINT(str) if (DispMono) PokeStringMono(/*MDA_NORMAL*/ 0, str) #else -void adduserquote(char *daquote); +void adduserquote(const char *daquote); extern int DispMono; #define MONO_PRINT(str) if (DispMono) CON_ConMessage(str); // Put it in my userquote stuff! //#define MONO_PRINT(str) if (DispMono) printf(str); @@ -85,14 +85,14 @@ extern int DispMono; #define ASSERT(f) do { } while(0) #define MONO_PRINT(str) -void _Assert(char *, char *, unsigned); +void _Assert(const char *expr, const char *strFile, unsigned uLine); #define PRODUCTION_ASSERT(f) \ if (f) \ do { } while(0); \ else \ _Assert(#f,ERR_STD_ARG); -void dsprintf_null(char *, char *, ...); +void dsprintf_null(char *str, const char *format, ...); #define DSPRINTF dsprintf_null //#define DSPRINTF() @@ -855,7 +855,7 @@ extern char con_quote[MAXCONQUOTES][256]; int minitext(int x,int y,char *t,char p,char sb); int minitextshade(int x,int y,char *t,char s,char p,char sb); void operatefta(void); -void adduserquote(char *daquote); +void adduserquote(const char *daquote); void operateconfta(void); void addconquote(char *daquote); @@ -898,8 +898,8 @@ typedef struct int16_t max_ammo; int16_t min_ammo; int16_t with_weapon; - char *weapon_name; - char *ammo_name; + const char *weapon_name; + const char *ammo_name; int16_t weapon_pickup; int16_t ammo_pickup; } DAMAGE_DATA, *DAMAGE_DATAp; @@ -958,11 +958,11 @@ typedef struct typedef struct { - char *LevelName; - char *SongName; - char *Description; - char *BestTime; - char *ParTime; + const char *LevelName; + const char *SongName; + const char *Description; + const char *BestTime; + const char *ParTime; } LEVEL_INFO, *LEVEL_INFOp, * *LEVEL_INFOpp; extern LEVEL_INFO LevelInfo[MAX_LEVELS_REG+2]; @@ -977,11 +977,11 @@ extern char EpisodeSubtitles[2][MAX_EPISODE_SUBTITLE_LEN+1]; extern char SkillNames[4][MAX_SKILL_NAME_LEN+2]; #define MAX_FORTUNES 16 -extern char *ReadFortune[MAX_FORTUNES]; +extern const char *ReadFortune[MAX_FORTUNES]; #define MAX_KEYS 8 -extern char *KeyMsg[MAX_KEYS]; -extern char *KeyDoorMessage[MAX_KEYS]; +extern const char *KeyMsg[MAX_KEYS]; +extern const char *KeyDoorMessage[MAX_KEYS]; typedef struct { @@ -2275,7 +2275,7 @@ extern unsigned char palette_data[256][3]; extern SWBOOL NightVision; #endif -int _PlayerSound(char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp); +int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp); #define PlayerSound(num, x, y, z, flags, pp) _PlayerSound(__FILE__, __LINE__, (num), (x), (y), (z), (flags), (pp)) #define MAXSO (MAXLONG) @@ -2321,7 +2321,7 @@ void post_analyzesprites(void); // draw.c int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c void ScreenCaptureKeys(void); // draw.c -int minigametext(int x,int y,char *t,char s,short dabits); // jplayer.c +int minigametext(int x,int y,const char *t,char s,short dabits); // jplayer.c void computergetinput(int snum,SW_PACKET *syn); // jplayer.c void DrawOverlapRoom(int tx,int ty,int tz,short tang,int thoriz,short tsectnum); // rooms.c @@ -2333,9 +2333,9 @@ void TermSetup(void); // swconfig.c void InitSetup(void); // setup.c -void LoadKVXFromScript(char *filename); // scrip2.c -void LoadPLockFromScript(char *filename); // scrip2.c -void LoadCustomInfoFromScript(char *filename); // scrip2.c +void LoadKVXFromScript(const char *filename); // scrip2.c +void LoadPLockFromScript(const char *filename); // scrip2.c +void LoadCustomInfoFromScript(const char *filename); // scrip2.c void EveryCheatToggle(PLAYERp pp,char *cheat_string); // cheats.c diff --git a/source/sw/src/inv.h b/source/sw/src/inv.h index f12c8193b..3d35b2d8a 100644 --- a/source/sw/src/inv.h +++ b/source/sw/src/inv.h @@ -38,7 +38,7 @@ enum InventoryNames typedef struct { - char *Name; + const char *Name; void (*Init)(PLAYERp); void (*Stop)(PLAYERp, short); PANEL_STATEp State; diff --git a/source/sw/src/jbhlp.cpp b/source/sw/src/jbhlp.cpp index 3551aac32..42c79e58f 100644 --- a/source/sw/src/jbhlp.cpp +++ b/source/sw/src/jbhlp.cpp @@ -46,7 +46,7 @@ static char tempbuf[256]; // Prototypes -void Message(char *string, char color); +void Message(const char *string, char color); long GetAToken(char *name, char *tc, long length); uint8_t* BKeyPressed(void); void ResetKeys(void); @@ -54,7 +54,7 @@ void ResetKeys(void); // Functions -void Msg(char *string, char color) +void Msg(const char *string, char color) { clearmidstatbar16(); diff --git a/source/sw/src/jnstub.cpp b/source/sw/src/jnstub.cpp index 5af5a668d..02b118846 100644 --- a/source/sw/src/jnstub.cpp +++ b/source/sw/src/jnstub.cpp @@ -84,7 +84,7 @@ short FindSpriteNum = 0; // My Function Prototypes void ContextHelp(short spritenum); -void LoadKVXFromScript(char *filename); +void LoadKVXFromScript(const char *filename); //void LogUserTime( SWBOOL bIsLoggingIn ); @@ -112,7 +112,7 @@ typedef struct STAG_INFO StagInfo[MAX_STAG_INFO]; -void PrintStatus(char *string, int num, char x, char y, char color); +void PrintStatus(const char *string, int num, char x, char y, char color); #define NUMOPTIONS 8 char option[NUMOPTIONS] = {0, 0, 0, 0, 0, 0, 1, 0}; @@ -159,7 +159,7 @@ void SectorMoveFloorZ(int); void SectorMoveCeilingZ(int); void BuildStagTable(void); -void Message(char *string, char color); +void Message(const char *string, char color); void ShowMessage(void); void ShadeMenu(void); void FindNextTag(void); @@ -647,7 +647,7 @@ ExtInit(void) #endif -char *startwin_labeltext = "Starting Build Editor for Shadow Warrior..."; +const char *startwin_labeltext = "Starting Build Editor for Shadow Warrior..."; int ExtInit(void) @@ -1360,7 +1360,7 @@ Keys3D(void) // Used to help print out the item status list void -PrintStatus(char *string, int num, char x, char y, char color) +PrintStatus(const char *string, int num, char x, char y, char color) { sprintf(tempbuf, "%s %d", string, num); printext16(x * 8, ydim16+y * 8, color, -1, tempbuf, 0); @@ -2280,7 +2280,7 @@ const char * ExtGetSpriteCaption(short spritenum) { SPRITEp sp = &sprite[spritenum]; - char *p = ""; + const char *p = ""; char name[64]; char tp[30]; char multi_str[30] = ""; @@ -3668,7 +3668,7 @@ static unsigned short messagedelay = 0; static char messagebuf[1024]; void -Message(char *string, char color) +Message(const char *string, char color) { sprintf(messagebuf, string, 0); messagedelay = 512; @@ -3728,7 +3728,7 @@ dsprintf(char *str, char *format, ...) } void -dsprintf_null(char *str, char *format, ...) +dsprintf_null(char *str, const char *format, ...) { va_list arglist; } diff --git a/source/sw/src/jplayer.cpp b/source/sw/src/jplayer.cpp index 101b5eb75..d781d9d3a 100644 --- a/source/sw/src/jplayer.cpp +++ b/source/sw/src/jplayer.cpp @@ -122,10 +122,11 @@ int gametext(int x,int y,char *t,char s,short dabits) return x; } -int minigametext(int x,int y,char *t,char s,short dabits) +int minigametext(int x,int y,const char *t,char s,short dabits) { short ac,newx; - char centre, *oldt; + char centre; + const char *oldt; centre = (x == (320>>1)); newx = 0; @@ -215,7 +216,7 @@ int quotebot, quotebotgoal; short user_quote_time[MAXUSERQUOTES]; char user_quote[MAXUSERQUOTES][256]; -void adduserquote(char *daquote) +void adduserquote(const char *daquote) { int i; diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index ffb1285d6..107450ee5 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -539,7 +539,7 @@ MenuGroup *menuarray[MaxLayers], *currentmenu; SWBOOL UsingMenus = FALSE; #define MAXDIALOG 2 // Maximum number of dialog strings allowed -char *dialog[MAXDIALOG]; +const char *dialog[MAXDIALOG]; // Global menu setting values //////////////////////////////////////////////////////////////////// // Mouse slider vars @@ -564,7 +564,7 @@ MenuItem_p cust_callback_item; static void MNU_ClearDialog(void); static SWBOOL MNU_Dialog(void); -void LoadSaveMsg(char *msg); +void LoadSaveMsg(const char *msg); static void MNU_ItemPreProcess(MenuGroup *group); static void MNU_SelectItem(MenuGroup *group, short index, SWBOOL draw); static void MNU_PushItem(MenuItem *item, SWBOOL draw); @@ -611,7 +611,7 @@ MNU_DoParentalPassword(UserCall call, MenuItem_p item) signed char MNU_InputString(char *, short); static SWBOOL cur_show; char TempString[80]; - char *extra_text; + const char *extra_text; extra_text = "This mode should remove most of the"; @@ -776,7 +776,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) { short w, h = 0; - char *s = "Keys Setup"; + const char *s = "Keys Setup"; rotatesprite(10 << 16, (5-3) << 16, MZ, 0, 2427, m_defshade, 0, MenuDrawFlags|ROTATE_SPRITE_CORNER, 0, 0, xdim - 1, ydim - 1); MNU_MeasureStringLarge(s, &w, &h); @@ -786,8 +786,8 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) if (currentmode) { // customising a key - char *strs[] = { "Press the key to assign to", "\"%s\" %s", "or ESCAPE to cancel." }; - char *col[2] = { "(primary)", "(secondary)" }; + const char *strs[] = { "Press the key to assign to", "\"%s\" %s", "or ESCAPE to cancel." }; + const char *col[2] = { "(primary)", "(secondary)" }; short w, h = 8; int i, j, y; @@ -836,7 +836,7 @@ SWBOOL MNU_KeySetupCustom(UserCall call, MenuItem *item) #define PGSIZ 14 int topitem = 0, botitem = NUMGAMEFUNCTIONS; int i,j; - char *morestr = "More..."; + const char *morestr = "More..."; const char *p; UserInput inpt = {FALSE,FALSE,dir_None}; @@ -1764,8 +1764,8 @@ MNU_OrderCustom(UserCall call, MenuItem *item) { // Jonathon's credits page hack :-) - static char *jtitle = "^Port Credits"; - static char *jtext[] = + static const char *jtitle = "^Port Credits"; + static const char *jtext[] = { "*GAME AND ENGINE PORT", " Jonathon \"JonoF\" Fowler", @@ -1777,7 +1777,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item) " Visit http://www.jonof.id.au/jfsw for the", " source code, latest news, and updates of this port." }; - static char *scroller[] = + static const char *scroller[] = { "This program is free software; you can redistribute it", "and/or modify it under the terms of the GNU General", @@ -2695,7 +2695,7 @@ MNU_InputString(char *name, short pix_width) #define SS_YSTART SD_YSTART #define SS_BORDER_SIZE 5L -void LoadSaveMsg(char *msg) +void LoadSaveMsg(const char *msg) { short w,h; @@ -3058,7 +3058,7 @@ MNU_CheckUserMap(MenuItem *item) SWBOOL MNU_ShareWareMessage(MenuItem *item) { - char *extra_text; + const char *extra_text; short w,h; if (SW_SHAREWARE) @@ -3340,7 +3340,7 @@ MNU_DoButton(MenuItem_p item, SWBOOL draw) int last_value; short shade = MENU_SHADE_DEFAULT; extern char LevelSong[]; - char *extra_text = NULL; + const char *extra_text = NULL; PLAYERp pp = &Player[myconnectindex]; int button_x,zero=0; int handle=0; @@ -3606,9 +3606,9 @@ MNU_DoButton(MenuItem_p item, SWBOOL draw) } //char *gametype[] = {"War [Respawn]","Cooperative","War [No Respawn]"}; -char *gametype[] = {"WangBang (spawn)","WangBang (no spawn)","Cooperative"}; -char *playercolors[] = {"Brown","Gray","Purple","Red","Yellow","Olive","Green","Blue"}; -char *monsterskills[] = {"No Monsters","Easy","Normal","Hard","Insane!"}; +const char *gametype[] = {"WangBang (spawn)","WangBang (no spawn)","Cooperative"}; +const char *playercolors[] = {"Brown","Gray","Purple","Red","Yellow","Olive","Green","Blue"}; +const char *monsterskills[] = {"No Monsters","Easy","Normal","Hard","Insane!"}; void MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) @@ -3616,7 +3616,7 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) short offset, i, barwidth; int x, y, knobx; short shade = MENU_SHADE_DEFAULT; - char *extra_text=NULL; + const char *extra_text=NULL; char tmp_text[256]; memset(tmp_text,0,256); diff --git a/source/sw/src/menus.h b/source/sw/src/menus.h index c7d9638c1..268683b6c 100644 --- a/source/sw/src/menus.h +++ b/source/sw/src/menus.h @@ -252,7 +252,7 @@ typedef struct MENU_ITEM SLDRType slider; // Slider type, if any BTNType button; // Button state, if any unsigned char hotkey; // First letter of item - char *text; // Text appearing in item, if any. + const char *text; // Text appearing in item, if any. void *child; // Should be menugroup, used to spawn // sub-groups from items. int x, y; // x,y position on screen. @@ -268,7 +268,7 @@ typedef struct MENU_ITEM typedef struct { int x, y; // Menu x,y position on screen. - char *text; + const char *text; MenuItem_p items; // Array of menu items for this menu. short titlepic; // Used to draw title on menu with. short cursorpic; // Pic used for menu cursor, 1st in diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index 095c98162..9d8f3a876 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -434,7 +434,7 @@ ResumeAction(void) } void -SW_SendMessage(short pnum, char *text) +SW_SendMessage(short pnum, const char *text) { if (!CommEnabled) return; diff --git a/source/sw/src/network.h b/source/sw/src/network.h index d9c3ecb85..ec90d3e97 100644 --- a/source/sw/src/network.h +++ b/source/sw/src/network.h @@ -200,7 +200,7 @@ SWBOOL MenuCommPlayerQuit(short quit_player); void SendVersion(int version); void InitNetPlayerOptions(void); void CheckVersion(int GameVersion); -void SW_SendMessage(short pnum,char *text); +void SW_SendMessage(short pnum,const char *text); void PauseGame(void); void ResumeGame(void); diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index 4cedcc019..98e21df0e 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -486,8 +486,8 @@ PlayerUpdateWeaponSummary(PLAYERp pp, short UpdateWeaponNum) #define WSUM_YOFF 6 static short wsum_xoff[3] = {0,36,66}; - static char *wsum_fmt1[3] = {"%d:", "%d:", "%d:"}; - static char *wsum_fmt2[3] = {"%3d/%-3d", "%2d/%-2d", "%2d/%-2d"}; + static const char *wsum_fmt1[3] = {"%d:", "%d:", "%d:"}; + static const char *wsum_fmt2[3] = {"%3d/%-3d", "%2d/%-2d", "%2d/%-2d"}; static short wsum_back_pic[3] = {2405, 2406, 2406}; if (Prediction) diff --git a/source/sw/src/parse.h b/source/sw/src/parse.h index ec3b430c8..36846ce7f 100644 --- a/source/sw/src/parse.h +++ b/source/sw/src/parse.h @@ -35,7 +35,7 @@ extern int scriptline; extern SWBOOL endofscript; -SWBOOL LoadScriptFile(char *filename); +SWBOOL LoadScriptFile(const char *filename); void GetToken(SWBOOL crossline); void UnGetToken(void); SWBOOL TokenAvailable(void); diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index b4a0fd5a9..9463d75bf 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -6374,7 +6374,7 @@ DoPlayerDeathFall(PLAYERp pp) } #define MAX_SUICIDE 11 -char *SuicideNote[MAX_SUICIDE] = +const char *SuicideNote[MAX_SUICIDE] = { "decided to do the graveyard tour.", "had enough and checked out.", diff --git a/source/sw/src/rooms.cpp b/source/sw/src/rooms.cpp index 2601a051f..1f1016ce8 100644 --- a/source/sw/src/rooms.cpp +++ b/source/sw/src/rooms.cpp @@ -30,7 +30,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "game.h" #include "warp.h" -void _ErrMsg(char *strFile, unsigned uLine, char *format, ...); +void _ErrMsg(const char *strFile, unsigned uLine, const char *format, ...); void FAF_DrawRooms(int posx, int posy, int posz, short ang, int horiz, short cursectnum); //////////////////////////////////////////////////////////////////// diff --git a/source/sw/src/scrip2.cpp b/source/sw/src/scrip2.cpp index faf1beab2..1b35cca3e 100644 --- a/source/sw/src/scrip2.cpp +++ b/source/sw/src/scrip2.cpp @@ -70,7 +70,7 @@ SWBOOL tokenready; // only TRUE if UnGetToken was just ca ============== */ -SWBOOL LoadScriptFile(char *filename) +SWBOOL LoadScriptFile(const char *filename) { int size, readsize; int fp; @@ -261,7 +261,7 @@ SWBOOL TokenAvailable(void) // 1804 1 shotgun.kvx // etc.... -void LoadKVXFromScript(char *filename) +void LoadKVXFromScript(const char *filename) { int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being // replaced. @@ -328,7 +328,7 @@ void LoadKVXFromScript(char *filename) // Ex. 1803 -1 -1 = No tile replacement // 1804 2000 // etc.... -void LoadPLockFromScript(char *filename) +void LoadPLockFromScript(const char *filename) { int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being // replaced. @@ -405,7 +405,7 @@ enum static const struct _tokset { - char *str; + const char *str; int tokn; } cm_tokens[] = { @@ -546,7 +546,7 @@ static char *customweaponname[2][MAX_WEAPONS]; // weapon, ammo #define WM_AMMO 4 static struct { - char *sym; + const char *sym; int dmgid; int editable; } weaponmap[] = @@ -568,7 +568,7 @@ static struct }; // FIXME: yes, we are leaking memory here at the end of the program by not freeing anything -void LoadCustomInfoFromScript(char *filename) +void LoadCustomInfoFromScript(const char *filename) { scriptfile *script; char *token; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 6f6663990..904ce39a1 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -88,17 +88,17 @@ SWBOOL LoadSong(const char *track); #define NUM_SAMPLES 10 -char *BitNames[2] = +const char *BitNames[2] = { "8-bit", "16-bit" }; -char *ChannelNames[2] = +const char *ChannelNames[2] = { "Mono", "Stereo" }; -char *VoiceNames[8] = +const char *VoiceNames[8] = { "1", "2", "3", "4", "5", "6", "7", "8" }; @@ -662,7 +662,7 @@ SoundAngle(int x, int y) return delta_angle >> 6; } -int _PlayerSound(char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp) +int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp) //PlayerSound(int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp) { int handle; diff --git a/source/sw/src/sprite.cpp b/source/sw/src/sprite.cpp index c1561d896..7a0032052 100644 --- a/source/sw/src/sprite.cpp +++ b/source/sw/src/sprite.cpp @@ -5495,7 +5495,7 @@ void ChoosePlayerGetSound(PLAYERp pp) //#define MAX_FORTUNES 16 // With PLOCK on, max = 11 -char *ReadFortune[MAX_FORTUNES] = +const char *ReadFortune[MAX_FORTUNES] = { "You never going to score.", "26-31-43-82-16-29", @@ -5551,7 +5551,7 @@ SWBOOL CanGetWeapon(PLAYERp pp, short SpriteNum, int WPN) return TRUE; } -char *KeyMsg[MAX_KEYS] = +const char *KeyMsg[MAX_KEYS] = { "Got the RED key!", "Got the BLUE key!", diff --git a/source/sw/src/sprite.h b/source/sw/src/sprite.h index 30e6976c1..ca69c3349 100644 --- a/source/sw/src/sprite.h +++ b/source/sw/src/sprite.h @@ -75,7 +75,7 @@ enum struct InventoryDecl_t { - char *name; + const char *name; int amount; }; extern struct InventoryDecl_t InventoryDecls[InvDecl_TOTAL]; diff --git a/source/sw/src/sync.cpp b/source/sw/src/sync.cpp index 24dd043e2..63b2b7e66 100644 --- a/source/sw/src/sync.cpp +++ b/source/sw/src/sync.cpp @@ -277,7 +277,7 @@ RandomSync(void) #define STAT_SKIP4_END 8 */ -char *SyncNames[] = +const char *SyncNames[] = { "RandomSync", "PlayerSync", diff --git a/source/sw/src/text.cpp b/source/sw/src/text.cpp index 2b75a2900..ef61d5a3b 100644 --- a/source/sw/src/text.cpp +++ b/source/sw/src/text.cpp @@ -46,7 +46,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #define PANEL_SM_FONT_Y 3613 #define PANEL_SM_FONT_R 3625 -char *KeyDoorMessage[MAX_KEYS] = +const char *KeyDoorMessage[MAX_KEYS] = { "You need a RED key for this door.", "You need a BLUE key for this door.", diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index f8d687478..cf6ffc309 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -7444,7 +7444,7 @@ DoDamage(short SpriteNum, short Weapon) #if 1 // Select death text based on ID -char *DeathString(short SpriteNum) +const char *DeathString(short SpriteNum) { USERp ku = User[SpriteNum];