- Updated SDL dependency to SDL2

- fixed compilation issues with cmake and visual studio 2015
This commit is contained in:
xawotihs
2015-10-04 23:10:45 +02:00
parent 4272e2e2b2
commit 22d14b2a4f
25 changed files with 119 additions and 89 deletions

View File

@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 2.8.7) cmake_minimum_required(VERSION 2.8.7)
cmake_policy(SET CMP0054 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules)

View File

@@ -27,10 +27,13 @@ macro(FindOrBuildSDL2)
if(ANDROID) if(ANDROID)
set(ENV{SDL2DIR} "$ENV{ANDROID_SDL2_ROOT};$ENV{ANDROID_SDL2_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/") set(ENV{SDL2DIR} "$ENV{ANDROID_SDL2_ROOT};$ENV{ANDROID_SDL2_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/")
elseif(WIN32) 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() endif()
find_package(SDL2)
endmacro() endmacro()
macro(FindOrBuildUNZIP) macro(FindOrBuildUNZIP)
@@ -84,10 +87,11 @@ macro(FindOrBuildBoost)
endif() endif()
endmacro() endmacro()
macro(FindOrBuildZLIB) macro(FindOrBuildZLIB)
if(BUILD_ZLIB) if(BUILD_ZLIB)
add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/zlib ${CMAKE_BINARY_DIR}/thirdparty/zlib) add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/zlib)
set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/zlib) set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/zlib ${CMAKE_BINARY_DIR}/thirdparty/zlib)
set(ZLIB_LIBRARY zlib) set(ZLIB_LIBRARY zlib)
else() else()
if(WIN32) if(WIN32)
@@ -103,12 +107,7 @@ macro(FindOrBuildGIF)
if(BUILD_GIF) if(BUILD_GIF)
message(WARNING "ZLIB sources are currently not included within the wagic tree") message(WARNING "ZLIB sources are currently not included within the wagic tree")
else() else()
if(WIN32) find_package(GIF)
set(ENV{GIF_DIR} ${CMAKE_SOURCE_DIR}/thirdparty/binary/win)
find_package(GIF)
else()
find_package(GIF)
endif()
endif() endif()
endmacro() endmacro()

View File

@@ -67,6 +67,7 @@ set(JGE_psp_src
src/vram.cpp) src/vram.cpp)
set(JGE_INCLUDE_DIRS include include/hge) set(JGE_INCLUDE_DIRS include include/hge)
set(EXTRA_INCLUDE_DIR ../projects/mtg/extra)
#turn moc on #turn moc on
if(backend_qt_console OR backend_qt_widget) 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} set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR}
${UNZIP_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}) ${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_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}) ${JPEG_LIBRARIES} ${PNG_LIBRARIES})
else() else()
message(FATAL_ERROR "qt builds of jge platforms other than linux are not supported") 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} ) ${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_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} 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() else()
message(FATAL_ERROR "qt builds of jge platforms other than linux are not supported") message(FATAL_ERROR "qt builds of jge platforms other than linux are not supported")
endif() endif()
@@ -102,23 +103,22 @@ endif()
if(backend_sdl) if(backend_sdl)
if(UNIX AND NOT ANDROID) if(UNIX AND NOT ANDROID)
set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} 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_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}) ${PNG_LIBRARIES})
elseif(ANDROID) elseif(ANDROID)
set(JGE_INTERNAL_INCLUDE_DIRS ${BOOST_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} 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} ${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_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} set(JGE_LINK_LIBRARIES ${ZIPFS_LIBRARY} ${UNZIP_LIRARY} ${JPEG_LIBRARY} ${PNG_LIBRARIES}
${OPENSL_LIBRARIES}) ${OPENSL_LIBRARIES})
elseif(WIN32) elseif(WIN32)
set(JGE_INTERNAL_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${SDL2_INCLUDE_DIR} set(JGE_INTERNAL_INCLUDE_DIRS ${EXTRA_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${SDL2_INCLUDE_DIR}
${UNZIP_INCLUDE_DIR} ${GIF_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}) ${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_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})
${PNG_LIBRARIES})
set(JGE_LINK_DIRECTORIES ${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR}) set(JGE_LINK_DIRECTORIES ${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR})
endif() endif()
endif() endif()

View File

@@ -41,7 +41,7 @@ class DownloadRequest
private slots: private slots:
#endif #endif
void fileDownloaded(); void fileDownloaded();
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void downloadProgress(int64_t bytesReceived, int64_t bytesTotal);
#ifdef QT_CONFIG #ifdef QT_CONFIG
signals: signals:

View File

@@ -31,7 +31,7 @@ typedef u32 LocalKeySym;
#elif defined(SDL_CONFIG) #elif defined(SDL_CONFIG)
#include <SDL.h> #include <SDL.h>
typedef SDLKey LocalKeySym; typedef SDL_Keycode LocalKeySym;
#define LOCAL_KEY_NONE SDLK_UNKNOWN #define LOCAL_KEY_NONE SDLK_UNKNOWN
#elif defined(WIN32) #elif defined(WIN32)

View File

@@ -16,7 +16,7 @@
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#if (!defined IOS) && (!defined ANDROID) && (!defined QT_CONFIG) #if (!defined IOS) && (!defined ANDROID) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
#include <gif_lib.h> #include <gif_lib.h>
#endif //IOS ANDROID #endif //IOS ANDROID
@@ -567,7 +567,7 @@ private:
#if (!defined IOS) && (!defined QT_CONFIG) #if (!defined IOS) && (!defined QT_CONFIG)
void LoadJPG(TextureInfo &textureInfo, const char *filename, int mode = 0, int TextureFormat = TEXTURE_FORMAT); 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); 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); 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); 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 ? #endif // (ANDROID) How can we get gif support for android ?

View File

@@ -48,7 +48,7 @@
#endif #endif
#ifdef WITH_FMOD #ifdef WITH_FMOD
#include "../Dependencies/include/fmod.h" #include "fmod.h"
#endif #endif
//------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------

View File

@@ -26,8 +26,12 @@
#include "JAudio.h" #include "JAudio.h"
#else #else
//#define __STDC_LIMIT_MACROS
#include <stdint.h> #include <cstdint>
//#include <stdint.h>
//the MSC version might only define _MSC_STDINT_H_
//and that might cause redefinition of standard types
//#define _STDINT_H_
#endif #endif

View File

@@ -1,7 +1,7 @@
#ifndef THREADING_H #ifndef THREADING_H
#define 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 <boost/date_time.hpp> #include <boost/date_time.hpp>
#ifdef WIN32 #ifdef WIN32
@@ -537,7 +537,7 @@ namespace boost
} }
} }
#elif (__cplusplus > 199711L) #elif (__cplusplus > 199711L) || (_MSC_VER >= 1700)
#include <thread> #include <thread>
#include <mutex> #include <mutex>

View File

@@ -48,15 +48,16 @@ void DownloadRequest::startGet()
JFileSystem::GetInstance()->Remove(getTempLocalPath()); JFileSystem::GetInstance()->Remove(getTempLocalPath());
JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath()); JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath());
#ifdef QT_CONFIG #ifdef QT_CONFIG
connect(mNetworkReply, SIGNAL(downloadProgress(qint64, qint64)), connect(mNetworkReply, SIGNAL(downloadProgress(int64_t, int64_t)),
SLOT(downloadProgress(qint64, qint64))); SLOT(downloadProgress(int64_t, int64_t)));
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded())); connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
#endif #endif
} }
void DownloadRequest::fileDownloaded() void DownloadRequest::fileDownloaded()
{ {
do { #ifdef QT_CONFIG
do {
QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag"); QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag");
if(!eTagByteArray.isEmpty()) { if(!eTagByteArray.isEmpty()) {
string oldETag = mETag; string oldETag = mETag;
@@ -106,11 +107,14 @@ void DownloadRequest::fileDownloaded()
mNetworkReply->deleteLater(); mNetworkReply->deleteLater();
emit statusChanged((int)mDownloadStatus); 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()); mFile.write(byteArray.constData(), byteArray.size());
mCurrentSize = bytesReceived; mCurrentSize = bytesReceived;
mTotalSize = bytesTotal; mTotalSize = bytesTotal;
@@ -118,6 +122,7 @@ void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
if(bytesTotal) if(bytesTotal)
percent = (bytesReceived/bytesTotal)*100; percent = (bytesReceived/bytesTotal)*100;
emit percentChanged(percent); emit percentChanged(percent);
#endif
} }
Downloader* Downloader::mInstance = 0; Downloader* Downloader::mInstance = 0;

View File

@@ -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. The content that users should not be touching.
*/ */
#ifndef PSP #include "dirent.h"
#include "PrecompiledHeader.h"
#endif //PSP
#ifdef WIN32 #ifdef WIN32
#pragma warning(disable : 4786) #pragma warning(disable : 4786)
@@ -32,7 +30,6 @@ The content that users should not be touching.
#include "../include/JGE.h" #include "../include/JGE.h"
#include "../include/JFileSystem.h" #include "../include/JFileSystem.h"
#include "../include/JLogger.h" #include "../include/JLogger.h"
#include <dirent.h>
#ifdef QT_CONFIG #ifdef QT_CONFIG
#include <QDir> #include <QDir>

View File

@@ -34,7 +34,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#if defined (WIN32) // WIN32 specific code #if defined (WIN32) // WIN32 specific code
#include "../../Dependencies/include/fmod.h" #include "fmod.h"
u8 JGE::GetAnalogX() u8 JGE::GetAnalogX()
{ {
@@ -54,7 +54,7 @@ u8 JGE::GetAnalogY()
#elif defined (LINUX) // Unix specific code #elif defined (LINUX) // Unix specific code
#include <sys/time.h> #include <sys/time.h>
#ifdef WITH_FMOD #ifdef WITH_FMOD
#include "../Dependencies/include/fmod.h" #include "fmod.h"
#endif //WITH_FMOD #endif //WITH_FMOD

View File

@@ -137,6 +137,7 @@ set(MTG_android_sdl_src
set(MTG_INCLUDE_DIRS include include/qt) set(MTG_INCLUDE_DIRS include include/qt)
set(JGE_INCLUDE_DIRS ../../JGE/include ../../JGE/include/hge) set(JGE_INCLUDE_DIRS ../../JGE/include ../../JGE/include/hge)
set(JGE_LIBRARY jge) set(JGE_LIBRARY jge)
set(EXTRA_INCLUDE_DIR extra)
#turn moc on #turn moc on
if(backend_qt_console OR backend_qt_widget) 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} target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES}
${HGE_LIBRARY}) ${HGE_LIBRARY})
elseif(WIN32) 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} ${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) add_executable(wagic ${MTG_generic_src} ${MTG_sdl_src} src/TestSuiteAI.cpp src/AIPlayerBakaB.cpp)
link_directories(${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR}) link_directories(${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR})
target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES}

View File

@@ -60,13 +60,12 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
typedef struct dirent { typedef struct dirent {
/* name of current directory entry (a multi-byte character string) */ /* name of current directory entry (a multi-byte character string) */
char d_name[MAX_PATH + 1]; char d_name[MAX_PATH + 1];
/* file attributes */ /* file attributes */
WIN32_FIND_DATAA data; WIN32_FIND_DATAW data;
} dirent; } dirent;
@@ -81,7 +80,7 @@ typedef struct DIR {
HANDLE search_handle; HANDLE search_handle;
/* search pattern (3 = zero terminator + pattern "\\*") */ /* search pattern (3 = zero terminator + pattern "\\*") */
char patt[MAX_PATH + 3]; wchar_t patt[MAX_PATH + 3];
} DIR; } DIR;
@@ -91,12 +90,7 @@ static int closedir (DIR *dirp);
/* use the new safe string functions introduced in Visual Studio 2005 */ /* use the new safe string functions introduced in Visual Studio 2005 */
#if defined(_MSC_VER) && _MSC_VER >= 1400 # define STRNCPY(dest,src,size) wcsncpy_s((dest),(size),(src),_TRUNCATE)
# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
#else
# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
#endif
/* /*
* Open directory stream DIRNAME for read and return a pointer to the * Open directory stream DIRNAME for read and return a pointer to the
@@ -114,23 +108,29 @@ opendir(
/* construct new DIR structure */ /* construct new DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR)); dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp != NULL) { if (dirp != NULL) {
char *p; wchar_t *p;
/* take directory name... */ /* take directory name... */
STRNCPY (dirp->patt, dirname, sizeof(dirp->patt)); MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS, dirname, -1,dirp->patt, strlen(dirname)+1 );
dirp->patt[MAX_PATH] = '\0'; dirp->patt[MAX_PATH] = L'\0';
/* ... and append search pattern to it */ /* ... and append search pattern to it */
p = strchr (dirp->patt, '\0'); p = wcschr (dirp->patt, L'\0');
if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') { if (dirp->patt < p && *(p-1) != L'\\' && *(p-1) != L':') {
*p++ = '\\'; *p++ = L'\\';
} }
*p++ = '*'; *p++ = L'*';
*p = '\0'; *p = L'\0';
/* open stream and retrieve first file */ /* open stream and retrieve first file */
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data); dirp->search_handle = FindFirstFileExW( dirp->patt,
if (dirp->search_handle == INVALID_HANDLE_VALUE) { FindExInfoStandard,
&dirp->current.data,
FindExSearchNameMatch,
NULL,
0 );;
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
/* invalid search pattern? */ /* invalid search pattern? */
free (dirp); free (dirp);
return NULL; return NULL;
@@ -168,7 +168,7 @@ readdir(
dirp->cached = 0; dirp->cached = 0;
} else { } else {
/* read next directory entry from disk */ /* 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 */ /* the very last file has been processed or an error occured */
FindClose (dirp->search_handle); FindClose (dirp->search_handle);
dirp->search_handle = INVALID_HANDLE_VALUE; dirp->search_handle = INVALID_HANDLE_VALUE;
@@ -177,7 +177,7 @@ readdir(
} }
/* copy as a multibyte character string */ /* 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'; dirp->current.d_name[MAX_PATH] = '\0';
return &dirp->current; return &dirp->current;

View File

@@ -21,10 +21,10 @@
#include "GameOptions.h" #include "GameOptions.h"
#if !defined(WP8) && !defined(QT_CONFIG) //#if !defined(WP8) && !defined(QT_CONFIG)
#include <boost/shared_ptr.hpp> //#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp> //#include <boost/scoped_ptr.hpp>
#endif //#endif
#if defined (WP8) || defined (IOS) || defined (ANDROID) || defined (QT_CONFIG) || defined (SDL_CONFIG) #if defined (WP8) || defined (IOS) || defined (ANDROID) || defined (QT_CONFIG) || defined (SDL_CONFIG)
#define TOUCH_ENABLED #define TOUCH_ENABLED

View File

@@ -1,7 +1,7 @@
#ifndef WRESOURCE_FWD_H #ifndef WRESOURCE_FWD_H
#define WRESOURCE_FWD_H #define WRESOURCE_FWD_H
#if (__cplusplus > 199711L) #if (__cplusplus > 199711L) || (_MSC_VER >= 1700)
#include <memory> #include <memory>
typedef std::shared_ptr<JQuad> JQuadPtr; typedef std::shared_ptr<JQuad> JQuadPtr;
#elif defined(QT_CONFIG) #elif defined(QT_CONFIG)

View File

@@ -8,10 +8,10 @@
#include "Counters.h" #include "Counters.h"
#include "AllAbilities.h" #include "AllAbilities.h"
#if !defined(QT_CONFIG) #if (__cplusplus > 199711L) || (_MSC_VER >= 1700)
#include <boost/scoped_ptr.hpp> //#include <unique_ptr>
typedef boost::scoped_ptr<ManaCost> ManaCostPtr; typedef std::unique_ptr<ManaCost> ManaCostPtr;
#else #elif defined(QT_CONFIG)
#include <QScopedPointer> #include <QScopedPointer>
class ManaCostPtr : public QScopedPointer<ManaCost> class ManaCostPtr : public QScopedPointer<ManaCost>
{ {
@@ -21,6 +21,9 @@ public:
ManaCost* get() const {return data();}; ManaCost* get() const {return data();};
}; };
#else
#include <boost/scoped_ptr.hpp>
typedef boost::scoped_ptr<ManaCost> ManaCostPtr;
#endif #endif
SUPPORT_OBJECT_ANALYTICS(ExtraCost) SUPPORT_OBJECT_ANALYTICS(ExtraCost)

View File

@@ -1516,7 +1516,7 @@ ostream& operator<<(ostream& out, const GameObserver& g)
out << g.mSeed; out << g.mSeed;
out << endl; out << endl;
out << "rvalues:"; out << "rvalues:";
out << g.randomGenerator.saveUsedRandValues(out); g.randomGenerator.saveUsedRandValues(out);
out << endl; out << endl;
out << g.startupGameSerialized; out << g.startupGameSerialized;
} }

View File

@@ -101,7 +101,7 @@ class SdlApp
public: /* For easy interfacing with JGE static functions */ public: /* For easy interfacing with JGE static functions */
bool Running; bool Running;
SDL_Window* window; SDL_Window* window;
SDL_Surface* Surf_Display; SDL_GLContext gl_context;
SDL_Rect viewPort; SDL_Rect viewPort;
Uint32 lastMouseUpTime; Uint32 lastMouseUpTime;
Uint32 lastFingerDownTime; Uint32 lastFingerDownTime;
@@ -114,7 +114,7 @@ public: /* For easy interfacing with JGE static functions */
int mMouseDownY; int mMouseDownY;
public: 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(); OnCleanup();
return 0; return 0;
}; }
public: public:
bool OnInit(); bool OnInit();
@@ -276,7 +276,7 @@ public:
void OnCleanup() void OnCleanup()
{ {
SDL_FreeSurface(Surf_Display); SDL_GL_DeleteContext(gl_context);
SDL_Quit(); SDL_Quit();
} }
}; };
@@ -403,7 +403,11 @@ bool InitGame(void)
void DestroyGame(void) void DestroyGame(void)
{ {
g_engine->SetApp(NULL); if (g_engine != NULL)
{
g_engine->SetApp(NULL);
}
if (g_app) if (g_app)
{ {
g_app->Destroy(); g_app->Destroy();
@@ -443,7 +447,7 @@ void SdlApp::OnUpdate()
if(g_engine) if(g_engine)
g_engine->Render(); g_engine->Render();
SDL_GL_SwapBuffers(); SDL_GL_SwapWindow(window);
} }
void SdlApp::OnKeyPressed(const SDL_KeyboardEvent& event) void SdlApp::OnKeyPressed(const SDL_KeyboardEvent& event)
@@ -637,8 +641,9 @@ bool SdlApp::OnInit()
return false; return false;
} }
const SDL_VideoInfo *pVideoInfo = SDL_GetVideoInfo(); SDL_DisplayMode currentDisplayMode;
DebugTrace("Video Display : h " << pVideoInfo->current_h << ", w " << pVideoInfo->current_w); SDL_GetCurrentDisplayMode(0, &currentDisplayMode);
DebugTrace("Video Display : h " << currentDisplayMode.h << ", w " << currentDisplayMode.w);
#if (defined ANDROID) || (defined IOS) #if (defined ANDROID) || (defined IOS)
window_w = pVideoInfo->current_w; 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_ACCUM_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); 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_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
if((Surf_Display = SDL_SetVideoMode(window_w, window_h, 32,
#ifdef ANDROID #ifdef ANDROID
SDL_OPENGL | SDL_FULLSCREEN | SDL_WINDOW_BORDERLESS)) == NULL) Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
{
#else #else
SDL_OPENGL | SDL_RESIZABLE )) == NULL) Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
{
#endif #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; 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) 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) #if (defined GL_ES_VERSION_2_0) || (defined GL_VERSION_2_0)

View File

@@ -851,7 +851,7 @@ void TestSuiteGame::initGame()
p->life = initState.players[i]->life; p->life = initState.players[i]->life;
p->poisonCount = initState.players[i]->poisonCount; p->poisonCount = initState.players[i]->poisonCount;
stringstream stream; stringstream stream;
stream << initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream); initState.players[i]->getRandomGenerator()->saveLoadedRandValues(stream);
p->getRandomGenerator()->loadRandValues(stream.str()); p->getRandomGenerator()->loadRandValues(stream.str());
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard, MTGGameZone * loadedPlayerZones[] = { initState.players[i]->game->graveyard,