-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if the requested game exists (Game change command) #101
Conversation
@ericwa , @andrei-drexler : What do you think? |
Left a note above until others speak their minds. Another note: If this is to be accepted, do we not error out during first launch time if a non-existent directory name is given with |
That seems to be handled elsewhere. I tested this and the change in |
Yes, I know, but a non-existent gamedir is not created either, and who knows maybe there is a good reason for it: What I'm asking is should we error out in such a case of non-existing gamedir - would that be a good or a bad idea? |
Another thing of concern is whether the build supports userdirs, e.g. diff --git a/Quake/common.c b/Quake/common.c
index e53cdf6..d32ae31 100644
--- a/Quake/common.c
+++ b/Quake/common.c
@@ -2164,6 +2164,7 @@ static void COM_Game_f (void)
const char *p = Cmd_Argv(1);
const char *p2 = Cmd_Argv(2);
searchpath_t *search;
+ int exists;
if (!registered.value) //disable shareware quake
{
@@ -2188,8 +2189,11 @@ static void COM_Game_f (void)
return;
}
}
-
- if (Sys_FileType(va("%s/%s", com_basedir, p)) != FS_ENT_DIRECTORY)
+
+ exists = Sys_FileType(va("%s/%s", com_basedir, p)) == FS_ENT_DIRECTORY;
+ if (!exists && host_parms->userdir != host_parms->basedir)
+ exists = Sys_FileType(va("%s/%s", host_parms->userdir, p)) == FS_ENT_DIRECTORY;
+ if (!exists)
{
Con_Printf("The game \"%s\" couldn't be found.\n", p);
return; (This seems to have more complications than it sounds...) |
Yeah that's right.. I guess this needs a lot more careful consideration than I initially thought. |
I tested your patch @sezero. It works on my Linux machine. And just like before, in this case the va's can also be used directly without requiring the diff --git a/Quake/common.c b/Quake/common.c
index 5e32afa6..39b38650 100644
--- a/Quake/common.c
+++ b/Quake/common.c
@@ -2189,6 +2189,15 @@ static void COM_Game_f (void)
}
}
+ if (Sys_FileType(va("%s/%s", com_basedir, p)) != FS_ENT_DIRECTORY)
+ {
+ if (host_parms->userdir != host_parms->basedir && (Sys_FileType(va("%s/%s", host_parms->userdir, p)) != FS_ENT_DIRECTORY))
+ {
+ Con_Printf("The game \"%s\" couldn't be found.\n", p);
+ return;
+ }
+ }
+
if (!q_strcasecmp(p, COM_SkipPath(com_gamedir))) //no change
{
if (com_searchpaths->path_id > 1) { //current game not id1 Any comments or objections to that @sezero? |
Not yet :) But I'd like to hear what others have to say to all this |
Alright, I'll keep those patches on separate branches until more is known. |
Well, I seem to have lied: The patch above is broken. It should read like the following instead: diff --git a/Quake/common.c b/Quake/common.c
index 5e32afa..87f3e48 100644
--- a/Quake/common.c
+++ b/Quake/common.c
@@ -2189,6 +2189,15 @@ static void COM_Game_f (void)
}
}
+ if (Sys_FileType(va("%s/%s", com_basedir, p)) != FS_ENT_DIRECTORY)
+ {
+ if (host_parms->userdir == host_parms->basedir || (Sys_FileType(va("%s/%s", host_parms->userdir, p)) != FS_ENT_DIRECTORY))
+ {
+ Con_Printf ("No such game directory \"%s\"\n", p);
+ return;
+ }
+ }
+
if (!q_strcasecmp(p, COM_SkipPath(com_gamedir))) //no change
{
if (com_searchpaths->path_id > 1) { //current game not id1 |
Right.. the other patch would fail if |
Yes |
Co-authored-by: Ozkan Sezer <[email protected]>
Well, no one else seems to be interested in qs dev anymore, so I just went ahead and applied this patch. Thanks. |
Context
Closely related to issue #84, which I closed based on input from @Shpoike and @ericwa, who suggested that my patch (proposed in #84) would cause problems due to inconsistency in naming for assets from various Quake releases, which I ended up agreeing with (apologies for not clarifying that before closing the issue).
Patch
I want to propose a different solution that does not use case sensitivity to compare the requested game name with the current one, but rather cancels the command if no matching game directory was found in the first place (briefly mentioned in #84).
I used
<filetype> != FS_ENT_DIRECTORY
to make sure that it cancels only if the path does not point to an existing directory (also works for symbolic links on Linux).This patch aims to prevent situations where #84 would become a hindrance in Unix-based environments.
Testing
Should load the game if the directory was found by
Sys_FileType
or printThe game "<name>" couldn't be found.
No such game directory "<name>"
if not.Edit: try this for both cases where user dirs are enabled and disabled (build with
DO_USERDIRS=1
to enable).Notes
stat
implementation ofSys_FileType
, similar to the Linux build).