mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Make Quake II compatible with unicode directory names
This changes employs a horrible hack to connect the ASCII Quake II to the UTF-16 WinAPI. The path to "My Documentes" is read in UTF-16, then converted to a old "DOS style path" with 8.3 characters. This DOS path has by convention no UTF-16 characters in it and can be converted into a normal ASCII string. This ASCII string is the path used by Yamagi Quake II. The conversion logic will fail if the "Windows to DOS filename transistion" is deactivated in the registry (it's on by default). In that case no homedir is used and the "Windows Roaming Mechanism" kicks in.
This commit is contained in:
parent
e3690bcaab
commit
c0e9a6f045
3 changed files with 40 additions and 18 deletions
16
TODO
16
TODO
|
@ -42,19 +42,7 @@ Long term TODO list for Quake II on Windows
|
|||
implementation is rather invasive into the console
|
||||
subsystem and I don't think that it's worth the efford.
|
||||
|
||||
4. The unicode issue:
|
||||
Quake II only allows ASCII characters, internally all
|
||||
characters are represented as "char". But Windows uses
|
||||
unicode quite often. This may lead to problems. The big
|
||||
question is: "What happens, if the path to the home dir
|
||||
contains unicode characters?" At what can we do to prevent
|
||||
problems without rewriting the whole game to be unicode
|
||||
aware? This may be a problem on Linux and FreeBSD too,
|
||||
but at least on FreeBSD unicode characters in the user-
|
||||
name are a bad idea and for things to work correctly
|
||||
the homedir-name should be the same as the username...
|
||||
|
||||
5. The debug / stdout issue:
|
||||
4. The debug / stdout issue:
|
||||
At the moment no stdout is readable on windows, the only
|
||||
way is to scroll in the console. This is a problem, because
|
||||
without the game output problems are hard to debug. Enabling
|
||||
|
@ -70,7 +58,7 @@ Long term TODO list for Quake II on Windows
|
|||
While I'm not sure that gdb can read Windows crashdumps,
|
||||
it may be worth to take a deeper look into this.
|
||||
|
||||
6. The CR-LF issue:
|
||||
5. The CR-LF issue:
|
||||
At the moment all files have LF line endings, which are
|
||||
incompatible with most Windows software. This isn't a
|
||||
problem for the code itself (at least with MinGW), but
|
||||
|
|
|
@ -55,7 +55,7 @@ typedef enum {false, true} qboolean;
|
|||
#define MAX_QPATH 64 /* max length of a quake game pathname */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MAX_OSPATH 256 /* max length of a filesystem pathname */
|
||||
#define MAX_OSPATH 256 /* max length of a filesystem pathname (same as MAX_PATH) */
|
||||
#else
|
||||
#define MAX_OSPATH 128 /* max length of a filesystem pathname */
|
||||
#endif
|
||||
|
|
|
@ -610,12 +610,46 @@ Sys_GetCurrentDirectory(void)
|
|||
char *
|
||||
Sys_GetHomeDir(void)
|
||||
{
|
||||
char *old;
|
||||
char *cur;
|
||||
char *old;
|
||||
char profile[MAX_PATH];
|
||||
int len;
|
||||
static char gdir[MAX_OSPATH];
|
||||
TCHAR profile[MAX_OSPATH];
|
||||
WCHAR sprofile[MAX_PATH];
|
||||
WCHAR uprofile[MAX_PATH];
|
||||
|
||||
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, profile);
|
||||
/* The following lines implement a horrible
|
||||
hack to connect the UTF-16 WinAPI to the
|
||||
ASCII Quake II. While this should work in
|
||||
most cases, it'll fail if the "Windows to
|
||||
DOS filename translation" is switched off.
|
||||
In that case the function will return NULL
|
||||
and no homedir is used. */
|
||||
|
||||
/* Get the path to "My Documents" directory */
|
||||
SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, uprofile);
|
||||
|
||||
/* Create a UTF-16 DOS path */
|
||||
len = GetShortPathNameW(uprofile, sprofile, sizeof(sprofile));
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Since the DOS path contains no UTF-16 characters, just convert it to ASCII */
|
||||
WideCharToMultiByte(CP_ACP, 0, sprofile, -1, profile, sizeof(profile), NULL, NULL);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Check if path is too long */
|
||||
if ((len + strlen(CFGDIR) -1) >= 256)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Replace backslashes by slashes */
|
||||
cur = old = profile;
|
||||
|
|
Loading…
Reference in a new issue