mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Migrate to STL containers/algorithms.
This commit is contained in:
parent
e204bedf1d
commit
6a1670dbc3
63 changed files with 1330 additions and 1417 deletions
|
@ -895,24 +895,24 @@ static int l_get_modpath(lua_State *L)
|
|||
static int l_get_modnames(lua_State *L)
|
||||
{
|
||||
// Get a list of mods
|
||||
core::list<std::string> mods_unsorted, mods_sorted;
|
||||
std::list<std::string> mods_unsorted, mods_sorted;
|
||||
get_server(L)->getModNames(mods_unsorted);
|
||||
|
||||
// Take unsorted items from mods_unsorted and sort them into
|
||||
// mods_sorted; not great performance but the number of mods on a
|
||||
// server will likely be small.
|
||||
for(core::list<std::string>::Iterator i = mods_unsorted.begin();
|
||||
i != mods_unsorted.end(); i++)
|
||||
for(std::list<std::string>::iterator i = mods_unsorted.begin();
|
||||
i != mods_unsorted.end(); ++i)
|
||||
{
|
||||
bool added = false;
|
||||
for(core::list<std::string>::Iterator x = mods_sorted.begin();
|
||||
x != mods_unsorted.end(); x++)
|
||||
for(std::list<std::string>::iterator x = mods_sorted.begin();
|
||||
x != mods_unsorted.end(); ++x)
|
||||
{
|
||||
// I doubt anybody using Minetest will be using
|
||||
// anything not ASCII based :)
|
||||
if((*i).compare(*x) <= 0)
|
||||
{
|
||||
mods_sorted.insert_before(x, *i);
|
||||
mods_sorted.insert(x, *i);
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ static int l_get_modnames(lua_State *L)
|
|||
// Package them up for Lua
|
||||
lua_newtable(L);
|
||||
int new_table = lua_gettop(L);
|
||||
core::list<std::string>::Iterator i = mods_sorted.begin();
|
||||
std::list<std::string>::iterator i = mods_sorted.begin();
|
||||
while(i != mods_sorted.end())
|
||||
{
|
||||
lua_pushvalue(L, insertion_func);
|
||||
|
@ -939,7 +939,7 @@ static int l_get_modnames(lua_State *L)
|
|||
{
|
||||
script_error(L, "error: %s", lua_tostring(L, -1));
|
||||
}
|
||||
i++;
|
||||
++i;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue