From afa9fd3d8f7f5b632f6a0b01799ba7a866e894e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Fri, 15 Oct 2021 17:04:04 +0200 Subject: [PATCH] Remove precompiled headers, fix a few problems they masked --- meson.build | 5 +- pch/pch_cpp.h | 99 ---------------------------------- src/Update.cpp | 12 ++--- src/client/GameSave.cpp | 1 + src/common/Platform.cpp | 7 +-- src/common/Platform.h | 2 +- src/graphics/FontReader.cpp | 2 + src/lua/LuaScriptInterface.cpp | 2 +- 8 files changed, 17 insertions(+), 113 deletions(-) delete mode 100644 pch/pch_cpp.h diff --git a/meson.build b/meson.build index d89799d65..4ca178546 100644 --- a/meson.build +++ b/meson.build @@ -148,6 +148,8 @@ if copt_msvc args_msvc = [ '/GS', '-D_SCL_SECURE_NO_WARNINGS', + '-DUNICODE', + '-D_UNICODE', ] if copt_64bit message('SSE explicitly configured but unavailable in msvc targeting 64-bit machines') @@ -300,7 +302,6 @@ if get_option('build_powder') include_directories: [ project_inc, powder_inc ], c_args: project_c_args, cpp_args: project_cpp_args, - cpp_pch: 'pch/pch_cpp.h', gui_app: true, link_args: project_link_args, dependencies: powder_deps, @@ -318,7 +319,6 @@ if get_option('build_render') include_directories: [ project_inc, render_inc ], c_args: project_c_args, cpp_args: project_cpp_args, - cpp_pch: 'pch/pch_cpp.h', link_args: project_link_args, dependencies: render_deps, ) @@ -339,7 +339,6 @@ if get_option('build_font') include_directories: [ project_inc, font_inc ], c_args: project_c_args, cpp_args: project_cpp_args, - cpp_pch: 'pch/pch_cpp.h', gui_app: true, link_args: project_link_args, dependencies: font_deps, diff --git a/pch/pch_cpp.h b/pch/pch_cpp.h deleted file mode 100644 index 0618335b0..000000000 --- a/pch/pch_cpp.h +++ /dev/null @@ -1,99 +0,0 @@ -#include "Config.h" - -#include "common/Format.h" -#include "common/Singleton.h" -#include "common/String.h" -#include "common/tpt-compat.h" -#include "common/tpt-inline.h" -#include "common/tpt-minmax.h" -#include "common/tpt-rand.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef WIN -# include -# include -# include -# include -# include -# include -# include -#endif - -#ifdef WIN -# include -# include -# include -# include -#endif - -#ifdef GRAVFFT -#include -#endif - -#ifndef NOHTTP -#include -#endif - -#include -#include -#include -#include - -#if !defined(FONTEDITOR) && !defined(RENDERER) && defined(LUACONSOLE) -# include "lua/LuaCompat.h" -#endif -#include "SDLCompat.h" diff --git a/src/Update.cpp b/src/Update.cpp index 50ef666d8..ce656de0d 100644 --- a/src/Update.cpp +++ b/src/Update.cpp @@ -41,7 +41,7 @@ int update_start(char *data, unsigned int len) updName = exeName.substr(0, exeName.length() - 4); updName = updName + "_upd.exe"; - if (!MoveFile(exeName.c_str(), updName.c_str())) + if (!MoveFile(Platform::WinWiden(exeName).c_str(), Platform::WinWiden(updName).c_str())) return 1; f = fopen(exeName.c_str(), "wb"); @@ -50,14 +50,14 @@ int update_start(char *data, unsigned int len) if (fwrite(data, 1, len, f) != len) { fclose(f); - DeleteFile(exeName.c_str()); + Platform::RemoveFile(exeName); return 1; } fclose(f); - if ((uintptr_t)ShellExecute(NULL, "open", exeName.c_str(), NULL, NULL, SW_SHOWNORMAL) <= 32) + if ((uintptr_t)ShellExecute(NULL, L"open", Platform::WinWiden(exeName).c_str(), NULL, NULL, SW_SHOWNORMAL) <= 32) { - DeleteFile(exeName.c_str()); + Platform::RemoveFile(exeName); return 1; } @@ -114,7 +114,7 @@ int update_finish() printf("Update: Temp EXE name: %s\n", updName.c_str()); #endif - while (!DeleteFile(updName.c_str())) + while (!Platform::RemoveFile(updName)) { err = GetLastError(); if (err == ERROR_FILE_NOT_FOUND) @@ -128,7 +128,7 @@ int update_finish() if (extension == ".exe") updName = exeName.substr(0, exeName.length() - 4); updName = updName + "_update.exe"; - DeleteFile(updName.c_str()); + Platform::RemoveFile(updName); return 0; } Sleep(500); diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index a24d1418d..336c83e7d 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -16,6 +16,7 @@ #include "simulation/ElementClasses.h" #include "common/tpt-minmax.h" +#include "common/tpt-compat.h" GameSave::GameSave(const GameSave & save): majorVersion(save.majorVersion), diff --git a/src/common/Platform.cpp b/src/common/Platform.cpp index d3415619e..f9cad6a41 100644 --- a/src/common/Platform.cpp +++ b/src/common/Platform.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #else #include @@ -259,7 +260,7 @@ bool DirectoryExists(ByteString directory) } } -bool DeleteFile(ByteString filename) +bool RemoveFile(ByteString filename) { return std::remove(filename.c_str()) == 0; } @@ -442,13 +443,13 @@ String DoMigration(ByteString fromDir, ByteString toDir) result << '\n' << filename.FromUtf8() << " skipped (already exists)"; } - if (!DeleteFile(fromDir + filename)) { + if (!RemoveFile(fromDir + filename)) { logFile << "failed to delete " << filename << std::endl; } }; // Do actual migration - DeleteFile(fromDir + "stamps/stamps.def"); + RemoveFile(fromDir + "stamps/stamps.def"); migrateList(stamps, "stamps", "Stamps"); migrateList(saves, "Saves", "Saves"); if (!scripts.empty()) diff --git a/src/common/Platform.h b/src/common/Platform.h index 6cc41c6c0..90bf3759a 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -27,7 +27,7 @@ namespace Platform /** * @return true on success */ - bool DeleteFile(ByteString filename); + bool RemoveFile(ByteString filename); /** * @return true on success diff --git a/src/graphics/FontReader.cpp b/src/graphics/FontReader.cpp index 83421eefb..ff09eb751 100644 --- a/src/graphics/FontReader.cpp +++ b/src/graphics/FontReader.cpp @@ -3,6 +3,8 @@ #include "bzip2/bz2wrap.h" #include "font.bz2.h" +#include + unsigned char *font_data = nullptr; unsigned int *font_ptrs = nullptr; unsigned int (*font_ranges)[2] = nullptr; diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index a11c74f2c..9bd20b090 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -3697,7 +3697,7 @@ int LuaScriptInterface::fileSystem_removeFile(lua_State * l) { const char * filename = luaL_checkstring(l, 1); - bool ret = Platform::DeleteFile(filename); + bool ret = Platform::RemoveFile(filename); lua_pushboolean(l, ret); return 1; }