Make the init process more dependency based.

Most subsystems that depend on other subsystems now call the init functions
themselves. This makes for much cleaner client initialization (more work
needs to be done for the server).
This commit is contained in:
Bill Currie 2012-02-01 21:52:47 +09:00
parent c4e08bc152
commit f800e79a38
10 changed files with 91 additions and 86 deletions

View file

@ -42,7 +42,7 @@ extern viewdelta_t viewdelta;
struct cvar_s; struct cvar_s;
void IN_Init (void); void IN_Init (struct cbuf_s *cbuf);
void IN_Init_Cvars (void); void IN_Init_Cvars (void);
void IN_Shutdown (void); void IN_Shutdown (void);

View file

@ -50,6 +50,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/draw.h" #include "QF/draw.h"
#include "QF/quakefs.h" #include "QF/quakefs.h"
#include "QF/render.h" #include "QF/render.h"
#include "QF/screen.h"
#include "QF/skin.h" #include "QF/skin.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/vid.h" #include "QF/vid.h"
@ -146,6 +147,7 @@ R_Init (void)
"Load a pointfile to determine map leaks"); "Load a pointfile to determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox"); Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
SCR_Init ();
R_InitBubble (); R_InitBubble ();
GDT_Init (); GDT_Init ();

View file

@ -256,6 +256,7 @@ R_RenderView (void)
VISIBLE void VISIBLE void
R_Init (void) R_Init (void)
{ {
SCR_Init ();
R_InitBsp (); R_InitBsp ();
R_InitAlias (); R_InitAlias ();
R_InitSprites (); R_InitSprites ();

View file

@ -147,6 +147,7 @@ R_Init (void)
// get stack position so we can guess if we are going to overflow // get stack position so we can guess if we are going to overflow
r_stack_start = (byte *) & dummy; r_stack_start = (byte *) & dummy;
SCR_Init ();
R_SetFPCW (); R_SetFPCW ();
#ifdef USE_INTEL_ASM #ifdef USE_INTEL_ASM
R_InitVars (); R_InitVars ();

View file

@ -174,6 +174,7 @@ R_Init (void)
// get stack position so we can guess if we are going to overflow // get stack position so we can guess if we are going to overflow
r_stack_start = (byte *) & dummy; r_stack_start = (byte *) & dummy;
SCR_Init ();
R_InitTurb (); R_InitTurb ();
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current " Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current "

View file

@ -31,8 +31,7 @@
# include "config.h" # include "config.h"
#endif #endif
static __attribute__ ((used)) const char rcsid[] = static __attribute__ ((used)) const char rcsid[] = "$Id$";
"$Id$";
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
@ -50,6 +49,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "QF/cbuf.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/in_event.h" #include "QF/in_event.h"
#include "QF/input.h" #include "QF/input.h"
@ -142,11 +142,11 @@ IN_Shutdown (void)
} }
void void
IN_Init (void) IN_Init (cbuf_t *cbuf)
{ {
IE_Init (); IE_Init ();
IN_LL_Init (); IN_LL_Init ();
Key_Init (cbuf);
JOY_Init (); JOY_Init ();
in_mouse_x = in_mouse_y = 0.0; in_mouse_x = in_mouse_y = 0.0;
@ -156,6 +156,7 @@ void
IN_Init_Cvars (void) IN_Init_Cvars (void)
{ {
IE_Init_Cvars (); IE_Init_Cvars ();
Key_Init_Cvars ();
JOY_Init_Cvars (); JOY_Init_Cvars ();
in_grab = Cvar_Get ("in_grab", "0", CVAR_ARCHIVE, IN_UpdateGrab, in_grab = Cvar_Get ("in_grab", "0", CVAR_ARCHIVE, IN_UpdateGrab,
"With this set to 1, quake will grab the mouse, " "With this set to 1, quake will grab the mouse, "

View file

@ -129,16 +129,15 @@ CL_Shutdown (void)
void void
CL_InitCvars (void) CL_InitCvars (void)
{ {
Chase_Init_Cvars ();
IN_Init_Cvars ();
VID_Init_Cvars (); VID_Init_Cvars ();
S_Init_Cvars (); IN_Init_Cvars ();
Key_Init_Cvars ();
R_Init_Cvars ();
Mod_Init_Cvars (); Mod_Init_Cvars ();
V_Init_Cvars (); R_Init_Cvars ();
S_Init_Cvars ();
CL_Demo_Init (); CL_Demo_Init ();
Chase_Init_Cvars ();
V_Init_Cvars ();
cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL, cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL,
"Show bonus flash on item pickup"); "Show bonus flash on item pickup");
@ -511,26 +510,21 @@ CL_Init (cbuf_t *cbuf)
if (!colormap) if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp"); Sys_Error ("Couldn't load gfx/colormap.lmp");
Key_Init (cbuf); W_LoadWadFile ("gfx.wad");
VID_Init (basepal, colormap); VID_Init (basepal, colormap);
IN_Init (cbuf);
Draw_Init (); Draw_Init ();
SCR_Init ();
R_Init (); R_Init ();
S_Init (&cl.worldmodel, &viewentity, &host_frametime); S_Init (&cl.worldmodel, &viewentity, &host_frametime);
CDAudio_Init (); CDAudio_Init ();
Sbar_Init (); Sbar_Init ();
IN_Init ();
Skin_Init ();
CL_SetState (ca_disconnected);
SZ_Alloc (&cls.message, 1024);
CL_Input_Init (); CL_Input_Init ();
CL_TEnts_Init (); CL_TEnts_Init ();
CL_ClearState (); CL_ClearState ();
Skin_Init ();
V_Init (); V_Init ();
Cmd_AddCommand ("entities", CL_PrintEntities_f, "No Description"); Cmd_AddCommand ("entities", CL_PrintEntities_f, "No Description");
@ -540,4 +534,7 @@ CL_Init (cbuf_t *cbuf)
Cmd_AddCommand ("demolist", Con_Demolist_DEM_f, "List available demos"); Cmd_AddCommand ("demolist", Con_Demolist_DEM_f, "List available demos");
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view " Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
"to be level"); "to be level");
SZ_Alloc (&cls.message, 1024);
CL_SetState (ca_disconnected);
} }

View file

@ -863,6 +863,8 @@ Host_Init_Memory (void)
Sys_PageIn (mem_base, mem_size); Sys_PageIn (mem_base, mem_size);
Memory_Init (mem_base, mem_size); Memory_Init (mem_base, mem_size);
Sys_Printf ("%4.1f megabyte heap\n", host_mem_size->value);
} }
void void
@ -874,9 +876,8 @@ Host_Init (void)
cmd_source = src_command; cmd_source = src_command;
Sys_Init (); Sys_Init ();
COM_ParseConfig ();
GIB_Init (true); GIB_Init (true);
COM_ParseConfig ();
Host_Init_Memory (); Host_Init_Memory ();
@ -884,12 +885,12 @@ Host_Init (void)
Game_Init (); Game_Init ();
if (!isDedicated)
CL_InitCvars ();
PR_Init_Cvars (); PR_Init_Cvars ();
SV_Progs_Init_Cvars (); SV_Progs_Init_Cvars ();
if (!isDedicated)
CL_InitCvars ();
PR_Init (); PR_Init ();
if (isDedicated) { if (isDedicated) {
@ -911,14 +912,10 @@ Host_Init (void)
NET_Init (); NET_Init ();
W_LoadWadFile ("gfx.wad");
Mod_Init (); Mod_Init ();
SV_Progs_Init ();
SV_Init (); SV_Init ();
Sys_Printf ("%4.1f megabyte heap\n", host_mem_size->value);
if (cls.state != ca_dedicated) if (cls.state != ca_dedicated)
CL_Init (host_cbuf); CL_Init (host_cbuf);

View file

@ -84,6 +84,8 @@ SV_Init (void)
{ {
int i; int i;
SV_Progs_Init ();
sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, NULL, sv_maxvelocity = Cvar_Get ("sv_maxvelocity", "2000", CVAR_NONE, NULL,
"None"); "None");
sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_SERVERINFO, Cvar_Info, sv_gravity = Cvar_Get ("sv_gravity", "800", CVAR_SERVERINFO, Cvar_Info,

View file

@ -396,7 +396,8 @@ CL_ClearState (void)
S_StopAllSounds (); S_StopAllSounds ();
// wipe the entire cl structure // wipe the entire cl structure
Info_Destroy (cl.serverinfo); if (cl.serverinfo)
Info_Destroy (cl.serverinfo);
memset (&cl, 0, sizeof (cl)); memset (&cl, 0, sizeof (cl));
r_force_fullscreen = 0; r_force_fullscreen = 0;
@ -429,7 +430,8 @@ CL_ClearState (void)
memset (cl_efrags, 0, sizeof (cl_efrags)); memset (cl_efrags, 0, sizeof (cl_efrags));
memset (r_lightstyle, 0, sizeof (r_lightstyle)); memset (r_lightstyle, 0, sizeof (r_lightstyle));
dstring_clearstr (centerprint); if (centerprint)
dstring_clearstr (centerprint);
} }
/* /*
@ -1172,17 +1174,47 @@ CL_SetState (cactive_t state)
void void
CL_Init (void) CL_Init (void)
{ {
CL_SetState (ca_disconnected); byte *basepal, *colormap;
Info_SetValueForStarKey (cls.userinfo, "*ver", QW_VERSION, 0); basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");
W_LoadWadFile ("gfx.wad");
VID_Init (basepal, colormap);
IN_Init (cl_cbuf);
Draw_Init ();
Mod_Init ();
R_Init ();
S_Init (&cl.worldmodel, &viewentity, &host_frametime);
CDAudio_Init ();
Sbar_Init ();
CL_Input_Init (); CL_Input_Init ();
CL_Ents_Init (); CL_Ents_Init ();
CL_TEnts_Init (); CL_TEnts_Init ();
CL_ClearState ();
Pmove_Init (); Pmove_Init ();
SL_Init (); SL_Init ();
CL_Skin_Init ();
Locs_Init ();
V_Init ();
Info_SetValueForStarKey (cls.userinfo, "*ver", QW_VERSION, 0);
centerprint = dstring_newstr ();
cls.servername = dstring_newstr ();
cls.downloadtempname = dstring_newstr ();
cls.downloadname = dstring_newstr ();
cls.downloadurl = dstring_newstr ();
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
// register our commands // register our commands
Cmd_AddCommand ("version", CL_Version_f, "Report version information"); Cmd_AddCommand ("version", CL_Version_f, "Report version information");
Cmd_AddCommand ("changing", CL_Changing_f, "Used when maps are changing"); Cmd_AddCommand ("changing", CL_Changing_f, "Used when maps are changing");
@ -1240,6 +1272,8 @@ CL_Init (void)
"server info"); "server info");
cl_player_health_e = GIB_Event_New ("player.health"); cl_player_health_e = GIB_Event_New ("player.health");
cl_chat_e = GIB_Event_New ("chat"); cl_chat_e = GIB_Event_New ("chat");
CL_SetState (ca_disconnected);
} }
static void static void
@ -1260,6 +1294,22 @@ cl_cmd_pkt_adr_f (cvar_t *var)
static void static void
CL_Init_Cvars (void) CL_Init_Cvars (void)
{ {
VID_Init_Cvars ();
IN_Init_Cvars ();
Mod_Init_Cvars ();
R_Init_Cvars ();
S_Init_Cvars ();
CL_Cam_Init_Cvars ();
CL_Input_Init_Cvars ();
CL_Prediction_Init_Cvars ();
Game_Init_Cvars ();
Pmove_Init_Cvars ();
Team_Init_Cvars ();
V_Init_Cvars ();
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
cl_model_crcs = Cvar_Get ("cl_model_crcs", "1", CVAR_ARCHIVE, NULL, cl_model_crcs = Cvar_Get ("cl_model_crcs", "1", CVAR_ARCHIVE, NULL,
"Controls setting of emodel and pmodel info " "Controls setting of emodel and pmodel info "
"vars. Required by some servers, but clearing " "vars. Required by some servers, but clearing "
@ -1691,6 +1741,8 @@ CL_Init_Memory (void)
Sys_PageIn (mem_base, mem_size); Sys_PageIn (mem_base, mem_size);
Memory_Init (mem_base, mem_size); Memory_Init (mem_base, mem_size);
Sys_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);
} }
static void static void
@ -1714,8 +1766,6 @@ CL_Autoexec (int phase)
void void
Host_Init (void) Host_Init (void)
{ {
byte *basepal, *colormap;
cl_cbuf = Cbuf_New (&id_interp); cl_cbuf = Cbuf_New (&id_interp);
cl_stbuf = Cbuf_New (&id_interp); cl_stbuf = Cbuf_New (&id_interp);
@ -1727,41 +1777,21 @@ Host_Init (void)
pr_gametype = "quakeworld"; pr_gametype = "quakeworld";
centerprint = dstring_newstr ();
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
cls.servername = dstring_newstr ();
cls.downloadtempname = dstring_newstr ();
cls.downloadname = dstring_newstr ();
cls.downloadurl = dstring_newstr ();
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
QFS_Init ("qw"); QFS_Init ("qw");
QFS_GamedirCallback (CL_Autoexec); QFS_GamedirCallback (CL_Autoexec);
PI_Init (); PI_Init ();
CL_Cam_Init_Cvars ();
CL_Input_Init_Cvars ();
CL_Init_Cvars ();
CL_Prediction_Init_Cvars ();
Game_Init_Cvars ();
IN_Init_Cvars ();
Key_Init_Cvars ();
Mod_Init_Cvars ();
Netchan_Init_Cvars (); Netchan_Init_Cvars ();
PR_Init_Cvars (); PR_Init_Cvars ();
Pmove_Init_Cvars ();
R_Init_Cvars (); CL_Init_Cvars ();
S_Init_Cvars ();
Team_Init_Cvars ();
V_Init_Cvars ();
VID_Init_Cvars ();
PR_Init (); PR_Init ();
CL_Chat_Init (); CL_Chat_Init ();
CL_Cmd_Init (); CL_Cmd_Init ();
V_Init ();
Game_Init (); Game_Init ();
PI_RegisterPlugins (client_plugin_list); PI_RegisterPlugins (client_plugin_list);
@ -1788,36 +1818,9 @@ Host_Init (void)
} }
CL_HTTP_Init (); CL_HTTP_Init ();
W_LoadWadFile ("gfx.wad");
Key_Init (cl_cbuf);
Mod_Init ();
CL_Demo_Init (); CL_Demo_Init ();
Sys_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);
basepal = (byte *) QFS_LoadHunkFile ("gfx/palette.lmp");
if (!basepal)
Sys_Error ("Couldn't load gfx/palette.lmp");
colormap = (byte *) QFS_LoadHunkFile ("gfx/colormap.lmp");
if (!colormap)
Sys_Error ("Couldn't load gfx/colormap.lmp");
VID_Init (basepal, colormap);
Draw_Init ();
SCR_Init ();
R_Init ();
S_Init (&cl.worldmodel, &viewentity, &host_frametime);
CDAudio_Init ();
Sbar_Init ();
CL_Init (); CL_Init ();
IN_Init ();
CL_SetState (ca_disconnected);
CL_Skin_Init ();
Locs_Init ();
CL_UpdateScreen (realtime); CL_UpdateScreen (realtime);
CL_UpdateScreen (realtime); CL_UpdateScreen (realtime);