summaryrefslogtreecommitdiff
path: root/src/doom/g_game.c
diff options
context:
space:
mode:
authorSimon Howard2014-03-30 18:21:42 -0400
committerSimon Howard2014-03-30 18:21:42 -0400
commit4465be140a27e47aa8bed15be4e58064297c7d94 (patch)
treef27954337910f277d7883feab70e6b2a1fc421b6 /src/doom/g_game.c
parente56c9c948df1ad0e2ff2b64d8593caefbf98fd11 (diff)
downloadchocolate-doom-4465be140a27e47aa8bed15be4e58064297c7d94.tar.gz
chocolate-doom-4465be140a27e47aa8bed15be4e58064297c7d94.tar.bz2
chocolate-doom-4465be140a27e47aa8bed15be4e58064297c7d94.zip
doom: Eliminate use of sprintf().
Use snprintf() or other functions in place of sprintf(). This is part of fixing #371.
Diffstat (limited to 'src/doom/g_game.c')
-rw-r--r--src/doom/g_game.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/doom/g_game.c b/src/doom/g_game.c
index c6b71e01..034bb3ef 100644
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -909,17 +909,18 @@ void G_Ticker (void)
turbodetected[i] = true;
}
- if ((gametic & 31) == 0
+ if ((gametic & 31) == 0
&& ((gametic >> 5) % MAXPLAYERS) == i
&& turbodetected[i])
- {
- static char turbomessage[80];
- extern char *player_names[4];
- sprintf (turbomessage, "%s is turbo!",player_names[i]);
- players[consoleplayer].message = turbomessage;
+ {
+ static char turbomessage[80];
+ extern char *player_names[4];
+ snprintf(turbomessage, sizeof(turbomessage),
+ "%s is turbo!", player_names[i]);
+ players[consoleplayer].message = turbomessage;
turbodetected[i] = false;
- }
-
+ }
+
if (netgame && !netdemo && !(gametic%ticdup) )
{
if (gametic > BACKUPTICS
@@ -1937,16 +1938,18 @@ void G_WriteDemoTiccmd (ticcmd_t* cmd)
//
-// G_RecordDemo
-//
-void G_RecordDemo (char *name)
-{
- int i;
- int maxsize;
-
- usergame = false;
- demoname = Z_Malloc(strlen(name) + 5, PU_STATIC, NULL);
- sprintf(demoname, "%s.lmp", name);
+// G_RecordDemo
+//
+void G_RecordDemo (char *name)
+{
+ size_t demoname_size;
+ int i;
+ int maxsize;
+
+ usergame = false;
+ demoname_size = strlen(name) + 5;
+ demoname = Z_Malloc(demoname_size, PU_STATIC, NULL);
+ snprintf(demoname, demoname_size, "%s.lmp", name);
maxsize = 0x20000;
//!
@@ -2073,7 +2076,8 @@ static char *DemoVersionDescription(int version)
}
else
{
- sprintf(resultbuf, "%i.%i (unknown)", version / 100, version % 100);
+ snprintf(resultbuf, sizeof(resultbuf),
+ "%i.%i (unknown)", version / 100, version % 100);
return resultbuf;
}
}