From 3feccdc9892985ece7c3049a188a2d9fff1879f1 Mon Sep 17 00:00:00 2001 From: Xadhoom <> Date: Mon, 18 Mar 2019 20:56:30 +0000 Subject: [PATCH] Fixes, fix some warnings --- CMakeLists.txt | 2 +- SourceS/miniwin/misc.h | 2 +- SourceX/dx.cpp | 2 +- SourceX/miniwin/misc.cpp | 5 +++-- SourceX/miniwin/misc_io.cpp | 4 ++-- SourceX/miniwin/rand.cpp | 2 +- SourceX/storm/storm.cpp | 26 +++++++++++++------------- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b1a2228..78734f420 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,7 +240,7 @@ 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-multichar -Wno-unused-parameter) +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/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 255d080dd..958fe17e6 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -199,7 +199,7 @@ struct DVL_finddata_t { time_t time_access; /* -1 for FAT file systems */ time_t time_write; _fsize_t size; - char name[260]; + char name[DVL_MAX_PATH]; }; typedef WORD ATOM; diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index d473afcb0..274566096 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -384,7 +384,7 @@ void dx_init(HWND hWnd) return; } - MainWndProc(NULL, DVL_WM_ACTIVATEAPP, true, NULL); + MainWndProc(NULL, DVL_WM_ACTIVATEAPP, true, 0); lpDDInterface = &stub_draw; lpDDSPrimary = &stub_surface; diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index dfb541a81..4711e9852 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -276,7 +276,7 @@ HWND FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) void FakeWMDestroy() { - MainWndProc(NULL, DVL_WM_DESTROY, 0, NULL); + MainWndProc(NULL, DVL_WM_DESTROY, 0, 0); } HWND CreateWindowExA( @@ -641,6 +641,7 @@ DWORD GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefa strncpy(lpReturnedString, lpDefault, nSize); SRegSaveString(lpAppName, lpKeyName, 0, lpReturnedString); } + return 0; // dummy return value } int MessageBoxA(HWND hWnd, const char *Text, const char *Title, UINT Flags) @@ -706,7 +707,7 @@ LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) if (Msg == DVL_WM_QUERYENDSESSION) exit(0); - return NULL; + return 0; } LONG GetWindowLongA(HWND hWnd, int nIndex) diff --git a/SourceX/miniwin/misc_io.cpp b/SourceX/miniwin/misc_io.cpp index fd507b1d5..387718a42 100644 --- a/SourceX/miniwin/misc_io.cpp +++ b/SourceX/miniwin/misc_io.cpp @@ -90,11 +90,11 @@ DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveH file->pos = lDistanceToMove; } else if (dwMoveMethod == DVL_FILE_CURRENT) { file->pos += lDistanceToMove; - if(file->buf.size() < file->pos + 1) - file->buf.resize(file->pos + 1); } else { UNIMPLEMENTED(); } + if(file->buf.size() < file->pos + 1) + file->buf.resize(file->pos + 1); return file->pos; } diff --git a/SourceX/miniwin/rand.cpp b/SourceX/miniwin/rand.cpp index b14b044f4..327e8d1cc 100644 --- a/SourceX/miniwin/rand.cpp +++ b/SourceX/miniwin/rand.cpp @@ -1,4 +1,4 @@ -#include +#include #include "devilution.h" diff --git a/SourceX/storm/storm.cpp b/SourceX/storm/storm.cpp index 74b0c318e..6603b3f55 100644 --- a/SourceX/storm/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -13,6 +13,19 @@ namespace dvl { DWORD nLastError = 0; +static std::string getIniPath() +{ + char path[DVL_MAX_PATH]; + int len = GetModuleFileNameA(ghInst, path, DVL_MAX_PATH); + path[len - 1] = '/'; + strcat(path, "diablo.ini"); + + return path; +} + +static radon::File ini(getIniPath()); +static Mix_Chunk *SFileChunk; + void TranslateFileName(char *dst, int dstLen, const char *src) { for (int i = 0; i < dstLen; i++) { @@ -24,18 +37,6 @@ void TranslateFileName(char *dst, int dstLen, const char *src) } } -std::string getIniPath() -{ - char path[280]; - int len = GetModuleFileNameA(ghInst, path, 260); - path[len - 1] = '/'; - strcat(path, "diablo.ini"); - - return path; -} - -radon::File ini(getIniPath()); - // BOOL SFileCloseArchive(HANDLE hArchive) // { // UNIMPLEMENTED(); @@ -46,7 +47,6 @@ radon::File ini(getIniPath()); // UNIMPLEMENTED(); // } -Mix_Chunk *SFileChunk; BOOL SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7) {