From 278dc39029e9795c4e0b705ddb8697b698a00bcb Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 12 Apr 2017 16:22:35 +0000 Subject: [PATCH] UserEvent now usize size_t for UserData fields to avoid cutting number on some platforms. Fix some warnings. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5417 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/IEventReceiver.h | 4 ++-- source/Irrlicht/CIrrDeviceLinux.cpp | 4 ++-- source/Irrlicht/CIrrDeviceSDL.cpp | 7 +++---- source/Irrlicht/CIrrDeviceWin32.cpp | 4 ++-- source/Irrlicht/CTRTextureLightMap2_Add.cpp | 4 +--- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/changes.txt b/changes.txt index 03c9926f..bd73e232 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- change SEvent::SUserEvent.UserData1 and SEvent::SUserEvent.UserData1 from s32 to size_t to avoid cutting numbers on some 64-bit platforms (SDL and Windows) - Improve speed of draw3DBox (OpenGL and D3D9). Thanks @zerochen for patch (https://sourceforge.net/p/irrlicht/patches/256) - Support more keys on OSX "[]\". Thanks @neoascetic for patch (#313). - Fix IBillboardTextSceneNode::setTextColor which did nothing in the past. It now maps to setColor instead. diff --git a/include/IEventReceiver.h b/include/IEventReceiver.h index c03d3455..eae9be49 100644 --- a/include/IEventReceiver.h +++ b/include/IEventReceiver.h @@ -405,10 +405,10 @@ struct SEvent struct SUserEvent { //! Some user specified data as int - s32 UserData1; + size_t UserData1; //! Another user specified data as int - s32 UserData2; + size_t UserData2; }; EEVENT_TYPE EventType; diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index de06dbf2..ba08c52b 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -1007,8 +1007,8 @@ bool CIrrDeviceLinux::run() { // we assume it's a user message irrevent.EventType = irr::EET_USER_EVENT; - irrevent.UserEvent.UserData1 = (s32)event.xclient.data.l[0]; - irrevent.UserEvent.UserData2 = (s32)event.xclient.data.l[1]; + irrevent.UserEvent.UserData1 = static_cast(event.xclient.data.l[0]); + irrevent.UserEvent.UserData2 = static_cast(event.xclient.data.l[1]); postEventFromUser(irrevent); } XFree(atom); diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index d47e256f..b20b5339 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -428,8 +428,8 @@ bool CIrrDeviceSDL::run() case SDL_USEREVENT: irrevent.EventType = irr::EET_USER_EVENT; - irrevent.UserEvent.UserData1 = *(reinterpret_cast(&SDL_event.user.data1)); - irrevent.UserEvent.UserData2 = *(reinterpret_cast(&SDL_event.user.data2)); + irrevent.UserEvent.UserData1 = reinterpret_cast(SDL_event.user.data1); + irrevent.UserEvent.UserData2 = reinterpret_cast(SDL_event.user.data2); postEventFromUser(irrevent); break; @@ -601,7 +601,7 @@ void CIrrDeviceSDL::setWindowCaption(const wchar_t* text) bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rect* srcClip) { SDL_Surface *sdlSurface = SDL_CreateRGBSurfaceFrom( - surface->lock(), surface->getDimension().Width, surface->getDimension().Height, + surface->getData(), surface->getDimension().Width, surface->getDimension().Height, surface->getBitsPerPixel(), surface->getPitch(), surface->getRedMask(), surface->getGreenMask(), surface->getBlueMask(), surface->getAlphaMask()); if (!sdlSurface) @@ -673,7 +673,6 @@ bool CIrrDeviceSDL::present(video::IImage* surface, void* windowId, core::rectunlock(); return (scr != 0); } diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index f5e9e2f0..ac285ede 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -954,8 +954,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_USER: event.EventType = irr::EET_USER_EVENT; - event.UserEvent.UserData1 = (irr::s32)wParam; - event.UserEvent.UserData2 = (irr::s32)lParam; + event.UserEvent.UserData1 = static_cast(wParam); + event.UserEvent.UserData2 = static_cast(lParam); dev = getDeviceFromHWnd(hWnd); if (dev) diff --git a/source/Irrlicht/CTRTextureLightMap2_Add.cpp b/source/Irrlicht/CTRTextureLightMap2_Add.cpp index 02e968fc..50011468 100644 --- a/source/Irrlicht/CTRTextureLightMap2_Add.cpp +++ b/source/Irrlicht/CTRTextureLightMap2_Add.cpp @@ -190,10 +190,8 @@ REALINLINE void CTRTextureLightMap2_Add::scanline_bilinear () #endif - f32 inversew = FIX_POINT_F32_MUL; - - #ifdef BURNINGVIDEO_RENDERER_FAST + f32 inversew = FIX_POINT_F32_MUL; u32 dIndex = ( line.y & 3 ) << 2;