diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd742280..21cf79653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,20 +232,28 @@ if(WIN32) target_compile_options(devilution PUBLIC $<$:-gstabs>) endif() -target_compile_options(devilution PUBLIC -Wno-unknown-pragmas) -# Note: In Debug mode, GCC generates spurious memory references that upset Valgrind, -# these options fix that. -target_compile_options(devilution PUBLIC $<$:-fno-omit-frame-pointer>) -# Ignore serious warnings due to "quality" of decompiled code -# Currently, disable ignore all warnings (-w), to be removed later -target_compile_options(devilution PRIVATE -fpermissive -Wno-write-strings -Wno-multichar -w) -# Disable optimizations that can break non-standards-conforming code -target_compile_options(devilution PRIVATE -fno-strict-aliasing) +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # Note: In Debug mode, GCC generates spurious memory references that upset Valgrind, + # these options fix that. + target_compile_options(devilution PUBLIC $<$:-fno-omit-frame-pointer>) + target_compile_options(devilution PUBLIC -Wno-unknown-pragmas) + # Ignore serious warnings due to "quality" of decompiled code + # Currently, disable ignore all warnings (-w), to be removed later + target_compile_options(devilution PRIVATE -fpermissive -Wno-write-strings -Wno-multichar -w) + # Disable optimizations that can break non-standards-conforming code + target_compile_options(devilution PRIVATE -fno-strict-aliasing) + + # Warnings for devilutionX + target_compile_options(devilutionx PRIVATE -Wall -Wextra -Wno-write-strings -Wno-multichar -Wno-unused-parameter) +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + target_compile_options(devilution PRIVATE "/W0") +endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") target_compile_options(devilution PRIVATE -fno-aggressive-loop-optimizations) endif() -# Warnings for devilutionX -target_compile_options(devilutionx PRIVATE -Wall -Wextra -Wno-write-strings -Wno-multichar -Wno-unused-parameter) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Style issues diff --git a/README.md b/README.md index 471e1e718..a5f675cb5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Status | Platform ---:| --- [![CircleCI](https://circleci.com/gh/diasurgical/devilutionX.svg?style=svg)](https://circleci.com/gh/diasurgical/devilutionX) | Linux 32bit & 64bit, Windows 32bit [![Build Status](https://travis-ci.org/diasurgical/devilutionX.svg?branch=master)](https://travis-ci.org/diasurgical/devilutionX) | macOS 32bit & 64bit +[![Build status](https://ci.appveyor.com/api/projects/status/1a0jus2372qvksht?svg=true)](https://ci.appveyor.com/project/AJenbo/devilutionx) | Windows MSVC ![Discord Channel](https://avatars3.githubusercontent.com/u/1965106?s=16&v=4) [Discord Chat Channel](https://discord.gg/aQBQdDe) @@ -77,6 +78,17 @@ cmake -DASAN=OFF -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake .. make -j$(nproc) ``` +
Windows via Visual Studio + +### Installing dependencies +Make sure to install the `C++ CMake tools for Windows` component for Visual Studio. + +Download and place the 32bit MSVC Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php), [SDL2_mixer](https://www.libsdl.org/projects/SDL_mixer/), [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/) and [Libsodium](https://github.com/jedisct1/libsodium/releases) in `%USERPROFILE%\AppData\Local\Microsoft\WindowsApps\`. + +Go to `File -> Open -> CMake`, select `CMakeLists` from the project root. +### Compiling +Next select `Build devilution.exe` from the `Build` menu. +
## Building for the native platform *Note: Since 64-bit builds are currently not in a playable state, it is advised to build in a 32-bit environment. Another possibility is a 32-bit build on a 64-bit system (see above).* diff --git a/Source/control.cpp b/Source/control.cpp index b7eb94620..0b218684b 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -427,6 +427,7 @@ void __cdecl DrawSpellList() v0 = myplr; v1 = RSPLTYPE_SKILL; v24 = 0; + nCel = 0; do { switch (v1) { case RSPLTYPE_SKILL: diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 14ab57605..90f58d5c3 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -268,6 +268,7 @@ void __cdecl CheckCursMove() if (my >= MAXDUNY) my = MAXDUNY - 1; + some_bool = 0; if (posy_31 >= posx_63 >> 1) { if (!v9) some_bool = 0; diff --git a/Source/fault.cpp b/Source/fault.cpp index 98b581766..3b9e75e5a 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -292,7 +292,8 @@ void *__fastcall fault_set_filter(void *unused) LPTOP_LEVEL_EXCEPTION_FILTER __fastcall fault_reset_filter(void *unused) { - return SetUnhandledExceptionFilter(lpTopLevelExceptionFilter); + //return SetUnhandledExceptionFilter(lpTopLevelExceptionFilter); + return lpTopLevelExceptionFilter; } LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_get_filter() diff --git a/SourceS/miniwin.h b/SourceS/miniwin.h index 05e5dc254..7ced093c0 100644 --- a/SourceS/miniwin.h +++ b/SourceS/miniwin.h @@ -14,7 +14,7 @@ #include #include // For _rotr() -#ifdef DEVILUTION_ENGINE +#if !defined(_MSC_VER) && defined(DEVILUTION_ENGINE) #include #endif diff --git a/SourceS/miniwin/misc_macro.h b/SourceS/miniwin/misc_macro.h index f47db8702..6a03a95f6 100644 --- a/SourceS/miniwin/misc_macro.h +++ b/SourceS/miniwin/misc_macro.h @@ -15,7 +15,11 @@ #define LOWORD(l) ((WORD)(((DWORD_PTR)(l)) & 0xffff)) #define HIWORD(l) ((WORD)((((DWORD_PTR)(l)) >> 16) & 0xffff)) +#ifdef _MSC_VER +#define InterlockedIncrement(x) (x) +#else #define InterlockedIncrement(x) __sync_add_and_fetch(x, 1) +#endif #define INFINITE DVL_INFINITE; diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index e8ebd77ee..59115ff4a 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -179,11 +179,11 @@ void UiFocus(int itemIndex, bool wrap = false) itemIndex = SelectedItemMin; return; } else if (itemIndex > SelectedItemMax) { - itemIndex = SelectedItemMax ?: SelectedItemMin; + itemIndex = SelectedItemMax ? SelectedItemMax : SelectedItemMin; return; } } else if (itemIndex < SelectedItemMin) { - itemIndex = SelectedItemMax ?: SelectedItemMin; + itemIndex = SelectedItemMax ? SelectedItemMax : SelectedItemMin; } else if (itemIndex > SelectedItemMax) { itemIndex = SelectedItemMin; } @@ -519,7 +519,7 @@ void DrawArt(int screenX, int screenY, Art *art, int nFrame, int drawW) { BYTE *src = (BYTE *)art->data + (art->width * art->height * nFrame); BYTE *dst = &gpBuffer[screenX + 64 + (screenY + 160) * 768]; - drawW = drawW ?: art->width; + drawW = drawW ? drawW : art->width; for (int i = 0; i < art->height && i + screenY < SCREEN_HEIGHT; i++, src += art->width, dst += ROW_PITCH) { for (int j = 0; j < art->width && j + screenX < SCREEN_WIDTH; j++) { @@ -638,7 +638,7 @@ void DrawArtStr(UI_Item *item) sy += ArtFonts[size][color].height; continue; } - BYTE w = FontTables[size][*(BYTE *)&item->caption[i] + 2] ?: FontTables[size][0]; + BYTE w = FontTables[size][*(BYTE *)&item->caption[i] + 2] ? FontTables[size][*(BYTE *)&item->caption[i] + 2] : FontTables[size][0]; DrawArt(sx, sy, &ArtFonts[size][color], *(BYTE *)&item->caption[i], w); sx += w; } diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 925388cc2..2e147b98c 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -5,6 +5,10 @@ #include "dx.h" #include "DiabloUI/diabloui.h" #include +#ifdef _MSC_VER +#define strcasecmp _stricmp +#endif + namespace dvl { diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index c03983a81..f39f53acd 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -98,7 +98,7 @@ static WPARAM keystate_for_mouse(WPARAM ret) static WINBOOL false_avail() { - DUMMY_PRINT("return false although event avaliable"); + DUMMY_PRINT("return false although event avaliable", 1); return false; } diff --git a/SourceX/sound.cpp b/SourceX/sound.cpp index 3eafc1e2f..eba8d21f7 100644 --- a/SourceX/sound.cpp +++ b/SourceX/sound.cpp @@ -410,7 +410,8 @@ HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pU if (hDsound_dll == NULL) { } } - + + DirectSoundCreate = NULL; if (DirectSoundCreate == NULL) { } *ppDS = new DirectSound(); diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 1e5ea82b3..d78851765 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -323,7 +323,7 @@ void setIniValue(const char *sectionName, const char *keyName, char *value, int section = ini.getSection(sectionName); } - std::string stringValue(value, len ?: strlen(value)); + std::string stringValue(value, len ? len : strlen(value)); radon::Key *key = section->getKey(keyName); if (!key) { diff --git a/appveyor.yml b/appveyor.yml index 80c787c6c..d33ef6de3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,20 @@ version: 1.0.{build} + pull_requests: do_not_increment_build_number: true clone_depth: 1 image: Visual Studio 2017 -configuration: Release -platform: x86 +cache: c:\tools\vcpkg\installed\ + +install: + - vcpkg install sdl2:x86-windows sdl2-mixer:x86-windows sdl2-ttf:x86-windows libsodium:x86-windows + +before_build: + - cmake -G "Visual Studio 15 2017" -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake . + build: - project: Diablo.sln + project: $(APPVEYOR_BUILD_FOLDER)\$(APPVEYOR_PROJECT_NAME).sln verbosity: minimal artifacts: - path: Debug\devilutionx.exe - - name: devilutionx.exe + name: devilutionx.exe