shithub: choc

Download patch

ref: ad816c1bc28ab81ddb892ff878f65969bddd9764
parent: 80bf45c902f78e3cd0212938ee176a3c6f436997
author: Fabian Greffrath <fabian@greffrath.com>
date: Tue Jan 20 01:53:45 EST 2015

First shot at support for the Hexen 4-level Demo

With these changes it is possible to run the game using the HEXEN.WAD
IWAD from the 4-level Demo and start a new game as one of the three
player classes.

Known missing bits:
 - The game does not yet identify itself as the demo version
 - The cheat codes are still unchanged
 - Bug compatibility, see e.g.
   http://dengine.net/dew/index.php?title=Libhexen

--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -1467,6 +1467,12 @@
 
 void G_Completed(int map, int position)
 {
+    if (gamemode == shareware && map > 4)
+    {
+        P_SetMessage(&players[consoleplayer], "access denied -- demo", true);
+        return;
+    }
+
     gameaction = ga_completed;
     LeaveMap = map;
     LeavePosition = position;
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -796,9 +796,19 @@
     int mcmdValue;
     mapInfo_t *info;
     char songMulch[10];
+    char *default_sky_name = DEFAULT_SKY_NAME;
 
     mapMax = 1;
 
+    // The Hexen Shareware, ne 4-level Demo, is missing the SKY1 lump
+    // and uses the SKY2 lump instead. Let's use this fact to identify
+    // it and set gamemode accordingly
+    if (W_CheckNumForName(default_sky_name) == -1)
+    {
+	default_sky_name = "SKY2";
+	gamemode = shareware;
+    }
+
     // Put defaults into MapInfo[0]
     info = MapInfo;
     info->cluster = 0;
@@ -805,7 +815,7 @@
     info->warpTrans = 0;
     info->nextMap = 1;          // Always go to map 1 if not specified
     info->cdTrack = 1;
-    info->sky1Texture = R_TextureNumForName(DEFAULT_SKY_NAME);
+    info->sky1Texture = R_TextureNumForName(default_sky_name);
     info->sky2Texture = info->sky1Texture;
     info->sky1ScrollDelta = 0;
     info->sky2ScrollDelta = 0;
--- a/src/hexen/p_switch.c
+++ b/src/hexen/p_switch.c
@@ -66,6 +66,13 @@
             switchlist[index] = -1;
             break;
         }
+
+        if (R_CheckTextureNumForName(alphSwitchList[i].name1) == -1 &&
+            gamemode == shareware)
+        {
+            continue;
+        }
+
         switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1);
         switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2);
     }
--- a/src/hexen/sb_bar.c
+++ b/src/hexen/sb_bar.c
@@ -314,6 +314,7 @@
 void SB_SetClassData(void)
 {
     int class;
+    int maxplayers = (gamemode == shareware) ? 4 : MAXPLAYERS;
 
     class = PlayerClass[consoleplayer]; // original player class (not pig)
     PatchWEAPONSLOT = W_CacheLumpNum(W_GetNumForName("wpslot0")
@@ -330,12 +331,12 @@
     if (!netgame)
     {                           // single player game uses red life gem (the second gem)
         PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem")
-                                      + MAXPLAYERS * class + 1, PU_STATIC);
+                                      + maxplayers * class + 1, PU_STATIC);
     }
     else
     {
         PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("lifegem")
-                                      + MAXPLAYERS * class + consoleplayer,
+                                      + maxplayers * class + consoleplayer,
                                       PU_STATIC);
     }
     SB_state = -1;