shithub: choc

Download patch

ref: e9c6289014661d06275e8d378dbcecfb16b15fa8
parent: 4767ddccafca1a1c50bc097284df1328d478882a
author: Simon Howard <fraggle@gmail.com>
date: Mon May 3 13:21:16 EDT 2010

Use dehacked printf functions in Heretic code where appropriate.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1932

--- a/src/heretic/ct_chat.c
+++ b/src/heretic/ct_chat.c
@@ -301,7 +301,9 @@
                 CT_AddChar(i, 0);       // set the end of message character
                 if (numplayers > 2)
                 {
-                    strcpy(plr_lastmsg[i], DEH_String(CT_FromPlrText[i]));
+                    strncpy(plr_lastmsg[i], DEH_String(CT_FromPlrText[i]),
+                            MESSAGESIZE + 9);
+                    plr_lastmsg[i][MESSAGESIZE + 8] = '\0';
                     strcat(plr_lastmsg[i], chat_msg[i]);
                 }
                 else
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -700,7 +700,7 @@
 // haleyjd: moved up, removed WATCOMC code
 void CleanExit(void)
 {
-    printf(DEH_String("Exited from HERETIC.\n"));
+    DEH_printf("Exited from HERETIC.\n");
     exit(1);
 }
 
@@ -849,7 +849,7 @@
 //
 // init subsystems
 //
-    printf(DEH_String("V_Init: allocate screens.\n"));
+    DEH_printf("V_Init: allocate screens.\n");
     V_Init();
 
     // Check for -CDROM
@@ -882,7 +882,7 @@
     }
 
     // Load defaults before initing other systems
-    printf(DEH_String("M_LoadDefaults: Load system defaults.\n"));
+    DEH_printf("M_LoadDefaults: Load system defaults.\n");
     D_BindVariables();
     M_SetConfigFilenames("heretic.cfg", PROGRAM_PREFIX "heretic.cfg");
     M_LoadDefaults();
@@ -889,7 +889,7 @@
 
     I_AtExit(M_SaveDefaults, false);
 
-    printf(DEH_String("Z_Init: Init zone memory allocation daemon.\n"));
+    DEH_printf("Z_Init: Init zone memory allocation daemon.\n");
     Z_Init();
 
 #ifdef FEATURE_DEHACKED
@@ -897,7 +897,7 @@
     DEH_Init();
 #endif
 
-    printf(DEH_String("W_Init: Init WADfiles.\n"));
+    DEH_printf("W_Init: Init WADfiles.\n");
 
     iwadfile = D_FindIWAD(IWAD_MASK_HERETIC, &gamemission);
 
@@ -917,9 +917,9 @@
     }
     if (p && p < myargc - 1)
     {
-        sprintf(file, DEH_String("%s.lmp"), myargv[p + 1]);
+        DEH_snprintf(file, sizeof(file), "%s.lmp", myargv[p + 1]);
         D_AddFile(file);
-        printf(DEH_String("Playing demo %s.lmp.\n"), myargv[p + 1]);
+        DEH_printf("Playing demo %s.lmp.\n", myargv[p + 1]);
     }
 
     if (W_CheckNumForName(DEH_String("E2M1")) == -1)
@@ -958,8 +958,9 @@
     if (autostart)
     {
         char temp[64];
-        sprintf(temp, DEH_String("Warp to Episode %d, Map %d, Skill %d "),
-                startepisode, startmap, startskill + 1);
+        DEH_snprintf(temp, sizeof(temp),
+                     "Warp to Episode %d, Map %d, Skill %d ",
+                     startepisode, startmap, startskill + 1);
         status(temp);
     }
     wadprintf();                // print the added wadfiles
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -863,12 +863,16 @@
                         {
                             if (netgame)
                             {
-                                strcpy(savedescription, DEH_String("NET GAME"));
+                                strncpy(savedescription, DEH_String("NET GAME"),
+                                        sizeof(savedescription));
                             }
                             else
                             {
-                                strcpy(savedescription, DEH_String("SAVE GAME"));
+                                strncpy(savedescription, DEH_String("SAVE GAME"),
+                                        sizeof(savedescription));
                             }
+
+                            savedescription[sizeof(savedescription) - 1] = '\0';
                         }
                         savegameslot =
                             (players[i].cmd.
@@ -1321,7 +1325,9 @@
     save_p = savebuffer + SAVESTRINGSIZE;
     // Skip the description field
     memset(vcheck, 0, sizeof(vcheck));
-    sprintf(vcheck, DEH_String("version %i"), HERETIC_VERSION);
+
+    DEH_snprintf(vcheck, VERSIONSIZE, "version %i", HERETIC_VERSION);
+
     if (strcmp((char *) save_p, vcheck) != 0)
     {                           // Bad version
         return;
@@ -1695,7 +1701,7 @@
     SV_Open(name);
     SV_Write(description, SAVESTRINGSIZE);
     memset(verString, 0, sizeof(verString));
-    sprintf(verString, DEH_String("version %i"), HERETIC_VERSION);
+    DEH_snprintf(verString, VERSIONSIZE, "version %i", HERETIC_VERSION);
     SV_Write(verString, VERSIONSIZE);
     SV_WriteByte(gameskill);
     SV_WriteByte(gameepisode);