shithub: choc

Download patch

ref: 28e726147ae63442a5aeb99724b41d4ba7f0df3e
parent: 9ea4b024c233201bf72ded262550f6da0d1566e3
parent: 3bd1270c4861b9a139275d088021c28d13e09216
author: Simon Howard <[email protected]>
date: Fri Aug 17 20:48:19 EDT 2018

Merge pull request #1075 from turol/const

More const correctness

--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -69,7 +69,7 @@
 typedef struct
 {
     ItemType_t type;
-    char *text;
+    const char *text;
     boolean(*func) (int option);
     int option;
     MenuType_t menu;
@@ -459,7 +459,7 @@
 //
 //---------------------------------------------------------------------------
 
-char *QuitEndMsg[] = {
+const char *QuitEndMsg[] = {
     "ARE YOU SURE YOU WANT TO QUIT?",
     "ARE YOU SURE YOU WANT TO END THE GAME?",
     "DO YOU WANT TO QUICKSAVE THE GAME NAMED",
--- a/src/heretic/p_spec.c
+++ b/src/heretic/p_spec.c
@@ -193,7 +193,7 @@
 int *TerrainTypes;
 struct
 {
-    char *name;
+    const char *name;
     int type;
 } TerrainTypeDefs[] =
 {
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -2042,9 +2042,9 @@
 ===================
 */
 
-char *defdemoname;
+static const char *defdemoname;
 
-void G_DeferedPlayDemo(char *name)
+void G_DeferedPlayDemo(const char *name)
 {
     defdemoname = name;
     gameaction = ga_playdemo;
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -764,7 +764,7 @@
 
 void G_DeferredNewGame(skill_t skill);
 
-void G_DeferedPlayDemo(char *demo);
+void G_DeferedPlayDemo(const char *demo);
 
 void G_LoadGame(int slot);
 // can be called by the startup code or M_Responder
@@ -807,7 +807,7 @@
 
 extern char *SavePath;
 
-void SV_SaveGame(int slot, char *description);
+void SV_SaveGame(int slot, const char *description);
 void SV_SaveMap(boolean savePlayers);
 void SV_LoadGame(int slot);
 void SV_MapTeleport(int map, int position);
@@ -885,10 +885,10 @@
 void R_SetViewSize(int blocks, int detail);
 // called by M_Responder
 
-int R_FlatNumForName(char *name);
+int R_FlatNumForName(const char *name);
 
-int R_TextureNumForName(char *name);
-int R_CheckTextureNumForName(char *name);
+int R_TextureNumForName(const char *name);
+int R_CheckTextureNumForName(const char *name);
 // called by P_Ticker for switches and animations
 // returns the texture number for the texture name
 
@@ -904,9 +904,9 @@
 // SC_man.c
 //------------------------------
 
-void SC_Open(char *name);
-void SC_OpenLump(char *name);
-void SC_OpenFile(char *name);
+void SC_Open(const char *name);
+void SC_OpenLump(const char *name);
+void SC_OpenFile(const char *name);
 void SC_Close(void);
 boolean SC_GetString(void);
 void SC_MustGetString(void);
@@ -915,10 +915,10 @@
 void SC_MustGetNumber(void);
 void SC_UnGet(void);
 //boolean SC_Check(void);
-boolean SC_Compare(char *text);
-int SC_MatchString(char **strings);
-int SC_MustMatchString(char **strings);
-void SC_ScriptError(char *message);
+boolean SC_Compare(const char *text);
+int SC_MatchString(const char **strings);
+int SC_MustMatchString(const char **strings);
+void SC_ScriptError(const char *message);
 
 extern char *sc_String;
 extern int sc_Number;
@@ -1059,11 +1059,11 @@
 boolean MN_Responder(event_t * event);
 void MN_Ticker(void);
 void MN_Drawer(void);
-void MN_DrTextA(char *text, int x, int y);
-void MN_DrTextAYellow(char *text, int x, int y);
-int MN_TextAWidth(char *text);
-void MN_DrTextB(char *text, int x, int y);
-int MN_TextBWidth(char *text);
+void MN_DrTextA(const char *text, int x, int y);
+void MN_DrTextAYellow(const char *text, int x, int y);
+int MN_TextAWidth(const char *text);
+void MN_DrTextB(const char *text, int x, int y);
+int MN_TextBWidth(const char *text);
 
 extern int messageson;
 
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -68,7 +68,7 @@
 typedef struct
 {
     ItemType_t type;
-    char *text;
+    const char *text;
     void (*func) (int option);
     int option;
     MenuType_t menu;
@@ -294,7 +294,7 @@
     &SaveMenu
 };
 
-static char *GammaText[] = {
+static const char *GammaText[] = {
     TXT_GAMMA_LEVEL_OFF,
     TXT_GAMMA_LEVEL_1,
     TXT_GAMMA_LEVEL_2,
@@ -339,7 +339,7 @@
 //
 //---------------------------------------------------------------------------
 
-void MN_DrTextA(char *text, int x, int y)
+void MN_DrTextA(const char *text, int x, int y)
 {
     char c;
     patch_t *p;
@@ -365,7 +365,7 @@
 //
 //==========================================================================
 
-void MN_DrTextAYellow(char *text, int x, int y)
+void MN_DrTextAYellow(const char *text, int x, int y)
 {
     char c;
     patch_t *p;
@@ -393,7 +393,7 @@
 //
 //---------------------------------------------------------------------------
 
-int MN_TextAWidth(char *text)
+int MN_TextAWidth(const char *text)
 {
     char c;
     int width;
@@ -423,7 +423,7 @@
 //
 //---------------------------------------------------------------------------
 
-void MN_DrTextB(char *text, int x, int y)
+void MN_DrTextB(const char *text, int x, int y)
 {
     char c;
     patch_t *p;
@@ -451,7 +451,7 @@
 //
 //---------------------------------------------------------------------------
 
-int MN_TextBWidth(char *text)
+int MN_TextBWidth(const char *text)
 {
     char c;
     int width;
@@ -494,7 +494,7 @@
 //
 //---------------------------------------------------------------------------
 
-char *QuitEndMsg[] = {
+const char *QuitEndMsg[] = {
     "ARE YOU SURE YOU WANT TO QUIT?",
     "ARE YOU SURE YOU WANT TO END THE GAME?",
     "DO YOU WANT TO QUICKSAVE THE GAME NAMED",
@@ -508,7 +508,7 @@
     int x;
     int y;
     MenuItem_t *item;
-    char *selName;
+    const char *selName;
 
     if (MenuActive == false)
     {
@@ -596,12 +596,12 @@
 static void DrawClassMenu(void)
 {
     pclass_t class;
-    static char *boxLumpName[3] = {
+    static const char *boxLumpName[3] = {
         "m_fbox",
         "m_cbox",
         "m_mbox"
     };
-    static char *walkLumpName[3] = {
+    static const char *walkLumpName[3] = {
         "m_fwalk1",
         "m_cwalk1",
         "m_mwalk1"
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -310,7 +310,7 @@
 //
 //==========================================================================
 
-static void ACSAssert(int condition, char *fmt, ...)
+static void ACSAssert(int condition, const char *fmt, ...)
 {
     char buf[128];
     va_list args;
--- a/src/hexen/p_inter.c
+++ b/src/hexen/p_inter.c
@@ -63,7 +63,7 @@
 //
 //--------------------------------------------------------------------------
 
-void P_SetMessage(player_t * player, char *message, boolean ultmsg)
+void P_SetMessage(player_t * player, const char *message, boolean ultmsg)
 {
     if ((player->ultimateMessage || !messageson) && !ultmsg)
     {
@@ -90,7 +90,7 @@
 //
 //==========================================================================
 
-void P_SetYellowMessage(player_t * player, char *message, boolean ultmsg)
+void P_SetYellowMessage(player_t * player, const char *message, boolean ultmsg)
 {
     if ((player->ultimateMessage || !messageson) && !ultmsg)
     {
--- a/src/hexen/p_local.h
+++ b/src/hexen/p_local.h
@@ -278,8 +278,8 @@
 
 extern int clipmana[NUMMANA];
 
-void P_SetMessage(player_t * player, char *message, boolean ultmsg);
-void P_SetYellowMessage(player_t * player, char *message, boolean ultmsg);
+void P_SetMessage(player_t * player, const char *message, boolean ultmsg);
+void P_SetYellowMessage(player_t * player, const char *message, boolean ultmsg);
 void P_ClearMessage(player_t * player);
 void P_TouchSpecialThing(mobj_t * special, mobj_t * toucher);
 void P_DamageMobj(mobj_t * target, mobj_t * inflictor, mobj_t * source,
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -113,7 +113,7 @@
 // PRIVATE DATA DEFINITIONS ------------------------------------------------
 
 static mapInfo_t MapInfo[99];
-static char *MapCmdNames[] = {
+static const char *MapCmdNames[] = {
     "SKY1",
     "SKY2",
     "DOUBLESKY",
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -527,7 +527,7 @@
 ================
 */
 
-int R_FlatNumForName(char *name)
+int R_FlatNumForName(const char *name)
 {
     int i;
     char namet[9];
@@ -551,7 +551,7 @@
 ================
 */
 
-int R_CheckTextureNumForName(char *name)
+int R_CheckTextureNumForName(const char *name)
 {
     int i;
 
@@ -574,7 +574,7 @@
 ================
 */
 
-int R_TextureNumForName(char *name)
+int R_TextureNumForName(const char *name)
 {
     int i;
     //char  namet[9];
--- a/src/hexen/sc_man.c
+++ b/src/hexen/sc_man.c
@@ -40,7 +40,7 @@
 // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
 
 static void CheckOpen(void);
-static void OpenScript(char *name, int type);
+static void OpenScript(const char *name, int type);
 
 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
 
@@ -74,7 +74,7 @@
 //
 //==========================================================================
 
-void SC_Open(char *name)
+void SC_Open(const char *name)
 {
     char fileName[128];
 
@@ -97,7 +97,7 @@
 //
 //==========================================================================
 
-void SC_OpenLump(char *name)
+void SC_OpenLump(const char *name)
 {
     OpenScript(name, LUMP_SCRIPT);
 }
@@ -111,7 +111,7 @@
 //
 //==========================================================================
 
-void SC_OpenFile(char *name)
+void SC_OpenFile(const char *name)
 {
     OpenScript(name, FILE_ZONE_SCRIPT);
 }
@@ -122,7 +122,7 @@
 //
 //==========================================================================
 
-static void OpenScript(char *name, int type)
+static void OpenScript(const char *name, int type)
 {
     SC_Close();
     if (type == LUMP_SCRIPT)
@@ -393,7 +393,7 @@
 //
 //==========================================================================
 
-int SC_MatchString(char **strings)
+int SC_MatchString(const char **strings)
 {
     int i;
 
@@ -413,7 +413,7 @@
 //
 //==========================================================================
 
-int SC_MustMatchString(char **strings)
+int SC_MustMatchString(const char **strings)
 {
     int i;
 
@@ -431,7 +431,7 @@
 //
 //==========================================================================
 
-boolean SC_Compare(char *text)
+boolean SC_Compare(const char *text)
 {
     if (strcasecmp(text, sc_String) == 0)
     {
@@ -446,7 +446,7 @@
 //
 //==========================================================================
 
-void SC_ScriptError(char *message)
+void SC_ScriptError(const char *message)
 {
     if (message == NULL)
     {
--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -128,7 +128,7 @@
 static uint16_t SV_ReadWord(void);
 static uint32_t SV_ReadLong(void);
 static void *SV_ReadPtr(void);
-static void SV_Write(void *buffer, int size);
+static void SV_Write(const void *buffer, int size);
 static void SV_WriteByte(byte val);
 static void SV_WriteWord(unsigned short val);
 static void SV_WriteLong(unsigned int val);
@@ -1922,7 +1922,7 @@
 //
 //==========================================================================
 
-void SV_SaveGame(int slot, char *description)
+void SV_SaveGame(int slot, const char *description)
 {
     char fileName[100];
     char versionText[HXS_VERSION_TEXT_LENGTH];
@@ -3422,7 +3422,7 @@
 //
 //==========================================================================
 
-static void SV_Write(void *buffer, int size)
+static void SV_Write(const void *buffer, int size)
 {
     fwrite(buffer, size, 1, SavingFP);
 }