summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeway <mewaysid92@gmail.com>2025-06-30 10:11:51 -0500
committerMeway <mewaysid92@gmail.com>2025-06-30 10:11:51 -0500
commita5c77bd142a78586af89ee95da088533426e957b (patch)
tree757c0d62a5078a1da4c364d631ed9981c8c70b63
parent427c4ba42ff64cdf4f9c370cfd9c29785a85d27c (diff)
downloadmanaserv-windowssupport-a5c77bd142a78586af89ee95da088533426e957b.tar.gz
manaserv-windowssupport-a5c77bd142a78586af89ee95da088533426e957b.tar.bz2
manaserv-windowssupport-a5c77bd142a78586af89ee95da088533426e957b.tar.xz
manaserv-windowssupport-a5c77bd142a78586af89ee95da088533426e957b.zip
Fixing windows support
Changes to be committed: modified: CMake/Modules/FindLibIntl.cmake modified: CMakeLists.txt modified: src/CMakeLists.txt modified: src/Makefile.am modified: src/chatlogger.cpp modified: src/configmanager.cpp modified: src/debug/nvwa/debug_new.cpp modified: src/debug/nvwa/fast_mutex.h modified: src/defaults.cpp modified: src/dirs.cpp modified: src/enums/input/inputaction.h modified: src/enums/state.h modified: src/fs/files.cpp modified: src/fs/mkdir.cpp modified: src/fs/paths.cpp modified: src/fs/specialfolder.cpp modified: src/fs/specialfolder.h modified: src/fs/virtfs/fs.cpp modified: src/fs/virtfs/fsdir.cpp modified: src/game.cpp modified: src/graphicsmanager.cpp modified: src/gui/dialogsmanager.cpp modified: src/gui/palette.cpp modified: src/gui/widgets/tabs/chat/chattab.cpp modified: src/gui/widgets/tabs/setup_misc.cpp modified: src/gui/widgets/tabs/setup_video.cpp modified: src/gui/widgets/tabs/setup_visual.cpp modified: src/gui/windowmanager.cpp modified: src/gui/windows/killstats.cpp modified: src/gui/windows/serverdialog.cpp modified: src/gui/windows/updaterwindow.cpp modified: src/logger.cpp modified: src/main.cpp modified: src/main.h modified: src/maingui.cpp modified: src/mumblemanager.cpp modified: src/particle/particleemitterprop.h modified: src/progs/dyecmd/client.cpp modified: src/progs/manaverse/client.cpp modified: src/render/opengl/mgl.hpp modified: src/render/opengl/mglfunctions.h modified: src/render/opengl/mgltypes.h modified: src/resources/wallpaper.cpp modified: src/sdl2gfx/SDL2_rotozoom.cpp modified: src/sdl2gfx/SDL2_rotozoom.h modified: src/test/testlauncher.cpp modified: src/test/testlauncher.h modified: src/unittests/fs/files.cc modified: src/utils/copynpaste.cpp modified: src/utils/env.cpp modified: src/utils/gettexthelper.cpp modified: src/utils/process.cpp modified: src/utils/stringutils.cpp modified: src/utils/xml/libxml.cpp
-rw-r--r--CMake/Modules/FindLibIntl.cmake2
-rw-r--r--CMakeLists.txt8
-rw-r--r--src/CMakeLists.txt8
-rw-r--r--src/Makefile.am6
-rw-r--r--src/chatlogger.cpp2
-rw-r--r--src/configmanager.cpp2
-rw-r--r--src/debug/nvwa/debug_new.cpp6
-rw-r--r--src/debug/nvwa/fast_mutex.h6
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/dirs.cpp12
-rw-r--r--src/enums/input/inputaction.h2
-rw-r--r--src/enums/state.h2
-rw-r--r--src/fs/files.cpp47
-rw-r--r--src/fs/mkdir.cpp4
-rw-r--r--src/fs/paths.cpp12
-rw-r--r--src/fs/specialfolder.cpp2
-rw-r--r--src/fs/specialfolder.h2
-rw-r--r--src/fs/virtfs/fs.cpp2
-rw-r--r--src/fs/virtfs/fsdir.cpp174
-rw-r--r--src/game.cpp2
-rw-r--r--src/graphicsmanager.cpp8
-rw-r--r--src/gui/dialogsmanager.cpp2
-rw-r--r--src/gui/palette.cpp400
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_misc.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp6
-rw-r--r--src/gui/widgets/tabs/setup_visual.cpp4
-rw-r--r--src/gui/windowmanager.cpp8
-rw-r--r--src/gui/windows/killstats.cpp2
-rw-r--r--src/gui/windows/serverdialog.cpp2
-rw-r--r--src/gui/windows/updaterwindow.cpp2
-rw-r--r--src/logger.cpp6
-rw-r--r--src/main.cpp2
-rw-r--r--src/main.h2
-rw-r--r--src/maingui.cpp2
-rw-r--r--src/mumblemanager.cpp6
-rw-r--r--src/particle/particleemitterprop.h256
-rw-r--r--src/progs/dyecmd/client.cpp8
-rw-r--r--src/progs/manaverse/client.cpp8
-rw-r--r--src/render/opengl/mgl.hpp2
-rw-r--r--src/render/opengl/mglfunctions.h2
-rw-r--r--src/render/opengl/mgltypes.h2
-rw-r--r--src/resources/wallpaper.cpp2
-rw-r--r--src/sdl2gfx/SDL2_rotozoom.cpp2
-rw-r--r--src/sdl2gfx/SDL2_rotozoom.h262
-rw-r--r--src/test/testlauncher.cpp2
-rw-r--r--src/test/testlauncher.h2
-rw-r--r--src/unittests/fs/files.cc2
-rw-r--r--src/utils/copynpaste.cpp4
-rw-r--r--src/utils/env.cpp6
-rw-r--r--src/utils/gettexthelper.cpp15
-rw-r--r--src/utils/process.cpp13
-rw-r--r--src/utils/stringutils.cpp8
-rw-r--r--src/utils/xml/libxml.cpp5
54 files changed, 738 insertions, 622 deletions
diff --git a/CMake/Modules/FindLibIntl.cmake b/CMake/Modules/FindLibIntl.cmake
index e75960525..fbe0b7515 100644
--- a/CMake/Modules/FindLibIntl.cmake
+++ b/CMake/Modules/FindLibIntl.cmake
@@ -15,7 +15,7 @@ ENDIF ()
# for Windows we rely on the environement variables
# %INCLUDE% and %LIB%; FIND_LIBRARY checks %LIB%
# automatically on Windows
-IF(WIN32)
+IF(_WIN32)
FIND_LIBRARY(LibIntl_LIBRARY
NAMES intl
)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aaca9b88d..ead1eb873 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,19 +33,19 @@ OPTION(USE_SDL2 "Build with SDL 2.0 instead of 1.2" OFF)
OPTION(ENABLE_NLS "Enable building of tranlations" ON)
OPTION(ENABLE_TMWA "Enable tmwA support" ON)
-IF (WIN32)
+IF (_WIN32)
SET(PKG_DATADIR ".")
SET(PKG_BINDIR ".")
SET(LOCALEDIR ".")
CONFIGURE_FILE(src/winver.h.in src/winver.h)
-ELSE (WIN32)
+ELSE (_WIN32)
IF (NOT OSX AND NOT BEOS)
OPTION(USE_X11 "Use X11 Clipboard functionality" ON)
ENDIF ()
SET(PKG_DATADIR ${CMAKE_INSTALL_PREFIX}/share/manaplus)
SET(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
SET(PKG_BINDIR ${CMAKE_INSTALL_PREFIX}/bin)
-ENDIF (WIN32)
+ENDIF (_WIN32)
ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(src)
@@ -70,7 +70,7 @@ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "ManaPlus")
SET(CPACK_PACKAGE_VERSION_MAJOR ${VER_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${VER_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${VER_RELEASE})
-IF(WIN32)
+IF(_WIN32)
SET(CPACK_NSIS_DISPLAY_NAME "ManaVerse")
SET(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/icons/manaplus.ico")
SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/packaging/windows/setup_welcome.bmp")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 64c62002f..05501d646 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -57,7 +57,7 @@ IF (CMAKE_BUILD_TYPE)
ENDIF()
ENDIF()
-IF (WIN32)
+IF (_WIN32)
SET(EXTRA_LIBRARIES ws2_32 winmm)
FIND_PACKAGE(LibIntl REQUIRED)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR BEOS)
@@ -2213,7 +2213,7 @@ SET(SRCS_TMWA
gui/widgets/tabs/socialguildtab2.h
)
-IF (WIN32)
+IF (_WIN32)
SET(SRCS
${SRCS}
fs/specialfolder.cpp
@@ -2237,8 +2237,8 @@ ELSE()
SET(SRCS ${SRCS})
ENDIF(ENABLE_TMWA)
-ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EVOL})
-#ADD_EXECUTABLE(dyecmd WIN32 ${DYE_CMD_SRCS})
+ADD_EXECUTABLE(manaplus _WIN32 ${SRCS} ${SRCS_EVOL})
+#ADD_EXECUTABLE(dyecmd _WIN32 ${DYE_CMD_SRCS})
IF (USE_SDL2)
SET(SDL_LIBS
diff --git a/src/Makefile.am b/src/Makefile.am
index 141e4897b..2ec4d7d49 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -168,8 +168,10 @@ dyecmd_SOURCES += debug/mse/msemsevector.h \
endif
if MINGW
-manaplus_SOURCES += manaplus.rc
-dyecmd_SOURCES += manaplus.rc
+LIBS += -lopengl32
+manaplus_RESOURCES = manaplus.rc
+dyecmd_RESOURCES = manaplus.rc
+manaplustests_RESOURCES = manaplus.rc
endif
dyecmd_CXXFLAGS += -DDYECMD
diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp
index 7bede5777..b8272b888 100644
--- a/src/chatlogger.cpp
+++ b/src/chatlogger.cpp
@@ -32,7 +32,7 @@
#include <dirent.h>
#include <iostream>
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#include <sys/time.h>
#elif defined __APPLE__
diff --git a/src/configmanager.cpp b/src/configmanager.cpp
index 4417bfe16..b0de0d5b2 100644
--- a/src/configmanager.cpp
+++ b/src/configmanager.cpp
@@ -109,7 +109,7 @@ void ConfigManager::initConfiguration()
config.setValue("opengl", CAST_S32(RENDER_NORMAL_OPENGL));
#elif (defined ANDROID)
config.setValue("opengl", CAST_S32(RENDER_GLES_OPENGL));
-#elif (defined WIN32)
+#elif (defined _WIN32)
config.setValue("opengl", CAST_S32(RENDER_SAFE_OPENGL));
#else // (defined __APPLE__)
diff --git a/src/debug/nvwa/debug_new.cpp b/src/debug/nvwa/debug_new.cpp
index 77ef8f17e..471032290 100644
--- a/src/debug/nvwa/debug_new.cpp
+++ b/src/debug/nvwa/debug_new.cpp
@@ -61,8 +61,8 @@ PRAGMA45(GCC diagnostic ignored "-Wcast-qual")
#endif
#if NVWA_WINDOWS
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
+#ifndef _WIN32_LEAN_AND_MEAN
+#define _WIN32_LEAN_AND_MEAN
#endif
#include <windows.h> // CaptureStackBackTrace
#endif
@@ -405,7 +405,7 @@ static bool print_position_from_addr(const void* addr)
#if NVWA_UNIX && !NVWA_CYGWIN
const char ignore_err[] = " 2>/dev/null";
#elif NVWA_CYGWIN || \
- (NVWA_WIN32 && defined(WINVER) && WINVER >= 0x0500)
+ (NVWA__WIN32 && defined(WINVER) && WINVER >= 0x0500)
const char ignore_err[] = " 2>nul";
#else
const char ignore_err[] = "";
diff --git a/src/debug/nvwa/fast_mutex.h b/src/debug/nvwa/fast_mutex.h
index faccc4893..7f4d9270b 100644
--- a/src/debug/nvwa/fast_mutex.h
+++ b/src/debug/nvwa/fast_mutex.h
@@ -285,9 +285,9 @@ NVWA_NAMESPACE_BEGIN
};
NVWA_NAMESPACE_END
# elif defined(NVWA_WIN32THREADS)
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif /* WIN32_LEAN_AND_MEAN */
+# ifndef _WIN32_LEAN_AND_MEAN
+# define _WIN32_LEAN_AND_MEAN
+# endif /* _WIN32_LEAN_AND_MEAN */
# include <windows.h>
NVWA_NAMESPACE_BEGIN
/**
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 354393946..47a1daed6 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -311,7 +311,7 @@ void setConfigDefaults(Configuration &cfg)
AddDEF("downloadProxyType", 0);
AddDEF("downloadProxyTunnel", false);
AddDEF("blur", false);
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || defined(__APPLE__)
AddDEF("centerwindow", true);
#else // defined(WIN32) || defined(__APPLE__)
diff --git a/src/dirs.cpp b/src/dirs.cpp
index 1a39f9e1e..8593e3590 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -56,7 +56,7 @@
#include <CoreFoundation/CFBundle.h>
#endif // __APPLE__
-#ifdef WIN32
+#ifdef _WIN32
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_syswm.h>
@@ -245,7 +245,7 @@ void Dirs::mountDataDir()
Append_false);
#endif // defined __native_client__
-#ifndef WIN32
+#ifndef _WIN32
// Add branding/data to VirtFS search path
if (!settings.options.brandingPath.empty())
{
@@ -349,7 +349,7 @@ void Dirs::initLocalDataDir()
#elif defined __HAIKU__
settings.localDataDir = pathJoin(VirtFs::getUserDir(),
"config/cache/Mana");
-#elif defined WIN32
+#elif defined _WIN32
settings.localDataDir = getSpecialFolderLocation(CSIDL_LOCAL_APPDATA);
if (settings.localDataDir.empty())
settings.localDataDir = VirtFs::getUserDir();
@@ -407,7 +407,7 @@ void Dirs::initConfigDir()
settings.configDir = pathJoin(VirtFs::getUserDir(),
"config/settings/Mana",
branding.getValue("appName", "ManaPlus"));
-#elif defined WIN32
+#elif defined _WIN32
settings.configDir = getSpecialFolderLocation(CSIDL_APPDATA);
if (settings.configDir.empty())
{
@@ -499,7 +499,7 @@ void Dirs::initUpdatesDir()
settings.updatesDir = updates.str();
}
-#ifdef WIN32
+#ifdef _WIN32
if (settings.updatesDir.find(":") != std::string::npos)
replaceAll(settings.updatesDir, ":", "_");
#endif // WIN32
@@ -511,7 +511,7 @@ void Dirs::initUpdatesDir()
{
if (!VirtFs::mkdir(updateDir))
{
-#if defined WIN32
+#if defined _WIN32
std::string newDir = pathJoin(settings.localDataDir,
settings.updatesDir);
if (!CreateDirectory(newDir.c_str(), nullptr) &&
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 5abfd9d14..6b7e6220e 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -26,7 +26,7 @@
#include "enums/simpletypes/enumdefines.h"
-#ifdef WIN32
+#ifdef _WIN32
#undef ERROR
#undef IGNORE
#endif // WIN32
diff --git a/src/enums/state.h b/src/enums/state.h
index 4784428dc..e348528ab 100644
--- a/src/enums/state.h
+++ b/src/enums/state.h
@@ -26,7 +26,7 @@
#include "enums/simpletypes/enumdefines.h"
-#ifdef WIN32
+#ifdef _WIN32
#undef ERROR
#endif // WIN32
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
index 5a041b698..b30ed48da 100644
--- a/src/fs/files.cpp
+++ b/src/fs/files.cpp
@@ -18,6 +18,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef _WIN32
+ #include <windows.h> // for FILEHDEFAULT, FILEOPEN, FILEOPEN_FLAG_READ,
+ // FILEOPEN_FLAG_WRITE, FILEOPEN_FLAG_APPEND
+#else // _WIN32
+ #define _POSIX_C_SOURCE 200809L
+ #include <unistd.h> // for lstat()
+ #include <sys/stat.h> // for S_ISLNK
+#endif
#include "fs/files.h"
@@ -209,7 +217,7 @@ int Files::copyFile(const std::string &restrict srcName,
bool Files::existsLocal(const std::string &path)
{
struct stat statbuf;
-#ifdef WIN32
+#ifdef _WIN32
// in windows path\file.ext\ by default detected as exists
// if file.ext is not directory, need return false
const bool res = (stat(path.c_str(), &statbuf) == 0);
@@ -303,17 +311,32 @@ void Files::enumFiles(StringVect &files,
const std::string file = next_file->d_name;
if (file == "." || file == "..")
continue;
-#ifndef WIN32
- if (skipSymlinks == true)
- {
- struct stat statbuf;
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
+#if !defined(_WIN32)
+ if (skipSymlinks)
+ {
+ struct stat statbuf;
+ const std::string fullPath = path + file;
+ if (lstat(fullPath.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode))
+ {
+ continue;
+ }
+ }
+#else
+ if (skipSymlinks)
+ {
+ const std::string fullPath = path + file;
+ DWORD attrs = GetFileAttributesA(fullPath.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & FILE_ATTRIBUTE_REPARSE_POINT))
+ {
+ // This is a symlink or junction, skip it
+ continue;
+ }
+ }
+#endif
+
+
files.push_back(file);
}
closedir(dir);
diff --git a/src/fs/mkdir.cpp b/src/fs/mkdir.cpp
index ee344324c..4542f4a35 100644
--- a/src/fs/mkdir.cpp
+++ b/src/fs/mkdir.cpp
@@ -24,7 +24,7 @@
#include "utils/cast.h"
-#if defined WIN32
+#if defined _WIN32
#include <limits.h>
#include <windows.h>
#endif // defined WIN32
@@ -33,7 +33,7 @@
#include "debug.h"
-#if defined WIN32
+#if defined _WIN32
int mkdir_r(const char *const pathname)
{
if (!pathname)
diff --git a/src/fs/paths.cpp b/src/fs/paths.cpp
index 897d2ff41..e5326a08c 100644
--- a/src/fs/paths.cpp
+++ b/src/fs/paths.cpp
@@ -42,7 +42,7 @@
#define realpath(N, R) strcpy(R, N)
#endif // __native_client__
-#ifdef WIN32
+#ifdef _WIN32
#include "fs/specialfolder.h"
#define realpath(N, R) _fullpath((R), (N), _MAX_PATH)
#endif
@@ -53,7 +53,7 @@
#include <climits>
#endif // WIN32
-#ifndef WIN32
+#ifndef _WIN32
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
@@ -148,7 +148,7 @@ void prepareFsPath(std::string &path)
std::string &fixDirSeparators(std::string &str)
{
-#ifdef WIN32
+#ifdef _WIN32
return replaceAll(str, "/", "\\");
#else
return str;
@@ -169,7 +169,7 @@ std::string removeLast(const std::string &str)
return str;
}
-#ifdef WIN32
+#ifdef _WIN32
std::string getSelfName()
{
return "manaplus.exe";
@@ -206,7 +206,7 @@ std::string getSelfName()
std::string getPicturesDir()
{
-#ifdef WIN32
+#ifdef _WIN32
std::string dir = getSpecialFolderLocation(CSIDL_MYPICTURES);
if (dir.empty())
dir = getSpecialFolderLocation(CSIDL_DESKTOP);
@@ -257,7 +257,7 @@ std::string getHomePath()
dir += dirSeparator;
return dir;
#else // defined(UNITTESTS) && defined(UNITESTSDIR)
-#ifdef WIN32
+#ifdef _WIN32
return getSpecialFolderLocation(CSIDL_LOCAL_APPDATA);
#elif defined(__SWITCH__)
return VirtFs::getBaseDir();
diff --git a/src/fs/specialfolder.cpp b/src/fs/specialfolder.cpp
index 807ea093b..2e03ed432 100644
--- a/src/fs/specialfolder.cpp
+++ b/src/fs/specialfolder.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef WIN32
+#ifdef _WIN32
#include "fs/specialfolder.h"
#include <windows.h>
diff --git a/src/fs/specialfolder.h b/src/fs/specialfolder.h
index 618a2d90d..a9f9bc898 100644
--- a/src/fs/specialfolder.h
+++ b/src/fs/specialfolder.h
@@ -23,7 +23,7 @@
#ifndef UTILS_SPECIALFOLDER_H
#define UTILS_SPECIALFOLDER_H
-#ifdef WIN32
+#ifdef _WIN32
#include <shlobj.h>
#include <string>
diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp
index 42b93188e..126b66537 100644
--- a/src/fs/virtfs/fs.cpp
+++ b/src/fs/virtfs/fs.cpp
@@ -64,7 +64,7 @@ namespace VirtFs
void updateDirSeparator()
{
-#ifdef WIN32
+#ifdef _WIN32
dirSeparator = "\\";
#else // WIN32
dirSeparator = "/";
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index 7832dcce6..cafd9a08f 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -18,6 +18,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef _WIN32
+ #include <windows.h> // for FILEHDEFAULT, FILEOPEN, FILEOPEN_FLAG_READ,
+ // FILEOPEN_FLAG_WRITE, FILEOPEN_FLAG_APPEND
+#else // _WIN32
+ #define _POSIX_C_SOURCE 200809L
+ #include <unistd.h> // for lstat()
+ #include <sys/stat.h> // for S_ISLNK
+#endif
#include "fs/virtfs/fsdir.h"
@@ -204,17 +212,32 @@ namespace FsDir
const std::string file = next_file->d_name;
if (file == "." || file == "..")
continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- struct stat statbuf;
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
+#if !defined(_WIN32)
+ if (mPermitLinks == false)
+ {
+ struct stat statbuf;
+ const std::string fullPath = path + file;
+ if (lstat(fullPath.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode))
+ {
+ continue;
+ }
+ }
+#else
+ if (mPermitLinks == false)
+ {
+ const std::string fullPath = path + file;
+ DWORD attrs = GetFileAttributesA(fullPath.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & FILE_ATTRIBUTE_REPARSE_POINT))
+ {
+ // It's a symlink or junction, skip it
+ continue;
+ }
+ }
+#endif // !_WIN32
+
+
bool found(false);
FOR_EACH (StringVectCIter, itn, names)
@@ -256,16 +279,25 @@ namespace FsDir
name.c_str())
return false;
}
-#ifndef WIN32
- if (mPermitLinks == false)
- return false;
+#if !defined(_WIN32)
+ if (mPermitLinks == false)
+ return false;
- struct stat statbuf;
- return lstat(name.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0;
+ struct stat statbuf;
+ return lstat(name.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode);
#else
+ if (mPermitLinks == false)
return false;
-#endif // WIN32
+
+ DWORD attrs = GetFileAttributesA(name.c_str());
+ if (attrs == INVALID_FILE_ATTRIBUTES)
+ return false;
+
+ return (attrs & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+#endif // !_WIN32
+
+
}
void freeList(List *restrict const handle)
@@ -549,16 +581,31 @@ namespace FsDir
const std::string file = next_file->d_name;
if (file == "." || file == "..")
continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
+#if !defined(_WIN32)
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace `file` with actual filename variable in context
+ struct stat statbuf;
+ if (lstat(fullPath.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode))
+ {
+ continue;
+ }
+ }
+#else
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace `file` with actual filename variable in context
+ DWORD attrs = GetFileAttributesA(fullPath.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & FILE_ATTRIBUTE_REPARSE_POINT))
+ {
+ continue;
+ }
+ }
+#endif // !_WIN32
+
+
const std::string filePath = pathJoin(path, file);
if (stat(filePath.c_str(), &statbuf) == 0)
@@ -599,16 +646,32 @@ namespace FsDir
const std::string file = next_file->d_name;
if (file == "." || file == "..")
continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
+#if !defined(_WIN32)
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace 'file' with the correct filename variable
+ struct stat statbuf;
+ if (lstat(fullPath.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode))
+ {
+ continue;
+ }
+ }
+#else
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace 'file' with the correct filename variable
+ DWORD attrs = GetFileAttributesA(fullPath.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & FILE_ATTRIBUTE_REPARSE_POINT))
+ {
+ continue;
+ }
+ }
+#endif // !_WIN32
+
+
+
const std::string filePath = pathJoin(path, file);
if (stat(filePath.c_str(), &statbuf) == 0)
@@ -649,16 +712,31 @@ namespace FsDir
const std::string file = next_file->d_name;
if (file == "." || file == "..")
continue;
-#ifndef WIN32
- if (mPermitLinks == false)
- {
- if (lstat(path.c_str(), &statbuf) == 0 &&
- S_ISLNK(statbuf.st_mode) != 0)
- {
- continue;
- }
- }
-#endif // WIN32
+#if !defined(_WIN32)
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace 'file' with actual filename variable
+ struct stat statbuf;
+ if (lstat(fullPath.c_str(), &statbuf) == 0 &&
+ S_ISLNK(statbuf.st_mode))
+ {
+ continue;
+ }
+ }
+#else
+ if (mPermitLinks == false)
+ {
+ std::string fullPath = path + file; // replace 'file' with actual filename variable
+ DWORD attrs = GetFileAttributesA(fullPath.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & FILE_ATTRIBUTE_REPARSE_POINT))
+ {
+ continue;
+ }
+ }
+#endif // !WIN32
+
+
const std::string filePath = pathJoin(path, file);
if (stat(filePath.c_str(), &statbuf) == 0)
diff --git a/src/game.cpp b/src/game.cpp
index bd90937f0..8713e7e56 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -147,7 +147,7 @@
#include "mumblemanager.h"
#endif // USE_MUMBLE
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#undef ERROR
#endif // WIN32
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 81d01496d..2c7ee502d 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -22,7 +22,7 @@
#include "graphicsmanager.h"
#ifdef USE_OPENGL
-#ifndef WIN32
+#ifndef _WIN32
#ifdef ANDROID
#include <GLES2/gl2.h>
@@ -682,7 +682,7 @@ void GraphicsManager::updatePlanformExtensions()
SDL_VERSION(&info.version)
if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
{
-#ifdef WIN32
+#ifdef _WIN32
if (!mwglGetExtensionsString)
return;
@@ -1398,7 +1398,7 @@ void GraphicsManager::initOpenGLFunctions()
logger->log1("shaders not supported");
}
-#ifdef WIN32
+#ifdef _WIN32
assignFunctionARB(wglGetExtensionsString)
#endif // WIN32
#endif // __native_client__
@@ -1670,7 +1670,7 @@ void GraphicsManager::detectPixelSize()
SDL_VERSION(&info.version)
if (SDL::getWindowWMInfo(mainGraphics->getWindow(), &info))
{
-#ifdef WIN32
+#ifdef _WIN32
#ifdef USE_SDL2
HDC hdc = GetDC(info.info.win.window);
#else
diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp
index 655ef0c2c..7d6739721 100644
--- a/src/gui/dialogsmanager.cpp
+++ b/src/gui/dialogsmanager.cpp
@@ -57,7 +57,7 @@
#include "debug.h"
-#ifdef WIN32
+#ifdef _WIN32
#undef ERROR
#endif // WIN32
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index c98a9416e..bdd01266d 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -1,200 +1,200 @@
-/*
- * The ManaVerse Client
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2025 The ManaVerse Developers
- *
- * This file is part of The ManaVerse Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "gui/palette.h"
-
-#include "utils/foreach.h"
-#include "utils/timer.h"
-
-#ifndef USE_SDL2
-#include <cmath>
-#endif // USE_SDL2
-
-#include "debug.h"
-
-const Color Palette::BLACK = Color(0, 0, 0, 255);
-Palette::Palettes Palette::mInstances;
-
-const Color Palette::RAINBOW_COLORS[7] =
-{
- Color(255, 0, 0, 255),
- Color(255, 153, 0, 255),
- Color(255, 255, 0, 255),
- Color(0, 153, 0, 255),
- Color(0, 204, 204, 255),
- Color(51, 0, 153, 255),
- Color(153, 0, 153, 255)
-};
-
-const int Palette::RAINBOW_COLOR_COUNT = 7;
-
-Palette::Palette(const int size) :
- mRainbowTime(tick_time),
- mColors(Colors(size)),
- mCharColors(),
- mGradVector()
-{
- mInstances.insert(this);
-}
-
-Palette::~Palette()
-{
- mInstances.erase(this);
-}
-
-const Color& Palette::getCharColor(const signed char c, bool &valid) const
-{
- const CharColors::const_iterator it = mCharColors.find(c);
- if (it != mCharColors.end())
- {
- valid = true;
- return mColors[(*it).second].color;
- }
-
- valid = false;
- return BLACK;
-}
-
-void Palette::advanceGradients()
-{
- FOR_EACH (Palettes::const_iterator, it, mInstances)
- (*it)->advanceGradient();
-}
-
-void Palette::advanceGradient()
-{
- const int time = get_elapsed_time(mRainbowTime);
- if (time > 5)
- {
- // For slower systems, advance can be greater than one (advance > 1
- // skips advance-1 steps). Should make gradient look the same
- // independent of the framerate.
- const int advance = time / 5;
-
- for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
- {
- ColorElem *const elem A_NONNULLPOINTER = mGradVector[i];
- if (elem == nullptr)
- continue;
-
- int delay = elem->delay;
- const GradientTypeT &grad = elem->grad;
-
- if (grad == GradientType::PULSE)
- delay = delay / 20;
-
- const int numOfColors = (elem->grad == GradientType::SPECTRUM ? 6 :
- grad == GradientType::PULSE ? 127 :
- RAINBOW_COLOR_COUNT);
-
- elem->gradientIndex = (elem->gradientIndex + advance)
- % (delay * numOfColors);
-
- const int gradIndex = elem->gradientIndex;
- const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
- int colIndex;
- if (delay != 0)
- colIndex = gradIndex / delay;
- else
- colIndex = gradIndex;
-
- Color &color = elem->color;
- int colVal;
-
- if (grad == GradientType::PULSE)
- {
- colVal = CAST_S32(255.0 *
- sin(M_PI * colIndex / numOfColors));
-
- const Color &col = elem->testColor;
-
- color.r = ((colVal * col.r) / 255) % (col.r + 1);
- color.g = ((colVal * col.g) / 255) % (col.g + 1);
- color.b = ((colVal * col.b) / 255) % (col.b + 1);
- }
- else if (grad == GradientType::SPECTRUM)
- {
- if ((colIndex % 2) != 0)
- { // falling curve
- if (delay != 0)
- {
- colVal = CAST_S32(255.0 *
- (cos(M_PI * pos / delay) + 1) / 2);
- }
- else
- {
- colVal = CAST_S32(255.0 *
- (cos(M_PI * pos) + 1) / 2);
- }
- }
- else
- { // ascending curve
- if (delay != 0)
- {
- colVal = CAST_S32(255.0 * (cos(M_PI *
- (delay - pos) / delay) + 1) / 2);
- }
- else
- {
- colVal = CAST_S32(255.0 * (cos(M_PI *
- (delay - pos)) + 1) / 2);
- }
- }
-
- color.r = (colIndex == 0 || colIndex == 5) ? 255 :
- (colIndex == 1 || colIndex == 4) ? colVal : 0;
- color.g = (colIndex == 1 || colIndex == 2) ? 255 :
- (colIndex == 0 || colIndex == 3) ? colVal : 0;
- color.b = (colIndex == 3 || colIndex == 4) ? 255 :
- (colIndex == 2 || colIndex == 5) ? colVal : 0;
- }
- else if (elem->grad == GradientType::RAINBOW)
- {
- const Color &startCol = RAINBOW_COLORS[colIndex];
- const Color &destCol
- = RAINBOW_COLORS[(colIndex + 1) % numOfColors];
- double startColVal;
- double destColVal;
-
- if (delay != 0)
- startColVal = (cos(M_PI * pos / delay) + 1) / 2;
- else
- startColVal = 0;
-
- destColVal = 1 - startColVal;
-
- color.r = CAST_S32(startColVal
- * startCol.r + destColVal * destCol.r);
-
- color.g = CAST_S32(startColVal
- * startCol.g + destColVal * destCol.g);
-
- color.b = CAST_S32(startColVal
- * startCol.b + destColVal * destCol.b);
- }
- }
-
- mRainbowTime = tick_time;
- }
-}
+/*
+ * The ManaVerse Client
+ * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2020 The ManaPlus Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
+ *
+ * This file is part of The ManaVerse Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/palette.h"
+
+#include "utils/foreach.h"
+#include "utils/timer.h"
+
+#ifndef USE_SDL2
+#include <cmath>
+#endif // USE_SDL2
+
+#include "debug.h"
+
+const Color Palette::BLACK = Color(0, 0, 0, 255);
+Palette::Palettes Palette::mInstances;
+
+const Color Palette::RAINBOW_COLORS[7] =
+{
+ Color(255, 0, 0, 255),
+ Color(255, 153, 0, 255),
+ Color(255, 255, 0, 255),
+ Color(0, 153, 0, 255),
+ Color(0, 204, 204, 255),
+ Color(51, 0, 153, 255),
+ Color(153, 0, 153, 255)
+};
+
+const int Palette::RAINBOW_COLOR_COUNT = 7;
+
+Palette::Palette(const int size) :
+ mRainbowTime(tick_time),
+ mColors(Colors(size)),
+ mCharColors(),
+ mGradVector()
+{
+ mInstances.insert(this);
+}
+
+Palette::~Palette()
+{
+ mInstances.erase(this);
+}
+
+const Color& Palette::getCharColor(const signed char c, bool &valid) const
+{
+ const CharColors::const_iterator it = mCharColors.find(c);
+ if (it != mCharColors.end())
+ {
+ valid = true;
+ return mColors[(*it).second].color;
+ }
+
+ valid = false;
+ return BLACK;
+}
+
+void Palette::advanceGradients()
+{
+ FOR_EACH (Palettes::const_iterator, it, mInstances)
+ (*it)->advanceGradient();
+}
+
+void Palette::advanceGradient()
+{
+ const int time = get_elapsed_time(mRainbowTime);
+ if (time > 5)
+ {
+ // For slower systems, advance can be greater than one (advance > 1
+ // skips advance-1 steps). Should make gradient look the same
+ // independent of the framerate.
+ const int advance = time / 5;
+
+ for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
+ {
+ ColorElem *const elem A_NONNULLPOINTER = mGradVector[i];
+ if (elem == nullptr)
+ continue;
+
+ int delay = elem->delay;
+ const GradientTypeT &grad = elem->grad;
+
+ if (grad == GradientType::PULSE)
+ delay = delay / 20;
+
+ const int numOfColors = (elem->grad == GradientType::SPECTRUM ? 6 :
+ grad == GradientType::PULSE ? 127 :
+ RAINBOW_COLOR_COUNT);
+
+ elem->gradientIndex = (elem->gradientIndex + advance)
+ % (delay * numOfColors);
+
+ const int gradIndex = elem->gradientIndex;
+ const int pos = delay != 0 ? (gradIndex % delay) : gradIndex;
+ int colIndex;
+ if (delay != 0)
+ colIndex = gradIndex / delay;
+ else
+ colIndex = gradIndex;
+
+ Color &color = elem->color;
+ int colVal;
+
+ if (grad == GradientType::PULSE)
+ {
+ colVal = CAST_S32(255.0 *
+ sin(M_PI * colIndex / numOfColors));
+
+ const Color &col = elem->testColor;
+
+ color.r = ((colVal * col.r) / 255) % (col.r + 1);
+ color.g = ((colVal * col.g) / 255) % (col.g + 1);
+ color.b = ((colVal * col.b) / 255) % (col.b + 1);
+ }
+ else if (grad == GradientType::SPECTRUM)
+ {
+ if ((colIndex % 2) != 0)
+ { // falling curve
+ if (delay != 0)
+ {
+ colVal = CAST_S32(255.0 *
+ (cos(M_PI * pos / delay) + 1) / 2);
+ }
+ else
+ {
+ colVal = CAST_S32(255.0 *
+ (cos(M_PI * pos) + 1) / 2);
+ }
+ }
+ else
+ { // ascending curve
+ if (delay != 0)
+ {
+ colVal = CAST_S32(255.0 * (cos(M_PI *
+ (delay - pos) / delay) + 1) / 2);
+ }
+ else
+ {
+ colVal = CAST_S32(255.0 * (cos(M_PI *
+ (delay - pos)) + 1) / 2);
+ }
+ }
+
+ color.r = (colIndex == 0 || colIndex == 5) ? 255 :
+ (colIndex == 1 || colIndex == 4) ? colVal : 0;
+ color.g = (colIndex == 1 || colIndex == 2) ? 255 :
+ (colIndex == 0 || colIndex == 3) ? colVal : 0;
+ color.b = (colIndex == 3 || colIndex == 4) ? 255 :
+ (colIndex == 2 || colIndex == 5) ? colVal : 0;
+ }
+ else if (elem->grad == GradientType::RAINBOW)
+ {
+ const Color &startCol = RAINBOW_COLORS[colIndex];
+ const Color &destCol
+ = RAINBOW_COLORS[(colIndex + 1) % numOfColors];
+ double startColVal;
+ double destColVal;
+
+ if (delay != 0)
+ startColVal = (cos(M_PI * pos / delay) + 1) / 2;
+ else
+ startColVal = 0;
+
+ destColVal = 1 - startColVal;
+
+ color.r = CAST_S32(startColVal
+ * startCol.r + destColVal * destCol.r);
+
+ color.g = CAST_S32(startColVal
+ * startCol.g + destColVal * destCol.g);
+
+ color.b = CAST_S32(startColVal
+ * startCol.b + destColVal * destCol.b);
+ }
+ }
+
+ mRainbowTime = tick_time;
+ }
+}
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index b1847cde1..b8a93ee3b 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -51,7 +51,7 @@
#include "utils/delete2.h"
#include "utils/gettext.h"
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#endif // WIN32
diff --git a/src/gui/widgets/tabs/setup_misc.cpp b/src/gui/widgets/tabs/setup_misc.cpp
index ea159e8cf..647a7828e 100644
--- a/src/gui/widgets/tabs/setup_misc.cpp
+++ b/src/gui/widgets/tabs/setup_misc.cpp
@@ -563,7 +563,7 @@ Setup_Misc::Setup_Misc(const Widget2 *const widget) :
MainConfig_true);
#endif // ANDROID
-#ifndef WIN32
+#ifndef _WIN32
// TRANSLATORS: settings option
new SetupItemTextField(_("Screenshot directory"), "",
"screenshotDirectory3", this, "screenshotDirectory3Event",
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index c980280e8..c46ec3a54 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -239,7 +239,7 @@ void Setup_Video::apply()
* See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode
*/
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
+#if defined(_WIN32) || defined(__APPLE__) || defined(ANDROID)
// checks for opengl usage
if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE)
{
@@ -267,7 +267,7 @@ void Setup_Video::apply()
logger->safeError(errorMsg.str());
}
}
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
+#if defined(_WIN32) || defined(__APPLE__) || defined(ANDROID)
}
else
{
@@ -415,7 +415,7 @@ void Setup_Video::action(const ActionEvent &event)
if (width != mainGraphics->mActualWidth
|| height != mainGraphics->mActualHeight)
{
-#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
+#if defined(_WIN32) || defined(__APPLE__) || defined(ANDROID)
if (intToRenderType(config.getIntValue("opengl"))
== RENDER_SOFTWARE)
{
diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp
index 7f0dcdae9..428d8af88 100644
--- a/src/gui/widgets/tabs/setup_visual.cpp
+++ b/src/gui/widgets/tabs/setup_visual.cpp
@@ -230,7 +230,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) :
"vsyncEvent", mVSyncList, 100,
MainConfig_true);
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || defined(__APPLE__)
// TRANSLATORS: settings option
new SetupItemCheckBox(_("Center game window"),
"", "centerwindow", this, "centerwindowEvent",
@@ -269,7 +269,7 @@ void Setup_Visual::apply()
{
SetupTabScroll::apply();
WindowManager::applyGrabMode();
-#ifndef WIN32
+#ifndef _WIN32
WindowManager::applyScale();
#endif // WIN32
}
diff --git a/src/gui/windowmanager.cpp b/src/gui/windowmanager.cpp
index a198efe8f..33de13eba 100644
--- a/src/gui/windowmanager.cpp
+++ b/src/gui/windowmanager.cpp
@@ -91,7 +91,7 @@ PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_image.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <SDL_syswm.h>
#endif // WIN32
PRAGMA48(GCC diagnostic pop)
@@ -419,7 +419,7 @@ void WindowManager::setIcon()
{
#if !defined(ANDROID) && !defined(__SWITCH__)
std::string iconFile = branding.getValue("appIcon", "icons/manaplus");
-#ifdef WIN32
+#ifdef _WIN32
iconFile.append(".ico");
#else // WIN32
@@ -429,7 +429,7 @@ void WindowManager::setIcon()
iconFile = VirtFs::getPath(iconFile);
logger->log("Loading icon from file: %s", iconFile.c_str());
-#ifdef WIN32
+#ifdef _WIN32
static SDL_SysWMinfo pInfo;
if (mainGraphics)
SDL::getWindowWMInfo(mainGraphics->getWindow(), &pInfo);
@@ -458,7 +458,7 @@ void WindowManager::setIcon()
if (icon)
{
-#ifdef WIN64
+#ifdef _WIN32
SetClassLongPtr(windowRef,
GCLP_HICON,
reinterpret_cast<LONG_PTR>(icon));
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 09a39b6ea..503703631 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -38,7 +38,7 @@
#include "utils/gettext.h"
#include "utils/performance.h"
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#endif // WIN32
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index b5be96164..d931c595c 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -53,7 +53,7 @@
#include "debug.h"
-#ifdef WIN32
+#ifdef _WIN32
#undef ERROR
#endif // WIN32
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 87a2b1894..9e124a9ec 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -471,7 +471,7 @@ void UpdaterWindow::loadPatch()
#if defined(ANDROID)
const std::string url = "androidDownloadUrl";
const std::string text = "androidDownloadUrl";
-#elif defined(WIN32)
+#elif defined(_WIN32)
const std::string url = "windowsDownloadUrl";
const std::string text = "windowsDownloadUrl";
#else // defined(ANDROID)
diff --git a/src/logger.cpp b/src/logger.cpp
index 7c37ecdf4..fb854aa81 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -33,7 +33,7 @@
#include <iostream>
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#elif defined __APPLE__
#include <Carbon/Carbon.h>
@@ -441,7 +441,7 @@ void Logger::safeError(const std::string &error_text)
error_text.c_str(),
nullptr);
#else // USE_SDL2
-#ifdef WIN32
+#ifdef _WIN32
MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
#elif defined __APPLE__
// Str255 msg;
@@ -478,7 +478,7 @@ void Logger::error(const std::string &error_text)
error_text.c_str(),
nullptr);
#else // USE_SDL2
-#ifdef WIN32
+#ifdef _WIN32
MessageBox(nullptr, error_text.c_str(), "Error", MB_ICONERROR | MB_OK);
#elif defined __APPLE__
// Str255 msg;
diff --git a/src/main.cpp b/src/main.cpp
index 58525134c..7a6b4ab62 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,7 +23,7 @@
#include "maingui.h"
-#ifdef WIN32
+#ifdef _WIN32
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL.h>
diff --git a/src/main.h b/src/main.h
index 4119c16f1..c55ad8433 100644
--- a/src/main.h
+++ b/src/main.h
@@ -120,7 +120,7 @@
#define PACKAGE_OS "GNU Hurd"
#elif defined __HAIKU__
#define PACKAGE_OS "Haiku"
-#elif defined WIN32 || defined _WIN32 || defined __WIN32__ || defined __NT__ \
+#elif defined _WIN32 || defined _WIN32 || defined __WIN32__ || defined __NT__ \
|| defined WIN64 || defined _WIN64 || defined __WIN64__ \
|| defined __MINGW32__ || defined _MSC_VER
#define PACKAGE_OS "Windows"
diff --git a/src/maingui.cpp b/src/maingui.cpp
index 56a1658c8..fd36f4705 100644
--- a/src/maingui.cpp
+++ b/src/maingui.cpp
@@ -171,7 +171,7 @@ int mainGui(int argc, char *argv[])
Mix_Init(MIX_INIT_OGG);
#endif // SDL_MIXER_VERSION_ATLEAST(1, 2, 11)
-#ifdef WIN32
+#ifdef _WIN32
SetCurrentDirectory(VirtFs::getBaseDir());
#endif // WIN32
diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp
index f24df7242..2fd9c5eb5 100644
--- a/src/mumblemanager.cpp
+++ b/src/mumblemanager.cpp
@@ -32,7 +32,7 @@ PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_syswm.h>
PRAGMA48(GCC diagnostic pop)
-#ifndef WIN32
+#ifndef _WIN32
#include <sys/mman.h>
#endif // WIN32
@@ -54,7 +54,7 @@ MumbleManager::~MumbleManager()
{
if (mLinkedMem)
{
-#ifdef WIN32
+#ifdef _WIN32
UnmapViewOfFile(mLinkedMem);
#elif defined BSD4_4
#else // WIN32
@@ -100,7 +100,7 @@ void MumbleManager::init()
return;
logger->log1("MumbleManager::init");
-#ifdef WIN32
+#ifdef _WIN32
HANDLE hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS,
FALSE, L"MumbleLink");
if (!hMapObject)
diff --git a/src/particle/particleemitterprop.h b/src/particle/particleemitterprop.h
index d82f188ac..c49667b31 100644
--- a/src/particle/particleemitterprop.h
+++ b/src/particle/particleemitterprop.h
@@ -1,128 +1,128 @@
-/*
- * The ManaVerse Client
- * Copyright (C) 2006-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2020 The ManaPlus Developers
- * Copyright (C) 2020-2025 The ManaVerse Developers
- *
- * This file is part of The ManaVerse Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef PARTICLE_PARTICLEEMITTERPROP_H
-#define PARTICLE_PARTICLEEMITTERPROP_H
-
-#include <cmath>
-
-#include "enums/particle/particlechangefunc.h"
-
-#include "localconsts.h"
-
-template <typename T> struct ParticleEmitterProp final
-{
- ParticleEmitterProp() :
- minVal(0),
- maxVal(0),
- changeFunc(ParticleChangeFunc::FUNC_NONE),
- changeAmplitude(0),
- changePeriod(0),
- changePhase(0)
- {
- }
-
- A_DEFAULT_COPY(ParticleEmitterProp)
-
- void set(const T min, const T max)
- {
- minVal = min;
- maxVal = max;
- }
-
- void set(const T val)
- {
- set(val, val);
- }
-
- void setFunction(ParticleChangeFuncT func,
- T amplitude,
- const int period,
- const int phase)
- {
- changeFunc = func;
- changeAmplitude = amplitude;
- changePeriod = period;
- if (changePeriod == 0)
- changePeriod = 1;
- changePhase = phase;
- }
-
- T value(int tick) const
- {
- tick += changePhase;
- T val = static_cast<T>(minVal + (maxVal - minVal)
- * (rand() / (static_cast<double>(RAND_MAX) + 1)));
-
- switch (changeFunc)
- {
- case ParticleChangeFunc::FUNC_SINE:
- val += static_cast<T>(std::sin(M_PI * 2 * (static_cast<double>(
- tick % changePeriod) / static_cast<double>(
- changePeriod)))) * changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_SAW:
- val += static_cast<T>(changeAmplitude * (static_cast<double>(
- tick % changePeriod) / static_cast<double>(
- changePeriod))) * 2 - changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_TRIANGLE:
- if ((tick % changePeriod) * 2 < changePeriod)
- {
- val += changeAmplitude - static_cast<T>((
- tick % changePeriod) / static_cast<double>(
- changePeriod)) * changeAmplitude * 4;
- }
- else
- {
- val += changeAmplitude * -3 + static_cast<T>((
- tick % changePeriod) / static_cast<double>(
- changePeriod)) * changeAmplitude * 4;
- // I have no idea why this works but it does
- }
- break;
- case ParticleChangeFunc::FUNC_SQUARE:
- if ((tick % changePeriod) * 2 < changePeriod)
- val += changeAmplitude;
- else
- val -= changeAmplitude;
- break;
- case ParticleChangeFunc::FUNC_NONE:
- default:
- // nothing
- break;
- }
-
- return val;
- }
-
- T minVal;
- T maxVal;
-
- ParticleChangeFuncT changeFunc;
- T changeAmplitude;
- int changePeriod;
- int changePhase;
-};
-
-#endif // PARTICLE_PARTICLEEMITTERPROP_H
+/*
+ * The ManaVerse Client
+ * Copyright (C) 2006-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2020 The ManaPlus Developers
+ * Copyright (C) 2020-2025 The ManaVerse Developers
+ *
+ * This file is part of The ManaVerse Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PARTICLE_PARTICLEEMITTERPROP_H
+#define PARTICLE_PARTICLEEMITTERPROP_H
+
+#include <cmath>
+
+#include "enums/particle/particlechangefunc.h"
+
+#include "localconsts.h"
+
+template <typename T> struct ParticleEmitterProp final
+{
+ ParticleEmitterProp() :
+ minVal(0),
+ maxVal(0),
+ changeFunc(ParticleChangeFunc::FUNC_NONE),
+ changeAmplitude(0),
+ changePeriod(0),
+ changePhase(0)
+ {
+ }
+
+ A_DEFAULT_COPY(ParticleEmitterProp)
+
+ void set(const T min, const T max)
+ {
+ minVal = min;
+ maxVal = max;
+ }
+
+ void set(const T val)
+ {
+ set(val, val);
+ }
+
+ void setFunction(ParticleChangeFuncT func,
+ T amplitude,
+ const int period,
+ const int phase)
+ {
+ changeFunc = func;
+ changeAmplitude = amplitude;
+ changePeriod = period;
+ if (changePeriod == 0)
+ changePeriod = 1;
+ changePhase = phase;
+ }
+
+ T value(int tick) const
+ {
+ tick += changePhase;
+ T val = static_cast<T>(minVal + (maxVal - minVal)
+ * (rand() / (static_cast<double>(RAND_MAX) + 1)));
+
+ switch (changeFunc)
+ {
+ case ParticleChangeFunc::FUNC_SINE:
+ val += static_cast<T>(std::sin(M_PI * 2 * (static_cast<double>(
+ tick % changePeriod) / static_cast<double>(
+ changePeriod)))) * changeAmplitude;
+ break;
+ case ParticleChangeFunc::FUNC_SAW:
+ val += static_cast<T>(changeAmplitude * (static_cast<double>(
+ tick % changePeriod) / static_cast<double>(
+ changePeriod))) * 2 - changeAmplitude;
+ break;
+ case ParticleChangeFunc::FUNC_TRIANGLE:
+ if ((tick % changePeriod) * 2 < changePeriod)
+ {
+ val += changeAmplitude - static_cast<T>((
+ tick % changePeriod) / static_cast<double>(
+ changePeriod)) * changeAmplitude * 4;
+ }
+ else
+ {
+ val += changeAmplitude * -3 + static_cast<T>((
+ tick % changePeriod) / static_cast<double>(
+ changePeriod)) * changeAmplitude * 4;
+ // I have no idea why this works but it does
+ }
+ break;
+ case ParticleChangeFunc::FUNC_SQUARE:
+ if ((tick % changePeriod) * 2 < changePeriod)
+ val += changeAmplitude;
+ else
+ val -= changeAmplitude;
+ break;
+ case ParticleChangeFunc::FUNC_NONE:
+ default:
+ // nothing
+ break;
+ }
+
+ return val;
+ }
+
+ T minVal;
+ T maxVal;
+
+ ParticleChangeFuncT changeFunc;
+ T changeAmplitude;
+ int changePeriod;
+ int changePhase;
+};
+
+#endif // PARTICLE_PARTICLEEMITTERPROP_H
diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp
index 40eaa71cd..7e57eb11a 100644
--- a/src/progs/dyecmd/client.cpp
+++ b/src/progs/dyecmd/client.cpp
@@ -79,7 +79,7 @@
#include "net/ipc.h"
-#ifdef WIN32
+#ifdef _WIN32
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_syswm.h>
@@ -261,7 +261,7 @@ void Client::gameInit()
eventsManager.init();
eventsManager.enableEvents();
-#ifdef WIN32
+#ifdef _WIN32
Dirs::mountDataDir();
#endif // WIN32
#ifndef USE_SDL2
@@ -287,7 +287,7 @@ void Client::gameInit()
SDL::allowScreenSaver(config.getBoolValue("allowscreensaver"));
initGraphics();
-#ifndef WIN32
+#ifndef _WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
#endif // WIN32
@@ -776,7 +776,7 @@ void Client::moveButtons(const int width)
{
int x = width - mSetupButton->getWidth() - mButtonPadding;
mSetupButton->setPosition(x, mButtonPadding);
-#ifndef WIN32
+#ifndef _WIN32
x -= mPerfomanceButton->getWidth() + mButtonSpacing;
mPerfomanceButton->setPosition(x, mButtonPadding);
diff --git a/src/progs/manaverse/client.cpp b/src/progs/manaverse/client.cpp
index 9430bcf5d..b6e129ba2 100644
--- a/src/progs/manaverse/client.cpp
+++ b/src/progs/manaverse/client.cpp
@@ -146,7 +146,7 @@
#include "configuration.h"
#endif // USE_OPENGL
-#ifdef WIN32
+#ifdef _WIN32
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_syswm.h>
@@ -393,7 +393,7 @@ void Client::gameInit()
eventsManager.init();
eventsManager.enableEvents();
-#ifdef WIN32
+#ifdef _WIN32
Dirs::mountDataDir();
#endif // WIN32
#ifndef USE_SDL2
@@ -425,7 +425,7 @@ void Client::gameInit()
touchManager.init();
-#ifndef WIN32
+#ifndef _WIN32
Dirs::extractDataDir();
Dirs::mountDataDir();
#endif // WIN32
@@ -1881,7 +1881,7 @@ void Client::moveButtons(const int width)
{
int x = width - mSetupButton->getWidth() - mButtonPadding;
mSetupButton->setPosition(x, mButtonPadding);
-#ifndef WIN32
+#ifndef _WIN32
x -= mPerfomanceButton->getWidth() + mButtonSpacing;
mPerfomanceButton->setPosition(x, mButtonPadding);
diff --git a/src/render/opengl/mgl.hpp b/src/render/opengl/mgl.hpp
index 9dce907a4..df678578b 100644
--- a/src/render/opengl/mgl.hpp
+++ b/src/render/opengl/mgl.hpp
@@ -140,6 +140,6 @@ defName(glTextureSubImage2D);
defName(glTextureSubImage2DEXT);
defName(glClearTexImage);
defName(glClearTexSubImage);
-#ifdef WIN32
+#ifdef _WIN32
defName(wglGetExtensionsString);
#endif
diff --git a/src/render/opengl/mglfunctions.h b/src/render/opengl/mglfunctions.h
index b583e3625..1e534271a 100644
--- a/src/render/opengl/mglfunctions.h
+++ b/src/render/opengl/mglfunctions.h
@@ -28,7 +28,7 @@
LOGGER_H
-#ifdef WIN32
+#ifdef _WIN32
#define getFunction(name) wglGetProcAddress(name)
#elif defined ANDROID
#define getFunction(name) eglGetProcAddress(name)
diff --git a/src/render/opengl/mgltypes.h b/src/render/opengl/mgltypes.h
index 2d8759796..10c5a0540 100644
--- a/src/render/opengl/mgltypes.h
+++ b/src/render/opengl/mgltypes.h
@@ -231,7 +231,7 @@ typedef void (APIENTRY *glDebugMessageCallback_t) (GLDEBUGPROC_t callback,
const void *userParam);
-#ifdef WIN32
+#ifdef _WIN32
typedef const char* (APIENTRY * wglGetExtensionsString_t) (HDC hdc);
#else // WIN32
#define CALLBACK
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 14dc07ae9..0f7509247 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -35,7 +35,7 @@
#include <algorithm>
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#else // WIN32
#include <ctime>
diff --git a/src/sdl2gfx/SDL2_rotozoom.cpp b/src/sdl2gfx/SDL2_rotozoom.cpp
index a37e1c51e..b016e6b03 100644
--- a/src/sdl2gfx/SDL2_rotozoom.cpp
+++ b/src/sdl2gfx/SDL2_rotozoom.cpp
@@ -29,7 +29,7 @@ Changed for ManaPlus (C) 2013-2017 ManaPlus developers
*/
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#endif
diff --git a/src/sdl2gfx/SDL2_rotozoom.h b/src/sdl2gfx/SDL2_rotozoom.h
index ffab24fbc..94c8cc96a 100644
--- a/src/sdl2gfx/SDL2_rotozoom.h
+++ b/src/sdl2gfx/SDL2_rotozoom.h
@@ -1,131 +1,131 @@
-/*
-
-SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
-
-Copyright (C) 2012-2014 Andreas Schiffler
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-claim that you wrote the original software. If you use this software
-in a product, an acknowledgment in the product documentation would be
-appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not be
-misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-distribution.
-
-Andreas Schiffler -- aschiffler at ferzkopp dot net
-
-Changed for ManaPlus (C) 2013-2017 ManaPlus developers
-
-*/
-
-#ifndef _SDL2_rotozoom_h
-#define _SDL2_rotozoom_h
-
-#include <math.h>
-
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifndef M_PI
-#define M_PI 3.1415926535897932384626433832795
-#endif
-
-#include "localconsts.h"
-
-PRAGMA48(GCC diagnostic push)
-PRAGMA48(GCC diagnostic ignored "-Wshadow")
-#include <SDL.h>
-PRAGMA48(GCC diagnostic pop)
-
- /* ---- Defines */
-
- /*!
- \brief Disable anti-aliasing (no smoothing).
- */
-#define SMOOTHING_OFF 0
-
- /*!
- \brief Enable anti-aliasing (smoothing).
- */
-#define SMOOTHING_ON 1
-
- /* ---- Function Prototypes */
-
-#ifdef _MSC_VER
-# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
-# define SDL2_ROTOZOOM_SCOPE __declspec(dllexport)
-# else
-# ifdef LIBSDL2_GFX_DLL_IMPORT
-# define SDL2_ROTOZOOM_SCOPE __declspec(dllimport)
-# endif
-# endif
-#endif
-#ifndef SDL2_ROTOZOOM_SCOPE
-# define SDL2_ROTOZOOM_SCOPE extern
-#endif
-
- /*
-
- Rotozoom functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
- (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
-
-
- SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
- int *dstheight);
-
- SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
- (int width, int height, double angle, double zoomx, double zoomy,
- int *dstwidth, int *dstheight);
-
- /*
-
- Zooming functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
-
- SDL2_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
-
- /*
-
- Shrinking functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
-
- /*
-
- Specialized rotation functions
-
- */
-
- SDL2_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
-
- /* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SDL2_rotozoom_h */
+/*
+
+SDL2_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
+
+Copyright (C) 2012-2014 Andreas Schiffler
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+claim that you wrote the original software. If you use this software
+in a product, an acknowledgment in the product documentation would be
+appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not be
+misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+
+Andreas Schiffler -- aschiffler at ferzkopp dot net
+
+Changed for ManaPlus (C) 2013-2017 ManaPlus developers
+
+*/
+
+#ifndef _SDL2_rotozoom_h
+#define _SDL2_rotozoom_h
+
+#include <math.h>
+
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifndef M_PI
+#define M_PI 3.1415926535897932384626433832795
+#endif
+
+#include "localconsts.h"
+
+PRAGMA48(GCC diagnostic push)
+PRAGMA48(GCC diagnostic ignored "-Wshadow")
+#include <SDL.h>
+PRAGMA48(GCC diagnostic pop)
+
+ /* ---- Defines */
+
+ /*!
+ \brief Disable anti-aliasing (no smoothing).
+ */
+#define SMOOTHING_OFF 0
+
+ /*!
+ \brief Enable anti-aliasing (smoothing).
+ */
+#define SMOOTHING_ON 1
+
+ /* ---- Function Prototypes */
+
+#ifdef _MSC_VER
+# if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
+# define SDL2_ROTOZOOM_SCOPE __declspec(dllexport)
+# else
+# ifdef LIBSDL2_GFX_DLL_IMPORT
+# define SDL2_ROTOZOOM_SCOPE __declspec(dllimport)
+# endif
+# endif
+#endif
+#ifndef SDL2_ROTOZOOM_SCOPE
+# define SDL2_ROTOZOOM_SCOPE extern
+#endif
+
+ /*
+
+ Rotozoom functions
+
+ */
+
+ SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
+
+ SDL2_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
+ (SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
+
+
+ SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
+ int *dstheight);
+
+ SDL2_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
+ (int width, int height, double angle, double zoomx, double zoomy,
+ int *dstwidth, int *dstheight);
+
+ /*
+
+ Zooming functions
+
+ */
+
+ SDL2_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
+
+ SDL2_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
+
+ /*
+
+ Shrinking functions
+
+ */
+
+ SDL2_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
+
+ /*
+
+ Specialized rotation functions
+
+ */
+
+ SDL2_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
+
+ /* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SDL2_rotozoom_h */
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index b4f67f373..c53484589 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -64,7 +64,7 @@ PRAGMA48(GCC diagnostic pop)
#include <unistd.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <windows.h>
#define sleep(seconds) Sleep((seconds) * 1000)
#endif // WIN32
diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h
index efb149439..df4dae8d4 100644
--- a/src/test/testlauncher.h
+++ b/src/test/testlauncher.h
@@ -26,7 +26,7 @@
#include <fstream>
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#endif // WIN32
diff --git a/src/unittests/fs/files.cc b/src/unittests/fs/files.cc
index 767c4b5e8..070805bf1 100644
--- a/src/unittests/fs/files.cc
+++ b/src/unittests/fs/files.cc
@@ -116,7 +116,7 @@ TEST_CASE("Files saveTextFile", "")
Files::saveTextFile(dir, "tempfile.txt", "test line\ntext line2");
std::string data = VirtFs::loadTextFileString("test/tempfile.txt");
::remove((dir + "/tempfile.txt").c_str());
-#ifdef WIN32
+#ifdef _WIN32
REQUIRE(data == "test line\r\ntext line2\r\n");
#else // WIN32
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 73e857da2..70eb1df7d 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -63,7 +63,7 @@ PRAGMA48(GCC diagnostic pop)
#include <unistd.h>
#elif defined __native_client__
#include "utils/naclmessages.h"
-#elif defined WIN32
+#elif defined _WIN32
#include "utils/cast.h"
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
@@ -94,7 +94,7 @@ bool sendBuffer(const std::string &restrict text)
#else // USE_SDL2
-#ifdef WIN32
+#ifdef _WIN32
bool retrieveBuffer(std::string& text, size_t& pos)
{
bool ret = false;
diff --git a/src/utils/env.cpp b/src/utils/env.cpp
index 10feebca7..97f31636b 100644
--- a/src/utils/env.cpp
+++ b/src/utils/env.cpp
@@ -29,14 +29,14 @@
void updateEnv()
{
-#if defined(WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || defined(__APPLE__)
if (config.getBoolValue("centerwindow"))
setEnv("SDL_VIDEO_CENTERED", "1");
else
setEnv("SDL_VIDEO_CENTERED", "0");
#endif // defined(WIN32) || defined(__APPLE__)
-#ifndef WIN32
+#ifndef _WIN32
const int vsync = settings.options.test.empty()
? config.getIntValue("vsync") : 1;
// __GL_SYNC_TO_VBLANK is nvidia variable.
@@ -61,7 +61,7 @@ void setEnv(const char *const name, const char *const value)
{
if ((name == nullptr) || (value == nullptr))
return;
-#ifdef WIN32
+#if defined(_WIN32) || defined(__MSYS__)
if (putenv(const_cast<char*>((std::string(name)
+ "=" + value).c_str())))
#else // WIN32
diff --git a/src/utils/gettexthelper.cpp b/src/utils/gettexthelper.cpp
index 0069b0bfd..3d8de880c 100644
--- a/src/utils/gettexthelper.cpp
+++ b/src/utils/gettexthelper.cpp
@@ -34,9 +34,9 @@
#include <libintl.h>
#include <locale.h>
-#ifdef WIN32
+#ifdef _WIN32
#include <string>
-extern "C" char const *_nl_locale_name_default(void);
+//extern "C" char const *_nl_locale_name_default(void);
#endif // WIN32
#elif defined(ENABLE_CUSTOMNLS)
#include "utils/translation/podict.h"
@@ -45,7 +45,7 @@ extern "C" char const *_nl_locale_name_default(void);
#endif // __native_client__
#endif // ENABLE_NLS
-#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
+#if defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(_WIN32)
#include "utils/env.h"
#endif // defined(ENABLE_NLS) || defined(ENABLE_CUSTOMNLS) && !defined(WIN32)
@@ -55,9 +55,10 @@ extern "C" char const *_nl_locale_name_default(void);
static std::string setLangEnv()
{
std::string lang = config.getStringValue("lang");
-#if defined(ENABLE_NLS) && defined(WIN32)
+#if defined(ENABLE_NLS) && defined(_WIN32)
if (lang.empty())
- lang = std::string(_nl_locale_name_default());
+ lang = std::string(setlocale(LC_MESSAGES, ""));
+
#elif defined(ENABLE_CUSTOMNLS) && defined(__native_client__)
if (lang.empty())
{
@@ -70,7 +71,7 @@ static std::string setLangEnv()
if (!lang.empty())
{
-#ifdef WIN32
+#ifdef _WIN32
putenv(const_cast<char*>(("LANG=" + lang).c_str()));
putenv(const_cast<char*>(("LANGUAGE=" + lang).c_str()));
#else // WIN32
@@ -88,7 +89,7 @@ void GettextHelper::initLang()
{
#ifdef ENABLE_NLS
const std::string lang = setLangEnv();
-#ifdef WIN32
+#ifdef _WIN32
// mingw doesn't like LOCALEDIR to be defined for some reason
if (lang != "C")
bindTextDomain("translations/");
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index 11cdf1c53..2e27247a4 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -25,6 +25,7 @@
#include "localconsts.h"
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#ifdef USE_SDL2
@@ -36,17 +37,19 @@ PRAGMA48(GCC diagnostic pop)
#include "debug.h"
-#if defined(WIN32) || defined(__linux__) || \
+#if defined(_WIN32) || defined(__linux__) || \
defined(__linux) || defined(__APPLE__)
const int timeOut = 10;
#endif // defined(WIN32) || defined(__linux__) ||
// defined(__linux) || defined(__APPLE__)
-#ifdef WIN32
+#ifdef _WIN32
#include "utils/stringutils.h"
#include <windows.h>
+#include <shellapi.h> // For ShellExecute
+#include <cstdint> // For std::intptr_t
int execFileWait(const std::string &pathName, const std::string &name A_UNUSED,
const std::string &arg1, const std::string &arg2,
@@ -257,7 +260,11 @@ bool openBrowser(std::string url)
#elif defined WIN32
bool openBrowser(std::string url)
{
- return reinterpret_cast<int32_t>(ShellExecute(nullptr, "open",
+ return reinterpret_cast<std::intptr_t>(ShellExecute(nullptr, "open",
+ // Remove spaces from the URL to avoid issues with ShellExecute
+ // interpreting the URL incorrectly.
+ // This is a workaround for the issue where spaces in URLs can cause
+ // ShellExecute to fail.
replaceAll(url, " ", "").c_str(),
nullptr, nullptr, SW_SHOWNORMAL)) > 32;
}
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index cc9e830b8..3382e2a1a 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -38,7 +38,7 @@
#include <algorithm>
#include <sstream>
-#ifdef WIN32
+#ifdef _WIN32
#include <sys/time.h>
#endif // WIN32
@@ -1027,7 +1027,7 @@ std::string escapeString(std::string str)
void sanitizePath(std::string &path)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sepStr = '\\';
const std::string sep2Str = "\\\\";
const std::string sepWrongStr = "/";
@@ -1043,7 +1043,7 @@ void sanitizePath(std::string &path)
std::string pathJoin(std::string str1,
const std::string &str2)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sep = '\\';
std::string sepStr = "\\";
#else
@@ -1082,7 +1082,7 @@ std::string pathJoin(std::string str1,
const std::string &str2,
const std::string &str3)
{
-#ifdef WIN32
+#ifdef _WIN32
const char sep = '\\';
std::string sepStr = "\\";
#else
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
index 9bff3f877..ee25ba6c6 100644
--- a/src/utils/xml/libxml.cpp
+++ b/src/utils/xml/libxml.cpp
@@ -35,6 +35,11 @@
#include "utils/translation/podict.h"
#include <fstream>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlreader.h>
+#include <libxml/xmlerror.h>
+
#include "debug.h"