mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Code modernization: subfolders (#6283)
* Code modernization: subfolders Modernize various code on subfolders client, network, script, threading, unittests, util * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Make connection.cpp readable in a pointed place + typo
This commit is contained in:
parent
7528986e44
commit
88b436e6a9
49 changed files with 398 additions and 518 deletions
|
@ -551,8 +551,8 @@ int ObjectRef::l_get_local_animation(lua_State *L)
|
|||
float frame_speed;
|
||||
player->getLocalAnimations(frames, &frame_speed);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
push_v2s32(L, frames[i]);
|
||||
for (v2s32 frame : frames) {
|
||||
push_v2s32(L, frame);
|
||||
}
|
||||
|
||||
lua_pushnumber(L, frame_speed);
|
||||
|
@ -611,7 +611,7 @@ int ObjectRef::l_set_bone_position(lua_State *L)
|
|||
ServerActiveObject *co = getobject(ref);
|
||||
if (co == NULL) return 0;
|
||||
// Do it
|
||||
std::string bone = "";
|
||||
std::string bone;
|
||||
if (!lua_isnil(L, 2))
|
||||
bone = lua_tostring(L, 2);
|
||||
v3f position = v3f(0, 0, 0);
|
||||
|
@ -633,7 +633,7 @@ int ObjectRef::l_get_bone_position(lua_State *L)
|
|||
if (co == NULL)
|
||||
return 0;
|
||||
// Do it
|
||||
std::string bone = "";
|
||||
std::string bone;
|
||||
if (!lua_isnil(L, 2))
|
||||
bone = lua_tostring(L, 2);
|
||||
|
||||
|
@ -661,7 +661,7 @@ int ObjectRef::l_set_attach(lua_State *L)
|
|||
return 0;
|
||||
// Do it
|
||||
int parent_id = 0;
|
||||
std::string bone = "";
|
||||
std::string bone;
|
||||
v3f position = v3f(0, 0, 0);
|
||||
v3f rotation = v3f(0, 0, 0);
|
||||
co->getAttachment(&parent_id, &bone, &position, &rotation);
|
||||
|
@ -696,7 +696,7 @@ int ObjectRef::l_get_attach(lua_State *L)
|
|||
|
||||
// Do it
|
||||
int parent_id = 0;
|
||||
std::string bone = "";
|
||||
std::string bone;
|
||||
v3f position = v3f(0, 0, 0);
|
||||
v3f rotation = v3f(0, 0, 0);
|
||||
co->getAttachment(&parent_id, &bone, &position, &rotation);
|
||||
|
@ -722,7 +722,7 @@ int ObjectRef::l_set_detach(lua_State *L)
|
|||
return 0;
|
||||
|
||||
int parent_id = 0;
|
||||
std::string bone = "";
|
||||
std::string bone;
|
||||
v3f position;
|
||||
v3f rotation;
|
||||
co->getAttachment(&parent_id, &bone, &position, &rotation);
|
||||
|
@ -1223,7 +1223,7 @@ int ObjectRef::l_get_attribute(lua_State *L)
|
|||
|
||||
std::string attr = luaL_checkstring(L, 2);
|
||||
|
||||
std::string value = "";
|
||||
std::string value;
|
||||
if (co->getExtendedAttribute(attr, &value)) {
|
||||
lua_pushstring(L, value.c_str());
|
||||
return 1;
|
||||
|
@ -1684,9 +1684,9 @@ int ObjectRef::l_set_sky(lua_State *L)
|
|||
while (lua_next(L, 4) != 0) {
|
||||
// key at index -2 and value at index -1
|
||||
if (lua_isstring(L, -1))
|
||||
params.push_back(lua_tostring(L, -1));
|
||||
params.emplace_back(lua_tostring(L, -1));
|
||||
else
|
||||
params.push_back("");
|
||||
params.emplace_back("");
|
||||
// removes value, keeps key for next iteration
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
@ -1720,15 +1720,14 @@ int ObjectRef::l_get_sky(lua_State *L)
|
|||
bool clouds;
|
||||
|
||||
player->getSky(&bgcolor, &type, ¶ms, &clouds);
|
||||
type = type == "" ? "regular" : type;
|
||||
type = type.empty() ? "regular" : type;
|
||||
|
||||
push_ARGB8(L, bgcolor);
|
||||
lua_pushlstring(L, type.c_str(), type.size());
|
||||
lua_newtable(L);
|
||||
s16 i = 1;
|
||||
for (std::vector<std::string>::iterator it = params.begin();
|
||||
it != params.end(); ++it) {
|
||||
lua_pushlstring(L, it->c_str(), it->size());
|
||||
for (const std::string ¶m : params) {
|
||||
lua_pushlstring(L, param.c_str(), param.size());
|
||||
lua_rawseti(L, -2, i);
|
||||
i++;
|
||||
}
|
||||
|
@ -1865,15 +1864,6 @@ ObjectRef::ObjectRef(ServerActiveObject *object):
|
|||
//infostream<<"ObjectRef created for id="<<m_object->getId()<<std::endl;
|
||||
}
|
||||
|
||||
ObjectRef::~ObjectRef()
|
||||
{
|
||||
/*if (m_object)
|
||||
infostream<<"ObjectRef destructing for id="
|
||||
<<m_object->getId()<<std::endl;
|
||||
else
|
||||
infostream<<"ObjectRef destructing for id=unknown"<<std::endl;*/
|
||||
}
|
||||
|
||||
// Creates an ObjectRef and leaves it on top of stack
|
||||
// Not callable from Lua; all references are created on the C side.
|
||||
void ObjectRef::create(lua_State *L, ServerActiveObject *object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue