shithub: choc

Download patch

ref: 154d9d8024ffad9027981eb586913d14c6c50d60
parent: 580372cddbb04538da69a3936f670f7128765c4b
author: Simon Howard <fraggle@gmail.com>
date: Wed Sep 10 14:45:53 EDT 2008

Split off game mode/mission/version definitions into common code, along
with various netgame constants.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1218

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,6 +9,7 @@
 
 DEDSERV_FILES=\
 d_dedicated.c                              \
+d_mode.c             d_mode.h              \
 i_main.c                                   \
 i_timer.c            i_timer.h             \
 m_argv.c             m_argv.h              \
@@ -27,10 +28,11 @@
 
 MAIN_SOURCE_FILES=\
 d_event.c            d_event.h             \
-doomkeys.h                                 \
-doomfeatures.h                             \
-doomtype.h                                 \
-d_ticcmd.h                                 \
+                     doomkeys.h            \
+                     doomfeatures.h        \
+                     doomtype.h            \
+d_mode.c             d_mode.h              \
+                     d_ticcmd.h            \
 i_cdmus.c            i_cdmus.h             \
 i_main.c                                   \
 i_joystick.c         i_joystick.h          \
--- a/src/doom/d_net.h
+++ b/src/doom/d_net.h
@@ -30,11 +30,6 @@
 
 #include "d_player.h"
 
-#define MAXNETNODES 8
-
-// Networking and tick handling related.
-#define BACKUPTICS		128
-
 extern int extratics;
 
 // Create any new ticcmds and broadcast to other players.
--- a/src/doom/doomdef.h
+++ b/src/doom/doomdef.h
@@ -31,7 +31,9 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "doomtype.h"
 #include "i_timer.h"
+#include "d_mode.h"
 
 //
 // Global parameters/defines.
@@ -43,42 +45,6 @@
 #define DOOM_191_VERSION 111
 
 
-// Game mode handling - identify IWAD version
-//  to handle IWAD dependend animations etc.
-typedef enum
-{
-  shareware,	// DOOM 1 shareware, E1, M9
-  registered,	// DOOM 1 registered, E3, M27
-  commercial,	// DOOM 2 retail, E1 M34
-  // DOOM 2 german edition not handled
-  retail,	// DOOM 1 retail, E4, M36
-  indetermined	// Well, no IWAD found.
-  
-} GameMode_t;
-
-
-// Mission packs - might be useful for TC stuff?
-typedef enum
-{
-  doom,		// DOOM 1
-  doom2,	// DOOM 2
-  pack_tnt,	// TNT mission pack
-  pack_plut,	// Plutonia pack
-  none
-
-} GameMission_t;
-
-// What version are we emulating?
-
-typedef enum
-{
-    exe_doom_1_9,   // Doom 1.9: used for shareware, registered and commercial
-    exe_ultimate,   // Ultimate Doom (retail)
-    exe_final,      // Final Doom
-    exe_chex,       // Chex Quest executable (based on Final Doom)
-} GameVersion_t;
-
-
 // If rangecheck is undefined,
 // most parameter validation debugging code will not be compiled
 #define RANGECHECK
@@ -105,18 +71,6 @@
 
 // Deaf monsters/do not react to sound.
 #define	MTF_AMBUSH		8
-
-typedef enum
-{
-    sk_noitems = -1,        // the "-skill 0" hack
-    sk_baby = 0,
-    sk_easy,
-    sk_medium,
-    sk_hard,
-    sk_nightmare
-} skill_t;
-
-
 
 
 //
--- a/src/doom/doomstat.h
+++ b/src/doom/doomstat.h
@@ -41,7 +41,10 @@
 // We need the playr data structure as well.
 #include "d_player.h"
 
+// Game mode/mission
+#include "d_mode.h"
 
+#include "net_defs.h"
 
 
 
--- a/src/net_common.c
+++ b/src/net_common.c
@@ -21,10 +21,12 @@
 // Common code shared between the client and server
 //
 
+#include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 
 #include "doomtype.h"
+#include "d_mode.h"
 #include "i_timer.h"
 
 #include "net_common.h"
@@ -531,24 +533,6 @@
     putchar('\n');
 }
 
-// Check that a gamemode+gamemission received over the network is valid.
-
-boolean NET_ValidGameMode(GameMode_t mode, GameMission_t mission)
-{
-    if (mode == shareware || mode == registered || mode == retail)
-    {
-        return true;
-    }
-    else if (mode == commercial)
-    {
-        return mission == doom2 || mission == pack_tnt || mission == pack_plut;
-    }
-    else
-    {
-        return false;
-    }
-}
-
 // Check that game settings are valid
 
 boolean NET_ValidGameSettings(GameMode_t mode, GameMission_t mission,
@@ -566,7 +550,7 @@
     if (settings->skill < sk_noitems || settings->skill > sk_nightmare)
         return false;
 
-    if (settings->gameversion < exe_doom_1_9 || settings->gameversion > exe_chex)
+    if (!D_ValidGameVersion(mission, settings->gameversion))
         return false;
 
     if (mode == shareware || mode == retail || mode == registered)
--- a/src/net_common.h
+++ b/src/net_common.h
@@ -24,11 +24,10 @@
 #ifndef NET_COMMON_H
 #define NET_COMMON_H
 
+#include "d_mode.h"
 #include "net_defs.h"
 #include "net_packet.h"
 
-#include "doomdef.h"
-
 typedef enum 
 {
     // sending syn packets, waiting for an ACK reply 
@@ -113,8 +112,6 @@
 
 void NET_SafePuts(char *msg);
 unsigned int NET_ExpandTicNum(unsigned int relative, unsigned int b);
-
-boolean NET_ValidGameMode(GameMode_t mode, GameMission_t mission);
 boolean NET_ValidGameSettings(GameMode_t mode, GameMission_t mission, 
                               net_gamesettings_t *settings);
 
--- a/src/net_defs.h
+++ b/src/net_defs.h
@@ -29,9 +29,19 @@
 #include "doomtype.h"
 #include "d_ticcmd.h"
 
+// Absolute maximum number of "nodes" in the game.  This is different to
+// MAXPLAYERS, as there may be observers that are not participating
+// (eg. left/right monitors)
+
+#define MAXNETNODES 16
+
 // The maximum number of players, multiplayer/networking.
 
 #define MAXPLAYERS		4
+
+// Networking and tick handling related.
+
+#define BACKUPTICS		128
 
 typedef struct _net_module_s net_module_t;
 typedef struct _net_packet_s net_packet_t;
--- a/src/net_query.c
+++ b/src/net_query.c
@@ -22,6 +22,7 @@
 //     Querying servers to find their current status.
 //
 
+#include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -21,6 +21,7 @@
 // Network server code
 //
 
+#include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
@@ -28,7 +29,7 @@
 #include "config.h"
 
 #include "doomtype.h"
-#include "doomstat.h"
+#include "d_mode.h"
 #include "i_system.h"
 #include "i_timer.h"
 
@@ -511,7 +512,7 @@
         return;
     }
 
-    if (!NET_ValidGameMode(cl_gamemode, cl_gamemission))
+    if (!D_ValidGameMode(cl_gamemission, cl_gamemode))
     {
         return;
     }