diff --git a/source/graphics/CinemaTrack.cpp b/source/graphics/CinemaTrack.cpp index 7bc52eb852..264a9811d6 100644 --- a/source/graphics/CinemaTrack.cpp +++ b/source/graphics/CinemaTrack.cpp @@ -52,7 +52,7 @@ CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline) DistModePtr = &CCinemaPath::EaseOutIn; break; default: - debug_printf(L"Cinematic mode not found for %d ", data.m_Mode); + debug_printf("Cinematic mode not found for %d ", data.m_Mode); break; } @@ -74,7 +74,7 @@ CCinemaPath::CCinemaPath(const CCinemaData& data, const TNSpline& spline) DistStylePtr = &CCinemaPath::EaseSine; break; default: - debug_printf(L"Cinematic mode not found for %d !", data.m_Style); + debug_printf("Cinematic mode not found for %d !", data.m_Style); break; } //UpdateDuration(); diff --git a/source/graphics/Color.cpp b/source/graphics/Color.cpp index b36707bfc9..ab41a1a4df 100644 --- a/source/graphics/Color.cpp +++ b/source/graphics/Color.cpp @@ -90,6 +90,6 @@ void ColorActivateFastImpl() #endif else { - debug_printf(L"No SSE available. Slow fallback routines will be used.\n"); + debug_printf("No SSE available. Slow fallback routines will be used.\n"); } } diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index 95a54fef52..85996f45fb 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -1140,7 +1140,7 @@ void CXMLReader::ReadXML() } else { - debug_printf(L"Invalid XML element in map file: %hs\n", name.c_str()); + debug_printf("Invalid XML element in map file: %s\n", name.c_str()); debug_warn(L"Invalid map XML data"); } } diff --git a/source/graphics/TextRenderer.cpp b/source/graphics/TextRenderer.cpp index e5e8025ec3..9f7bb00bbe 100644 --- a/source/graphics/TextRenderer.cpp +++ b/source/graphics/TextRenderer.cpp @@ -108,7 +108,7 @@ void CTextRenderer::PrintfAdvance(const wchar_t* fmt, ...) va_end(args); if (ret < 0) - debug_printf(L"CTextRenderer::Printf vswprintf failed (buffer size exceeded?) - return value %d, errno %d\n", ret, errno); + debug_printf("CTextRenderer::Printf vswprintf failed (buffer size exceeded?) - return value %d, errno %d\n", ret, errno); PutAdvance(buf); } @@ -124,7 +124,7 @@ void CTextRenderer::PrintfAt(float x, float y, const wchar_t* fmt, ...) va_end(args); if (ret < 0) - debug_printf(L"CTextRenderer::PrintfAt vswprintf failed (buffer size exceeded?) - return value %d, errno %d\n", ret, errno); + debug_printf("CTextRenderer::PrintfAt vswprintf failed (buffer size exceeded?) - return value %d, errno %d\n", ret, errno); Put(x, y, buf); } diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index 3ab9b9e7f4..c24877243e 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -993,7 +993,7 @@ void CGUI::Xeromyces_ReadRootObjects(XMBElement Element, CXeromyces* pFile, boos XMBElementList children = Element.GetChildNodes(); for (int i=0; iev.edit.start, ev->ev.edit.length); + debug_printf("SDL_TEXTEDITING: text=%s, start=%d, length=%d\n", rawText, ev->ev.edit.start, ev->ev.edit.length); m_WantedX=0.0f; if (SelectingText()) diff --git a/source/gui/scripting/ScriptFunctions.cpp b/source/gui/scripting/ScriptFunctions.cpp index 84145d8384..3d98cc51d3 100644 --- a/source/gui/scripting/ScriptFunctions.cpp +++ b/source/gui/scripting/ScriptFunctions.cpp @@ -612,7 +612,7 @@ void SetCameraTarget(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), float x, fl // Useful for testing the crashlog/stack trace code. int Crash(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)) { - debug_printf(L"Crashing at user's request.\n"); + debug_printf("Crashing at user's request.\n"); return *(volatile int*)0; } diff --git a/source/lib/allocators/dynarray.cpp b/source/lib/allocators/dynarray.cpp index a8b80ead05..22cab0691f 100644 --- a/source/lib/allocators/dynarray.cpp +++ b/source/lib/allocators/dynarray.cpp @@ -112,7 +112,7 @@ Status da_set_size(DynArray* da, size_t new_size) { ok = vm::Commit(uintptr_t(end), size_delta_pa); if(!ok) - debug_printf(L"Commit failed (%p %lld)\n", end, (long long)size_delta_pa); + debug_printf("Commit failed (%p %lld)\n", (void *)end, (long long)size_delta_pa); } // shrinking else if(size_delta_pa < 0) diff --git a/source/lib/debug.cpp b/source/lib/debug.cpp index 35102c38ab..df29334cd6 100644 --- a/source/lib/debug.cpp +++ b/source/lib/debug.cpp @@ -74,9 +74,9 @@ static const size_t MAX_TAGS = 20; static u32 tags[MAX_TAGS]; static size_t num_tags; -void debug_filter_add(const wchar_t* tag) +void debug_filter_add(const char* tag) { - const u32 hash = fnv_hash(tag, wcslen(tag)*sizeof(tag[0])); + const u32 hash = fnv_hash(tag, strlen(tag)*sizeof(tag[0])); // make sure it isn't already in the list for(size_t i = 0; i < MAX_TAGS; i++) @@ -93,9 +93,9 @@ void debug_filter_add(const wchar_t* tag) tags[num_tags++] = hash; } -void debug_filter_remove(const wchar_t* tag) +void debug_filter_remove(const char* tag) { - const u32 hash = fnv_hash(tag, wcslen(tag)*sizeof(tag[0])); + const u32 hash = fnv_hash(tag, strlen(tag)*sizeof(tag[0])); for(size_t i = 0; i < MAX_TAGS; i++) { @@ -116,7 +116,7 @@ void debug_filter_clear() std::fill(tags, tags+MAX_TAGS, 0); } -bool debug_filter_allows(const wchar_t* text) +bool debug_filter_allows(const char* text) { size_t i; for(i = 0; ; i++) @@ -139,19 +139,24 @@ bool debug_filter_allows(const wchar_t* text) } #undef debug_printf // allowing #defining it out -void debug_printf(const wchar_t* fmt, ...) +void debug_printf(const char* fmt, ...) { - wchar_t buf[16384]; - + char buf[16384]; + va_list ap; va_start(ap, fmt); - const int numChars = vswprintf_s(buf, ARRAY_SIZE(buf), fmt, ap); - if(numChars < 0) - debug_break(); // poor man's assert - avoid infinite loop because ENSURE also uses debug_printf + const int numChars = vsprintf_s(buf, ARRAY_SIZE(buf), fmt, ap); + if (numChars < 0) + debug_break(); // poor man's assert - avoid infinite loop because ENSURE also uses debug_printf va_end(ap); - if(debug_filter_allows(buf)) - debug_puts(buf); + debug_puts_filtered(buf); +} + +void debug_puts_filtered(const char* text) +{ + if(debug_filter_allows(text)) + debug_puts(text); } @@ -460,7 +465,7 @@ ErrorReaction debug_DisplayError(const wchar_t* description, const wchar_t* filename = path_name_only(pathname); // display in output window; double-click will navigate to error location. - debug_printf(L"%ls(%d): %ls\n", filename, line, description); + debug_printf("%s(%d): %s\n", utf8_from_wstring(filename).c_str(), line, utf8_from_wstring(description).c_str()); ErrorMessageMem emm; const wchar_t* text = debug_BuildErrorMessage(description, filename, line, func, context, lastFuncToSkip, &emm); diff --git a/source/lib/debug.h b/source/lib/debug.h index 9459da4375..ea581fd3ae 100644 --- a/source/lib/debug.h +++ b/source/lib/debug.h @@ -66,7 +66,7 @@ extern void debug_break(); * * @param fmt Format string and varargs; see printf. **/ -LIB_API void debug_printf(const wchar_t* fmt, ...) WPRINTF_ARGS(1); +LIB_API void debug_printf(const char* fmt, ...) PRINTF_ARGS(1); /** @@ -232,13 +232,13 @@ LIB_API ErrorReaction debug_DisplayError(const wchar_t* description, size_t flag * in future, allow output with the given tag to proceed. * no effect if already added. **/ -LIB_API void debug_filter_add(const wchar_t* tag); +LIB_API void debug_filter_add(const char* tag); /** * in future, discard output with the given tag. * no effect if not currently added. **/ -LIB_API void debug_filter_remove(const wchar_t* tag); +LIB_API void debug_filter_remove(const char* tag); /** * clear all filter state; equivalent to debug_filter_remove for @@ -251,7 +251,12 @@ LIB_API void debug_filter_clear(); * useful for a series of debug_printfs - avoids needing to add a tag to * each of their format strings. **/ -LIB_API bool debug_filter_allows(const wchar_t* text); +LIB_API bool debug_filter_allows(const char* text); + +/** + * call debug_puts if debug_filter_allows allows the string. + **/ +LIB_API void debug_puts_filtered(const char* text); /** * write an error description and all logs into crashlog.txt @@ -263,7 +268,7 @@ LIB_API bool debug_filter_allows(const wchar_t* text); * @return Status; ERR::REENTERED if reentered via recursion or * multithreading (not allowed since an infinite loop may result). **/ -LIB_API Status debug_WriteCrashlog(const wchar_t* text); +LIB_API Status debug_WriteCrashlog(const char* text); //----------------------------------------------------------------------------- @@ -489,7 +494,7 @@ LIB_API Status debug_DumpStack(wchar_t* buf, size_t maxChars, void* context, con * this can be quite slow (~1 ms)! On Windows, it uses OutputDebugString * (entails context switch), otherwise stdout+fflush (waits for IO). **/ -LIB_API void debug_puts(const wchar_t* text); +LIB_API void debug_puts(const char* text); /** * return the caller of a certain function on the call stack. diff --git a/source/lib/file/common/file_stats.cpp b/source/lib/file/common/file_stats.cpp index ddbf76fa3c..a8f06dc361 100644 --- a/source/lib/file/common/file_stats.cpp +++ b/source/lib/file/common/file_stats.cpp @@ -264,13 +264,13 @@ template int percent(T num, T divisor) void file_stats_dump() { - if(!debug_filter_allows(L"FILE_STATS|")) + if(!debug_filter_allows("FILE_STATS|")) return; const double KB = 1e3; const double MB = 1e6; const double ms = 1e-3; - debug_printf(L"--------------------------------------------------------------------------------\n"); - debug_printf(L"File statistics:\n"); + debug_printf("--------------------------------------------------------------------------------\n"); + debug_printf("File statistics:\n"); // note: we split the reports into several debug_printfs for clarity; // this is necessary anyway due to fixed-size buffer. diff --git a/source/lib/file/file_system.cpp b/source/lib/file/file_system.cpp index 1c2606d208..ac972fa4f2 100644 --- a/source/lib/file/file_system.cpp +++ b/source/lib/file/file_system.cpp @@ -153,7 +153,7 @@ Status CreateDirectories(const OsPath& path, mode_t mode) errno = 0; if(wmkdir(path, mode) != 0) { - debug_printf(L"CreateDirectories: failed to mkdir %ls (mode %d)", path.string().c_str(), mode); + debug_printf("CreateDirectories: failed to mkdir %s (mode %d)", path.string8().c_str(), mode); WARN_RETURN(StatusFromErrno()); } diff --git a/source/lib/file/io/io.h b/source/lib/file/io/io.h index 29dd1cbde6..42fd490e17 100644 --- a/source/lib/file/io/io.h +++ b/source/lib/file/io/io.h @@ -269,7 +269,7 @@ static inline Status Run(const Operation& op, const Parameters& p = Parameters() COMPILER_FENCE; const double t1 = timer_Time(); const off_t totalSize = p.blockSize? numBlocks*p.blockSize : op.size; - debug_printf(L"IO: %.2f MB/s (%.2f)\n", totalSize/(t1-t0)/1e6, (t1-t0)*1e3); + debug_printf("IO: %.2f MB/s (%.2f)\n", totalSize/(t1-t0)/1e6, (t1-t0)*1e3); #endif return INFO::OK; diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index 35e414942f..28e61b20b0 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -66,7 +66,7 @@ static Status CreateDirectory(const OsPath& path) return ERR::FILE_ACCESS; // unexpected failure - debug_printf(L"wmkdir failed with errno=%d\n", errno); + debug_printf("wmkdir failed with errno=%d\n", errno); DEBUG_WARN_ERR(ERR::LOGIC); WARN_RETURN(StatusFromErrno()); } diff --git a/source/lib/ogl.cpp b/source/lib/ogl.cpp index f374e35439..5c701fd980 100644 --- a/source/lib/ogl.cpp +++ b/source/lib/ogl.cpp @@ -375,8 +375,8 @@ static void importExtensionFunctions() static void dump_gl_error(GLenum err) { - debug_printf(L"OGL| "); -#define E(e) case e: debug_printf(L"%ls\n", WIDEN(#e)); break; + debug_printf("OGL| "); +#define E(e) case e: debug_printf("%s\n", #e); break; switch (err) { E(GL_INVALID_ENUM) @@ -388,7 +388,7 @@ static void dump_gl_error(GLenum err) #endif E(GL_OUT_OF_MEMORY) E(GL_INVALID_FRAMEBUFFER_OPERATION) - default: debug_printf(L"Unknown GL error: %04x\n", err); break; + default: debug_printf("Unknown GL error: %04x\n", err); break; } #undef E } @@ -414,7 +414,7 @@ void ogl_WarnIfErrorLoc(const char *file, int line) } if(error_enountered) - debug_printf(L"%hs:%d: OpenGL error(s) occurred: %04x\n", file, line, (unsigned int)first_error); + debug_printf("%s:%d: OpenGL error(s) occurred: %04x\n", file, line, (unsigned int)first_error); } @@ -452,7 +452,7 @@ bool ogl_SquelchError(GLenum err_to_ignore) } if(error_enountered) - debug_printf(L"OpenGL error(s) occurred: %04x\n", (unsigned int)first_error); + debug_printf("OpenGL error(s) occurred: %04x\n", (unsigned int)first_error); return error_ignored; } diff --git a/source/lib/path.h b/source/lib/path.h index 89e13c6e6f..989f956c8e 100644 --- a/source/lib/path.h +++ b/source/lib/path.h @@ -249,7 +249,7 @@ public: private: void PrintToDebugOutput() const { - debug_printf(L"Path %ls, separator %c\n", path.c_str(), separator); + debug_printf("Path %s, separator %c\n", string8().c_str(), (char)separator); } void DetectSeparator() diff --git a/source/lib/res/h_mgr.cpp b/source/lib/res/h_mgr.cpp index ffae058471..3e782ba074 100644 --- a/source/lib/res/h_mgr.cpp +++ b/source/lib/res/h_mgr.cpp @@ -258,7 +258,7 @@ static Status h_data_tag_type(const Handle h, const H_Type type, HDATA*& hd) // h_alloc makes sure type isn't 0, so no need to check that here. if(hd->type != type) { - debug_printf(L"h_mgr: expected type %ls, got %ls\n", hd->type->name, type->name); + debug_printf("h_mgr: expected type %s, got %s\n", utf8_from_wstring(hd->type->name).c_str(), utf8_from_wstring(type->name).c_str()); WARN_RETURN(ERR::H_TYPE_MISMATCH); } @@ -565,12 +565,12 @@ static void h_free_hd(HDATA* hd) #ifndef NDEBUG // to_string is slow for some handles, so avoid calling it if unnecessary - if(debug_filter_allows(L"H_MGR|")) + if(debug_filter_allows("H_MGR|")) { wchar_t buf[H_STRING_LEN]; if(vtbl->to_string(hd->user, buf) < 0) wcscpy_s(buf, ARRAY_SIZE(buf), L"(error)"); - debug_printf(L"H_MGR| free %ls %ls accesses=%lu %ls\n", hd->type->name, hd->pathname.string().c_str(), (unsigned long)hd->num_derefs, buf); + debug_printf("H_MGR| free %s %s accesses=%lu %s\n", utf8_from_wstring(hd->type->name).c_str(), hd->pathname.string8().c_str(), (unsigned long)hd->num_derefs, utf8_from_wstring(buf).c_str()); } #endif @@ -761,7 +761,7 @@ static Status Init() static void Shutdown() { - debug_printf(L"H_MGR| shutdown. any handle frees after this are leaks!\n"); + debug_printf("H_MGR| shutdown. any handle frees after this are leaks!\n"); // objects that store handles to other objects are destroyed before their // children, so the subsequent forced destruction of the child here will // raise a double-free warning unless we ignore it. (#860, #915, #920) diff --git a/source/lib/self_test.cpp b/source/lib/self_test.cpp index 0a15f0db62..d7705052b1 100644 --- a/source/lib/self_test.cpp +++ b/source/lib/self_test.cpp @@ -59,7 +59,7 @@ int self_test_register(SelfTestRecord* r) void self_test_run_all() { - debug_printf(L"SELF TESTS:\n"); + debug_printf("SELF TESTS:\n"); const double t0 = timer_Time(); // someone somewhere may want to run self-tests twice (e.g. to help @@ -73,7 +73,7 @@ void self_test_run_all() } const double dt = timer_Time() - t0; - debug_printf(L"-- done (elapsed time %.0f ms)\n", dt*1e3); + debug_printf("-- done (elapsed time %.0f ms)\n", dt*1e3); } #endif diff --git a/source/lib/sysdep/arch/x86_x64/apic.cpp b/source/lib/sysdep/arch/x86_x64/apic.cpp index edc126a9a4..3dd3eef038 100644 --- a/source/lib/sysdep/arch/x86_x64/apic.cpp +++ b/source/lib/sysdep/arch/x86_x64/apic.cpp @@ -71,7 +71,7 @@ static Status GetAndValidateApicIds() // having one zero-valued ID is legitimate) if(numUnique == 1 && sortedApicIds[0] == 0 && numIds != 1) { - debug_printf(L"APIC: all zero\n"); + debug_printf("APIC: all zero\n"); return ERR::CPU_FEATURE_MISSING; // NOWARN } @@ -79,7 +79,7 @@ static Status GetAndValidateApicIds() // imperfect or doesn't allow access to all processors. if(numUnique != numIds) { - debug_printf(L"APIC: not unique\n"); + debug_printf("APIC: not unique\n"); return ERR::FAIL; // NOWARN } diff --git a/source/lib/sysdep/arch/x86_x64/cache.cpp b/source/lib/sysdep/arch/x86_x64/cache.cpp index 80fc086db2..717da409e6 100644 --- a/source/lib/sysdep/arch/x86_x64/cache.cpp +++ b/source/lib/sysdep/arch/x86_x64/cache.cpp @@ -536,7 +536,7 @@ static const Characteristics* CharacteristicsFromDescriptor(Descriptor descripto return &characteristics; } - debug_printf(L"Unknown cache/TLB descriptor 0x%x\n", (unsigned int)descriptor); + debug_printf("Unknown cache/TLB descriptor 0x%x\n", (unsigned int)descriptor); return 0; } diff --git a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp index 93c5ad2d80..863bf4649f 100644 --- a/source/lib/sysdep/os/linux/dir_watch_inotify.cpp +++ b/source/lib/sysdep/os/linux/dir_watch_inotify.cpp @@ -156,13 +156,13 @@ static void* inotify_event_loop(void*) else if(errno == EBADF) { // probably just lost the connection to inotify - kill the thread - debug_printf(L"inotify_event_loop: Invalid file descriptor inotifyfd=%d\n", inotifyfd); + debug_printf("inotify_event_loop: Invalid file descriptor inotifyfd=%d\n", inotifyfd); return NULL; } else { // oops - debug_printf(L"inotify_event_loop: select error errno=%d\n", errno); + debug_printf("inotify_event_loop: select error errno=%d\n", errno); return NULL; } errno = 0; @@ -261,7 +261,7 @@ Status dir_watch_Poll(DirWatchNotifications& notifications) } else { - debug_printf(L"dir_watch_Poll: Notification with invalid watch descriptor wd=%d\n", polled_notifications[i].wd); + debug_printf("dir_watch_Poll: Notification with invalid watch descriptor wd=%d\n", polled_notifications[i].wd); } } diff --git a/source/lib/sysdep/os/osx/osx_sys_cursor.mm b/source/lib/sysdep/os/osx/osx_sys_cursor.mm index fbda78b6b8..f4da463ec5 100644 --- a/source/lib/sysdep/os/osx/osx_sys_cursor.mm +++ b/source/lib/sysdep/os/osx/osx_sys_cursor.mm @@ -36,7 +36,7 @@ Status sys_cursor_create(int w, int h, void* bgra_img, int hx, int hy, sys_curso colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:w*4 bitsPerPixel:0]; if (!bitmap) { - debug_printf(L"sys_cursor_create: Error creating NSBitmapImageRep!\n"); + debug_printf("sys_cursor_create: Error creating NSBitmapImageRep!\n"); return ERR::FAIL; } @@ -56,7 +56,7 @@ Status sys_cursor_create(int w, int h, void* bgra_img, int hx, int hy, sys_curso if (!image) { [bitmap release]; - debug_printf(L"sys_cursor_create: Error creating NSImage!\n"); + debug_printf("sys_cursor_create: Error creating NSImage!\n"); return ERR::FAIL; } @@ -67,7 +67,7 @@ Status sys_cursor_create(int w, int h, void* bgra_img, int hx, int hy, sys_curso if (!impl) { - debug_printf(L"sys_cursor_create: Error creating NSCursor!\n"); + debug_printf("sys_cursor_create: Error creating NSCursor!\n"); return ERR::FAIL; } diff --git a/source/lib/sysdep/os/unix/udbg.cpp b/source/lib/sysdep/os/unix/udbg.cpp index 415c28d803..9470be573f 100644 --- a/source/lib/sysdep/os/unix/udbg.cpp +++ b/source/lib/sysdep/os/unix/udbg.cpp @@ -79,7 +79,7 @@ void udbg_launch_debugger() else if (ret > 0) { // Parent (original) fork: - debug_printf(L"Sleeping until debugger attaches.\nPlease wait.\n"); + debug_printf("Sleeping until debugger attaches.\nPlease wait.\n"); sleep(DEBUGGER_WAIT); } else // fork error, ret == -1 @@ -92,25 +92,16 @@ void udbg_launch_debugger() #include -void debug_puts(const wchar_t* text) +void debug_puts(const char* text) { - // The Android logger doesn't like "%ls" format strings, so convert - // the message to UTF-8 before outputting - Status err; - std::string str = utf8_from_wstring(text, &err); - __android_log_print(ANDROID_LOG_WARN, "pyrogenesis", "%s", str.c_str()); + __android_log_print(ANDROID_LOG_WARN, "pyrogenesis", "%s", text); } #else -void debug_puts(const wchar_t* text) +void debug_puts(const char* text) { - // printf doesn't like %ls strings that contain non-ASCII characters - // (it tends to print nothing and return an error), so convert to - // UTF-8 before outputting - Status err; - std::string str = utf8_from_wstring(text, &err); - printf("%s", str.c_str()); + printf("%s", text); fflush(stdout); } diff --git a/source/lib/sysdep/os/unix/unix.cpp b/source/lib/sysdep/os/unix/unix.cpp index 58599abc50..390bc161fd 100644 --- a/source/lib/sysdep/os/unix/unix.cpp +++ b/source/lib/sysdep/os/unix/unix.cpp @@ -205,7 +205,7 @@ static ErrorReactionInternal try_gui_display_error(const wchar_t* text, bool man ErrorReactionInternal sys_display_error(const wchar_t* text, size_t flags) { - debug_printf(L"%ls\n\n", text); + debug_printf("%s\n\n", utf8_from_wstring(text).c_str()); const bool manual_break = (flags & DE_MANUAL_BREAK ) != 0; const bool allow_suppress = (flags & DE_ALLOW_SUPPRESS) != 0; @@ -358,7 +358,7 @@ Status sys_open_url(const std::string& url) execlp(URL_OPEN_COMMAND, URL_OPEN_COMMAND, url.c_str(), (const char*)NULL); - debug_printf(L"Failed to run '" URL_OPEN_COMMAND "' command\n"); + debug_printf("Failed to run '" URL_OPEN_COMMAND "' command\n"); // We can't call exit() because that'll try to free resources which were the parent's, // so just abort here diff --git a/source/lib/sysdep/os/unix/x/x.cpp b/source/lib/sysdep/os/unix/x/x.cpp index 050780567d..2684ae5494 100644 --- a/source/lib/sysdep/os/unix/x/x.cpp +++ b/source/lib/sysdep/os/unix/x/x.cpp @@ -33,6 +33,7 @@ #if HAVE_X #include "lib/debug.h" +#include "lib/utf8.h" #include "lib/sysdep/gfx.h" #include "lib/sysdep/cursor.h" @@ -127,16 +128,16 @@ static bool get_wminfo(SDL_SysWMinfo& wminfo) if(ret == -1) { - debug_printf(L"SDL_GetWMInfo failed\n"); + debug_printf("SDL_GetWMInfo failed\n"); return false; } if(ret == 0) { - debug_printf(L"SDL_GetWMInfo is not implemented on this platform\n"); + debug_printf("SDL_GetWMInfo is not implemented on this platform\n"); return false; } - debug_printf(L"SDL_GetWMInfo returned an unknown value: %d\n", ret); + debug_printf("SDL_GetWMInfo returned an unknown value: %d\n", ret); return false; } @@ -213,7 +214,7 @@ wchar_t *sys_clipboard_get() &len, &bytes_left, &data); if(result != Success) - debug_printf(L"clipboard_get: result: %d type:%lu len:%lu format:%d bytes_left:%lu\n", + debug_printf("clipboard_get: result: %d type:%lu len:%lu format:%d bytes_left:%lu\n", result, type, len, format, bytes_left); if(result == Success && bytes_left > 0) { @@ -224,8 +225,8 @@ wchar_t *sys_clipboard_get() if(result == Success) { - debug_printf(L"clipboard_get: XGetWindowProperty succeeded, returning data\n"); - debug_printf(L"clipboard_get: data was: \"%hs\", type was %lu, XA_STRING atom is %lu\n", data, type, XA_STRING); + debug_printf("clipboard_get: XGetWindowProperty succeeded, returning data\n"); + debug_printf("clipboard_get: data was: \"%s\", type was %lu, XA_STRING atom is %lu\n", (char *)data, type, XA_STRING); if(type == XA_STRING) //Latin-1: Just copy into low byte of wchar_t { @@ -238,7 +239,7 @@ wchar_t *sys_clipboard_get() } else { - debug_printf(L"clipboard_get: XGetWindowProperty failed!\n"); + debug_printf("clipboard_get: XGetWindowProperty failed!\n"); return NULL; } } @@ -374,7 +375,7 @@ Status sys_clipboard_set(const wchar_t *str) { ONCE(x11_clipboard_init()); - debug_printf(L"sys_clipboard_set: %ls\n", str); + debug_printf("sys_clipboard_set: %s\n", utf8_from_wstring(str).c_str()); if(selection_data) { @@ -429,7 +430,7 @@ static XcursorPixel cursor_pixel_to_x11_format(const XcursorPixel& bgra_pixel) Status sys_cursor_create(int w, int h, void* bgra_img, int hx, int hy, sys_cursor* cursor) { - debug_printf(L"sys_cursor_create: using Xcursor to create %d x %d cursor\n", w, h); + debug_printf("sys_cursor_create: using Xcursor to create %d x %d cursor\n", w, h); XcursorImage* image = XcursorImageCreate(w, h); if(!image) WARN_RETURN(ERR::FAIL); diff --git a/source/lib/sysdep/os/win/tests/test_wdbg_sym.h b/source/lib/sysdep/os/win/tests/test_wdbg_sym.h index e0d7383e07..88846bad3d 100644 --- a/source/lib/sysdep/os/win/tests/test_wdbg_sym.h +++ b/source/lib/sysdep/os/win/tests/test_wdbg_sym.h @@ -101,8 +101,8 @@ class TestWdbgSym : public CxxTest::TestSuite wchar_t chars[] = { 'w','c','h','a','r','s',0 }; wchar_t many_wchars[1024]; memset(many_wchars, 'a', sizeof(many_wchars)); - debug_printf(L"\n(dumping stack frames may result in access violations...)\n"); - debug_printf(L" locals: %.0d %.0c %.0c %.0g %.0g %.0d %.0d\n", ints[0], chars[0], many_wchars[0], large_array_of_large_structs[0].d1, small_array_of_large_structs[0].d1, large_array_of_small_structs[0].i1, small_array_of_small_structs[0].i1); + debug_printf("\n(dumping stack frames may result in access violations...)\n"); + debug_printf(" locals: %.0d %.0c %.0c %.0g %.0g %.0d %.0d\n", ints[0], chars[0], many_wchars[0], large_array_of_large_structs[0].d1, small_array_of_large_structs[0].d1, large_array_of_small_structs[0].i1, small_array_of_small_structs[0].i1); // note: we don't want any kind of dialog to be raised, because // this test now always runs. therefore, just make sure a decent @@ -120,7 +120,7 @@ class TestWdbgSym : public CxxTest::TestSuite #endif debug_FreeErrorMessage(&emm); - debug_printf(L"(done dumping stack frames)\n"); + debug_printf("(done dumping stack frames)\n"); } // also used by test_stl as an element type @@ -254,17 +254,17 @@ class TestWdbgSym : public CxxTest::TestSuite static HDC s_hdc = (HDC)0xff0; #if 0 // output only needed when debugging - debug_printf(L"\nTEST_ADDRS\n"); - debug_printf(L"p_int addr=%p val=%d\n", &p_int, p_int); - debug_printf(L"p_double addr=%p val=%g\n", &p_double, p_double); - debug_printf(L"p_pchar addr=%p val=%hs\n", &p_pchar, p_pchar); - debug_printf(L"p_uintptr addr=%p val=%lu\n", &p_uintptr, p_uintptr); + debug_printf("\nTEST_ADDRS\n"); + debug_printf("p_int addr=%p val=%d\n", &p_int, p_int); + debug_printf("p_double addr=%p val=%g\n", &p_double, p_double); + debug_printf("p_pchar addr=%p val=%s\n", &p_pchar, p_pchar); + debug_printf("p_uintptr addr=%p val=%lu\n", &p_uintptr, p_uintptr); - debug_printf(L"l_uint addr=%p val=%u\n", &l_uint, l_uint); - debug_printf(L"l_wchars addr=%p val=%ls\n", &l_wchars, l_wchars); - debug_printf(L"l_enum addr=%p val=%d\n", &l_enum, l_enum); - debug_printf(L"l_u8s addr=%p val=%d\n", &l_u8s, l_u8s); - debug_printf(L"l_funcptr addr=%p val=%p\n", &l_funcptr, l_funcptr); + debug_printf("l_uint addr=%p val=%u\n", &l_uint, l_uint); + debug_printf("l_wchars addr=%p val=%s\n", &l_wchars, utf8_from_wstring(l_wchars)); + debug_printf("l_enum addr=%p val=%d\n", &l_enum, l_enum); + debug_printf("l_u8s addr=%p val=%d\n", &l_u8s, l_u8s); + debug_printf("l_funcptr addr=%p val=%p\n", &l_funcptr, l_funcptr); #else UNUSED2(p_uintptr); UNUSED2(p_pchar); diff --git a/source/lib/sysdep/os/win/wdbg.cpp b/source/lib/sysdep/os/win/wdbg.cpp index 84a28563ec..d0370a03c7 100644 --- a/source/lib/sysdep/os/win/wdbg.cpp +++ b/source/lib/sysdep/os/win/wdbg.cpp @@ -92,9 +92,9 @@ bool debug_IsStackPointer(void* p) } -void debug_puts(const wchar_t* text) +void debug_puts(const char* text) { - OutputDebugStringW(text); + OutputDebugStringW(wstring_from_utf8(text).c_str()); } diff --git a/source/lib/sysdep/os/win/wdbg_sym.cpp b/source/lib/sysdep/os/win/wdbg_sym.cpp index bbbf764bb1..0ca635ce10 100644 --- a/source/lib/sysdep/os/win/wdbg_sym.cpp +++ b/source/lib/sysdep/os/win/wdbg_sym.cpp @@ -812,7 +812,7 @@ static Status DetermineSymbolAddress(DWORD id, const SYMBOL_INFOW* sym, const Du *pp = (const u8*)(uintptr_t)addr; - debug_printf(L"SYM| %ls at %p flags=%X dk=%d sym->addr=%I64X fp=%I64x\n", sym->Name, *pp, sym->Flags, dataKind, sym->Address, state.stackFrame->AddrFrame.Offset); + debug_printf("SYM| %s at %p flags=%X dk=%d sym->addr=%I64X fp=%I64x\n", utf8_from_wstring(sym->Name).c_str(), *pp, sym->Flags, dataKind, sym->Address, state.stackFrame->AddrFrame.Offset); return INFO::OK; } @@ -1170,7 +1170,7 @@ static bool ptr_already_visited(const u8* p) static bool haveComplained; if(!haveComplained) { - debug_printf(L"WARNING: ptr_already_visited: capacity exceeded, increase maxVisited\n"); + debug_printf("WARNING: ptr_already_visited: capacity exceeded, increase maxVisited\n"); debug_break(); haveComplained = true; } @@ -1469,7 +1469,7 @@ static Status udt_dump_normal(const wchar_t* type_name, const u8* p, size_t size continue; if(ofs >= size) { - debug_printf(L"INVALID_UDT %ls %d %d\n", type_name, ofs, size); + debug_printf("INVALID_UDT %s %d %d\n", utf8_from_wstring(type_name).c_str(), ofs, size); } //ENSURE(ofs < size); @@ -1581,7 +1581,7 @@ static Status dump_sym_unknown(DWORD type_id, const u8* UNUSED(p), DumpState& st if(!pSymGetTypeInfo(hProcess, state.moduleBase, type_id, TI_GET_SYMTAG, &type_tag)) WARN_RETURN(ERR::SYM_TYPE_INFO_UNAVAILABLE); - debug_printf(L"SYM: unknown tag: %d\n", type_tag); + debug_printf("SYM: unknown tag: %d\n", type_tag); out(L"(unknown symbol type)"); return INFO::OK; } diff --git a/source/lib/sysdep/os/win/wdir_watch.cpp b/source/lib/sysdep/os/win/wdir_watch.cpp index 0b4868efa3..a73948dcaf 100644 --- a/source/lib/sysdep/os/win/wdir_watch.cpp +++ b/source/lib/sysdep/os/win/wdir_watch.cpp @@ -119,7 +119,7 @@ public: { // (this could conceivably happen if a kernel debugger // hangs the system during the wait duration.) - debug_printf(L"WARNING: IO may still be pending; to avoid memory corruption, we won't free the buffer.\n"); + debug_printf("WARNING: IO may still be pending; to avoid memory corruption, we won't free the buffer.\n"); DEBUG_WARN_ERR(ERR::TIMED_OUT); // intentionally leak m_data and m_ovl! } diff --git a/source/lib/sysdep/os/win/whrt/counter.h b/source/lib/sysdep/os/win/whrt/counter.h index 0e269d8919..b850e80d3b 100644 --- a/source/lib/sysdep/os/win/whrt/counter.h +++ b/source/lib/sysdep/os/win/whrt/counter.h @@ -35,7 +35,7 @@ public: // (compiled-generated) ctor only sets up the vptr virtual ~ICounter() {} - virtual const wchar_t* Name() const = 0; + virtual const char* Name() const = 0; // Activate with an error return value is much cleaner+safer than // throwing exceptions in the ctor. diff --git a/source/lib/sysdep/os/win/whrt/hpet.cpp b/source/lib/sysdep/os/win/whrt/hpet.cpp index d7ef9375e0..de584c2c3f 100644 --- a/source/lib/sysdep/os/win/whrt/hpet.cpp +++ b/source/lib/sysdep/os/win/whrt/hpet.cpp @@ -51,9 +51,9 @@ public: { } - virtual const wchar_t* Name() const + virtual const char* Name() const { - return L"HPET"; + return "HPET"; } Status Activate() @@ -213,7 +213,7 @@ private: const u32 period_fs = (u32)bits(caps_and_id, 32, 63); ENSURE(period_fs != 0); // "a value of 0 in this field is not permitted" frequency = 1e15 / period_fs; - debug_printf(L"HPET: rev=%X vendor=%X bits=%d period=%08X freq=%g\n", revision, vendorID, counterBits, period_fs, frequency); + debug_printf("HPET: rev=%X vendor=%X bits=%d period=%08X freq=%g\n", revision, vendorID, counterBits, period_fs, frequency); if(period_fs > 0x05F5E100) // 100 ns (spec guarantees >= 10 MHz) return ERR::CORRUPTED; // avoid using HPET (e.g. if calibration was still in progress) diff --git a/source/lib/sysdep/os/win/whrt/pmt.cpp b/source/lib/sysdep/os/win/whrt/pmt.cpp index b0837a2d65..4932ca1202 100644 --- a/source/lib/sysdep/os/win/whrt/pmt.cpp +++ b/source/lib/sysdep/os/win/whrt/pmt.cpp @@ -47,9 +47,9 @@ public: { } - virtual const wchar_t* Name() const + virtual const char* Name() const { - return L"PMT"; + return "PMT"; } Status Activate() diff --git a/source/lib/sysdep/os/win/whrt/qpc.cpp b/source/lib/sysdep/os/win/whrt/qpc.cpp index c7ebfbd120..61c6293e46 100644 --- a/source/lib/sysdep/os/win/whrt/qpc.cpp +++ b/source/lib/sysdep/os/win/whrt/qpc.cpp @@ -44,9 +44,9 @@ public: { } - virtual const wchar_t* Name() const + virtual const char* Name() const { - return L"QPC"; + return "QPC"; } Status Activate() diff --git a/source/lib/sysdep/os/win/whrt/tgt.cpp b/source/lib/sysdep/os/win/whrt/tgt.cpp index dd08e4574f..e38063b922 100644 --- a/source/lib/sysdep/os/win/whrt/tgt.cpp +++ b/source/lib/sysdep/os/win/whrt/tgt.cpp @@ -49,9 +49,9 @@ static const UINT PERIOD_MS = 2; class CounterTGT : public ICounter { public: - virtual const wchar_t* Name() const + virtual const char* Name() const { - return L"TGT"; + return "TGT"; } Status Activate() diff --git a/source/lib/sysdep/os/win/whrt/tsc.cpp b/source/lib/sysdep/os/win/whrt/tsc.cpp index 394108d6bf..adc51cee07 100644 --- a/source/lib/sysdep/os/win/whrt/tsc.cpp +++ b/source/lib/sysdep/os/win/whrt/tsc.cpp @@ -126,9 +126,9 @@ static bool IsSandyBridge() class CounterTSC : public ICounter { public: - virtual const wchar_t* Name() const + virtual const char* Name() const { - return L"TSC"; + return "TSC"; } Status Activate() diff --git a/source/lib/sysdep/os/win/whrt/whrt.cpp b/source/lib/sysdep/os/win/whrt/whrt.cpp index e7988a2a5e..0ff0ca3480 100644 --- a/source/lib/sysdep/os/win/whrt/whrt.cpp +++ b/source/lib/sysdep/os/win/whrt/whrt.cpp @@ -77,13 +77,13 @@ static ICounter* GetNextBestSafeCounter() Status err = ActivateCounter(counter); if(err == INFO::OK) { - debug_printf(L"HRT: using name=%ls freq=%f\n", counter->Name(), counter->NominalFrequency()); + debug_printf("HRT: using name=%s freq=%f\n", counter->Name(), counter->NominalFrequency()); return counter; // found a safe counter } else { wchar_t buf[100]; - debug_printf(L"HRT: activating %ls failed: %ls\n", counter->Name(), StatusDescription(err, buf, ARRAY_SIZE(buf))); + debug_printf("HRT: activating %s failed: %s\n", counter->Name(), utf8_from_wstring(StatusDescription(err, buf, ARRAY_SIZE(buf))).c_str()); DestroyCounter(counter); } } @@ -111,7 +111,7 @@ static void InitCounter() nominalFrequency = counter->NominalFrequency(); resolution = counter->Resolution(); counterBits = counter->CounterBits(); - debug_printf(L"HRT: counter=%ls freq=%g res=%g bits=%d\n", counter->Name(), nominalFrequency, resolution, counterBits); + debug_printf("HRT: counter=%s freq=%g res=%g bits=%d\n", counter->Name(), nominalFrequency, resolution, counterBits); // sanity checks ENSURE(nominalFrequency >= 500.0-DBL_EPSILON); diff --git a/source/lib/sysdep/os/win/winit.cpp b/source/lib/sysdep/os/win/winit.cpp index 717966abe9..2231f14b1c 100644 --- a/source/lib/sysdep/os/win/winit.cpp +++ b/source/lib/sysdep/os/win/winit.cpp @@ -80,7 +80,7 @@ static void CallFunctionPointers(PfnLibError* begin, PfnLibError* end) } const DWORD t1 = GetTickCount(); - debug_printf(L"WINIT| total elapsed time in callbacks %d ms (+-10)\n", t1-t0); + debug_printf("WINIT| total elapsed time in callbacks %d ms (+-10)\n", t1-t0); } diff --git a/source/lib/sysdep/os/win/wnuma.cpp b/source/lib/sysdep/os/win/wnuma.cpp index a9ab8d0330..1cecaa5219 100644 --- a/source/lib/sysdep/os/win/wnuma.cpp +++ b/source/lib/sysdep/os/win/wnuma.cpp @@ -491,12 +491,12 @@ static bool VerifyPages(void* mem, size_t size, size_t pageSize, size_t node) return false; if((attributes.LargePage != 0) != (pageSize == largePageSize)) { - debug_printf(L"NUMA: is not a large page\n"); + debug_printf("NUMA: is not a large page\n"); return false; } if(attributes.Node != node) { - debug_printf(L"NUMA: allocated from remote node\n"); + debug_printf("NUMA: allocated from remote node\n"); return false; } } diff --git a/source/lib/sysdep/os/win/wposix/waio.cpp b/source/lib/sysdep/os/win/wposix/waio.cpp index 6bca04c005..802710c451 100644 --- a/source/lib/sysdep/os/win/wposix/waio.cpp +++ b/source/lib/sysdep/os/win/wposix/waio.cpp @@ -172,7 +172,7 @@ struct OvlAllocator // POD void Shutdown() { if(extant != 0) - debug_printf(L"waio: OvlAllocator::Shutdown with extant=%d\n", extant); + debug_printf("waio: OvlAllocator::Shutdown with extant=%d\n", extant); InterlockedFlushSList(&freelist); @@ -462,7 +462,7 @@ Status waio_Preallocate(int fd, off_t size) if(GetLastError() == ERROR_DISK_FULL) SetLastError(0); else - debug_printf(L"waio_Preallocate(%lld) failed: %d\n", size, GetLastError()); + debug_printf("waio_Preallocate(%lld) failed: %d\n", size, GetLastError()); return ERR::FAIL; // NOWARN (either out of disk space, or error was printed) } diff --git a/source/lib/sysdep/os/win/wposix/wmman.cpp b/source/lib/sysdep/os/win/wposix/wmman.cpp index bf32e02d83..6754968374 100644 --- a/source/lib/sysdep/os/win/wposix/wmman.cpp +++ b/source/lib/sysdep/os/win/wposix/wmman.cpp @@ -109,7 +109,7 @@ static Status mmap_mem(void* start, size_t len, int prot, int flags, int fd, voi void* p = VirtualAlloc(start, len, allocationType, protect); if(!p) { - debug_printf(L"wmman: VirtualAlloc(%p, 0x%I64X) failed\n", start, len); + debug_printf("wmman: VirtualAlloc(%p, 0x%I64X) failed\n", start, len); WARN_RETURN(ERR::NO_MEM); } *pp = p; diff --git a/source/lib/sysdep/os/win/wposix/wpthread.cpp b/source/lib/sysdep/os/win/wposix/wpthread.cpp index 9da6b09df8..508a28fa5e 100644 --- a/source/lib/sysdep/os/win/wposix/wpthread.cpp +++ b/source/lib/sysdep/os/win/wposix/wpthread.cpp @@ -671,7 +671,7 @@ int pthread_cancel(pthread_t thread) { HANDLE hThread = HANDLE_from_pthread(thread); TerminateThread(hThread, 0); - debug_printf(L"WARNING: pthread_cancel is unsafe\n"); + debug_printf("WARNING: pthread_cancel is unsafe\n"); return 0; } diff --git a/source/lib/sysdep/os/win/wsdl.cpp b/source/lib/sysdep/os/win/wsdl.cpp index e2cb3fab91..ac9e49d7dd 100644 --- a/source/lib/sysdep/os/win/wsdl.cpp +++ b/source/lib/sysdep/os/win/wsdl.cpp @@ -161,7 +161,7 @@ private: // at least one 32-bit XP system STILL fails here, // so don't raise an error dialog. if(!ok) - debug_printf(L"SetDeviceGammaRamp failed twice. Oh well.\n"); + debug_printf("SetDeviceGammaRamp failed twice. Oh well.\n"); } return (ok == TRUE); } diff --git a/source/lib/sysdep/os/win/wvm.cpp b/source/lib/sysdep/os/win/wvm.cpp index 79706dd3de..c679fa7842 100644 --- a/source/lib/sysdep/os/win/wvm.cpp +++ b/source/lib/sysdep/os/win/wvm.cpp @@ -138,12 +138,12 @@ void DumpStatistics() return; const size_t largePageRatio = totalCommits? largePageCommits*100/totalCommits : 0; - debug_printf(L"%d commits (%d, i.e. %d%% of them via large pages)\n", totalCommits, largePageCommits, largePageRatio); + debug_printf("%d commits (%d, i.e. %d%% of them via large pages)\n", totalCommits, largePageCommits, largePageRatio); if(processorsWithNoCommits != 0) - debug_printf(L" processors with no commits: %x\n", processorsWithNoCommits); + debug_printf(" processors with no commits: %x\n", processorsWithNoCommits); if(numa_NumNodes() > 1) - debug_printf(L"NUMA factor: %.2f\n", numa_Factor()); + debug_printf("NUMA factor: %.2f\n", numa_Factor()); } @@ -242,7 +242,7 @@ static void* AllocateLargeOrSmallPages(uintptr_t address, size_t size, DWORD all { MEMORY_BASIC_INFORMATION mbi = {0}; (void)VirtualQuery(LPCVOID(address), &mbi, sizeof(mbi)); // return value is #bytes written in mbi - debug_printf(L"Allocation failed: base=%p allocBase=%p allocProt=%d size=%d state=%d prot=%d type=%d\n", mbi.BaseAddress, mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.State, mbi.Protect, mbi.Type); + debug_printf("Allocation failed: base=%p allocBase=%p allocProt=%d size=%d state=%d prot=%d type=%d\n", mbi.BaseAddress, mbi.AllocationBase, mbi.AllocationProtect, mbi.RegionSize, mbi.State, mbi.Protect, mbi.Type); } return 0; @@ -293,7 +293,7 @@ CACHE_ALIGNED(struct AddressRangeDescriptor) // POD base = (intptr_t)AllocateLargeOrSmallPages(0, totalSize, MEM_RESERVE); if(!base) { - debug_printf(L"AllocateLargeOrSmallPages of %lld failed\n", (u64)totalSize); + debug_printf("AllocateLargeOrSmallPages of %lld failed\n", (u64)totalSize); DEBUG_DISPLAY_ERROR(ErrorString()); return ERR::NO_MEM; // NOWARN (error string is more helpful) } @@ -411,7 +411,7 @@ void ReleaseAddressSpace(void* p, size_t UNUSED(size)) d->Free(); else { - debug_printf(L"No AddressRangeDescriptor contains %P\n", p); + debug_printf("No AddressRangeDescriptor contains %P\n", p); ENSURE(0); } } @@ -502,7 +502,7 @@ static LONG CALLBACK VectoredHandler(const PEXCEPTION_POINTERS ep) bool ok = d->Commit(alignedAddress); if(!ok) { - debug_printf(L"VectoredHandler: Commit(0x%p) failed; address=0x%p\n", alignedAddress, address); + debug_printf("VectoredHandler: Commit(0x%p) failed; address=0x%p\n", alignedAddress, address); ENSURE(0); return EXCEPTION_CONTINUE_SEARCH; } diff --git a/source/lib/sysdep/smbios.cpp b/source/lib/sysdep/smbios.cpp index 88422823ca..5c410872d9 100644 --- a/source/lib/sysdep/smbios.cpp +++ b/source/lib/sysdep/smbios.cpp @@ -227,7 +227,7 @@ void FieldInitializer::operator()(size_t flags, const char*& t, con if(number > strings.size()) { - debug_printf(L"SMBIOS: invalid string number %d (count=%d)\n", number, (int)strings.size()); + debug_printf("SMBIOS: invalid string number %d (count=%d)\n", number, (int)strings.size()); return; } @@ -436,7 +436,7 @@ static Status InitStructures() { if(header+1 > end) { - debug_printf(L"SMBIOS: table not terminated\n"); + debug_printf("SMBIOS: table not terminated\n"); break; } if(header->id == 127) // end @@ -455,7 +455,7 @@ static Status InitStructures() default: if(32 < header->id && header->id < 126) // only mention non-proprietary structures of which we are not aware - debug_printf(L"SMBIOS: unknown structure type %d\n", header->id); + debug_printf("SMBIOS: unknown structure type %d\n", header->id); break; } diff --git a/source/lib/timer.cpp b/source/lib/timer.cpp index 7cdbb924dc..37b81145d1 100644 --- a/source/lib/timer.cpp +++ b/source/lib/timer.cpp @@ -180,8 +180,8 @@ TimerClient* timer_AddClient(TimerClient* tc, const wchar_t* description) void timer_DisplayClientTotals() { - debug_printf(L"TIMER TOTALS (%lu clients)\n", (unsigned long)numClients); - debug_printf(L"-----------------------------------------------------\n"); + debug_printf("TIMER TOTALS (%lu clients)\n", (unsigned long)numClients); + debug_printf("-----------------------------------------------------\n"); while(clients) { @@ -191,44 +191,44 @@ void timer_DisplayClientTotals() clients = tc->next; numClients--; - const std::wstring duration = tc->sum.ToString(); - debug_printf(L" %ls: %ls (%lux)\n", tc->description, duration.c_str(), (unsigned long)tc->num_calls); + const std::string duration = tc->sum.ToString(); + debug_printf(" %s: %s (%lux)\n", utf8_from_wstring(tc->description).c_str(), duration.c_str(), (unsigned long)tc->num_calls); } - debug_printf(L"-----------------------------------------------------\n"); + debug_printf("-----------------------------------------------------\n"); } //----------------------------------------------------------------------------- -std::wstring StringForSeconds(double seconds) +std::string StringForSeconds(double seconds) { double scale = 1e6; - const wchar_t* unit = L" us"; + const char* unit = " us"; if(seconds > 1.0) - scale = 1, unit = L" s"; + scale = 1, unit = " s"; else if(seconds > 1e-3) - scale = 1e3, unit = L" ms"; + scale = 1e3, unit = " ms"; - std::wstringstream ss; + std::stringstream ss; ss << seconds*scale; ss << unit; return ss.str(); } -std::wstring StringForCycles(Cycles cycles) +std::string StringForCycles(Cycles cycles) { double scale = 1.0; - const wchar_t* unit = L" c"; + const char* unit = " c"; if(cycles > 10000000000LL) // 10 Gc - scale = 1e-9, unit = L" Gc"; + scale = 1e-9, unit = " Gc"; else if(cycles > 10000000) // 10 Mc - scale = 1e-6, unit = L" Mc"; + scale = 1e-6, unit = " Mc"; else if(cycles > 10000) // 10 kc - scale = 1e-3, unit = L" kc"; + scale = 1e-3, unit = " kc"; - std::wstringstream ss; + std::stringstream ss; ss << cycles*scale; ss << unit; return ss.str(); diff --git a/source/lib/timer.h b/source/lib/timer.h index 0d0401827a..3ea03229f4 100644 --- a/source/lib/timer.h +++ b/source/lib/timer.h @@ -34,6 +34,7 @@ # include "lib/sysdep/arch/x86_x64/x86_x64.h" // x86_x64::rdtsc #endif +#include "lib/utf8.h" /** * timer_Time will subsequently return values relative to the current time. @@ -62,8 +63,8 @@ typedef i64 Cycles; * internal helper functions for returning an easily readable * string (i.e. re-scaled to appropriate units) **/ -LIB_API std::wstring StringForSeconds(double seconds); -LIB_API std::wstring StringForCycles(Cycles cycles); +LIB_API std::string StringForSeconds(double seconds); +LIB_API std::string StringForCycles(Cycles cycles); //----------------------------------------------------------------------------- @@ -82,8 +83,8 @@ public: ~ScopeTimer() { const double t1 = timer_Time(); - const std::wstring elapsedTimeString = StringForSeconds(t1-m_t0); - debug_printf(L"TIMER| %ls: %ls\n", m_description, elapsedTimeString.c_str()); + const std::string elapsedTimeString = StringForSeconds(t1-m_t0); + debug_printf("TIMER| %s: %s\n", utf8_from_wstring(m_description).c_str(), elapsedTimeString.c_str()); } private: @@ -197,7 +198,7 @@ retry: m_cycles -= t.m_cycles; } - std::wstring ToString() const + std::string ToString() const { ENSURE(m_cycles >= 0); return StringForCycles(m_cycles); @@ -251,7 +252,7 @@ retry: m_seconds -= t.m_seconds; } - std::wstring ToString() const + std::string ToString() const { ENSURE(m_seconds >= 0.0); return StringForSeconds(m_seconds); diff --git a/source/network/tests/test_Net.h b/source/network/tests/test_Net.h index 6568b7e528..a4c0439315 100644 --- a/source/network/tests/test_Net.h +++ b/source/network/tests/test_Net.h @@ -77,7 +77,7 @@ public: for (size_t i = 0; ; ++i) { -// debug_printf(L"."); +// debug_printf("."); for (size_t j = 0; j < clients.size(); ++j) clients[j]->Poll(); @@ -99,7 +99,7 @@ public: { for (size_t i = 0; ; ++i) { -// debug_printf(L"."); +// debug_printf("."); server.Poll(); for (size_t j = 0; j < clients.size(); ++j) clients[j]->Poll(); @@ -161,7 +161,7 @@ public: clients.push_back(&client3); connect(server, clients); - debug_printf(L"%ls", client1.TestReadGuiMessages().c_str()); + debug_printf("%s", utf8_from_wstring(client1.TestReadGuiMessages()).c_str()); server.StartGame(); SDL_Delay(100); @@ -230,7 +230,7 @@ public: clients.push_back(&client3); connect(server, clients); - debug_printf(L"%ls", client1.TestReadGuiMessages().c_str()); + debug_printf("%s", utf8_from_wstring(client1.TestReadGuiMessages()).c_str()); server.StartGame(); SDL_Delay(100); @@ -261,12 +261,12 @@ public: client1Game.GetTurnManager()->PostCommand(cmd); } - debug_printf(L"==== Disconnecting client 2\n"); + debug_printf("==== Disconnecting client 2\n"); client2.DestroyConnection(); clients.erase(clients.begin()+1); - debug_printf(L"==== Connecting client 2B\n"); + debug_printf("==== Connecting client 2B\n"); CGame client2BGame(true); CNetClient client2B(&client2BGame); @@ -277,7 +277,7 @@ public: for (size_t i = 0; ; ++i) { - debug_printf(L"[%u]\n", client2B.GetCurrState()); + debug_printf("[%u]\n", client2B.GetCurrState()); client2B.Poll(); if (client2B.GetCurrState() == NCS_PREGAME) break; diff --git a/source/ps/ArchiveBuilder.cpp b/source/ps/ArchiveBuilder.cpp index 4adb3070ff..3317f4ae78 100644 --- a/source/ps/ArchiveBuilder.cpp +++ b/source/ps/ArchiveBuilder.cpp @@ -97,7 +97,7 @@ void CArchiveBuilder::Build(const OsPath& archive, bool compress) ) { VfsPath cachedPath; - debug_printf(L"Converting texture %ls\n", realPath.string().c_str()); + debug_printf("Converting texture %s\n", realPath.string8().c_str()); bool ok = textureManager.GenerateCachedTexture(path, cachedPath); ENSURE(ok); @@ -129,7 +129,7 @@ void CArchiveBuilder::Build(const OsPath& archive, bool compress) } VfsPath cachedPath; - debug_printf(L"Converting model %ls\n", realPath.string().c_str()); + debug_printf("Converting model %s\n", realPath.string8().c_str()); bool ok = colladaManager.GenerateCachedFile(path, type, cachedPath); // The DAE might fail to convert for whatever reason, and in that case @@ -149,14 +149,14 @@ void CArchiveBuilder::Build(const OsPath& archive, bool compress) continue; } - debug_printf(L"Adding %ls\n", realPath.string().c_str()); + debug_printf("Adding %s\n", realPath.string8().c_str()); writer->AddFile(realPath, path); // Also cache XMB versions of all XML files if (path.Extension() == L".xml") { VfsPath cachedPath; - debug_printf(L"Converting XML file %ls\n", realPath.string().c_str()); + debug_printf("Converting XML file %s\n", realPath.string8().c_str()); bool ok = xero.GenerateCachedXMB(m_VFS, path, cachedPath); ENSURE(ok); diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index e09dbbfdca..bdcbfd1fc0 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -522,7 +522,7 @@ void CConsole::InsertMessage(const wchar_t* szMessage, ...) va_start(args, szMessage); if (vswprintf(szBuffer, CONSOLE_MESSAGE_SIZE, szMessage, args) == -1) { - debug_printf(L"Error printfing console message (buffer size exceeded?)\n"); + debug_printf("Error printfing console message (buffer size exceeded?)\n"); // Make it obvious that the text was trimmed (assuming it was) wcscpy(szBuffer+CONSOLE_MESSAGE_SIZE-4, L"..."); diff --git a/source/ps/CLogger.cpp b/source/ps/CLogger.cpp index a46fd544b3..9a7d58f9b1 100644 --- a/source/ps/CLogger.cpp +++ b/source/ps/CLogger.cpp @@ -148,7 +148,7 @@ void CLogger::WriteMessage(const char* message, bool doRender = false) ++m_NumberOfMessages; // if (m_UseDebugPrintf) -// debug_printf(L"MESSAGE: %hs\n", message); +// debug_printf("MESSAGE: %s\n", message); *m_MainLog << "

" << cmessage << "

\n"; m_MainLog->flush(); @@ -169,7 +169,7 @@ void CLogger::WriteError(const char* message) ++m_NumberOfErrors; if (m_UseDebugPrintf) - debug_printf(L"ERROR: %hs\n", message); + debug_printf("ERROR: %s\n", message); if (g_Console) g_Console->InsertMessage(L"ERROR: %hs", message); *m_InterestingLog << "

ERROR: " << cmessage << "

\n"; @@ -189,7 +189,7 @@ void CLogger::WriteWarning(const char* message) ++m_NumberOfWarnings; if (m_UseDebugPrintf) - debug_printf(L"WARNING: %hs\n", message); + debug_printf("WARNING: %s\n", message); if (g_Console) g_Console->InsertMessage(L"WARNING: %hs", message); *m_InterestingLog << "

WARNING: " << cmessage << "

\n"; diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index c1600cc389..26400b05b2 100644 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -246,7 +246,7 @@ PSRETURN CGame::ReallyStartGame() if (g_NetClient) g_NetClient->LoadFinished(); - debug_printf(L"GAME STARTED, ALL INIT COMPLETE\n"); + debug_printf("GAME STARTED, ALL INIT COMPLETE\n"); // The call tree we've built for pregame probably isn't useful in-game. if (CProfileManager::IsInitialised()) diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index e85ccd762d..83611f76df 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -372,7 +372,7 @@ static size_t ChooseCacheSize() // always provide at least this much to ensure correct operation cache = std::max(cache, (ssize_t)64); - debug_printf(L"Cache: %d (total: %d) MiB\n", (int)cache, (int)total); + debug_printf("Cache: %d (total: %d) MiB\n", (int)cache, (int)total); return size_t(cache)*MiB; } @@ -847,7 +847,7 @@ void EarlyInit() debug_SetThreadName("main"); // add all debug_printf "tags" that we are interested in: - debug_filter_add(L"TIMER"); + debug_filter_add("TIMER"); timer_LatchStartTime(); @@ -865,7 +865,7 @@ void EarlyInit() #if MUST_INIT_X11 int status = XInitThreads(); if (status == 0) - debug_printf(L"Error enabling thread-safety via XInitThreads\n"); + debug_printf("Error enabling thread-safety via XInitThreads\n"); #endif // Initialise the low-quality rand function diff --git a/source/ps/GameSetup/Paths.cpp b/source/ps/GameSetup/Paths.cpp index 434f02cae4..b54772acfe 100644 --- a/source/ps/GameSetup/Paths.cpp +++ b/source/ps/GameSetup/Paths.cpp @@ -194,7 +194,7 @@ Paths::Paths(const CmdLineArgs& args) # if OS_MACOSX if (osx_IsAppBundleValid()) { - debug_printf(L"Valid app bundle detected\n"); + debug_printf("Valid app bundle detected\n"); std::string resourcesPath = osx_GetBundleResourcesPath(); // Ensure we have a valid resources path diff --git a/source/ps/Loader.cpp b/source/ps/Loader.cpp index ce4404a64d..5fa481f410 100644 --- a/source/ps/Loader.cpp +++ b/source/ps/Loader.cpp @@ -234,7 +234,7 @@ Status LDR_ProgressiveLoad(double time_budget, wchar_t* description, size_t max_ // either finished entirely, or failed => remove from queue. if(!timed_out) { - debug_printf(L"LOADER| completed %ls in %g ms; estimate was %g ms\n", lr.description.c_str(), task_elapsed_time*1e3, estimated_duration*1e3); + debug_printf("LOADER| completed %s in %g ms; estimate was %g ms\n", utf8_from_wstring(lr.description).c_str(), task_elapsed_time*1e3, estimated_duration*1e3); task_elapsed_time = 0.0; estimated_duration_tally += estimated_duration; load_requests.pop_front(); @@ -297,7 +297,7 @@ done: new_description = load_requests.front().description.c_str(); wcscpy_s(description, max_chars, new_description); - debug_printf(L"LOADER| returning; desc=%ls progress=%d\n", description, *progress_percent); + debug_printf("LOADER| returning; desc=%s progress=%d\n", utf8_from_wstring(description).c_str(), *progress_percent); return ret; } diff --git a/source/ps/Replay.cpp b/source/ps/Replay.cpp index 4a969ced73..df50463470 100644 --- a/source/ps/Replay.cpp +++ b/source/ps/Replay.cpp @@ -178,7 +178,7 @@ void CReplayPlayer::Replay(bool serializationtest) else if (type == "turn") { *m_Stream >> turn >> turnLength; - debug_printf(L"Turn %u (%u)... ", turn, turnLength); + debug_printf("Turn %u (%u)... ", turn, turnLength); } else if (type == "cmd") { @@ -208,9 +208,9 @@ void CReplayPlayer::Replay(bool serializationtest) ENSURE(ok); std::string hexHash = Hexify(hash); if (hexHash == replayHash) - debug_printf(L"hash ok (%hs)", hexHash.c_str()); + debug_printf("hash ok (%s)", hexHash.c_str()); else - debug_printf(L"HASH MISMATCH (%hs != %hs)", hexHash.c_str(), replayHash.c_str()); + debug_printf("HASH MISMATCH (%s != %s)", hexHash.c_str(), replayHash.c_str()); } } else if (type == "end") @@ -228,9 +228,9 @@ void CReplayPlayer::Replay(bool serializationtest) // std::string hash; // bool ok = game.GetSimulation2()->ComputeStateHash(hash, true); // ENSURE(ok); -// debug_printf(L"%hs", Hexify(hash).c_str()); +// debug_printf("%s", Hexify(hash).c_str()); - debug_printf(L"\n"); + debug_printf("\n"); g_Profiler.Frame(); @@ -242,7 +242,7 @@ void CReplayPlayer::Replay(bool serializationtest) } else { - debug_printf(L"Unrecognised replay token %hs\n", type.c_str()); + debug_printf("Unrecognised replay token %s\n", type.c_str()); } } @@ -251,7 +251,7 @@ void CReplayPlayer::Replay(bool serializationtest) std::string hash; bool ok = game.GetSimulation2()->ComputeStateHash(hash, false); ENSURE(ok); - debug_printf(L"# Final state: %hs\n", Hexify(hash).c_str()); + debug_printf("# Final state: %s\n", Hexify(hash).c_str()); timer_DisplayClientTotals(); diff --git a/source/ps/TouchInput.cpp b/source/ps/TouchInput.cpp index 390f11bcb9..ff52debf6f 100644 --- a/source/ps/TouchInput.cpp +++ b/source/ps/TouchInput.cpp @@ -62,7 +62,7 @@ bool CTouchInput::IsEnabled() void CTouchInput::OnFingerDown(int id, int x, int y) { - debug_printf(L"finger down %d %d %d; state %d\n", id, x, y, m_State); + debug_printf("finger down %d %d %d; state %d\n", id, x, y, m_State); m_Down[id] = true; m_Prev[id] = m_Pos[id] = CVector2D(x, y); @@ -80,7 +80,7 @@ void CTouchInput::OnFingerDown(int id, int x, int y) void CTouchInput::OnFingerUp(int id, int x, int y) { - debug_printf(L"finger up %d %d %d; state %d\n", id, x, y, m_State); + debug_printf("finger up %d %d %d; state %d\n", id, x, y, m_State); m_Down[id] = false; m_Pos[id] = CVector2D(x, y); @@ -113,7 +113,7 @@ void CTouchInput::OnFingerUp(int id, int x, int y) void CTouchInput::OnFingerMotion(int id, int x, int y) { - debug_printf(L"finger motion %d %d %d; state %d\n", id, x, y, m_State); + debug_printf("finger motion %d %d %d; state %d\n", id, x, y, m_State); CVector2D pos(x, y); @@ -267,7 +267,7 @@ InReaction CTouchInput::HandleEvent(const SDL_Event_* ev) case SDL_FINGERMOTION: { // Map finger events onto the mouse, for basic testing - debug_printf(L"finger %hs tid=%lld fid=%lld x=%f y=%f dx=%f dy=%f p=%f\n", + debug_printf("finger %s tid=%lld fid=%lld x=%f y=%f dx=%f dy=%f p=%f\n", ev->ev.type == SDL_FINGERDOWN ? "down" : ev->ev.type == SDL_FINGERUP ? "up" : ev->ev.type == SDL_FINGERMOTION ? "motion" : "?", diff --git a/source/ps/UserReport.cpp b/source/ps/UserReport.cpp index 755542d318..469b157de7 100644 --- a/source/ps/UserReport.cpp +++ b/source/ps/UserReport.cpp @@ -322,7 +322,7 @@ private: CScopeLock lock(m_WorkerMutex); m_Status = status; #if DEBUG_UPLOADS - debug_printf(L">>> CUserReporterWorker status: %hs\n", status.c_str()); + debug_printf(">>> CUserReporterWorker status: %s\n", status.c_str()); #endif } diff --git a/source/renderer/VertexArray.cpp b/source/renderer/VertexArray.cpp index 8363f55b93..8128e4140f 100644 --- a/source/renderer/VertexArray.cpp +++ b/source/renderer/VertexArray.cpp @@ -224,7 +224,7 @@ void VertexArray::Layout() m_Stride = 0; - //debug_printf(L"Layouting VertexArray\n"); + //debug_printf("Layouting VertexArray\n"); for (ssize_t idx = m_Attributes.size()-1; idx >= 0; --idx) { @@ -262,13 +262,13 @@ void VertexArray::Layout() if (m_Target == GL_ARRAY_BUFFER) m_Stride = Align<4>(m_Stride); - //debug_printf(L"%i: offset: %u\n", idx, attr->offset); + //debug_printf("%i: offset: %u\n", idx, attr->offset); } if (m_Target == GL_ARRAY_BUFFER) m_Stride = RoundStride(m_Stride); - //debug_printf(L"Stride: %u\n", m_Stride); + //debug_printf("Stride: %u\n", m_Stride); if (m_Stride) m_BackingStore = (char*)rtl_AllocateAligned(m_Stride * m_NumVertices, 16); diff --git a/source/renderer/VertexBuffer.cpp b/source/renderer/VertexBuffer.cpp index 6b3e399b77..a4c943d7a9 100644 --- a/source/renderer/VertexBuffer.cpp +++ b/source/renderer/VertexBuffer.cpp @@ -286,7 +286,7 @@ u8* CVertexBuffer::Bind() // Unmap might fail on e.g. resolution switches, so just try again // and hope it will eventually succeed - debug_printf(L"glUnmapBuffer failed, trying again..."); + debug_printf("glUnmapBuffer failed, trying again..."); } // Anything we just uploaded is clean; anything else is dirty @@ -337,16 +337,16 @@ size_t CVertexBuffer::GetBytesAllocated() const void CVertexBuffer::DumpStatus() { - debug_printf(L"freeverts = %d\n", (int)m_FreeVertices); + debug_printf("freeverts = %d\n", (int)m_FreeVertices); size_t maxSize = 0; typedef std::list::iterator Iter; for (Iter iter = m_FreeList.begin(); iter != m_FreeList.end(); ++iter) { - debug_printf(L"free chunk %p: size=%d\n", *iter, (int)((*iter)->m_Count)); + debug_printf("free chunk %p: size=%d\n", (void *)*iter, (int)((*iter)->m_Count)); maxSize = std::max((*iter)->m_Count, maxSize); } - debug_printf(L"max size = %d\n", (int)maxSize); + debug_printf("max size = %d\n", (int)maxSize); } bool CVertexBuffer::UseStreaming(GLenum usage) diff --git a/source/renderer/VertexBufferManager.cpp b/source/renderer/VertexBufferManager.cpp index c1f6e04f5e..0efed3ff19 100644 --- a/source/renderer/VertexBufferManager.cpp +++ b/source/renderer/VertexBufferManager.cpp @@ -63,12 +63,12 @@ CVertexBuffer::VBChunk* CVertexBufferManager::Allocate(size_t vertexSize, size_t typedef std::list::iterator Iter; #if DUMP_VB_STATS - debug_printf(L"\n============================\n# allocate vsize=%d nverts=%d\n\n", vertexSize, numVertices); + debug_printf("\n============================\n# allocate vsize=%d nverts=%d\n\n", vertexSize, numVertices); for (Iter iter = m_Buffers.begin(); iter != m_Buffers.end(); ++iter) { CVertexBuffer* buffer = *iter; if (buffer->CompatibleVertexType(vertexSize, usage, target)) { - debug_printf(L"%p\n", buffer); + debug_printf("%p\n", buffer); buffer->DumpStatus(); } } @@ -102,7 +102,7 @@ void CVertexBufferManager::Release(CVertexBuffer::VBChunk* chunk) { ENSURE(chunk); #if DUMP_VB_STATS - debug_printf(L"\n============================\n# release %p nverts=%d\n\n", chunk, chunk->m_Count); + debug_printf("\n============================\n# release %p nverts=%d\n\n", chunk, chunk->m_Count); #endif chunk->m_Owner->Release(chunk); } diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index 15873b2b00..487b409651 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -150,7 +150,7 @@ bool print(JSContext* cx, uint argc, jsval* vp) std::wstring str; if (!ScriptInterface::FromJSVal(cx, args[i], str)) return false; - debug_printf(L"%ls", str.c_str()); + debug_printf("%s", utf8_from_wstring(str).c_str()); } fflush(stdout); args.rval().setUndefined(); diff --git a/source/simulation2/components/CCmpRangeManager.cpp b/source/simulation2/components/CCmpRangeManager.cpp index 68f2ba0e18..191f02befb 100644 --- a/source/simulation2/components/CCmpRangeManager.cpp +++ b/source/simulation2/components/CCmpRangeManager.cpp @@ -649,17 +649,17 @@ public: { for (size_t i = 0; i < oldPlayerCounts.size(); ++i) { - debug_printf(L"%d: ", (int)i); + debug_printf("%d: ", (int)i); for (size_t j = 0; j < oldPlayerCounts[i].size(); ++j) - debug_printf(L"%d ", oldPlayerCounts[i][j]); - debug_printf(L"\n"); + debug_printf("%d ", oldPlayerCounts[i][j]); + debug_printf("\n"); } for (size_t i = 0; i < m_LosPlayerCounts.size(); ++i) { - debug_printf(L"%d: ", (int)i); + debug_printf("%d: ", (int)i); for (size_t j = 0; j < m_LosPlayerCounts[i].size(); ++j) - debug_printf(L"%d ", m_LosPlayerCounts[i][j]); - debug_printf(L"\n"); + debug_printf("%d ", m_LosPlayerCounts[i][j]); + debug_printf("\n"); } debug_warn(L"inconsistent player counts"); } diff --git a/source/simulation2/components/tests/test_scripts.h b/source/simulation2/components/tests/test_scripts.h index 40aa26325d..f548e06f24 100644 --- a/source/simulation2/components/tests/test_scripts.h +++ b/source/simulation2/components/tests/test_scripts.h @@ -60,7 +60,7 @@ public: { if (!VfsFileExists(L"simulation/components/tests/setup.js")) { - debug_printf(L"WARNING: Skipping component scripts tests (can't find binaries/data/mods/public/simulation/components/tests/setup.js)\n"); + debug_printf("WARNING: Skipping component scripts tests (can't find binaries/data/mods/public/simulation/components/tests/setup.js)\n"); return; } diff --git a/source/simulation2/system/DynamicSubscription.cpp b/source/simulation2/system/DynamicSubscription.cpp index 5894560074..a2e1a58e88 100644 --- a/source/simulation2/system/DynamicSubscription.cpp +++ b/source/simulation2/system/DynamicSubscription.cpp @@ -71,18 +71,18 @@ void CDynamicSubscription::DebugDump() { std::set::iterator it; - debug_printf(L"components:"); + debug_printf("components:"); for (size_t i = 0; i < m_Components.size(); i++) - debug_printf(L" %p", m_Components[i]); - debug_printf(L"\n"); + debug_printf(" %p", (void *)m_Components[i]); + debug_printf("\n"); - debug_printf(L"added:"); + debug_printf("added:"); for (it = m_Added.begin(); it != m_Added.end(); ++it) - debug_printf(L" %p", *it); - debug_printf(L"\n"); + debug_printf(" %p", (void *)*it); + debug_printf("\n"); - debug_printf(L"removed:"); + debug_printf("removed:"); for (it = m_Removed.begin(); it != m_Removed.end(); ++it) - debug_printf(L" %p", *it); - debug_printf(L"\n"); + debug_printf(" %p", (void *)*it); + debug_printf("\n"); } diff --git a/source/simulation2/tests/test_Serializer.h b/source/simulation2/tests/test_Serializer.h index 69acda6326..36958245a6 100644 --- a/source/simulation2/tests/test_Serializer.h +++ b/source/simulation2/tests/test_Serializer.h @@ -673,12 +673,12 @@ public: std::string hash; sim2.SerializeState(str); sim2.ComputeStateHash(hash, false); - debug_printf(L"\n"); - debug_printf(L"# size = %d\n", (int)str.str().length()); - debug_printf(L"# hash = "); + debug_printf("\n"); + debug_printf("# size = %d\n", (int)str.str().length()); + debug_printf("# hash = "); for (size_t i = 0; i < hash.size(); ++i) - debug_printf(L"%02x", (unsigned int)(u8)hash[i]); - debug_printf(L"\n"); + debug_printf("%02x", (unsigned int)(u8)hash[i]); + debug_printf("\n"); } double t = timer_Time(); @@ -691,7 +691,7 @@ public: } CALLGRIND_STOP_INSTRUMENTATION; t = timer_Time() - t; - debug_printf(L"# time = %f (%f/%d)\n", t/reps, t, (int)reps); + debug_printf("# time = %f (%f/%d)\n", t/reps, t, (int)reps); // Shut down the world delete &g_TexMan; diff --git a/source/soundmanager/SoundManager.cpp b/source/soundmanager/SoundManager.cpp index db34628585..c6484a6a5d 100644 --- a/source/soundmanager/SoundManager.cpp +++ b/source/soundmanager/SoundManager.cpp @@ -338,7 +338,7 @@ Status CSoundManager::AlcInit() const char* dev_name = (const char*)alcGetString(m_Device, ALC_DEVICE_SPECIFIER); if (err == ALC_NO_ERROR && m_Device && m_Context) - debug_printf(L"Sound: AlcInit success, using %hs\n", dev_name); + debug_printf("Sound: AlcInit success, using %s\n", dev_name); else { LOGERROR("Sound: AlcInit failed, m_Device=%p m_Context=%p dev_name=%s err=%x\n", (void *)m_Device, (void *)m_Context, dev_name, err); diff --git a/source/tools/atlas/GameInterface/CommandProc.cpp b/source/tools/atlas/GameInterface/CommandProc.cpp index 0a4c32c787..409956c526 100644 --- a/source/tools/atlas/GameInterface/CommandProc.cpp +++ b/source/tools/atlas/GameInterface/CommandProc.cpp @@ -128,7 +128,7 @@ void CommandProc::Merge() { const char* a = (*prev)->GetType(); const char* b = (*m_CurrentCommand)->GetType(); - debug_printf(L"[incompatible: %hs -> %hs]\n", a, b); + debug_printf("[incompatible: %s -> %s]\n", a, b); debug_warn(L"Merge illogic: incompatible command"); return; } diff --git a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp index 7f324a0117..ff882d7e6e 100644 --- a/source/tools/atlas/GameInterface/MessagePasserImpl.cpp +++ b/source/tools/atlas/GameInterface/MessagePasserImpl.cpp @@ -84,7 +84,7 @@ void MessagePasserImpl::Add(IMessage* msg) ENSURE(msg->GetType() == IMessage::Message); if (m_Trace) - debug_printf(L"%8.3f add message: %hs\n", timer_Time(), msg->GetName()); + debug_printf("%8.3f add message: %s\n", timer_Time(), msg->GetName()); { CScopeLock lock(m_Mutex); @@ -110,7 +110,7 @@ IMessage* MessagePasserImpl::Retrieve() } if (m_Trace && msg) - debug_printf(L"%8.3f retrieved message: %hs\n", timer_Time(), msg->GetName()); + debug_printf("%8.3f retrieved message: %s\n", timer_Time(), msg->GetName()); return msg; } @@ -121,7 +121,7 @@ void MessagePasserImpl::Query(QueryMessage* qry, void(* UNUSED(timeoutCallback) ENSURE(qry->GetType() == IMessage::Query); if (m_Trace) - debug_printf(L"%8.3f add query: %hs\n", timer_Time(), qry->GetName()); + debug_printf("%8.3f add query: %s\n", timer_Time(), qry->GetName()); // Set the semaphore, so we can block until the query has been handled qry->m_Semaphore = static_cast(m_Semaphore);