diff --git a/CMakeLists.txt b/CMakeLists.txt index 32958558a..e5c45d5db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,23 +9,20 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_EXTENSIONS OFF) # Warnings -add_compile_options(-Wall) +add_compile_options(-Wall -Wignored-qualifiers -Wvariadic-macros) +add_compile_options($<$:-Wc++11-extensions>) if(WERROR) add_compile_options(-Werror) endif() +if(APPLE) + add_compile_options(-Wno-deprecated-declarations) +endif() # Detect Windows include(CheckSymbolExists) check_symbol_exists("_WIN32" "" REMCPE_WIN32) -# Clang -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-Wno-inconsistent-missing-override) -endif() -if(APPLE) - add_compile_options(-Wno-deprecated-declarations) -endif() - +# Windows Linking if(REMCPE_WIN32) # Modern MinGW doesn't support C++98 and will error if you try to use it set(CMAKE_CXX_STANDARD 11) diff --git a/compat/KeyCodes.hpp b/compat/KeyCodes.hpp index 4b3756309..158ae2e5f 100644 --- a/compat/KeyCodes.hpp +++ b/compat/KeyCodes.hpp @@ -17,8 +17,10 @@ enum eSDLVirtualKeys { #define CODE(x) SDLVK_ ## x, + #define _CODE(x) SDLVK_ ## x #include "SDLKeyCodes.h" #undef CODE + #undef _CODE }; #endif diff --git a/compat/LegacyCPP_Compat.hpp b/compat/LegacyCPP_Compat.hpp index 4df9f87f4..daad9a04e 100644 --- a/compat/LegacyCPP_Compat.hpp +++ b/compat/LegacyCPP_Compat.hpp @@ -4,6 +4,7 @@ #ifdef USE_OLD_CPP +#define CONSTEXPR #ifndef constexpr #define constexpr const #endif @@ -37,6 +38,8 @@ namespace std #endif // !defined(_WIN32)*/ +#else +#define CONSTEXPR constexpr #endif // USE_OLD_CPP // https://gcc.gnu.org/legacy-ml/gcc-help/2006-04/msg00062.html diff --git a/compat/SDLKeyCodes.h b/compat/SDLKeyCodes.h index c8aef200b..e46338a9f 100644 --- a/compat/SDLKeyCodes.h +++ b/compat/SDLKeyCodes.h @@ -1,4 +1,3 @@ -CODE(UNKNOWN) CODE(RETURN) CODE(ESCAPE) CODE(BACKSPACE) @@ -247,4 +246,5 @@ CODE(AUDIOREWIND) #endif #ifdef SDLK_AUDIOFASTFORWARD CODE(AUDIOFASTFORWARD) -#endif \ No newline at end of file +#endif +_CODE(UNKNOWN) diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index a2a16a457..575d8f656 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -117,7 +117,7 @@ std::string AppPlatform_android::getDateString(int time) return std::string(buffer); } -SoundSystem* const AppPlatform_android::getSoundSystem() const +SoundSystem* AppPlatform_android::getSoundSystem() const { return m_pSoundSystem; } diff --git a/platforms/android/AppPlatform_android.hpp b/platforms/android/AppPlatform_android.hpp index 4d58dd137..59a98c08a 100644 --- a/platforms/android/AppPlatform_android.hpp +++ b/platforms/android/AppPlatform_android.hpp @@ -46,7 +46,7 @@ class AppPlatform_android : public AppPlatform bool hasFileSystemAccess() override; - SoundSystem* const getSoundSystem() const override; + SoundSystem* getSoundSystem() const override; void initSoundSystem() override; bool isTouchscreen() const override; diff --git a/platforms/android/android_native_app_glue.h b/platforms/android/android_native_app_glue.h index 1b390c2d4..e2ec941f2 100644 --- a/platforms/android/android_native_app_glue.h +++ b/platforms/android/android_native_app_glue.h @@ -206,7 +206,7 @@ enum { /** * Start of user-defined ALooper identifiers. */ - LOOPER_ID_USER = 3, + LOOPER_ID_USER = 3 }; enum { @@ -308,7 +308,7 @@ enum { * Command from main thread: the app's activity is being destroyed, * and waiting for the app thread to clean up and exit before proceeding. */ - APP_CMD_DESTROY, + APP_CMD_DESTROY }; /** diff --git a/platforms/ios/AppPlatform_iOS.h b/platforms/ios/AppPlatform_iOS.h index 45cf6fa62..e1fc5376b 100644 --- a/platforms/ios/AppPlatform_iOS.h +++ b/platforms/ios/AppPlatform_iOS.h @@ -38,7 +38,7 @@ class AppPlatform_iOS : public AppPlatform bool isTouchscreen() const override; std::string getAssetPath(const std::string& path) const override; std::string getPatchData() override; - SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + SoundSystem* getSoundSystem() const override { return m_pSoundSystem; } // Also add these to allow proper text input within the game. bool shiftPressed() override; diff --git a/platforms/sdl/base/AppPlatform_sdl.cpp b/platforms/sdl/base/AppPlatform_sdl.cpp index e243d07af..bb335e951 100644 --- a/platforms/sdl/base/AppPlatform_sdl.cpp +++ b/platforms/sdl/base/AppPlatform_sdl.cpp @@ -442,8 +442,10 @@ int AppPlatform_sdl::_TranslateSDLKeyCodeToVirtual(int sdlCode) { switch (sdlCode) { #define CODE(x) case SDLK_ ## x: return SDLVK_ ## x; +#define _CODE(x) CODE(x) #include "compat/SDLKeyCodes.h" #undef CODE +#undef _CODE } return SDLVK_UNKNOWN; } diff --git a/platforms/sdl/base/AppPlatform_sdl.hpp b/platforms/sdl/base/AppPlatform_sdl.hpp index 3f17abcfd..66c3df7cc 100644 --- a/platforms/sdl/base/AppPlatform_sdl.hpp +++ b/platforms/sdl/base/AppPlatform_sdl.hpp @@ -38,7 +38,7 @@ class AppPlatform_sdl : public AppPlatform int getUserInputStatus() override; void saveScreenshot(const std::string& fileName, int width, int height) override; bool doesTextureExist(const std::string& path) const override; - SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + SoundSystem* getSoundSystem() const override { return m_pSoundSystem; } // Also add these to allow proper turning within the game. void setMouseGrabbed(bool b) override; diff --git a/platforms/sound/opensl/SoundSystemSL.cpp b/platforms/sound/opensl/SoundSystemSL.cpp index ac0451b1d..2fa6c54ce 100644 --- a/platforms/sound/opensl/SoundSystemSL.cpp +++ b/platforms/sound/opensl/SoundSystemSL.cpp @@ -91,7 +91,7 @@ void SoundSystemSL::removeStoppedSounds() toRemove.clear(); pthread_mutex_unlock(&toRemoveMutex); - for (int i = 0; i < m_tempToRemove.size(); i++) + for (size_t i = 0; i < m_tempToRemove.size(); i++) { for (SLSoundList::iterator it = m_playingSounds.begin(); diff --git a/platforms/windows/AppPlatform_win32.hpp b/platforms/windows/AppPlatform_win32.hpp index 45e550149..bc5d612e3 100644 --- a/platforms/windows/AppPlatform_win32.hpp +++ b/platforms/windows/AppPlatform_win32.hpp @@ -63,8 +63,8 @@ class AppPlatform_win32 : public AppPlatform AssetFile readAssetFile(const std::string&, bool) const override; void setScreenSize(int width, int height); - const char* const getWindowTitle() const { return m_WindowTitle; } - SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; } + const char* getWindowTitle() const { return m_WindowTitle; } + SoundSystem* getSoundSystem() const override { return m_pSoundSystem; } HWND createWindow(HINSTANCE hInstance, WNDPROC wndProc, LPVOID lpParam, WORD iconId); void initializeWindow(HWND hWnd, int nCmdShow); diff --git a/source/client/app/AppPlatform.cpp b/source/client/app/AppPlatform.cpp index b061ea22b..bfd21d360 100644 --- a/source/client/app/AppPlatform.cpp +++ b/source/client/app/AppPlatform.cpp @@ -18,7 +18,7 @@ AppPlatform* AppPlatform::m_singleton = nullptr; -AppPlatform* const AppPlatform::singleton() +AppPlatform* AppPlatform::singleton() { return m_singleton; } @@ -377,7 +377,7 @@ void AppPlatform::initSoundSystem() { } -SoundSystem* const AppPlatform::getSoundSystem() const +SoundSystem* AppPlatform::getSoundSystem() const { return nullptr; } diff --git a/source/client/app/AppPlatform.hpp b/source/client/app/AppPlatform.hpp index b7eb54a13..67298c362 100644 --- a/source/client/app/AppPlatform.hpp +++ b/source/client/app/AppPlatform.hpp @@ -48,13 +48,13 @@ class AppPlatform DLG_CREATE_WORLD, DLG_CHAT, DLG_OPTIONS, - DLG_RENAME_MP_WORLD, + DLG_RENAME_MP_WORLD }; private: static AppPlatform* m_singleton; public: - static AppPlatform* const singleton(); + static AppPlatform* singleton(); public: AppPlatform(); @@ -120,7 +120,7 @@ class AppPlatform // Also add this to allow dynamic patching. virtual std::string getPatchData(); virtual void initSoundSystem(); - virtual SoundSystem* const getSoundSystem() const; + virtual SoundSystem* getSoundSystem() const; // Used For Sounds virtual std::string getAssetPath(const std::string& path) const; virtual AssetFile readAssetFile(const std::string& path, bool quiet) const; diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index 9b9309018..02d9a7c31 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -337,7 +337,7 @@ void OptionList::initMultiplayerMenu() OPTION(Boolean, m_bServerVisibleDefault, "Local Server Multiplayer"); -#ifdef __EMSCRIPTEN +#ifndef FEATURE_NETWORKING m_items[currentIndex]->setDisabled(true); #endif (void)currentIndex; // compiler will warn about an unused variable sometimes if this isn't here diff --git a/source/client/gui/components/OptionList.hpp b/source/client/gui/components/OptionList.hpp index 13bd2c748..3d309fc63 100644 --- a/source/client/gui/components/OptionList.hpp +++ b/source/client/gui/components/OptionList.hpp @@ -53,7 +53,7 @@ class DistanceOptionItem : public OptionItem RD_FAR, RD_NORMAL, RD_SHORT, - RD_COUNT, + RD_COUNT }; public: diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index a6cea0761..39728a45f 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -21,10 +21,8 @@ #if defined(ORIGINAL_CODE) || defined(VERBOSE_CLIENT) #define puts_ignorable(str) LOG_I(str) -#define printf_ignorable(str, ...) LOG_I(str, __VA_ARGS__) #else #define puts_ignorable(str) -#define printf_ignorable(str, ...) #endif ClientSideNetworkHandler::ClientSideNetworkHandler(Minecraft* pMinecraft, RakNetInstance* pRakNetInstance) @@ -60,7 +58,7 @@ void ClientSideNetworkHandler::onConnect(const RakNet::RakNetGUID& rakGuid) // s { #ifdef VERBOSE_CLIENT RakNet::RakNetGUID localGuid = ((RakNet::RakPeer*)m_pServerPeer)->GetMyGUID(); - printf_ignorable("onConnect, server guid: %s, local guid: %s", rakGuid.ToString(), localGuid.ToString()); + LOG_I("onConnect, server guid: %s, local guid: %s", rakGuid.ToString(), localGuid.ToString()); #endif m_serverGUID = rakGuid; diff --git a/source/client/options/Options.hpp b/source/client/options/Options.hpp index 7dfe9fbcf..f75885951 100644 --- a/source/client/options/Options.hpp +++ b/source/client/options/Options.hpp @@ -50,7 +50,7 @@ enum eKeyMappingIndex KM_FLY_UP, KM_FLY_DOWN, KM_CHAT_CMD, // called "Open Chat" in Release 1.8 - KM_COUNT, + KM_COUNT }; struct KeyMapping diff --git a/source/client/player/input/IMoveInput.hpp b/source/client/player/input/IMoveInput.hpp index c5d63584e..1292c6213 100644 --- a/source/client/player/input/IMoveInput.hpp +++ b/source/client/player/input/IMoveInput.hpp @@ -21,7 +21,7 @@ enum INPUT_JUMP, INPUT_SNEAK, INPUT_FORWARDLEFT, - INPUT_FORWARDRIGHT, + INPUT_FORWARDRIGHT }; class IMoveInput diff --git a/source/client/player/input/MouseDevice.hpp b/source/client/player/input/MouseDevice.hpp index 65a533fbf..e271726cb 100644 --- a/source/client/player/input/MouseDevice.hpp +++ b/source/client/player/input/MouseDevice.hpp @@ -18,7 +18,7 @@ enum MouseButtonType BUTTON_MIDDLE, BUTTON_COUNT, BUTTON_SCROLLWHEEL, - BUTTON_MIN = BUTTON_LEFT, + BUTTON_MIN = BUTTON_LEFT }; struct MouseAction diff --git a/source/client/renderer/PatchManager.hpp b/source/client/renderer/PatchManager.hpp index 5eb750ca6..72854e0b4 100644 --- a/source/client/renderer/PatchManager.hpp +++ b/source/client/renderer/PatchManager.hpp @@ -13,13 +13,13 @@ enum ePatchType TYPE_TERRAIN, TYPE_ITEMS, TYPE_FRAME, - TYPE_FEATURE, + TYPE_FEATURE }; enum ePatchOption { PO_NONE, - PO_GRASS_TINT, + PO_GRASS_TINT }; struct PatchData diff --git a/source/client/renderer/TileRenderer.cpp b/source/client/renderer/TileRenderer.cpp index b5e34ca7e..5b104ad4d 100644 --- a/source/client/renderer/TileRenderer.cpp +++ b/source/client/renderer/TileRenderer.cpp @@ -2791,7 +2791,7 @@ bool TileRenderer::tesselateBlockInWorldWithAmbienceOcclusionV2(Tile* tile, cons ETILE_FACE_DNE,// -Y+X-Z ETILE_FACE_DSW,// -Y-X+Z ETILE_FACE_DSE,// -Y+X+Z - ETILE_FACE_COUNT, + ETILE_FACE_COUNT }; // for Facing::Name directions diff --git a/source/client/renderer/texture/ColorSpace.hpp b/source/client/renderer/texture/ColorSpace.hpp index 1e2b4fb20..afb1cd040 100644 --- a/source/client/renderer/texture/ColorSpace.hpp +++ b/source/client/renderer/texture/ColorSpace.hpp @@ -3,5 +3,5 @@ enum ColorSpace { COLOR_SPACE_RGBA, - COLOR_SPACE_RGB, + COLOR_SPACE_RGB }; diff --git a/source/client/sound/SoundData.cpp b/source/client/sound/SoundData.cpp index 12efebe2f..0b4664b30 100644 --- a/source/client/sound/SoundData.cpp +++ b/source/client/sound/SoundData.cpp @@ -107,20 +107,26 @@ void SoundDesc::_unload() // Load All Sounds void SoundDesc::_loadAll(const AppPlatform* platform) { -#define SOUND(category, name, number) SA_##name##number._load(platform, #category, #name#number); +#define SOUND(category, name) SA_##name._load(platform, #category, #name); +#define SOUND_NUM(category, name, number) SA_##name##number._load(platform, #category, #name#number); #include "sound_list.h" #undef SOUND +#undef SOUND_NUM } // Un-load All Sounds void SoundDesc::_unloadAll() { -#define SOUND(category, name, number) SA_##name##number._unload(); +#define SOUND(category, name) SA_##name._unload(); +#define SOUND_NUM(category, name, number) SA_##name##number._unload(); #include "sound_list.h" #undef SOUND +#undef SOUND_NUM } // Declare Variables -#define SOUND(category, name, number) SoundDesc SA_##name##number; +#define SOUND(category, name) SoundDesc SA_##name; +#define SOUND_NUM(category, name, number) SoundDesc SA_##name##number; #include "sound_list.h" #undef SOUND +#undef SOUND_NUM diff --git a/source/client/sound/SoundData.hpp b/source/client/sound/SoundData.hpp index e2b458aa4..a91356c33 100644 --- a/source/client/sound/SoundData.hpp +++ b/source/client/sound/SoundData.hpp @@ -64,6 +64,8 @@ struct SoundDesc : AudioDescriptor static void _unloadAll(); }; -#define SOUND(category, name, number) extern SoundDesc SA_##name##number; +#define SOUND(category, name) extern SoundDesc SA_##name; +#define SOUND_NUM(category, name, number) extern SoundDesc SA_##name##number; #include "sound_list.h" #undef SOUND +#undef SOUND_NUM diff --git a/source/client/sound/SoundEngine.cpp b/source/client/sound/SoundEngine.cpp index 335ba066c..4d3ea5c3d 100644 --- a/source/client/sound/SoundEngine.cpp +++ b/source/client/sound/SoundEngine.cpp @@ -39,9 +39,11 @@ void SoundEngine::init(Options* options, AppPlatform* platform) // Load Sounds SoundDesc::_loadAll(platform); -#define SOUND(category, name, number) m_sounds.add(#category "." #name, SA_##name##number); +#define SOUND(category, name) m_sounds.add(#category "." #name, SA_##name); +#define SOUND_NUM(category, name, number) m_sounds.add(#category "." #name, SA_##name##number); #include "sound_list.h" #undef SOUND +#undef SOUND_NUM #define MUSIC(name, number) m_songs.add(#name, platform->getAssetPath("music/" #name #number ".ogg")); #define NEWMUSIC(name, number) m_songs.add(#name, platform->getAssetPath("newmusic/" #name #number ".ogg")); diff --git a/source/client/sound/sound_list.h b/source/client/sound/sound_list.h index df43af453..e2399de6e 100644 --- a/source/client/sound/sound_list.h +++ b/source/client/sound/sound_list.h @@ -1,98 +1,98 @@ -SOUND(step, cloth, 1) -SOUND(step, cloth, 2) -SOUND(step, cloth, 3) -SOUND(step, cloth, 4) - -SOUND(step, grass, 1) -SOUND(step, grass, 2) -SOUND(step, grass, 3) -SOUND(step, grass, 4) - -SOUND(step, gravel, 1) -SOUND(step, gravel, 2) -SOUND(step, gravel, 3) -SOUND(step, gravel, 4) - -SOUND(step, sand, 1) -SOUND(step, sand, 2) -SOUND(step, sand, 3) -SOUND(step, sand, 4) - -SOUND(step, stone, 1) -SOUND(step, stone, 2) -SOUND(step, stone, 3) -SOUND(step, stone, 4) - -SOUND(step, wood, 1) -SOUND(step, wood, 2) -SOUND(step, wood, 3) -SOUND(step, wood, 4) - -SOUND(random, bow, ) -SOUND(random, click, ) -SOUND(random, door_close, ) -SOUND(random, door_open, ) -SOUND(random, drr, ) -SOUND(random, explode, ) -SOUND(random, fizz, ) -SOUND(random, fuse, ) -SOUND(random, hurt, ) -SOUND(random, pop, ) -SOUND(random, splash, ) - -SOUND(fire, fire, ) - -SOUND(damage, fallbig, 1) -SOUND(damage, fallbig, 2) - -SOUND(damage, fallsmall, ) - -SOUND(mob, chicken, 2) -SOUND(mob, chicken, 3) -SOUND(mob, chickenhurt, 1) -SOUND(mob, chickenhurt, 2) - -SOUND(mob, cow, 1) -SOUND(mob, cow, 2) -SOUND(mob, cow, 3) -SOUND(mob, cow, 4) -SOUND(mob, cowhurt, 1) -SOUND(mob, cowhurt, 2) -SOUND(mob, cowhurt, 3) - -SOUND(mob, creeper, 1) -SOUND(mob, creeper, 2) -SOUND(mob, creeper, 3) -SOUND(mob, creeper, 4) -SOUND(mob, creeperdeath, ) - -SOUND(mob, pig, 1) -SOUND(mob, pig, 2) -SOUND(mob, pig, 3) -SOUND(mob, pigdeath, ) - -SOUND(mob, sheep, 1) -SOUND(mob, sheep, 2) -SOUND(mob, sheep, 3) - -SOUND(mob, skeleton, 1) -SOUND(mob, skeleton, 2) -SOUND(mob, skeleton, 3) -SOUND(mob, skeletonhurt, 1) -SOUND(mob, skeletonhurt, 2) -SOUND(mob, skeletonhurt, 3) -SOUND(mob, skeletonhurt, 4) -SOUND(mob, skeletondeath, ) - -SOUND(mob, spider, 1) -SOUND(mob, spider, 2) -SOUND(mob, spider, 3) -SOUND(mob, spider, 4) -SOUND(mob, spiderdeath, ) - -SOUND(mob, zombie, 1) -SOUND(mob, zombie, 2) -SOUND(mob, zombie, 3) -SOUND(mob, zombiehurt, 1) -SOUND(mob, zombiehurt, 2) -SOUND(mob, zombiedeath, ) +SOUND_NUM(step, cloth, 1) +SOUND_NUM(step, cloth, 2) +SOUND_NUM(step, cloth, 3) +SOUND_NUM(step, cloth, 4) + +SOUND_NUM(step, grass, 1) +SOUND_NUM(step, grass, 2) +SOUND_NUM(step, grass, 3) +SOUND_NUM(step, grass, 4) + +SOUND_NUM(step, gravel, 1) +SOUND_NUM(step, gravel, 2) +SOUND_NUM(step, gravel, 3) +SOUND_NUM(step, gravel, 4) + +SOUND_NUM(step, sand, 1) +SOUND_NUM(step, sand, 2) +SOUND_NUM(step, sand, 3) +SOUND_NUM(step, sand, 4) + +SOUND_NUM(step, stone, 1) +SOUND_NUM(step, stone, 2) +SOUND_NUM(step, stone, 3) +SOUND_NUM(step, stone, 4) + +SOUND_NUM(step, wood, 1) +SOUND_NUM(step, wood, 2) +SOUND_NUM(step, wood, 3) +SOUND_NUM(step, wood, 4) + +SOUND(random, bow) +SOUND(random, click) +SOUND(random, door_close) +SOUND(random, door_open) +SOUND(random, drr) +SOUND(random, explode) +SOUND(random, fizz) +SOUND(random, fuse) +SOUND(random, hurt) +SOUND(random, pop) +SOUND(random, splash) + +SOUND(fire, fire) + +SOUND_NUM(damage, fallbig, 1) +SOUND_NUM(damage, fallbig, 2) + +SOUND(damage, fallsmall) + +SOUND_NUM(mob, chicken, 2) +SOUND_NUM(mob, chicken, 3) +SOUND_NUM(mob, chickenhurt, 1) +SOUND_NUM(mob, chickenhurt, 2) + +SOUND_NUM(mob, cow, 1) +SOUND_NUM(mob, cow, 2) +SOUND_NUM(mob, cow, 3) +SOUND_NUM(mob, cow, 4) +SOUND_NUM(mob, cowhurt, 1) +SOUND_NUM(mob, cowhurt, 2) +SOUND_NUM(mob, cowhurt, 3) + +SOUND_NUM(mob, creeper, 1) +SOUND_NUM(mob, creeper, 2) +SOUND_NUM(mob, creeper, 3) +SOUND_NUM(mob, creeper, 4) +SOUND(mob, creeperdeath) + +SOUND_NUM(mob, pig, 1) +SOUND_NUM(mob, pig, 2) +SOUND_NUM(mob, pig, 3) +SOUND(mob, pigdeath) + +SOUND_NUM(mob, sheep, 1) +SOUND_NUM(mob, sheep, 2) +SOUND_NUM(mob, sheep, 3) + +SOUND_NUM(mob, skeleton, 1) +SOUND_NUM(mob, skeleton, 2) +SOUND_NUM(mob, skeleton, 3) +SOUND_NUM(mob, skeletonhurt, 1) +SOUND_NUM(mob, skeletonhurt, 2) +SOUND_NUM(mob, skeletonhurt, 3) +SOUND_NUM(mob, skeletonhurt, 4) +SOUND(mob, skeletondeath) + +SOUND_NUM(mob, spider, 1) +SOUND_NUM(mob, spider, 2) +SOUND_NUM(mob, spider, 3) +SOUND_NUM(mob, spider, 4) +SOUND(mob, spiderdeath) + +SOUND_NUM(mob, zombie, 1) +SOUND_NUM(mob, zombie, 2) +SOUND_NUM(mob, zombie, 3) +SOUND_NUM(mob, zombiehurt, 1) +SOUND_NUM(mob, zombiehurt, 2) +SOUND(mob, zombiedeath) diff --git a/source/common/Logger.cpp b/source/common/Logger.cpp index e9688aa89..a98c4559f 100644 --- a/source/common/Logger.cpp +++ b/source/common/Logger.cpp @@ -7,7 +7,7 @@ Logger* Logger::m_singleton = nullptr; -Logger* const Logger::singleton() +Logger* Logger::singleton() { return m_singleton; } @@ -69,4 +69,4 @@ void Logger::printf(eLogLevel ll, const char* const fmt, ...) vprintf(ll, fmt, argList); va_end(argList); -} \ No newline at end of file +} diff --git a/source/common/Logger.hpp b/source/common/Logger.hpp index 7ab2e5863..e891cdfd1 100644 --- a/source/common/Logger.hpp +++ b/source/common/Logger.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #ifdef ANDROID #include @@ -9,14 +10,14 @@ enum eLogLevel { LOG_INFO = ANDROID_LOG_INFO, LOG_WARN = ANDROID_LOG_WARN, - LOG_ERR = ANDROID_LOG_ERROR, + LOG_ERR = ANDROID_LOG_ERROR }; #else enum eLogLevel { LOG_INFO, LOG_WARN, - LOG_ERR, + LOG_ERR }; #endif @@ -25,7 +26,7 @@ class Logger private: static Logger* m_singleton; public: - static Logger* const singleton(); + static Logger* singleton(); static void setSingleton(Logger*); virtual ~Logger(); @@ -39,22 +40,61 @@ class Logger #ifndef NDEBUG +static inline void mc_vlog(enum eLogLevel loglevel, const char *fmt, va_list ap) +{ #ifdef ANDROID -// TODO: Add a LoggerAndroid -#define LOG(level, ...) __android_log_print(level, "ReMinecraftPE", __VA_ARGS__) + // TODO: Add a LoggerAndroid + __android_log_vprint(loglevel, "ReMinecraftPE", fmt, ap); #else -#define LOG(level, ...) Logger::singleton()->printf(level, __VA_ARGS__) + Logger::singleton()->vprintf(loglevel, fmt, ap); #endif +} + +static inline void mc_log(enum eLogLevel loglevel, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + mc_vlog(loglevel, fmt, ap); + va_end(ap); +} + +static inline void mc_log_info(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + mc_vlog(LOG_INFO, fmt, ap); + va_end(ap); +} -#define LOG_I(...) LOG(LOG_INFO, __VA_ARGS__) -#define LOG_W(...) LOG(LOG_WARN, __VA_ARGS__) -#define LOG_E(...) LOG(LOG_ERR, __VA_ARGS__) +static inline void mc_log_warn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + mc_vlog(LOG_WARN, fmt, ap); + va_end(ap); +} + +static inline void mc_log_err(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + mc_vlog(LOG_ERR, fmt, ap); + va_end(ap); +} + +#define LOG mc_log +#define LOG_I mc_log_info +#define LOG_W mc_log_warn +#define LOG_E mc_log_err #else -#define LOG(...) ((void)0) -#define LOG_I(...) ((void)0) -#define LOG_W(...) ((void)0) -#define LOG_E(...) ((void)0) +static inline void mc_log(enum eLogLevel loglevel, const char *fmt, ...) {} +static inline void mc_log_nothing(const char *fmt, ...) {} + +#define LOG if (0) mc_log +#define LOG_I if (0) mc_log_nothing +#define LOG_W if (0) mc_log_nothing +#define LOG_E if (0) mc_log_nothing #endif diff --git a/source/common/Mth.hpp b/source/common/Mth.hpp index d0e3bc15c..07dbcd580 100644 --- a/source/common/Mth.hpp +++ b/source/common/Mth.hpp @@ -44,7 +44,7 @@ class Mth return sqrtf(f); } - static inline constexpr float Lerp(float a, float b, float progress) + static inline CONSTEXPR float Lerp(float a, float b, float progress) { return a + progress * (b - a); } diff --git a/source/common/Utils.hpp b/source/common/Utils.hpp index a50a13eae..f230c02b7 100644 --- a/source/common/Utils.hpp +++ b/source/common/Utils.hpp @@ -360,7 +360,7 @@ enum eTileID // Custom items ITEM_ROCKET = 470, - ITEM_QUIVER = 484, + ITEM_QUIVER = 484 }; enum // Textures @@ -507,7 +507,7 @@ enum // Textures TEXTURE_INFO_UPDATEGAME1 = 252, TEXTURE_INFO_UPDATEGAME2 = 253, - TEXTURE_LAVA_PLACEHOLDER = 255, + TEXTURE_LAVA_PLACEHOLDER = 255 }; enum eRenderShape diff --git a/source/network/Packet.hpp b/source/network/Packet.hpp index ec7321280..7a45b57b4 100644 --- a/source/network/Packet.hpp +++ b/source/network/Packet.hpp @@ -61,7 +61,7 @@ enum ePacketType PACKET_SET_ENTITY_DATA, PACKET_SET_HEALTH, PACKET_ANIMATE, - PACKET_RESPAWN, + PACKET_RESPAWN #else PACKET_LOGIN = ID_USER_PACKET_ENUM, PACKET_LOGIN_STATUS, @@ -94,7 +94,7 @@ enum ePacketType PACKET_ANIMATE, PACKET_RESPAWN, - PACKET_LEVEL_DATA = 200, + PACKET_LEVEL_DATA = 200 #endif }; diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index da7b4a4c7..2c1cad9b8 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -16,12 +16,6 @@ //#define LOG_PACKETS -#ifdef LOG_PACKETS -#define LOG_PACKET(str, ...) LOG_I(str, __VA_ARGS__) -#else -#define LOG_PACKET(str, ...) -#endif - RakNetInstance::RakNetInstance() { m_bIsHost = false; @@ -145,7 +139,9 @@ void RakNetInstance::runEvents(NetEventCallback& callback) RakNet::BitStream* pBitStream = new RakNet::BitStream(pPacket->data + 1, pPacket->length - 1, 0); - LOG_PACKET("Recieved packet from %s (id: %d bitStream: 0x%x length: %u)", pPacket->systemAddress.ToString(), packetType, pBitStream, pPacket->length); +#ifdef LOG_PACKETS + LOG_I("Recieved packet from %s (id: %d bitStream: 0x%x length: %u)", pPacket->systemAddress.ToString(), packetType, pBitStream, pPacket->length); +#endif // @NOTE: why -1? if (packetType >= PACKET_LOGIN - 1) @@ -154,7 +150,9 @@ void RakNetInstance::runEvents(NetEventCallback& callback) if (pUserPacket) { pUserPacket->read(*pBitStream); - //LOG_PACKET("Packet: %d", packetType); +// #ifdef LOG_PACKETS +// LOG_I("Packet: %d", packetType); +// #endif pUserPacket->handle(pPacket->guid, callback); delete pUserPacket; } @@ -282,7 +280,7 @@ void RakNetInstance::send(Packet* packet) #ifdef LOG_PACKETS uint8_t packetId; bs.Read(packetId); - LOG_PACKET("Sent packet (id: %d guid: %s)", packetId, m_bIsHost ? "UNASSIGNED_SYSTEM_ADDRESS" : m_guid.ToString()); + LOG_I("Sent packet (id: %d guid: %s)", packetId, m_bIsHost ? "UNASSIGNED_SYSTEM_ADDRESS" : m_guid.ToString()); #endif } else diff --git a/source/renderer/hal/base/ConstantBufferConstantsBase.cpp b/source/renderer/hal/base/ConstantBufferConstantsBase.cpp index 05ee5fcc9..0017040ca 100644 --- a/source/renderer/hal/base/ConstantBufferConstantsBase.cpp +++ b/source/renderer/hal/base/ConstantBufferConstantsBase.cpp @@ -6,7 +6,7 @@ using namespace mce; ConstantBufferConstantsBase::ConstantBufferConstantsBase() { m_constantBuffer = nullptr; -}; +} void ConstantBufferConstantsBase::sync() { diff --git a/source/renderer/hal/ogl/API_OGL.hpp b/source/renderer/hal/ogl/API_OGL.hpp index 8781f4ba8..184eb1652 100644 --- a/source/renderer/hal/ogl/API_OGL.hpp +++ b/source/renderer/hal/ogl/API_OGL.hpp @@ -17,7 +17,7 @@ namespace gl GLES_2_0, GLES_3_0, GLES_3_1, - GLES_3_2, + GLES_3_2 }; private: diff --git a/source/server/ServerSideNetworkHandler.cpp b/source/server/ServerSideNetworkHandler.cpp index 1e17336a7..8fcd8a12e 100644 --- a/source/server/ServerSideNetworkHandler.cpp +++ b/source/server/ServerSideNetworkHandler.cpp @@ -22,10 +22,11 @@ #if defined(ORIGINAL_CODE) || defined(VERBOSE_SERVER) #define puts_ignorable(str) LOG_I(str) -#define printf_ignorable(str, ...) LOG_I(str, __VA_ARGS__) +#define printf_ignorable LOG_I #else +static inline void _do_nothing(...) {} #define puts_ignorable(str) -#define printf_ignorable(str, ...) +#define printf_ignorable _do_nothing #endif ServerSideNetworkHandler::ServerSideNetworkHandler(Minecraft* minecraft, RakNetInstance* rakNetInstance) diff --git a/source/world/Facing.hpp b/source/world/Facing.hpp index bb02d9bee..e3fe240b8 100644 --- a/source/world/Facing.hpp +++ b/source/world/Facing.hpp @@ -10,6 +10,6 @@ class Facing NORTH, // -Z SOUTH, // +Z WEST, // -X - EAST, // +X + EAST // +X }; }; \ No newline at end of file diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index 904d6ece1..707bed065 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -102,7 +102,7 @@ class Entity RENDER_ARROW, // custom - RENDER_FALLING_TILE = 50, + RENDER_FALLING_TILE = 50 }; private: diff --git a/source/world/entity/EntityType.hpp b/source/world/entity/EntityType.hpp index 1be1d3493..a2cdc2a03 100644 --- a/source/world/entity/EntityType.hpp +++ b/source/world/entity/EntityType.hpp @@ -153,7 +153,7 @@ class EntityType TRADER_LLAMA = 157, - CHEST_BOAT = 218, + CHEST_BOAT = 218 }; typedef const std::string& Name; diff --git a/source/world/item/Item.cpp b/source/world/item/Item.cpp index d43c77f98..15e8f7944 100644 --- a/source/world/item/Item.cpp +++ b/source/world/item/Item.cpp @@ -19,7 +19,7 @@ #define ITEM(x) ((x) - 256) #define NEW_ITEM(id) (new Item(ITEM(id))) -#define NEW_X_ITEM(Type, id, ...) (new Type(ITEM(id), __VA_ARGS__)) +#define NEW_X_ITEM(Type, id, arg) (new Type(ITEM(id), arg)) #define NEW_X_ITEMN(Type, id) (new Type(ITEM(id))) static bool g_bInittedItems = false; diff --git a/source/world/item/ItemInstance.cpp b/source/world/item/ItemInstance.cpp index a75bc30dc..6c0a02e5c 100644 --- a/source/world/item/ItemInstance.cpp +++ b/source/world/item/ItemInstance.cpp @@ -24,6 +24,7 @@ void ItemInstance::_init(int id, int count, int auxValue) m_auxValue = auxValue; m_userData = nullptr; m_popTime = 0; + m_bValid = false; _setItem(id); } @@ -546,4 +547,4 @@ bool ItemInstance::operator!=(const ItemInstance& other) const ItemInstance::operator bool() const { return m_bValid && getItem() && !isNull(); -} \ No newline at end of file +} diff --git a/source/world/item/ItemInstance.hpp b/source/world/item/ItemInstance.hpp index 08c1723e1..16bb9ecb9 100644 --- a/source/world/item/ItemInstance.hpp +++ b/source/world/item/ItemInstance.hpp @@ -120,7 +120,7 @@ class ItemInstance private: int16_t m_auxValue; CompoundTag* m_userData; - Item* m_pItem; // @TODO: replace m_itemID with Item pointer + Item* m_pItem; Tile* m_pTile; bool m_bValid; }; diff --git a/source/world/level/TileChange.hpp b/source/world/level/TileChange.hpp index 5fe61f41a..5aed859e9 100644 --- a/source/world/level/TileChange.hpp +++ b/source/world/level/TileChange.hpp @@ -11,7 +11,7 @@ class TileChange UPDATE_LISTENERS = 1 << 1, // 0 1 0 // UPDATE_SILENT = 1 << 2, // 1 0 0 // - UPDATE_ALL = UPDATE_NEIGHBORS | UPDATE_LISTENERS, // the default behavior + UPDATE_ALL = UPDATE_NEIGHBORS | UPDATE_LISTENERS // the default behavior }; public: diff --git a/source/world/level/levelgen/chunk/LevelChunk.cpp b/source/world/level/levelgen/chunk/LevelChunk.cpp index 41eca9548..17e684cae 100644 --- a/source/world/level/levelgen/chunk/LevelChunk.cpp +++ b/source/world/level/levelgen/chunk/LevelChunk.cpp @@ -19,12 +19,12 @@ LevelChunk::~LevelChunk() SAFE_DELETE_ARRAY(m_tileData.m_data); } -constexpr int MakeBlockDataIndex(const ChunkTilePos& pos) +CONSTEXPR int MakeBlockDataIndex(const ChunkTilePos& pos) { return (pos.x << 11) | (pos.z << 7) | pos.y; } -constexpr int MakeHeightMapIndex(const ChunkTilePos& pos) +CONSTEXPR int MakeHeightMapIndex(const ChunkTilePos& pos) { return pos.x | (pos.z * 16); } diff --git a/source/world/level/path/PathFinder.cpp b/source/world/level/path/PathFinder.cpp index 449a9e26d..1a25b4a08 100644 --- a/source/world/level/path/PathFinder.cpp +++ b/source/world/level/path/PathFinder.cpp @@ -13,7 +13,7 @@ static int dword_1CD868; static int dword_1CD870; -constexpr int MakeNodeHash(const TilePos& pos) +CONSTEXPR int MakeNodeHash(const TilePos& pos) { // NOTE: Same as in Java Edition Beta 1.3_01 return (pos.y & 0xFF) | diff --git a/source/world/particle/Particle.hpp b/source/world/particle/Particle.hpp index cc3ccbd25..95eaf68c6 100644 --- a/source/world/particle/Particle.hpp +++ b/source/world/particle/Particle.hpp @@ -16,14 +16,14 @@ enum eParticleTexture PT_PARTICLES, PT_TERRAIN, PT_PARTICLES2, - PT_PARTICLES3, + PT_PARTICLES3 }; enum eParticleTextureIndex { PTI_BUBBLE = 32, PTI_FLAME = 48, - PTI_LAVA, + PTI_LAVA }; class Particle : public Entity diff --git a/source/world/phys/HitResult.hpp b/source/world/phys/HitResult.hpp index 53891d627..ccd824c87 100644 --- a/source/world/phys/HitResult.hpp +++ b/source/world/phys/HitResult.hpp @@ -22,7 +22,7 @@ class HitResult { TILE, ENTITY, - NONE, + NONE }; private: diff --git a/thirdparty/raknet/DS_BPlusTree.h b/thirdparty/raknet/DS_BPlusTree.h index 6f83a4f64..be5e27615 100644 --- a/thirdparty/raknet/DS_BPlusTree.h +++ b/thirdparty/raknet/DS_BPlusTree.h @@ -81,7 +81,7 @@ namespace DataStructures NO_ACTION, REPLACE_KEY1_WITH_KEY2, PUSH_KEY_TO_PARENT, - SET_BRANCH_KEY, + SET_BRANCH_KEY } action; // 0=none, 1=replace key1 with key2 }; diff --git a/thirdparty/raknet/MessageIdentifiers.h b/thirdparty/raknet/MessageIdentifiers.h index 46510438e..101d2f5de 100644 --- a/thirdparty/raknet/MessageIdentifiers.h +++ b/thirdparty/raknet/MessageIdentifiers.h @@ -33,7 +33,7 @@ enum OutOfBandIdentifiers ID_XBOX_360_GET_NETWORK_ROOM, ID_XBOX_360_RETURN_NETWORK_ROOM, ID_NAT_PING, - ID_NAT_PONG, + ID_NAT_PONG }; /// You should not edit the file MessageIdentifiers.h as it is a part of RakNet static library diff --git a/thirdparty/raknet/RakNetSocket2.h b/thirdparty/raknet/RakNetSocket2.h index 817068db7..9ce18353d 100644 --- a/thirdparty/raknet/RakNetSocket2.h +++ b/thirdparty/raknet/RakNetSocket2.h @@ -47,7 +47,7 @@ enum RNS2BindResult BR_SUCCESS, BR_REQUIRES_RAKNET_SUPPORT_IPV6_DEFINE, BR_FAILED_TO_BIND_SOCKET, - BR_FAILED_SEND_TEST, + BR_FAILED_SEND_TEST }; typedef int RNS2SendResult; diff --git a/thirdparty/raknet/RakPeer.h b/thirdparty/raknet/RakPeer.h index 742b99b43..69c40846d 100644 --- a/thirdparty/raknet/RakPeer.h +++ b/thirdparty/raknet/RakPeer.h @@ -844,7 +844,7 @@ class RAK_DLL_EXPORT RakPeer : public RakPeerInterface, public RNS2EventHandler RakNet::TimeMS timeoutTime; PublicKeyMode publicKeyMode; RakNetSocket2* socket; - enum {CONNECT=1, /*PING=2, PING_OPEN_CONNECTIONS=4,*/ /*ADVERTISE_SYSTEM=2*/} actionToTake; + enum {CONNECT=1 /*PING=2, PING_OPEN_CONNECTIONS=4,*/ /*ADVERTISE_SYSTEM=2*/} actionToTake; #if LIBCAT_SECURITY==1 char handshakeChallenge[cat::EasyHandshake::CHALLENGE_BYTES]; diff --git a/thirdparty/raknet/ReliabilityLayer.h b/thirdparty/raknet/ReliabilityLayer.h index e4f99ea78..7e2d4cb71 100644 --- a/thirdparty/raknet/ReliabilityLayer.h +++ b/thirdparty/raknet/ReliabilityLayer.h @@ -491,7 +491,7 @@ class ReliabilityLayer// // If Update::maxBitsPerSecond > 0, then throughputCapCountdown is used as a timer to prevent sends for some amount of time after each send, depending on // the amount of data sent - long long throughputCapCountdown; + int64_t throughputCapCountdown; unsigned receivePacketCount;