diff --git a/source/collada/CommonConvert.cpp b/source/collada/CommonConvert.cpp index 3d7a5e702c..46b5c094d4 100644 --- a/source/collada/CommonConvert.cpp +++ b/source/collada/CommonConvert.cpp @@ -79,9 +79,9 @@ void FColladaErrorHandler::OnError(FUError::Level errorLevel, uint32 errorCode, errorString = "Unknown error code"; if (errorLevel == FUError::DEBUG_LEVEL) - Log(LOG_INFO, "FCollada message %d: %s", errorCode, errorString); + Log(LOG_INFO, "FCollada message %d: %hs", errorCode, errorString); else if (errorLevel == FUError::WARNING_LEVEL) - Log(LOG_WARNING, "FCollada warning %d: %s", errorCode, errorString); + Log(LOG_WARNING, "FCollada warning %d: %hs", errorCode, errorString); else throw ColladaException(errorString); } @@ -97,7 +97,7 @@ void FColladaDocument::LoadFromText(const char *text) size_t newTextSize = 0; FixBrokenXML(text, &newText, &newTextSize); - // Log(LOG_INFO, "%s", newText); + // Log(LOG_INFO, "%hs", newText); bool status = FCollada::LoadDocumentFromMemory("unknown.dae", document.get(), (void*)newText, newTextSize); if (newText != text) @@ -143,7 +143,7 @@ CommonConvert::CommonConvert(const char* text, std::string& xmlErrors) throw ColladaException("Couldn't find object to convert"); assert(m_Instance); - Log(LOG_INFO, "Converting '%s'", m_Instance->GetEntity()->GetName().c_str()); + Log(LOG_INFO, "Converting '%hs'", m_Instance->GetEntity()->GetName().c_str()); m_IsXSI = false; FCDAsset* asset = m_Doc.GetDocument()->GetAsset(); @@ -254,7 +254,7 @@ static void FindInstances(FCDSceneNode* node, std::vector& instan f.transform = transform * node->ToMatrix(); f.instance = node->GetInstance(i); instances.push_back(f); - Log(LOG_INFO, "Found convertible object '%s'", node->GetName().c_str()); + Log(LOG_INFO, "Found convertible object '%hs'", node->GetName().c_str()); } } diff --git a/source/collada/DLL.cpp b/source/collada/DLL.cpp index 2576fa12a1..941de8bd38 100644 --- a/source/collada/DLL.cpp +++ b/source/collada/DLL.cpp @@ -27,7 +27,7 @@ void default_logger(int severity, const char* message) { - fprintf(stderr, "[%d] %s\n", severity, message); + fprintf(stderr, "[%d] %hs\n", severity, message); } static LogFn g_Logger = &default_logger; @@ -111,9 +111,9 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi catch (const ColladaException& e) { if (! xmlErrors.empty()) - Log(LOG_ERROR, "%s", xmlErrors.c_str()); + Log(LOG_ERROR, "%hs", xmlErrors.c_str()); - Log(LOG_ERROR, "%s", e.what()); + Log(LOG_ERROR, "%hs", e.what()); FCollada::Release(); @@ -124,7 +124,7 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi if (! xmlErrors.empty()) { - Log(LOG_ERROR, "%s", xmlErrors.c_str()); + Log(LOG_ERROR, "%hs", xmlErrors.c_str()); return -1; } @@ -152,9 +152,9 @@ EXPORT int set_skeleton_definitions(const char* xml, int length) catch (const ColladaException& e) { if (! xmlErrors.empty()) - Log(LOG_ERROR, "%s", xmlErrors.c_str()); + Log(LOG_ERROR, "%hs", xmlErrors.c_str()); - Log(LOG_ERROR, "%s", e.what()); + Log(LOG_ERROR, "%hs", e.what()); return -1; } diff --git a/source/collada/PMDConvert.cpp b/source/collada/PMDConvert.cpp index fecd1288bb..9c7b240996 100644 --- a/source/collada/PMDConvert.cpp +++ b/source/collada/PMDConvert.cpp @@ -152,9 +152,9 @@ public: Log(LOG_WARNING, "Mismatched bone counts (skin has %d, skeleton has %d)", skin->GetJointCount(), controllerInstance.GetJointCount()); for (size_t i = 0; i < skin->GetJointCount(); ++i) - Log(LOG_INFO, "Skin joint %d: %s", i, skin->GetJoint(i)->GetId().c_str()); + Log(LOG_INFO, "Skin joint %d: %hs", i, skin->GetJoint(i)->GetId().c_str()); for (size_t i = 0; i < controllerInstance.GetJointCount(); ++i) - Log(LOG_INFO, "Skeleton joint %d: %s", i, controllerInstance.GetJoint(i)->GetName().c_str()); + Log(LOG_INFO, "Skeleton joint %d: %hs", i, controllerInstance.GetJoint(i)->GetName().c_str()); } // Get the skinned mesh for this entity @@ -212,7 +212,7 @@ public: { // The relevant joint does exist, but it's not a recognised // bone in our chosen skeleton structure - Log(LOG_ERROR, "Vertex influenced by unrecognised bone '%s'", joint->GetName().c_str()); + Log(LOG_ERROR, "Vertex influenced by unrecognised bone '%hs'", joint->GetName().c_str()); continue; } @@ -287,7 +287,7 @@ public: // Strip off the "prop-" from the name std::string propPointName (child->GetName().substr(5)); - Log(LOG_INFO, "Adding prop point %s", propPointName.c_str()); + Log(LOG_INFO, "Adding prop point %hs", propPointName.c_str()); // Get translation and orientation of local transform @@ -426,7 +426,7 @@ public: { uint32 nameLen = (uint32)propPoints[i].name.length(); write(output, nameLen); - output((char*)propPoints[i].name.c_str(), nameLen); + output(propPoints[i].name.c_str(), nameLen); write(output, propPoints[i].translation); write(output, propPoints[i].orientation); write(output, propPoints[i].bone); diff --git a/source/collada/XMLFix.cpp b/source/collada/XMLFix.cpp index 2f1d67770e..419524c008 100644 --- a/source/collada/XMLFix.cpp +++ b/source/collada/XMLFix.cpp @@ -154,7 +154,7 @@ static bool processDocument(xmlNode* root) if (! authoring_tool_text) return false; if (authoring_tool_text->type != XML_TEXT_NODE) return false; xmlChar* toolname = authoring_tool_text->content; - Log(LOG_INFO, "Authoring tool: %s", toolname); + Log(LOG_INFO, "Authoring tool: %hs", toolname); if (strcmp((const char*)toolname, "FBX COLLADA exporter") == 0) return applyFBXFixes(root); else diff --git a/source/gui/CGUI.h b/source/gui/CGUI.h index e492e89693..b44a116c38 100644 --- a/source/gui/CGUI.h +++ b/source/gui/CGUI.h @@ -303,7 +303,7 @@ private: * * @param str Error message */ - void ReportParseError(const wchar_t* str, ...) PRINTF_ARGS(2); + void ReportParseError(const wchar_t* str, ...) WPRINTF_ARGS(2); /** * You input the name of the object type, and let's diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index 7b488140c3..af4afef4e5 100644 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -587,7 +587,7 @@ JSBool JSI_IGUIObject::toString(JSContext* cx, JSObject* obj, uintN UNUSED(argc) IGUIObject* e = (IGUIObject*)JS_GetPrivate( cx, obj ); char buffer[256]; - snprintf(buffer, 256, "[GUIObject: %s]", e->GetName().c_str()); + snprintf(buffer, 256, "[GUIObject: %hs]", e->GetName().c_str()); buffer[255] = 0; *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, buffer)); return JS_TRUE; diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index d2e2864416..3413e7d809 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -294,7 +294,7 @@ private: // split out of debug_DisplayError because it's used by the self-test. const wchar_t* debug_BuildErrorMessage( const wchar_t* description, - const wchar_t* filename, int line, const wchar_t* func, + const wchar_t* filename, int line, const char* func, void* context, const wchar_t* lastFuncToSkip, ErrorMessageMem* emm) { @@ -308,7 +308,7 @@ const wchar_t* debug_BuildErrorMessage( // header if(!writer( L"%ls\r\n" - L"Location: %ls:%d (%ls)\r\n" + L"Location: %ls:%d (%hs)\r\n" L"\r\n" L"Call stack:\r\n" L"\r\n", @@ -449,7 +449,7 @@ static ErrorReaction PerformErrorReaction(ErrorReaction er, size_t flags, u8* su ErrorReaction debug_DisplayError(const wchar_t* description, size_t flags, void* context, const wchar_t* lastFuncToSkip, - const wchar_t* pathname, int line, const wchar_t* func, + const wchar_t* pathname, int line, const char* func, u8* suppress) { // "suppressing" this error means doing nothing and returning ER_CONTINUE. @@ -469,7 +469,7 @@ ErrorReaction debug_DisplayError(const wchar_t* description, if(line <= 0) line = 0; if(!func || func[0] == '\0') - func = L"?"; + func = "?"; // .. _FILE__ evaluates to the full path (albeit without drive letter) // which is rather long. we only display the base name for clarity. const wchar_t* filename = path_name_only(pathname); @@ -523,12 +523,13 @@ static bool ShouldSkipThisError(LibError err) return false; } -ErrorReaction debug_OnError(LibError err, u8* suppress, const wchar_t* file, int line, const wchar_t* func) +ErrorReaction debug_OnError(LibError err, u8* suppress, const wchar_t* file, int line, const char* func) { if(ShouldSkipThisError(err)) return ER_CONTINUE; - void* context = 0; const wchar_t* lastFuncToSkip = __wfunc__; + void* context = 0; + const wchar_t* lastFuncToSkip = L"debug_OnError"; wchar_t buf[400]; wchar_t err_buf[200]; error_description_r(err, err_buf, ARRAY_SIZE(err_buf)); swprintf_s(buf, ARRAY_SIZE(buf), L"Function call failed: return value was %d (%ls)", err, err_buf); @@ -549,12 +550,13 @@ static bool ShouldSkipThisAssertion() return ShouldSkipThisError(ERR::ASSERTION_FAILED); } -ErrorReaction debug_OnAssertionFailure(const wchar_t* expr, u8* suppress, const wchar_t* file, int line, const wchar_t* func) +ErrorReaction debug_OnAssertionFailure(const wchar_t* expr, u8* suppress, const wchar_t* file, int line, const char* func) { if(ShouldSkipThisAssertion()) return ER_CONTINUE; - void* context = 0; const wchar_t* lastFuncToSkip = __wfunc__; + void* context = 0; + const std::wstring lastFuncToSkip = L"debug_OnAssertionFailure"; wchar_t buf[400]; swprintf_s(buf, ARRAY_SIZE(buf), L"Assertion failed: \"%ls\"", expr); - return debug_DisplayError(buf, DE_MANUAL_BREAK, context, lastFuncToSkip, file,line,func, suppress); + return debug_DisplayError(buf, DE_MANUAL_BREAK, context, lastFuncToSkip.c_str(), file,line,func, suppress); } diff --git a/source/lib/debug.h b/source/lib/debug.h index 75f8cda998..5f5d9d0547 100644 --- a/source/lib/debug.h +++ b/source/lib/debug.h @@ -48,7 +48,8 @@ extern void debug_break(); #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) #define __WFILE__ WIDEN(__FILE__) -#define __wfunc__ WIDEN(__func__) +// note: C99 says __func__ is a magic *variable*, and GCC doesn't allow +// widening it via preprocessor. //----------------------------------------------------------------------------- @@ -155,7 +156,7 @@ enum ErrorReaction * @param flags: see DebugDisplayErrorFlags. * @param context, lastFuncToSkip: see debug_DumpStack. * @param file, line, func: location of the error (typically passed as - * __WFILE__, __LINE__, __wfunc__ from a macro) + * __WFILE__, __LINE__, __func__ from a macro) * @param suppress pointer to a caller-allocated flag that can be used to * suppress this error. if NULL, this functionality is skipped and the * "Suppress" dialog button will be disabled. @@ -163,13 +164,13 @@ enum ErrorReaction * provides the storage. values: see DEBUG_SUPPRESS above. * @return ErrorReaction (user's choice: continue running or stop?) **/ -LIB_API ErrorReaction debug_DisplayError(const wchar_t* description, size_t flags, void* context, const wchar_t* lastFuncToSkip, const wchar_t* file, int line, const wchar_t* func, u8* suppress); +LIB_API ErrorReaction debug_DisplayError(const wchar_t* description, size_t flags, void* context, const wchar_t* lastFuncToSkip, const wchar_t* file, int line, const char* func, u8* suppress); /** * convenience version, in case the advanced parameters aren't needed. * macro instead of providing overload/default values for C compatibility. **/ -#define DEBUG_DISPLAY_ERROR(text) debug_DisplayError(text, 0, 0, L"debug_DisplayError", __WFILE__,__LINE__,__wfunc__, 0) +#define DEBUG_DISPLAY_ERROR(text) debug_DisplayError(text, 0, 0, L"debug_DisplayError", __WFILE__,__LINE__,__func__, 0) // @@ -269,7 +270,7 @@ STMT(\ static u8 suppress__;\ if(!(expr))\ {\ - switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, __WFILE__, __LINE__, __wfunc__))\ + switch(debug_OnAssertionFailure(WIDEN(#expr), &suppress__, __WFILE__, __LINE__, __func__))\ {\ case ER_BREAK:\ debug_break();\ @@ -293,7 +294,7 @@ STMT(\ #define debug_warn(expr) \ STMT(\ static u8 suppress__;\ - switch(debug_OnAssertionFailure(expr, &suppress__, __WFILE__, __LINE__, __wfunc__))\ + switch(debug_OnAssertionFailure(expr, &suppress__, __WFILE__, __LINE__, __func__))\ {\ case ER_BREAK:\ debug_break();\ @@ -312,7 +313,7 @@ STMT(\ #define DEBUG_WARN_ERR(err)\ STMT(\ static u8 suppress__;\ - switch(debug_OnError(err, &suppress__, __WFILE__, __LINE__, __wfunc__))\ + switch(debug_OnError(err, &suppress__, __WFILE__, __LINE__, __func__))\ {\ case ER_BREAK:\ debug_break();\ @@ -334,7 +335,7 @@ STMT(\ * @param func name of the function containing it * @return ErrorReaction (user's choice: continue running or stop?) **/ -LIB_API ErrorReaction debug_OnAssertionFailure(const wchar_t* assert_expr, u8* suppress, const wchar_t* file, int line, const wchar_t* func); +LIB_API ErrorReaction debug_OnAssertionFailure(const wchar_t* assert_expr, u8* suppress, const wchar_t* file, int line, const char* func); /** * called when a DEBUG_WARN_ERR indicates an error occurred; @@ -346,7 +347,7 @@ LIB_API ErrorReaction debug_OnAssertionFailure(const wchar_t* assert_expr, u8* s * @param func name of the function containing it * @return ErrorReaction (user's choice: continue running or stop?) **/ -LIB_API ErrorReaction debug_OnError(LibError err, u8* suppress, const wchar_t* file, int line, const wchar_t* func); +LIB_API ErrorReaction debug_OnError(LibError err, u8* suppress, const wchar_t* file, int line, const char* func); /** @@ -540,6 +541,6 @@ LIB_API void debug_FreeErrorMessage(ErrorMessageMem* emm); * fallback in case heap alloc fails. should be freed via * debug_FreeErrorMessage when no longer needed. **/ -LIB_API const wchar_t* debug_BuildErrorMessage(const wchar_t* description, const wchar_t* fn_only, int line, const wchar_t* func, void* context, const wchar_t* lastFuncToSkip, ErrorMessageMem* emm); +LIB_API const wchar_t* debug_BuildErrorMessage(const wchar_t* description, const wchar_t* fn_only, int line, const char* func, void* context, const wchar_t* lastFuncToSkip, ErrorMessageMem* emm); #endif // #ifndef INCLUDED_DEBUG diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index b72df6d9a7..ddceac74c4 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -70,7 +70,7 @@ LibError vfs_Lookup(const VfsPath& pathname, VfsDirectory* startDirectory, VfsDi currentPath /= subdirectoryName; fs::path currentPath_c = path_from_wpath(currentPath); - const int ret = mkdir(currentPath_c.external_directory_string().c_str(), S_IRWXU); + const int ret = mkdir(currentPath_c.string().c_str(), S_IRWXU); if(ret == 0) { PRealDirectory realDirectory(new RealDirectory(currentPath, 0, 0)); diff --git a/source/lib/res/graphics/cursor.cpp b/source/lib/res/graphics/cursor.cpp index a51415c2ea..fae8f2ce5e 100644 --- a/source/lib/res/graphics/cursor.cpp +++ b/source/lib/res/graphics/cursor.cpp @@ -266,7 +266,7 @@ static LibError Cursor_to_string(const Cursor* c, char* buf) break; } - snprintf(buf, H_STRING_LEN, "cursor (%s)", type); + snprintf(buf, H_STRING_LEN, "cursor (%hs)", type); return INFO::OK; } diff --git a/source/lib/res/sound/snd_mgr.cpp b/source/lib/res/sound/snd_mgr.cpp index b7ab5c4e5d..dab23c75d4 100644 --- a/source/lib/res/sound/snd_mgr.cpp +++ b/source/lib/res/sound/snd_mgr.cpp @@ -107,11 +107,11 @@ static LibError list_free_all(); static void hsd_list_free_all(); -static void al_ReportError(ALenum err, const wchar_t* caller, int line) +static void al_ReportError(ALenum err, const char* caller, int line) { debug_assert(al_initialized); - debug_printf(L"OpenAL error: %hs; called from %ls (line %d)\n", alGetString(err), caller, line); + debug_printf(L"OpenAL error: %hs; called from %hs (line %d)\n", alGetString(err), caller, line); debug_assert(0); } @@ -123,7 +123,7 @@ static void al_ReportError(ALenum err, const wchar_t* caller, int line) * @param line line number of the call site (typically passed via __LINE__) * (identifies the exact call site since there may be several per caller) */ -static void al_check(const wchar_t* caller, int line) +static void al_check(const char* caller, int line) { ALenum err = alGetError(); if(err != AL_NO_ERROR) @@ -131,7 +131,7 @@ static void al_check(const wchar_t* caller, int line) } // convenience version that automatically passes in function name. -#define AL_CHECK al_check(__wfunc__, __LINE__) +#define AL_CHECK al_check(__func__, __LINE__) //----------------------------------------------------------------------------- @@ -841,7 +841,7 @@ static LibError SndData_validate(const SndData * sd) static LibError SndData_to_string(const SndData* sd, char* buf) { const char* type = "clip"; - snprintf(buf, H_STRING_LEN, "%s; al_buf=%d", type, sd->al_buf); + snprintf(buf, H_STRING_LEN, "%hs; al_buf=%d", type, sd->al_buf); return INFO::OK; } @@ -1479,7 +1479,7 @@ static void vsrc_latch(VSrc* vs) debug_printf(L" pitch: %f\n", vs->pitch); debug_printf(L" loop: %d\n", (int)vs->loop); - al_ReportError(err, __wfunc__, __LINE__); + al_ReportError(err, __func__, __LINE__); } } diff --git a/source/lib/sysdep/os/win/wdir_watch.cpp b/source/lib/sysdep/os/win/wdir_watch.cpp index 3e09727231..ef3b5e6c35 100644 --- a/source/lib/sysdep/os/win/wdir_watch.cpp +++ b/source/lib/sysdep/os/win/wdir_watch.cpp @@ -173,7 +173,7 @@ public: WinScopedPreserveLastError s; // CreateFile const DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; const DWORD flags = FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED; - const std::wstring dirPath = m_path.external_directory_string(); + const std::wstring dirPath = m_path.string(); m_hDir = CreateFileW(dirPath.c_str(), FILE_LIST_DIRECTORY, share, 0, OPEN_EXISTING, flags, 0); if(m_hDir == INVALID_HANDLE_VALUE) throw std::runtime_error(""); diff --git a/source/lib/sysdep/os/win/wdll_ver.cpp b/source/lib/sysdep/os/win/wdll_ver.cpp index cd85c25515..cbb089f4ff 100644 --- a/source/lib/sysdep/os/win/wdll_ver.cpp +++ b/source/lib/sysdep/os/win/wdll_ver.cpp @@ -42,7 +42,7 @@ static LibError ReadVersionString(const fs::wpath& modulePathname_, wchar_t* out WinScopedPreserveLastError s; // GetFileVersion*, Ver* WinScopedDisableWow64Redirection noRedirect; - const std::wstring modulePathname = modulePathname_.external_file_string(); + const std::wstring modulePathname = modulePathname_.string(); // determine size of and allocate memory for version information. DWORD unused; diff --git a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp index b9baf2c512..d5932b0f87 100644 --- a/source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ b/source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -295,7 +295,7 @@ DIR* opendir(const char* path) // information about that directory; trailing slashes aren't allowed. // for dir entries to be returned, we have to append "\\*". char search_path[PATH_MAX]; - sprintf_s(search_path, ARRAY_SIZE(search_path), "%s\\*", path); + sprintf_s(search_path, ARRAY_SIZE(search_path), "%hs\\*", path); // note: we could store search_path and defer FindFirstFile until // readdir. this way is a bit more complex but required for diff --git a/source/lib/sysdep/os/win/wposix/wutsname.cpp b/source/lib/sysdep/os/win/wposix/wutsname.cpp index e4bb3c6d3d..e2f32306a8 100644 --- a/source/lib/sysdep/os/win/wposix/wutsname.cpp +++ b/source/lib/sysdep/os/win/wposix/wutsname.cpp @@ -39,7 +39,7 @@ int uname(struct utsname* un) sprintf(un->release, "SP %d", sp); // version - sprintf(un->version, "%s.%lu", wutil_WindowsVersionString(), vi.dwBuildNumber & 0xFFFF); + sprintf(un->version, "%hs.%lu", wutil_WindowsVersionString(), vi.dwBuildNumber & 0xFFFF); // node name DWORD buf_size = sizeof(un->nodename); diff --git a/source/lib/sysdep/os/win/wseh.cpp b/source/lib/sysdep/os/win/wseh.cpp index a665a3c4d7..0d724cc06a 100644 --- a/source/lib/sysdep/os/win/wseh.cpp +++ b/source/lib/sysdep/os/win/wseh.cpp @@ -23,6 +23,7 @@ #include "wseh.h" #include "lib/byte_order.h" // FOURCC +#include "lib/wchar.h" #include "lib/sysdep/cpu.h" #include "win.h" #include "wutil.h" @@ -280,7 +281,7 @@ long __stdcall wseh_ExceptionFilter(struct _EXCEPTION_POINTERS* ep) if(ep->ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE) flags = DE_NO_CONTINUE; const wchar_t* const lastFuncToSkip = WIDEN(STRINGIZE(DECORATED_NAME(wseh_ExceptionFilter))); - ErrorReaction er = debug_DisplayError(message, flags, ep->ContextRecord, lastFuncToSkip, file,line,func, 0); + ErrorReaction er = debug_DisplayError(message, flags, ep->ContextRecord, lastFuncToSkip, file,line,string_from_wstring(func).c_str(), 0); debug_assert(er == ER_CONTINUE); // nothing else possible // invoke the Win32 default handler - it calls ExitProcess for diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h index c223ae51b4..c7635d098b 100644 --- a/source/lib/sysdep/tests/test_sysdep.h +++ b/source/lib/sysdep/tests/test_sysdep.h @@ -104,7 +104,7 @@ public: if (! tmpdir) tmpdir = P_tmpdir; char root[PATH_MAX]; - sprintf_s(root, PATH_MAX, "%s/pyrogenesis-test-sysdep-XXXXXX", tmpdir); + sprintf_s(root, PATH_MAX, "%hs/pyrogenesis-test-sysdep-XXXXXX", tmpdir); TS_ASSERT(mkdtemp(root)); std::string rootstr(root); diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 6f519c6c54..589eb9a41d 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -258,7 +258,7 @@ bool CNetClient::OnError( void* pContext, CFsmEvent* pEvent ) CErrorMessage* pMessage = ( CErrorMessage* )pEvent->GetParamRef(); if ( pMessage ) { - LOG( CLogger::Error, LOG_CATEGORY, L"CNetClient::OnError(): Error description %s", pMessage->m_Error ); + LOG( CLogger::Error, LOG_CATEGORY, L"CNetClient::OnError(): Error description %hs", pMessage->m_Error ); if ( pClient->m_OnConnectComplete.Defined() ) { @@ -461,7 +461,7 @@ bool CNetClient::OnPreGame( void* pContext, CFsmEvent* pEvent ) break; default: - LOG( CLogger::Warning, LOG_CATEGORY, L"Invalid slot assignment %s", pMessage->ToString().c_str() ); + LOG( CLogger::Warning, LOG_CATEGORY, L"Invalid slot assignment %hs", pMessage->ToString().c_str() ); break; } } diff --git a/source/network/NetLog.cpp b/source/network/NetLog.cpp index cc898f07b3..4d3bc38124 100644 --- a/source/network/NetLog.cpp +++ b/source/network/NetLog.cpp @@ -260,7 +260,7 @@ CNetLogFileSink::CNetLogFileSink( void ) // Make relative path fs::wpath path(psLogDir()/L"net_log"); path /= CStrW(time)+L".txt"; - m_FileName = path.external_file_string(); + m_FileName = path.string(); m_Append = true; } diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index bbfd6ef55c..c89a3336d9 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -413,7 +413,7 @@ bool CNetServer::OnError( void* pContext, CFsmEvent* pEvent ) else { // Weird stuff... - LOG( CLogger::Warning, LOG_CATEGORY, L"NMT_ERROR: %s", pMessage->ToString().c_str() ); + LOG( CLogger::Warning, LOG_CATEGORY, L"NMT_ERROR: %hs", pMessage->ToString().c_str() ); } } @@ -1022,7 +1022,7 @@ void CNetServer::QueueIncomingCommand( CNetMessage* pMessage ) // Validate parameters if ( !pMessage ) return; - //LOG( NORMAL, LOG_CATEGORY, L"CNetServer::QueueIncomingCommand(): %s.", pMessage->ToString().c_str() ); + //LOG( NORMAL, LOG_CATEGORY, L"CNetServer::QueueIncomingCommand(): %hs.", pMessage->ToString().c_str() ); QueueMessage( 2, pMessage ); } diff --git a/source/network/NetSession.cpp b/source/network/NetSession.cpp index 3450a29a53..9798d7641b 100644 --- a/source/network/NetSession.cpp +++ b/source/network/NetSession.cpp @@ -159,7 +159,7 @@ bool CNetHost::Connect( const CStr& host, uint port ) if ( !SetupSession( pNewSession ) ) return false; - NET_LOG3( "Successfully connected to server %s:%d succeeded", host.c_str(), port ); + NET_LOG3( "Successfully connected to server %hs:%d succeeded", host.c_str(), port ); // Successfully handled? if ( !HandleConnect( pNewSession ) ) @@ -177,7 +177,7 @@ bool CNetHost::Connect( const CStr& host, uint port ) return true; } - NET_LOG3( "Connection to server %s:%d failed", host.c_str(), port ); + NET_LOG3( "Connection to server %hs:%d failed", host.c_str(), port ); // 3 seconds are up or a host was disconnected enet_peer_reset( pPeer ); @@ -420,7 +420,7 @@ bool CNetHost::Poll( void ) CNetMessage* pNewMessage = CNetMessageFactory::CreateMessage( event.packet->data, event.packet->dataLength ); if ( !pNewMessage ) return false; - NET_LOG4( "Message %s of size %lu was received from %p", pNewMessage->ToString().c_str(), (unsigned long)pNewMessage->GetSerializedLength(), event.peer->data ); + NET_LOG4( "Message %hs of size %lu was received from %p", pNewMessage->ToString().c_str(), (unsigned long)pNewMessage->GetSerializedLength(), event.peer->data ); // Successfully handled? if ( !HandleMessageReceive( pNewMessage, it->pSession ) ) { @@ -526,7 +526,7 @@ bool CNetHost::SendMessage( } else { - NET_LOG4( "Message %s of size %lu was sent to %p", + NET_LOG4( "Message %hs of size %lu was sent to %p", pMessage->ToString().c_str(), (unsigned long)pMessage->GetSerializedLength(), pSession->m_Peer->data ); } @@ -866,7 +866,7 @@ bool CNetServerSession::BaseHandler( else { // Not disconnected? Weired... - LOG( WARNING, LOG_CATEGORY, L"CNetServerSession::BaseHandler() NMT_ERROR: %s", pErrMessage->ToString().c_str() ); + LOG( WARNING, LOG_CATEGORY, L"CNetServerSession::BaseHandler() NMT_ERROR: %hs", pErrMessage->ToString().c_str() ); } delete pMessage; @@ -892,7 +892,7 @@ bool CNetServerSession::HandshakeHandler( CNetServerSession* pSrvSession = dynamic_cast< CNetServerSession* >( pSession ); if ( !pSrvSession ) return false; - LOG( NORMAL, LOG_CATEGORY, L"CNetServerSession::HandshakeHandler() %s", pMessage->ToString().c_str() ); + LOG( NORMAL, LOG_CATEGORY, L"CNetServerSession::HandshakeHandler() %hs", pMessage->ToString().c_str() ); // Call base handler if other message thant NMT_ClientHandshake if ( pMessage->GetType() != NMT_ClientHandshake ) BaseHandler( pMessage, pSession ); diff --git a/source/network/Network.cpp b/source/network/Network.cpp index ac19188e55..e8e4573d6f 100644 --- a/source/network/Network.cpp +++ b/source/network/Network.cpp @@ -139,7 +139,7 @@ CStr CCloseRequestMessage::ToString( void ) const void CMessageSocket::Push(CNetMessage *msg) { - NET_LOG2( "CMessageSocket::Push(): %s", msg->ToString().c_str() ); + NET_LOG2( "CMessageSocket::Push(): %hs", msg->ToString().c_str() ); m_OutQ.Lock(); m_OutQ.push_back(msg); @@ -222,7 +222,7 @@ void CMessageSocket::StartWriteNextMessage() PS_RESULT res=Write(m_pWrBuffer, hdr.m_MsgLength+HEADER_LENGTH); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartWriteNextMessage(): %s", res ); + NET_LOG2( "CMessageSocket::StartWriteNextMessage(): %hs", res ); // Queue Error Message m_InQ.Lock(); @@ -246,7 +246,7 @@ void CMessageSocket::StartWriteNextMessage() void CMessageSocket::WriteComplete(PS_RESULT ec) { - NET_LOG2( "CMessageSocket::WriteComplete(): %s", ec ); + NET_LOG2( "CMessageSocket::WriteComplete(): %hs", ec ); if (ec == PS_OK) { @@ -285,7 +285,7 @@ void CMessageSocket::StartReadHeader() PS_RESULT res=Read(m_pRdBuffer, HEADER_LENGTH); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartReadHeader(): %s", res ); + NET_LOG2( "CMessageSocket::StartReadHeader(): %hs", res ); // Push an error message CScopeLock scopeLock(m_InQ.m_Mutex); @@ -319,7 +319,7 @@ void CMessageSocket::StartReadMessage() PS_RESULT res=Read(m_pRdBuffer+HEADER_LENGTH, hdr.m_MsgLength); if (res != PS_OK) { - NET_LOG2( "CMessageSocket::StartReadMessage(): %s", res ); + NET_LOG2( "CMessageSocket::StartReadMessage(): %hs", res ); // Queue an error message CScopeLock scopeLock(m_InQ); @@ -330,7 +330,7 @@ void CMessageSocket::StartReadMessage() void CMessageSocket::ReadComplete(PS_RESULT ec) { - NET_LOG3( "CMessageSocket::ReadComplete(%s): %s", m_ReadingData ? "data":"header", ec ); + NET_LOG3( "CMessageSocket::ReadComplete(%ls): %hs", m_ReadingData ? L"data":L"header", ec ); // Check if we were reading header or message // If header: @@ -368,7 +368,7 @@ void CMessageSocket::OnMessage(CNetMessage *pMsg) { m_InQ.Lock(); m_InQ.push_back(pMsg); - NET_LOG2( "CMessageSocket::OnMessage(): %s", pMsg->ToString().c_str() ); + NET_LOG2( "CMessageSocket::OnMessage(): %hs", pMsg->ToString().c_str() ); NET_LOG2( "CMessageSocket::OnMessage(): Queue size now %lu", (unsigned long)m_InQ.size() ); m_InQ.Unlock(); } diff --git a/source/network/ServerSocket.cpp b/source/network/ServerSocket.cpp index e78510fda8..1e7bbd8344 100644 --- a/source/network/ServerSocket.cpp +++ b/source/network/ServerSocket.cpp @@ -37,7 +37,7 @@ void CServerSocket::OnRead() { // All errors are non-critical, so no need to do anything special besides // not calling OnAccept [ shouldn't be, that is ;-) ] - NET_LOG2( "CServerSocket::OnRead(): PreAccept returned an error: %s", res ); + NET_LOG2( "CServerSocket::OnRead(): PreAccept returned an error: %hs", res ); } } diff --git a/source/network/SocketBase.cpp b/source/network/SocketBase.cpp index 06eafe9e3b..f784172226 100644 --- a/source/network/SocketBase.cpp +++ b/source/network/SocketBase.cpp @@ -78,7 +78,7 @@ PS_RESULT GetPS_RESULT(int error) default: char buf[256]; Network_GetErrorString(error, buf, sizeof(buf)); - LOG(CLogger::Error, LOG_CATEGORY, L"SocketBase.cpp::GetPS_RESULT(): Unrecognized error %s[%d]", buf, error); + LOG(CLogger::Error, LOG_CATEGORY, L"SocketBase.cpp::GetPS_RESULT(): Unrecognized error %hs[%d]", buf, error); return PS_FAIL; } } @@ -369,7 +369,7 @@ PS_RESULT CSocketBase::Read(void *buf, size_t len, size_t *bytesRead) case ETIMEDOUT:*/ default: Network_GetErrorString(error, errbuf, sizeof(errbuf)); - NET_LOG3("Read error %s [%d]", errbuf, error); + NET_LOG3("Read error %hs [%d]", errbuf, error); m_State=SS_UNCONNECTED; m_Error=GetPS_RESULT(error); return m_Error; @@ -420,7 +420,7 @@ PS_RESULT CSocketBase::Write(void *buf, size_t len, size_t *bytesWritten) case EHOSTUNREACH:*/ default: Network_GetErrorString(err, errbuf, sizeof(errbuf)); - NET_LOG3("Write error %s [%d]", errbuf, err); + NET_LOG3("Write error %hs [%d]", errbuf, err); m_State=SS_UNCONNECTED; return CONNECTION_BROKEN; } @@ -491,7 +491,7 @@ PS_RESULT CSocketBase::Bind(const CSocketAddress &address) break; default: Network_GetErrorString(err, errBuf, sizeof(errBuf)); - LOG(CLogger::Error, LOG_CATEGORY, L"CServerSocket::Bind(): bind: %s [%d] => PS_FAIL", errBuf, err); + LOG(CLogger::Error, LOG_CATEGORY, L"CServerSocket::Bind(): bind: %hs [%d] => PS_FAIL", errBuf, err); } m_State=SS_UNCONNECTED; m_Error=ret; @@ -503,7 +503,7 @@ PS_RESULT CSocketBase::Bind(const CSocketAddress &address) { int err=Network_LastError; Network_GetErrorString(err, errBuf, sizeof(errBuf)); - LOG(CLogger::Error, LOG_CATEGORY, L"CServerSocket::Bind(): listen: %s [%d] => PS_FAIL", errBuf, err); + LOG(CLogger::Error, LOG_CATEGORY, L"CServerSocket::Bind(): listen: %hs [%d] => PS_FAIL", errBuf, err); m_State=SS_UNCONNECTED; return PS_FAIL; } @@ -579,7 +579,7 @@ bool CSocketBase::ConnectError(CSocketBase *pSocket) { pSocket->m_State=SS_UNCONNECTED; PS_RESULT connErr=GetPS_RESULT(errno); - NET_LOG4("Connect error: %s [%d:%s]", connErr, errno, strerror(errno)); + NET_LOG4("Connect error: %hs [%d:%hs]", connErr, errno, strerror(errno)); pSocket->m_Error=connErr; return true; } @@ -644,7 +644,7 @@ void CSocketBase::SocketReadable(CSocketBase *pSock) // success, nRead != 0 means alive stream socket if (res == -1 && errno != EINVAL) { - NET_LOG3("RunWaitLoop:ioctl: Connection broken [%d:%s]", errno, strerror(errno)); + NET_LOG3("RunWaitLoop:ioctl: Connection broken [%d:%hs]", errno, strerror(errno)); // Don't use API function - we both hold a lock and // it is unnecessary to SendWaitLoopUpdate at this // stage @@ -880,7 +880,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, (LPSTR)&errBuf, 256); - NET_LOG3("RegisterClass: %s [%d]", errBuf, ret); + NET_LOG3("RegisterClass: %hs [%d]", errBuf, ret); return; } @@ -891,7 +891,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, errBuf, sizeof(errBuf)); - NET_LOG3("CreateWindowEx: %s [%d]", errBuf, ret); + NET_LOG3("CreateWindowEx: %hs [%d]", errBuf, ret); return; } @@ -915,7 +915,7 @@ void CSocketBase::RunWaitLoop() { ret=GetLastError(); Network_GetErrorString(ret, errBuf, sizeof(errBuf)); - NET_LOG3("GetMessage: %s [%d]", errBuf, ret); + NET_LOG3("GetMessage: %hs [%d]", errBuf, ret); } { TranslateMessage(&msg); diff --git a/source/network/StreamSocket.cpp b/source/network/StreamSocket.cpp index 5c0e19083d..b9db7c6506 100644 --- a/source/network/StreamSocket.cpp +++ b/source/network/StreamSocket.cpp @@ -42,7 +42,7 @@ void *CStreamSocket_ConnectThread(void *data) CSocketAddress addr; res=CSocketAddress::Resolve(pSock->m_pConnectHost, pSock->m_ConnectPort, addr); - NET_LOG4("CStreamSocket_ConnectThread: Resolve: %s -> %s [%s]", pSock->m_pConnectHost, addr.GetString().c_str(), res); + NET_LOG4("CStreamSocket_ConnectThread: Resolve: %hs -> %hs [%hs]", pSock->m_pConnectHost, addr.GetString().c_str(), res); if (res == PS_OK) { pSock->Initialize(); @@ -53,7 +53,7 @@ void *CStreamSocket_ConnectThread(void *data) pSock->SetOpMask(0); pSock->SetNonBlocking(false); res=pSock->Connect(addr); - NET_LOG2("CStreamSocket_ConnectThread: Connect: %s", res); + NET_LOG2("CStreamSocket_ConnectThread: Connect: %hs", res); } if (res == PS_OK) @@ -128,7 +128,7 @@ PS_RESULT CStreamSocket::Write(void *buf, size_t len) } #define MakeDefaultCallback(_nm) void CStreamSocket::_nm(PS_RESULT error) \ - { NET_LOG2("CStreamSocket::"#_nm"(): %s", error); } + { NET_LOG2("CStreamSocket::"#_nm"(): %hs", error); } MakeDefaultCallback(OnClose) MakeDefaultCallback(ConnectComplete) @@ -173,7 +173,7 @@ void CStreamSocket::OnRead() ((u8 *)m_ReadContext.m_pBuffer)+m_ReadContext.m_Completed, m_ReadContext.m_Length-m_ReadContext.m_Completed, &bytes); - NET_LOG4("CStreamSocket::OnRead(): %s, %lu bytes read of %lu", + NET_LOG4("CStreamSocket::OnRead(): %hs, %lu bytes read of %lu", res, (unsigned long)bytes, (unsigned long)(m_ReadContext.m_Length-m_ReadContext.m_Completed)); if (res != PS_OK) diff --git a/source/ps/CLogger.cpp b/source/ps/CLogger.cpp index dba5719685..d9827adf75 100644 --- a/source/ps/CLogger.cpp +++ b/source/ps/CLogger.cpp @@ -55,10 +55,10 @@ const wchar_t* html_footer = L""; CLogger::CLogger() { fs::wpath mainlogPath(psLogDir()/L"mainlog.html"); - m_MainLog = new std::wofstream(mainlogPath.external_file_string().c_str(), std::ofstream::out | std::ofstream::trunc); + m_MainLog = new std::wofstream(mainlogPath.string().c_str(), std::ofstream::out | std::ofstream::trunc); fs::wpath interestinglogPath(psLogDir()/L"interestinglog.html"); - m_InterestingLog = new std::wofstream(interestinglogPath.external_file_string().c_str(), std::ofstream::out | std::ofstream::trunc); + m_InterestingLog = new std::wofstream(interestinglogPath.string().c_str(), std::ofstream::out | std::ofstream::trunc); m_OwnsStreams = true; m_UseDebugPrintf = true; diff --git a/source/ps/CLogger.h b/source/ps/CLogger.h index 1bf4d5570d..c638e54d68 100644 --- a/source/ps/CLogger.h +++ b/source/ps/CLogger.h @@ -64,15 +64,15 @@ public: // Function to log stuff to file // -- This function has not been removed because the build would break. - void Log(ELogMethod method, const wchar_t* category, const wchar_t* fmt, ...) PRINTF_ARGS(4); + void Log(ELogMethod method, const wchar_t* category, const wchar_t* fmt, ...) WPRINTF_ARGS(4); // Similar to Log, but only outputs each message once no matter how many times it's called // -- This function has not been removed because the build would break. - void LogOnce(ELogMethod method, const wchar_t* category, const wchar_t* fmt, ...) PRINTF_ARGS(4); + void LogOnce(ELogMethod method, const wchar_t* category, const wchar_t* fmt, ...) WPRINTF_ARGS(4); // Functions to write a message, warning or error to file. - void LogMessage(const wchar_t* fmt, ...) PRINTF_ARGS(2); - void LogWarning(const wchar_t* fmt, ...) PRINTF_ARGS(2); - void LogError(const wchar_t* fmt, ...) PRINTF_ARGS(2); + void LogMessage(const wchar_t* fmt, ...) WPRINTF_ARGS(2); + void LogWarning(const wchar_t* fmt, ...) WPRINTF_ARGS(2); + void LogError(const wchar_t* fmt, ...) WPRINTF_ARGS(2); private: void Init(); diff --git a/source/ps/CStr.h b/source/ps/CStr.h index 30aad50e90..aa3b878917 100644 --- a/source/ps/CStr.h +++ b/source/ps/CStr.h @@ -30,7 +30,7 @@ Examples: The following shows several examples of traditional ANSI vs UNICODE. // ANSI LPCSTR str = "PI"; - printf( "%s = %fn", str, 3.1459f ); + printf( "%hs = %fn", str, 3.1459f ); // UNICODE LPCWSTR str = L"PI"; diff --git a/source/ps/Profile.cpp b/source/ps/Profile.cpp index 1d2a5b4a67..359d949178 100644 --- a/source/ps/Profile.cpp +++ b/source/ps/Profile.cpp @@ -111,7 +111,7 @@ CStr CProfileNodeTable::GetTitle() { char buf[512]; - snprintf(buf, sizeof(buf), "Profiling Information for: %s (Time in node: %.3f msec/frame)", node->GetName(), node->GetFrameTime() * 1000.0f ); + snprintf(buf, sizeof(buf), "Profiling Information for: %hs (Time in node: %.3f msec/frame)", node->GetName(), node->GetFrameTime() * 1000.0f ); buf[sizeof(buf)-1] = '\0'; return buf; diff --git a/source/ps/ProfileViewer.cpp b/source/ps/ProfileViewer.cpp index a95222b3d9..408571c4cc 100644 --- a/source/ps/ProfileViewer.cpp +++ b/source/ps/ProfileViewer.cpp @@ -430,7 +430,7 @@ void CProfileViewer::SaveToFile() // Open the file. (It will be closed when the CProfileViewer // destructor is called.) fs::wpath path(psLogDir()/L"profile.txt"); - m->outputStream.open(path.external_file_string().c_str(), std::ofstream::out | std::ofstream::trunc); + m->outputStream.open(path.string().c_str(), std::ofstream::out | std::ofstream::trunc); if (m->outputStream.fail()) { diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index cdc8293a16..6549f2e1b3 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -86,15 +86,15 @@ void WriteSystemInfo() struct tm* t = gmtime(&seconds); const size_t charsWritten = wcsftime(timestampBuf, ARRAY_SIZE(timestampBuf), L"(generated %Y-%m-%d %H:%M:%S UTC)", t); debug_assert(charsWritten != 0); - fwprintf(f, L"%ls\n\n", timestampBuf); + fprintf(f, "%ls\n\n", timestampBuf); } // OS - fprintf(f, "OS : %s %s (%s)\n", un.sysname, un.release, un.version); + fprintf(f, "OS : %hs %hs (%hs)\n", un.sysname, un.release, un.version); // CPU const CpuTopology* topology = cpu_topology_Detect(); - fprintf(f, "CPU : %s, %s (%dx%dx%d)", un.machine, cpu_IdentifierString(), (int)cpu_topology_NumPackages(topology), (int)cpu_topology_CoresPerPackage(topology), (int)cpu_topology_LogicalPerCore(topology)); + fprintf(f, "CPU : %hs, %hs (%dx%dx%d)", un.machine, cpu_IdentifierString(), (int)cpu_topology_NumPackages(topology), (int)cpu_topology_CoresPerPackage(topology), (int)cpu_topology_LogicalPerCore(topology)); const double cpu_freq = os_cpu_ClockFrequency(); if(cpu_freq != 0.0f) { @@ -110,13 +110,13 @@ void WriteSystemInfo() fprintf(f, "Memory : %u MiB; %u MiB free\n", (unsigned)os_cpu_MemorySize(), (unsigned)os_cpu_MemoryAvailable()); // graphics - fwprintf(f, L"Graphics Card : %ls\n", gfx_card); - fprintf(f, "OpenGL Drivers : %s; %ls\n", glGetString(GL_VERSION), gfx_drv_ver); + fprintf(f, "Graphics Card : %ls\n", gfx_card); + fprintf(f, "OpenGL Drivers : %hs; %ls\n", glGetString(GL_VERSION), gfx_drv_ver); fprintf(f, "Video Mode : %dx%d:%d@%d\n", g_xres, g_yres, g_bpp, g_freq); // sound - fwprintf(f, L"Sound Card : %ls\n", snd_card); - fwprintf(f, L"Sound Drivers : %ls\n", snd_drv_ver); + fprintf(f, "Sound Card : %ls\n", snd_card); + fprintf(f, "Sound Drivers : %ls\n", snd_drv_ver); // @@ -129,7 +129,7 @@ void WriteSystemInfo() (void)gethostname(hostname, sizeof(hostname)-1); // -1 makes sure it's 0-terminated. if the function fails, // we display "(unknown)" and will skip IP output below. - fprintf(f, "Network Name : %s", hostname); + fprintf(f, "Network Name : %hs", hostname); { // ignore exception here - see https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=114032 @@ -147,7 +147,7 @@ void WriteSystemInfo() // separate entries but avoid trailing comma if(i != 0) fprintf(f, ", "); - fprintf(f, "%s", inet_ntoa(*ips[i])); + fprintf(f, "%hs", inet_ntoa(*ips[i])); } fprintf(f, ")"); } @@ -159,7 +159,7 @@ no_ip: // OpenGL extensions (write them last, since it's a lot of text) const char* exts = ogl_ExtensionString(); if (!exts) exts = "{unknown}"; - fprintf(f, "\nOpenGL Extensions: \n%s\n", SplitExts(exts).c_str()); + fprintf(f, "\nOpenGL Extensions: \n%hs\n", SplitExts(exts).c_str()); fclose(f); f = 0; diff --git a/source/ps/XML/Xeromyces.cpp b/source/ps/XML/Xeromyces.cpp index 359b0dfe8e..aaf6f48b80 100644 --- a/source/ps/XML/Xeromyces.cpp +++ b/source/ps/XML/Xeromyces.cpp @@ -33,7 +33,7 @@ static void errorHandler(void* UNUSED(userData), xmlErrorPtr error) { - LOG(CLogger::Error, LOG_CATEGORY, L"CXeromyces: Parse %hs: %ls:%d: %hs", + LOG(CLogger::Error, LOG_CATEGORY, L"CXeromyces: Parse %ls: %hs:%d: %hs", error->level == XML_ERR_WARNING ? L"warning" : L"error", error->file, error->line, error->message); // TODO: The (non-fatal) warnings and errors don't get stored in the XMB, @@ -83,7 +83,7 @@ void CXeromyces::GetXMBPath(const PIVFS& vfs, const VfsPath& xmlFilename, const const wchar_t* modPath = wcsstr(XMBRealPath, L"mods/"); debug_assert(modPath != 0); wchar_t modName[PATH_MAX]; - // .. NOTE: can't use %s, of course (keeps going beyond '/') + // .. NOTE: can't use %ls, of course (keeps going beyond '/') int matches = swscanf(modPath, L"mods/%[^/]", modName); debug_assert(matches == 1); diff --git a/source/ps/scripting/JSCollection.h b/source/ps/scripting/JSCollection.h index b91ac24c99..239a999099 100644 --- a/source/ps/scripting/JSCollection.h +++ b/source/ps/scripting/JSCollection.h @@ -249,7 +249,7 @@ template bool CJSCollection::Get if( ToPrimitive( g_ScriptingHost.GetContext(), m, Storage ) ) return( true ); - JS_ReportError( g_ScriptingHost.GetContext(), "Only objects of type %s can be stored in this collection.", ScriptType->name ); + JS_ReportError( g_ScriptingHost.GetContext(), "Only objects of type %hs can be stored in this collection.", ScriptType->name ); return( false ); } diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 3eac85abc8..1750fe075e 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -187,7 +187,7 @@ JSBool GetEntityTemplate( JSContext* cx, JSObject*, uintN argc, jsval* argv, jsv CEntityTemplate* v = g_EntityTemplateCollection.GetTemplate( templateName, player ); if( !v ) { - JS_ReportError( cx, "No such template: %s", CStr(templateName).c_str() ); + JS_ReportError( cx, "No such template: %hs", CStr(templateName).c_str() ); return( JS_TRUE ); } @@ -1064,13 +1064,13 @@ JSBool GetBuildTimestamp( JSContext* cx, JSObject*, uintN argc, jsval* argv, jsv switch(mode) { case -1: - sprintf_s(buf, ARRAY_SIZE(buf), "%s %s (%ls)", __DATE__, __TIME__, svn_revision); + sprintf_s(buf, ARRAY_SIZE(buf), "%hs %hs (%ls)", __DATE__, __TIME__, svn_revision); break; case 0: - sprintf_s(buf, ARRAY_SIZE(buf), "%s", __DATE__); + sprintf_s(buf, ARRAY_SIZE(buf), "%hs", __DATE__); break; case 1: - sprintf_s(buf, ARRAY_SIZE(buf), "%s", __TIME__); + sprintf_s(buf, ARRAY_SIZE(buf), "%hs", __TIME__); break; case 2: sprintf_s(buf, ARRAY_SIZE(buf), "%ls", svn_revision); diff --git a/source/scripting/ScriptingHost.cpp b/source/scripting/ScriptingHost.cpp index e8c03457d6..58cf986692 100644 --- a/source/scripting/ScriptingHost.cpp +++ b/source/scripting/ScriptingHost.cpp @@ -409,16 +409,16 @@ void ScriptingHost::ErrorReporter(JSContext* UNUSED(cx), const char* pmessage, J // apparently there is no further information in this struct we can use // because linebuf/tokenptr require a buffer to have been allocated. // that doesn't look possible since we are a callback and there is - // no mention in the dox about where this would happen (typical). + // no mention in the docs about where this would happen (typical). // for developer convenience: write to output window so they can - // doubleclick on that line and be taken to the error locus. + // double-click on that line and be taken to the error locus. debug_printf(L"%ls(%d): %ls\n", file.c_str(), line, message.c_str()); // note: CLogger's LOG already takes care of writing to the console, // so don't do that here. - LOG(CLogger::Error, LOG_CATEGORY, L"JavaScript Error (%s, line %d): %s", file.c_str(), line, message.c_str()); + LOG(CLogger::Error, LOG_CATEGORY, L"JavaScript Error (%ls, line %d): %ls", file.c_str(), line, message.c_str()); } #ifndef NDEBUG diff --git a/source/simulation/EntityScriptInterface.cpp b/source/simulation/EntityScriptInterface.cpp index 6df0f7e7cb..5fe869c068 100644 --- a/source/simulation/EntityScriptInterface.cpp +++ b/source/simulation/EntityScriptInterface.cpp @@ -183,7 +183,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsv if( !baseEntity ) { *rval = JSVAL_NULL; - JS_ReportError( cx, "No such template: %s", CStr8(templateName).c_str() ); + JS_ReportError( cx, "No such template: %hs", CStr8(templateName).c_str() ); return( JS_TRUE ); } diff --git a/source/simulation/Formation.cpp b/source/simulation/Formation.cpp index 31b5f54859..e760ee6fa2 100644 --- a/source/simulation/Formation.cpp +++ b/source/simulation/Formation.cpp @@ -120,8 +120,7 @@ bool CFormation::LoadXml(const VfsPath& filename) m_fileSpacing = CStr(Attr.Value).ToFloat(); else { - const char* invAttr = XeroFile.GetAttributeString(Attr.Name).c_str(); - LOG(CLogger::Error, LOG_CATEGORY, L"CFormation::LoadXml: Invalid attribute %hs defined in formation file %ls. Load failed.", invAttr, filename.string().c_str() ); + LOG(CLogger::Error, LOG_CATEGORY, L"CFormation::LoadXml: Invalid attribute %hs defined in formation file %ls. Load failed.", XeroFile.GetAttributeString(Attr.Name).c_str(), filename.string().c_str() ); return( false ); } } diff --git a/source/sound/CMusicPlayer.cpp b/source/sound/CMusicPlayer.cpp index 923d9dce24..667bf5ab7d 100644 --- a/source/sound/CMusicPlayer.cpp +++ b/source/sound/CMusicPlayer.cpp @@ -47,7 +47,7 @@ CMusicPlayer::~CMusicPlayer(void) Release(); } -void CMusicPlayer::Open(char* UNUSED(filename)) +void CMusicPlayer::Open(const VfsPath& UNUSED(pathname)) { // If a new file is opened while another is already in memory, // close the old one first. @@ -57,19 +57,19 @@ void CMusicPlayer::Open(char* UNUSED(filename)) /* void* p; size_t sizeOfFile; - if(vfs_load(filename, p, sizeOfFile) != INFO::OK) + if(vfs_load(pathname, p, sizeOfFile) != INFO::OK) { - LOG(CLogger::Error, LOG_CATEGORY, L"CMusicPlayer::open(): vfs_load for %s failed!\n", filename); + LOG(CLogger::Error, LOG_CATEGORY, L"CMusicPlayer::open(): vfs_load for %ls failed!\n", pathname.string().c_str()); return; } else - LOG(CLogger::Normal, LOG_CATEGORY, L"CMusicPlayer::open(): file %s loaded successfully\n", filename); + LOG(CLogger::Normal, LOG_CATEGORY, L"CMusicPlayer::open(): file %ls loaded successfully\n", pathname.string().c_str()); memFile.dataPtr = (char*)p; memFile.dataRead = 0; memFile.dataSize = sizeOfFile; */ /* - hf = vfs_open(filename); + hf = vfs_open(pathname); for(int i = 0; i < NUM_BUFS; i++) { @@ -233,7 +233,7 @@ void CMusicPlayer::Check() if(error != AL_NO_ERROR) { std::string str = errorString(error); - LOG(CLogger::Error, LOG_CATEGORY, L"OpenAL error: %s\n", str.c_str()); + LOG(CLogger::Error, LOG_CATEGORY, L"OpenAL error: %hs\n", str.c_str()); } */ } diff --git a/source/sound/CMusicPlayer.h b/source/sound/CMusicPlayer.h index c6e48490cc..8e241d646c 100644 --- a/source/sound/CMusicPlayer.h +++ b/source/sound/CMusicPlayer.h @@ -22,6 +22,8 @@ #include #include +#include "lib/file/vfs/vfs_path.h" + //#include "oal.h" /* @@ -48,7 +50,7 @@ class CMusicPlayer public: CMusicPlayer(void); ~CMusicPlayer(void); - void Open(char *filename); + void Open(const VfsPath& pathname); void Release(); bool Play(); bool IsPlaying();