shithub: choc

Download patch

ref: 19659f3eab0614465577ac71731b4bdce67ce30c
parent: 909a779a0d54ff91b01fad2cc17a0263ba5419ad
author: Fabian Greffrath <fabian@greffrath.com>
date: Mon Mar 23 08:12:08 EDT 2015

maintain an explicit switch list for the demo version

instead of interating through the list for the full version
and letting missing texture lumps slip through.

--- a/src/hexen/p_switch.c
+++ b/src/hexen/p_switch.c
@@ -25,9 +25,16 @@
 //      CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE
 //
 //==================================================================
-switchlist_t alphSwitchList[] = {
+switchlist_t alphSwitchListDemo[] = {
     {"SW_1_UP", "SW_1_DN", SFX_SWITCH1},
     {"SW_2_UP", "SW_2_DN", SFX_SWITCH1},
+    {"SW52_OFF", "SW52_ON", SFX_SWITCH2},
+    {"\0", "\0", 0}
+};
+
+switchlist_t alphSwitchListFull[] = {
+    {"SW_1_UP", "SW_1_DN", SFX_SWITCH1},
+    {"SW_2_UP", "SW_2_DN", SFX_SWITCH1},
     {"VALVE1", "VALVE2", SFX_VALVE_TURN},
     {"SW51_OFF", "SW51_ON", SFX_SWITCH2},
     {"SW52_OFF", "SW52_ON", SFX_SWITCH2},
@@ -39,6 +46,8 @@
     {"\0", "\0", 0}
 };
 
+switchlist_t *alphSwitchList = NULL;
+
 int switchlist[MAXSWITCHES * 2];
 int numswitches;
 button_t buttonlist[MAXBUTTONS];
@@ -58,6 +67,18 @@
     int i;
     int index;
 
+    if (!alphSwitchList)
+    {
+        if (gamemode == shareware)
+        {
+            alphSwitchList = alphSwitchListDemo;
+        }
+        else
+        {
+            alphSwitchList = alphSwitchListFull;
+        }
+    }
+
     for (index = 0, i = 0; i < MAXSWITCHES; i++)
     {
         if (!alphSwitchList[i].soundID)
@@ -66,13 +87,6 @@
             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);
     }