fix: PVS-Studio V522 mark false

Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov 2024-08-03 21:49:18 +03:00 committed by Pugemon
parent 4efa574eec
commit 3621e7ce1b
No known key found for this signature in database
GPG Key ID: 472FA343B3CC3287
18 changed files with 81 additions and 81 deletions

View File

@ -96,8 +96,8 @@ void ALStream::bindSpeaker(speakerid_t speaker) {
this->speaker = speaker; this->speaker = speaker;
sp = audio::get_speaker(speaker); sp = audio::get_speaker(speaker);
if (sp) { if (sp) {
auto alspeaker = dynamic_cast<ALSpeaker*>(sp); auto alspeaker = dynamic_cast<ALSpeaker*>(sp); //FIXME: Potentional null pointer
alspeaker->stream = this; alspeaker->stream = this; //-V522
alspeaker->duration = source->getTotalDuration(); alspeaker->duration = source->getTotalDuration();
} }
} }
@ -148,8 +148,8 @@ void ALStream::update(double delta) {
speaker = 0; speaker = 0;
return; return;
} }
ALSpeaker* alspeaker = dynamic_cast<ALSpeaker*>(speaker); ALSpeaker* alspeaker = dynamic_cast<ALSpeaker*>(speaker); //FIXME: Potentional null pointer
if (alspeaker->stopped) { if (alspeaker->stopped) { //-V522
speaker = 0; speaker = 0;
return; return;
} }

View File

@ -38,7 +38,7 @@ public:
indices.push_back(i); indices.push_back(i);
} }
for (size_t i = 0; i < unitIndices.count(); 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++) { for (size_t i = unitIndices.count(); i < count; i++) {
names.emplace_back(""); names.emplace_back("");

View File

@ -269,7 +269,7 @@ void Engine::loadAssets() {
// no need // no need
// correct log messages order is more useful // correct log messages order is more useful
bool threading = false; bool threading = false;
if (threading) { if (threading) { // TODO: Why is always false?
auto task = loader.startTask([=](){}); auto task = loader.startTask([=](){});
task->waitForEnd(); task->waitForEnd();
} else { } else {

View File

@ -105,7 +105,7 @@ static void write_indices(
) { ) {
size_t count = indices.count(); size_t count = indices.count();
for (size_t i = 0; i < count; i++) { 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
} }
} }

View File

@ -18,9 +18,9 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte
auto atlas = assets->get<Atlas>("blocks"); auto atlas = assets->get<Atlas>("blocks");
for (uint i = 0; i < indices->blocks.count(); i++) { 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++) { 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)) { if (atlas->has(tex)) {
sideregions[i * 6 + side] = atlas->get(tex); sideregions[i * 6 + side] = atlas->get(tex);
} else if (atlas->has(TEXTURE_NOTFOUND)) { } else if (atlas->has(TEXTURE_NOTFOUND)) {

View File

@ -154,9 +154,9 @@ std::unique_ptr<Atlas> BlocksPreview::build(
fbo.bind(); fbo.bind();
for (size_t i = 0; i < count; i++) { 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(); 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(); fbo.unbind();

View File

@ -141,11 +141,11 @@ void Skybox::refresh(const DrawContext& pctx, float t, float mie, uint quality)
ctx.setFramebuffer(fbo.get()); ctx.setFramebuffer(fbo.get());
ctx.setViewport(Viewport(size, size)); ctx.setViewport(Viewport(size, size));
auto cubemap = dynamic_cast<Cubemap*>(fbo->getTexture()); auto cubemap = dynamic_cast<Cubemap*>(fbo->getTexture()); //FIXME: Potentional null pointer
ready = true; ready = true;
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
cubemap->bind(); cubemap->bind(); //-V522
shader->use(); shader->use();
const glm::vec3 xaxs[] = { const glm::vec3 xaxs[] = {

View File

@ -172,10 +172,10 @@ void WorldRenderer::setupWorldShader(
{ {
auto inventory = player->getInventory(); auto inventory = player->getInventory();
ItemStack& stack = inventory->getSlot(player->getChosenSlot()); 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; float multiplier = 0.5f;
shader->uniform3f("u_torchlightColor", 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[1] / 15.0f * multiplier,
item->emission[2] / 15.0f * multiplier item->emission[2] / 15.0f * multiplier
); );
@ -222,12 +222,12 @@ void WorldRenderer::renderBlockSelection() {
const auto& selection = player->selection; const auto& selection = player->selection;
auto indices = level->content->getIndices(); auto indices = level->content->getIndices();
blockid_t id = selection.vox.id; 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::ivec3 pos = player->selection.position;
const glm::vec3 point = selection.hitPosition; const glm::vec3 point = selection.hitPosition;
const glm::vec3 norm = selection.normal; const glm::vec3 norm = selection.normal;
const std::vector<AABB>& hitboxes = block->rotatable const std::vector<AABB>& hitboxes = block->rotatable //-V522
? block->rt.hitboxes[selection.vox.state.rotation] ? block->rt.hitboxes[selection.vox.state.rotation]
: block->hitboxes; : block->hitboxes;

View File

@ -121,9 +121,9 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
itemid_t itemid = bound->getItemId(); itemid_t itemid = bound->getItemId();
if (itemid != prevItem) { if (itemid != prevItem) {
if (itemid) { if (itemid) {
auto def = content->getIndices()->items.get(itemid); auto def = content->getIndices()->items.get(itemid); //FIXME: Potentional null pointer
tooltip = util::pascal_case( tooltip = util::pascal_case(
langs::get(util::str2wstr_utf8(def->caption)) langs::get(util::str2wstr_utf8(def->caption)) //-V522
); );
} else { } else {
tooltip.clear(); tooltip.clear();
@ -159,8 +159,8 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
auto previews = assets->get<Atlas>("block-previews"); auto previews = assets->get<Atlas>("block-previews");
auto indices = content->getIndices(); auto indices = content->getIndices();
ItemDef* item = indices->items.get(stack.getItemId()); ItemDef* item = indices->items.get(stack.getItemId()); //FIXME: Potentional null pointer
switch (item->iconType) { switch (item->iconType) { //-V522
case item_icon_type::none: case item_icon_type::none:
break; break;
case item_icon_type::block: { case item_icon_type::block: {
@ -268,12 +268,12 @@ void SlotView::clicked(gui::GUI* gui, mousecode button) {
stack.setCount(halfremain); stack.setCount(halfremain);
} }
} else { } else {
auto stackDef = content->getIndices()->items.get(stack.getItemId()); auto stackDef = content->getIndices()->items.get(stack.getItemId()); //FIXME: Potentional null pointer
if (stack.isEmpty()) { if (stack.isEmpty()) {
stack.set(grabbed); stack.set(grabbed);
stack.setCount(1); stack.setCount(1);
grabbed.setCount(grabbed.getCount()-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); stack.setCount(stack.getCount()+1);
grabbed.setCount(grabbed.getCount()-1); grabbed.setCount(grabbed.getCount()-1);
} }

View File

@ -26,8 +26,8 @@ bool ItemStack::accepts(const ItemStack& other) const {
} }
void ItemStack::move(ItemStack& item, const ContentIndices* indices) { void ItemStack::move(ItemStack& item, const ContentIndices* indices) {
auto def = indices->items.get(item.getItemId()); auto def = indices->items.get(item.getItemId()); //FIXME: Potentional null pointer
int count = std::min(item.count, def->stackSize - this->count); int count = std::min(item.count, def->stackSize - this->count); //-V522
if (isEmpty()) { if (isEmpty()) {
set(ItemStack(item.getItemId(), count)); set(ItemStack(item.getItemId(), count));
} else { } else {

View File

@ -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){ 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); solverR->remove(x,y,z);
solverG->remove(x,y,z); solverG->remove(x,y,z);
solverB->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){ if (chunks->getLight(x,y+1,z, 3) == 0xF){
for (int i = y; i >= 0; i--){ for (int i = y; i >= 0; i--){
voxel* vox = chunks->get(x,i,z); 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; break;
solverS->add(x,i,z, 0xF); solverS->add(x,i,z, 0xF);
} }

View File

@ -62,8 +62,8 @@ void BlocksController::placeBlock(
void BlocksController::updateBlock(int x, int y, int z) { void BlocksController::updateBlock(int x, int y, int z) {
voxel* vox = chunks->get(x, y, z); voxel* vox = chunks->get(x, y, z);
if (vox == nullptr) return; if (vox == nullptr) return;
auto def = level->content->getIndices()->blocks.get(vox->id); auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (def->grounded) { if (def->grounded) { //-V522
const auto& vec = get_ground_direction(def, vox->state.rotation); const auto& vec = get_ground_direction(def, vox->state.rotation);
if (!chunks->isSolidBlock(x + vec.x, y + vec.y, z + vec.z)) { if (!chunks->isSolidBlock(x + vec.x, y + vec.y, z + vec.z)) {
breakBlock(nullptr, def, x, y, z); breakBlock(nullptr, def, x, y, z);
@ -93,8 +93,8 @@ void BlocksController::onBlocksTick(int tickid, int parts) {
int tickRate = blocksTickClock.getTickRate(); int tickRate = blocksTickClock.getTickRate();
for (size_t id = 0; id < indices->blocks.count(); id++) { for (size_t id = 0; id < indices->blocks.count(); id++) {
if ((id + tickid) % parts != 0) continue; if ((id + tickid) % parts != 0) continue;
auto def = indices->blocks.get(id); auto def = indices->blocks.get(id); //FIXME: Potentional null pointer
auto interval = def->tickInterval; auto interval = def->tickInterval; //-V522
if (def->rt.funcsset.onblockstick && tickid / parts % interval == 0) { if (def->rt.funcsset.onblockstick && tickid / parts % interval == 0) {
scripting::on_blocks_tick(def, tickRate / interval); scripting::on_blocks_tick(def, tickRate / interval);
} }
@ -112,8 +112,8 @@ void BlocksController::randomTick(
int by = random.rand() % segheight + s * segheight; int by = random.rand() % segheight + s * segheight;
int bz = random.rand() % CHUNK_D; int bz = random.rand() % CHUNK_D;
const voxel& vox = chunk.voxels[(by * CHUNK_D + bz) * CHUNK_W + bx]; const voxel& vox = chunk.voxels[(by * CHUNK_D + bz) * CHUNK_W + bx];
Block* block = indices->blocks.get(vox.id); Block* block = indices->blocks.get(vox.id); //FIXME: Potentional null pointer
if (block->rt.funcsset.randupdate) { if (block->rt.funcsset.randupdate) { //-V522
scripting::random_update_block( scripting::random_update_block(
block, chunk.x * CHUNK_W + bx, by, chunk.z * CHUNK_D + bz 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); auto inv = chunk->getBlockInventory(lx, y, lz);
if (inv == nullptr) { if (inv == nullptr) {
auto indices = level->content->getIndices(); auto indices = level->content->getIndices();
auto def = indices->blocks.get(chunk->voxels[vox_index(lx, y, lz)].id); auto def = indices->blocks.get(chunk->voxels[vox_index(lx, y, lz)].id); //FIXME: Potentional null pointer
int invsize = def->inventorySize; int invsize = def->inventorySize; //-V522
if (invsize == 0) { if (invsize == 0) {
return 0; return 0;
} }

View File

@ -208,8 +208,8 @@ void PlayerController::onFootstep(const Hitbox& hitbox) {
int z = std::floor(pos.z + half.z * offsetZ); int z = std::floor(pos.z + half.z * offsetZ);
auto vox = level->chunks->get(x, y, z); auto vox = level->chunks->get(x, y, z);
if (vox) { if (vox) {
auto def = level->content->getIndices()->blocks.get(vox->id); auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->obstacle) continue; if (!def->obstacle) continue; //-V522
blocksController->onBlockInteraction( blocksController->onBlockInteraction(
player.get(), player.get(),
glm::ivec3(x, y, z), glm::ivec3(x, y, z),
@ -333,8 +333,8 @@ static int determine_rotation(
static void pick_block( static void pick_block(
ContentIndices* indices, Chunks* chunks, Player* player, int x, int y, int z ContentIndices* indices, Chunks* chunks, Player* player, int x, int y, int z
) { ) {
auto block = indices->blocks.get(chunks->get(x, y, z)->id); auto block = indices->blocks.get(chunks->get(x, y, z)->id); //FIXME: Potentional null pointer
itemid_t id = block->rt.pickingItem; itemid_t id = block->rt.pickingItem; //-V522
auto inventory = player->getInventory(); auto inventory = player->getInventory();
size_t slotid = inventory->findSlotByItem(id, 0, 10); size_t slotid = inventory->findSlotByItem(id, 0, 10);
if (slotid == Inventory::npos) { if (slotid == Inventory::npos) {
@ -492,11 +492,11 @@ void PlayerController::updateInteraction() {
auto inventory = player->getInventory(); auto inventory = player->getInventory();
const ItemStack& stack = inventory->getSlot(player->getChosenSlot()); 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); auto vox = updateSelection(maxDistance);
if (vox == nullptr) { 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); scripting::on_item_use(player.get(), item);
} }
if (selection.entity) { if (selection.entity) {
@ -513,8 +513,8 @@ void PlayerController::updateInteraction() {
return; return;
} }
} }
auto target = indices->blocks.get(vox->id); auto target = indices->blocks.get(vox->id); //FIXME: Potentional null pointer
if (lclick && target->breakable) { if (lclick && target->breakable) { //-V522
blocksController->breakBlock( blocksController->breakBlock(
player.get(), target, iend.x, iend.y, iend.z player.get(), target, iend.x, iend.y, iend.z
); );

View File

@ -122,8 +122,8 @@ static int l_get_x(lua::State* L) {
if (vox == nullptr) { if (vox == nullptr) {
return lua::pushivec3_stack(L, 1, 0, 0); return lua::pushivec3_stack(L, 1, 0, 0);
} }
auto def = level->content->getIndices()->blocks.get(vox->id); auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 1, 0, 0); return lua::pushivec3_stack(L, 1, 0, 0);
} else { } else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; const CoordSystem& rot = def->rotations.variants[vox->state.rotation];
@ -139,8 +139,8 @@ static int l_get_y(lua::State* L) {
if (vox == nullptr) { if (vox == nullptr) {
return lua::pushivec3_stack(L, 0, 1, 0); return lua::pushivec3_stack(L, 0, 1, 0);
} }
auto def = level->content->getIndices()->blocks.get(vox->id); auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 0, 1, 0); return lua::pushivec3_stack(L, 0, 1, 0);
} else { } else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; const CoordSystem& rot = def->rotations.variants[vox->state.rotation];
@ -156,8 +156,8 @@ static int l_get_z(lua::State* L) {
if (vox == nullptr) { if (vox == nullptr) {
return lua::pushivec3_stack(L, 0, 0, 1); return lua::pushivec3_stack(L, 0, 0, 1);
} }
auto def = level->content->getIndices()->blocks.get(vox->id); auto def = level->content->getIndices()->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable) { if (!def->rotatable) { //-V522
return lua::pushivec3_stack(L, 0, 0, 1); return lua::pushivec3_stack(L, 0, 0, 1);
} else { } else {
const CoordSystem& rot = def->rotations.variants[vox->state.rotation]; const CoordSystem& rot = def->rotations.variants[vox->state.rotation];

View File

@ -53,34 +53,34 @@ static DocumentNode getDocumentNode(lua::State* L, int idx = 1) {
static int l_menu_back(lua::State* L) { static int l_menu_back(lua::State* L) {
auto node = getDocumentNode(L); auto node = getDocumentNode(L);
auto menu = dynamic_cast<Menu*>(node.node.get()); auto menu = dynamic_cast<Menu*>(node.node.get()); //FIXME: Potentional null pointer
menu->back(); menu->back(); //-V522
return 0; return 0;
} }
static int l_menu_reset(lua::State* L) { static int l_menu_reset(lua::State* L) {
auto node = getDocumentNode(L); auto node = getDocumentNode(L);
auto menu = dynamic_cast<Menu*>(node.node.get()); auto menu = dynamic_cast<Menu*>(node.node.get()); //FIXME: Potentional null pointer
menu->reset(); menu->reset(); //-V522
return 0; return 0;
} }
static int l_textbox_paste(lua::State* L) { static int l_textbox_paste(lua::State* L) {
auto node = getDocumentNode(L); auto node = getDocumentNode(L);
auto box = dynamic_cast<TextBox*>(node.node.get()); auto box = dynamic_cast<TextBox*>(node.node.get()); //FIXME: Potentional null pointer
auto text = lua::require_string(L, 2); auto text = lua::require_string(L, 2);
box->paste(util::str2wstr_utf8(text)); box->paste(util::str2wstr_utf8(text)); //-V522
return 0; return 0;
} }
static int l_container_add(lua::State* L) { static int l_container_add(lua::State* L) {
auto docnode = getDocumentNode(L); auto docnode = getDocumentNode(L);
auto node = dynamic_cast<Container*>(docnode.node.get()); auto node = dynamic_cast<Container*>(docnode.node.get()); //FIXME: Potentional null pointer
auto xmlsrc = lua::require_string(L, 2); auto xmlsrc = lua::require_string(L, 2);
try { try {
auto subnode = auto subnode =
guiutil::create(xmlsrc, docnode.document->getEnvironment()); guiutil::create(xmlsrc, docnode.document->getEnvironment());
node->add(subnode); node->add(subnode); //-V522
UINode::getIndices(subnode, docnode.document->getMapWriteable()); UINode::getIndices(subnode, docnode.document->getMapWriteable());
} catch (const std::exception& err) { } catch (const std::exception& err) {
throw std::runtime_error(err.what()); throw std::runtime_error(err.what());

View File

@ -51,7 +51,7 @@ static int l_hud_open_block(lua::State* L) {
} }
auto def = content->getIndices()->blocks.get(vox->id); auto def = content->getIndices()->blocks.get(vox->id);
auto assets = engine->getAssets(); auto assets = engine->getAssets();
auto layout = assets->get<UiDocument>(def->uiLayout); auto layout = assets->get<UiDocument>(def->uiLayout);//FIXME: Potentional null pointer //-V522
if (layout == nullptr) { if (layout == nullptr) {
throw std::runtime_error("block '" + def->name + "' has no ui layout"); throw std::runtime_error("block '" + def->name + "' has no ui layout");
} }

View File

@ -76,8 +76,8 @@ const AABB* Chunks::isObstacleAt(float x, float y, float z) {
return &empty; return &empty;
} }
} }
const auto def = indices->blocks.get(v->id); const auto def = indices->blocks.get(v->id); //FIXME: Potentional null pointer
if (def->obstacle) { if (def->obstacle) { //-V522
glm::ivec3 offset {}; glm::ivec3 offset {};
if (v->state.segment) { if (v->state.segment) {
glm::ivec3 point(ix, iy, iz); 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) { bool Chunks::isSolidBlock(int32_t x, int32_t y, int32_t z) {
voxel* v = get(x, y, z); voxel* v = get(x, y, z);
if (v == nullptr) return false; 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) { bool Chunks::isReplaceableBlock(int32_t x, int32_t y, int32_t z) {
voxel* v = get(x, y, z); voxel* v = get(x, y, z);
if (v == nullptr) return false; 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) { bool Chunks::isObstacleBlock(int32_t x, int32_t y, int32_t z) {
voxel* v = get(x, y, z); voxel* v = get(x, y, z);
if (v == nullptr) return false; 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) { 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.axisY * sy;
pos += rotation.axisZ * sz; pos += rotation.axisZ * sz;
if (auto vox = get(pos.x, pos.y, pos.z)) { if (auto vox = get(pos.x, pos.y, pos.z)) {
auto target = indices->blocks.get(vox->id); auto target = indices->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!target->replaceable && vox->id != ignore) { if (!target->replaceable && vox->id != ignore) { //-V522
return false; return false;
} }
} else { } else {
@ -300,8 +300,8 @@ void Chunks::setRotationExtended(
set(pos.x, pos.y, pos.z, def->rt.id, segState); set(pos.x, pos.y, pos.z, def->rt.id, segState);
} else { } else {
vox->state = segState; vox->state = segState;
auto chunk = getChunkByVoxel(pos.x, pos.y, pos.z); auto chunk = getChunkByVoxel(pos.x, pos.y, pos.z); //FIXME: Potentional null pointer
chunk->setModifiedAndUnsaved(); chunk->setModifiedAndUnsaved(); //-V522
segmentBlocks.emplace_back(pos); 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) { if (vox == nullptr) {
return; return;
} }
auto def = indices->blocks.get(vox->id); auto def = indices->blocks.get(vox->id); //FIXME: Potentional null pointer
if (!def->rotatable || vox->state.rotation == index) { if (!def->rotatable || vox->state.rotation == index) { //-V522
return; return;
} }
if (def->rt.extended) { if (def->rt.extended) {
setRotationExtended(def, vox->state, {x, y, z}, index); setRotationExtended(def, vox->state, {x, y, z}, index);
} else { } else {
vox->state.rotation = index; vox->state.rotation = index;
auto chunk = getChunkByVoxel(x, y, z); auto chunk = getChunkByVoxel(x, y, z); //FIXME: Potentional null pointer
chunk->setModifiedAndUnsaved(); chunk->setModifiedAndUnsaved(); //-V522
} }
} }
@ -371,8 +371,8 @@ void Chunks::set(
// block finalization // block finalization
voxel& vox = chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx]; voxel& vox = chunk->voxels[(y * CHUNK_D + lz) * CHUNK_W + lx];
auto prevdef = indices->blocks.get(vox.id); auto prevdef = indices->blocks.get(vox.id); //FIXME: Potentional null pointer
if (prevdef->inventorySize == 0) { if (prevdef->inventorySize == 0) { //-V522
chunk->removeBlockInventory(lx, y, lz); chunk->removeBlockInventory(lx, y, lz);
} }
if (prevdef->rt.extended && !vox.state.segment) { if (prevdef->rt.extended && !vox.state.segment) {
@ -380,11 +380,11 @@ void Chunks::set(
} }
// block initialization // block initialization
auto newdef = indices->blocks.get(id); auto newdef = indices->blocks.get(id); //FIXME: Potentional null pointer
vox.id = id; vox.id = id;
vox.state = state; vox.state = state;
chunk->setModifiedAndUnsaved(); chunk->setModifiedAndUnsaved();
if (!state.segment && newdef->rt.extended) { if (!state.segment && newdef->rt.extended) { //-V522
repairSegments(newdef, state, gx, y, gz); repairSegments(newdef, state, gx, y, gz);
} }
@ -452,8 +452,8 @@ voxel* Chunks::rayCast(
if (voxel == nullptr) { if (voxel == nullptr) {
return nullptr; return nullptr;
} }
const auto def = indices->blocks.get(voxel->id); const auto def = indices->blocks.get(voxel->id); //FIXME: Potentional null pointer
if (def->selectable) { if (def->selectable) { //-V522
end.x = px + t * dx; end.x = px + t * dx;
end.y = py + t * dy; end.y = py + t * dy;
end.z = pz + t * dz; end.z = pz + t * dz;
@ -579,8 +579,8 @@ glm::vec3 Chunks::rayCastToObstacle(
while (t <= maxDist) { while (t <= maxDist) {
voxel* voxel = get(ix, iy, iz); voxel* voxel = get(ix, iy, iz);
if (voxel) { if (voxel) {
const auto def = indices->blocks.get(voxel->id); const auto def = indices->blocks.get(voxel->id); //FIXME: Potentional null pointer
if (def->obstacle) { if (def->obstacle) { //-V522
if (!def->rt.solid) { if (!def->rt.solid) {
const std::vector<AABB>& hitboxes = const std::vector<AABB>& hitboxes =
def->rotatable ? def->rt.hitboxes[voxel->state.rotation] def->rotatable ? def->rt.hitboxes[voxel->state.rotation]

View File

@ -150,8 +150,8 @@ void ChunksStorage::getVoxels(VoxelsVolume* volume, bool backlight) const {
light_t light = clights[cidx]; light_t light = clights[cidx];
if (backlight) { if (backlight) {
auto block = auto block =
indices->blocks.get(voxels[vidx].id); indices->blocks.get(voxels[vidx].id); //FIXME: Potentional null pointer
if (block->lightPassing) { if (block->lightPassing) { //-V522
light = Lightmap::combine( light = Lightmap::combine(
min(15, min(15,
Lightmap::extract(light, 0) + 1), Lightmap::extract(light, 0) + 1),