shithub: choc

Download patch

ref: 43edb6bf2e1d1cdc0bb4389a0c94b8751a18df38
parent: f523e59e1db0015b5e6e25da863c387f19841eea
author: Turo Lamminen <turol@iki.fi>
date: Mon Apr 27 15:46:03 EDT 2020

hexen: Refactor chat macro defaults for const correctness

hexen version of f523e59e1db0015b5e6e25da863c387f19841eea

--- 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]);
     }