Rework our fallback defaults to override id1's too, so newbies don't need to rebind everything before playing.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6069 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-10-05 05:05:34 +00:00
parent f353f55024
commit 8ec36b7ab4
5 changed files with 116 additions and 65 deletions

View file

@ -425,8 +425,6 @@ void CL_MakeActive(char *gamename)
else else
TP_ExecTrigger("f_spawn", false); TP_ExecTrigger("f_spawn", false);
Key_EnsureBinds();
#ifdef __GLIBC__ #ifdef __GLIBC__
malloc_trim(0); malloc_trim(0);
#endif #endif
@ -6770,7 +6768,6 @@ void CL_ExecInitialConfigs(char *resetcommand)
// int cfg = COM_FDepthFile ("config.cfg", true); // int cfg = COM_FDepthFile ("config.cfg", true);
int q3cfg = COM_FDepthFile ("q3config.cfg", true); int q3cfg = COM_FDepthFile ("q3config.cfg", true);
// Cbuf_AddText ("bind ` toggleconsole\n", RESTRICT_LOCAL); //in case default.cfg does not exist. :( // Cbuf_AddText ("bind ` toggleconsole\n", RESTRICT_LOCAL); //in case default.cfg does not exist. :(
if (def!=FDEPTH_MISSING)
Cbuf_AddText ("exec default.cfg\n", RESTRICT_LOCAL); Cbuf_AddText ("exec default.cfg\n", RESTRICT_LOCAL);
if (q3cfg <= def && q3cfg!=FDEPTH_MISSING) if (q3cfg <= def && q3cfg!=FDEPTH_MISSING)
Cbuf_AddText ("exec q3config.cfg\n", RESTRICT_LOCAL); Cbuf_AddText ("exec q3config.cfg\n", RESTRICT_LOCAL);

View file

@ -2778,46 +2778,6 @@ void Key_WriteBindings (vfsfile_t *f)
} }
} }
void Key_EnsureBinds(void)
{
int i, m;
for (i=0 ; i<=K_AUX16 ; i++)
{
for (m = 0; m < KEY_MODIFIERSTATES; m++)
{
if (keybindings[i][m])
return;
}
}
Key_SetBinding ('`', ~0, "toggleconsole", RESTRICT_LOCAL);
Key_SetBinding ('w', ~0, "+forward", RESTRICT_LOCAL);
Key_SetBinding ('s', ~0, "+back", RESTRICT_LOCAL);
Key_SetBinding ('a', ~0, "+moveleft", RESTRICT_LOCAL);
Key_SetBinding ('d', ~0, "+moveright", RESTRICT_LOCAL);
Key_SetBinding (K_MOUSE1, ~0, "+attack", RESTRICT_LOCAL);
Key_SetBinding (K_MOUSE2, ~0, "+jump", RESTRICT_LOCAL);
Key_SetBinding (K_SPACE, ~0, "+jump", RESTRICT_LOCAL);
Key_SetBinding ('c', ~0, "+movedown", RESTRICT_LOCAL);
Key_SetBinding ('v', ~0, "+voip", RESTRICT_LOCAL);
Key_SetBinding ('t', ~0, "messagemode2", RESTRICT_LOCAL);
Key_SetBinding ('y', ~0, "messagemode", RESTRICT_LOCAL);
Key_SetBinding (K_TAB, ~0, "+showscores", RESTRICT_LOCAL);
Key_SetBinding (K_MWHEELUP, ~0, "impulse 12", RESTRICT_LOCAL);
Key_SetBinding (K_MWHEELDOWN, ~0, "impulse 10", RESTRICT_LOCAL);
Key_SetBinding ('1', ~0, "impulse 1", RESTRICT_LOCAL);
Key_SetBinding ('2', ~0, "impulse 2", RESTRICT_LOCAL);
Key_SetBinding ('3', ~0, "impulse 3", RESTRICT_LOCAL);
Key_SetBinding ('4', ~0, "impulse 4", RESTRICT_LOCAL);
Key_SetBinding ('5', ~0, "impulse 5", RESTRICT_LOCAL);
Key_SetBinding ('6', ~0, "impulse 6", RESTRICT_LOCAL);
Key_SetBinding ('7', ~0, "impulse 7", RESTRICT_LOCAL);
Key_SetBinding ('8', ~0, "impulse 8", RESTRICT_LOCAL);
Key_SetBinding (K_RSHIFT, ~0, "+speed", RESTRICT_LOCAL);
}
/* /*
=================== ===================
Key_Init Key_Init

View file

@ -321,7 +321,6 @@ void IN_WriteButtons(vfsfile_t *f, qboolean all);
void Key_WriteBindings (struct vfsfile_s *f); void Key_WriteBindings (struct vfsfile_s *f);
void Key_SetBinding (int keynum, int modifier, const char *binding, int cmdlevel); void Key_SetBinding (int keynum, int modifier, const char *binding, int cmdlevel);
void Key_ClearStates (void); void Key_ClearStates (void);
void Key_EnsureBinds(void);
qboolean Key_Centerprint(int key, int unicode, unsigned int devid); qboolean Key_Centerprint(int key, int unicode, unsigned int devid);
void Key_Unbindall_f (void); //aka: Key_Shutdown void Key_Unbindall_f (void); //aka: Key_Shutdown
void Key_ConsoleReplace(const char *instext); void Key_ConsoleReplace(const char *instext);

View file

@ -1418,6 +1418,9 @@ void M_DeInit_Internal (void)
Cmd_RemoveCommand ("menu_particles"); Cmd_RemoveCommand ("menu_particles");
Cmd_RemoveCommand ("menu_network"); Cmd_RemoveCommand ("menu_network");
#ifdef HAVE_LEGACY
Cmd_RemoveCommand ("menu_credits");
#endif
Cmd_RemoveCommand ("menu_main"); //I've moved main to last because that way tab gives us main and not quit. Cmd_RemoveCommand ("menu_main"); //I've moved main to last because that way tab gives us main and not quit.
Cmd_RemoveCommand ("quickconnect"); Cmd_RemoveCommand ("quickconnect");

View file

@ -638,6 +638,69 @@ void Cmd_StuffCmds (void)
Z_Free (build); Z_Free (build);
} }
#if defined(HAVE_LEGACY) && defined(HAVE_CLIENT)
static const char *replacementq1binds =
"unbindall\n"
"bind ` toggleconsole\n"
"bind w +forward\n"
"bind s +back\n"
"bind a +moveleft\n"
"bind d +moveright\n"
"bind MOUSE1 +attack\n"
"bind MOUSE2 +jump\n"
"bind SPACE +jump\n"
"bind v +voip\n"
"bind t messagemode2\n"
"bind y messagemode\n"
"bind TAB +showscores\n"
"bind e +moveup\n"
"bind c +movedown\n"
"bind MWHEELUP impulse 12\n"
"bind MWHEELDOWN impulse 10\n"
"bind UPARROW +forward\n"
"bind DOWNARROW +back\n"
"bind LEFTARROW +left\n"
"bind RIGHTARROW +right\n"
"bind LCTRL +attack\n"
"bind RCTRL +attack\n"
"bind LALT +strafe\n"
"bind RALT +strafe\n"
"bind LSHIFT +speed\n"
"bind RSHIFT +speed\n"
"bind + sizeup\n"
"bind - sizedown\n"
"bind 1 impulse 1\n"
"bind 2 impulse 2\n"
"bind 3 impulse 3\n"
"bind 4 impulse 4\n"
"bind 5 impulse 5\n"
"bind 6 impulse 6\n"
"bind 7 impulse 7\n"
"bind 8 impulse 8\n"
// "bind 9 impulse 9\n"
// "bind 0 impulse 10\n"
// "bind F1 help\n"
"bind F2 menu_save\n"
"bind F3 menu_load\n"
"bind F4 menu_options\n"
"bind F5 menu_multiplayer\n"
"bind F6 save quick\n"
// "bind F7
// "bind F8
"bind F9 load quick\n"
"bind F10 menu_quit\n"
// "bind F11 +zoom\n"
"bind F12 screenshot\n"
;
#endif
/* /*
=============== ===============
@ -728,24 +791,14 @@ static void Cmd_Exec_f (void)
return; return;
} }
if (!FS_FLocateFile(name, FSLF_IFFOUND|FSLF_IGNOREPURE, &loc) && !FS_FLocateFile(va("%s.cfg", name), FSLF_IFFOUND, &loc)) if (FS_FLocateFile(name, FSLF_IFFOUND|FSLF_IGNOREPURE, &loc) || FS_FLocateFile(va("%s.cfg", name), FSLF_IFFOUND, &loc))
{ {
Con_TPrintf ("couldn't exec %s\n", name);
return;
}
file = FS_OpenReadLocation(name, &loc); file = FS_OpenReadLocation(name, &loc);
if (!file) if (!file)
{ {
Con_TPrintf ("couldn't exec %s. check permissions.\n", name); Con_TPrintf ("couldn't exec %s. check permissions.\n", name);
return; return;
} }
if (cl_warncmd.ival || developer.ival || cvar_watched || dpcompat_console.ival)
{
if (loc.search)
Con_TPrintf ("execing ^[^7%s\\tip\\from %s/%s^]\n", name, loc.search->logicalpath, name);
else
Con_TPrintf ("execing %s\n", name);
}
l = VFS_GETLEN(file); l = VFS_GETLEN(file);
f = BZ_Malloc(l+1); f = BZ_Malloc(l+1);
@ -754,8 +807,30 @@ static void Cmd_Exec_f (void)
VFS_CLOSE(file); VFS_CLOSE(file);
untrusted = !!(loc.search->flags&SPF_UNTRUSTED); untrusted = !!(loc.search->flags&SPF_UNTRUSTED);
}
#if defined(HAVE_LEGACY) && defined(HAVE_CLIENT)
else if (!strcmp(name, "default.cfg")) //the q1 rerelease lacks a default.cfg (which I suppose is kinda handy, but oh well)
{
f = Z_StrDup(replacementq1binds);
untrusted = false;
l = 0;
}
#endif
else
{
Con_TPrintf ("couldn't exec %s\n", name);
return;
}
level = ((Cmd_FromGamecode() || untrusted) ? RESTRICT_INSECURE : Cmd_ExecLevel); level = ((Cmd_FromGamecode() || untrusted) ? RESTRICT_INSECURE : Cmd_ExecLevel);
if (cl_warncmd.ival || developer.ival || cvar_watched || dpcompat_console.ival)
{
if (loc.search)
Con_TPrintf ("execing ^[^7%s\\tip\\from %s/%s^]\n", name, loc.search->logicalpath, name);
else
Con_TPrintf ("execing %s\n", name);
}
s = f; s = f;
if (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf') if (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf')
{ {
@ -789,8 +864,10 @@ static void Cmd_Exec_f (void)
if (*loc.rawname) if (*loc.rawname)
COM_QuotedString(loc.rawname, buf, sizeof(buf), false); COM_QuotedString(loc.rawname, buf, sizeof(buf), false);
else else if (loc.search)
COM_QuotedString(va("%s/%s", loc.search->logicalpath, name), buf, sizeof(buf), false); COM_QuotedString(va("%s/%s", loc.search->logicalpath, name), buf, sizeof(buf), false);
else
COM_QuotedString(name, buf, sizeof(buf), false);
if (cvar_watched) if (cvar_watched)
Cbuf_InsertText (va("echo END %s", buf), level, true); Cbuf_InsertText (va("echo END %s", buf), level, true);
@ -801,6 +878,11 @@ static void Cmd_Exec_f (void)
Cbuf_InsertText ("\ncvar_lockdefaults 1\n", level, false); Cbuf_InsertText ("\ncvar_lockdefaults 1\n", level, false);
if (fs_manifest->defaultoverrides) if (fs_manifest->defaultoverrides)
Cbuf_InsertText (fs_manifest->defaultoverrides, level, false); Cbuf_InsertText (fs_manifest->defaultoverrides, level, false);
#if defined(HAVE_LEGACY) && defined(HAVE_CLIENT)
if (l == 1914 && Com_BlockChecksum(f, l) == 0x2d7b72b9)
s = (char*)replacementq1binds;
#endif
} }
#ifndef QUAKETC #ifndef QUAKETC
//hack to try to work around nquake's b0rkedness //hack to try to work around nquake's b0rkedness
@ -852,10 +934,20 @@ static void Cmd_Exec_f (void)
#ifdef HAVE_CLIENT #ifdef HAVE_CLIENT
if (!cl_warncmd.ival && foundone && (!strcmp(name, "quake.rc") || !strcmp(name, "default.cfg") || !strcmp(name, "autoexec.cfg"))) if (!cl_warncmd.ival && foundone && (!strcmp(name, "quake.rc") || !strcmp(name, "default.cfg") || !strcmp(name, "autoexec.cfg")))
{ {
#if defined(HAVE_LEGACY) && defined(HAVE_CLIENT)
if (!strcmp(name, "default.cfg"))
{
s = (char*)replacementq1binds;
foundone = 0;
}
else
#endif
{
Menu_Prompt(NULL, NULL, va("WARNING: nquake %s file detected. The file has been ignored.", name), NULL, NULL, "Argh"); Menu_Prompt(NULL, NULL, va("WARNING: nquake %s file detected. The file has been ignored.", name), NULL, NULL, "Argh");
*s = 0; *s = 0;
foundone = 0; foundone = 0;
} }
}
#endif #endif
Cbuf_InsertText (s, level, true); Cbuf_InsertText (s, level, true);