mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 04:21:51 +00:00
[console] Separate loading and initialization
This will make it easy for client code to set up data needed by the console before the console initializes. It already separates console cvar setup and initialization, which has generally been a good thing.
This commit is contained in:
parent
06fdef52e8
commit
68c7003991
11 changed files with 49 additions and 24 deletions
|
@ -545,9 +545,10 @@ main (int argc, const char **argv)
|
|||
|
||||
Cvar_Register (&sv_console_plugin_cvar, 0, 0);
|
||||
PI_RegisterPlugins (server_plugin_list);
|
||||
Con_Init (sv_console_plugin);
|
||||
Con_Load (sv_console_plugin);
|
||||
if (con_module)
|
||||
con_module->data->console->cbuf = mst_cbuf;
|
||||
Con_Init ();
|
||||
con_list_print = Sys_Printf;
|
||||
|
||||
SV_InitNet ();
|
||||
|
|
|
@ -90,7 +90,8 @@ void Con_BufferAddText (con_buffer_t *buf, const char *text);
|
|||
void Con_ClearBuffer (con_buffer_t *buffer);
|
||||
|
||||
// init/shutdown functions
|
||||
void Con_Init (const char *plugin_name);
|
||||
void Con_Load (const char *plugin_name);
|
||||
void Con_Init (void);
|
||||
void Con_ExecLine (const char *line);
|
||||
|
||||
void Con_ProcessInput (void);
|
||||
|
|
|
@ -1014,6 +1014,17 @@ Condump_f (void)
|
|||
Qclose (file);
|
||||
}
|
||||
|
||||
static void
|
||||
C_InitCvars (void)
|
||||
{
|
||||
Cvar_Register (&con_notifytime_cvar, 0, 0);
|
||||
Cvar_Register (&con_scale_cvar, con_scale_f, 0);
|
||||
Cvar_Register (&con_alpha_cvar, 0, 0);
|
||||
Cvar_Register (&con_size_cvar, 0, 0);
|
||||
Cvar_Register (&con_speed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_conmode_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
|
@ -1032,14 +1043,6 @@ C_Init (void)
|
|||
|
||||
Menu_Init ();
|
||||
|
||||
Cvar_Register (&con_notifytime_cvar, 0, 0);
|
||||
|
||||
Cvar_Register (&con_scale_cvar, con_scale_f, 0);
|
||||
Cvar_Register (&con_alpha_cvar, 0, 0);
|
||||
Cvar_Register (&con_size_cvar, 0, 0);
|
||||
Cvar_Register (&con_speed_cvar, 0, 0);
|
||||
Cvar_Register (&cl_conmode_cvar, 0, 0);
|
||||
|
||||
con_debuglog = COM_CheckParm ("-condebug");
|
||||
|
||||
// The console will get resized, so assume initial size is 320x200
|
||||
|
@ -1185,11 +1188,12 @@ C_shutdown (void)
|
|||
}
|
||||
|
||||
static general_funcs_t plugin_info_general_funcs = {
|
||||
.init = C_Init,
|
||||
.init = C_InitCvars,
|
||||
.shutdown = C_shutdown,
|
||||
};
|
||||
|
||||
static console_funcs_t plugin_info_console_funcs = {
|
||||
.init = C_Init,
|
||||
.print = C_Print,
|
||||
.draw_console = C_DrawConsole,
|
||||
.new_map = C_NewMap,
|
||||
|
|
|
@ -108,16 +108,23 @@ Con_shutdown (void *data)
|
|||
}
|
||||
|
||||
VISIBLE void
|
||||
Con_Init (const char *plugin_name)
|
||||
Con_Load (const char *plugin_name)
|
||||
{
|
||||
Sys_RegisterShutdown (Con_shutdown, 0);
|
||||
|
||||
con_module = PI_LoadPlugin ("console", plugin_name);
|
||||
if (!con_module) {
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Con_Init (void)
|
||||
{
|
||||
if (con_module) {
|
||||
__auto_type funcs = con_module->functions->console;
|
||||
funcs->init ();
|
||||
saved_sys_printf = Sys_SetStdPrintf (funcs->print);
|
||||
} else {
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
}
|
||||
Cvar_Register (&con_interpreter_cvar, Con_Interp_f, 0);
|
||||
}
|
||||
|
|
|
@ -776,9 +776,16 @@ sv_exec_line_chat (void *data, const char *line)
|
|||
}
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
C_InitCvars (void)
|
||||
{
|
||||
Cvar_Register (&sv_use_curses_cvar, 0, 0);
|
||||
Cvar_Register (&sv_logfile_cvar, sv_logfile_f, 0);
|
||||
Cvar_Register (&sv_conmode_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
C_Init (void)
|
||||
{
|
||||
#ifdef HAVE_NCURSES
|
||||
use_curses = sv_use_curses;
|
||||
if (use_curses) {
|
||||
|
@ -786,8 +793,6 @@ C_Init (void)
|
|||
} else
|
||||
#endif
|
||||
setvbuf (stdout, 0, _IOLBF, BUFSIZ);
|
||||
Cvar_Register (&sv_logfile_cvar, sv_logfile_f, 0);
|
||||
Cvar_Register (&sv_conmode_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -863,12 +868,13 @@ C_NewMap (void)
|
|||
}
|
||||
|
||||
static general_funcs_t plugin_info_general_funcs = {
|
||||
.init = C_Init,
|
||||
.init = C_InitCvars,
|
||||
.shutdown = C_shutdown,
|
||||
};
|
||||
static general_data_t plugin_info_general_data;
|
||||
|
||||
static console_funcs_t plugin_info_console_funcs = {
|
||||
.init = C_Init,
|
||||
.print = C_Print,
|
||||
.process_input = C_ProcessInput,
|
||||
.draw_console = C_DrawConsole,
|
||||
|
|
|
@ -708,8 +708,9 @@ CL_Init (cbuf_t *cbuf)
|
|||
S_Init (&cl.viewentity, &host_frametime);
|
||||
|
||||
PI_RegisterPlugins (client_plugin_list);
|
||||
Con_Init ("client");
|
||||
Con_Load ("client");
|
||||
CL_Init_Screen ();
|
||||
Con_Init ();
|
||||
|
||||
CDAudio_Init ();
|
||||
|
||||
|
|
|
@ -926,7 +926,8 @@ Host_Init (void)
|
|||
|
||||
if (isDedicated) {
|
||||
PI_RegisterPlugins (server_plugin_list);
|
||||
Con_Init ("server");
|
||||
Con_Load ("server");
|
||||
Con_Init ();
|
||||
}
|
||||
|
||||
Host_InitVCR (&host_parms);
|
||||
|
|
|
@ -297,9 +297,10 @@ qtv_init (void)
|
|||
|
||||
Cvar_Register (&qtv_console_plugin_cvar, 0, 0);
|
||||
PI_RegisterPlugins (server_plugin_list);
|
||||
Con_Init (qtv_console_plugin);
|
||||
Con_Load (qtv_console_plugin);
|
||||
if (con_module)
|
||||
con_module->data->console->cbuf = qtv_cbuf;
|
||||
Con_Init ();
|
||||
Sys_SetStdPrintf (qtv_print);
|
||||
|
||||
qtv_sbar_init ();
|
||||
|
|
|
@ -1461,7 +1461,7 @@ CL_Init (void)
|
|||
r_data->lightstyle = cl.lightstyle;
|
||||
|
||||
PI_RegisterPlugins (client_plugin_list);
|
||||
Con_Init ("client");
|
||||
Con_Load ("client");
|
||||
CL_Init_Screen ();
|
||||
if (con_module) {
|
||||
con_module->data->console->dl_name = cls.downloadname;
|
||||
|
@ -1473,6 +1473,7 @@ CL_Init (void)
|
|||
Cbuf_DeleteStack (con_module->data->console->cbuf);
|
||||
con_module->data->console->cbuf = cl_cbuf;
|
||||
}
|
||||
Con_Init ();
|
||||
CL_NetGraph_Init ();
|
||||
|
||||
S_Init (&cl.viewentity, &host_frametime);
|
||||
|
|
|
@ -2691,9 +2691,10 @@ SV_Init (void)
|
|||
|
||||
Cvar_Register (&sv_console_plugin_cvar, 0, 0);
|
||||
PI_RegisterPlugins (server_plugin_list);
|
||||
Con_Init (sv_console_plugin);
|
||||
Con_Load (sv_console_plugin);
|
||||
if (con_module)
|
||||
con_module->data->console->cbuf = sv_cbuf;
|
||||
Con_Init ();
|
||||
con_list_print = Sys_Printf;
|
||||
Sys_SetStdPrintf (SV_Print);
|
||||
Sys_SetErrPrintf (SV_Error);
|
||||
|
|
|
@ -354,7 +354,7 @@ BI_Graphics_Init (progs_t *pr)
|
|||
event_handler_id = IE_Add_Handler (event_handler, pr);
|
||||
IE_Set_Focus (event_handler_id);
|
||||
|
||||
Con_Init ("client");
|
||||
Con_Load ("client");
|
||||
if (con_module) {
|
||||
con_module->data->console->realtime = &con_realtime;
|
||||
con_module->data->console->frametime = &con_frametime;
|
||||
|
@ -363,6 +363,7 @@ BI_Graphics_Init (progs_t *pr)
|
|||
//con_module->data->console->screen_view = r_data->scr_view;
|
||||
}
|
||||
//Key_SetKeyDest (key_game);
|
||||
Con_Init ();
|
||||
|
||||
S_Init (0, &con_frametime);
|
||||
//CDAudio_Init ();
|
||||
|
|
Loading…
Reference in a new issue