Browse Source

Enable building with MSVC 2017 (#75)

pull/79/head
Anders Jenbo 7 years ago committed by GitHub
parent
commit
3f9691bf2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      CMakeLists.txt
  2. 12
      README.md
  3. 1
      Source/control.cpp
  4. 1
      Source/cursor.cpp
  5. 3
      Source/fault.cpp
  6. 2
      SourceS/miniwin.h
  7. 4
      SourceS/miniwin/misc_macro.h
  8. 8
      SourceX/DiabloUI/diabloui.cpp
  9. 4
      SourceX/miniwin/misc.cpp
  10. 2
      SourceX/miniwin/misc_msg.cpp
  11. 3
      SourceX/sound.cpp
  12. 2
      SourceX/storm/storm.cpp
  13. 15
      appveyor.yml

30
CMakeLists.txt

@ -232,20 +232,28 @@ if(WIN32)
target_compile_options(devilution PUBLIC $<$<CONFIG:Debug>:-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 $<$<CONFIG:Debug>:-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 $<$<CONFIG:Debug>:-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

12
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)
```
</details>
<details><summary>Windows via Visual Studio</summary>
### 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.
</details>
## 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).*

1
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:

1
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;

3
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()

2
SourceS/miniwin.h

@ -14,7 +14,7 @@
#include <string.h>
#include <time.h>
// For _rotr()
#ifdef DEVILUTION_ENGINE
#if !defined(_MSC_VER) && defined(DEVILUTION_ENGINE)
#include <x86intrin.h>
#endif

4
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;

8
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;
}

4
SourceX/miniwin/misc.cpp

@ -5,6 +5,10 @@
#include "dx.h"
#include "DiabloUI/diabloui.h"
#include <string>
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
namespace dvl {

2
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;
}

3
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();

2
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) {

15
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

Loading…
Cancel
Save