refactor: change pointer parameters to references for Level and Content in various classes

This commit is contained in:
MihailRis
2024-12-25 18:53:53 +03:00
parent ef2c0b2370
commit c1b311f3c4
41 changed files with 258 additions and 251 deletions
+5 -5
View File
@@ -133,7 +133,7 @@ static int l_get_x(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec_stack(L, glm::ivec3(1, 0, 0));
}
const auto& def = level->content->getIndices()->blocks.require(vox->id);
const auto& def = level->content.getIndices()->blocks.require(vox->id);
if (!def.rotatable) {
return lua::pushivec_stack(L, glm::ivec3(1, 0, 0));
} else {
@@ -150,7 +150,7 @@ static int l_get_y(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec_stack(L, glm::ivec3(0, 1, 0));
}
const auto& def = level->content->getIndices()->blocks.require(vox->id);
const auto& def = level->content.getIndices()->blocks.require(vox->id);
if (!def.rotatable) {
return lua::pushivec_stack(L, glm::ivec3(0, 1, 0));
} else {
@@ -167,7 +167,7 @@ static int l_get_z(lua::State* L) {
if (vox == nullptr) {
return lua::pushivec_stack(L, glm::ivec3(0, 0, 1));
}
const auto& def = level->content->getIndices()->blocks.require(vox->id);
const auto& def = level->content.getIndices()->blocks.require(vox->id);
if (!def.rotatable) {
return lua::pushivec_stack(L, glm::ivec3(0, 0, 1));
} else {
@@ -367,7 +367,7 @@ static int l_place(lua::State* L) {
if (!blocks_agent::get(*level->chunks, x, y, z)) {
return 0;
}
const auto def = level->content->getIndices()->blocks.get(id);
const auto def = level->content.getIndices()->blocks.get(id);
if (def == nullptr) {
throw std::runtime_error(
"there is no block with index " + std::to_string(id)
@@ -389,7 +389,7 @@ static int l_destruct(lua::State* L) {
if (vox == nullptr) {
return 0;
}
auto& def = level->content->getIndices()->blocks.require(vox->id);
auto& def = level->content.getIndices()->blocks.require(vox->id);
auto player = level->players->get(playerid);
controller->getBlocksController()->breakBlock(player, def, x, y, z);
return 0;