diff options
author | Simon Howard | 2006-03-30 19:08:37 +0000 |
---|---|---|
committer | Simon Howard | 2006-03-30 19:08:37 +0000 |
commit | 08c59baa5e747bd65468a2e5b7ba47e195742e23 (patch) | |
tree | d216b2942b0da1419525ecabd9154b21446ef0a8 /src | |
parent | 4c5d0e68a46ae1f1baf3d9407b0dbd08eda9b987 (diff) | |
download | chocolate-doom-08c59baa5e747bd65468a2e5b7ba47e195742e23.tar.gz chocolate-doom-08c59baa5e747bd65468a2e5b7ba47e195742e23.tar.bz2 chocolate-doom-08c59baa5e747bd65468a2e5b7ba47e195742e23.zip |
Split off timer code into separate i_timer.c file. Add d_dedicated.c
and build chocolate-server, a standalone dedicated server.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 455
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 20 | ||||
-rw-r--r-- | src/d_dedicated.c | 81 | ||||
-rw-r--r-- | src/d_main.c | 5 | ||||
-rw-r--r-- | src/d_net.c | 5 | ||||
-rw-r--r-- | src/g_game.c | 5 | ||||
-rw-r--r-- | src/i_system.c | 58 | ||||
-rw-r--r-- | src/i_system.h | 13 | ||||
-rw-r--r-- | src/i_timer.c | 86 | ||||
-rw-r--r-- | src/i_timer.h | 52 | ||||
-rw-r--r-- | src/i_video.c | 5 | ||||
-rw-r--r-- | src/m_menu.c | 5 | ||||
-rw-r--r-- | src/net_client.c | 3 | ||||
-rw-r--r-- | src/net_dedicated.c | 1 | ||||
-rw-r--r-- | src/net_gui.c | 3 | ||||
-rw-r--r-- | src/net_server.c | 4 |
15 files changed, 267 insertions, 79 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 56b7468c..c5824dac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,10 +1,27 @@ gamesdir = $(prefix)/games -games_PROGRAMS = chocolate-doom +games_PROGRAMS = chocolate-doom chocolate-server AM_CFLAGS = -I../textscreen @SDL_CFLAGS@ @SDLMIXER_CFLAGS@ @SDLNET_CFLAGS@ -Wall +DEDSERV_FILES=\ +d_dedicated.c \ +i_main.c i_main.h \ +i_timer.c i_timer.h \ +m_argv.c m_argv.h \ +net_common.c net_common.h \ +net_dedicated.c net_dedicated.h \ +net_io.c net_io.h \ +net_packet.c net_packet.h \ +net_sdl.c net_sdl.h \ +net_server.c net_server.h \ +net_structrw.c net_structrw.h \ +z_native.c z_zone.h + +chocolate_server_SOURCES=$(DEDSERV_FILES) +chocolate_server_LDADD = @LDFLAGS@ @SDL_LIBS@ @SDLNET_LIBS@ + SOURCE_FILES=\ am_map.c am_map.h \ deh_ammo.c \ @@ -45,6 +62,7 @@ i_main.c \ info.c info.h \ i_sound.c i_sound.h \ i_system.c i_system.h \ +i_timer.c i_timer.h \ i_video.c i_video.h \ m_argv.c m_argv.h \ m_bbox.c m_bbox.h \ diff --git a/src/d_dedicated.c b/src/d_dedicated.c new file mode 100644 index 00000000..fb01baab --- /dev/null +++ b/src/d_dedicated.c @@ -0,0 +1,81 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id: $ +// +// Copyright(C) 2006 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// $Log$ +// +// Code specific to the standalone dedicated server. +// + +#include <SDL.h> +#include <stdlib.h> +#include <stdarg.h> + +#include "config.h" + +#include "m_argv.h" +#include "net_defs.h" + +#include "net_dedicated.h" +#include "net_server.h" +#include "z_zone.h" + +void NET_CL_Run(void) +{ + // No client present :-) + // + // This is here because the server code sometimes runs this + // to let the client do some processing if it needs to. + // In a standalone dedicated server, we don't have a client. +} + +// +// I_Error +// +// We have our own I_Error function for the dedicated server. +// The normal one does extra things like shutdown graphics, etc. + +void I_Error (char *error, ...) +{ + va_list argptr; + + // Message first. + va_start(argptr,error); + fprintf(stderr, "Error: "); + vfprintf(stderr,error,argptr); + fprintf(stderr, "\n"); + va_end(argptr); + + fflush(stderr); + + exit(-1); +} + + +void D_DoomMain(void) +{ + printf(PACKAGE_NAME " standalone dedicated server\n"); + + Z_Init(); + + NET_DedicatedServer(); +} + diff --git a/src/d_main.c b/src/d_main.c index 7819c0c4..78bd7c37 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_main.c 454 2006-03-30 18:17:58Z fraggle $ +// $Id: d_main.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -184,7 +184,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_main.c 454 2006-03-30 18:17:58Z fraggle $"; +static const char rcsid[] = "$Id: d_main.c 455 2006-03-30 19:08:37Z fraggle $"; #define BGCOLOR 7 #define FGCOLOR 8 @@ -229,6 +229,7 @@ static const char rcsid[] = "$Id: d_main.c 454 2006-03-30 18:17:58Z fraggle $"; #include "i_system.h" #include "i_sound.h" +#include "i_timer.h" #include "i_video.h" #include "g_game.h" diff --git a/src/d_net.c b/src/d_net.c index 888b3114..2ba52a5d 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_net.c 453 2006-03-30 00:23:20Z fraggle $ +// $Id: d_net.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -117,7 +117,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_net.c 453 2006-03-30 00:23:20Z fraggle $"; +static const char rcsid[] = "$Id: d_net.c 455 2006-03-30 19:08:37Z fraggle $"; #include "doomfeatures.h" @@ -125,6 +125,7 @@ static const char rcsid[] = "$Id: d_net.c 453 2006-03-30 00:23:20Z fraggle $"; #include "m_argv.h" #include "m_menu.h" #include "i_system.h" +#include "i_timer.h" #include "i_video.h" #include "g_game.h" #include "doomdef.h" diff --git a/src/g_game.c b/src/g_game.c index b8807da1..c20c5912 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: g_game.c 422 2006-03-16 22:17:45Z fraggle $ +// $Id: g_game.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -134,7 +134,7 @@ static const char -rcsid[] = "$Id: g_game.c 422 2006-03-16 22:17:45Z fraggle $"; +rcsid[] = "$Id: g_game.c 455 2006-03-30 19:08:37Z fraggle $"; #include <string.h> #include <stdlib.h> @@ -152,6 +152,7 @@ rcsid[] = "$Id: g_game.c 422 2006-03-16 22:17:45Z fraggle $"; #include "m_menu.h" #include "m_random.h" #include "i_system.h" +#include "i_timer.h" #include "p_setup.h" #include "p_saveg.h" diff --git a/src/i_system.c b/src/i_system.c index 0a915b38..c0535725 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_system.c 289 2006-01-13 18:23:28Z fraggle $ +// $Id: i_system.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -81,7 +81,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_system.c 289 2006-01-13 18:23:28Z fraggle $"; +rcsid[] = "$Id: i_system.c 455 2006-03-30 19:08:37Z fraggle $"; #include <stdlib.h> @@ -93,8 +93,9 @@ rcsid[] = "$Id: i_system.c 289 2006-01-13 18:23:28Z fraggle $"; #include "doomdef.h" #include "m_misc.h" -#include "i_video.h" #include "i_sound.h" +#include "i_timer.h" +#include "i_video.h" #include "d_net.h" #include "g_game.h" @@ -145,55 +146,13 @@ byte* I_ZoneBase (int* size) // -// I_GetTime -// returns time in 1/35th second tics -// - -static Uint32 basetime = 0; - -int I_GetTime (void) -{ - Uint32 ticks; - - ticks = SDL_GetTicks(); - - if (basetime == 0) - basetime = ticks; - - ticks -= basetime; - - return (ticks * 35) / 1000; -} - -// -// Same as I_GetTime, but returns time in milliseconds -// - -int I_GetTimeMS(void) -{ - Uint32 ticks; - - ticks = SDL_GetTicks(); - - if (basetime == 0) - basetime = ticks; - - return ticks - basetime; -} - - - -// // I_Init // void I_Init (void) { I_InitSound(); I_InitMusic(); - - // initialise timer - - SDL_Init(SDL_INIT_TIMER); + I_InitTimer(); } // @@ -269,13 +228,6 @@ void I_WaitVBL(int count) SDL_Delay((count * 1000) / 70); } -// Sleep for a specified number of ms - -void I_Sleep(int ms) -{ - SDL_Delay(ms); -} - byte* I_AllocLow(int length) { byte* mem; diff --git a/src/i_system.h b/src/i_system.h index 02a8c862..4a1585d4 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_system.h 234 2005-12-30 18:50:53Z fraggle $ +// $Id: i_system.h 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -45,17 +45,6 @@ byte* I_ZoneBase (int *size); // Called by D_DoomLoop, -// returns current time in tics. -int I_GetTime (void); - -// returns current time in ms -int I_GetTimeMS (void); - -// Pause for a specified number of ms -void I_Sleep(int ms); - -// -// Called by D_DoomLoop, // called before processing any tics in a frame // (just after displaying a frame). // Time consuming syncronous operations diff --git a/src/i_timer.c b/src/i_timer.c new file mode 100644 index 00000000..927f0713 --- /dev/null +++ b/src/i_timer.c @@ -0,0 +1,86 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id: i_timer.c 455 2006-03-30 19:08:37Z fraggle $ +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// $Log$ +// +// DESCRIPTION: +// Timer functionssss. +// +//----------------------------------------------------------------------------- + +#include <SDL.h> + +#include "i_timer.h" + +// +// I_GetTime +// returns time in 1/35th second tics +// + +static Uint32 basetime = 0; + +int I_GetTime (void) +{ + Uint32 ticks; + + ticks = SDL_GetTicks(); + + if (basetime == 0) + basetime = ticks; + + ticks -= basetime; + + return (ticks * 35) / 1000; +} + +// +// Same as I_GetTime, but returns time in milliseconds +// + +int I_GetTimeMS(void) +{ + Uint32 ticks; + + ticks = SDL_GetTicks(); + + if (basetime == 0) + basetime = ticks; + + return ticks - basetime; +} + +// Sleep for a specified number of ms + +void I_Sleep(int ms) +{ + SDL_Delay(ms); +} + + +void I_InitTimer(void) +{ + // initialise timer + + SDL_Init(SDL_INIT_TIMER); +} + diff --git a/src/i_timer.h b/src/i_timer.h new file mode 100644 index 00000000..df9d89f3 --- /dev/null +++ b/src/i_timer.h @@ -0,0 +1,52 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id: i_timer.h 455 2006-03-30 19:08:37Z fraggle $ +// +// Copyright(C) 1993-1996 Id Software, Inc. +// Copyright(C) 2005 Simon Howard +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. +// +// DESCRIPTION: +// System-specific timer interface +// +//----------------------------------------------------------------------------- + + +#ifndef __I_TIMER__ +#define __I_TIMER__ + +// Called by D_DoomLoop, +// returns current time in tics. +int I_GetTime (void); + +// returns current time in ms +int I_GetTimeMS (void); + +// Pause for a specified number of ms +void I_Sleep(int ms); + +// Initialise timer +void I_InitTimer(void); + +#endif + +//----------------------------------------------------------------------------- +// +// $Log$ +// +//----------------------------------------------------------------------------- diff --git a/src/i_video.c b/src/i_video.c index 53e175dd..e370a0b3 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_video.c 428 2006-03-19 00:12:00Z fraggle $ +// $Id: i_video.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -175,7 +175,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_video.c 428 2006-03-19 00:12:00Z fraggle $"; +rcsid[] = "$Id: i_video.c 455 2006-03-30 19:08:37Z fraggle $"; #include <SDL.h> #include <ctype.h> @@ -188,6 +188,7 @@ rcsid[] = "$Id: i_video.c 428 2006-03-19 00:12:00Z fraggle $"; #include "doomstat.h" #include "d_main.h" #include "i_system.h" +#include "i_timer.h" #include "m_argv.h" #include "m_swap.h" #include "s_sound.h" diff --git a/src/m_menu.c b/src/m_menu.c index 09d7e7f6..76efffa1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: m_menu.c 429 2006-03-23 17:43:15Z fraggle $ +// $Id: m_menu.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -78,7 +78,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: m_menu.c 429 2006-03-23 17:43:15Z fraggle $"; +rcsid[] = "$Id: m_menu.c 455 2006-03-30 19:08:37Z fraggle $"; #include <stdlib.h> #include <ctype.h> @@ -91,6 +91,7 @@ rcsid[] = "$Id: m_menu.c 429 2006-03-23 17:43:15Z fraggle $"; #include "deh_main.h" #include "i_system.h" +#include "i_timer.h" #include "i_video.h" #include "z_zone.h" #include "v_video.h" diff --git a/src/net_client.c b/src/net_client.c index eb99489b..097b2f44 100644 --- a/src/net_client.c +++ b/src/net_client.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_client.c 440 2006-03-24 21:43:43Z fraggle $ +// $Id: net_client.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -153,6 +153,7 @@ #include "deh_main.h" #include "g_game.h" #include "i_system.h" +#include "i_timer.h" #include "m_argv.h" #include "net_client.h" #include "net_common.h" diff --git a/src/net_dedicated.c b/src/net_dedicated.c index b3f41d6d..77ad1a99 100644 --- a/src/net_dedicated.c +++ b/src/net_dedicated.c @@ -28,6 +28,7 @@ #include "doomtype.h" #include "i_system.h" +#include "i_timer.h" #include "net_defs.h" #include "net_sdl.h" diff --git a/src/net_gui.c b/src/net_gui.c index b6cb4c6c..d7a6f175 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_gui.c 440 2006-03-24 21:43:43Z fraggle $ +// $Id: net_gui.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -81,6 +81,7 @@ #include "doomstat.h" #include "i_system.h" +#include "i_timer.h" #include "i_video.h" #include "net_client.h" diff --git a/src/net_server.c b/src/net_server.c index d49934e5..b964beae 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: net_server.c 453 2006-03-30 00:23:20Z fraggle $ +// $Id: net_server.c 455 2006-03-30 19:08:37Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -167,6 +167,8 @@ #include "doomdef.h" #include "doomstat.h" #include "i_system.h" +#include "i_timer.h" + #include "net_client.h" #include "net_common.h" #include "net_defs.h" |