mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-06-04 18:40:51 +00:00
[qw] Switch quakeforge.cfg to property list format
Cvars aren't handled yet, but input configuration is. Seems to work :)
This commit is contained in:
parent
fede9125e1
commit
8cf0d00eda
2 changed files with 63 additions and 6 deletions
|
@ -34,6 +34,7 @@
|
||||||
|
|
||||||
void CL_Init (void);
|
void CL_Init (void);
|
||||||
void Host_WriteConfiguration (void);
|
void Host_WriteConfiguration (void);
|
||||||
|
int Host_ReadConfiguration (const char *cfg_name);
|
||||||
|
|
||||||
void CL_EstablishConnection (const char *host);
|
void CL_EstablishConnection (const char *host);
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,9 @@
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
|
#include "QF/quakeio.h"
|
||||||
#include "QF/ruamoko.h"
|
#include "QF/ruamoko.h"
|
||||||
|
#include "QF/plist.h"
|
||||||
#include "QF/screen.h"
|
#include "QF/screen.h"
|
||||||
#include "QF/sound.h"
|
#include "QF/sound.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
@ -1504,18 +1506,72 @@ void
|
||||||
Host_WriteConfiguration (void)
|
Host_WriteConfiguration (void)
|
||||||
{
|
{
|
||||||
if (host_initialized && cl_writecfg->int_val) {
|
if (host_initialized && cl_writecfg->int_val) {
|
||||||
|
plitem_t *config = PL_NewDictionary (0); //FIXME hashlinks
|
||||||
|
IN_SaveConfig (config);
|
||||||
|
//Cvar_WriteVariables (f);
|
||||||
|
|
||||||
const char *path = va (0, "%s/quakeforge.cfg", qfs_gamedir->dir.def);
|
const char *path = va (0, "%s/quakeforge.cfg", qfs_gamedir->dir.def);
|
||||||
QFile *f = QFS_WOpen (path, 0);
|
QFile *f = QFS_WOpen (path, 0);
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
Sys_Printf ("Couldn't write quakeforge.cfg.\n");
|
Sys_Printf ("Couldn't write quakeforge.cfg.\n");
|
||||||
return;
|
} else {
|
||||||
|
char *cfg = PL_WritePropertyList (config);
|
||||||
|
Qputs (f, cfg);
|
||||||
|
free (cfg);
|
||||||
|
Qclose (f);
|
||||||
|
}
|
||||||
|
PL_Free (config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Host_ReadConfiguration (const char *cfg_name)
|
||||||
|
{
|
||||||
|
QFile *cfg_file = QFS_FOpenFile (cfg_name);
|
||||||
|
if (!cfg_file) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
size_t len = Qfilesize (cfg_file);
|
||||||
|
char *cfg = malloc (len + 1);
|
||||||
|
Qread (cfg_file, cfg, len);
|
||||||
|
cfg[len] = 0;
|
||||||
|
Qclose (cfg_file);
|
||||||
|
|
||||||
|
plitem_t *config = PL_GetPropertyList (cfg, 0); // FIXME hashlinks
|
||||||
|
if (!config) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Key_WriteBindings (f);
|
IN_LoadConfig (config);
|
||||||
Cvar_WriteVariables (f);
|
|
||||||
|
|
||||||
Qclose (f);
|
PL_Free (config);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
Host_ExecConfig (cbuf_t *cbuf, int skip_quakerc)
|
||||||
|
{
|
||||||
|
// quakeforge.cfg overrides quake.rc as it contains quakeforge-specific
|
||||||
|
// commands. If it doesn't exist, then this is the first time quakeforge
|
||||||
|
// has been used in this installation, thus any existing legacy config
|
||||||
|
// should be used to set up defaults on the assumption that the user has
|
||||||
|
// things set up to work with another (hopefully compatible) client
|
||||||
|
if (Host_ReadConfiguration ("quakeforge.cfg")) {
|
||||||
|
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||||
|
Cmd_StuffCmds (cbuf);
|
||||||
|
COM_Check_quakerc ("startdemos", cbuf);
|
||||||
|
} else {
|
||||||
|
if (!skip_quakerc) {
|
||||||
|
Cbuf_InsertText (cbuf, "exec quake.rc\n");
|
||||||
|
}
|
||||||
|
Cmd_Exec_File (cbuf, fs_usercfg->string, 0);
|
||||||
|
// Reparse the command line for + commands.
|
||||||
|
// (sets still done, but it doesn't matter)
|
||||||
|
// (Note, no non-base commands exist yet)
|
||||||
|
if (skip_quakerc || !COM_Check_quakerc ("stuffcmds", 0)) {
|
||||||
|
Cmd_StuffCmds (cbuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1741,7 +1797,7 @@ CL_Autoexec (int phase)
|
||||||
{
|
{
|
||||||
if (!phase)
|
if (!phase)
|
||||||
return;
|
return;
|
||||||
if (!Cmd_Exec_File (cl_cbuf, "quakeforge.cfg", 1)) {
|
if (!Host_ReadConfiguration ("quakeforge.cfg")) {
|
||||||
int cmd_warncmd_val = cmd_warncmd->int_val;
|
int cmd_warncmd_val = cmd_warncmd->int_val;
|
||||||
|
|
||||||
Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
|
Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
|
||||||
|
@ -1806,7 +1862,7 @@ Host_Init (void)
|
||||||
CL_UpdateScreen (realtime);
|
CL_UpdateScreen (realtime);
|
||||||
CL_UpdateScreen (realtime);
|
CL_UpdateScreen (realtime);
|
||||||
|
|
||||||
COM_ExecConfig (cl_cbuf, !cl_quakerc->int_val);
|
Host_ExecConfig (cl_cbuf, !cl_quakerc->int_val);
|
||||||
|
|
||||||
// make sure all + commands have been executed
|
// make sure all + commands have been executed
|
||||||
Cbuf_Execute_Stack (cl_cbuf);
|
Cbuf_Execute_Stack (cl_cbuf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue