shithub: choc

Download patch

ref: 84fa6864cbee697f2529a4b86663259df1e8fb2a
parent: e88fdf26badf3a88ce30a0faa58e85758d42e315
parent: a3e027a20bc15350ccee1051755a5e0d918b9ef8
author: Simon Howard <fraggle@soulsphere.org>
date: Thu Apr 30 16:52:23 EDT 2020

Merge pull request #1276 from turol/const

More const correctness

--- a/src/hexen/ct_chat.c
+++ b/src/hexen/ct_chat.c
@@ -84,18 +84,7 @@
     "PURPLE:  "
 };
 
-char *chat_macros[10] = {
-    HUSTR_CHATMACRO0,
-    HUSTR_CHATMACRO1,
-    HUSTR_CHATMACRO2,
-    HUSTR_CHATMACRO3,
-    HUSTR_CHATMACRO4,
-    HUSTR_CHATMACRO5,
-    HUSTR_CHATMACRO6,
-    HUSTR_CHATMACRO7,
-    HUSTR_CHATMACRO8,
-    HUSTR_CHATMACRO9,
-};
+char *chat_macros[10];
 
 boolean altdown;
 boolean shiftdown;
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -124,6 +124,22 @@
 
 // CODE --------------------------------------------------------------------
 
+
+static const char * const chat_macro_defaults[10] =
+{
+    HUSTR_CHATMACRO0,
+    HUSTR_CHATMACRO1,
+    HUSTR_CHATMACRO2,
+    HUSTR_CHATMACRO3,
+    HUSTR_CHATMACRO4,
+    HUSTR_CHATMACRO5,
+    HUSTR_CHATMACRO6,
+    HUSTR_CHATMACRO7,
+    HUSTR_CHATMACRO8,
+    HUSTR_CHATMACRO9,
+};
+
+
 void D_BindVariables(void)
 {
     int i;
@@ -172,6 +188,7 @@
     {
         char buf[12];
 
+        chat_macros[i] = M_StringDuplicate(chat_macro_defaults[i]);
         M_snprintf(buf, sizeof(buf), "chatmacro%i", i);
         M_BindStringVariable(buf, &chat_macros[i]);
     }
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -796,7 +796,7 @@
     int mcmdValue;
     mapInfo_t *info;
     char songMulch[10];
-    char *default_sky_name = DEFAULT_SKY_NAME;
+    const char *default_sky_name = DEFAULT_SKY_NAME;
 
     mapMax = 1;
 
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -396,6 +396,22 @@
 // Add configuration file variable bindings.
 //
 
+
+static const char * const chat_macro_defaults[10] =
+{
+    HUSTR_CHATMACRO0,
+    HUSTR_CHATMACRO1,
+    HUSTR_CHATMACRO2,
+    HUSTR_CHATMACRO3,
+    HUSTR_CHATMACRO4,
+    HUSTR_CHATMACRO5,
+    HUSTR_CHATMACRO6,
+    HUSTR_CHATMACRO7,
+    HUSTR_CHATMACRO8,
+    HUSTR_CHATMACRO9
+};
+
+
 void D_BindVariables(void)
 {
     int i;
@@ -460,6 +476,7 @@
     {
         char buf[12];
 
+        chat_macros[i] = M_StringDuplicate(chat_macro_defaults[i]);
         M_snprintf(buf, sizeof(buf), "chatmacro%i", i);
         M_BindStringVariable(buf, &chat_macros[i]);
     }
--- a/src/strife/hu_stuff.c
+++ b/src/strife/hu_stuff.c
@@ -58,19 +58,7 @@
 #define HU_INPUTWIDTH   64
 #define HU_INPUTHEIGHT  1
 
-char *chat_macros[10] =
-{
-    HUSTR_CHATMACRO0,
-    HUSTR_CHATMACRO1,
-    HUSTR_CHATMACRO2,
-    HUSTR_CHATMACRO3,
-    HUSTR_CHATMACRO4,
-    HUSTR_CHATMACRO5,
-    HUSTR_CHATMACRO6,
-    HUSTR_CHATMACRO7,
-    HUSTR_CHATMACRO8,
-    HUSTR_CHATMACRO9
-};
+char *chat_macros[10];
 
 // villsa [STRIFE]
 char player_names[8][16] =