aboutsummaryrefslogtreecommitdiff
path: root/src/noise.cpp
Commit message (Expand)AuthorAge
* Add Mapgen V7, reorganize biomeskwolekr2013-04-07
* Fix most warnings, re-fix MSVC compile errorkwolekr2013-02-26
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Fix and improve noise map functionskwolekr2013-02-06
* Finish and clean up mapgen configurationkwolekr2013-01-21
* Readded and optimized mapgen V6kwolekr2013-01-21
* Cleaned & enhanced noise object managementkwolekr2013-01-21
* Add initial Lua biomedef support, fixed biome selectionkwolekr2013-01-21
* The new mapgen, noise functions, et al.kwolekr2013-01-21
* Replace pow() with multiplikation to improve speedPilzAdam2012-11-02
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* updated noise stuffPerttu Ahola2011-06-26
* New map generator added (and SQLite, messed up the commits at that time...) (...Perttu Ahola2011-06-25
* tested out and commented out some new stuff for the terrain generator, to be ...Perttu Ahola2011-04-26
* mapgen work-in-progressPerttu Ahola2011-03-02
* mapgen tweakingPerttu Ahola2011-03-01
* A third try on terrain generation. No trees yet.Perttu Ahola2011-02-28
* fixed 3d noise and made 2d noise fasterPerttu Ahola2011-02-27
* 3d noise stuffPerttu Ahola2011-02-26
* made it to work with my windows compilerPerttu Ahola2011-02-08
* added noise.*Perttu Ahola2011-02-05
m">51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <cassert> #include <log.h> #include "lua_api/l_modchannels.h" #include "l_internal.h" #include "modchannels.h" int ModApiChannels::l_mod_channel_join(lua_State *L) { if (!lua_isstring(L, 1)) return 0; std::string channel = luaL_checkstring(L, 1); if (channel.empty()) return 0; getGameDef(L)->joinModChannel(channel); assert(getGameDef(L)->getModChannel(channel) != nullptr); ModChannelRef::create(L, channel); int object = lua_gettop(L); lua_pushvalue(L, object); return 1; } void ModApiChannels::Initialize(lua_State *L, int top) { API_FCT(mod_channel_join); } /* * ModChannelRef */ ModChannelRef::ModChannelRef(const std::string &modchannel) : m_modchannel_name(modchannel) { } int ModChannelRef::l_leave(lua_State *L) { ModChannelRef *ref = checkobject(L, 1); getGameDef(L)->leaveModChannel(ref->m_modchannel_name); return 0; } int ModChannelRef::l_send_all(lua_State *L) { ModChannelRef *ref = checkobject(L, 1); ModChannel *channel = getobject(L, ref); if (!channel || !channel->canWrite()) return 0; // @TODO serialize message std::string message = luaL_checkstring(L, 2); getGameDef(L)->sendModChannelMessage(channel->getName(), message); return 0; } int ModChannelRef::l_is_writeable(lua_State *L) { ModChannelRef *ref = checkobject(L, 1); ModChannel *channel = getobject(L, ref); if (!channel) return 0; lua_pushboolean(L, channel->canWrite()); return 1; } void ModChannelRef::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 } void ModChannelRef::create(lua_State *L, const std::string &channel) { ModChannelRef *o = new ModChannelRef(channel); *(void **)(lua_newuserdata(L, sizeof(void *))) = o; luaL_getmetatable(L, className); lua_setmetatable(L, -2); } int ModChannelRef::gc_object(lua_State *L) { ModChannelRef *o = *(ModChannelRef **)(lua_touserdata(L, 1)); delete o; return 0; } ModChannelRef *ModChannelRef::checkobject(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); if (!ud) luaL_typerror(L, narg, className); return *(ModChannelRef **)ud; // unbox pointer } ModChannel *ModChannelRef::getobject(lua_State *L, ModChannelRef *ref) { return getGameDef(L)->getModChannel(ref->m_modchannel_name); } // clang-format off const char ModChannelRef::className[] = "ModChannelRef"; const luaL_Reg ModChannelRef::methods[] = { luamethod(ModChannelRef, leave), luamethod(ModChannelRef, is_writeable), luamethod(ModChannelRef, send_all), {0, 0}, }; // clang-format on