foxygit / doom Log in
commit 83d832ee4e6aabcdeacd282e73dd12ba81367e88
Author:     James Haley <haleyjd@hotmail.com>
AuthorDate: Mon Sep 16 00:29:44 2013 +0000
Commit:     James Haley <haleyjd@hotmail.com>
CommitDate: Mon Sep 16 00:29:44 2013 +0000

    Support for the -random parameter. Needs netcode support (passing the
    ball to fraggle).

    Subversion-branch: /branches/v2-branch
    Subversion-revision: 2657
---
 src/strife/d_main.c   |  9 +++++++++
 src/strife/doomstat.h |  1 +
 src/strife/p_mobj.c   | 19 ++++++++++++++-----
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index 01e560a2..a3179359 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -111,6 +111,7 @@ boolean         nomonsters;     // checkparm of -nomonsters
 boolean         respawnparm;    // checkparm of -respawn
 boolean         fastparm;       // checkparm of -fast
 boolean         flipparm;       // [STRIFE] haleyjd 20110629: checkparm of -flip
+boolean         randomparm;     // [STRIFE] haleyjd 20130915: checkparm of -random

 boolean         showintro = true;   // [STRIFE] checkparm of -nograph, disables intro

@@ -1432,6 +1433,14 @@ void D_DoomMain (void)

     respawnparm = M_CheckParm ("-respawn");

+    //!
+    // @vanilla
+    //
+    // Items respawn at random locations
+    //
+
+    randomparm = M_CheckParm ("-random");
+
     //!
     // @vanilla
     //
diff --git a/src/strife/doomstat.h b/src/strife/doomstat.h
index 1d2d191d..95803c29 100644
--- a/src/strife/doomstat.h
+++ b/src/strife/doomstat.h
@@ -54,6 +54,7 @@
 extern  boolean	nomonsters;	// checkparm of -nomonsters
 extern  boolean	respawnparm;	// checkparm of -respawn
 extern  boolean	fastparm;	// checkparm of -fast
+extern  boolean randomparm;     // [STRIFE] checkparm of -random
 extern  boolean flipparm;       // [STRIFE] checkparm of -flip

 extern  boolean	devparm;	// DEBUG: launched with -devparm
diff --git a/src/strife/p_mobj.c b/src/strife/p_mobj.c
index 53d12f9c..7517b57f 100644
--- a/src/strife/p_mobj.c
+++ b/src/strife/p_mobj.c
@@ -709,13 +709,22 @@ void P_RemoveMobj (mobj_t* mobj)
     {
         itemrespawnque[iquehead] = mobj->spawnpoint;
         itemrespawntime[iquehead] = leveltime + 30*TICRATE; // [STRIFE]
-        iquehead = (iquehead+1)&(ITEMQUESIZE-1);

-        // [STRIFE] FIXME/TODO: - haleyjd 20110629
+        // [STRIFE] haleyjd 20130915
         // -random parameter affects the behavior of respawning items here.
-        // However, this requires addition of randomparm to the transmission
-        // of variables during netgame initialization, and the netcode is not
-        // functional yet - so, I haven't added this yet!
+        if(randomparm && iquehead != iquetail)
+        {
+            short type    = itemrespawnque[iquehead].type;
+            short options = itemrespawnque[iquehead].options;
+
+            // swap the type and options of iquehead and iquetail
+            itemrespawnque[iquehead].type    = itemrespawnque[iquetail].type;
+            itemrespawnque[iquehead].options = itemrespawnque[iquetail].options;
+            itemrespawnque[iquetail].type    = type;
+            itemrespawnque[iquetail].options = options;
+        }
+
+        iquehead = (iquehead+1)&(ITEMQUESIZE-1);

         // lose one off the end?
         if (iquehead == iquetail)