mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Various random code cleanups
This commit is contained in:
parent
358658fa34
commit
7892541383
73 changed files with 216 additions and 285 deletions
|
@ -1175,8 +1175,7 @@ void push_palette(lua_State *L, const std::vector<video::SColor> *palette)
|
|||
lua_createtable(L, palette->size(), 0);
|
||||
int newTable = lua_gettop(L);
|
||||
int index = 1;
|
||||
std::vector<video::SColor>::const_iterator iter;
|
||||
for (iter = palette->begin(); iter != palette->end(); ++iter) {
|
||||
for (auto iter = palette->begin(); iter != palette->end(); ++iter) {
|
||||
push_ARGB8(L, (*iter));
|
||||
lua_rawseti(L, newTable, index);
|
||||
index++;
|
||||
|
@ -1829,7 +1828,7 @@ void push_hit_params(lua_State *L,const HitParams ¶ms)
|
|||
/******************************************************************************/
|
||||
|
||||
bool getflagsfield(lua_State *L, int table, const char *fieldname,
|
||||
FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
|
||||
const FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
|
||||
{
|
||||
lua_getfield(L, table, fieldname);
|
||||
|
||||
|
@ -1840,7 +1839,7 @@ bool getflagsfield(lua_State *L, int table, const char *fieldname,
|
|||
return success;
|
||||
}
|
||||
|
||||
bool read_flags(lua_State *L, int index, FlagDesc *flagdesc,
|
||||
bool read_flags(lua_State *L, int index, const FlagDesc *flagdesc,
|
||||
u32 *flags, u32 *flagmask)
|
||||
{
|
||||
if (lua_isstring(L, index)) {
|
||||
|
@ -1855,7 +1854,7 @@ bool read_flags(lua_State *L, int index, FlagDesc *flagdesc,
|
|||
return true;
|
||||
}
|
||||
|
||||
u32 read_flags_table(lua_State *L, int table, FlagDesc *flagdesc, u32 *flagmask)
|
||||
u32 read_flags_table(lua_State *L, int table, const FlagDesc *flagdesc, u32 *flagmask)
|
||||
{
|
||||
u32 flags = 0, mask = 0;
|
||||
char fnamebuf[64] = "no";
|
||||
|
@ -1880,7 +1879,7 @@ u32 read_flags_table(lua_State *L, int table, FlagDesc *flagdesc, u32 *flagmask)
|
|||
return flags;
|
||||
}
|
||||
|
||||
void push_flags_string(lua_State *L, FlagDesc *flagdesc, u32 flags, u32 flagmask)
|
||||
void push_flags_string(lua_State *L, const FlagDesc *flagdesc, u32 flags, u32 flagmask)
|
||||
{
|
||||
std::string flagstring = writeFlagString(flags, flagdesc, flagmask);
|
||||
lua_pushlstring(L, flagstring.c_str(), flagstring.size());
|
||||
|
|
|
@ -120,21 +120,21 @@ void read_groups(lua_State *L, int index, ItemGroupList &result);
|
|||
|
||||
void push_groups(lua_State *L, const ItemGroupList &groups);
|
||||
|
||||
//TODO rename to "read_enum_field"
|
||||
// TODO: rename to "read_enum_field" and replace with type-safe template
|
||||
int getenumfield(lua_State *L, int table, const char *fieldname,
|
||||
const EnumString *spec, int default_);
|
||||
|
||||
bool getflagsfield(lua_State *L, int table, const char *fieldname,
|
||||
FlagDesc *flagdesc, u32 *flags, u32 *flagmask);
|
||||
const FlagDesc *flagdesc, u32 *flags, u32 *flagmask);
|
||||
|
||||
bool read_flags(lua_State *L, int index, FlagDesc *flagdesc,
|
||||
bool read_flags(lua_State *L, int index, const FlagDesc *flagdesc,
|
||||
u32 *flags, u32 *flagmask);
|
||||
|
||||
void push_flags_string(lua_State *L, FlagDesc *flagdesc,
|
||||
void push_flags_string(lua_State *L, const FlagDesc *flagdesc,
|
||||
u32 flags, u32 flagmask);
|
||||
|
||||
u32 read_flags_table(lua_State *L, int table,
|
||||
FlagDesc *flagdesc, u32 *flagmask);
|
||||
const FlagDesc *flagdesc, u32 *flagmask);
|
||||
|
||||
void push_items(lua_State *L, const std::vector<ItemStack> &items);
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ static void push_craft_recipe(lua_State *L, IGameDef *gdef,
|
|||
CraftOutput output = recipe->getOutput(input, gdef);
|
||||
|
||||
lua_newtable(L); // items
|
||||
std::vector<ItemStack>::const_iterator iter = input.items.begin();
|
||||
auto iter = input.items.begin();
|
||||
for (u16 j = 1; iter != input.items.end(); ++iter, j++) {
|
||||
if (iter->empty())
|
||||
continue;
|
||||
|
@ -457,7 +457,7 @@ static void push_craft_recipes(lua_State *L, IGameDef *gdef,
|
|||
|
||||
lua_createtable(L, recipes.size(), 0);
|
||||
|
||||
std::vector<CraftDefinition*>::const_iterator it = recipes.begin();
|
||||
auto it = recipes.begin();
|
||||
for (unsigned i = 0; it != recipes.end(); ++it) {
|
||||
lua_newtable(L);
|
||||
push_craft_recipe(L, gdef, *it, output);
|
||||
|
|
|
@ -250,7 +250,7 @@ bool read_schematic_def(lua_State *L, int index,
|
|||
u8 param2 = getintfield_default(L, -1, "param2", 0);
|
||||
|
||||
//// Find or add new nodename-to-ID mapping
|
||||
std::unordered_map<std::string, content_t>::iterator it = name_id_map.find(name);
|
||||
auto it = name_id_map.find(name);
|
||||
content_t name_index;
|
||||
if (it != name_id_map.end()) {
|
||||
name_index = it->second;
|
||||
|
|
|
@ -36,7 +36,7 @@ int ModApiRollback::l_rollback_get_node_actions(lua_State *L)
|
|||
}
|
||||
|
||||
std::list<RollbackAction> actions = rollback->getNodeActors(pos, range, seconds, limit);
|
||||
std::list<RollbackAction>::iterator iter = actions.begin();
|
||||
auto iter = actions.begin();
|
||||
|
||||
lua_createtable(L, actions.size(), 0);
|
||||
for (unsigned int i = 1; iter != actions.end(); ++iter, ++i) {
|
||||
|
@ -86,8 +86,7 @@ int ModApiRollback::l_rollback_revert_actions_by(lua_State *L)
|
|||
lua_pushboolean(L, success);
|
||||
lua_createtable(L, log.size(), 0);
|
||||
unsigned long i = 0;
|
||||
for(std::list<std::string>::const_iterator iter = log.begin();
|
||||
iter != log.end(); ++i, ++iter) {
|
||||
for(auto iter = log.begin(); iter != log.end(); ++i, ++iter) {
|
||||
lua_pushnumber(L, i);
|
||||
lua_pushstring(L, iter->c_str());
|
||||
lua_settable(L, -3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue