refactor: PVS-Studio warnings fixes
This commit is contained in:
@@ -196,38 +196,38 @@ void scripting::on_world_quit() {
|
||||
scripting::controller = nullptr;
|
||||
}
|
||||
|
||||
void scripting::on_blocks_tick(const Block* block, int tps) {
|
||||
std::string name = block->name + ".blockstick";
|
||||
void scripting::on_blocks_tick(const Block& block, int tps) {
|
||||
std::string name = block.name + ".blockstick";
|
||||
lua::emit_event(lua::get_main_thread(), name, [tps](auto L) {
|
||||
return lua::pushinteger(L, tps);
|
||||
});
|
||||
}
|
||||
|
||||
void scripting::update_block(const Block* block, int x, int y, int z) {
|
||||
std::string name = block->name + ".update";
|
||||
void scripting::update_block(const Block& block, int x, int y, int z) {
|
||||
std::string name = block.name + ".update";
|
||||
lua::emit_event(lua::get_main_thread(), name, [x, y, z](auto L) {
|
||||
return lua::pushivec3_stack(L, x, y, z);
|
||||
});
|
||||
}
|
||||
|
||||
void scripting::random_update_block(const Block* block, int x, int y, int z) {
|
||||
std::string name = block->name + ".randupdate";
|
||||
void scripting::random_update_block(const Block& block, int x, int y, int z) {
|
||||
std::string name = block.name + ".randupdate";
|
||||
lua::emit_event(lua::get_main_thread(), name, [x, y, z](auto L) {
|
||||
return lua::pushivec3_stack(L, x, y, z);
|
||||
});
|
||||
}
|
||||
|
||||
void scripting::on_block_placed(
|
||||
Player* player, const Block* block, int x, int y, int z
|
||||
Player* player, const Block& block, int x, int y, int z
|
||||
) {
|
||||
std::string name = block->name + ".placed";
|
||||
std::string name = block.name + ".placed";
|
||||
lua::emit_event(lua::get_main_thread(), name, [x, y, z, player](auto L) {
|
||||
lua::pushivec3_stack(L, x, y, z);
|
||||
lua::pushinteger(L, player ? player->getId() : -1);
|
||||
return 4;
|
||||
});
|
||||
auto world_event_args = [block, x, y, z, player](lua::State* L) {
|
||||
lua::pushinteger(L, block->rt.id);
|
||||
auto world_event_args = [&](lua::State* L) {
|
||||
lua::pushinteger(L, block.rt.id);
|
||||
lua::pushivec3_stack(L, x, y, z);
|
||||
lua::pushinteger(L, player ? player->getId() : -1);
|
||||
return 5;
|
||||
@@ -244,10 +244,10 @@ void scripting::on_block_placed(
|
||||
}
|
||||
|
||||
void scripting::on_block_broken(
|
||||
Player* player, const Block* block, int x, int y, int z
|
||||
Player* player, const Block& block, int x, int y, int z
|
||||
) {
|
||||
if (block->rt.funcsset.onbroken) {
|
||||
std::string name = block->name + ".broken";
|
||||
if (block.rt.funcsset.onbroken) {
|
||||
std::string name = block.name + ".broken";
|
||||
lua::emit_event(
|
||||
lua::get_main_thread(),
|
||||
name,
|
||||
@@ -258,8 +258,8 @@ void scripting::on_block_broken(
|
||||
}
|
||||
);
|
||||
}
|
||||
auto world_event_args = [block, x, y, z, player](lua::State* L) {
|
||||
lua::pushinteger(L, block->rt.id);
|
||||
auto world_event_args = [&](lua::State* L) {
|
||||
lua::pushinteger(L, block.rt.id);
|
||||
lua::pushivec3_stack(L, x, y, z);
|
||||
lua::pushinteger(L, player ? player->getId() : -1);
|
||||
return 5;
|
||||
@@ -276,9 +276,9 @@ void scripting::on_block_broken(
|
||||
}
|
||||
|
||||
bool scripting::on_block_interact(
|
||||
Player* player, const Block* block, glm::ivec3 pos
|
||||
Player* player, const Block& block, glm::ivec3 pos
|
||||
) {
|
||||
std::string name = block->name + ".interact";
|
||||
std::string name = block.name + ".interact";
|
||||
return lua::emit_event(lua::get_main_thread(), name, [pos, player](auto L) {
|
||||
lua::pushivec3_stack(L, pos.x, pos.y, pos.z);
|
||||
lua::pushinteger(L, player->getId());
|
||||
@@ -286,8 +286,8 @@ bool scripting::on_block_interact(
|
||||
});
|
||||
}
|
||||
|
||||
bool scripting::on_item_use(Player* player, const ItemDef* item) {
|
||||
std::string name = item->name + ".use";
|
||||
bool scripting::on_item_use(Player* player, const ItemDef& item) {
|
||||
std::string name = item.name + ".use";
|
||||
return lua::emit_event(
|
||||
lua::get_main_thread(),
|
||||
name,
|
||||
@@ -296,9 +296,9 @@ bool scripting::on_item_use(Player* player, const ItemDef* item) {
|
||||
}
|
||||
|
||||
bool scripting::on_item_use_on_block(
|
||||
Player* player, const ItemDef* item, glm::ivec3 ipos, glm::ivec3 normal
|
||||
Player* player, const ItemDef& item, glm::ivec3 ipos, glm::ivec3 normal
|
||||
) {
|
||||
std::string name = item->name + ".useon";
|
||||
std::string name = item.name + ".useon";
|
||||
return lua::emit_event(
|
||||
lua::get_main_thread(),
|
||||
name,
|
||||
@@ -312,9 +312,9 @@ bool scripting::on_item_use_on_block(
|
||||
}
|
||||
|
||||
bool scripting::on_item_break_block(
|
||||
Player* player, const ItemDef* item, int x, int y, int z
|
||||
Player* player, const ItemDef& item, int x, int y, int z
|
||||
) {
|
||||
std::string name = item->name + ".blockbreakby";
|
||||
std::string name = item.name + ".blockbreakby";
|
||||
return lua::emit_event(
|
||||
lua::get_main_thread(),
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user