From fdd3fc232fd7ca729aac1213c3420eb88b9391d9 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Tue, 1 Dec 2015 08:51:32 +0100 Subject: [PATCH 1/4] fix a possible uninitialized variable return --- src/unit/script_unit.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unit/script_unit.cpp b/src/unit/script_unit.cpp index 34feae83c..cae1a6e2c 100644 --- a/src/unit/script_unit.cpp +++ b/src/unit/script_unit.cpp @@ -1160,7 +1160,8 @@ static int CclSetUnitVariable(lua_State *l) const char *const name = LuaToString(l, 2); int value; if (!strcmp(name, "Player")) { - unit->AssignToPlayer(Players[LuaToNumber(l, 3)]); + value = LuaToNumber(l, 3); + unit->AssignToPlayer(Players[value]); } else if (!strcmp(name, "RegenerationRate")) { value = LuaToNumber(l, 3); unit->Variable[HP_INDEX].Increase = std::min(unit->Variable[HP_INDEX].Max, value); From 9e43d695d2ecece328455e8e5df672378798c829 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Thu, 26 Nov 2015 14:12:53 +0100 Subject: [PATCH 2/4] updates to make compilation with vs 2015 work --- CMakeLists.txt | 17 +++++++++-------- appveyor.yml | 8 +++----- cmake/modules/FindMakeNSIS.cmake | 2 +- cmake/modules/FindOggVorbis.cmake | 4 ++-- cmake/modules/FindTheora.cmake | 6 +++--- src/include/stratagus.h | 1 - 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4a385d9a..7c35874cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -629,6 +629,11 @@ if(LINUX) endif() endif() +if(WIN32 AND MSVC AND NOT CMAKE_PREFIX_PATH) + # use a default + set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../dependencies) +endif() + # Find all libraries option(ENABLE_STATIC "Compile Stratagus as static executable" OFF) @@ -830,7 +835,7 @@ if(WIN32) endif() if (WIN32 AND MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE=1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE=1 -DNOMINMAX) endif() if (WIN32 AND MINGW) @@ -934,13 +939,9 @@ endif() if(ENABLE_MULTIBUILD) if(WIN32 AND MSVC) - if(MSVC_VERSION GREATER 1600) # if > VC13 - message("The project must be compiled with VS2013 or older. VS2015 has deprecated many functions that we still use.") - set(CMAKE_GENERATOR_TOOLSET "v120" CACHE STRING "Platform Toolset" FORCE) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:MSVCRT") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:MSVCRT") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:MSVCRT") - endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") message(STATUS "Added parallel build arguments to CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") endif() diff --git a/appveyor.yml b/appveyor.yml index ef0f7cab3..4481641c5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,8 @@ -environment: - VisualStudioVersion: 12.0 shallow_clone: true before_build: - mkdir build - cd build - - appveyor DownloadFile http://stratagus.sourceforge.net/msvc-libs.zip - - 7z x msvc-libs.zip - - cmake -G "Visual Studio 12 2013" -DCMAKE_PREFIX_PATH="%cd%\\3rd" .. + - appveyor DownloadFile https://github.com/Wargus/stratagus/releases/download/2015-30-11/dependencies.zip + - 7z x dependencies.zip + - cmake -G "Visual Studio 14 2015" -DCMAKE_PREFIX_PATH="%cd%\\dependencies" .. - cd .. diff --git a/cmake/modules/FindMakeNSIS.cmake b/cmake/modules/FindMakeNSIS.cmake index b96a91141..ffa1e5a72 100644 --- a/cmake/modules/FindMakeNSIS.cmake +++ b/cmake/modules/FindMakeNSIS.cmake @@ -14,7 +14,7 @@ if(MAKENSIS) set(MAKENSIS_FOUND true) else() - find_program(MAKENSIS NAMES makensis) + find_program(MAKENSIS NAMES makensis HINTS "C:/Program Files/NSIS" "C:/Program Files (x86)/NSIS") find_package(SelfPackers) set(MAKENSIS_ADDITIONAL_FLAGS "" CACHE STRING "Additional flags for makensis") diff --git a/cmake/modules/FindOggVorbis.cmake b/cmake/modules/FindOggVorbis.cmake index de8d0c92e..6ce106ba4 100644 --- a/cmake/modules/FindOggVorbis.cmake +++ b/cmake/modules/FindOggVorbis.cmake @@ -19,8 +19,8 @@ include (CheckLibraryExists) find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) find_path(OGG_INCLUDE_DIR ogg/ogg.h) -find_library(OGG_LIBRARY NAMES ogg ogg_static) -find_library(VORBIS_LIBRARY NAMES vorbis vorbis_static) +find_library(OGG_LIBRARY NAMES libogg libogg_static ogg ogg_static) +find_library(VORBIS_LIBRARY NAMES libvorbis libvorbis_static vorbis vorbis_static) mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY) diff --git a/cmake/modules/FindTheora.cmake b/cmake/modules/FindTheora.cmake index ac176b799..18eb65dba 100644 --- a/cmake/modules/FindTheora.cmake +++ b/cmake/modules/FindTheora.cmake @@ -13,11 +13,11 @@ endif(THEORA_INCLUDE_DIR AND THEORA_LIB_LIBRARIES AND THEORA_VORBIS_LIBRARIES AN FIND_PATH(THEORA_INCLUDE_DIR theora/theora.h) -FIND_LIBRARY(THEORA_OGG_LIBRARIES NAMES ogg) +FIND_LIBRARY(THEORA_OGG_LIBRARIES NAMES libogg libogg_static ogg ogg_static) -FIND_LIBRARY(THEORA_VORBIS_LIBRARIES NAMES vorbis vorbis_static) +FIND_LIBRARY(THEORA_VORBIS_LIBRARIES NAMES libvorbis libvorbis_static vorbis vorbis_static) -FIND_LIBRARY(THEORA_LIB_LIBRARIES NAMES theora theora_static) +FIND_LIBRARY(THEORA_LIB_LIBRARIES NAMES libtheora libtheora_static theora theora_static) if(THEORA_LIB_LIBRARIES AND THEORA_VORBIS_LIBRARIES AND THEORA_OGG_LIBRARIES AND THEORA_INCLUDE_DIR) set(THEORA_LIBRARY ${THEORA_LIB_LIBRARIES} ${THEORA_OGG_LIBRARIES} ${THEORA_VORBIS_LIBRARIES}) diff --git a/src/include/stratagus.h b/src/include/stratagus.h index 27df7c262..a2dcacafb 100644 --- a/src/include/stratagus.h +++ b/src/include/stratagus.h @@ -47,7 +47,6 @@ #define WIN32_LEAN_AND_MEAN #define NOUSER -#define NOMINMAX // do not use min, max as macro #if _MSC_VER >= 1800 // From VS2013 onwards, std::min/max are only defined if algorithm is included From 3ab44693d8f4081909e9d5a1d1002b120cb5411b Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Mon, 30 Nov 2015 14:12:32 +0100 Subject: [PATCH 3/4] build nsis installer on appveyor and release to github --- CMakeLists.txt | 17 +++++++++++------ appveyor.yml | 18 +++++++++++++++++- src/win32/stratagus.nsi | 7 +++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c35874cf..d983cc0f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -762,7 +762,10 @@ if(WITH_FLUIDSYNTH AND FLUIDSYNTH_FOUND) add_definitions(-DUSE_FLUIDSYNTH ${FLUIDSYNTH_DEFINITIONS}) include_directories(${FLUIDSYNTH_INCLUDE_DIR}) set(stratagus_LIBS ${stratagus_LIBS} ${FLUIDSYNTH_LIBRARY}) - set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -DFLUID) + find_file(FLUIDSYNTH_DLL libfluidsynth.dll HINTS ${CMAKE_PREFIX_PATH}/bin) + find_file(GLIB_DLL libglib-2.0-0.dll HINTS ${CMAKE_PREFIX_PATH} PATH_SUFFIXES bin lib) + find_file(GTHREAD_DLL libgthread-2.0-0.dll HINTS ${CMAKE_PREFIX_PATH} PATH_SUFFIXES bin lib) + set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -DFLUID -DFLUIDDLL=libfluidsynth.dll -DGTHREADDLL=libglib-2.0-0.dll -DGLIBDLL=libgthread-2.0-0.dll) endif() if(WITH_MIKMOD AND MIKMOD_FOUND) @@ -939,10 +942,7 @@ endif() if(ENABLE_MULTIBUILD) if(WIN32 AND MSVC) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMT") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") message(STATUS "Added parallel build arguments to CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") endif() endif() @@ -1239,8 +1239,13 @@ endif() ########### next target ############### if(WIN32 AND ENABLE_NSIS AND MAKENSIS_FOUND) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/COPYING DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/COPYING DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/win32/stratagus.ico DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + if(WITH_FLUIDSYNTH AND FLUIDSYNTH_FOUND) + file(COPY ${FLUIDSYNTH_DLL} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${GLIB_DLL} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${GTHREAD_DLL} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + endif() add_custom_command(OUTPUT Stratagus-${STRATAGUS_VERSION}${MAKENSIS_SUFFIX} COMMAND ${MAKENSIS} ARGS ${MAKENSIS_FLAGS} -DVERSION=${STRATAGUS_VERSION} -DVIVERSION=${STRATAGUS_VERSION_FULL} ${CMAKE_CURRENT_SOURCE_DIR}/src/win32/stratagus.nsi DEPENDS src/win32/stratagus.nsi stratagus COPYING diff --git a/appveyor.yml b/appveyor.yml index 4481641c5..983fbbeea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,24 @@ shallow_clone: true +configuration: + - Release before_build: - mkdir build - cd build - appveyor DownloadFile https://github.com/Wargus/stratagus/releases/download/2015-30-11/dependencies.zip - 7z x dependencies.zip - - cmake -G "Visual Studio 14 2015" -DCMAKE_PREFIX_PATH="%cd%\\dependencies" .. + - choco install nsis -pre + - cmake -G "Visual Studio 14 2015" -DCMAKE_PREFIX_PATH="%cd%\\dependencies" -DENABLE_NSIS=ON .. - cd .. +artifacts: + - path: build\Stratagus-*.exe +deploy: + release: master-builds + description: 'Automatic builds from the master branch' + provider: GitHub + auth_token: + secure: NMy2KE3EpZTjverxNzEAoBnlV+7VLGvwy3e1WEIrliFy3R1oxuT+AgGUDcRwv9y/ + artifact: /.*exe/ + draft: false + prerelease: true + on: + branch: tim/vs2015 diff --git a/src/win32/stratagus.nsi b/src/win32/stratagus.nsi index 1d0eb18dd..3f7dcd6c7 100644 --- a/src/win32/stratagus.nsi +++ b/src/win32/stratagus.nsi @@ -58,7 +58,7 @@ !define SDL "SDL.dll" !ifndef NO_DOWNLOAD -!system 'powershell -Command "& {wget https://www.libsdl.org/release/SDL-1.2.15-win32.zip -O SDL.zip}"' +!system 'powershell -Command "& {wget https://www.libsdl.org/release/SDL-1.2.15-win32.zip -OutFile SDL.zip}"' !system 'powershell -Command "& {unzip -o SDL.zip SDL.dll}"' !endif @@ -92,9 +92,6 @@ ${redefine} NAME "Stratagus (64 bit)" !endif -!ifdef FLUID -!define FLUIDDLL "libfluidsynth.dll" -!endif !define REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" ;-------------------------------- @@ -228,6 +225,8 @@ Section "${NAME}" File "${SDL}" !ifdef FLUID File "${FLUIDDLL}" + File "${GLIBDLL}" + File "${GTHREADDLL}" !endif WriteRegStr HKLM "${REGKEY}" "DisplayName" "${NAME}" WriteRegStr HKLM "${REGKEY}" "UninstallString" "$\"$INSTDIR\${UNINSTALL}$\"" From 7479cc5522b6c33dba399a8432e47993c83dd8eb Mon Sep 17 00:00:00 2001 From: Tim Felgentreff <timfelgentreff@gmail.com> Date: Wed, 2 Dec 2015 09:49:37 +0100 Subject: [PATCH 4/4] [skip ci] deploy windows installer from master only --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 983fbbeea..8407de65c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,4 +21,4 @@ deploy: draft: false prerelease: true on: - branch: tim/vs2015 + branch: master