diff --git a/CMakeLists.txt b/CMakeLists.txt index 39c0a5469..e7ccc537b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.8.7) +cmake_policy(SET CMP0054 NEW) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) diff --git a/CMakeModules/FindOrBuild.cmake b/CMakeModules/FindOrBuild.cmake index 4849e7acf..2b9da5ce6 100644 --- a/CMakeModules/FindOrBuild.cmake +++ b/CMakeModules/FindOrBuild.cmake @@ -27,10 +27,13 @@ macro(FindOrBuildSDL2) if(ANDROID) set(ENV{SDL2DIR} "$ENV{ANDROID_SDL2_ROOT};$ENV{ANDROID_SDL2_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/") elseif(WIN32) - set(ENV{SDL2DIR} $ENV{WIN_SDL2_ROOT}) +# set(ENV{SDL2DIR} $ENV{WIN_SDL2_ROOT}) + add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/SDL2) + set(SDL2_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/SDL2/include ${CMAKE_BINARY_DIR}/thirdparty/SDL2) + set(SDL2_LIBRARY SDL2) + else() + find_package(SDL2) endif() - - find_package(SDL2) endmacro() macro(FindOrBuildUNZIP) @@ -84,10 +87,11 @@ macro(FindOrBuildBoost) endif() endmacro() + macro(FindOrBuildZLIB) if(BUILD_ZLIB) - add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/zlib ${CMAKE_BINARY_DIR}/thirdparty/zlib) - set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/zlib) + add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/zlib) + set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/zlib ${CMAKE_BINARY_DIR}/thirdparty/zlib) set(ZLIB_LIBRARY zlib) else() if(WIN32) @@ -103,12 +107,7 @@ macro(FindOrBuildGIF) if(BUILD_GIF) message(WARNING "ZLIB sources are currently not included within the wagic tree") else() - if(WIN32) - set(ENV{GIF_DIR} ${CMAKE_SOURCE_DIR}/thirdparty/binary/win) - find_package(GIF) - else() - find_package(GIF) - endif() + find_package(GIF) endif() endmacro() diff --git a/JGE/CMakeLists.txt b/JGE/CMakeLists.txt index aeac3d197..dc944b836 100644 --- a/JGE/CMakeLists.txt +++ b/JGE/CMakeLists.txt @@ -67,6 +67,7 @@ set(JGE_psp_src src/vram.cpp) set(JGE_INCLUDE_DIRS include include/hge) +set(EXTRA_INCLUDE_DIR ../projects/mtg/extra) #turn moc on if(backend_qt_console OR backend_qt_widget) @@ -80,7 +81,7 @@ if(backend_qt_console) set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}) set(JGE_SOURCES ${JGE_generic_src} ${JGE_console_src} ${JGE_linux_src} ${JGE_hge_src}) - set(JGE_LINK_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${GIF_LIBRARIES} + set(JGE_LINK_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) else() message(FATAL_ERROR "qt builds of jge platforms other than linux are not supported") @@ -93,7 +94,7 @@ if(backend_qt_widget) ${UNZIP_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS} ) set(JGE_SOURCES ${JGE_generic_src} ${JGE_graphics_src} ${JGE_linux_src} ${JGE_hge_src}) set(JGE_LINK_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5OpenGL_LIBRARIES} ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} - ${GIF_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) + ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) else() message(FATAL_ERROR "qt builds of jge platforms other than linux are not supported") endif() @@ -102,23 +103,22 @@ endif() if(backend_sdl) if(UNIX AND NOT ANDROID) set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} - ${SDL2_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${PNG_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS}) + ${SDL2_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${PNG_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) set(JGE_SOURCES ${JGE_generic_src} ${JGE_graphics_src} ${JGE_linux_src} ${JGE_hge_src}) - set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${GIF_LIBRARIES} ${JPEG_LIBRARY} + set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES}) elseif(ANDROID) set(JGE_INTERNAL_INCLUDE_DIRS ${BOOST_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${PNG_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR} - ${OPENSL_INCLUDE_DIR}) + ${OPENSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) set(JGE_SOURCES ${JGE_generic_src} ${JGE_android_src} ${JGE_graphics_src} ${JGE_hge_src}) set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES} ${OPENSL_LIBRARIES}) elseif(WIN32) - set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} - ${UNZIP_INCLUDE_DIR} ${GIF_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) + set(JGE_INTERNAL_INCLUDE_DIRS ${EXTRA_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} + ${UNZIP_INCLUDE_DIR} ${PNG_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/thirdparty/binary/win/include) set(JGE_SOURCES ${JGE_generic_src} ${JGE_graphics_src} ${JGE_linux_src} ${JGE_hge_src}) - set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${GIF_LIBRARIES} ${JPEG_LIBRARY} - ${PNG_LIBRARIES}) + set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES}) set(JGE_LINK_DIRECTORIES ${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR}) endif() endif() diff --git a/JGE/include/Downloader.h b/JGE/include/Downloader.h index 96c643ae2..f77c55303 100644 --- a/JGE/include/Downloader.h +++ b/JGE/include/Downloader.h @@ -41,7 +41,7 @@ class DownloadRequest private slots: #endif void fileDownloaded(); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void downloadProgress(int64_t bytesReceived, int64_t bytesTotal); #ifdef QT_CONFIG signals: diff --git a/JGE/include/JGE.h b/JGE/include/JGE.h index 80a2e3717..69974f178 100644 --- a/JGE/include/JGE.h +++ b/JGE/include/JGE.h @@ -31,7 +31,7 @@ typedef u32 LocalKeySym; #elif defined(SDL_CONFIG) #include -typedef SDLKey LocalKeySym; +typedef SDL_Keycode LocalKeySym; #define LOCAL_KEY_NONE SDLK_UNKNOWN #elif defined(WIN32) diff --git a/JGE/include/JRenderer.h b/JGE/include/JRenderer.h index 452ac4955..9eaabcbfe 100644 --- a/JGE/include/JRenderer.h +++ b/JGE/include/JRenderer.h @@ -16,7 +16,7 @@ #include #include -#if (!defined IOS) && (!defined ANDROID) && (!defined QT_CONFIG) +#if (!defined IOS) && (!defined ANDROID) && (!defined QT_CONFIG) && (!defined SDL_CONFIG) #include #endif //IOS ANDROID @@ -567,7 +567,7 @@ private: #if (!defined IOS) && (!defined QT_CONFIG) void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); int LoadPNG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); -#if (!defined ANDROID) && (!defined QT_CONFIG) +#if (!defined ANDROID) && (!defined QT_CONFIG) && (!defined SDL_CONFIG) void LoadGIF(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); int image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bgcolor, InputFunc readFunc,int mode = 0, int TextureFormat = TEXTURE_FORMAT); #endif // (ANDROID) How can we get gif support for android ? diff --git a/JGE/include/JSoundSystem.h b/JGE/include/JSoundSystem.h index 50771a646..ef1ad30a8 100644 --- a/JGE/include/JSoundSystem.h +++ b/JGE/include/JSoundSystem.h @@ -48,7 +48,7 @@ #endif #ifdef WITH_FMOD -#include "../Dependencies/include/fmod.h" +#include "fmod.h" #endif //------------------------------------------------------------------------------------------------ diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index 0a7a23766..619c58a7d 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -26,8 +26,12 @@ #include "JAudio.h" #else - -#include +//#define __STDC_LIMIT_MACROS +#include +//#include +//the MSC version might only define _MSC_STDINT_H_ +//and that might cause redefinition of standard types +//#define _STDINT_H_ #endif diff --git a/JGE/include/Threading.h b/JGE/include/Threading.h index adfe4084e..1fe1d703c 100644 --- a/JGE/include/Threading.h +++ b/JGE/include/Threading.h @@ -1,7 +1,7 @@ #ifndef THREADING_H #define THREADING_H -#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L) +#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L) && !(_MSC_VER >= 1700) #include #ifdef WIN32 @@ -537,7 +537,7 @@ namespace boost } } -#elif (__cplusplus > 199711L) +#elif (__cplusplus > 199711L) || (_MSC_VER >= 1700) #include #include diff --git a/JGE/src/Downloader.cpp b/JGE/src/Downloader.cpp index e1ba9eb26..0cd38d229 100644 --- a/JGE/src/Downloader.cpp +++ b/JGE/src/Downloader.cpp @@ -48,15 +48,16 @@ void DownloadRequest::startGet() JFileSystem::GetInstance()->Remove(getTempLocalPath()); JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath()); #ifdef QT_CONFIG - connect(mNetworkReply, SIGNAL(downloadProgress(qint64, qint64)), - SLOT(downloadProgress(qint64, qint64))); + connect(mNetworkReply, SIGNAL(downloadProgress(int64_t, int64_t)), + SLOT(downloadProgress(int64_t, int64_t))); connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded())); #endif } void DownloadRequest::fileDownloaded() { - do { +#ifdef QT_CONFIG + do { QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag"); if(!eTagByteArray.isEmpty()) { string oldETag = mETag; @@ -106,11 +107,14 @@ void DownloadRequest::fileDownloaded() mNetworkReply->deleteLater(); emit statusChanged((int)mDownloadStatus); +#endif + } -void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) +void DownloadRequest::downloadProgress(int64_t bytesReceived, int64_t bytesTotal) { - QByteArray byteArray = mNetworkReply->readAll(); +#ifdef QT_CONFIG + QByteArray byteArray = mNetworkReply->readAll(); mFile.write(byteArray.constData(), byteArray.size()); mCurrentSize = bytesReceived; mTotalSize = bytesTotal; @@ -118,6 +122,7 @@ void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) if(bytesTotal) percent = (bytesReceived/bytesTotal)*100; emit percentChanged(percent); +#endif } Downloader* Downloader::mInstance = 0; diff --git a/JGE/src/JFileSystem.cpp b/JGE/src/JFileSystem.cpp index 4eeff8f4f..d62968ab8 100644 --- a/JGE/src/JFileSystem.cpp +++ b/JGE/src/JFileSystem.cpp @@ -16,9 +16,7 @@ User folder is the only one that is really needed to guarantee both read and wri The content that users should not be touching. */ -#ifndef PSP -#include "PrecompiledHeader.h" -#endif //PSP +#include "dirent.h" #ifdef WIN32 #pragma warning(disable : 4786) @@ -32,7 +30,6 @@ The content that users should not be touching. #include "../include/JGE.h" #include "../include/JFileSystem.h" #include "../include/JLogger.h" -#include #ifdef QT_CONFIG #include diff --git a/JGE/src/JGE.cpp b/JGE/src/JGE.cpp index eb606f302..243baa071 100644 --- a/JGE/src/JGE.cpp +++ b/JGE/src/JGE.cpp @@ -34,7 +34,7 @@ ////////////////////////////////////////////////////////////////////////// #if defined (WIN32) // WIN32 specific code -#include "../../Dependencies/include/fmod.h" +#include "fmod.h" u8 JGE::GetAnalogX() { @@ -54,7 +54,7 @@ u8 JGE::GetAnalogY() #elif defined (LINUX) // Unix specific code #include #ifdef WITH_FMOD -#include "../Dependencies/include/fmod.h" +#include "fmod.h" #endif //WITH_FMOD diff --git a/projects/mtg/CMakeLists.txt b/projects/mtg/CMakeLists.txt index 26451cb24..486239204 100644 --- a/projects/mtg/CMakeLists.txt +++ b/projects/mtg/CMakeLists.txt @@ -137,6 +137,7 @@ set(MTG_android_sdl_src set(MTG_INCLUDE_DIRS include include/qt) set(JGE_INCLUDE_DIRS ../../JGE/include ../../JGE/include/hge) set(JGE_LIBRARY jge) +set(EXTRA_INCLUDE_DIR extra) #turn moc on if(backend_qt_console OR backend_qt_widget) @@ -187,9 +188,9 @@ if(backend_sdl) target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} ${HGE_LIBRARY}) elseif(WIN32) - include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} + include_directories(${EXTRA_INCLUDE_DIR} ${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR}) + ${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/thirdparty/binary/win/include) add_executable(wagic ${MTG_generic_src} ${MTG_sdl_src} src/TestSuiteAI.cpp src/AIPlayerBakaB.cpp) link_directories(${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR}) target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} diff --git a/projects/mtg/extra/dirent.h b/projects/mtg/extra/dirent.h index 021a95ef9..0bc3da687 100644 --- a/projects/mtg/extra/dirent.h +++ b/projects/mtg/extra/dirent.h @@ -60,13 +60,12 @@ #include #include - typedef struct dirent { /* name of current directory entry (a multi-byte character string) */ char d_name[MAX_PATH + 1]; /* file attributes */ - WIN32_FIND_DATAA data; + WIN32_FIND_DATAW data; } dirent; @@ -81,7 +80,7 @@ typedef struct DIR { HANDLE search_handle; /* search pattern (3 = zero terminator + pattern "\\*") */ - char patt[MAX_PATH + 3]; + wchar_t patt[MAX_PATH + 3]; } DIR; @@ -91,12 +90,7 @@ static int closedir (DIR *dirp); /* use the new safe string functions introduced in Visual Studio 2005 */ -#if defined(_MSC_VER) && _MSC_VER >= 1400 -# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE) -#else -# define STRNCPY(dest,src,size) strncpy((dest),(src),(size)) -#endif - +# define STRNCPY(dest,src,size) wcsncpy_s((dest),(size),(src),_TRUNCATE) /* * Open directory stream DIRNAME for read and return a pointer to the @@ -114,23 +108,29 @@ opendir( /* construct new DIR structure */ dirp = (DIR*) malloc (sizeof (struct DIR)); if (dirp != NULL) { - char *p; + wchar_t *p; /* take directory name... */ - STRNCPY (dirp->patt, dirname, sizeof(dirp->patt)); - dirp->patt[MAX_PATH] = '\0'; + MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS, dirname, -1,dirp->patt, strlen(dirname)+1 ); + dirp->patt[MAX_PATH] = L'\0'; /* ... and append search pattern to it */ - p = strchr (dirp->patt, '\0'); - if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { - *p++ = '\\'; + p = wcschr (dirp->patt, L'\0'); + if (dirp->patt < p && *(p-1) != L'\\' && *(p-1) != L':') { + *p++ = L'\\'; } - *p++ = '*'; - *p = '\0'; + *p++ = L'*'; + *p = L'\0'; /* open stream and retrieve first file */ - dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); - if (dirp->search_handle == INVALID_HANDLE_VALUE) { + dirp->search_handle = FindFirstFileExW( dirp->patt, + FindExInfoStandard, + &dirp->current.data, + FindExSearchNameMatch, + NULL, + 0 );; + + if (dirp->search_handle == INVALID_HANDLE_VALUE) { /* invalid search pattern? */ free (dirp); return NULL; @@ -168,7 +168,7 @@ readdir( dirp->cached = 0; } else { /* read next directory entry from disk */ - if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) { + if (FindNextFileW (dirp->search_handle, &dirp->current.data) == FALSE) { /* the very last file has been processed or an error occured */ FindClose (dirp->search_handle); dirp->search_handle = INVALID_HANDLE_VALUE; @@ -177,7 +177,7 @@ readdir( } /* copy as a multibyte character string */ - STRNCPY (dirp->current.d_name, dirp->current.data.cFileName, sizeof(dirp->current.d_name)); + WideCharToMultiByte(CP_ACP, 0, dirp->current.data.cFileName, -1, dirp->current.d_name, wcslen(dirp->current.data.cFileName)+1, NULL, NULL); dirp->current.d_name[MAX_PATH] = '\0'; return &dirp->current; diff --git a/projects/mtg/include/PrecompiledHeader.h b/projects/mtg/include/PrecompiledHeader.h index 97df7a34b..1175bb7ac 100644 --- a/projects/mtg/include/PrecompiledHeader.h +++ b/projects/mtg/include/PrecompiledHeader.h @@ -21,10 +21,10 @@ #include "GameOptions.h" -#if !defined(WP8) && !defined(QT_CONFIG) -#include -#include -#endif +//#if !defined(WP8) && !defined(QT_CONFIG) +//#include +//#include +//#endif #if defined (WP8) || defined (IOS) || defined (ANDROID) || defined (QT_CONFIG) || defined (SDL_CONFIG) #define TOUCH_ENABLED diff --git a/projects/mtg/include/WResource_Fwd.h b/projects/mtg/include/WResource_Fwd.h index 096f4df97..8bdb89eda 100644 --- a/projects/mtg/include/WResource_Fwd.h +++ b/projects/mtg/include/WResource_Fwd.h @@ -1,7 +1,7 @@ #ifndef WRESOURCE_FWD_H #define WRESOURCE_FWD_H -#if (__cplusplus > 199711L) +#if (__cplusplus > 199711L) || (_MSC_VER >= 1700) #include typedef std::shared_ptr JQuadPtr; #elif defined(QT_CONFIG) diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index 4437bd0f8..f9571342b 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -8,10 +8,10 @@ #include "Counters.h" #include "AllAbilities.h" -#if !defined(QT_CONFIG) -#include -typedef boost::scoped_ptr ManaCostPtr; -#else +#if (__cplusplus > 199711L) || (_MSC_VER >= 1700) +//#include +typedef std::unique_ptr ManaCostPtr; +#elif defined(QT_CONFIG) #include class ManaCostPtr : public QScopedPointer { @@ -21,6 +21,9 @@ public: ManaCost* get() const {return data();}; }; +#else +#include +typedef boost::scoped_ptr ManaCostPtr; #endif SUPPORT_OBJECT_ANALYTICS(ExtraCost) diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index 95d0311fe..7eb353859 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -1516,7 +1516,7 @@ ostream& operator<<(ostream& out, const GameObserver& g) out << g.mSeed; out << endl; out << "rvalues:"; - out << g.randomGenerator.saveUsedRandValues(out); + g.randomGenerator.saveUsedRandValues(out); out << endl; out << g.startupGameSerialized; } diff --git a/projects/mtg/src/SDLmain.cpp b/projects/mtg/src/SDLmain.cpp index bf09628fd..39b537485 100644 --- a/projects/mtg/src/SDLmain.cpp +++ b/projects/mtg/src/SDLmain.cpp @@ -101,7 +101,7 @@ class SdlApp public: /* For easy interfacing with JGE static functions */ bool Running; SDL_Window* window; - SDL_Surface* Surf_Display; + SDL_GLContext gl_context; SDL_Rect viewPort; Uint32 lastMouseUpTime; Uint32 lastFingerDownTime; @@ -114,7 +114,7 @@ public: /* For easy interfacing with JGE static functions */ int mMouseDownY; public: - SdlApp() : Surf_Display(NULL), window(NULL), lastMouseUpTime(0), lastFingerDownTime(0), Running(true), mMouseDownX(0), mMouseDownY(0) + SdlApp() : Running(true), window(NULL), gl_context(NULL), lastMouseUpTime(0), lastFingerDownTime(0), mMouseDownX(0), mMouseDownY(0) { } @@ -144,7 +144,7 @@ public: OnCleanup(); return 0; - }; + } public: bool OnInit(); @@ -276,7 +276,7 @@ public: void OnCleanup() { - SDL_FreeSurface(Surf_Display); + SDL_GL_DeleteContext(gl_context); SDL_Quit(); } }; @@ -403,7 +403,11 @@ bool InitGame(void) void DestroyGame(void) { - g_engine->SetApp(NULL); + if (g_engine != NULL) + { + g_engine->SetApp(NULL); + } + if (g_app) { g_app->Destroy(); @@ -443,7 +447,7 @@ void SdlApp::OnUpdate() if(g_engine) g_engine->Render(); - SDL_GL_SwapBuffers(); + SDL_GL_SwapWindow(window); } void SdlApp::OnKeyPressed(const SDL_KeyboardEvent& event) @@ -637,8 +641,9 @@ bool SdlApp::OnInit() return false; } - const SDL_VideoInfo *pVideoInfo = SDL_GetVideoInfo(); - DebugTrace("Video Display : h " << pVideoInfo->current_h << ", w " << pVideoInfo->current_w); + SDL_DisplayMode currentDisplayMode; + SDL_GetCurrentDisplayMode(0, ¤tDisplayMode); + DebugTrace("Video Display : h " << currentDisplayMode.h << ", w " << currentDisplayMode.w); #if (defined ANDROID) || (defined IOS) window_w = pVideoInfo->current_w; @@ -662,22 +667,37 @@ bool SdlApp::OnInit() SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); - SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 2); + + int buffers, samples; + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &buffers); + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &samples); + if (buffers == 0 || samples == 0) + { //no multisampling available + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0); + SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0); + } SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - if((Surf_Display = SDL_SetVideoMode(window_w, window_h, 32, #ifdef ANDROID - SDL_OPENGL | SDL_FULLSCREEN | SDL_WINDOW_BORDERLESS)) == NULL) - { + Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS; #else - SDL_OPENGL | SDL_RESIZABLE )) == NULL) - { + Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; #endif + window = SDL_CreateWindow( + g_launcher->GetName(), + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + window_w, windowed_h, flags); + if (window == NULL) + { + DebugTrace(SDL_GetError()); return false; } - SDL_WM_SetCaption(g_launcher->GetName(), ""); + + gl_context = SDL_GL_CreateContext(window); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background (yes that's the way fuckers) #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0) diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index bb7e236ce..2ac1e98cd 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -851,7 +851,7 @@ void TestSuiteGame::initGame() p->life = initState.players[i]->life; p->poisonCount = initState.players[i]->poisonCount; stringstream stream; - stream << initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream); + initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream); p->getRandomGenerator()->loadRandValues(stream.str()); MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard, diff --git a/JGE/Dependencies/dll/fmod.dll b/thirdparty/binary/win/dll/fmod.dll similarity index 100% rename from JGE/Dependencies/dll/fmod.dll rename to thirdparty/binary/win/dll/fmod.dll diff --git a/JGE/Dependencies/include/fmod.h b/thirdparty/binary/win/include/fmod.h similarity index 100% rename from JGE/Dependencies/include/fmod.h rename to thirdparty/binary/win/include/fmod.h diff --git a/JGE/Dependencies/include/fmod_errors.h b/thirdparty/binary/win/include/fmod_errors.h similarity index 100% rename from JGE/Dependencies/include/fmod_errors.h rename to thirdparty/binary/win/include/fmod_errors.h diff --git a/JGE/Dependencies/include/fmoddyn.h b/thirdparty/binary/win/include/fmoddyn.h similarity index 100% rename from JGE/Dependencies/include/fmoddyn.h rename to thirdparty/binary/win/include/fmoddyn.h diff --git a/JGE/Dependencies/lib/fmodvc.lib b/thirdparty/binary/win/lib/fmodvc.lib similarity index 100% rename from JGE/Dependencies/lib/fmodvc.lib rename to thirdparty/binary/win/lib/fmodvc.lib