@@ -350,15 +350,15 @@ void push_object_properties(lua_State *L, ObjectProperties *prop)
350
350
push_v3f (L, prop->visual_size );
351
351
lua_setfield (L, -2 , " visual_size" );
352
352
353
- lua_newtable (L );
353
+ lua_createtable (L, prop-> textures . size (), 0 );
354
354
u16 i = 1 ;
355
355
for (const std::string &texture : prop->textures ) {
356
356
lua_pushlstring (L, texture.c_str (), texture.size ());
357
357
lua_rawseti (L, -2 , i++);
358
358
}
359
359
lua_setfield (L, -2 , " textures" );
360
360
361
- lua_newtable (L );
361
+ lua_createtable (L, prop-> colors . size (), 0 );
362
362
i = 1 ;
363
363
for (const video::SColor &color : prop->colors ) {
364
364
push_ARGB8 (L, color);
@@ -840,7 +840,7 @@ void push_content_features(lua_State *L, const ContentFeatures &c)
840
840
lua_pushnumber (L, c.connect_sides );
841
841
lua_setfield (L, -2 , " connect_sides" );
842
842
843
- lua_newtable (L );
843
+ lua_createtable (L, c. connects_to . size (), 0 );
844
844
u16 i = 1 ;
845
845
for (const std::string &it : c.connects_to ) {
846
846
lua_pushlstring (L, it.c_str (), it.size ());
@@ -963,7 +963,7 @@ void push_nodebox(lua_State *L, const NodeBox &box)
963
963
964
964
void push_box (lua_State *L, const std::vector<aabb3f> &box)
965
965
{
966
- lua_newtable (L );
966
+ lua_createtable (L, box. size (), 0 );
967
967
u8 i = 1 ;
968
968
for (const aabb3f &it : box) {
969
969
push_aabb3f (L, it);
@@ -1040,7 +1040,7 @@ void read_soundspec(lua_State *L, int index, SimpleSoundSpec &spec)
1040
1040
1041
1041
void push_soundspec (lua_State *L, const SimpleSoundSpec &spec)
1042
1042
{
1043
- lua_newtable (L );
1043
+ lua_createtable (L, 0 , 3 );
1044
1044
lua_pushstring (L, spec.name .c_str ());
1045
1045
lua_setfield (L, -2 , " name" );
1046
1046
lua_pushnumber (L, spec.gain );
@@ -1125,12 +1125,12 @@ MapNode readnode(lua_State *L, int index, const NodeDefManager *ndef)
1125
1125
/* *****************************************************************************/
1126
1126
void pushnode (lua_State *L, const MapNode &n, const NodeDefManager *ndef)
1127
1127
{
1128
- lua_newtable (L );
1128
+ lua_createtable (L, 0 , 3 );
1129
1129
lua_pushstring (L, ndef->get (n).name .c_str ());
1130
1130
lua_setfield (L, -2 , " name" );
1131
- lua_pushnumber (L, n.getParam1 ());
1131
+ lua_pushinteger (L, n.getParam1 ());
1132
1132
lua_setfield (L, -2 , " param1" );
1133
- lua_pushnumber (L, n.getParam2 ());
1133
+ lua_pushinteger (L, n.getParam2 ());
1134
1134
lua_setfield (L, -2 , " param2" );
1135
1135
}
1136
1136
@@ -1163,7 +1163,7 @@ bool string_to_enum(const EnumString *spec, int &result,
1163
1163
{
1164
1164
const EnumString *esp = spec;
1165
1165
while (esp->str ){
1166
- if ( str == std::string ( esp->str )){
1166
+ if (! strcmp ( str. c_str (), esp->str )) {
1167
1167
result = esp->num ;
1168
1168
return true ;
1169
1169
}
@@ -1438,7 +1438,7 @@ ToolCapabilities read_tool_capabilities(
1438
1438
/* *****************************************************************************/
1439
1439
void push_dig_params (lua_State *L,const DigParams ¶ms)
1440
1440
{
1441
- lua_newtable (L );
1441
+ lua_createtable (L, 0 , 3 );
1442
1442
setboolfield (L, -1 , " diggable" , params.diggable );
1443
1443
setfloatfield (L, -1 , " time" , params.time );
1444
1444
setintfield (L, -1 , " wear" , params.wear );
@@ -1447,7 +1447,7 @@ void push_dig_params(lua_State *L,const DigParams ¶ms)
1447
1447
/* *****************************************************************************/
1448
1448
void push_hit_params (lua_State *L,const HitParams ¶ms)
1449
1449
{
1450
- lua_newtable (L );
1450
+ lua_createtable (L, 0 , 3 );
1451
1451
setintfield (L, -1 , " hp" , params.hp );
1452
1452
setintfield (L, -1 , " wear" , params.wear );
1453
1453
}
@@ -1540,9 +1540,9 @@ void read_groups(lua_State *L, int index, ItemGroupList &result)
1540
1540
/* *****************************************************************************/
1541
1541
void push_groups (lua_State *L, const ItemGroupList &groups)
1542
1542
{
1543
- lua_newtable (L );
1543
+ lua_createtable (L, 0 , groups. size () );
1544
1544
for (const auto &group : groups) {
1545
- lua_pushnumber (L, group.second );
1545
+ lua_pushinteger (L, group.second );
1546
1546
lua_setfield (L, -2 , group.first .c_str ());
1547
1547
}
1548
1548
}
@@ -1587,7 +1587,7 @@ void luaentity_get(lua_State *L, u16 id)
1587
1587
lua_getglobal (L, " core" );
1588
1588
lua_getfield (L, -1 , " luaentities" );
1589
1589
luaL_checktype (L, -1 , LUA_TTABLE);
1590
- lua_pushnumber (L, id);
1590
+ lua_pushinteger (L, id);
1591
1591
lua_gettable (L, -2 );
1592
1592
lua_remove (L, -2 ); // Remove luaentities
1593
1593
lua_remove (L, -2 ); // Remove core
@@ -1689,15 +1689,15 @@ static bool push_json_value_helper(lua_State *L, const Json::Value &value,
1689
1689
lua_pushboolean (L, value.asInt ());
1690
1690
break ;
1691
1691
case Json::arrayValue:
1692
- lua_newtable (L );
1692
+ lua_createtable (L, value. size (), 0 );
1693
1693
for (Json::Value::const_iterator it = value.begin ();
1694
1694
it != value.end (); ++it) {
1695
1695
push_json_value_helper (L, *it, nullindex);
1696
1696
lua_rawseti (L, -2 , it.index () + 1 );
1697
1697
}
1698
1698
break ;
1699
1699
case Json::objectValue:
1700
- lua_newtable (L );
1700
+ lua_createtable (L, 0 , value. size () );
1701
1701
for (Json::Value::const_iterator it = value.begin ();
1702
1702
it != value.end (); ++it) {
1703
1703
#ifndef JSONCPP_STRING
@@ -1824,7 +1824,7 @@ void push_objectRef(lua_State *L, const u16 id)
1824
1824
lua_getglobal (L, " core" );
1825
1825
lua_getfield (L, -1 , " object_refs" );
1826
1826
luaL_checktype (L, -1 , LUA_TTABLE);
1827
- lua_pushnumber (L, id);
1827
+ lua_pushinteger (L, id);
1828
1828
lua_gettable (L, -2 );
1829
1829
lua_remove (L, -2 ); // object_refs
1830
1830
lua_remove (L, -2 ); // core
0 commit comments