From 05644d07b46472090dc2fddd9f581b7e895cac7a Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 21 Nov 2013 23:16:59 +0000 Subject: [PATCH] fixes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4525 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_win.c | 78 ++++--------------------------- engine/common/fs_win32.c | 69 ++++++++++++++++++++++++++- engine/common/pr_bgcmd.c | 2 +- engine/dotnet2005/ftequake.vcproj | 9 ++++ engine/server/sv_sys_win.c | 2 +- 5 files changed, 88 insertions(+), 72 deletions(-) diff --git a/engine/client/sys_win.c b/engine/client/sys_win.c index 35c423fa5..6db66e561 100644 --- a/engine/client/sys_win.c +++ b/engine/client/sys_win.c @@ -676,73 +676,8 @@ FILE IO */ -wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8) -{ - wchar_t *ret = out; - //utf-8 to utf-16, not ucs-2. - unsigned int codepoint; - int error; - if (!outlen) - return L""; - outlen /= sizeof(wchar_t); - outlen--; - while (*utf8) - { - codepoint = utf8_decode(&error, utf8, (void*)&utf8); - if (error) - codepoint = 0xFFFDu; - if (codepoint > 0xffff) - { - if (outlen < 2) - break; - outlen -= 2; - codepoint -= 0x10000u; - *out++ = 0xD800 | (codepoint>>10); - *out++ = 0xDC00 | (codepoint&0x3ff); - } - else - { - if (outlen < 1) - break; - outlen -= 1; - *out++ = codepoint; - } - } - *out = 0; - return ret; -} - -char *narrowen(char *out, size_t outlen, wchar_t *wide) -{ - char *ret = out; - int bytes; - unsigned int codepoint; - if (!outlen) - return ""; - outlen--; - //utf-8 to utf-16, not ucs-2. - while (*wide) - { - codepoint = *wide++; - if (codepoint >= 0xD800u && codepoint <= 0xDBFFu) - { //handle utf-16 surrogates - if (*wide >= 0xDC00u && *wide <= 0xDFFFu) - { - codepoint = (codepoint&0x3ff)<<10; - codepoint |= *wide++ & 0x3ff; - } - else - codepoint = 0xFFFDu; - } - bytes = utf8_encode(out, codepoint, outlen); - if (bytes <= 0) - break; - out += bytes; - outlen -= bytes; - } - *out = 0; - return ret; -} +wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8); +char *narrowen(char *out, size_t outlen, wchar_t *wide); void Sys_mkdir (char *path) { @@ -2733,7 +2668,14 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin setjmp (restart_jmpbuf); #endif - GetModuleFileName(NULL, bindir, sizeof(bindir)-1); + if (WinNT) + { + wchar_t widebindir[1024]; + GetModuleFileNameW(NULL, widebindir, sizeof(widebindir)/sizeof(widebindir[0])-1); + narrowen(bindir, sizeof(bindir)-1, widebindir); + } + else + GetModuleFileNameA(NULL, bindir, sizeof(bindir)-1); Q_strncpyz(exename, bindir, sizeof(exename)); *COM_SkipPath(bindir) = 0; parms.argv = (const char **)argv; diff --git a/engine/common/fs_win32.c b/engine/common/fs_win32.c index 1e571ca9c..5f2487df4 100644 --- a/engine/common/fs_win32.c +++ b/engine/common/fs_win32.c @@ -28,8 +28,73 @@ typedef struct { unsigned int offset; } vfsw32file_t; -wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8); -char *narrowen(char *out, size_t outlen, const wchar_t *wide); +wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8) +{ + wchar_t *ret = out; + //utf-8 to utf-16, not ucs-2. + unsigned int codepoint; + int error; + if (!outlen) + return L""; + outlen /= sizeof(wchar_t); + outlen--; + while (*utf8) + { + codepoint = utf8_decode(&error, utf8, (void*)&utf8); + if (error) + codepoint = 0xFFFDu; + if (codepoint > 0xffff) + { + if (outlen < 2) + break; + outlen -= 2; + codepoint -= 0x10000u; + *out++ = 0xD800 | (codepoint>>10); + *out++ = 0xDC00 | (codepoint&0x3ff); + } + else + { + if (outlen < 1) + break; + outlen -= 1; + *out++ = codepoint; + } + } + *out = 0; + return ret; +} + +char *narrowen(char *out, size_t outlen, wchar_t *wide) +{ + char *ret = out; + int bytes; + unsigned int codepoint; + if (!outlen) + return ""; + outlen--; + //utf-8 to utf-16, not ucs-2. + while (*wide) + { + codepoint = *wide++; + if (codepoint >= 0xD800u && codepoint <= 0xDBFFu) + { //handle utf-16 surrogates + if (*wide >= 0xDC00u && *wide <= 0xDFFFu) + { + codepoint = (codepoint&0x3ff)<<10; + codepoint |= *wide++ & 0x3ff; + } + else + codepoint = 0xFFFDu; + } + bytes = utf8_encode(out, codepoint, outlen); + if (bytes <= 0) + break; + out += bytes; + outlen -= bytes; + } + *out = 0; + return ret; +} static int QDECL VFSW32_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread) diff --git a/engine/common/pr_bgcmd.c b/engine/common/pr_bgcmd.c index dc85b52b9..91b71702c 100644 --- a/engine/common/pr_bgcmd.c +++ b/engine/common/pr_bgcmd.c @@ -3974,7 +3974,7 @@ void QCBUILTIN PF_break (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals //need to alter the client, or rewrite a bit of the server.. if (pr_globals) - Con_TPrintf(STL_BREAKSTATEMENT); + Con_Printf("Break Statement\n"); else if (developer.value!=2) return; //non developers cann't step. for(;;) diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index 0791153ee..66fd31a81 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -18942,6 +18942,7 @@ + + +