summaryrefslogtreecommitdiff
path: root/src/d_mode.c
diff options
context:
space:
mode:
authorSimon Howard2008-10-30 02:10:50 +0000
committerSimon Howard2008-10-30 02:10:50 +0000
commit091f93809ee554571a6ed6145b8ac69f17814d91 (patch)
tree25e8e1f92ef66e95f5ab19f5d588562292a02785 /src/d_mode.c
parent8c045b4bfee2e859f800f8fbd76f5ae3d5d3f435 (diff)
downloadchocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.tar.gz
chocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.tar.bz2
chocolate-doom-091f93809ee554571a6ed6145b8ac69f17814d91.zip
Factor out Heretic and Hexen versions of m_misc.c. Make -file for
Heretic and Hexen use WAD path lookup. Subversion-branch: /branches/raven-branch Subversion-revision: 1368
Diffstat (limited to 'src/d_mode.c')
-rw-r--r--src/d_mode.c63
1 files changed, 52 insertions, 11 deletions
diff --git a/src/d_mode.c b/src/d_mode.c
index 12b97e6a..435ce8d5 100644
--- a/src/d_mode.c
+++ b/src/d_mode.c
@@ -25,21 +25,26 @@
#include "doomtype.h"
#include "d_mode.h"
-// Table of valid game modes
+// Valid game mode/mission combinations, with the number of
+// episodes/maps for each.
-static struct {
+static struct
+{
GameMission_t mission;
GameMode_t mode;
+ int episode;
+ int map;
} valid_modes[] = {
- { doom, shareware },
- { doom, registered },
- { doom, retail },
- { doom2, commercial },
- { pack_tnt, commercial },
- { pack_plut, commercial },
- { heretic, shareware },
- { heretic, registered },
- { hexen, commercial },
+ { doom, shareware, 1, 9 },
+ { doom, registered, 3, 9 },
+ { doom, retail, 4, 9 },
+ { doom2, commercial, 1, 32 },
+ { pack_tnt, commercial, 1, 32 },
+ { pack_plut, commercial, 1, 32 },
+ { heretic, shareware, 1, 9 },
+ { heretic, registered, 3, 9 },
+ { heretic, retail, 5, 9 },
+ { hexen, commercial, 1, 40 },
};
// Check that a gamemode+gamemission received over the network is valid.
@@ -59,6 +64,42 @@ boolean D_ValidGameMode(GameMission_t mission, GameMode_t mode)
return false;
}
+boolean D_ValidEpisodeMap(GameMission_t mission, GameMode_t mode,
+ int episode, int map)
+{
+ int i;
+
+ // Hacks for Heretic secret episodes
+
+ if (mission == heretic)
+ {
+ if (mode == retail && episode == 6)
+ {
+ return map >= 1 && map <= 3;
+ }
+ else if (mode == registered && episode == 4)
+ {
+ return map == 1;
+ }
+ }
+
+ // Find the table entry for this mission/mode combination.
+
+ for (i=0; i<arrlen(valid_modes); ++i)
+ {
+ if (mission == valid_modes[i].mission
+ && mode == valid_modes[i].mode)
+ {
+ return episode >= 1 && episode <= valid_modes[i].episode
+ && map >= 1 && map <= valid_modes[i].map;
+ }
+ }
+
+ // Unknown mode/mission combination
+
+ return false;
+}
+
// Table of valid versions
static struct {