mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
refactor: PVS-Studio warnings fixes
This commit is contained in:
parent
7bc96affbb
commit
245b39be62
22 changed files with 311 additions and 302 deletions
|
|
@ -11,12 +11,9 @@
|
|||
|
||||
using namespace scripting;
|
||||
|
||||
static Block* require_block(lua::State* L) {
|
||||
static const Block* require_block(lua::State* L) {
|
||||
auto indices = content->getIndices();
|
||||
auto id = lua::tointeger(L, 1);
|
||||
if (static_cast<size_t>(id) >= indices->blocks.count()) {
|
||||
return nullptr;
|
||||
}
|
||||
return indices->blocks.get(id);
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +75,7 @@ static int l_seek_origin(lua::State* L) {
|
|||
auto y = lua::tointeger(L, 2);
|
||||
auto z = lua::tointeger(L, 3);
|
||||
auto vox = level->chunks->get(x, y, z);
|
||||
auto def = indices->blocks.get(vox->id);
|
||||
auto& def = indices->blocks.require(vox->id);
|
||||
return lua::pushivec3_stack(
|
||||
L, level->chunks->seekOrigin({x, y, z}, def, vox->state)
|
||||
);
|
||||
|
|
@ -330,7 +327,7 @@ static int l_place(lua::State* L) {
|
|||
}
|
||||
auto player = level->getObject<Player>(playerid);
|
||||
controller->getBlocksController()->placeBlock(
|
||||
player ? player.get() : nullptr, def, int2blockstate(state), x, y, z
|
||||
player ? player.get() : nullptr, *def, int2blockstate(state), x, y, z
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -344,7 +341,7 @@ static int l_destruct(lua::State* L) {
|
|||
if (voxel == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
const auto def = level->content->getIndices()->blocks.get(voxel->id);
|
||||
auto& def = level->content->getIndices()->blocks.require(voxel->id);
|
||||
auto player = level->getObject<Player>(playerid);
|
||||
controller->getBlocksController()->breakBlock(
|
||||
player ? player.get() : nullptr, def, x, y, z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue