Skip to content

Commit 9f25aba

Browse files
committedOct 4, 2015
Hide mapgens from main menu not intended for end users
1 parent 0850d3b commit 9f25aba

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed
 

Diff for: ‎doc/menu_lua_api.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ core.get_game(index)
141141
addon_mods_paths = {[1] = <path>,},
142142
}
143143
core.get_games() -> table of all games in upper format (possible in async calls)
144-
core.get_mapgen_names() -> table of all map generator algorithms registered in
145-
the core (possible in async calls)
144+
core.get_mapgen_names([include_hidden=false]) -> table of map generator algorithms
145+
registered in the core (possible in async calls)
146146

147147
Favorites:
148148
core.get_favorites(location) -> list of favorites (possible in async calls)

Diff for: ‎src/emerge.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
5454
struct MapgenDesc {
5555
const char *name;
5656
MapgenFactory *factory;
57+
bool is_user_visible;
5758
};
5859

5960
class EmergeThread : public Thread {
@@ -100,10 +101,10 @@ class EmergeThread : public Thread {
100101
////
101102

102103
MapgenDesc g_reg_mapgens[] = {
103-
{"v5", new MapgenFactoryV5},
104-
{"v6", new MapgenFactoryV6},
105-
{"v7", new MapgenFactoryV7},
106-
{"singlenode", new MapgenFactorySinglenode},
104+
{"v5", new MapgenFactoryV5, true},
105+
{"v6", new MapgenFactoryV6, true},
106+
{"v7", new MapgenFactoryV7, true},
107+
{"singlenode", new MapgenFactorySinglenode, false},
107108
};
108109

109110
////
@@ -343,10 +344,13 @@ bool EmergeManager::isBlockUnderground(v3s16 blockpos)
343344
}
344345

345346

346-
void EmergeManager::getMapgenNames(std::vector<const char *> *mgnames)
347+
void EmergeManager::getMapgenNames(
348+
std::vector<const char *> *mgnames, bool include_hidden)
347349
{
348-
for (u32 i = 0; i != ARRLEN(g_reg_mapgens); i++)
349-
mgnames->push_back(g_reg_mapgens[i].name);
350+
for (u32 i = 0; i != ARRLEN(g_reg_mapgens); i++) {
351+
if (include_hidden || g_reg_mapgens[i].is_user_visible)
352+
mgnames->push_back(g_reg_mapgens[i].name);
353+
}
350354
}
351355

352356

Diff for: ‎src/emerge.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class EmergeManager {
139139
bool isBlockUnderground(v3s16 blockpos);
140140

141141
static MapgenFactory *getMapgenFactory(const std::string &mgname);
142-
static void getMapgenNames(std::vector<const char *> *mgnames);
142+
static void getMapgenNames(
143+
std::vector<const char *> *mgnames, bool include_hidden);
143144
static v3s16 getContainingChunk(v3s16 blockpos, s16 chunksize);
144145

145146
private:

Diff for: ‎src/script/lua_api/l_mainmenu.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ int ModApiMainMenu::l_set_topleft_text(lua_State *L)
707707
int ModApiMainMenu::l_get_mapgen_names(lua_State *L)
708708
{
709709
std::vector<const char *> names;
710-
EmergeManager::getMapgenNames(&names);
710+
EmergeManager::getMapgenNames(&names, lua_toboolean(L, 1));
711711

712712
lua_newtable(L);
713713
for (size_t i = 0; i != names.size(); i++) {

0 commit comments

Comments
 (0)
Please sign in to comment.