shithub: choc

Download patch

ref: 439a4b158b47c635100b0006470a7ed1e44e29f3
parent: 87be507ed7d66194903cfd80db76a30275469260
author: Simon Howard <[email protected]>
date: Sat Sep 6 16:06:14 EDT 2008

Remove includes of doomdef.h where possible, move generic parts into top
level.

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

--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@
 
 games_PROGRAMS = chocolate-doom chocolate-server
 
-AM_CFLAGS = -Idoom -I../textscreen -I../pcsound @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@
+AM_CFLAGS = -Idoom -I../textscreen -I../pcsound @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ -Werror
 
 DEDSERV_FILES=\
 d_dedicated.c                              \
--- a/src/deh_ammo.c
+++ b/src/deh_ammo.c
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "deh_defs.h"
 #include "deh_io.h"
--- a/src/deh_cheat.c
+++ b/src/deh_cheat.c
@@ -24,7 +24,8 @@
 //
 //-----------------------------------------------------------------------------
 
-#include "doomdef.h"
+#include <stdlib.h>
+
 #include "doomtype.h"
 
 #include "deh_defs.h"
--- a/src/deh_frame.c
+++ b/src/deh_frame.c
@@ -26,7 +26,6 @@
 
 #include <stdlib.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "d_items.h"
 #include "info.h"
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -24,9 +24,11 @@
 //
 //-----------------------------------------------------------------------------
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "d_iwad.h"
 #include "m_argv.h"
--- a/src/deh_mapping.c
+++ b/src/deh_mapping.c
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "deh_mapping.h"
 
--- a/src/deh_misc.c
+++ b/src/deh_misc.c
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "deh_defs.h"
 #include "deh_io.h"
--- a/src/deh_ptr.c
+++ b/src/deh_ptr.c
@@ -24,10 +24,10 @@
 //
 //-----------------------------------------------------------------------------
 
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "info.h"
 
--- a/src/deh_sound.c
+++ b/src/deh_sound.c
@@ -24,9 +24,9 @@
 //
 //-----------------------------------------------------------------------------
 
+#include <stdio.h>
 #include <stdlib.h>
 
-#include "doomdef.h"
 #include "doomfeatures.h"
 #include "doomtype.h"
 #include "deh_defs.h"
--- a/src/deh_text.c
+++ b/src/deh_text.c
@@ -24,7 +24,8 @@
 //
 //-----------------------------------------------------------------------------
 
-#include "doomdef.h"
+#include <string.h>
+
 #include "doomtype.h"
 
 #include "z_zone.h"
--- a/src/deh_thing.c
+++ b/src/deh_thing.c
@@ -24,9 +24,9 @@
 //
 //-----------------------------------------------------------------------------
 
+#include <stdio.h>
 #include <stdlib.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 
 #include "deh_defs.h"
--- a/src/deh_weapon.c
+++ b/src/deh_weapon.c
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 
 #include "d_items.h"
--- a/src/doom/am_map.c
+++ b/src/doom/am_map.c
@@ -30,6 +30,7 @@
 #include "deh_main.h"
 
 #include "z_zone.h"
+#include "doomkeys.h"
 #include "doomdef.h"
 #include "st_stuff.h"
 #include "p_local.h"
--- a/src/doom/d_iwad.c
+++ b/src/doom/d_iwad.c
@@ -30,6 +30,7 @@
 #include <string.h>
 
 #include "deh_main.h"
+#include "doomkeys.h"
 #include "doomdef.h"
 #include "doomstat.h"
 #include "i_system.h"
--- a/src/doom/d_player.h
+++ b/src/doom/d_player.h
@@ -45,6 +45,7 @@
 // as commands per game tick.
 #include "d_ticcmd.h"
 
+#include "net_defs.h"
 
 
 
--- a/src/doom/doomdef.h
+++ b/src/doom/doomdef.h
@@ -31,40 +31,9 @@
 #include <stdio.h>
 #include <string.h>
 
-// #define macros to provide functions missing in Windows.
-// Outside Windows, we use strings.h for str[n]casecmp.
+#include "i_timer.h"
 
-
-#ifdef _WIN32
-
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-
-#else
-
-#include <strings.h>
-
-#endif
-
-
 //
-// The packed attribute forces structures to be packed into the minimum 
-// space necessary.  If this is not done, the compiler may align structure
-// fields differently to optimise memory access, inflating the overall
-// structure size.  It is important to use the packed attribute on certain
-// structures where alignment is important, particularly data read/written
-// to disk.
-//
-
-#ifdef __GNUC__
-#define PACKEDATTR __attribute__((packed))
-#else
-#define PACKEDATTR
-#endif
-
-//
 // Global parameters/defines.
 //
 // DOOM version
@@ -114,27 +83,6 @@
 // most parameter validation debugging code will not be compiled
 #define RANGECHECK
 
-
-
-// Screen width and height.
-
-#define SCREENWIDTH  320
-#define SCREENHEIGHT 200
-
-// Screen width used for "squash" scale functions
-
-#define SCREENWIDTH_4_3 256
-
-// Screen height used for "stretch" scale functions.
-
-#define SCREENHEIGHT_4_3 240
-
-// The maximum number of players, multiplayer/networking.
-#define MAXPLAYERS		4
-
-// State updates, number of tics / second.
-#define TICRATE		35
-
 // The current state of the game: whether we are
 // playing, gazing at the intermission screen,
 // the game final animation, or a demo. 
@@ -254,59 +202,5 @@
     
 } powerduration_t;
 
-
-// fraggle: moved key definitions to a separate file
-
-#include "doomkeys.h"
-
-
-// DOOM basic types (boolean),
-//  and max/min values.
-//#include "doomtype.h"
-
-// Fixed point.
-//#include "m_fixed.h"
-
-// Endianess handling.
-//#include "m_swap.h"
-
-
-// Binary Angles, sine/cosine/atan lookups.
-//#include "tables.h"
-
-// Event type.
-//#include "d_event.h"
-
-// Game function, skills.
-//#include "g_game.h"
-
-// All external data is defined here.
-//#include "doomdata.h"
-
-// All important printed strings.
-// Language selection (message strings).
-//#include "dstrings.h"
-
-// Player is a special actor.
-//struct player_s;
-
-
-//#include "d_items.h"
-//#include "d_player.h"
-//#include "p_mobj.h"
-//#include "d_net.h"
-
-// PLAY
-//#include "p_tick.h"
-
-
-
-
-// Header, generated by sound utility.
-// The utility was written by Dave Taylor.
-//#include "sounds.h"
-
-
-
-
 #endif          // __DOOMDEF__
+
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -30,6 +30,7 @@
 #include <math.h>
 
 #include "doomdef.h" 
+#include "doomkeys.h"
 #include "doomstat.h"
 
 #include "deh_main.h"
--- a/src/doom/hu_lib.c
+++ b/src/doom/hu_lib.c
@@ -27,6 +27,7 @@
 #include <ctype.h>
 
 #include "doomdef.h"
+#include "doomkeys.h"
 
 #include "v_video.h"
 #include "i_swap.h"
--- a/src/doom/hu_stuff.c
+++ b/src/doom/hu_stuff.c
@@ -27,6 +27,7 @@
 #include <ctype.h>
 
 #include "doomdef.h"
+#include "doomkeys.h"
 
 #include "z_zone.h"
 
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -31,6 +31,7 @@
 
 
 #include "doomdef.h"
+#include "doomkeys.h"
 #include "dstrings.h"
 
 #include "d_main.h"
--- a/src/doom/r_defs.h
+++ b/src/doom/r_defs.h
@@ -42,6 +42,7 @@
 // SECTORS do store MObjs anyway.
 #include "p_mobj.h"
 
+#include "i_video.h"
 
 
 
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -39,6 +39,7 @@
 #include "deh_main.h"
 #include "deh_misc.h"
 #include "doomdef.h"
+#include "doomkeys.h"
 
 #include "g_game.h"
 
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -29,6 +29,39 @@
 #ifndef __DOOMTYPE__
 #define __DOOMTYPE__
 
+// #define macros to provide functions missing in Windows.
+// Outside Windows, we use strings.h for str[n]casecmp.
+
+
+#ifdef _WIN32
+
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#define strcasecmp stricmp
+#define strncasecmp strnicmp
+
+#else
+
+#include <strings.h>
+
+#endif
+
+
+//
+// The packed attribute forces structures to be packed into the minimum 
+// space necessary.  If this is not done, the compiler may align structure
+// fields differently to optimise memory access, inflating the overall
+// structure size.  It is important to use the packed attribute on certain
+// structures where alignment is important, particularly data read/written
+// to disk.
+//
+
+#ifdef __GNUC__
+#define PACKEDATTR __attribute__((packed))
+#else
+#define PACKEDATTR
+#endif
+
 // C99 integer types; with gcc we just use this.  Other compilers 
 // should add conditional statements that define the C99 types.
 
--- a/src/f_wipe.c
+++ b/src/f_wipe.c
@@ -33,7 +33,7 @@
 #include "v_video.h"
 #include "m_random.h"
 
-#include "doomdef.h"
+#include "doomtype.h"
 
 #include "f_wipe.h"
 
--- a/src/i_main.c
+++ b/src/i_main.c
@@ -34,7 +34,7 @@
 #include <windows.h>
 #endif
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "m_argv.h"
 #include "d_main.h"
--- a/src/i_pcsound.c
+++ b/src/i_pcsound.c
@@ -25,7 +25,6 @@
 
 #include "SDL.h"
 
-#include "doomdef.h"
 #include "doomtype.h"
 
 #include "deh_main.h"
--- a/src/i_scale.c
+++ b/src/i_scale.c
@@ -26,7 +26,9 @@
 //
 //-----------------------------------------------------------------------------
 
-#include "doomdef.h"
+#include <stdlib.h>
+#include <string.h>
+
 #include "doomtype.h"
 
 #include "i_video.h"
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -30,7 +30,7 @@
 #include "SDL.h"
 #include "SDL_mixer.h"
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "memio.h"
 #include "mus2mid.h"
 
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -45,7 +45,7 @@
 #include "w_wad.h"
 #include "z_zone.h"
 
-#include "doomdef.h"
+#include "doomtype.h"
 
 #define LOW_PASS_FILTER
 #define NUM_CHANNELS 16
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -39,7 +39,7 @@
 #endif
 
 #include "deh_main.h"
-#include "doomdef.h"
+#include "doomtype.h"
 #include "doomstat.h"
 #include "m_argv.h"
 #include "m_config.h"
--- a/src/i_timer.c
+++ b/src/i_timer.c
@@ -27,7 +27,7 @@
 #include "SDL.h"
 
 #include "i_timer.h"
-#include "doomdef.h"
+#include "doomtype.h"
 
 //
 // I_GetTime
--- a/src/i_timer.h
+++ b/src/i_timer.h
@@ -28,6 +28,8 @@
 #ifndef __I_TIMER__
 #define __I_TIMER__
 
+#define TICRATE 35
+
 // Called by D_DoomLoop,
 // returns current time in tics.
 int I_GetTime (void);
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -34,7 +34,8 @@
 
 #include "config.h"
 #include "deh_main.h"
-#include "doomdef.h"
+#include "doomtype.h"
+#include "doomkeys.h"
 #include "doomstat.h"
 #include "d_main.h"
 #include "i_joystick.h"
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -28,33 +28,45 @@
 #ifndef __I_VIDEO__
 #define __I_VIDEO__
 
-
 #include "doomtype.h"
 
+// Screen width and height.
+
+#define SCREENWIDTH  320
+#define SCREENHEIGHT 200
+
+// Screen width used for "squash" scale functions
+
+#define SCREENWIDTH_4_3 256
+
+// Screen height used for "stretch" scale functions.
+
+#define SCREENHEIGHT_4_3 240
+
 typedef struct 
 {
-        // Screen width and height
+    // Screen width and height
 
-        int width;
-        int height;
+    int width;
+    int height;
 
-        // Initialisation function to call when using this mode.
-        // Called with a pointer to the Doom palette.
-        //
-        // If NULL, no init function is called.
+    // Initialisation function to call when using this mode.
+    // Called with a pointer to the Doom palette.
+    //
+    // If NULL, no init function is called.
 
-        void (*InitMode)(byte *palette);
-        
-        // Function to call to draw the screen from the source buffer.
-        // Return true if draw was successful.
+    void (*InitMode)(byte *palette);
+    
+    // Function to call to draw the screen from the source buffer.
+    // Return true if draw was successful.
 
-        boolean (*DrawScreen)(int x1, int y1, int x2, int y2);
+    boolean (*DrawScreen)(int x1, int y1, int x2, int y2);
 
-        // If true, this is a "poor quality" mode.  The autoadjust 
-        // code should always attempt to use a different mode to this 
-        // mode in fullscreen.
+    // If true, this is a "poor quality" mode.  The autoadjust 
+    // code should always attempt to use a different mode to this 
+    // mode in fullscreen.
 
-        boolean poor_quality;
+    boolean poor_quality;
 } screen_mode_t;
 
 // Called by D_DoomMain,
--- a/src/m_argv.c
+++ b/src/m_argv.c
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "m_misc.h"
 
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -33,7 +33,8 @@
 
 #include "config.h"
 #include "deh_main.h"
-#include "doomdef.h"
+#include "doomtype.h"
+#include "doomkeys.h"
 #include "doomfeatures.h"
 
 #include "z_zone.h"
--- a/src/m_misc.c
+++ b/src/m_misc.c
@@ -42,7 +42,7 @@
 #include <sys/types.h>
 #endif
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "doomstat.h"
 
 #include "deh_main.h"
--- a/src/md5.c
+++ b/src/md5.c
@@ -20,7 +20,6 @@
  * Still in the public domain.
  */
 
-#include "doomdef.h"
 #include "i_swap.h"
 
 #include <string.h>             /* for memcpy() */
--- a/src/mus2mid.c
+++ b/src/mus2mid.c
@@ -25,7 +25,6 @@
 
 #include <stdio.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "i_swap.h"
 
--- a/src/net_client.c
+++ b/src/net_client.c
@@ -26,7 +26,7 @@
 #include <string.h>
 
 #include "config.h"
-#include "doomdef.h"
+#include "doomtype.h"
 #include "doomstat.h"
 #include "deh_main.h"
 #include "g_game.h"
--- a/src/net_client.h
+++ b/src/net_client.h
@@ -24,7 +24,6 @@
 #ifndef NET_CLIENT_H
 #define NET_CLIENT_H
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "d_ticcmd.h"
 #include "md5.h"
--- a/src/net_common.c
+++ b/src/net_common.c
@@ -24,7 +24,7 @@
 #include <ctype.h>
 #include <stdlib.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_timer.h"
 
 #include "net_common.h"
--- a/src/net_common.h
+++ b/src/net_common.h
@@ -27,6 +27,8 @@
 #include "net_defs.h"
 #include "net_packet.h"
 
+#include "doomdef.h"
+
 typedef enum 
 {
     // sending syn packets, waiting for an ACK reply 
--- a/src/net_dedicated.c
+++ b/src/net_dedicated.c
@@ -23,6 +23,8 @@
 // Dedicated server code.
 // 
 
+#include <stdlib.h>
+
 #include "doomtype.h"
 
 #include "i_system.h"
--- a/src/net_defs.h
+++ b/src/net_defs.h
@@ -26,9 +26,12 @@
 #ifndef NET_DEFS_H
 #define NET_DEFS_H 
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "d_ticcmd.h"
+
+// The maximum number of players, multiplayer/networking.
+
+#define MAXPLAYERS		4
 
 typedef struct _net_module_s net_module_t;
 typedef struct _net_packet_s net_packet_t;
--- a/src/net_gui.c
+++ b/src/net_gui.c
@@ -29,6 +29,7 @@
 
 #include "config.h"
 #include "doomstat.h"
+#include "doomkeys.h"
 
 #include "i_system.h"
 #include "i_timer.h"
--- a/src/net_loop.c
+++ b/src/net_loop.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "net_defs.h"
 #include "net_loop.h"
--- a/src/net_sdl.c
+++ b/src/net_sdl.c
@@ -27,7 +27,7 @@
 #include <string.h>
 #include <stdio.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "m_argv.h"
 #include "net_defs.h"
--- a/src/net_server.c
+++ b/src/net_server.c
@@ -27,7 +27,7 @@
 
 #include "config.h"
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "doomstat.h"
 #include "i_system.h"
 #include "i_timer.h"
--- a/src/net_structrw.c
+++ b/src/net_structrw.c
@@ -24,7 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 
 #include "net_packet.h"
 #include "net_structrw.h"
--- a/src/s_sound.c
+++ b/src/s_sound.c
@@ -32,7 +32,7 @@
 #include "deh_main.h"
 
 #include "doomstat.h"
-#include "doomdef.h"
+#include "doomtype.h"
 
 #include "sounds.h"
 #include "s_sound.h"
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -32,7 +32,7 @@
 #include "i_system.h"
 #include "r_local.h"
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "doomdata.h"
 
 #include "deh_main.h"
--- a/src/v_video.h
+++ b/src/v_video.h
@@ -32,8 +32,6 @@
 
 #include "doomtype.h"
 
-#include "doomdef.h"
-
 // Needed because we are refering to patches.
 #include "r_data.h"
 
--- a/src/w_file.c
+++ b/src/w_file.c
@@ -26,7 +26,6 @@
 
 #include "config.h"
 
-#include "doomdef.h"
 #include "doomtype.h"
 #include "m_argv.h"
 
--- a/src/w_merge.c
+++ b/src/w_merge.c
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
+#include "doomtype.h"
 #include "i_system.h"
 #include "w_merge.h"
 #include "w_wad.h"
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "doomdef.h"
 #include "doomtype.h"
 
 #include "i_swap.h"
--- a/src/z_native.c
+++ b/src/z_native.c
@@ -29,10 +29,11 @@
 
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "z_zone.h"
 #include "i_system.h"
-#include "doomdef.h"
+#include "doomtype.h"
 
 #define ZONEID	0x1d4a11
 
--- a/src/z_zone.c
+++ b/src/z_zone.c
@@ -27,7 +27,7 @@
 
 #include "z_zone.h"
 #include "i_system.h"
-#include "doomdef.h"
+#include "doomtype.h"
 
 
 //