shithub: choc

Download patch

ref: a3e027a20bc15350ccee1051755a5e0d918b9ef8
parent: f96fb6079a2675697869237c21fd60e69c3d94c3
author: Turo Lamminen <turol@iki.fi>
date: Tue Apr 28 13:57:05 EDT 2020

strife: Refactor chat macro defaults for const correctness

strife version of f523e59e1db0015b5e6e25da863c387f19841eea

--- 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] =