From cd23817bf1884fee4457ab3381320b0c8fc33f48 Mon Sep 17 00:00:00 2001 From: Kai Blaschke Date: Wed, 28 Feb 2024 18:11:55 +0100 Subject: [PATCH] Fixed remaining compiler warnings Some warnings (e.g. in Opus and the tests) can't be fixed, only suppressed. --- .../application/StarMainApplication_sdl.cpp | 2 +- .../StarP2PNetworkingService_pc.cpp | 2 +- .../application/StarPlatformServices_pc.cpp | 2 +- source/application/StarRenderer_opengl20.cpp | 5 +- source/base/StarAssets.cpp | 4 +- source/base/StarMixer.cpp | 2 +- source/client/StarClientApplication.cpp | 5 +- source/core/StarFont.cpp | 2 +- source/core/StarImageProcessing.cpp | 4 +- source/core/StarLuaConverters.cpp | 2 +- source/frontend/StarActionBar.cpp | 2 +- source/frontend/StarChatBubbleSeparation.hpp | 3 +- source/frontend/StarCinematic.cpp | 2 +- source/frontend/StarCodexInterface.cpp | 2 +- source/frontend/StarMainInterface.cpp | 8 +- source/frontend/StarTeamBar.cpp | 3 - source/frontend/StarTeleportDialog.cpp | 2 +- source/frontend/StarVoice.cpp | 8 +- source/frontend/StarWireInterface.cpp | 2 +- source/game/StarActorMovementController.cpp | 7 +- source/game/StarDrawable.cpp | 4 +- source/game/StarHumanoid.cpp | 2 +- source/game/StarImageMetadataDatabase.cpp | 2 +- source/game/StarMovementController.cpp | 5 +- source/game/StarPlayer.cpp | 2 +- source/game/StarPlayerInventory.cpp | 2 +- source/game/StarStatCollection.cpp | 2 +- source/game/StarSystemWorldServerThread.cpp | 2 +- source/game/StarToolUser.cpp | 2 +- source/game/StarUniverseClient.cpp | 2 +- source/game/StarWorldClient.cpp | 3 +- source/game/StarWorldImpl.hpp | 8 +- source/game/StarWorldLayout.cpp | 2 +- source/game/StarWorldParameters.cpp | 107 +++++++----------- source/game/StarWorldParameters.hpp | 92 +++++++-------- source/game/StarWorldServer.cpp | 3 +- source/game/StarWorldStorage.cpp | 2 - source/game/interfaces/StarEntity.cpp | 2 +- source/game/interfaces/StarToolUserItem.cpp | 2 +- source/game/items/StarArmors.cpp | 4 +- source/game/items/StarInspectionTool.cpp | 2 +- source/game/items/StarInstrumentItem.cpp | 2 +- source/game/items/StarMaterialItem.cpp | 8 +- source/game/items/StarUnlockItem.cpp | 2 +- .../game/scripting/StarLuaGameConverters.cpp | 2 +- source/rendering/StarTextPainter.cpp | 4 - source/windowing/StarPane.cpp | 2 +- source/windowing/StarScrollArea.cpp | 2 +- source/windowing/StarVerticalLayout.cpp | 2 +- 49 files changed, 148 insertions(+), 197 deletions(-) diff --git a/source/application/StarMainApplication_sdl.cpp b/source/application/StarMainApplication_sdl.cpp index 08d3813..b98da46 100644 --- a/source/application/StarMainApplication_sdl.cpp +++ b/source/application/StarMainApplication_sdl.cpp @@ -819,7 +819,7 @@ private: auto newImage = std::make_shared(processImageOperations(operations, *image)); // Fix fully transparent pixels inverting the underlying display pixel on Windows (allowing this could be made configurable per cursor later!) - newImage->forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) { if (!pixel[3]) pixel[0] = pixel[1] = pixel[2] = 0; }); + newImage->forEachPixel([](unsigned /*x*/, unsigned /*y*/, Vec4B& pixel) { if (!pixel[3]) pixel[0] = pixel[1] = pixel[2] = 0; }); entry->image = std::move(newImage); diff --git a/source/application/StarP2PNetworkingService_pc.cpp b/source/application/StarP2PNetworkingService_pc.cpp index f13bb62..5bb99f9 100644 --- a/source/application/StarP2PNetworkingService_pc.cpp +++ b/source/application/StarP2PNetworkingService_pc.cpp @@ -81,7 +81,7 @@ void PcP2PNetworkingService::setJoinRemote(HostAddressWithPort location) { setJoinLocation(JoinRemote(location)); } -void Star::PcP2PNetworkingService::setActivityData(String const& title, Maybe> party) { +void Star::PcP2PNetworkingService::setActivityData(String const&, Maybe>) { #ifdef STAR_ENABLE_DISCORD_INTEGRATION MutexLocker discordLocker(m_state->discordMutex); #endif diff --git a/source/application/StarPlatformServices_pc.cpp b/source/application/StarPlatformServices_pc.cpp index 8f940b3..9470201 100644 --- a/source/application/StarPlatformServices_pc.cpp +++ b/source/application/StarPlatformServices_pc.cpp @@ -98,7 +98,7 @@ void PcPlatformServicesState::onGameOverlayActivated(GameOverlayActivated_t* cal } #endif -PcPlatformServicesUPtr PcPlatformServices::create(String const& path, StringList platformArguments) { +PcPlatformServicesUPtr PcPlatformServices::create(String const&, StringList platformArguments) { auto services = unique_ptr(new PcPlatformServices); services->m_state = make_shared(); diff --git a/source/application/StarRenderer_opengl20.cpp b/source/application/StarRenderer_opengl20.cpp index 18f771b..ac141a4 100644 --- a/source/application/StarRenderer_opengl20.cpp +++ b/source/application/StarRenderer_opengl20.cpp @@ -720,7 +720,6 @@ void OpenGl20Renderer::GlRenderBuffer::set(List& primitives) { float textureIndex = 0.0f; Vec2F textureOffset = {}; - Texture* lastTexture = nullptr; for (auto& primitive : primitives) { if (auto tri = primitive.ptr()) { tie(textureIndex, textureOffset) = addCurrentTexture(std::move(tri->texture)); @@ -781,7 +780,7 @@ bool OpenGl20Renderer::logGlErrorSummary(String prefix) { } else { Logger::error(""); } - } while (error = glGetError()); + } while ((error = glGetError())); return true; } return false; @@ -897,8 +896,6 @@ void OpenGl20Renderer::renderGlBuffer(GlRenderBuffer const& renderBuffer, Mat3F //Assumes the passed effect program is currently in use. void OpenGl20Renderer::setupGlUniforms(Effect& effect) { - GLuint program = effect.program; - m_positionAttribute = effect.getAttribute("vertexPosition"); m_texCoordAttribute = effect.getAttribute("vertexTextureCoordinate"); m_texIndexAttribute = effect.getAttribute("vertexTextureIndex"); diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index 135945c..2c3d04b 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -858,7 +858,7 @@ shared_ptr Assets::loadImage(AssetPath const& path) const { for (auto& directives : path.directives.list()) directives.loadOperations(); - path.directives.forEach([&](auto const& entry, Directives const& directives) { + path.directives.forEach([&](auto const& entry, Directives const&) { addImageOperationReferences(entry.operation, referencePaths); }); // TODO: This can definitely be better, was changed quickly to support the new Directives. @@ -875,7 +875,7 @@ shared_ptr Assets::loadImage(AssetPath const& path) const { return unlockDuring([&]() { auto newData = make_shared(); Image newImage = *source->image; - path.directives.forEach([&](auto const& entry, Directives const& directives) { + path.directives.forEach([&](auto const& entry, Directives const&) { if (auto error = entry.operation.template ptr()) std::rethrow_exception(error->exception); else diff --git a/source/base/StarMixer.cpp b/source/base/StarMixer.cpp index be0bea8..2e52afc 100644 --- a/source/base/StarMixer.cpp +++ b/source/base/StarMixer.cpp @@ -473,7 +473,7 @@ void Mixer::setGroupVolume(MixerGroup group, float targetValue, float rampTime) } } -void Mixer::update(float dt, PositionalAttenuationFunction positionalAttenuationFunction) { +void Mixer::update(float, PositionalAttenuationFunction positionalAttenuationFunction) { { MutexLocker locker(m_queueMutex); eraseWhere(m_audios, [&](auto& p) { diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index d44bd6e..8967534 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -333,7 +333,6 @@ void ClientApplication::processInput(InputEvent const& event) { } m_input->handleInput(event, processed); - WorldCamera& camera = m_worldPainter->camera(); auto config = m_root->configuration(); int zoomOffset = 0; @@ -709,7 +708,7 @@ void ClientApplication::updateMods(float dt) { } } -void ClientApplication::updateModsWarning(float dt) { +void ClientApplication::updateModsWarning(float) { if (m_errorScreen->accepted()) changeState(MainAppState::Splash); } @@ -720,7 +719,7 @@ void ClientApplication::updateSplash(float dt) { changeState(MainAppState::Title); } -void ClientApplication::updateError(float dt) { +void ClientApplication::updateError(float) { if (m_errorScreen->accepted()) changeState(MainAppState::Title); } diff --git a/source/core/StarFont.cpp b/source/core/StarFont.cpp index 8113cf9..82151e3 100644 --- a/source/core/StarFont.cpp +++ b/source/core/StarFont.cpp @@ -115,7 +115,7 @@ std::pair Font::render(String::Char c) { for (unsigned y = 0; y != height; ++y) { uint8_t* p = slot->bitmap.buffer + y * slot->bitmap.pitch; for (unsigned x = 0; x != width; ++x) { - if (x >= 0 && y >= 0 && x < width && y < height) { + if (x < width && y < height) { uint8_t value = *(p + x); if (m_alphaThreshold) { if (value >= m_alphaThreshold) { diff --git a/source/core/StarImageProcessing.cpp b/source/core/StarImageProcessing.cpp index a98e7e5..f3a3108 100644 --- a/source/core/StarImageProcessing.cpp +++ b/source/core/StarImageProcessing.cpp @@ -182,7 +182,7 @@ ImageOperation imageOperationFromString(StringView string) { c[0] |= (c[0] << 4); c[1] |= (c[1] << 4); c[2] |= (c[2] << 4); - c[3] = 255; + c[3] = static_cast(255); } else if (hexLen == 4) { nibbleDecode(hexPtr, 4, c, 4); @@ -193,7 +193,7 @@ ImageOperation imageOperationFromString(StringView string) { } else if (hexLen == 6) { hexDecode(hexPtr, 6, c, 4); - c[3] = 255; + c[3] = static_cast(255); } else if (hexLen == 8) { hexDecode(hexPtr, 8, c, 4); diff --git a/source/core/StarLuaConverters.cpp b/source/core/StarLuaConverters.cpp index e170da5..d361af7 100644 --- a/source/core/StarLuaConverters.cpp +++ b/source/core/StarLuaConverters.cpp @@ -47,7 +47,7 @@ LuaValue LuaConverter::from(LuaEngine& engine, LuaCallbacks const& return table; } -Maybe LuaConverter::to(LuaEngine& engine, LuaValue const& v) { +Maybe LuaConverter::to(LuaEngine&, LuaValue const&) { return {}; } diff --git a/source/frontend/StarActionBar.cpp b/source/frontend/StarActionBar.cpp index 15e1bd5..fb08e3b 100644 --- a/source/frontend/StarActionBar.cpp +++ b/source/frontend/StarActionBar.cpp @@ -196,7 +196,7 @@ bool ActionBar::sendEvent(InputEvent const& event) { return false; } -void ActionBar::update(float dt) { +void ActionBar::update(float) { auto inventory = m_player->inventory(); auto abl = inventory->selectedActionBarLocation(); if (abl.is()) { diff --git a/source/frontend/StarChatBubbleSeparation.hpp b/source/frontend/StarChatBubbleSeparation.hpp index 03571cf..a79f122 100644 --- a/source/frontend/StarChatBubbleSeparation.hpp +++ b/source/frontend/StarChatBubbleSeparation.hpp @@ -169,11 +169,10 @@ void BubbleSeparator::forEach(function func) { } template -void BubbleSeparator::update(float dt) { +void BubbleSeparator::update(float) { m_bubbles.exec([this](Bubble& bubble) { Vec2F delta = bubble.seperatedOffset - bubble.currentOffset; bubble.currentOffset += m_tweenFactor * delta; - bubble.currentPosition = bubble.currentDestination + bubble.currentOffset; }); } diff --git a/source/frontend/StarCinematic.cpp b/source/frontend/StarCinematic.cpp index ade940d..abd638d 100644 --- a/source/frontend/StarCinematic.cpp +++ b/source/frontend/StarCinematic.cpp @@ -102,7 +102,7 @@ void Cinematic::setPlayer(PlayerPtr player) { m_player = player; } -void Cinematic::update(float dt) { +void Cinematic::update(float) { m_currentTimeSkip = {}; for (auto timeSkip : m_timeSkips) { if (currentTimecode() >= timeSkip.availableTime && currentTimecode() < timeSkip.skipToTime) diff --git a/source/frontend/StarCodexInterface.cpp b/source/frontend/StarCodexInterface.cpp index dcd82f3..b773eb5 100644 --- a/source/frontend/StarCodexInterface.cpp +++ b/source/frontend/StarCodexInterface.cpp @@ -50,7 +50,7 @@ void CodexInterface::show() { updateCodexList(); } -void CodexInterface::tick(float dt) { +void CodexInterface::tick(float) { updateCodexList(); } diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp index aa06dc7..193deea 100644 --- a/source/frontend/StarMainInterface.cpp +++ b/source/frontend/StarMainInterface.cpp @@ -1365,11 +1365,9 @@ void MainInterface::renderDebug() { m_debugTextRect = RectF::null(); - counter = 0; - for (auto const& pair : logMapValues) { + for (size_t index = 0; index < logMapValues.size(); ++index) { TextPositioning positioning = { Vec2F(m_config->debugOffset[0], windowHeight() - m_config->debugOffset[1] - m_config->fontSize * interfaceScale() * counter) }; - m_guiContext->renderText(formatted[counter], positioning); - ++counter; + m_guiContext->renderText(formatted[index], positioning); } m_guiContext->setFontSize(8); m_guiContext->setDefaultFont(); @@ -1515,7 +1513,7 @@ bool MainInterface::overButton(PolyI buttonPoly, Vec2I const& mousePos) const { return buttonPoly.contains(mousePos); } -bool MainInterface::overlayClick(Vec2I const& mousePos, MouseButton mouseButton) { +bool MainInterface::overlayClick(Vec2I const& mousePos, MouseButton) { PolyI mainBarPoly = m_config->mainBarPoly; Vec2I barPos = mainBarPosition(); mainBarPoly.translate(barPos); diff --git a/source/frontend/StarTeamBar.cpp b/source/frontend/StarTeamBar.cpp index d0c23c5..0909f9f 100644 --- a/source/frontend/StarTeamBar.cpp +++ b/source/frontend/StarTeamBar.cpp @@ -149,7 +149,6 @@ void TeamBar::buildTeamBar() { Vec2I offset; size_t controlIndex = 0; - size_t memberIndex = 0; float portraitScale = assets->json("/interface/windowconfig/teambar.config:memberPortraitScale").toFloat(); int memberSize = assets->json("/interface/windowconfig/teambar.config:memberSize").toInt(); @@ -158,7 +157,6 @@ void TeamBar::buildTeamBar() { Uuid myUuid = player->clientContext()->playerUuid(); for (auto member : teamClient->members()) { if (member.uuid == myUuid) { - memberIndex++; continue; } @@ -217,7 +215,6 @@ void TeamBar::buildTeamBar() { offset[1] -= memberSpacing; controlIndex++; - memberIndex++; } auto inviteButton = fetchChild("inviteButton"); diff --git a/source/frontend/StarTeleportDialog.cpp b/source/frontend/StarTeleportDialog.cpp index c1ca4b4..7b4030d 100644 --- a/source/frontend/StarTeleportDialog.cpp +++ b/source/frontend/StarTeleportDialog.cpp @@ -120,7 +120,7 @@ TeleportDialog::TeleportDialog(UniverseClientPtr client, fetchChild("btnTeleport")->setEnabled(destList->selectedItem() != NPos); } -void TeleportDialog::tick(float dt) { +void TeleportDialog::tick(float) { if (!m_client->worldClient()->playerCanReachEntity(m_sourceEntityId)) dismiss(); } diff --git a/source/frontend/StarVoice.cpp b/source/frontend/StarVoice.cpp index fc1c5a9..752a7b4 100644 --- a/source/frontend/StarVoice.cpp +++ b/source/frontend/StarVoice.cpp @@ -13,7 +13,6 @@ constexpr int VOICE_SAMPLE_RATE = 48000; constexpr int VOICE_FRAME_SIZE = 960; -constexpr int VOICE_MAX_FRAME_SIZE = 6 * VOICE_FRAME_SIZE; constexpr int VOICE_MAX_PACKET_SIZE = 3 * 1276; constexpr uint16_t VOICE_VERSION = 1; @@ -421,7 +420,7 @@ void Voice::mix(int16_t* buffer, size_t frameCount, unsigned channels) { } } -void Voice::update(float dt, PositionalAttenuationFunction positionalAttenuationFunction) { +void Voice::update(float, PositionalAttenuationFunction positionalAttenuationFunction) { for (auto& entry : m_speakers) { if (SpeakerPtr& speaker = entry.second) { if (positionalAttenuationFunction) { @@ -465,7 +464,7 @@ StringList Voice::availableDevices() { StringList deviceList; if (devices > 0) { deviceList.reserve(devices); - for (size_t i = 0; i != devices; ++i) + for (int i = 0; i != devices; ++i) deviceList.emplace_back(SDL_GetAudioDeviceName(i, 1)); } deviceList.sort(); @@ -482,7 +481,6 @@ int Voice::send(DataStreamBuffer& out, size_t budget) { return 0; std::vector encodedChunks = std::move(m_encodedChunks); - size_t encodedChunksLength = m_encodedChunksLength; m_encodedChunksLength = 0; encodeLock.unlock(); @@ -642,7 +640,7 @@ void Voice::closeDevice() { m_deviceOpen = false; } -bool Voice::playSpeaker(SpeakerPtr const& speaker, int channels) { +bool Voice::playSpeaker(SpeakerPtr const& speaker, int) { if (speaker->playing || speaker->audioStream->samples.size() < speaker->minimumPlaySamples) return false; diff --git a/source/frontend/StarWireInterface.cpp b/source/frontend/StarWireInterface.cpp index 61506fe..9d34a5b 100644 --- a/source/frontend/StarWireInterface.cpp +++ b/source/frontend/StarWireInterface.cpp @@ -35,7 +35,7 @@ void WirePane::reset() { m_connecting = false; } -void WirePane::update(float dt) { +void WirePane::update(float) { if (!active()) return; if (!m_worldClient->inWorld()) { diff --git a/source/game/StarActorMovementController.cpp b/source/game/StarActorMovementController.cpp index 00e3726..0badc7a 100644 --- a/source/game/StarActorMovementController.cpp +++ b/source/game/StarActorMovementController.cpp @@ -664,7 +664,7 @@ void ActorMovementController::controlFly(Vec2F const& velocity) { m_controlFly = velocity; } -Maybe> ActorMovementController::pathMove(Vec2F const& position, bool run, Maybe const& parameters) { +Maybe> ActorMovementController::pathMove(Vec2F const& position, bool, Maybe const& parameters) { if (!m_pathController) m_pathController = make_shared(world()); @@ -1214,7 +1214,7 @@ Maybe PathController::findPath(ActorMovementController& movementController if (!merged) { // try to splice the new path onto the current path auto& newPathStart = path.at(0); - for (size_t i = m_edgeIndex; i < m_path->size(); ++i) { + for (size_t i = m_edgeIndex; i < m_path->size(); i += 2) { auto& edge = m_path->at(i); if (edge.target.position == newPathStart.source.position) { // splice the new path onto our current path up to this index @@ -1228,7 +1228,6 @@ Maybe PathController::findPath(ActorMovementController& movementController merged = true; break; } - i++; } } } @@ -1456,7 +1455,7 @@ bool PathController::validateEdge(ActorMovementController& movementController, P bool PathController::movingCollision(ActorMovementController& movementController, PolyF const& collisionPoly) { bool collided = false; - movementController.forEachMovingCollision(collisionPoly.boundBox(), [&](MovingCollisionId id, PhysicsMovingCollision mc, PolyF poly, RectF bounds) { + movementController.forEachMovingCollision(collisionPoly.boundBox(), [&](MovingCollisionId, PhysicsMovingCollision, PolyF poly, RectF) { if (poly.intersects(collisionPoly)) { // set collided and stop iterating collided = true; diff --git a/source/game/StarDrawable.cpp b/source/game/StarDrawable.cpp index 2c527a5..a3826e0 100644 --- a/source/game/StarDrawable.cpp +++ b/source/game/StarDrawable.cpp @@ -70,7 +70,7 @@ Drawable::ImagePart& Drawable::ImagePart::removeDirectives(bool keepImageCenterP Drawable Drawable::makeLine(Line2F const& line, float lineWidth, Color const& color, Vec2F const& position) { Drawable drawable; - drawable.part = LinePart{std::move(line), lineWidth}; + drawable.part = LinePart{std::move(line), lineWidth, {}}; drawable.color = color; drawable.position = position; @@ -110,7 +110,7 @@ Drawable::Drawable() Drawable::Drawable(Json const& json) { if (auto line = json.opt("line")) { - part = LinePart{jsonToLine2F(*line), json.getFloat("width")}; + part = LinePart{jsonToLine2F(*line), json.getFloat("width"), {}}; } else if (auto poly = json.opt("poly")) { part = PolyPart{jsonToPolyF(*poly)}; } else if (auto image = json.opt("image")) { diff --git a/source/game/StarHumanoid.cpp b/source/game/StarHumanoid.cpp index 78b615b..c69872b 100644 --- a/source/game/StarHumanoid.cpp +++ b/source/game/StarHumanoid.cpp @@ -935,7 +935,7 @@ List Humanoid::renderSkull() const { Root::singleton().speciesDatabase()->species(m_identity.species)->skull(), 1.0f, true, Vec2F())}; } -Humanoid Humanoid::makeDummy(Gender gender) { +Humanoid Humanoid::makeDummy(Gender) { auto assets = Root::singleton().assets(); Humanoid humanoid(assets->json("/humanoid.config")); diff --git a/source/game/StarImageMetadataDatabase.cpp b/source/game/StarImageMetadataDatabase.cpp index 47ff97f..b3a3983 100644 --- a/source/game/StarImageMetadataDatabase.cpp +++ b/source/game/StarImageMetadataDatabase.cpp @@ -238,7 +238,7 @@ Vec2U ImageMetadataDatabase::calculateImageSize(AssetPath const& path) const { for (auto& directives : path.directives.list()) directives.loadOperations(); - bool complete = path.directives.forEachAbortable([&](auto const& entry, Directives const& directives) -> bool { + bool complete = path.directives.forEachAbortable([&](auto const& entry, Directives const&) -> bool { entry.operation.call(osa); return !osa.hasError; }); diff --git a/source/game/StarMovementController.cpp b/source/game/StarMovementController.cpp index 88ac69f..a06ead5 100644 --- a/source/game/StarMovementController.cpp +++ b/source/game/StarMovementController.cpp @@ -624,9 +624,7 @@ void MovementController::tickMaster(float dt) { Vec2F newVelocity = relativeVelocity + m_surfaceVelocity; - Vec2F pos = position(); PolyF body = collisionBody(); - RectF boundBox = body.boundBox(); updateLiquidPercentage(); @@ -736,7 +734,7 @@ void MovementController::forEachMovingCollision(RectF const& region, functiongeometry(); auto pos = position(); auto body = collisionBody(); @@ -804,7 +802,6 @@ void MovementController::updateForceRegions(float dt) { } void MovementController::updateLiquidPercentage() { - auto geometry = world()->geometry(); auto pos = position(); auto body = collisionBody(); RectF boundBox = body.boundBox(); diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp index ebadf20..adf3334 100644 --- a/source/game/StarPlayer.cpp +++ b/source/game/StarPlayer.cpp @@ -2186,7 +2186,7 @@ Maybe Player::inspectionLogName() const { return identifier; } -Maybe Player::inspectionDescription(String const& species) const { +Maybe Player::inspectionDescription(String const&) const { return m_description; } diff --git a/source/game/StarPlayerInventory.cpp b/source/game/StarPlayerInventory.cpp index d7ba6a1..b6c4af3 100644 --- a/source/game/StarPlayerInventory.cpp +++ b/source/game/StarPlayerInventory.cpp @@ -444,7 +444,7 @@ void PlayerInventory::condenseBagStacks(String const& bagType) {\ bag->condenseStacks(); - m_customBar.forEach([&](auto const& index, CustomBarLink& link) { + m_customBar.forEach([&](auto const&, CustomBarLink& link) { if (link.first) { if (auto bs = link.first->ptr()) { if (bs->first == bagType && !bag->at(bs->second)) diff --git a/source/game/StarStatCollection.cpp b/source/game/StarStatCollection.cpp index 6ded538..a12256f 100644 --- a/source/game/StarStatCollection.cpp +++ b/source/game/StarStatCollection.cpp @@ -157,7 +157,7 @@ void StatCollection::tickMaster(float dt) { m_stats.update(dt); } -void StatCollection::tickSlave(float dt) { +void StatCollection::tickSlave(float) { m_stats.update(0.0f); } diff --git a/source/game/StarSystemWorldServerThread.cpp b/source/game/StarSystemWorldServerThread.cpp index 3ec26a7..281ae3e 100644 --- a/source/game/StarSystemWorldServerThread.cpp +++ b/source/game/StarSystemWorldServerThread.cpp @@ -7,7 +7,7 @@ namespace Star { SystemWorldServerThread::SystemWorldServerThread(Vec3I const& location, SystemWorldServerPtr systemWorld, String storageFile) : Thread(strf("SystemWorldServer: {}", location)) , m_systemLocation(location) - , m_systemWorld(move(systemWorld)) + , m_systemWorld(std::move(systemWorld)) , m_storageFile(storageFile) { } diff --git a/source/game/StarToolUser.cpp b/source/game/StarToolUser.cpp index c9bd068..4951128 100644 --- a/source/game/StarToolUser.cpp +++ b/source/game/StarToolUser.cpp @@ -524,7 +524,7 @@ List ToolUser::forceRegions() const { return ds; } -void ToolUser::render(RenderCallback* renderCallback, bool inToolRange, bool shifting, EntityRenderLayer renderLayer) { +void ToolUser::render(RenderCallback* renderCallback, bool, bool shifting, EntityRenderLayer renderLayer) { if (m_suppress.get()) { for (auto item : {m_primaryHandItem.get(), m_altHandItem.get()}) { if (auto activeItem = as(item)) { diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp index 6f089d4..72dd6a0 100644 --- a/source/game/StarUniverseClient.cpp +++ b/source/game/StarUniverseClient.cpp @@ -487,7 +487,7 @@ void UniverseClient::stopLua() { m_scriptContexts.clear(); } -bool UniverseClient::reloadPlayer(Json const& data, Uuid const& uuid, bool resetInterfaces, bool showIndicator) { +bool UniverseClient::reloadPlayer(Json const& data, Uuid const&, bool resetInterfaces, bool showIndicator) { auto player = mainPlayer(); bool playerInWorld = player->inWorld(); auto world = as(player->world()); diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp index b4244b0..ca99165 100644 --- a/source/game/StarWorldClient.cpp +++ b/source/game/StarWorldClient.cpp @@ -1369,7 +1369,6 @@ void WorldClient::collectLiquid(List const& tilePositions, LiquidId liqui return; float bucketSize = Root::singleton().assets()->json("/items/defaultParameters.config:liquidItems.bucketSize").toFloat(); - unsigned drainedUnits = 0; float nextUnit = bucketSize; List maybeDrainTiles; @@ -1386,7 +1385,7 @@ void WorldClient::collectLiquid(List const& tilePositions, LiquidId liqui liquid.take(nextUnit); nextUnit = bucketSize; - for (auto& previousTile : maybeDrainTiles) + for (size_t i = 0; i < maybeDrainTiles.size(); ++i) m_predictedTiles[pos].liquid.emplace(EmptyLiquidId, 0.0f); maybeDrainTiles.clear(); diff --git a/source/game/StarWorldImpl.hpp b/source/game/StarWorldImpl.hpp index 1a4a509..828ed1e 100644 --- a/source/game/StarWorldImpl.hpp +++ b/source/game/StarWorldImpl.hpp @@ -92,7 +92,7 @@ namespace WorldImpl { } template - CollisionKind tileCollisionKind(shared_ptr const& tileSectorArray, EntityMapPtr const& entityMap, + CollisionKind tileCollisionKind(shared_ptr const& tileSectorArray, EntityMapPtr const&, Vec2I const& pos) { return tileSectorArray->tile(pos).collision; } @@ -226,7 +226,7 @@ namespace WorldImpl { if (!isRealMaterial(material)) return false; - auto isAdjacentToConnectable = [&](Vec2I const& pos, unsigned distance, bool foreground) { + auto isAdjacentToConnectable = [&](Vec2I const& pos, int distance, bool foreground) { if (pos.y() - distance < 0) return true; @@ -237,7 +237,7 @@ namespace WorldImpl { for (int x = pos.x() - distance; x != maxX; ++x) { tPos[0] = x; if (tPos != pos) { - auto& tile = getTile(tPos); + const auto& tile = getTile(tPos); if (isConnectableMaterial(foreground ? tile.foreground : tile.background)) return true; } @@ -286,7 +286,7 @@ namespace WorldImpl { if (!materialDatabase->canPlaceInLayer(material, layer)) return false; - auto& tile = getTile(pos); + const auto& tile = getTile(pos); if (layer == TileLayer::Background) { if (tile.background != EmptyMaterialId && tile.background != ObjectPlatformMaterialId) return false; diff --git a/source/game/StarWorldLayout.cpp b/source/game/StarWorldLayout.cpp index 58eca08..fd73190 100644 --- a/source/game/StarWorldLayout.cpp +++ b/source/game/StarWorldLayout.cpp @@ -629,7 +629,7 @@ void WorldLayout::expandBiomeRegion(Vec2I const& position, int newWidth) { pair WorldLayout::findLayerAndCell(int x, int y) const { // find the target layer - size_t targetLayerIndex; + size_t targetLayerIndex{}; for (size_t i = 0; i < m_layers.size(); ++i) { if (m_layers[i].yStart < y) targetLayerIndex = i; diff --git a/source/game/StarWorldParameters.cpp b/source/game/StarWorldParameters.cpp index 97f0611..01d497a 100644 --- a/source/game/StarWorldParameters.cpp +++ b/source/game/StarWorldParameters.cpp @@ -25,19 +25,6 @@ EnumMap const WorldEdgeForceRegionTypeNames{ {WorldEdgeForceRegionType::Bottom, "Bottom"}, {WorldEdgeForceRegionType::TopAndBottom, "TopAndBottom"}}; -VisitableWorldParameters::VisitableWorldParameters() { - threatLevel = 0; - gravity = 0; - airless = false; - disableDeathDrops = false; - terraformed = false; - worldEdgeForceRegions = WorldEdgeForceRegionType::None; -} - -VisitableWorldParameters::VisitableWorldParameters(VisitableWorldParameters const& visitableWorldParameters) { - *this = visitableWorldParameters; -} - VisitableWorldParameters::VisitableWorldParameters(Json const& store) { typeName = store.getString("typeName", ""); threatLevel = store.getFloat("threatLevel"); @@ -54,8 +41,6 @@ VisitableWorldParameters::VisitableWorldParameters(Json const& store) { worldEdgeForceRegions = WorldEdgeForceRegionTypeNames.getLeft(store.getString("worldEdgeForceRegions", "None")); } -VisitableWorldParameters::~VisitableWorldParameters() {} - Json VisitableWorldParameters::store() const { return JsonObject{{"typeName", typeName}, {"threatLevel", threatLevel}, @@ -104,15 +89,6 @@ void VisitableWorldParameters::write(DataStream& ds) const { ds << worldEdgeForceRegions; } -TerrestrialWorldParameters::TerrestrialWorldParameters() { - blendSize = 0; - dayLength = 0; -} - -TerrestrialWorldParameters::TerrestrialWorldParameters(TerrestrialWorldParameters const& terrestrialWorldParameters) { - *this = terrestrialWorldParameters; -} - TerrestrialWorldParameters::TerrestrialWorldParameters(Json const& store) : VisitableWorldParameters(store) { auto loadTerrestrialRegion = [](Json const& config) { return TerrestrialRegion{config.getString("biome"), @@ -122,19 +98,19 @@ TerrestrialWorldParameters::TerrestrialWorldParameters(Json const& store) : Visi config.getString("fgOreSelector"), config.getString("bgOreSelector"), config.getString("subBlockSelector"), - (LiquidId)config.getUInt("caveLiquid"), + static_cast(config.getUInt("caveLiquid")), config.getFloat("caveLiquidSeedDensity"), - (LiquidId)config.getUInt("oceanLiquid"), - (int)config.getInt("oceanLiquidLevel"), - (bool)config.getBool("encloseLiquids"), - (bool)config.getBool("fillMicrodungeons")}; + static_cast(config.getUInt("oceanLiquid")), + static_cast(config.getInt("oceanLiquidLevel")), + config.getBool("encloseLiquids"), + config.getBool("fillMicrodungeons")}; }; auto loadTerrestrialLayer = [loadTerrestrialRegion](Json const& config) { - return TerrestrialLayer{(int)config.getInt("layerMinHeight"), - (int)config.getInt("layerBaseHeight"), + return TerrestrialLayer{static_cast(config.getInt("layerMinHeight")), + static_cast(config.getInt("layerBaseHeight")), jsonToStringList(config.get("dungeons")), - (int)config.getInt("dungeonXVariance"), + static_cast(config.getInt("dungeonXVariance")), loadTerrestrialRegion(config.get("primaryRegion")), loadTerrestrialRegion(config.get("primarySubRegion")), config.getArray("secondaryRegions").transformed(loadTerrestrialRegion), @@ -333,14 +309,11 @@ void TerrestrialWorldParameters::write(DataStream& ds) const { AsteroidsWorldParameters::AsteroidsWorldParameters() { airless = true; - asteroidTopLevel = 0; - asteroidBottomLevel = 0; - blendSize = 0; } AsteroidsWorldParameters::AsteroidsWorldParameters(Json const& store) : VisitableWorldParameters(store) { - asteroidTopLevel = store.getInt("asteroidTopLevel"); - asteroidBottomLevel = store.getInt("asteroidBottomLevel"); + asteroidTopLevel = static_cast(store.getInt("asteroidTopLevel")); + asteroidBottomLevel = static_cast(store.getInt("asteroidBottomLevel")); blendSize = store.getFloat("blendSize"); asteroidBiome = store.getString("asteroidBiome"); ambientLightLevel = jsonToColor(store.get("ambientLightLevel")); @@ -376,12 +349,10 @@ void AsteroidsWorldParameters::write(DataStream& ds) const { ds << ambientLightLevel; } -FloatingDungeonWorldParameters::FloatingDungeonWorldParameters() {} - FloatingDungeonWorldParameters::FloatingDungeonWorldParameters(Json const& store) : VisitableWorldParameters(store) { - dungeonBaseHeight = store.getInt("dungeonBaseHeight"); - dungeonSurfaceHeight = store.getInt("dungeonSurfaceHeight"); - dungeonUndergroundLevel = store.getInt("dungeonUndergroundLevel"); + dungeonBaseHeight = static_cast(store.getInt("dungeonBaseHeight")); + dungeonSurfaceHeight = static_cast(store.getInt("dungeonSurfaceHeight")); + dungeonUndergroundLevel = static_cast(store.getInt("dungeonUndergroundLevel")); primaryDungeon = store.getString("primaryDungeon"); biome = store.optString("biome"); ambientLightLevel = jsonToColor(store.get("ambientLightLevel")); @@ -438,7 +409,7 @@ void FloatingDungeonWorldParameters::write(DataStream& ds) const { Json diskStoreVisitableWorldParameters(VisitableWorldParametersConstPtr const& parameters) { if (!parameters) - return Json(); + return {}; return parameters->store().setAll({{"type", WorldParametersTypeNames.getRight(parameters->type())}}); } @@ -459,7 +430,7 @@ VisitableWorldParametersPtr diskLoadVisitableWorldParameters(Json const& store) ByteArray netStoreVisitableWorldParameters(VisitableWorldParametersConstPtr const& parameters) { if (!parameters) - return ByteArray(); + return {}; DataStreamBuffer ds; ds.write(parameters->type()); @@ -509,7 +480,7 @@ TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& t auto dayLengthRange = jsonToVec2F(config.get("dayLengthRange")); auto threatLevelRange = jsonToVec2F(config.query("threatRange")); - float threatLevel = staticRandomDouble(seed, "ThreatLevel") * (threatLevelRange[1] - threatLevelRange[0]) + threatLevelRange[0]; + auto threatLevel = static_cast(staticRandomDouble(seed, "ThreatLevel") * (threatLevelRange[1] - threatLevelRange[0]) + threatLevelRange[0]); auto surfaceBiomeSeed = staticRandomU64(seed, "SurfaceBiomeSeed"); auto readRegion = [liquidsDatabase, threatLevel, seed](Json const& regionConfig, String const& layerName, int layerBaseHeight) { @@ -539,7 +510,7 @@ TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& t if (auto oceanLiquid = staticRandomValueFrom(regionConfig.getArray("oceanLiquid", {}), seed, "oceanLiquid", layerName.utf8Ptr()).optString()) { region.oceanLiquid = liquidsDatabase->liquidId(*oceanLiquid); - region.oceanLiquidLevel = regionConfig.getInt("oceanLevelOffset", 0) + layerBaseHeight; + region.oceanLiquidLevel = static_cast(regionConfig.getInt("oceanLevelOffset", 0) + layerBaseHeight); } else { region.oceanLiquid = EmptyLiquidId; region.oceanLiquidLevel = 0; @@ -561,30 +532,32 @@ TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& t TerrestrialWorldParameters::TerrestrialLayer layer; - layer.layerMinHeight = layerConfig.getFloat("layerLevel"); - layer.layerBaseHeight = layerConfig.getFloat("baseHeight"); + layer.layerMinHeight = static_cast(layerConfig.getFloat("layerLevel")); + layer.layerBaseHeight = static_cast(layerConfig.getFloat("baseHeight")); auto primaryRegionList = layerConfig.getArray("primaryRegion"); auto primaryRegionConfigName = staticRandomFrom(primaryRegionList, seed, layerName.utf8Ptr(), "PrimaryRegionSelection").toString(); Json primaryRegionConfig = jsonMerge(regionDefaults, regionTypes.get(primaryRegionConfigName)); layer.primaryRegion = readRegion(primaryRegionConfig, layerName, layer.layerBaseHeight); - auto subRegionList = primaryRegionConfig.getArray("subRegion"); - Json subRegionConfig; - if (subRegionList.size() > 0) { - String subRegionName = staticRandomFrom(subRegionList, seed, layerName, primaryRegionConfigName).toString(); - subRegionConfig = jsonMerge(regionDefaults, regionTypes.get(subRegionName)); - } else { - subRegionConfig = primaryRegionConfig; + { + auto subRegionList = primaryRegionConfig.getArray("subRegion"); + Json subRegionConfig; + if (!subRegionList.empty()) { + String subRegionName = staticRandomFrom(subRegionList, seed, layerName, primaryRegionConfigName).toString(); + subRegionConfig = jsonMerge(regionDefaults, regionTypes.get(subRegionName)); + } else { + subRegionConfig = primaryRegionConfig; + } + layer.primarySubRegion = readRegion(subRegionConfig, layerName, layer.layerBaseHeight); } - layer.primarySubRegion = readRegion(subRegionConfig, layerName, layer.layerBaseHeight); Vec2U secondaryRegionCountRange = jsonToVec2U(layerConfig.get("secondaryRegionCount")); - int secondaryRegionCount = staticRandomI32Range(secondaryRegionCountRange[0], secondaryRegionCountRange[1], seed, layerName, "SecondaryRegionCount"); + int secondaryRegionCount = staticRandomI32Range(static_cast(secondaryRegionCountRange[0]), static_cast(secondaryRegionCountRange[1]), seed, layerName, "SecondaryRegionCount"); auto secondaryRegionList = layerConfig.getArray("secondaryRegions"); - if (secondaryRegionList.size() > 0) { + if (!secondaryRegionList.empty()) { staticRandomShuffle(secondaryRegionList, seed, layerName, "SecondaryRegionShuffle"); - for (auto regionName : secondaryRegionList) { + for (const auto& regionName : secondaryRegionList) { if (secondaryRegionCount <= 0) break; Json secondaryRegionConfig = jsonMerge(regionDefaults, regionTypes.get(regionName.toString())); @@ -592,7 +565,7 @@ TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& t auto subRegionList = secondaryRegionConfig.getArray("subRegion"); Json subRegionConfig; - if (subRegionList.size() > 0) { + if (!subRegionList.empty()) { String subRegionName = staticRandomFrom(subRegionList, seed, layerName, regionName.toString()).toString(); subRegionConfig = jsonMerge(regionDefaults, regionTypes.get(subRegionName)); } else { @@ -611,7 +584,7 @@ TerrestrialWorldParametersPtr generateTerrestrialWorldParameters(String const& t Vec2U dungeonCountRange = layerConfig.opt("dungeonCountRange").apply(jsonToVec2U).value(); unsigned dungeonCount = staticRandomU32Range(dungeonCountRange[0], dungeonCountRange[1], seed, layerName, "DungeonCount"); layer.dungeons.appendAll(dungeonPool.selectUniques(dungeonCount, staticRandomHash64(seed, layerName, "DungeonChoice"))); - layer.dungeonXVariance = layerConfig.getInt("dungeonXVariance", 0); + layer.dungeonXVariance = static_cast(layerConfig.getInt("dungeonXVariance", 0)); return layer; }; @@ -674,7 +647,7 @@ AsteroidsWorldParametersPtr generateAsteroidsWorldParameters(uint64_t seed) { auto gravityRange = jsonToVec2F(asteroidsConfig.get("gravityRange")); auto threatLevelRange = jsonToVec2F(asteroidsConfig.get("threatRange")); - parameters->threatLevel = staticRandomDouble(seed, "ThreatLevel") * (threatLevelRange[1] - threatLevelRange[0]) + threatLevelRange[0]; + parameters->threatLevel = static_cast(staticRandomDouble(seed, "ThreatLevel") * (threatLevelRange[1] - threatLevelRange[0]) + threatLevelRange[0]); parameters->typeName = "asteroids"; parameters->worldSize = jsonToVec2U(asteroidsConfig.get("worldSize")); parameters->gravity = staticRandomFloatRange(gravityRange[0], gravityRange[1], seed, "WorldGravity"); @@ -685,8 +658,8 @@ AsteroidsWorldParametersPtr generateAsteroidsWorldParameters(uint64_t seed) { parameters->disableDeathDrops = asteroidsConfig.getBool("disableDeathDrops", false); parameters->worldEdgeForceRegions = WorldEdgeForceRegionTypeNames.getLeft(asteroidsConfig.getString("worldEdgeForceRegions", "TopAndBottom")); - parameters->asteroidTopLevel = asteroidsConfig.getInt("asteroidsTop"); - parameters->asteroidBottomLevel = asteroidsConfig.getInt("asteroidsBottom"); + parameters->asteroidTopLevel = static_cast(asteroidsConfig.getInt("asteroidsTop")); + parameters->asteroidBottomLevel = static_cast(asteroidsConfig.getInt("asteroidsBottom")); parameters->blendSize = asteroidsConfig.getFloat("blendSize"); parameters->asteroidBiome = biome; parameters->ambientLightLevel = jsonToColor(asteroidsConfig.get("ambientLightLevel")); @@ -716,9 +689,9 @@ FloatingDungeonWorldParametersPtr generateFloatingDungeonWorldParameters(String parameters->disableDeathDrops = worldConfig.getBool("disableDeathDrops", false); parameters->worldEdgeForceRegions = WorldEdgeForceRegionTypeNames.getLeft(worldConfig.getString("worldEdgeForceRegions", "Top")); - parameters->dungeonBaseHeight = worldConfig.getInt("dungeonBaseHeight"); - parameters->dungeonSurfaceHeight = worldConfig.getInt("dungeonSurfaceHeight", parameters->dungeonBaseHeight); - parameters->dungeonUndergroundLevel = worldConfig.getInt("dungeonUndergroundLevel", 0); + parameters->dungeonBaseHeight = static_cast(worldConfig.getInt("dungeonBaseHeight")); + parameters->dungeonSurfaceHeight = static_cast(worldConfig.getInt("dungeonSurfaceHeight", parameters->dungeonBaseHeight)); + parameters->dungeonUndergroundLevel = static_cast(worldConfig.getInt("dungeonUndergroundLevel", 0)); parameters->primaryDungeon = worldConfig.getString("primaryDungeon"); parameters->biome = worldConfig.optString("biome"); parameters->ambientLightLevel = jsonToColor(worldConfig.get("ambientLightLevel")); diff --git a/source/game/StarWorldParameters.hpp b/source/game/StarWorldParameters.hpp index 0e54929..386e98e 100644 --- a/source/game/StarWorldParameters.hpp +++ b/source/game/StarWorldParameters.hpp @@ -36,11 +36,11 @@ STAR_STRUCT(AsteroidsWorldParameters); STAR_STRUCT(FloatingDungeonWorldParameters); struct VisitableWorldParameters { - VisitableWorldParameters(); - VisitableWorldParameters(VisitableWorldParameters const& visitableWorldParameters); - VisitableWorldParameters(Json const& store); + VisitableWorldParameters() = default; + VisitableWorldParameters(VisitableWorldParameters const& visitableWorldParameters) = default; + explicit VisitableWorldParameters(Json const& store); - virtual ~VisitableWorldParameters(); + virtual ~VisitableWorldParameters() = default; virtual WorldParametersType type() const = 0; @@ -50,18 +50,18 @@ struct VisitableWorldParameters { virtual void write(DataStream& ds) const; String typeName; - float threatLevel; + float threatLevel{}; Vec2U worldSize; - float gravity; - bool airless; + float gravity{}; + bool airless{false}; WeatherPool weatherPool; StringList environmentStatusEffects; Maybe overrideTech; Maybe> globalDirectives; BeamUpRule beamUpRule; - bool disableDeathDrops; - bool terraformed; - WorldEdgeForceRegionType worldEdgeForceRegions; + bool disableDeathDrops{false}; + bool terraformed{false}; + WorldEdgeForceRegionType worldEdgeForceRegions{WorldEdgeForceRegionType::None}; }; struct TerrestrialWorldParameters : VisitableWorldParameters { @@ -75,14 +75,14 @@ struct TerrestrialWorldParameters : VisitableWorldParameters { String bgOreSelector; String subBlockSelector; - LiquidId caveLiquid; - float caveLiquidSeedDensity; + LiquidId caveLiquid{}; + float caveLiquidSeedDensity{}; - LiquidId oceanLiquid; - int oceanLiquidLevel; + LiquidId oceanLiquid{}; + int oceanLiquidLevel{}; - bool encloseLiquids; - bool fillMicrodungeons; + bool encloseLiquids{false}; + bool fillMicrodungeons{false}; }; struct TerrestrialLayer { @@ -102,67 +102,67 @@ struct TerrestrialWorldParameters : VisitableWorldParameters { Vec2F subRegionSizeRange; }; - TerrestrialWorldParameters(); - TerrestrialWorldParameters(TerrestrialWorldParameters const& terrestrialWorldParameters); - TerrestrialWorldParameters(Json const& store); + TerrestrialWorldParameters() = default; + TerrestrialWorldParameters(TerrestrialWorldParameters const& terrestrialWorldParameters) = default; + explicit TerrestrialWorldParameters(Json const& store); TerrestrialWorldParameters &operator=(TerrestrialWorldParameters const& terrestrialWorldParameters); - virtual WorldParametersType type() const override; + WorldParametersType type() const override; - virtual Json store() const override; + Json store() const override; - virtual void read(DataStream& ds) override; - virtual void write(DataStream& ds) const override; + void read(DataStream& ds) override; + void write(DataStream& ds) const override; String primaryBiome; - LiquidId primarySurfaceLiquid; + LiquidId primarySurfaceLiquid{}; String sizeName; - float hueShift; + float hueShift{}; SkyColoring skyColoring; - float dayLength; + float dayLength{}; Json blockNoiseConfig; Json blendNoiseConfig; - float blendSize; + float blendSize{}; - TerrestrialLayer spaceLayer; - TerrestrialLayer atmosphereLayer; - TerrestrialLayer surfaceLayer; - TerrestrialLayer subsurfaceLayer; + TerrestrialLayer spaceLayer{}; + TerrestrialLayer atmosphereLayer{}; + TerrestrialLayer surfaceLayer{}; + TerrestrialLayer subsurfaceLayer{}; List undergroundLayers; - TerrestrialLayer coreLayer; + TerrestrialLayer coreLayer{}; }; struct AsteroidsWorldParameters : VisitableWorldParameters { AsteroidsWorldParameters(); - AsteroidsWorldParameters(Json const& store); + explicit AsteroidsWorldParameters(Json const& store); - virtual WorldParametersType type() const override; + WorldParametersType type() const override; - virtual Json store() const override; + Json store() const override; - virtual void read(DataStream& ds) override; - virtual void write(DataStream& ds) const override; + void read(DataStream& ds) override; + void write(DataStream& ds) const override; - int asteroidTopLevel; - int asteroidBottomLevel; - float blendSize; + int asteroidTopLevel{}; + int asteroidBottomLevel{}; + float blendSize{}; String asteroidBiome; Color ambientLightLevel; }; struct FloatingDungeonWorldParameters : VisitableWorldParameters { - FloatingDungeonWorldParameters(); - FloatingDungeonWorldParameters(Json const& store); + FloatingDungeonWorldParameters() = default; + explicit FloatingDungeonWorldParameters(Json const& store); - virtual WorldParametersType type() const override; + WorldParametersType type() const override; - virtual Json store() const override; + Json store() const override; - virtual void read(DataStream& ds) override; - virtual void write(DataStream& ds) const override; + void read(DataStream& ds) override; + void write(DataStream& ds) const override; int dungeonBaseHeight; int dungeonSurfaceHeight; diff --git a/source/game/StarWorldServer.cpp b/source/game/StarWorldServer.cpp index f8acc18..7837221 100644 --- a/source/game/StarWorldServer.cpp +++ b/source/game/StarWorldServer.cpp @@ -535,7 +535,8 @@ List WorldServer::getOutgoingPackets(ConnectionId clientId) { Maybe WorldServer::receiveMessage(ConnectionId fromConnection, String const& message, JsonArray const& args) { Maybe result; for (auto& p : m_scriptContexts) { - if (result = p.second->handleMessage(message, fromConnection == ServerConnectionId, args)) + result = p.second->handleMessage(message, fromConnection == ServerConnectionId, args); + if (result) break; } return result; diff --git a/source/game/StarWorldStorage.cpp b/source/game/StarWorldStorage.cpp index 08cf55c..7cd890a 100644 --- a/source/game/StarWorldStorage.cpp +++ b/source/game/StarWorldStorage.cpp @@ -256,7 +256,6 @@ void WorldStorage::generateQueue(Maybe sectorGenerationLevelLimit, funct }); } - unsigned total = 0; while (!m_generationQueue.empty()) { if (sectorGenerationLevelLimit && *sectorGenerationLevelLimit == 0) break; @@ -266,7 +265,6 @@ void WorldStorage::generateQueue(Maybe sectorGenerationLevelLimit, funct m_generationQueue.removeFirst(); if (sectorGenerationLevelLimit) *sectorGenerationLevelLimit -= p.second; - total += p.second; } } catch (std::exception const& e) { m_db.rollback(); diff --git a/source/game/interfaces/StarEntity.cpp b/source/game/interfaces/StarEntity.cpp index 801a0d8..cbc968f 100644 --- a/source/game/interfaces/StarEntity.cpp +++ b/source/game/interfaces/StarEntity.cpp @@ -111,7 +111,7 @@ Maybe Entity::receiveMessage(ConnectionId, String const&, JsonArray const& return {}; } -void Entity::update(float dt, uint64_t) {} +void Entity::update(float, uint64_t) {} void Entity::render(RenderCallback*) {} diff --git a/source/game/interfaces/StarToolUserItem.cpp b/source/game/interfaces/StarToolUserItem.cpp index 104b513..8191cec 100644 --- a/source/game/interfaces/StarToolUserItem.cpp +++ b/source/game/interfaces/StarToolUserItem.cpp @@ -14,7 +14,7 @@ void ToolUserItem::uninit() { m_hand = {}; } -void ToolUserItem::update(float dt, FireMode, bool, HashSet const&) {} +void ToolUserItem::update(float, FireMode, bool, HashSet const&) {} bool ToolUserItem::initialized() const { return (bool)m_owner; diff --git a/source/game/items/StarArmors.cpp b/source/game/items/StarArmors.cpp index 85580d9..01ff4c4 100644 --- a/source/game/items/StarArmors.cpp +++ b/source/game/items/StarArmors.cpp @@ -43,11 +43,11 @@ List ArmorItem::drawables() const { return drawables; } -float ArmorItem::getAngle(float aimAngle) { +float ArmorItem::getAngle(float) { return -25.0f * Constants::deg2rad; } -void ArmorItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {} +void ArmorItem::fire(FireMode, bool, bool) {} void ArmorItem::fireTriggered() {} List const& ArmorItem::colorOptions() { diff --git a/source/game/items/StarInspectionTool.cpp b/source/game/items/StarInspectionTool.cpp index a9b12c4..6ab6789 100644 --- a/source/game/items/StarInspectionTool.cpp +++ b/source/game/items/StarInspectionTool.cpp @@ -31,7 +31,7 @@ ItemPtr InspectionTool::clone() const { return make_shared(*this); } -void InspectionTool::update(float dt, FireMode fireMode, bool, HashSet const&) { +void InspectionTool::update(float, FireMode fireMode, bool, HashSet const&) { m_currentAngle = world()->geometry().diff(owner()->aimPosition(), owner()->position()).angle(); m_currentPosition = owner()->position() + owner()->handPosition(hand(), m_lightPosition - m_handPosition); SpatialLogger::logPoint("world", m_currentPosition, {0, 0, 255, 255}); diff --git a/source/game/items/StarInstrumentItem.cpp b/source/game/items/StarInstrumentItem.cpp index f93bca7..1a31934 100644 --- a/source/game/items/StarInstrumentItem.cpp +++ b/source/game/items/StarInstrumentItem.cpp @@ -42,7 +42,7 @@ StringSet InstrumentItem::effectSources() const { return m_inactiveEffectSources; } -void InstrumentItem::update(float dt, FireMode, bool, HashSet const&) { +void InstrumentItem::update(float, FireMode, bool, HashSet const&) { if (entityMode() == EntityMode::Master) { if (active()) { m_activeCooldown--; diff --git a/source/game/items/StarMaterialItem.cpp b/source/game/items/StarMaterialItem.cpp index c533add..42f90fc 100644 --- a/source/game/items/StarMaterialItem.cpp +++ b/source/game/items/StarMaterialItem.cpp @@ -119,7 +119,7 @@ void MaterialItem::update(float dt, FireMode fireMode, bool shifting, HashSetfavoriteColor()).mix(Color::White); @@ -190,8 +190,8 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) { : Root::singleton().materialDatabase()->materialCollisionKind(m_material); size_t total = 0; - for (int i = 0; i != steps; ++i) { - auto placementOrigin = aimPosition + diff * (1.0f - ((float)i / steps)); + for (unsigned i = 0; i != steps; ++i) { + auto placementOrigin = aimPosition + diff * (1.0f - (static_cast(i) / steps)); if (!owner()->inToolRange(placementOrigin)) continue; @@ -218,7 +218,7 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) { m_lastAimPosition = aimPosition; } -void MaterialItem::endFire(FireMode mode, bool shifting) { +void MaterialItem::endFire(FireMode, bool) { m_lastAimPosition.reset(); } diff --git a/source/game/items/StarUnlockItem.cpp b/source/game/items/StarUnlockItem.cpp index ee067fb..ad61eae 100644 --- a/source/game/items/StarUnlockItem.cpp +++ b/source/game/items/StarUnlockItem.cpp @@ -24,7 +24,7 @@ List UnlockItem::drawables() const { return m_drawables; } -List UnlockItem::preview(PlayerPtr const& viewer) const { +List UnlockItem::preview(PlayerPtr const&) const { return iconDrawables(); } diff --git a/source/game/scripting/StarLuaGameConverters.cpp b/source/game/scripting/StarLuaGameConverters.cpp index 64415e6..15dd11d 100644 --- a/source/game/scripting/StarLuaGameConverters.cpp +++ b/source/game/scripting/StarLuaGameConverters.cpp @@ -470,7 +470,7 @@ LuaValue LuaConverter::from(LuaEngine& engine, Drawable const& v) { return table; } -Maybe LuaConverter::to(LuaEngine& engine, LuaValue const& v) { +Maybe LuaConverter::to(LuaEngine&, LuaValue const& v) { if (auto table = v.ptr()) { Maybe result; result.emplace(); diff --git a/source/rendering/StarTextPainter.cpp b/source/rendering/StarTextPainter.cpp index fe352d1..3266e18 100644 --- a/source/rendering/StarTextPainter.cpp +++ b/source/rendering/StarTextPainter.cpp @@ -124,7 +124,6 @@ bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapText m_fontTextureGroup.switchFont(font); int lines = 0; - size_t i = 0; auto it = text.begin(); auto end = text.end(); @@ -150,8 +149,6 @@ bool TextPainter::processWrapText(StringView text, unsigned* wrapWidth, WrapText if (Text::isEscapeCode(character)) escIt = it; - ++i; - if (escIt != end) { if (character == Text::EndEsc) { @@ -432,7 +429,6 @@ RectF TextPainter::doRenderLine(StringView text, TextPositioning const& position pos.hAnchor = HorizontalAnchor::LeftAnchor; } - bool escape = false; String escapeCode; RectF bounds = RectF::withSize(pos.pos, Vec2F()); Text::TextCallback textCallback = [&](StringView text) { diff --git a/source/windowing/StarPane.cpp b/source/windowing/StarPane.cpp index b1a3daa..36e8435 100644 --- a/source/windowing/StarPane.cpp +++ b/source/windowing/StarPane.cpp @@ -203,7 +203,7 @@ void Pane::update(float dt) { } } -void Pane::tick(float dt) { +void Pane::tick(float) { m_playingSounds.filter([](pair const& p) { return p.second->finished() == false; }); diff --git a/source/windowing/StarScrollArea.cpp b/source/windowing/StarScrollArea.cpp index 4cd2ba6..f4cc140 100644 --- a/source/windowing/StarScrollArea.cpp +++ b/source/windowing/StarScrollArea.cpp @@ -384,7 +384,7 @@ bool ScrollArea::sendEvent(InputEvent const& event) { return true; } -void ScrollArea::update(float dt) { +void ScrollArea::update(float) { if (!m_visible) return; diff --git a/source/windowing/StarVerticalLayout.cpp b/source/windowing/StarVerticalLayout.cpp index 412fce0..4619232 100644 --- a/source/windowing/StarVerticalLayout.cpp +++ b/source/windowing/StarVerticalLayout.cpp @@ -9,7 +9,7 @@ VerticalLayout::VerticalLayout(VerticalAnchor verticalAnchor, int verticalSpacin disableScissoring(); } -void VerticalLayout::update(float dt) { +void VerticalLayout::update(float) { m_size = Vec2I(0, 0); if (m_members.empty())