mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 19:41:51 +00:00
refactor: change pointer parameters to references for Level and Content in various classes
This commit is contained in:
parent
ef2c0b2370
commit
c1b311f3c4
41 changed files with 258 additions and 251 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static int l_set_vel(lua::State* L) {
|
|||
|
||||
static int l_get_rot(lua::State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
return lua::pushvec_stack(L, player->cam);
|
||||
return lua::pushvec_stack(L, player->rotation);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -70,17 +70,17 @@ static int l_set_rot(lua::State* L) {
|
|||
if (!player) {
|
||||
return 0;
|
||||
}
|
||||
glm::vec3& cam = player->cam;
|
||||
glm::vec3& rotation = player->rotation;
|
||||
|
||||
auto x = lua::tonumber(L, 2);
|
||||
auto y = lua::tonumber(L, 3);
|
||||
auto z = cam.z;
|
||||
auto z = rotation.z;
|
||||
if (lua::isnumber(L, 4)) {
|
||||
z = lua::tonumber(L, 4);
|
||||
}
|
||||
cam.x = x;
|
||||
cam.y = y;
|
||||
cam.z = z;
|
||||
rotation.x = x;
|
||||
rotation.y = y;
|
||||
rotation.z = z;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue