shithub: choc

Download patch

ref: 5ed7e666f29800043e15f7b301dd665e9c40fd39
parent: 1f7fa57972cee8eb5a8939919f4eedfadae03aac
parent: 5bed7c7ab75eb0192fa89d66e70c7f8428c763e2
author: Simon Howard <fraggle+github@gmail.com>
date: Fri May 11 19:33:08 EDT 2018

Merge pull request #1033 from turol/const

Const correctness

--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -269,9 +269,9 @@
 ===============================================================================
 */
 
-int demosequence;
-int pagetic;
-char *pagename;
+static int demosequence;
+static int pagetic;
+static const char *pagename;
 
 
 /*
@@ -488,7 +488,7 @@
 
 static int startup_line = STARTUP_WINDOW_Y;
 
-void hprintf(char *string)
+void hprintf(const char *string)
 {
     if (using_graphical_startup)
     {
@@ -521,7 +521,7 @@
     }
 }
 
-void status(char *string)
+static void status(const char *string)
 {
     if (using_graphical_startup)
     {
@@ -611,7 +611,7 @@
 }
 
 char tmsg[300];
-void tprintf(char *msg, int initflag)
+void tprintf(const char *msg, int initflag)
 {
     printf("%s", msg);
 }
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -453,7 +453,7 @@
     int refire;                 // refired shots are less accurate
 
     int killcount, itemcount, secretcount;      // for intermission
-    char *message;              // hint messages
+    const char *message;        // hint messages
     int messageTics;            // counter for showing messages
     int damagecount, bonuscount;        // for screen flashing
     int flamecount;             // for flame thrower duration
@@ -588,7 +588,7 @@
 void D_DoomMain(void);
 void IncThermo(void);
 void InitThermo(int max);
-void tprintf(char *string, int initflag);
+void tprintf(const char *string, int initflag);
 // not a globally visible function, just included for source reference
 // calls all startup code
 // parses command line options
@@ -651,7 +651,7 @@
 // can be called by the startup code or M_Responder
 // a normal game starts at map 1, but a warp test can start elsewhere
 
-void G_DeferedPlayDemo(char *demo);
+void G_DeferedPlayDemo(const char *demo);
 
 void G_LoadGame(char *name);
 // can be called by the startup code or M_Responder
@@ -753,8 +753,8 @@
 
 int R_FlatNumForName(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
 
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -24,16 +24,16 @@
 #include "s_sound.h"
 #include "v_video.h"
 
-int finalestage;                // 0 = text, 1 = art screen
-int finalecount;
+static int finalestage;                // 0 = text, 1 = art screen
+static int finalecount;
 
 #define TEXTSPEED       3
 #define TEXTWAIT        250
 
-char *finaletext;
-char *finaleflat;
+static const char *finaletext;
+static const char *finaleflat;
 
-int FontABaseLump;
+static int FontABaseLump;
 
 extern boolean automapactive;
 extern boolean viewactive;
@@ -156,7 +156,7 @@
     byte *src, *dest;
     int x, y;
     int count;
-    char *ch;
+    const char *ch;
     int c;
     int cx, cy;
     patch_t *w;
@@ -298,7 +298,7 @@
 {
     static boolean underwawa = false;
     extern boolean askforquit;
-    char *lumpname;
+    const char *lumpname;
     byte *palette;
 
     // The underwater screen has its own palette, which is rather annoying.
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -1869,9 +1869,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/heretic/p_inter.c
+++ b/src/heretic/p_inter.c
@@ -121,7 +121,7 @@
 
 boolean ultimatemsg;
 
-void P_SetMessage(player_t * player, char *message, boolean ultmsg)
+void P_SetMessage(player_t * player, const char *message, boolean ultmsg)
 {
     extern boolean messageson;
 
--- a/src/heretic/p_local.h
+++ b/src/heretic/p_local.h
@@ -252,7 +252,7 @@
 extern int maxammo[NUMAMMO];
 extern int clipammo[NUMAMMO];
 
-void P_SetMessage(player_t * player, char *message, boolean ultmsg);
+void P_SetMessage(player_t * player, const char *message, boolean ultmsg);
 void P_TouchSpecialThing(mobj_t * special, mobj_t * toucher);
 void P_DamageMobj(mobj_t * target, mobj_t * inflictor, mobj_t * source,
                   int damage);
--- a/src/heretic/p_saveg.c
+++ b/src/heretic/p_saveg.c
@@ -121,7 +121,7 @@
     SV_Write(&val, sizeof(int));
 }
 
-void SV_WritePtr(void *ptr)
+void SV_WritePtr(const void *ptr)
 {
     long val = (long)(intptr_t) ptr;
 
--- a/src/heretic/r_data.c
+++ b/src/heretic/r_data.c
@@ -595,7 +595,7 @@
 ================
 */
 
-int R_CheckTextureNumForName(char *name)
+int R_CheckTextureNumForName(const char *name)
 {
     int i;
 
@@ -618,7 +618,7 @@
 ================
 */
 
-int R_TextureNumForName(char *name)
+int R_TextureNumForName(const char *name)
 {
     int i;
     //char  namet[9];
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -44,7 +44,7 @@
 // Location where all configuration data is stored - 
 // default.cfg, savegames, etc.
 
-char *configdir;
+const char *configdir;
 
 // Default filenames for configuration files.
 
@@ -2185,7 +2185,7 @@
 // files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
 //
 
-void M_SetConfigDir(char *dir)
+void M_SetConfigDir(const char *dir)
 {
     // Use the directory that was passed, or find the default.
 
--- a/src/m_config.h
+++ b/src/m_config.h
@@ -25,7 +25,7 @@
 void M_LoadDefaults(void);
 void M_SaveDefaults(void);
 void M_SaveDefaultsAlternate(char *main, char *extra);
-void M_SetConfigDir(char *dir);
+void M_SetConfigDir(const char *dir);
 void M_BindIntVariable(char *name, int *variable);
 void M_BindFloatVariable(char *name, float *variable);
 void M_BindStringVariable(char *name, char **variable);
@@ -36,6 +36,6 @@
 void M_SetConfigFilenames(char *main_config, char *extra_config);
 char *M_GetSaveGameDir(char *iwadname);
 
-extern char *configdir;
+extern const char *configdir;
 
 #endif