refactor: PVS-Studio warnings fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -12,12 +12,9 @@
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
static EntityDef* require_entity_def(lua::State* L) {
|
||||
static const EntityDef* require_entity_def(lua::State* L) {
|
||||
auto indices = content->getIndices();
|
||||
auto id = lua::tointeger(L, 1);
|
||||
if (static_cast<size_t>(id) >= indices->entities.count()) {
|
||||
return nullptr;
|
||||
}
|
||||
return indices->entities.get(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
static ItemDef* get_item_def(lua::State* L, int idx) {
|
||||
static const ItemDef* get_item_def(lua::State* L, int idx) {
|
||||
auto indices = content->getIndices();
|
||||
auto id = lua::tointeger(L, idx);
|
||||
if (static_cast<size_t>(id) >= indices->items.count()) {
|
||||
return nullptr;
|
||||
}
|
||||
return indices->items.get(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user