ref: 08c59baa5e747bd65468a2e5b7ba47e195742e23
parent: 4c5d0e68a46ae1f1baf3d9407b0dbd08eda9b987
author: Simon Howard <fraggle@gmail.com>
date: Thu Mar 30 14:08:37 EST 2006
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
--- 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 @@
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 \
--- /dev/null
+++ b/src/d_dedicated.c
@@ -1,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();
+}
+
--- 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 @@
#include "i_system.h"
#include "i_sound.h"
+#include "i_timer.h"
#include "i_video.h"
#include "g_game.h"
--- 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 @@
#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"
--- 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 @@
#include "m_menu.h"
#include "m_random.h"
#include "i_system.h"
+#include "i_timer.h"
#include "p_setup.h"
#include "p_saveg.h"
--- 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 @@
#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,45 +146,6 @@
//
-// 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)
@@ -190,10 +152,7 @@
{
I_InitSound();
I_InitMusic();
-
- // initialise timer
-
- SDL_Init(SDL_INIT_TIMER);
+ I_InitTimer();
}
//
@@ -267,13 +226,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)
--- 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
@@ -44,17 +44,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).
--- /dev/null
+++ b/src/i_timer.c
@@ -1,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);
+}
+
--- /dev/null
+++ b/src/i_timer.h
@@ -1,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$
+//
+//-----------------------------------------------------------------------------
--- 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 @@
#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"
--- 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 @@
#include "deh_main.h"
#include "i_system.h"
+#include "i_timer.h"
#include "i_video.h"
#include "z_zone.h"
#include "v_video.h"
--- 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"
--- 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"
--- 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"
--- 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"