diff --git a/source/graphics/CinemaTrack.h b/source/graphics/CinemaTrack.h index cce0af533d..5adc2e1c0d 100644 --- a/source/graphics/CinemaTrack.h +++ b/source/graphics/CinemaTrack.h @@ -14,6 +14,8 @@ #define ES_SINE 4 #include +#include +#include #include "Camera.h" #include "CStr.h" #include "Vector3D.h" diff --git a/source/graphics/UnitManager.cpp b/source/graphics/UnitManager.cpp index c32e678a29..5838fe3616 100755 --- a/source/graphics/UnitManager.cpp +++ b/source/graphics/UnitManager.cpp @@ -8,6 +8,8 @@ #include "precompiled.h" +#include + #include "lib/res/res.h" #include "Model.h" #include "UnitManager.h" diff --git a/source/lib/debug.h b/source/lib/debug.h index 4a8f7e73d6..4a1556737f 100644 --- a/source/lib/debug.h +++ b/source/lib/debug.h @@ -171,12 +171,12 @@ STMT(\ // called when an assertion has failed; notifies the user via debug_display_error. -extern enum ErrorReaction debug_assert_failed(const char* assert_expr, +extern ErrorReaction debug_assert_failed(const char* assert_expr, const char* file, int line, const char* func); // called when a lib function wrapped in DEBUG_WARN_ERR failed; // notifies the user via debug_display_error. -extern enum ErrorReaction debug_warn_err(LibError err, +extern ErrorReaction debug_warn_err(LibError err, const char* file, int line, const char* func); @@ -198,29 +198,6 @@ extern void debug_wprintf(const wchar_t* fmt, ...); extern void debug_display_msgw(const wchar_t* caption, const wchar_t* msg); -// choices offered by the shared error dialog -enum ErrorReaction -{ - // ignore, continue as if nothing happened. - // note: don't start at 0 because that is interpreted as a - // DialogBoxParam failure. - ER_CONTINUE = 1, - - // ignore and do not report again. - // only returned if DE_ALLOW_SUPPRESS was passed. - // note: non-persistent; only applicable during this program run. - ER_SUPPRESS, - - // trigger breakpoint, i.e. enter debugger. - // only returned if DE_MANUAL_BREAK was passed; otherwise, - // debug_display_error will trigger a breakpoint itself. - ER_BREAK, - - // exit the program immediately. - // never returned; debug_display_error exits immediately. - ER_EXIT -}; - enum DisplayErrorFlags { // allow the suppress button (requires calling via macro that diff --git a/source/lib/lib_errors.h b/source/lib/lib_errors.h index 9a1788085f..6203516543 100644 --- a/source/lib/lib_errors.h +++ b/source/lib/lib_errors.h @@ -24,6 +24,30 @@ enum LibError { LIB_ERROR_DUMMY }; +// choices offered by the shared error dialog +enum ErrorReaction +{ + // ignore, continue as if nothing happened. + // note: don't start at 0 because that is interpreted as a + // DialogBoxParam failure. + ER_CONTINUE = 1, + + // ignore and do not report again. + // only returned if DE_ALLOW_SUPPRESS was passed. + // note: non-persistent; only applicable during this program run. + ER_SUPPRESS, + + // trigger breakpoint, i.e. enter debugger. + // only returned if DE_MANUAL_BREAK was passed; otherwise, + // debug_display_error will trigger a breakpoint itself. + ER_BREAK, + + // exit the program immediately. + // never returned; debug_display_error exits immediately. + ER_EXIT +}; + + // generate textual description of an error code. // stores up to in the given buffer. diff --git a/source/lib/res/sound/snd.cpp b/source/lib/res/sound/snd.cpp index 3e2d197fc7..46d745b9ec 100755 --- a/source/lib/res/sound/snd.cpp +++ b/source/lib/res/sound/snd.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include // (some math.h versions omit this) diff --git a/source/lib/sysdep/ia32.cpp b/source/lib/sysdep/ia32.cpp index 53bbe124e7..cc324819e9 100755 --- a/source/lib/sysdep/ia32.cpp +++ b/source/lib/sysdep/ia32.cpp @@ -154,7 +154,7 @@ __asm{ // calling conventions. // MSC, ICC and GCC currently return 64 bits in edx:eax, which even // matches rdtsc output, but we play it safe and return a temporary. -inline u64 rdtsc() +u64 rdtsc() { u64 c; #if HAVE_MS_ASM diff --git a/source/lib/sysdep/sysdep.h b/source/lib/sysdep/sysdep.h index ef98b2bd03..a3763386e7 100755 --- a/source/lib/sysdep/sysdep.h +++ b/source/lib/sysdep/sysdep.h @@ -119,6 +119,7 @@ extern void* alloca(size_t size); # define __func__ "(unknown)" #endif +#include "debug.h" //----------------------------------------------------------------------------- // sysdep API @@ -136,7 +137,6 @@ extern void sys_display_msgw(const wchar_t* caption, const wchar_t* msg); // show the error dialog. flags: see DisplayErrorFlags. // called from debug_display_error. -enum ErrorReaction; extern ErrorReaction sys_display_error(const wchar_t* text, int flags); diff --git a/source/lib/sysdep/unix/dir_watch_fam.cpp b/source/lib/sysdep/unix/dir_watch_fam.cpp index 2fa564a6b3..dda97bf0b4 100755 --- a/source/lib/sysdep/unix/dir_watch_fam.cpp +++ b/source/lib/sysdep/unix/dir_watch_fam.cpp @@ -57,7 +57,7 @@ int dir_cancel_watch(const intptr_t watch) int dir_get_changed_file(char* fn) { if(!initialized) - return -1; + return ERR_FAIL; FAMEvent e; while(FAMPending(&fc) > 0) @@ -69,9 +69,9 @@ int dir_get_changed_file(char* fn) const char* dir = dirs[e.fr.reqnum].c_str(); snprintf(n_path, PATH_MAX, "%s%c%s", dir, DIR_SEP, e.filename); CHECK_ERR(file_make_portable_path(n_path, fn)); - return 0; + return ERR_OK; } } - return 1; + return ERR_AGAIN; } diff --git a/source/lib/sysdep/unix/udbg.cpp b/source/lib/sysdep/unix/udbg.cpp index 5964ec43e0..4aa7f277a1 100755 --- a/source/lib/sysdep/unix/udbg.cpp +++ b/source/lib/sysdep/unix/udbg.cpp @@ -311,12 +311,12 @@ void demangle_buf(char *buf, const char *symbol, size_t n) free(alloc); } -int debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line) +static LibError debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line) { Dl_info syminfo; int res=dladdr(ptr, &syminfo); - if (res == 0) return -1; + if (res == 0) return ERR_FAIL; if (sym_name) { @@ -340,10 +340,10 @@ int debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line *line=0; } - return 0; + return ERR_OK; } -int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* line) +LibError debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* line) { ONCE(udbg_init()); @@ -403,7 +403,7 @@ int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* *line = ctx.line; } - return 0; + return ERR_OK; } #include "mmgr.h" diff --git a/source/lib/sysdep/unix/unix.cpp b/source/lib/sysdep/unix/unix.cpp index e0dfc32202..22d261c7df 100644 --- a/source/lib/sysdep/unix/unix.cpp +++ b/source/lib/sysdep/unix/unix.cpp @@ -25,19 +25,19 @@ void sys_display_msgw(const wchar_t* caption, const wchar_t* msg) } -int get_executable_name(char* n_path, size_t buf_size) +LibError sys_get_executable_name(char* n_path, size_t buf_size) { Dl_info dl_info; memset(&dl_info, 0, sizeof(dl_info)); - if (!dladdr((void *)get_executable_name, &dl_info) || + if (!dladdr((void *)sys_get_executable_name, &dl_info) || !dl_info.dli_fname ) { - return -ENOSYS; + return ERR_NO_SYS; } strncpy(n_path, dl_info.dli_fname, buf_size); - return 0; + return ERR_OK; } extern int cpus; @@ -53,8 +53,10 @@ int unix_get_cpu_info() // apparently not possible on non-Windows OSes because they seem to lack // a CPU affinity API. see sysdep.h comment. -int sys_on_each_cpu(void(*cb)()) +LibError sys_on_each_cpu(void(*cb)()) { + UNUSED2(cb); + return ERR_NO_SYS; } @@ -119,27 +121,41 @@ ErrorReaction sys_display_error(const wchar_t* text, int flags) // take advantage of hardware mouse cursors instead of the (jerky when // loading) OpenGL cursor. -int sys_cursor_create(uint w, uint h, void* bgra_img, +LibError sys_cursor_create(uint w, uint h, void* bgra_img, uint hx, uint hy, void** cursor) { + UNUSED2(w); + UNUSED2(h); + UNUSED2(hx); + UNUSED2(hy); + UNUSED2(bgra_img); + *cursor = 0; - return 0; + return ERR_OK; } -int sys_cursor_set(void* cursor) +LibError sys_cursor_set(void* cursor) { - return 0; + UNUSED2(cursor); + + return ERR_OK; } -int sys_cursor_free(void* cursor) +LibError sys_cursor_free(void* cursor) { - return 0; + UNUSED2(cursor); + + return ERR_OK; } -int sys_error_description_r(int err, char* buf, size_t max_chars) +LibError sys_error_description_r(int err, char* buf, size_t max_chars) { + UNUSED2(err); + UNUSED2(buf); + UNUSED2(max_chars); + // don't need to do anything: lib/errors.cpp already queries // libc's strerror(). if we ever end up needing translation of // e.g. Qt or X errors, that'd go here. - return -1; -} \ No newline at end of file + return ERR_FAIL; +} diff --git a/source/lib/sysdep/unix/x.cpp b/source/lib/sysdep/unix/x.cpp index 2276b6887c..61c4acc8dc 100755 --- a/source/lib/sysdep/unix/x.cpp +++ b/source/lib/sysdep/unix/x.cpp @@ -31,11 +31,11 @@ // useful for choosing a video mode. not called by detect(). // if we fail, outputs are unchanged (assumed initialized to defaults) -int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) +LibError get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) { Display* disp = XOpenDisplay(0); if(!disp) - return -1; + return ERR_FAIL; int screen = XDefaultScreen(disp); @@ -59,17 +59,17 @@ int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) if(freq) *freq = 0; XCloseDisplay(disp); - return 0; + return ERR_OK; } // useful for determining aspect ratio. not called by detect(). // if we fail, outputs are unchanged (assumed initialized to defaults) -int get_monitor_size(int& width_mm, int& height_mm) +LibError get_monitor_size(int& width_mm, int& height_mm) { Display* disp = XOpenDisplay(0); if(!disp) - return -1; + return ERR_FAIL; int screen = XDefaultScreen(disp); @@ -77,7 +77,7 @@ int get_monitor_size(int& width_mm, int& height_mm) height_mm=XDisplayHeightMM(disp, screen); XCloseDisplay(disp); - return 0; + return ERR_OK; } /* @@ -113,7 +113,7 @@ Expansions: * Implement UTF-8 format support (should be interresting for international users) */ -wchar_t *clipboard_get() +wchar_t *sys_clipboard_get() { Display *disp=XOpenDisplay(NULL); if (!disp) @@ -187,10 +187,10 @@ wchar_t *clipboard_get() return NULL; } -int clipboard_free(wchar_t *clip_buf) +LibError sys_clipboard_free(wchar_t *clip_buf) { free(clip_buf); - return 0; + return ERR_OK; } /* @@ -202,10 +202,10 @@ Setting the Selection (i.e. "copy") * Tell the X server that we want to own the selection * Listen for Selection events and respond to them as appropriate */ -int clipboard_set(const wchar_t *clip_str) +LibError sys_clipboard_set(const wchar_t *clip_str) { // Not Implemented, see comment before clipboard_get, above - return -1; + return ERR_FAIL; } #endif // #ifdef HAVE_X diff --git a/source/lib/types.h b/source/lib/types.h index 5ccfc78bbb..070ebc6b9d 100755 --- a/source/lib/types.h +++ b/source/lib/types.h @@ -4,6 +4,7 @@ #define __TYPES_H__ #include "posix_types.h" +#include "lib_errors.h" // defines instead of typedefs so we can #undef conflicting decls @@ -31,6 +32,4 @@ typedef unsigned int PS_uint; # error "check size_t and SIZE_MAX - too small?" #endif -enum LibError; - #endif // #ifndef __TYPES_H__ diff --git a/source/simulation/Aura.cpp b/source/simulation/Aura.cpp index 19d59f5965..5b3626b569 100644 --- a/source/simulation/Aura.cpp +++ b/source/simulation/Aura.cpp @@ -53,7 +53,8 @@ void CAura::Update( size_t UNUSED(timestep) ) CStrW enterName = L"onEnter"; jsval enterFunction; - if( JS_GetUCProperty( m_cx, m_handler, enterName.c_str(), enterName.length(), &enterFunction ) ) + utf16string enterName16 = enterName.utf16(); + if( JS_GetUCProperty( m_cx, m_handler, enterName16.c_str(), enterName16.length(), &enterFunction ) ) { back_insert_iterator > ins( entered ); set_difference( curInfluenced.begin(), curInfluenced.end(), @@ -69,7 +70,8 @@ void CAura::Update( size_t UNUSED(timestep) ) CStrW exitName = L"onExit"; jsval exitFunction; - if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) ) + utf16string exitName16 = exitName.utf16(); + if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) ) { back_insert_iterator > ins( exited ); set_difference( prevInfluenced.begin(), prevInfluenced.end(), @@ -90,7 +92,8 @@ void CAura::RemoveAll() jsval argv[1]; CStrW exitName = L"onExit"; jsval exitFunction; - if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) ) + utf16string exitName16 = exitName.utf16(); + if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) ) { for( vector::iterator it = m_influenced.begin(); it != m_influenced.end(); it++ ) { @@ -112,7 +115,8 @@ void CAura::Remove( CEntity* ent ) jsval argv[1]; CStrW exitName = L"onExit"; jsval exitFunction; - if( JS_GetUCProperty( m_cx, m_handler, exitName.c_str(), exitName.length(), &exitFunction ) ) + utf16string exitName16 = exitName.utf16(); + if( JS_GetUCProperty( m_cx, m_handler, exitName16.c_str(), exitName16.length(), &exitFunction ) ) { argv[0] = OBJECT_TO_JSVAL( ent->GetScript() ); JS_CallFunctionValue( m_cx, m_handler, exitFunction, 1, argv, &rval ); diff --git a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp index 385ad5cc3f..adfa17a3c0 100644 --- a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -1,5 +1,7 @@ #include "precompiled.h" +#include + #include "MessageHandler.h" #include "../CommandProc.h"