From 3621e7ce1b30051f4a842a7d8ea4e38c66664668 Mon Sep 17 00:00:00 2001 From: Vyacheslav Ivanov Date: Sat, 3 Aug 2024 21:49:18 +0300 Subject: [PATCH] fix: PVS-Studio V522 mark false Signed-off-by: Vyacheslav Ivanov --- src/audio/AL/ALAudio.cpp | 8 ++--- src/content/ContentLUT.hpp | 2 +- src/engine.cpp | 2 +- src/files/WorldFiles.cpp | 2 +- src/frontend/ContentGfxCache.cpp | 4 +-- src/graphics/render/BlocksPreview.cpp | 4 +-- src/graphics/render/Skybox.cpp | 4 +-- src/graphics/render/WorldRenderer.cpp | 8 ++--- src/graphics/ui/elements/InventoryView.cpp | 12 +++---- src/items/ItemStack.cpp | 4 +-- src/lighting/Lighting.cpp | 4 +-- src/logic/BlocksController.cpp | 16 ++++----- src/logic/PlayerController.cpp | 16 ++++----- src/logic/scripting/lua/libblock.cpp | 12 +++---- src/logic/scripting/lua/libgui.cpp | 16 ++++----- src/logic/scripting/lua/libhud.cpp | 2 +- src/voxels/Chunks.cpp | 42 +++++++++++----------- src/voxels/ChunksStorage.cpp | 4 +-- 18 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/audio/AL/ALAudio.cpp b/src/audio/AL/ALAudio.cpp index 4c24c75b..66f5f235 100644 --- a/src/audio/AL/ALAudio.cpp +++ b/src/audio/AL/ALAudio.cpp @@ -96,8 +96,8 @@ void ALStream::bindSpeaker(speakerid_t speaker) { this->speaker = speaker; sp = audio::get_speaker(speaker); if (sp) { - auto alspeaker = dynamic_cast(sp); - alspeaker->stream = this; + auto alspeaker = dynamic_cast(sp); //FIXME: Potentional null pointer + alspeaker->stream = this; //-V522 alspeaker->duration = source->getTotalDuration(); } } @@ -148,8 +148,8 @@ void ALStream::update(double delta) { speaker = 0; return; } - ALSpeaker* alspeaker = dynamic_cast(speaker); - if (alspeaker->stopped) { + ALSpeaker* alspeaker = dynamic_cast(speaker); //FIXME: Potentional null pointer + if (alspeaker->stopped) { //-V522 speaker = 0; return; } diff --git a/src/content/ContentLUT.hpp b/src/content/ContentLUT.hpp index be6f4b7a..2e29d985 100644 --- a/src/content/ContentLUT.hpp +++ b/src/content/ContentLUT.hpp @@ -38,7 +38,7 @@ public: indices.push_back(i); } for (size_t i = 0; i < unitIndices.count(); i++) { - names.push_back(unitIndices.get(i)->name); + names.push_back(unitIndices.get(i)->name); //FIXME: .get(i) potentional null pointer //-V522 } for (size_t i = unitIndices.count(); i < count; i++) { names.emplace_back(""); diff --git a/src/engine.cpp b/src/engine.cpp index cd88298f..bc0681d0 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -269,7 +269,7 @@ void Engine::loadAssets() { // no need // correct log messages order is more useful bool threading = false; - if (threading) { + if (threading) { // TODO: Why is always false? auto task = loader.startTask([=](){}); task->waitForEnd(); } else { diff --git a/src/files/WorldFiles.cpp b/src/files/WorldFiles.cpp index 80fedc72..d858427d 100644 --- a/src/files/WorldFiles.cpp +++ b/src/files/WorldFiles.cpp @@ -105,7 +105,7 @@ static void write_indices( ) { size_t count = indices.count(); for (size_t i = 0; i < count; i++) { - list.put(indices.get(i)->name); + list.put(indices.get(i)->name); //FIXME: .get(i) potential null pointer //-V522 } } diff --git a/src/frontend/ContentGfxCache.cpp b/src/frontend/ContentGfxCache.cpp index 4de80069..b10a360f 100644 --- a/src/frontend/ContentGfxCache.cpp +++ b/src/frontend/ContentGfxCache.cpp @@ -18,9 +18,9 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte auto atlas = assets->get("blocks"); for (uint i = 0; i < indices->blocks.count(); i++) { - Block* def = indices->blocks.get(i); + Block* def = indices->blocks.get(i); //FIXME: Potential null pointer for (uint side = 0; side < 6; side++) { - const std::string& tex = def->textureFaces[side]; + const std::string& tex = def->textureFaces[side]; //-V522 if (atlas->has(tex)) { sideregions[i * 6 + side] = atlas->get(tex); } else if (atlas->has(TEXTURE_NOTFOUND)) { diff --git a/src/graphics/render/BlocksPreview.cpp b/src/graphics/render/BlocksPreview.cpp index 3f3cce33..2955a8c7 100644 --- a/src/graphics/render/BlocksPreview.cpp +++ b/src/graphics/render/BlocksPreview.cpp @@ -154,9 +154,9 @@ std::unique_ptr BlocksPreview::build( fbo.bind(); for (size_t i = 0; i < count; i++) { - auto def = indices->blocks.get(i); + auto def = indices->blocks.get(i); //FIXME: Potentional null pointer atlas->getTexture()->bind(); - builder.add(def->name, draw(cache, shader, &fbo, &batch, def, iconSize)); + builder.add(def->name, draw(cache, shader, &fbo, &batch, def, iconSize)); //-V522 } fbo.unbind(); diff --git a/src/graphics/render/Skybox.cpp b/src/graphics/render/Skybox.cpp index 029f0b8b..09ed7997 100644 --- a/src/graphics/render/Skybox.cpp +++ b/src/graphics/render/Skybox.cpp @@ -141,11 +141,11 @@ void Skybox::refresh(const DrawContext& pctx, float t, float mie, uint quality) ctx.setFramebuffer(fbo.get()); ctx.setViewport(Viewport(size, size)); - auto cubemap = dynamic_cast(fbo->getTexture()); + auto cubemap = dynamic_cast(fbo->getTexture()); //FIXME: Potentional null pointer ready = true; glActiveTexture(GL_TEXTURE1); - cubemap->bind(); + cubemap->bind(); //-V522 shader->use(); const glm::vec3 xaxs[] = { diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index 9dbe97c7..8a7b77b8 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -172,10 +172,10 @@ void WorldRenderer::setupWorldShader( { auto inventory = player->getInventory(); ItemStack& stack = inventory->getSlot(player->getChosenSlot()); - auto item = indices->items.get(stack.getItemId()); + auto item = indices->items.get(stack.getItemId()); //FIXME: Potentional null pointer float multiplier = 0.5f; shader->uniform3f("u_torchlightColor", - item->emission[0] / 15.0f * multiplier, + item->emission[0] / 15.0f * multiplier, //-V522 item->emission[1] / 15.0f * multiplier, item->emission[2] / 15.0f * multiplier ); @@ -222,12 +222,12 @@ void WorldRenderer::renderBlockSelection() { const auto& selection = player->selection; auto indices = level->content->getIndices(); blockid_t id = selection.vox.id; - auto block = indices->blocks.get(id); + auto block = indices->blocks.get(id); //FIXME: Potentional null pointer const glm::ivec3 pos = player->selection.position; const glm::vec3 point = selection.hitPosition; const glm::vec3 norm = selection.normal; - const std::vector& hitboxes = block->rotatable + const std::vector& hitboxes = block->rotatable //-V522 ? block->rt.hitboxes[selection.vox.state.rotation] : block->hitboxes; diff --git a/src/graphics/ui/elements/InventoryView.cpp b/src/graphics/ui/elements/InventoryView.cpp index 14b7a59b..cb7e6b71 100644 --- a/src/graphics/ui/elements/InventoryView.cpp +++ b/src/graphics/ui/elements/InventoryView.cpp @@ -121,9 +121,9 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) { itemid_t itemid = bound->getItemId(); if (itemid != prevItem) { if (itemid) { - auto def = content->getIndices()->items.get(itemid); + auto def = content->getIndices()->items.get(itemid); //FIXME: Potentional null pointer tooltip = util::pascal_case( - langs::get(util::str2wstr_utf8(def->caption)) + langs::get(util::str2wstr_utf8(def->caption)) //-V522 ); } else { tooltip.clear(); @@ -159,8 +159,8 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) { auto previews = assets->get("block-previews"); auto indices = content->getIndices(); - ItemDef* item = indices->items.get(stack.getItemId()); - switch (item->iconType) { + ItemDef* item = indices->items.get(stack.getItemId()); //FIXME: Potentional null pointer + switch (item->iconType) { //-V522 case item_icon_type::none: break; case item_icon_type::block: { @@ -268,12 +268,12 @@ void SlotView::clicked(gui::GUI* gui, mousecode button) { stack.setCount(halfremain); } } else { - auto stackDef = content->getIndices()->items.get(stack.getItemId()); + auto stackDef = content->getIndices()->items.get(stack.getItemId()); //FIXME: Potentional null pointer if (stack.isEmpty()) { stack.set(grabbed); stack.setCount(1); grabbed.setCount(grabbed.getCount()-1); - } else if (stack.accepts(grabbed) && stack.getCount() < stackDef->stackSize){ + } else if (stack.accepts(grabbed) && stack.getCount() < stackDef->stackSize){ //-V522 stack.setCount(stack.getCount()+1); grabbed.setCount(grabbed.getCount()-1); } diff --git a/src/items/ItemStack.cpp b/src/items/ItemStack.cpp index 120972b6..2c9b74ae 100644 --- a/src/items/ItemStack.cpp +++ b/src/items/ItemStack.cpp @@ -26,8 +26,8 @@ bool ItemStack::accepts(const ItemStack& other) const { } void ItemStack::move(ItemStack& item, const ContentIndices* indices) { - auto def = indices->items.get(item.getItemId()); - int count = std::min(item.count, def->stackSize - this->count); + auto def = indices->items.get(item.getItemId()); //FIXME: Potentional null pointer + int count = std::min(item.count, def->stackSize - this->count); //-V522 if (isEmpty()) { set(ItemStack(item.getItemId(), count)); } else { diff --git a/src/lighting/Lighting.cpp b/src/lighting/Lighting.cpp index 1236d7dd..e6cfbd54 100644 --- a/src/lighting/Lighting.cpp +++ b/src/lighting/Lighting.cpp @@ -149,7 +149,7 @@ void Lighting::onChunkLoaded(int cx, int cz, bool expand){ } void Lighting::onBlockSet(int x, int y, int z, blockid_t id){ - Block* block = content->getIndices()->blocks.get(id); + Block* block = content->getIndices()->blocks.get(id); //FIXME: Potentional null pointer solverR->remove(x,y,z); solverG->remove(x,y,z); solverB->remove(x,y,z); @@ -161,7 +161,7 @@ void Lighting::onBlockSet(int x, int y, int z, blockid_t id){ if (chunks->getLight(x,y+1,z, 3) == 0xF){ for (int i = y; i >= 0; i--){ voxel* vox = chunks->get(x,i,z); - if ((vox == nullptr || vox->id != 0) && block->skyLightPassing) + if ((vox == nullptr || vox->id != 0) && block->skyLightPassing) //-V522 break; solverS->add(x,i,z, 0xF); } diff --git a/src/logic/BlocksController.cpp b/src/logic/BlocksController.cpp index ade2a16f..31cd9685 100644 --- a/src/logic/BlocksController.cpp +++ b/src/logic/BlocksController.cpp @@ -62,8 +62,8 @@ void BlocksController::placeBlock( void BlocksController::updateBlock(int x, int y, int z) { voxel* vox = chunks->get(x, y, z); if (vox == nullptr) return; - auto def = level->content->getIndices()->blocks.get(vox->id); - if (def->grounded) { + auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer + if (def->grounded) { //-V522 const auto& vec = get_ground_direction(def, vox->state.rotation); if (!chunks->isSolidBlock(x + vec.x, y + vec.y, z + vec.z)) { breakBlock(nullptr, def, x, y, z); @@ -93,8 +93,8 @@ void BlocksController::onBlocksTick(int tickid, int parts) { int tickRate = blocksTickClock.getTickRate(); for (size_t id = 0; id < indices->blocks.count(); id++) { if ((id + tickid) % parts != 0) continue; - auto def = indices->blocks.get(id); - auto interval = def->tickInterval; + auto def = indices->blocks.get(id); //FIXME: Potentional null pointer + auto interval = def->tickInterval; //-V522 if (def->rt.funcsset.onblockstick && tickid / parts % interval == 0) { scripting::on_blocks_tick(def, tickRate / interval); } @@ -112,8 +112,8 @@ void BlocksController::randomTick( int by = random.rand() % segheight + s * segheight; int bz = random.rand() % CHUNK_D; const voxel& vox = chunk.voxels[(by * CHUNK_D + bz) * CHUNK_W + bx]; - Block* block = indices->blocks.get(vox.id); - if (block->rt.funcsset.randupdate) { + Block* block = indices->blocks.get(vox.id); //FIXME: Potentional null pointer + if (block->rt.funcsset.randupdate) { //-V522 scripting::random_update_block( block, chunk.x * CHUNK_W + bx, by, chunk.z * CHUNK_D + bz ); @@ -153,8 +153,8 @@ int64_t BlocksController::createBlockInventory(int x, int y, int z) { auto inv = chunk->getBlockInventory(lx, y, lz); if (inv == nullptr) { auto indices = level->content->getIndices(); - auto def = indices->blocks.get(chunk->voxels[vox_index(lx, y, lz)].id); - int invsize = def->inventorySize; + auto def = indices->blocks.get(chunk->voxels[vox_index(lx, y, lz)].id); //FIXME: Potentional null pointer + int invsize = def->inventorySize; //-V522 if (invsize == 0) { return 0; } diff --git a/src/logic/PlayerController.cpp b/src/logic/PlayerController.cpp index 3c710cef..816900be 100644 --- a/src/logic/PlayerController.cpp +++ b/src/logic/PlayerController.cpp @@ -208,8 +208,8 @@ void PlayerController::onFootstep(const Hitbox& hitbox) { int z = std::floor(pos.z + half.z * offsetZ); auto vox = level->chunks->get(x, y, z); if (vox) { - auto def = level->content->getIndices()->blocks.get(vox->id); - if (!def->obstacle) continue; + auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!def->obstacle) continue; //-V522 blocksController->onBlockInteraction( player.get(), glm::ivec3(x, y, z), @@ -333,8 +333,8 @@ static int determine_rotation( static void pick_block( ContentIndices* indices, Chunks* chunks, Player* player, int x, int y, int z ) { - auto block = indices->blocks.get(chunks->get(x, y, z)->id); - itemid_t id = block->rt.pickingItem; + auto block = indices->blocks.get(chunks->get(x, y, z)->id); //FIXME: Potentional null pointer + itemid_t id = block->rt.pickingItem; //-V522 auto inventory = player->getInventory(); size_t slotid = inventory->findSlotByItem(id, 0, 10); if (slotid == Inventory::npos) { @@ -492,11 +492,11 @@ void PlayerController::updateInteraction() { auto inventory = player->getInventory(); const ItemStack& stack = inventory->getSlot(player->getChosenSlot()); - ItemDef* item = indices->items.get(stack.getItemId()); + ItemDef* item = indices->items.get(stack.getItemId()); //FIXME: Potentional null pointer auto vox = updateSelection(maxDistance); if (vox == nullptr) { - if (rclick && item->rt.funcsset.on_use) { + if (rclick && item->rt.funcsset.on_use) { //-V522 scripting::on_item_use(player.get(), item); } if (selection.entity) { @@ -513,8 +513,8 @@ void PlayerController::updateInteraction() { return; } } - auto target = indices->blocks.get(vox->id); - if (lclick && target->breakable) { + auto target = indices->blocks.get(vox->id); //FIXME: Potentional null pointer + if (lclick && target->breakable) { //-V522 blocksController->breakBlock( player.get(), target, iend.x, iend.y, iend.z ); diff --git a/src/logic/scripting/lua/libblock.cpp b/src/logic/scripting/lua/libblock.cpp index cc1c6cd0..ea73df72 100644 --- a/src/logic/scripting/lua/libblock.cpp +++ b/src/logic/scripting/lua/libblock.cpp @@ -122,8 +122,8 @@ static int l_get_x(lua::State* L) { if (vox == nullptr) { return lua::pushivec3_stack(L, 1, 0, 0); } - auto def = level->content->getIndices()->blocks.get(vox->id); - if (!def->rotatable) { + auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!def->rotatable) { //-V522 return lua::pushivec3_stack(L, 1, 0, 0); } else { const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; @@ -139,8 +139,8 @@ static int l_get_y(lua::State* L) { if (vox == nullptr) { return lua::pushivec3_stack(L, 0, 1, 0); } - auto def = level->content->getIndices()->blocks.get(vox->id); - if (!def->rotatable) { + auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!def->rotatable) { //-V522 return lua::pushivec3_stack(L, 0, 1, 0); } else { const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; @@ -156,8 +156,8 @@ static int l_get_z(lua::State* L) { if (vox == nullptr) { return lua::pushivec3_stack(L, 0, 0, 1); } - auto def = level->content->getIndices()->blocks.get(vox->id); - if (!def->rotatable) { + auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!def->rotatable) { //-V522 return lua::pushivec3_stack(L, 0, 0, 1); } else { const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; diff --git a/src/logic/scripting/lua/libgui.cpp b/src/logic/scripting/lua/libgui.cpp index 99a4c569..8436dd0c 100644 --- a/src/logic/scripting/lua/libgui.cpp +++ b/src/logic/scripting/lua/libgui.cpp @@ -53,34 +53,34 @@ static DocumentNode getDocumentNode(lua::State* L, int idx = 1) { static int l_menu_back(lua::State* L) { auto node = getDocumentNode(L); - auto menu = dynamic_cast(node.node.get()); - menu->back(); + auto menu = dynamic_cast(node.node.get()); //FIXME: Potentional null pointer + menu->back(); //-V522 return 0; } static int l_menu_reset(lua::State* L) { auto node = getDocumentNode(L); - auto menu = dynamic_cast(node.node.get()); - menu->reset(); + auto menu = dynamic_cast(node.node.get()); //FIXME: Potentional null pointer + menu->reset(); //-V522 return 0; } static int l_textbox_paste(lua::State* L) { auto node = getDocumentNode(L); - auto box = dynamic_cast(node.node.get()); + auto box = dynamic_cast(node.node.get()); //FIXME: Potentional null pointer auto text = lua::require_string(L, 2); - box->paste(util::str2wstr_utf8(text)); + box->paste(util::str2wstr_utf8(text)); //-V522 return 0; } static int l_container_add(lua::State* L) { auto docnode = getDocumentNode(L); - auto node = dynamic_cast(docnode.node.get()); + auto node = dynamic_cast(docnode.node.get()); //FIXME: Potentional null pointer auto xmlsrc = lua::require_string(L, 2); try { auto subnode = guiutil::create(xmlsrc, docnode.document->getEnvironment()); - node->add(subnode); + node->add(subnode); //-V522 UINode::getIndices(subnode, docnode.document->getMapWriteable()); } catch (const std::exception& err) { throw std::runtime_error(err.what()); diff --git a/src/logic/scripting/lua/libhud.cpp b/src/logic/scripting/lua/libhud.cpp index 775c4ef0..b9500126 100644 --- a/src/logic/scripting/lua/libhud.cpp +++ b/src/logic/scripting/lua/libhud.cpp @@ -51,7 +51,7 @@ static int l_hud_open_block(lua::State* L) { } auto def = content->getIndices()->blocks.get(vox->id); auto assets = engine->getAssets(); - auto layout = assets->get(def->uiLayout); + auto layout = assets->get(def->uiLayout);//FIXME: Potentional null pointer //-V522 if (layout == nullptr) { throw std::runtime_error("block '" + def->name + "' has no ui layout"); } diff --git a/src/voxels/Chunks.cpp b/src/voxels/Chunks.cpp index a479569c..e645cf9b 100644 --- a/src/voxels/Chunks.cpp +++ b/src/voxels/Chunks.cpp @@ -76,8 +76,8 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z) { return ∅ } } - const auto def = indices->blocks.get(v->id); - if (def->obstacle) { + const auto def = indices->blocks.get(v->id); //FIXME: Potentional null pointer + if (def->obstacle) { //-V522 glm::ivec3 offset {}; if (v->state.segment) { glm::ivec3 point(ix, iy, iz); @@ -99,19 +99,19 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z) { bool Chunks::isSolidBlock(int32_t x, int32_t y, int32_t z) { voxel* v = get(x, y, z); if (v == nullptr) return false; - return indices->blocks.get(v->id)->rt.solid; + return indices->blocks.get(v->id)->rt.solid; //-V522 } bool Chunks::isReplaceableBlock(int32_t x, int32_t y, int32_t z) { voxel* v = get(x, y, z); if (v == nullptr) return false; - return indices->blocks.get(v->id)->replaceable; + return indices->blocks.get(v->id)->replaceable; //-V522 } bool Chunks::isObstacleBlock(int32_t x, int32_t y, int32_t z) { voxel* v = get(x, y, z); if (v == nullptr) return false; - return indices->blocks.get(v->id)->obstacle; + return indices->blocks.get(v->id)->obstacle; //-V522 } ubyte Chunks::getLight(int32_t x, int32_t y, int32_t z, int channel) { @@ -255,8 +255,8 @@ bool Chunks::checkReplaceability( pos += rotation.axisY * sy; pos += rotation.axisZ * sz; if (auto vox = get(pos.x, pos.y, pos.z)) { - auto target = indices->blocks.get(vox->id); - if (!target->replaceable && vox->id != ignore) { + auto target = indices->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!target->replaceable && vox->id != ignore) { //-V522 return false; } } else { @@ -300,8 +300,8 @@ void Chunks::setRotationExtended( set(pos.x, pos.y, pos.z, def->rt.id, segState); } else { vox->state = segState; - auto chunk = getChunkByVoxel(pos.x, pos.y, pos.z); - chunk->setModifiedAndUnsaved(); + auto chunk = getChunkByVoxel(pos.x, pos.y, pos.z); //FIXME: Potentional null pointer + chunk->setModifiedAndUnsaved(); //-V522 segmentBlocks.emplace_back(pos); } } @@ -333,16 +333,16 @@ void Chunks::setRotation(int32_t x, int32_t y, int32_t z, uint8_t index) { if (vox == nullptr) { return; } - auto def = indices->blocks.get(vox->id); - if (!def->rotatable || vox->state.rotation == index) { + auto def = indices->blocks.get(vox->id); //FIXME: Potentional null pointer + if (!def->rotatable || vox->state.rotation == index) { //-V522 return; } if (def->rt.extended) { setRotationExtended(def, vox->state, {x, y, z}, index); } else { vox->state.rotation = index; - auto chunk = getChunkByVoxel(x, y, z); - chunk->setModifiedAndUnsaved(); + auto chunk = getChunkByVoxel(x, y, z); //FIXME: Potentional null pointer + chunk->setModifiedAndUnsaved(); //-V522 } } @@ -371,8 +371,8 @@ void Chunks::set( // block finalization voxel& vox = chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx]; - auto prevdef = indices->blocks.get(vox.id); - if (prevdef->inventorySize == 0) { + auto prevdef = indices->blocks.get(vox.id); //FIXME: Potentional null pointer + if (prevdef->inventorySize == 0) { //-V522 chunk->removeBlockInventory(lx, y, lz); } if (prevdef->rt.extended && !vox.state.segment) { @@ -380,11 +380,11 @@ void Chunks::set( } // block initialization - auto newdef = indices->blocks.get(id); + auto newdef = indices->blocks.get(id); //FIXME: Potentional null pointer vox.id = id; vox.state = state; chunk->setModifiedAndUnsaved(); - if (!state.segment && newdef->rt.extended) { + if (!state.segment && newdef->rt.extended) { //-V522 repairSegments(newdef, state, gx, y, gz); } @@ -452,8 +452,8 @@ voxel* Chunks::rayCast( if (voxel == nullptr) { return nullptr; } - const auto def = indices->blocks.get(voxel->id); - if (def->selectable) { + const auto def = indices->blocks.get(voxel->id); //FIXME: Potentional null pointer + if (def->selectable) { //-V522 end.x = px + t * dx; end.y = py + t * dy; end.z = pz + t * dz; @@ -579,8 +579,8 @@ glm::vec3 Chunks::rayCastToObstacle( while (t <= maxDist) { voxel* voxel = get(ix, iy, iz); if (voxel) { - const auto def = indices->blocks.get(voxel->id); - if (def->obstacle) { + const auto def = indices->blocks.get(voxel->id); //FIXME: Potentional null pointer + if (def->obstacle) { //-V522 if (!def->rt.solid) { const std::vector& hitboxes = def->rotatable ? def->rt.hitboxes[voxel->state.rotation] diff --git a/src/voxels/ChunksStorage.cpp b/src/voxels/ChunksStorage.cpp index eab8a002..0f3bfc97 100644 --- a/src/voxels/ChunksStorage.cpp +++ b/src/voxels/ChunksStorage.cpp @@ -150,8 +150,8 @@ void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const { light_t light = clights[cidx]; if (backlight) { auto block = - indices->blocks.get(voxels[vidx].id); - if (block->lightPassing) { + indices->blocks.get(voxels[vidx].id); //FIXME: Potentional null pointer + if (block->lightPassing) { //-V522 light = Lightmap::combine( min(15, Lightmap::extract(light, 0) + 1),