shithub: choc

Download patch

ref: fc15c99c8e943200e6c7da85f1046fd759514e16
parent: 7309335cd2578e6f1bc3c69590bcc7af5840da89
author: Simon Howard <[email protected]>
date: Thu Aug 31 14:13:04 EDT 2006

Allow the demo size limit to be disabled through the config file.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 581

--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: g_game.c 562 2006-06-21 19:08:20Z fraggle $
+// $Id: g_game.c 581 2006-08-31 18:13:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -134,7 +134,7 @@
 
 
 static const char
-rcsid[] = "$Id: g_game.c 562 2006-06-21 19:08:20Z fraggle $";
+rcsid[] = "$Id: g_game.c 581 2006-08-31 18:13:04Z fraggle $";
 
 #include <string.h>
 #include <stdlib.h>
@@ -343,6 +343,7 @@
 int		bodyqueslot; 
  
 int             vanilla_savegame_limit = 1;
+int             vanilla_demo_limit = 1;
  
  
 int G_CmdChecksum (ticcmd_t* cmd) 
@@ -1680,7 +1681,38 @@
     cmd->buttons = (unsigned char)*demo_p++; 
 } 
 
+// Increase the size of the demo buffer to allow unlimited demos
 
+static void IncreaseDemoBuffer(void)
+{
+    int current_length;
+    byte *new_demobuffer;
+    byte *new_demop;
+    int new_length;
+
+    // Find the current size
+
+    current_length = demoend - demobuffer;
+    
+    // Generate a new buffer twice the size
+    new_length = current_length * 2;
+    
+    new_demobuffer = Z_Malloc(new_length, PU_STATIC, 0);
+    new_demop = new_demobuffer + (demo_p - demobuffer);
+
+    // Copy over the old data
+
+    memcpy(new_demobuffer, demobuffer, current_length);
+
+    // Free the old buffer and point the demo pointers at the new buffer.
+
+    Z_Free(demobuffer);
+
+    demobuffer = new_demobuffer;
+    demo_p = new_demop;
+    demoend = demobuffer + new_length;
+}
+
 void G_WriteDemoTiccmd (ticcmd_t* cmd) 
 { 
     byte *demo_start;
@@ -1712,9 +1744,19 @@
 
     if (demo_p > demoend - 16)
     {
-	// no more space 
-	G_CheckDemoStatus (); 
-	return; 
+        if (vanilla_demo_limit)
+        {
+            // no more space 
+            G_CheckDemoStatus (); 
+            return; 
+        }
+        else
+        {
+            // Vanilla demo limit disabled: unlimited
+            // demo lengths!
+
+            IncreaseDemoBuffer();
+        }
     } 
 	
     G_ReadDemoTiccmd (cmd);         // make SURE it is exactly the same 
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: m_misc.c 535 2006-05-29 00:17:24Z fraggle $
+// $Id: m_misc.c 581 2006-08-31 18:13:04Z fraggle $
 //
 // Copyright(C) 1993-1996 Id Software, Inc.
 // Copyright(C) 2005 Simon Howard
@@ -106,7 +106,7 @@
 //-----------------------------------------------------------------------------
 
 static const char
-rcsid[] = "$Id: m_misc.c 535 2006-05-29 00:17:24Z fraggle $";
+rcsid[] = "$Id: m_misc.c 581 2006-08-31 18:13:04Z fraggle $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -296,6 +296,7 @@
 
 extern int      show_endoom;
 extern int      vanilla_savegame_limit;
+extern int      vanilla_demo_limit;
 
 // dos specific options: these are unused but should be maintained
 // so that the config file can be shared between chocolate
@@ -405,6 +406,7 @@
     {"mouse_threshold",             &mouse_threshold},
     {"show_endoom",                 &show_endoom},
     {"vanilla_savegame_limit",      &vanilla_savegame_limit},
+    {"vanilla_demo_limit",          &vanilla_demo_limit},
 #ifdef FEATURE_MULTIPLAYER
     {"player_name",                 &net_player_name,          DEFAULT_STRING},
 #endif