aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen
ModeNameSize
-rw-r--r--CMakeLists.txt745logplain
-rw-r--r--cavegen.cpp26226logplain
-rw-r--r--cavegen.h7098logplain
-rw-r--r--dungeongen.cpp18486logplain
-rw-r--r--dungeongen.h3951logplain
-rw-r--r--mapgen.cpp33340logplain
-rw-r--r--mapgen.h8564logplain
-rw-r--r--mapgen_carpathian.cpp22104logplain
-rw-r--r--mapgen_carpathian.h3059logplain
-rw-r--r--mapgen_flat.cpp10862logplain
-rw-r--r--mapgen_flat.h2216logplain
-rw-r--r--mapgen_fractal.cpp14875logplain
-rw-r--r--mapgen_fractal.h2549logplain
-rw-r--r--mapgen_singlenode.cpp2994logplain
-rw-r--r--mapgen_singlenode.h1476logplain
-rw-r--r--mapgen_v5.cpp11660logplain
-rw-r--r--mapgen_v5.h2114logplain
-rw-r--r--mapgen_v6.cpp35154logplain
-rw-r--r--mapgen_v6.h4462logplain
-rw-r--r--mapgen_v7.cpp21988logplain
-rw-r--r--mapgen_v7.h3331logplain
-rw-r--r--mapgen_valleys.cpp19374logplain
-rw-r--r--mapgen_valleys.h2899logplain
-rw-r--r--mg_biome.cpp11969logplain
-rw-r--r--mg_biome.h5884logplain
-rw-r--r--mg_decoration.cpp11729logplain
-rw-r--r--mg_decoration.h3505logplain
-rw-r--r--mg_ore.cpp14366logplain
-rw-r--r--mg_ore.h5017logplain
-rw-r--r--mg_schematic.cpp15110logplain
-rw-r--r--mg_schematic.h4090logplain
-rw-r--r--treegen.cpp24854logplain
-rw-r--r--treegen.h2776logplain
t">)); bool success = o->m_settings->remove(key); lua_pushboolean(L, success); return 1; } // get_names(self) -> {key1, ...} int LuaSettings::l_get_names(lua_State* L) { NO_MAP_LOCK_REQUIRED; LuaSettings* o = checkobject(L, 1); std::vector<std::string> keys = o->m_settings->getNames(); lua_newtable(L); for (unsigned int i=0; i < keys.size(); i++) { lua_pushstring(L, keys[i].c_str()); lua_rawseti(L, -2, i + 1); } return 1; } // write(self) -> success int LuaSettings::l_write(lua_State* L) { NO_MAP_LOCK_REQUIRED; LuaSettings* o = checkobject(L, 1); bool success = o->m_settings->updateConfigFile(o->m_filename.c_str()); lua_pushboolean(L, success); return 1; } // to_table(self) -> {[key1]=value1,...} int LuaSettings::l_to_table(lua_State* L) { NO_MAP_LOCK_REQUIRED; LuaSettings* o = checkobject(L, 1); std::vector<std::string> keys = o->m_settings->getNames(); lua_newtable(L); for (unsigned int i=0; i < keys.size(); i++) { lua_pushstring(L, o->m_settings->get(keys[i]).c_str()); lua_setfield(L, -2, keys[i].c_str()); } return 1; } LuaSettings::LuaSettings(const char* filename) { m_filename = std::string(filename); m_settings = new Settings(); m_settings->readConfigFile(m_filename.c_str()); } LuaSettings::~LuaSettings() { delete m_settings; } void LuaSettings::Register(lua_State* L) { lua_newtable(L); int methodtable = lua_gettop(L); luaL_newmetatable(L, className); int metatable = lua_gettop(L); lua_pushliteral(L, "__metatable"); lua_pushvalue(L, methodtable); lua_settable(L, metatable); // hide metatable from Lua getmetatable() lua_pushliteral(L, "__index"); lua_pushvalue(L, methodtable); lua_settable(L, metatable); lua_pushliteral(L, "__gc"); lua_pushcfunction(L, gc_object); lua_settable(L, metatable); lua_pop(L, 1); // drop metatable luaL_openlib(L, 0, methods, 0); // fill methodtable lua_pop(L, 1); // drop methodtable // Can be created from Lua (Settings(filename)) lua_register(L, className, create_object); } // LuaSettings(filename) // Creates an LuaSettings and leaves it on top of stack int LuaSettings::create_object(lua_State* L) { NO_MAP_LOCK_REQUIRED; const char* filename = luaL_checkstring(L, 1); LuaSettings* o = new LuaSettings(filename); *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, className); lua_setmetatable(L, -2); return 1; } LuaSettings* LuaSettings::checkobject(lua_State* L, int narg) { NO_MAP_LOCK_REQUIRED; luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); if(!ud) luaL_typerror(L, narg, className); return *(LuaSettings**)ud; // unbox pointer } const char LuaSettings::className[] = "Settings"; const luaL_reg LuaSettings::methods[] = { luamethod(LuaSettings, get), luamethod(LuaSettings, get_bool), luamethod(LuaSettings, set), luamethod(LuaSettings, remove), luamethod(LuaSettings, get_names), luamethod(LuaSettings, write), luamethod(LuaSettings, to_table), {0,0} };