diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bfb43c639..704a4c414 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: sudo apt-get update sudo apt-get install --no-install-recommends -y cmake ninja-build - name: Build - run: ./build-wasm.sh + run: ./build-wasm.sh -DWERROR=ON macos: strategy: fail-fast: false diff --git a/CMakeLists.txt b/CMakeLists.txt index 760657cd6..05b04e162 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ endif() set(CXX_EXTENSIONS OFF) # Warnings +add_compile_options(-Wall) if(WERROR) add_compile_options(-Werror) endif() @@ -93,3 +94,4 @@ endif() # Disable warnings on third party libraries target_compile_options(stb_vorbis PRIVATE -w) target_compile_options(stb_image PRIVATE -w) +target_compile_options(raknet PRIVATE -w) diff --git a/build-wasm.sh b/build-wasm.sh index ab4c2b703..638906693 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -31,7 +31,7 @@ mkdir -p build cd build # Configure Build -emcmake cmake -GNinja -DWERROR=ON "$@" ../../ +emcmake cmake -GNinja "$@" ../../ # Build cmake --build . diff --git a/compat/KeyCodes.hpp b/compat/KeyCodes.hpp index 125e38b4f..709de9ecc 100644 --- a/compat/KeyCodes.hpp +++ b/compat/KeyCodes.hpp @@ -23,7 +23,7 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include -#elif __APPLE__ +#elif defined(__APPLE__) && !defined(USE_SDL) // https://i.stack.imgur.com/LD8pT.png #define AKEYCODE_FORWARD_DEL 0x75 #define AKEYCODE_ARROW_LEFT 0x7B @@ -37,4 +37,4 @@ #define AKEYCODE_ARROW_LEFT AKEYCODE_DPAD_LEFT #define AKEYCODE_ARROW_RIGHT AKEYCODE_DPAD_RIGHT -#endif \ No newline at end of file +#endif diff --git a/compat/Unused.hpp b/compat/Unused.hpp new file mode 100644 index 000000000..175137968 --- /dev/null +++ b/compat/Unused.hpp @@ -0,0 +1,7 @@ +#pragma once + +#ifdef __GNUC__ +#define MC_UNUSED __attribute__((unused)) +#else +#define MC_UNUSED +#endif diff --git a/platforms/android/AppPlatform_android.cpp b/platforms/android/AppPlatform_android.cpp index 03c9eaee0..a2a16a457 100644 --- a/platforms/android/AppPlatform_android.cpp +++ b/platforms/android/AppPlatform_android.cpp @@ -248,7 +248,7 @@ void AppPlatform_android::changeKeyboardVisibility(bool bShown) // lInputMethodManager.hideSoftInput(...). jmethodID MethodHideSoftInput = pEnv->GetMethodID(ClassInputMethodManager, "hideSoftInputFromWindow","(Landroid/os/IBinder;I)Z"); - jboolean lResult = pEnv->CallBooleanMethod(lInputMethodManager, MethodHideSoftInput,lBinder, flags); + pEnv->CallBooleanMethod(lInputMethodManager, MethodHideSoftInput,lBinder, flags); m_bIsKeyboardShown = false; // just treat it as hidden anyways why not } diff --git a/platforms/android/main.cpp b/platforms/android/main.cpp index 031fcea81..086cef2ac 100644 --- a/platforms/android/main.cpp +++ b/platforms/android/main.cpp @@ -43,30 +43,30 @@ struct engine NinecraftApp* ninecraftApp = nullptr; }; -static float mapStick(AInputEvent* event, int32_t axis) -{ - const float deadZone = .265f; - float value = AMotionEvent_getAxisValue(event, axis, 0); - if (value > deadZone) - return (value - deadZone) / (1.f - deadZone); - else if (value < -deadZone) - return (value + deadZone) / (1.f - deadZone); - else - return 0.f; -} - -static float mapTrigger(AInputEvent* event, int32_t axis) -{ - const float deadZone = .1f; - float value = AMotionEvent_getAxisValue(event, axis, 0); - if (value > deadZone) - return (value - deadZone) / (1.f - deadZone); - else - return 0.f; -} - -static bool s_lastR = false; -static bool s_lastL = false; +// static float mapStick(AInputEvent* event, int32_t axis) +// { +// const float deadZone = .265f; +// float value = AMotionEvent_getAxisValue(event, axis, 0); +// if (value > deadZone) +// return (value - deadZone) / (1.f - deadZone); +// else if (value < -deadZone) +// return (value + deadZone) / (1.f - deadZone); +// else +// return 0.f; +// } + +// static float mapTrigger(AInputEvent* event, int32_t axis) +// { +// const float deadZone = .1f; +// float value = AMotionEvent_getAxisValue(event, axis, 0); +// if (value > deadZone) +// return (value - deadZone) / (1.f - deadZone); +// else +// return 0.f; +// } + +// static bool s_lastR = false; +// static bool s_lastL = false; static char getCharFromKey(int32_t keyCode, int32_t metaState) { @@ -470,4 +470,4 @@ void android_main(struct android_app* state) { exit: engine.ninecraftApp->saveOptions(); delete engine.ninecraftApp; -} \ No newline at end of file +} diff --git a/platforms/ios/minecraftpeViewController.mm b/platforms/ios/minecraftpeViewController.mm index ac84a189c..51a3d4a9c 100644 --- a/platforms/ios/minecraftpeViewController.mm +++ b/platforms/ios/minecraftpeViewController.mm @@ -170,7 +170,7 @@ - (void)viewDidLoad else if (![EAGLContext setCurrentContext:aContext]) NSLog(@"Failed to set ES context current"); - self.context = aContext; + self.context = aContext; [(EAGLView *)self.view setContext:context]; [(EAGLView *)self.view setFramebuffer]; @@ -247,7 +247,7 @@ - (void)viewDidUnload // Tear down context. if ([EAGLContext currentContext] == context) [EAGLContext setCurrentContext:nil]; - self.context = nil; + self.context = nil; } - (void)initView diff --git a/platforms/sdl/sdl1/main.cpp b/platforms/sdl/sdl1/main.cpp index 8cfe5d52c..82bb095c8 100644 --- a/platforms/sdl/sdl1/main.cpp +++ b/platforms/sdl/sdl1/main.cpp @@ -38,10 +38,9 @@ static void initGraphics() #if MCE_GFX_API_OGL if (!mce::Platform::OGL::InitBindings()) { - const char* const GL_ERROR_MSG = "Error initializing GL extensions. OpenGL 2.0 or later is required."; + LOG_E("Error initializing GL extensions. OpenGL 2.0 or later is required."); exit(EXIT_FAILURE); } -#else #endif } diff --git a/platforms/sound/directsound/CustomSoundSystem.hpp b/platforms/sound/directsound/CustomSoundSystem.hpp index 5efc39859..7340c3348 100644 --- a/platforms/sound/directsound/CustomSoundSystem.hpp +++ b/platforms/sound/directsound/CustomSoundSystem.hpp @@ -14,9 +14,11 @@ #include #include +#ifdef _MSVC_VER #pragma comment(lib, "dsound.lib") #pragma comment(lib, "dxguid.lib") #pragma comment(lib, "winmm.lib") +#endif #include #include diff --git a/platforms/sound/openal/SoundStreamAL.cpp b/platforms/sound/openal/SoundStreamAL.cpp index 778f8085c..6ba7f438a 100644 --- a/platforms/sound/openal/SoundStreamAL.cpp +++ b/platforms/sound/openal/SoundStreamAL.cpp @@ -57,7 +57,7 @@ void SoundStreamAL::_createBuffers() ALuint buffers[2]; alGenBuffers(2, buffers); - for (int i = 0; i < sizeof(buffers) / sizeof(ALuint); i++) + for (size_t i = 0; i < sizeof(buffers) / sizeof(ALuint); i++) { _buffers.push_back(buffers[i]); _bufferIdMap.insert(std::make_pair(buffers[i], i )); @@ -108,7 +108,7 @@ bool SoundStreamAL::_open(const std::string& fileName) else _alFormat = AL_FORMAT_MONO16; size_t size = _buffers.size(); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { if (!_stream(i)) return false; } @@ -168,4 +168,4 @@ void SoundStreamAL::_publishBuffer(unsigned int destBufferId, const SoundBuffer& { alBufferData(_buffers[destBufferId], _alFormat, sourceBuffer.m_pData, sourceBuffer.m_dataSize * sizeof(int16_t), m_info.sample_rate); AL_ERROR_CHECK(); -} \ No newline at end of file +} diff --git a/platforms/sound/openal/SoundSystemAL.cpp b/platforms/sound/openal/SoundSystemAL.cpp index fc9f97542..88f66eab9 100644 --- a/platforms/sound/openal/SoundSystemAL.cpp +++ b/platforms/sound/openal/SoundSystemAL.cpp @@ -261,7 +261,6 @@ void SoundSystemAL::playAt(const SoundDesc& sound, const Vec3& pos, float volume return; bool bIsGUI = AL_FALSE; - float distance = 0.0f; if (pos == Vec3::ZERO) { bIsGUI = AL_TRUE; diff --git a/platforms/windows/AppPlatform_win32.cpp b/platforms/windows/AppPlatform_win32.cpp index 6756f32cb..e1c7deeee 100644 --- a/platforms/windows/AppPlatform_win32.cpp +++ b/platforms/windows/AppPlatform_win32.cpp @@ -117,8 +117,6 @@ void AppPlatform_win32::saveScreenshot(const std::string& fileName, int width, i sprintf(str, "%s\\%s", ".", "Screenshots"); // https://stackoverflow.com/a/8233867 - DWORD ftyp = GetFileAttributesA(str); - DWORD error = GetLastError(); if (error == ERROR_PATH_NOT_FOUND || error == ERROR_FILE_NOT_FOUND || error == ERROR_INVALID_NAME) { @@ -150,6 +148,8 @@ void AppPlatform_win32::createUserInput() m_UserInputStatus = 1; break; } + default: + break; } } diff --git a/source/client/gui/Gui.cpp b/source/client/gui/Gui.cpp index dc860dfc0..d9f1ac6c0 100644 --- a/source/client/gui/Gui.cpp +++ b/source/client/gui/Gui.cpp @@ -13,7 +13,7 @@ #include "client/renderer/renderer/RenderMaterialGroup.hpp" #include "renderer/ShaderConstants.hpp" -#ifdef _WIN32 +#ifdef _MSVC_VER #pragma warning(disable : 4244) #endif diff --git a/source/client/gui/components/OptionList.cpp b/source/client/gui/components/OptionList.cpp index 41371a91d..9b9309018 100644 --- a/source/client/gui/components/OptionList.cpp +++ b/source/client/gui/components/OptionList.cpp @@ -340,6 +340,7 @@ void OptionList::initMultiplayerMenu() #ifdef __EMSCRIPTEN m_items[currentIndex]->setDisabled(true); #endif + (void)currentIndex; // compiler will warn about an unused variable sometimes if this isn't here } void OptionList::initMiscMenu() @@ -358,4 +359,4 @@ void OptionList::initMiscMenu() if (!Screen::isMenuPanoramaAvailable()) m_items[idxPano]->setDisabled(true); #endif -} \ No newline at end of file +} diff --git a/source/client/gui/components/TextInputBox.cpp b/source/client/gui/components/TextInputBox.cpp index 7fe941915..bdcddbfc7 100644 --- a/source/client/gui/components/TextInputBox.cpp +++ b/source/client/gui/components/TextInputBox.cpp @@ -377,7 +377,7 @@ std::string TextInputBox::_sanitizePasteText(const std::string& text) const std::string sanitized; sanitized.reserve(text.length()); - for (int i = 0; i < text.length(); ++i) + for (size_t i = 0; i < text.length(); ++i) { char c = text[i]; if (!IsInvalidCharacter(c)) diff --git a/source/client/gui/screens/CreateWorldScreen.cpp b/source/client/gui/screens/CreateWorldScreen.cpp index 179b8813f..a2414c9f5 100644 --- a/source/client/gui/screens/CreateWorldScreen.cpp +++ b/source/client/gui/screens/CreateWorldScreen.cpp @@ -104,7 +104,7 @@ void CreateWorldScreen::buttonClicked(Button* pButton) std::string levelNickname = Util::stringTrim(nameStr); std::string levelUniqueName = levelNickname; - for (int i = 0; i < sizeof(g_CreateWorldFilterArray); i++) + for (size_t i = 0; i < sizeof(g_CreateWorldFilterArray); i++) { std::string str; str.push_back(g_CreateWorldFilterArray[i]); diff --git a/source/client/gui/screens/JoinGameScreen.cpp b/source/client/gui/screens/JoinGameScreen.cpp index 6c719347b..4fa194d14 100644 --- a/source/client/gui/screens/JoinGameScreen.cpp +++ b/source/client/gui/screens/JoinGameScreen.cpp @@ -149,8 +149,8 @@ void JoinGameScreen::tick() std::vector* pGames = &m_pAvailableGamesList->m_games; for (int i = int(pGames->size() - 1); i >= 0; i--) { - int j = 0; - for (; j < int(serverListFiltered.size()); j++) + size_t j = 0; + for (; j < serverListFiltered.size(); j++) { if (serverListFiltered[j].m_address == (*pGames)[i].m_address) break; diff --git a/source/client/gui/screens/OptionsScreen.cpp b/source/client/gui/screens/OptionsScreen.cpp index a5f7703bc..7313bf215 100644 --- a/source/client/gui/screens/OptionsScreen.cpp +++ b/source/client/gui/screens/OptionsScreen.cpp @@ -18,12 +18,12 @@ OptionsScreen::OptionsScreen() : m_pList(nullptr), + m_currentCategory(OC_VIDEO), m_videoButton(MIN_CATEGORY_BUTTON_ID, "Video"), m_controlsButton(MIN_CATEGORY_BUTTON_ID + 1, "Controls"), m_multiplayerButton(MIN_CATEGORY_BUTTON_ID + 2, "Multiplayer"), m_miscButton(MAX_CATEGORY_BUTTON_ID, "Misc"), - m_backButton(BACK_BUTTON_ID, "Done"), - m_currentCategory(OC_VIDEO) + m_backButton(BACK_BUTTON_ID, "Done") { } diff --git a/source/client/gui/screens/SelectWorldScreen.cpp b/source/client/gui/screens/SelectWorldScreen.cpp index 22a3dde23..bc1f0139b 100644 --- a/source/client/gui/screens/SelectWorldScreen.cpp +++ b/source/client/gui/screens/SelectWorldScreen.cpp @@ -111,7 +111,7 @@ void SelectWorldScreen::tick() std::string levelNickname = Util::stringTrim(userInput[0]); std::string levelUniqueName = levelNickname; - for (int i = 0; i < sizeof(g_SelectWorldFilterArray); i++) + for (size_t i = 0; i < sizeof(g_SelectWorldFilterArray); i++) { std::string str; str.push_back(g_SelectWorldFilterArray[i]); diff --git a/source/client/gui/screens/StartMenuScreen.cpp b/source/client/gui/screens/StartMenuScreen.cpp index 38cb78136..3ec8205ba 100644 --- a/source/client/gui/screens/StartMenuScreen.cpp +++ b/source/client/gui/screens/StartMenuScreen.cpp @@ -542,7 +542,7 @@ void StartMenuScreen::draw2dTitle() { Textures* tx = m_pMinecraft->m_pTextures; - bool crampedMode = false; + // bool crampedMode = false; currentShaderColor = Color::WHITE; @@ -559,7 +559,7 @@ void StartMenuScreen::draw2dTitle() if (m_width * 3 / 4 < m_2dTitleBounds.w) { - crampedMode = true; + // crampedMode = true; yPos = 4; } @@ -588,7 +588,7 @@ void StartMenuScreen::draw2dTitle() if (m_width * 3 / 4 < m_2dTitleBounds.w) { - crampedMode = true; + // crampedMode = true; yPos = 4; } diff --git a/source/client/multiplayer/MultiPlayerLevel.cpp b/source/client/multiplayer/MultiPlayerLevel.cpp index 58a787006..1890674d5 100644 --- a/source/client/multiplayer/MultiPlayerLevel.cpp +++ b/source/client/multiplayer/MultiPlayerLevel.cpp @@ -10,7 +10,7 @@ void MultiPlayerLevel::tick() _setTime(getTime() + 1); // Bypasses the normally-required update to LevelListeners updateSkyDarken(); - for (int i = 0; i < 10 && i < m_reEntries.size(); i++) + for (size_t i = 0; i < 10 && i < m_reEntries.size(); i++) { Entity* pEntity = m_reEntries[i]; if (std::find(m_entities.begin(), m_entities.end(), pEntity) != m_entities.end()) @@ -51,4 +51,4 @@ void MultiPlayerLevel::putEntity(int id, Entity* e) } m_entitiesById[id] = e; -} \ No newline at end of file +} diff --git a/source/client/network/ClientSideNetworkHandler.cpp b/source/client/network/ClientSideNetworkHandler.cpp index 04f4c7234..a6cea0761 100644 --- a/source/client/network/ClientSideNetworkHandler.cpp +++ b/source/client/network/ClientSideNetworkHandler.cpp @@ -484,7 +484,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, ChunkDa m_pLevel->setTileNoUpdate(TilePos(x16 + (k & 0xF), yPos + i, z16 + (k >> 4)), tiles[i]); } - int idx = ((k & 0xF) << 11) | ((k >> 4) << 7) + yPos; + int idx = ((k & 0xF) << 11) | (((k >> 4) << 7) + yPos); memcpy(&pChunk->m_tileData.m_data[idx >> 1], datas, sizeof datas); } diff --git a/source/client/options/Options.cpp b/source/client/options/Options.cpp index 764e02f39..bc666da0d 100644 --- a/source/client/options/Options.cpp +++ b/source/client/options/Options.cpp @@ -101,7 +101,7 @@ void Options::_load() { std::vector strings = readPropertiesFromFile(m_filePath); - for (int i = 0; i < strings.size(); i += 2) + for (size_t i = 0; i < strings.size(); i += 2) { std::string key = strings[i], value = strings[i + 1]; @@ -250,7 +250,7 @@ void Options::savePropertiesToFile(const std::string& filePath, std::vector #include "Keyboard.hpp" #include "GameMods.hpp" @@ -28,7 +29,7 @@ void Keyboard::feed(KeyState state, int key) bool Keyboard::next() { - if (_index + 1 >= _inputs.size()) + if ((size_t)_index + 1 >= _inputs.size()) return false; _index++; diff --git a/source/client/player/input/MouseDevice.cpp b/source/client/player/input/MouseDevice.cpp index 8e60b067b..7bd9ee5de 100644 --- a/source/client/player/input/MouseDevice.cpp +++ b/source/client/player/input/MouseDevice.cpp @@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include #include "MouseDevice.hpp" MouseDevice::MouseDevice() @@ -51,7 +52,7 @@ short MouseDevice::getY() bool MouseDevice::next() { - if (_index + 1 >= _inputs.size()) + if ((size_t)_index + 1 >= _inputs.size()) return false; _index++; diff --git a/source/client/player/input/Multitouch.cpp b/source/client/player/input/Multitouch.cpp index 3a8156515..52f56ccd6 100644 --- a/source/client/player/input/Multitouch.cpp +++ b/source/client/player/input/Multitouch.cpp @@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ +#include #include "Multitouch.hpp" int Multitouch::_activePointerCount; @@ -132,7 +133,7 @@ bool Multitouch::isPressed(int fingerId) bool Multitouch::next() { - if (_index + 1 >= _inputs.size()) + if ((size_t)_index + 1 >= _inputs.size()) return false; _index++; diff --git a/source/client/renderer/GameRenderer.cpp b/source/client/renderer/GameRenderer.cpp index a19b1de26..0c495f4f2 100644 --- a/source/client/renderer/GameRenderer.cpp +++ b/source/client/renderer/GameRenderer.cpp @@ -187,7 +187,7 @@ void GameRenderer::_renderVertexGraph(int vertices, int h) Font& font = *m_pMinecraft->m_pFont; static int vertGraph[200]; - memcpy(vertGraph, vertGraph + 1, sizeof(vertGraph) - sizeof(int)); + memmove(vertGraph, vertGraph + 1, sizeof(vertGraph) - sizeof(int)); vertGraph[(sizeof(vertGraph) / sizeof(vertGraph[0])) - 1] = vertices; Tesselator& t = Tesselator::instance; diff --git a/source/client/renderer/LavaSideTexture.cpp b/source/client/renderer/LavaSideTexture.cpp index b8492508b..29f984027 100644 --- a/source/client/renderer/LavaSideTexture.cpp +++ b/source/client/renderer/LavaSideTexture.cpp @@ -54,13 +54,13 @@ void LavaSideTexture::tick() { for (int by = y - 1; by <= y + 1; by++) { - int k2 = bx + ay & 0xf; - int i3 = by + ax & 0xf; + int k2 = (bx + ay) & 0xf; + int i3 = (by + ax) & 0xf; f += m_data1[k2 + i3 * 16]; } } - m_data2[x + y * 16] = f / 10.0f + ((m_data3[(x & 0xf) + (y + 0 & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y + 1 & 0xf) * 16] + m_data3[(x & 0xf) + (y + 1 & 0xf) * 16]) * 0.25f) * 0.8f; + m_data2[x + y * 16] = f / 10.0f + ((m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; m_data3[x + y * 16] += m_data4[x + y * 16] * 0.01f; if (m_data3[x + y * 16] < 0.0f) diff --git a/source/client/renderer/LavaTexture.cpp b/source/client/renderer/LavaTexture.cpp index e53acd416..f2c882412 100644 --- a/source/client/renderer/LavaTexture.cpp +++ b/source/client/renderer/LavaTexture.cpp @@ -52,13 +52,13 @@ void LavaTexture::tick() { for (int by = y - 1; by <= y + 1; by++) { - int k2 = bx + ay & 0xf; - int i3 = by + ax & 0xf; + int k2 = (bx + ay) & 0xf; + int i3 = (by + ax) & 0xf; f += m_data1[k2 + i3 * 16]; } } - m_data2[x + y * 16] = f / 10.0f + ((m_data3[(x & 0xf) + (y + 0 & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y & 0xf) * 16] + m_data3[(x + 1 & 0xf) + (y + 1 & 0xf) * 16] + m_data3[(x & 0xf) + (y + 1 & 0xf) * 16]) * 0.25f) * 0.8f; + m_data2[x + y * 16] = f / 10.0f + ((m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; m_data3[x + y * 16] += m_data4[x + y * 16] * 0.01f; if (m_data3[x + y * 16] < 0.0f) diff --git a/source/client/renderer/LevelRenderer.cpp b/source/client/renderer/LevelRenderer.cpp index eb33c4d11..f2ec72433 100644 --- a/source/client/renderer/LevelRenderer.cpp +++ b/source/client/renderer/LevelRenderer.cpp @@ -250,7 +250,7 @@ void LevelRenderer::_buildStarsMesh() { float ___xo = 0.0f; float ___yo = ((c & 2) - 1) * ss; - float ___zo = ((c + 1 & 2) - 1) * ss; + float ___zo = (((c + 1) & 2) - 1) * ss; float __yo = ___yo * zCos - ___zo * zSin; float __zo = ___zo * zCos + ___yo * zSin; float _yo = __yo * xSin + ___xo * xCos; @@ -576,7 +576,7 @@ void LevelRenderer::cull(Culler* pCuller, float f) if (pChunk->isEmpty()) continue; - if (!pChunk->m_bVisible || (i + m_cullStep & 15) == 0) + if (!pChunk->m_bVisible || ((i + m_cullStep) & 15) == 0) { pChunk->cull(pCuller); } diff --git a/source/client/renderer/ScreenRenderer.cpp b/source/client/renderer/ScreenRenderer.cpp index 5dd9128a4..0603b68bd 100644 --- a/source/client/renderer/ScreenRenderer.cpp +++ b/source/client/renderer/ScreenRenderer.cpp @@ -4,7 +4,7 @@ #include "renderer/ShaderConstants.hpp" #include "client/renderer/Tesselator.hpp" -#ifdef _WIN32 +#ifdef _MSVC_VER #pragma warning (disable : 4244) #endif @@ -129,4 +129,4 @@ void ScreenRenderer::fillGradient(float left, float top, float right, float bott void ScreenRenderer::fillGradient(int left, int top, int right, int bottom, const Color& colorUp, const Color& colorDown) { fillGradient(float(left), float(top), float(right), float(bottom), colorUp, colorDown); -} \ No newline at end of file +} diff --git a/source/client/renderer/Tesselator.hpp b/source/client/renderer/Tesselator.hpp index b8a79aaba..c2ae33436 100644 --- a/source/client/renderer/Tesselator.hpp +++ b/source/client/renderer/Tesselator.hpp @@ -140,9 +140,6 @@ class Tesselator bool m_bTesselating; mce::PrimitiveMode m_drawMode; - // Buffer state - int m_maxVertices; - private: bool m_bVoidBeginEnd; }; diff --git a/source/client/renderer/Textures.cpp b/source/client/renderer/Textures.cpp index 6eecf47e9..44801e97d 100644 --- a/source/client/renderer/Textures.cpp +++ b/source/client/renderer/Textures.cpp @@ -18,8 +18,7 @@ bool Textures::MIPMAP = false; TextureData* Textures::loadTexture(const std::string& name, bool bIsRequired) { - TextureMap::iterator it = m_textures.find(name); - assert(it == m_textures.end()); + assert(m_textures.find(name) == m_textures.end()); TextureData t = m_pPlatform->loadTexture(name, bIsRequired); @@ -194,7 +193,6 @@ void Textures::tick() TextureData* Textures::loadAndBindTexture(const std::string& name, bool isRequired, unsigned int textureUnit) { - TextureMap::iterator it = m_textures.find(name); TextureData* pTexture = getTextureData(name, isRequired); if (!pTexture) @@ -222,4 +220,4 @@ void Textures::addDynamicTexture(DynamicTexture* pTexture) { m_dynamicTextures.push_back(pTexture); pTexture->tick(); -} \ No newline at end of file +} diff --git a/source/client/renderer/renderer/EntityShaderManager.cpp b/source/client/renderer/renderer/EntityShaderManager.cpp index e31266f37..b82350d04 100644 --- a/source/client/renderer/renderer/EntityShaderManager.cpp +++ b/source/client/renderer/renderer/EntityShaderManager.cpp @@ -37,8 +37,6 @@ void EntityShaderManager::_setupShaderParameters(const Entity& entity, mce::GlobalConstantBuffers& globalBuffers = mce::GlobalConstantBuffers::getInstance(); mce::EntityConstants& cEntity = globalBuffers.m_entityConstants; - Vec3 entityPos = entity.m_pos; - Color tileLightColor = Color::WHITE * entity.getBrightness(a); if (a != 1.0f) @@ -165,4 +163,4 @@ Color EntityShaderManager::getOverlayColor(const Entity& entity, float a) } return Color::NIL; -} \ No newline at end of file +} diff --git a/source/client/renderer/renderer/RenderMaterialGroup.cpp b/source/client/renderer/renderer/RenderMaterialGroup.cpp index e653b283a..dfe3c85bf 100644 --- a/source/client/renderer/renderer/RenderMaterialGroup.cpp +++ b/source/client/renderer/renderer/RenderMaterialGroup.cpp @@ -16,6 +16,11 @@ struct MaterialParent { std::string parentName; const rapidjson::Value* json; + + MaterialParent() + { + json = nullptr; + } }; typedef InheritanceTree MaterialTree; diff --git a/source/client/renderer/texture/TextureData.cpp b/source/client/renderer/texture/TextureData.cpp index 594c1880e..424ef03f9 100644 --- a/source/client/renderer/texture/TextureData.cpp +++ b/source/client/renderer/texture/TextureData.cpp @@ -141,7 +141,7 @@ void TextureData::setData(uint8_t* data) void TextureData::load() { _loadTexData(m_texture, m_bEnableFiltering, m_bWrap); - for (int i = 0; i < m_mipmaps.size(); i++) + for (size_t i = 0; i < m_mipmaps.size(); i++) { _loadMipmap(m_mipmaps[i]); } @@ -173,4 +173,4 @@ void TextureData::unbindAll() lastBoundTexture[5] = nullptr; lastBoundTexture[6] = nullptr; lastBoundTexture[7] = nullptr; -} \ No newline at end of file +} diff --git a/source/common/Mth.cpp b/source/common/Mth.cpp index 9b1b07242..af2663c15 100644 --- a/source/common/Mth.cpp +++ b/source/common/Mth.cpp @@ -7,6 +7,7 @@ ********************************************************************/ #include +#include #include #include @@ -42,17 +43,19 @@ float Mth::invSqrt(float number) // It looks familiar. With IDA I get a convoluted mess. I'm going to assume // they just stole it from Quake. - int32_t i; float x2, y; const float threehalfs = 1.5F; - - x2 = number * 0.5F; - y = number; - i = * ( int32_t * ) &y; // evil floating point bit level hacking - i = 0x5f3759df - ( i >> 1 ); // what the fuck? - y = * ( float * ) &i; - y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration - // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed + union { + float f; + int32_t i; + } un; + + x2 = number * 0.5F; + un.f = number; // evil floating point bit level hacking + un.i = 0x5f3759df - ( un.i >> 1 ); // what the fuck? + y = un.f; + y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration + // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; } diff --git a/source/common/Util.cpp b/source/common/Util.cpp index 4aa56bdc5..a2cc6593f 100644 --- a/source/common/Util.cpp +++ b/source/common/Util.cpp @@ -68,7 +68,7 @@ std::string Util::format(const char *fmt, ...) bool Util::isValidPath(const std::string& path) { - for (int i = 0; i < path.size(); i++) + for (size_t i = 0; i < path.size(); i++) { switch (path.at(i)) { @@ -135,4 +135,4 @@ std::string Util::toString(int value) std::reverse(str.begin(), str.end()); return str; -} \ No newline at end of file +} diff --git a/source/common/Util.hpp b/source/common/Util.hpp index 864fcf34e..785e309b2 100644 --- a/source/common/Util.hpp +++ b/source/common/Util.hpp @@ -80,7 +80,7 @@ class Util int32_t result = 0; const size_t size = str.size(); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { result = result * 31 + str.at(i); } diff --git a/source/common/Utils.cpp b/source/common/Utils.cpp index 12a730577..9f178b5c3 100644 --- a/source/common/Utils.cpp +++ b/source/common/Utils.cpp @@ -17,7 +17,9 @@ #include // Why are we not using GetTickCount64()? It's simple -- getTimeMs has the exact same problem as using regular old GetTickCount. +#ifdef _MSVC_VER #pragma warning(disable : 28159) +#endif #elif MC_PLATFORM_XBOX360 diff --git a/source/common/utility/InheritanceTree.hpp b/source/common/utility/InheritanceTree.hpp index 366bcc357..f487bce7e 100644 --- a/source/common/utility/InheritanceTree.hpp +++ b/source/common/utility/InheritanceTree.hpp @@ -66,10 +66,10 @@ class InheritanceTree } // Queue child nodes - for (int i = 0; i < currentNode->child.size(); i++) + for (size_t i = 0; i < currentNode->child.size(); i++) { queue.push_back(currentNode->child[i]); } } } -}; \ No newline at end of file +}; diff --git a/source/nbt/Int32ArrayTag.cpp b/source/nbt/Int32ArrayTag.cpp index 5a50c2a8b..1a9737d67 100644 --- a/source/nbt/Int32ArrayTag.cpp +++ b/source/nbt/Int32ArrayTag.cpp @@ -34,14 +34,14 @@ void Int32ArrayTag::load(IDataInput& dis) uint8_t* buf = m_data.alloc(size); if (buf) { - for (uint32_t i = 0; i < elements; i++) + for (uint32_t i = 0; i < (uint32_t)elements; i++) { if (dis.numBytesLeft() == 0) break; if (i >= m_data.m_elements) { size = m_data.m_elements + MAX_SIZE; - if (elements < size) + if ((uint32_t)elements < size) size = elements; m_data.alloc(size); } @@ -78,4 +78,4 @@ bool Int32ArrayTag::operator==(const Tag& other) const return false; return true; -} \ No newline at end of file +} diff --git a/source/nbt/Int64ArrayTag.cpp b/source/nbt/Int64ArrayTag.cpp index 1ff1a3ce0..5e4dac8ce 100644 --- a/source/nbt/Int64ArrayTag.cpp +++ b/source/nbt/Int64ArrayTag.cpp @@ -34,14 +34,14 @@ void Int64ArrayTag::load(IDataInput& dis) uint8_t* buf = m_data.alloc(size); if (buf) { - for (uint32_t i = 0; i < elements; i++) + for (uint32_t i = 0; i < (uint32_t)elements; i++) { if (dis.numBytesLeft() == 0) break; if (i >= m_data.m_elements) { size = m_data.m_elements + MAX_SIZE; - if (elements < size) + if ((uint32_t)elements < size) size = elements; m_data.alloc(size); } @@ -78,4 +78,4 @@ bool Int64ArrayTag::operator==(const Tag& other) const return false; return true; -} \ No newline at end of file +} diff --git a/source/nbt/Int8ArrayTag.cpp b/source/nbt/Int8ArrayTag.cpp index 441dc28d6..4e5549421 100644 --- a/source/nbt/Int8ArrayTag.cpp +++ b/source/nbt/Int8ArrayTag.cpp @@ -22,7 +22,7 @@ void Int8ArrayTag::load(IDataInput& dis) if (elements <= 0) return; - unsigned int bytesLeft = dis.numBytesLeft(); + ssize_t bytesLeft = dis.numBytesLeft(); int32_t count = elements; if (bytesLeft < elements) count = bytesLeft; @@ -53,4 +53,4 @@ bool Int8ArrayTag::operator==(const Tag& other) const return false; return true; -} \ No newline at end of file +} diff --git a/source/network/NetEventCallback.cpp b/source/network/NetEventCallback.cpp index 2fd32b04d..724c0bed1 100644 --- a/source/network/NetEventCallback.cpp +++ b/source/network/NetEventCallback.cpp @@ -17,7 +17,7 @@ Player* NetEventCallback::_findPlayer(Level& level, Entity::ID entityId, const R if (!guid || level.m_players.empty()) return nullptr; - for (int i = 0; i < level.m_players.size(); i++) + for (size_t i = 0; i < level.m_players.size(); i++) { Player* pPlayer = level.m_players[i]; if (pPlayer && pPlayer->m_guid == *guid) @@ -40,4 +40,4 @@ void NetEventCallback::handle(Level& level, const RakNet::RakNetGUID& guid, Resp pPlayer->moveTo(pkt->m_pos); pPlayer->reset(); pPlayer->resetPos(true); -} \ No newline at end of file +} diff --git a/source/network/PacketUtil.cpp b/source/network/PacketUtil.cpp index f7b6fe311..cb746b793 100644 --- a/source/network/PacketUtil.cpp +++ b/source/network/PacketUtil.cpp @@ -102,15 +102,16 @@ void PacketUtil::ReadUserData(ItemInstance& item, RakNet::BitStream* bs) else if (item.getTile()) { // Tile::readUserData (0.12.1) (never called or called virtually) - bool hasData; - bs->Read(hasData); + bool hasData = false; + if (!bs->Read(hasData)) + return; if (!hasData) return; int32_t repairCost; bs->Read(repairCost); - bool hasHoverName; + bool hasHoverName = false; bs->Read(hasHoverName); item.setRepairCost(repairCost); @@ -178,4 +179,4 @@ ItemInstance PacketUtil::ReadItemInstance(RakNet::BitStream* bs, bool doUserData ReadUserData(itemInstance, bs); return itemInstance; -} \ No newline at end of file +} diff --git a/source/network/RakNetInstance.cpp b/source/network/RakNetInstance.cpp index 7e7151043..da7b4a4c7 100644 --- a/source/network/RakNetInstance.cpp +++ b/source/network/RakNetInstance.cpp @@ -205,7 +205,7 @@ void RakNetInstance::runEvents(NetEventCallback& callback) break; // update the info of a pinged compatible server, if possible. - for (int i = 0; i < m_servers.size(); i++) + for (size_t i = 0; i < m_servers.size(); i++) { PingedCompatibleServer& server = m_servers.at(i); if (server.m_address == pPacket->systemAddress) diff --git a/source/network/packets/ChunkDataPacket.cpp b/source/network/packets/ChunkDataPacket.cpp index 7d598fcc0..703a3001c 100644 --- a/source/network/packets/ChunkDataPacket.cpp +++ b/source/network/packets/ChunkDataPacket.cpp @@ -36,7 +36,7 @@ void ChunkDataPacket::write(RakNet::BitStream& bs) { if ((m_pChunk->m_updateMap[i] >> y) & 1) { - int idx = ((i & 0xF) << 11) | ((i >> 4) << 7) + (y * 16); + int idx = ((i & 0xF) << 11) | (((i >> 4) << 7) + (y * 16)); //write the tile data m_data.Write((const char*) &m_pChunk->m_pBlockData[idx], 16 * sizeof(TileID)); diff --git a/source/renderer/ConstantBufferMetaData.cpp b/source/renderer/ConstantBufferMetaData.cpp index d7d545b3c..6c39762ee 100644 --- a/source/renderer/ConstantBufferMetaData.cpp +++ b/source/renderer/ConstantBufferMetaData.cpp @@ -31,7 +31,7 @@ const std::string& ConstantBufferMetaData::getConstantBufferName() const const UniformMetaData* ConstantBufferMetaData::getUniformMetaData(const std::string& uniformName) const { - for (int i = 0; i < m_uniformMetaData.size(); i++) + for (size_t i = 0; i < m_uniformMetaData.size(); i++) { const UniformMetaData& uniformMeta = m_uniformMetaData[i]; if (uniformMeta.m_uniformName == uniformName) @@ -50,4 +50,4 @@ unsigned int ConstantBufferMetaData::getRequiredSpaceForUniforms() const unsigned int unalignedSize = lastUniform.getSize() + lastUniform.m_byteOffset; return AlignmentHelper::getAlignedOffset(unalignedSize, 16); -} \ No newline at end of file +} diff --git a/source/renderer/ConstantBufferMetaDataManager.cpp b/source/renderer/ConstantBufferMetaDataManager.cpp index b3762fd4b..2959f0cd2 100644 --- a/source/renderer/ConstantBufferMetaDataManager.cpp +++ b/source/renderer/ConstantBufferMetaDataManager.cpp @@ -16,7 +16,7 @@ void ConstantBufferMetaDataManager::allocateConstantBufferContainers() GlobalConstantBufferManager& bufferManager = GlobalConstantBufferManager::getInstance(); bufferManager.m_constantBufferContainers.reserve(m_constantBufferMetaDataList.size()); - for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + for (size_t i = 0; i < m_constantBufferMetaDataList.size(); i++) { ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; ConstantBufferContainer buffer; @@ -27,7 +27,7 @@ void ConstantBufferMetaDataManager::allocateConstantBufferContainers() buffer.m_constantBufferName = bufferMeta.getConstantBufferName(); - for (int i = 0; i < bufferMeta.m_uniformMetaData.size(); i++) + for (size_t i = 0; i < bufferMeta.m_uniformMetaData.size(); i++) { UniformMetaData& uniformMeta = bufferMeta.m_uniformMetaData[i]; buffer.registerReflectedShaderParameter(uniformMeta); @@ -91,7 +91,7 @@ void ConstantBufferMetaDataManager::loadJsonFile(const std::string& document) const UniformMetaData& ConstantBufferMetaDataManager::findUniformMetaData(const std::string& uniformName) const { - for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + for (size_t i = 0; i < m_constantBufferMetaDataList.size(); i++) { const ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; const UniformMetaData* uniformMeta = bufferMeta.getUniformMetaData(uniformName); @@ -105,7 +105,7 @@ const UniformMetaData& ConstantBufferMetaDataManager::findUniformMetaData(const const ConstantBufferMetaData& ConstantBufferMetaDataManager::findConstantBuffer(const std::string& bufferName) const { - for (int i = 0; i < m_constantBufferMetaDataList.size(); i++) + for (size_t i = 0; i < m_constantBufferMetaDataList.size(); i++) { const ConstantBufferMetaData& bufferMeta = m_constantBufferMetaDataList[i]; if (bufferMeta.getConstantBufferName() == bufferName) @@ -116,4 +116,4 @@ const ConstantBufferMetaData& ConstantBufferMetaDataManager::findConstantBuffer( LOG_E("Couldn't find the constant buffer named: %s was it properly reflected in the uniforms metadata file?", bufferName.c_str()); throw std::bad_cast(); -} \ No newline at end of file +} diff --git a/source/renderer/ShaderGroup.cpp b/source/renderer/ShaderGroup.cpp index e2ea8b3cc..dfbdf81d4 100644 --- a/source/renderer/ShaderGroup.cpp +++ b/source/renderer/ShaderGroup.cpp @@ -19,7 +19,7 @@ ShaderGroup::~ShaderGroup() void ShaderGroup::_clearShaders() { - for (int i = 0; i < m_shaders.size(); i++) + for (size_t i = 0; i < m_shaders.size(); i++) { if (m_shaders[i]) { @@ -150,7 +150,7 @@ void ShaderGroup::processIncludeDirectives(const std::string& path, std::string& Shader& ShaderGroup::loadShader(const std::string& header, const std::string& vertexCodeOrPath, const std::string& fragmentCodeOrPath, const std::string& geometryCodeOrPath) { - for (int i = 0; i < m_shaders.size(); i++) + for (size_t i = 0; i < m_shaders.size(); i++) { Shader* shader = m_shaders[i]; if (shader->isBuiltFrom(header, vertexCodeOrPath, fragmentCodeOrPath, geometryCodeOrPath)) diff --git a/source/renderer/hal/base/RenderDeviceBase.cpp b/source/renderer/hal/base/RenderDeviceBase.cpp index 5e15310e2..ec9c383c7 100644 --- a/source/renderer/hal/base/RenderDeviceBase.cpp +++ b/source/renderer/hal/base/RenderDeviceBase.cpp @@ -1,3 +1,4 @@ +#include #include "RenderDeviceBase.hpp" using namespace mce; @@ -14,7 +15,7 @@ const RenderDeviceBase::AttributeList& RenderDeviceBase::getAttributeList(unsign unsigned int RenderDeviceBase::registerOrGetAttributeListIndex(const AttributeList& attributeList) { - for (int i = 0; i < m_registeredAttributeLists.size(); i++) + for (size_t i = 0; i < m_registeredAttributeLists.size(); i++) { if (m_registeredAttributeLists[i] == attributeList) { @@ -25,4 +26,4 @@ unsigned int RenderDeviceBase::registerOrGetAttributeListIndex(const AttributeLi m_registeredAttributeLists.push_back(attributeList); return m_registeredAttributeLists.size() - 1; -} \ No newline at end of file +} diff --git a/source/renderer/hal/d3d11/ConstantBufferContainerD3D11.cpp b/source/renderer/hal/d3d11/ConstantBufferContainerD3D11.cpp index 69344c5b0..d39fabce7 100644 --- a/source/renderer/hal/d3d11/ConstantBufferContainerD3D11.cpp +++ b/source/renderer/hal/d3d11/ConstantBufferContainerD3D11.cpp @@ -11,7 +11,7 @@ ConstantBufferContainerD3D11::ConstantBufferContainerD3D11() void ConstantBufferContainerD3D11::sync(RenderContext& context) { - for (int i = 0; i < m_shaderConstants->size(); i++) + for (size_t i = 0; i < m_shaderConstants->size(); i++) { const ShaderConstant* shaderConstant = (*m_shaderConstants)[i]; if (shaderConstant->isDirty()) @@ -94,4 +94,4 @@ void ConstantBufferContainerD3D11::unmap(RenderContext& context) d3dDeviceContext->Unmap(**m_buffer, 0); m_bCurrentlyMapped = true; // yeah, they did this -} \ No newline at end of file +} diff --git a/source/renderer/hal/d3d11/ShaderD3D11.cpp b/source/renderer/hal/d3d11/ShaderD3D11.cpp index d457052c4..b85eb6129 100644 --- a/source/renderer/hal/d3d11/ShaderD3D11.cpp +++ b/source/renderer/hal/d3d11/ShaderD3D11.cpp @@ -118,7 +118,7 @@ void ShaderD3D11::bindShader(RenderContext& context, const VertexFormat& format, } } - for (int i = 0; i < m_resourceList.size(); i++) + for (size_t i = 0; i < m_resourceList.size(); i++) { for (int t = 0; t < SHADER_TYPES_COUNT; t++) { @@ -155,7 +155,7 @@ void ShaderD3D11::reflectShaderResources(ComInterface sh unsigned int shaderStagesBits = 1 << shaderType; - for (int i = 0; i < shaderDesc.ConstantBuffers; i++) + for (unsigned int i = 0; i < shaderDesc.ConstantBuffers; i++) { ID3D11ShaderReflectionConstantBuffer* constantBuffer = shaderReflection->GetConstantBufferByIndex(i); @@ -221,7 +221,7 @@ void ShaderD3D11::reflectShaderAttributes(ComInterface s RenderDeviceBase::AttributeList attrList; D3D11_SIGNATURE_PARAMETER_DESC paramDesc; - for (int i = 0; i < shaderDesc.InputParameters; i++) + for (unsigned int i = 0; i < shaderDesc.InputParameters; i++) { shaderReflection->GetInputParameterDesc(i, ¶mDesc); // Check if semantic name begins with "SV_" @@ -298,7 +298,7 @@ ComInterface ShaderD3D11::createInputLayout(const VertexForma std::vector attrNames; attrNames.resize(attrList.size()); - for (int i = 0; i < attrList.size(); i++) + for (size_t i = 0; i < attrList.size(); i++) { Attribute& attr = attrList[i]; std::string& elementName = attrNames[attr.getLocation()]; diff --git a/source/renderer/hal/d3d11/TextureD3D11.cpp b/source/renderer/hal/d3d11/TextureD3D11.cpp index 72ef331ff..197ffcc1e 100644 --- a/source/renderer/hal/d3d11/TextureD3D11.cpp +++ b/source/renderer/hal/d3d11/TextureD3D11.cpp @@ -139,9 +139,9 @@ void TextureD3D11::subBuffer(RenderContext& context, const void* pixels, unsigne const uint32_t* pixelPtr = (const uint32_t*)pixels; - for (int y = yoffset; y < yoffset + height; y++) + for (unsigned int y = yoffset; y < yoffset + height; y++) { - for (int x = xoffset; x < xoffset + width; x++) + for (unsigned int x = xoffset; x < xoffset + width; x++) { int destIndex = x + y * m_description.width; uint32_t color = *pixelPtr++; @@ -274,4 +274,4 @@ void TextureD3D11::move(TextureD3D11& other) bool TextureD3D11::supportsMipMaps() { return true; -} \ No newline at end of file +} diff --git a/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp b/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp index 69be613d7..a870e3d02 100644 --- a/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp +++ b/source/renderer/hal/enums/ShaderPrimitiveTypes.hpp @@ -1,5 +1,7 @@ #pragma once +#include "compat/Unused.hpp" + namespace mce { enum ShaderPrimitiveTypes @@ -30,7 +32,7 @@ namespace mce static int sizeInBytesFromShaderPrimitiveType(ShaderPrimitiveTypes shaderPrimitiveType); }; - static const char* ShaderPrimitiveTypeToString[] = { + MC_UNUSED static const char* ShaderPrimitiveTypeToString[] = { "UnknownPrimitiveType", "Float1", "Float2", @@ -44,4 +46,4 @@ namespace mce "Matrix3x3", "Matrix4x4" }; -} \ No newline at end of file +} diff --git a/source/renderer/hal/ogl/API_OGL.hpp b/source/renderer/hal/ogl/API_OGL.hpp index c7cc8aacc..8781f4ba8 100644 --- a/source/renderer/hal/ogl/API_OGL.hpp +++ b/source/renderer/hal/ogl/API_OGL.hpp @@ -3,6 +3,7 @@ #include #include "thirdparty/GL/GL.hpp" +#include "compat/Unused.hpp" // This file is actually titled "gl_header.h", but I like "API_OGL.hpp" better @@ -37,7 +38,7 @@ namespace gl void parse(); }; - static bool hardwareOverideOpenGLES3 = false; + MC_UNUSED static bool hardwareOverideOpenGLES3 = false; std::string getOpenGLVendor(); std::string getOpenGLRenderer(); @@ -50,4 +51,4 @@ namespace gl bool supportsImmediateMode(); bool supports32BitIndices(); bool supports16BitUnsignedUVs(); -} \ No newline at end of file +} diff --git a/source/renderer/hal/ogl/ShaderOGL.cpp b/source/renderer/hal/ogl/ShaderOGL.cpp index ce98f8da6..360b7c582 100644 --- a/source/renderer/hal/ogl/ShaderOGL.cpp +++ b/source/renderer/hal/ogl/ShaderOGL.cpp @@ -59,7 +59,7 @@ void ShaderOGL::deleteShader() void ShaderOGL::finalizeShaderUniforms() { - for (int i = 0; i < m_uniformList.size(); i++) + for (size_t i = 0; i < m_uniformList.size(); i++) { ShaderUniformOGL& uniform = m_uniformList[i]; uniform.m_pShaderConstant = uniform.m_pConstantBufferContainer->getUnspecializedShaderConstant(uniform.m_name); @@ -136,7 +136,7 @@ void ShaderOGL::bindVertexPointers(const VertexFormat& vertexFormat, const void* RenderDevice& device = RenderDevice::getInstance(); const RenderDeviceBase::AttributeList& attrList = device.getAttributeList(m_attributeListIndex); - for (int i = 0; i < attrList.size(); i++) + for (size_t i = 0; i < attrList.size(); i++) { const Attribute& attr = attrList[i]; @@ -171,7 +171,7 @@ void ShaderOGL::bindShader(RenderContext& context, const VertexFormat& format, c bindVertexPointers(format, dataBasePtr); - for (int i = 0; i < m_textureList.size(); i++) + for (size_t i = 0; i < m_textureList.size(); i++) { const ShaderResourceOGL& resource = m_textureList[i]; RenderContextOGL::ActiveTextureUnit& activeTextureUnit = context.getActiveTextureUnit(i); @@ -182,7 +182,7 @@ void ShaderOGL::bindShader(RenderContext& context, const VertexFormat& format, c } } - for (int i = 0; i < m_uniformList.size(); i++) + for (size_t i = 0; i < m_uniformList.size(); i++) { ShaderUniformOGL& shaderUniform = m_uniformList[i]; shaderUniform.bind(shaderChanged); @@ -299,4 +299,4 @@ void ShaderOGL::BuildHeader(std::ostringstream& stream) stream << "#extension GL_OES_standard_derivatives : enable\n"; } -#endif // FEATURE_GFX_SHADERS \ No newline at end of file +#endif // FEATURE_GFX_SHADERS diff --git a/source/server/ServerSideNetworkHandler.cpp b/source/server/ServerSideNetworkHandler.cpp index 5f28ae741..1e17336a7 100644 --- a/source/server/ServerSideNetworkHandler.cpp +++ b/source/server/ServerSideNetworkHandler.cpp @@ -975,7 +975,9 @@ void ServerSideNetworkHandler::commandGamemode(OnlinePlayer* player, const std:: GameType gameMode; std::stringstream ss; ss.str(parms[0]); - ss >> (int&)gameMode; + int tmp; + ss >> tmp; + gameMode = static_cast(tmp); if (!_validateNum(player, gameMode, GAME_TYPES_MIN, GAME_TYPES_MAX)) return; diff --git a/source/world/entity/Entity.hpp b/source/world/entity/Entity.hpp index ace8a670a..904d6ece1 100644 --- a/source/world/entity/Entity.hpp +++ b/source/world/entity/Entity.hpp @@ -154,7 +154,10 @@ class Entity virtual float distanceTo(const Vec3& pos) const; virtual float distanceToSqr(const Entity*) const; virtual int interactPreventDefault(); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" virtual bool interact(Player*); +#pragma GCC diagnostic pop virtual void playerTouch(Player*); virtual void push(Entity*); virtual void push(const Vec3& pos); diff --git a/source/world/entity/SynchedEntityData.cpp b/source/world/entity/SynchedEntityData.cpp index 492af2ecf..7d2b84b9f 100644 --- a/source/world/entity/SynchedEntityData.cpp +++ b/source/world/entity/SynchedEntityData.cpp @@ -64,7 +64,7 @@ bool SynchedEntityData::isDirty() const void SynchedEntityData::clear() { - for (int i = 0; i < m_itemsArray.size(); i++) + for (size_t i = 0; i < m_itemsArray.size(); i++) { DataItem* item = m_itemsArray[i]; SAFE_DELETE(item); @@ -102,7 +102,7 @@ void SynchedEntityData::packAll(IDataOutput& dos) const void SynchedEntityData::assignValues(const ItemsArray& items) { - for (int i = 0; i < items.size(); i++) + for (size_t i = 0; i < items.size(); i++) { DataItem* newItem = items[i]; DataID itemId = newItem->getId(); @@ -113,37 +113,35 @@ void SynchedEntityData::assignValues(const ItemsArray& items) if (!oldItem) continue; - bool result = false; - // ugly switch (newItem->getType()) { case TYPE_INT8: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_INT16: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_INT32: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_FLOAT: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_STRING: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_ITEMINSTANCE: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_TILEPOS: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_INT64: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; case TYPE_VEC3: - result = set(itemId, newItem->getData()); + set(itemId, newItem->getData()); break; default: continue; @@ -204,7 +202,7 @@ void SynchedEntityData::_WriteDataItem(IDataOutput& dos, const DataItem& dataIte void SynchedEntityData::Pack(const ItemsArray& items, IDataOutput& dos) { - for (int i = 0; i < items.size(); i++) + for (size_t i = 0; i < items.size(); i++) { const DataItem* item = items[i]; if (item) diff --git a/source/world/item/Inventory.cpp b/source/world/item/Inventory.cpp index 334d2e989..1e1bda41d 100644 --- a/source/world/item/Inventory.cpp +++ b/source/world/item/Inventory.cpp @@ -234,7 +234,7 @@ void Inventory::release(int slotNo) void Inventory::empty() { - for (int i = 0; i < m_items.size(); i++) + for (size_t i = 0; i < m_items.size(); i++) { release(i); m_items[i] = nullptr; @@ -243,7 +243,7 @@ void Inventory::empty() void Inventory::clear() { - for (int i = 0; i < m_items.size(); i++) + for (size_t i = 0; i < m_items.size(); i++) { release(i); } @@ -320,7 +320,7 @@ bool Inventory::addItem(ItemInstance& instance) // Doesn't exist in PE void Inventory::tick() { - for (int i = 0; i < m_items.size(); i++) + for (size_t i = 0; i < m_items.size(); i++) { ItemInstance* item = m_items[i]; @@ -430,7 +430,7 @@ int Inventory::getSelectedItemId() const void Inventory::setItem(int index, ItemInstance* item) { - if (index >= m_items.size()) + if ((size_t)index >= m_items.size()) { //m_armor[index - m_items.size()] = item; } @@ -554,7 +554,7 @@ void Inventory::save(ListTag& tag) const if (_getGameMode() == GAME_TYPE_CREATIVE) return; - for (int i = 0; i < m_items.size(); i++) + for (size_t i = 0; i < m_items.size(); i++) { const ItemInstance* item = m_items[i]; @@ -591,7 +591,7 @@ void Inventory::load(const ListTag& tag) for (std::vector::const_iterator it = itemTags.begin(); it != itemTags.end(); it++) { const CompoundTag* itemTag = (const CompoundTag*)*it; - int slot = itemTag->getInt8("Slot") & 255; + uint8_t slot = itemTag->getInt8("Slot") & 255; ItemInstance* item = ItemInstance::fromTag(*itemTag); if (item) { diff --git a/source/world/level/Explosion.cpp b/source/world/level/Explosion.cpp index d5c3935a3..88dad14ef 100644 --- a/source/world/level/Explosion.cpp +++ b/source/world/level/Explosion.cpp @@ -82,7 +82,7 @@ void Explosion::explode() AABB aabb(m_pos - m_power - 1.0f, m_pos + m_power + 1.0f); EntityVector ents = m_pLevel->getEntities(m_pEntity, aabb); - for (int i = 0; i < ents.size(); i++) + for (size_t i = 0; i < ents.size(); i++) { Entity* entity = ents.at(i); float distPowerRatio = entity->distanceTo(m_pos) / m_power; diff --git a/source/world/level/Level.cpp b/source/world/level/Level.cpp index 3e14122b7..ada020483 100644 --- a/source/world/level/Level.cpp +++ b/source/world/level/Level.cpp @@ -74,7 +74,7 @@ Level::~Level() SAFE_DELETE(m_pPathFinder); const size_t size = m_entities.size(); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { Entity* pEnt = m_entities.at(i); diff --git a/source/world/level/levelgen/chunk/RandomLevelSource.cpp b/source/world/level/levelgen/chunk/RandomLevelSource.cpp index f666b6aa9..1908668f1 100644 --- a/source/world/level/levelgen/chunk/RandomLevelSource.cpp +++ b/source/world/level/levelgen/chunk/RandomLevelSource.cpp @@ -52,6 +52,7 @@ RandomLevelSource::RandomLevelSource(Level* level, int32_t seed, int version) : Random random = m_random; LOG_I("random.get : %d", random.genrand_int32() >> 1); + (void)random; // compiler will sometimes warn about unused variable if this isn't here } // @BUG: Potential collisions. diff --git a/source/world/level/storage/ExternalFileLevelStorage.cpp b/source/world/level/storage/ExternalFileLevelStorage.cpp index e354c296a..702dc9c12 100644 --- a/source/world/level/storage/ExternalFileLevelStorage.cpp +++ b/source/world/level/storage/ExternalFileLevelStorage.cpp @@ -282,7 +282,7 @@ void ExternalFileLevelStorage::loadEntities(Level* level, LevelChunk* chunk) long v7 = ftell(pFile); fseek(pFile, v6, 0); - if (size <= v7 - v6 && size > 0) + if (size <= (unsigned int)(v7 - v6) && size > 0) { uint8_t* data = new uint8_t[size]; fread(data, 1, size, pFile); @@ -412,7 +412,7 @@ bool ExternalFileLevelStorage::readLevelData(const std::string& path, LevelData& uint8_t* data = new uint8_t[length]; - if (fread(data, sizeof(uint8_t), length, pFile) != length) + if (fread(data, sizeof(uint8_t), length, pFile) != (size_t)length) { SAFE_DELETE_ARRAY(data); goto _cleanup; @@ -451,7 +451,7 @@ bool ExternalFileLevelStorage::readPlayerData(const std::string& path, LevelData if (nPlayers != 1) goto _cleanup; - if (fread(&levelData.m_LocalPlayerData, 1, sizeof levelData.m_LocalPlayerData, pFile) == size) + if (fread(&levelData.m_LocalPlayerData, 1, sizeof levelData.m_LocalPlayerData, pFile) == (size_t)size) levelData.m_nPlayers = nPlayers; fclose(pFile); diff --git a/source/world/level/storage/ExternalFileLevelStorageSource.cpp b/source/world/level/storage/ExternalFileLevelStorageSource.cpp index 283726b5d..435e845c2 100644 --- a/source/world/level/storage/ExternalFileLevelStorageSource.cpp +++ b/source/world/level/storage/ExternalFileLevelStorageSource.cpp @@ -112,7 +112,7 @@ void ExternalFileLevelStorageSource::renameLevel(const std::string& oldName, con return; std::string levelName = Util::stringTrim(newName); - for (int i = 0; i < sizeof(g_EFLSSFilterArray); i++) + for (size_t i = 0; i < sizeof(g_EFLSSFilterArray); i++) { std::string str; str.push_back(g_EFLSSFilterArray[i]); @@ -125,7 +125,7 @@ void ExternalFileLevelStorageSource::renameLevel(const std::string& oldName, con std::set maps; const size_t size = vls.size(); - for (int i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) maps.insert(vls.at(i).m_fileName); std::string levelUniqueName = levelName; diff --git a/source/world/level/storage/RegionFile.cpp b/source/world/level/storage/RegionFile.cpp index 3fbf0fca4..39783a3a0 100644 --- a/source/world/level/storage/RegionFile.cpp +++ b/source/world/level/storage/RegionFile.cpp @@ -81,13 +81,12 @@ bool RegionFile::readChunk(const ChunkPos& pos, RakNet::BitStream** pBitStream) return false; int thing = (idx >> 8); - int offset = (idx & 0xFF); int length = 0; fseek(m_pFile, thing * SECTOR_BYTES, SEEK_SET); fread(&length, sizeof(int), 1, m_pFile); - assert(length < ((offset & 0xff) * SECTOR_BYTES)); + assert(length < ((idx & 0xff) * SECTOR_BYTES)); length -= 4; diff --git a/source/world/particle/ParticleEngine.cpp b/source/world/particle/ParticleEngine.cpp index f57c7c59f..c10e18fdc 100644 --- a/source/world/particle/ParticleEngine.cpp +++ b/source/world/particle/ParticleEngine.cpp @@ -194,7 +194,7 @@ void ParticleEngine::renderLit(const Entity& camera, float a) { Tesselator& t = Tesselator::instance; - for (int i = 0; i < m_particles[tt].size(); ++i) + for (size_t i = 0; i < m_particles[tt].size(); ++i) { Particle* p = m_particles[tt].at(i); p->render(t, a, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); diff --git a/source/world/tile/Tile.hpp b/source/world/tile/Tile.hpp index feac3f2b1..01690bd16 100644 --- a/source/world/tile/Tile.hpp +++ b/source/world/tile/Tile.hpp @@ -56,7 +56,10 @@ class Tile virtual ~Tile(); virtual bool isCubeShaped() const; virtual eRenderShape getRenderShape() const; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverloaded-virtual" virtual Tile* setShape(float, float, float, float, float, float); +#pragma GCC diagnostic pop virtual void updateShape(const LevelSource*, const TilePos& pos); virtual void updateDefaultShape(); virtual void addLights(Level*, const TilePos& pos); @@ -278,4 +281,4 @@ class FullTile public: TileID getTypeId() const { return _tileType->m_ID; } Tile* getType() const { return _tileType; } -}; \ No newline at end of file +}; diff --git a/thirdparty/GL/GL.hpp b/thirdparty/GL/GL.hpp index cf5c3c6c9..a539136a5 100644 --- a/thirdparty/GL/GL.hpp +++ b/thirdparty/GL/GL.hpp @@ -79,7 +79,7 @@ #include // it'll include from a different dir, namely thirdparty/GL/glext.h #endif - #ifdef _WIN32 + #ifdef _MSVC_VER #pragma comment(lib, "opengl32.lib") #pragma comment(lib, "glu32.lib") #endif diff --git a/thirdparty/SDL/SDL.h b/thirdparty/SDL/SDL.h index 7af64aa82..e25fcd2e6 100644 --- a/thirdparty/SDL/SDL.h +++ b/thirdparty/SDL/SDL.h @@ -2,7 +2,7 @@ #if (defined(_WIN32) || defined(USE_SDL1)) #ifdef _WIN32 - #ifndef __clang__ + #ifdef _MSVC_VER #ifdef USE_SDL1 #pragma comment(lib, "SDL.lib") #else @@ -16,4 +16,4 @@ #endif #else #include -#endif \ No newline at end of file +#endif diff --git a/thirdparty/SDL/SDL_opengl.h b/thirdparty/SDL/SDL_opengl.h index a8a634f71..9f9b4b1af 100644 --- a/thirdparty/SDL/SDL_opengl.h +++ b/thirdparty/SDL/SDL_opengl.h @@ -2,7 +2,7 @@ #if (defined(_WIN32) || defined(USE_SDL1)) #ifdef _WIN32 - #ifndef __clang__ + #ifdef _MSVC_VER #ifdef USE_SDL1 #pragma comment(lib, "SDL.lib") #else @@ -15,4 +15,4 @@ #endif #else #include -#endif \ No newline at end of file +#endif diff --git a/thirdparty/raknet/DS_LinkedList.h b/thirdparty/raknet/DS_LinkedList.h index 138c72f9b..4d2bba27d 100644 --- a/thirdparty/raknet/DS_LinkedList.h +++ b/thirdparty/raknet/DS_LinkedList.h @@ -983,9 +983,9 @@ namespace DataStructures while ( current != this->root ); } - this->list_size = 0; - this->root = 0; - this->position = 0; + this->list_size = 0; + this->root = 0; + this->position = 0; } template diff --git a/thirdparty/raknet/DS_OrderedList.h b/thirdparty/raknet/DS_OrderedList.h index 22a2e97d0..e39eae0a2 100644 --- a/thirdparty/raknet/DS_OrderedList.h +++ b/thirdparty/raknet/DS_OrderedList.h @@ -27,7 +27,9 @@ namespace DataStructures template int defaultOrderedListComparison(const key_type &a, const data_type &b) { - if (a