本文整理汇总了C++中getServer函数的典型用法代码示例。如果您正苦于以下问题:C++ getServer函数的具体用法?C++ getServer怎么用?C++ getServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getServer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_tostring
// get_biome_id(biomename)
// returns the biome id used in biomemap
int ModApiMapgen::l_get_biome_id(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
const char *biome_str = lua_tostring(L, 1);
if (!biome_str)
return 0;
BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
if (!bmgr)
return 0;
Biome *biome = (Biome *)bmgr->getByName(biome_str);
if (!biome || biome->index == OBJDEF_INVALID_INDEX)
return 0;
lua_pushinteger(L, biome->index);
return 1;
}
示例2: log_deprecated
int ModApiMapgen::l_get_mapgen_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
log_deprecated(L, "get_mapgen_params is deprecated; "
"use get_mapgen_setting instead");
std::string value;
MapSettingsManager *settingsmgr =
getServer(L)->getEmergeManager()->map_settings_mgr;
lua_newtable(L);
settingsmgr->getMapSetting("mg_name", &value);
lua_pushstring(L, value.c_str());
lua_setfield(L, -2, "mgname");
settingsmgr->getMapSetting("seed", &value);
std::istringstream ss(value);
u64 seed;
ss >> seed;
lua_pushinteger(L, seed);
lua_setfield(L, -2, "seed");
settingsmgr->getMapSetting("water_level", &value);
lua_pushinteger(L, stoi(value, -32768, 32767));
lua_setfield(L, -2, "water_level");
settingsmgr->getMapSetting("chunksize", &value);
lua_pushinteger(L, stoi(value, -32768, 32767));
lua_setfield(L, -2, "chunksize");
settingsmgr->getMapSetting("mg_flags", &value);
lua_pushstring(L, value.c_str());
lua_setfield(L, -2, "flags");
return 1;
}
示例3: getServer
// get_modnames()
// the returned list is sorted alphabetically for you
int ModApiServer::l_get_modnames(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
// Get a list of mods
std::vector<std::string> modlist;
getServer(L)->getModNames(modlist);
// 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.
std::sort(modlist.begin(), modlist.end());
// Package them up for Lua
lua_createtable(L, modlist.size(), 0);
std::vector<std::string>::iterator iter = modlist.begin();
for (u16 i = 0; iter != modlist.end(); ++iter) {
lua_pushstring(L, iter->c_str());
lua_rawseti(L, -2, ++i);
}
return 1;
}
示例4: QSettings
void Save::odczytajopcje()
{
QMPset = new QSettings( QMPConf, QSettings::IniFormat );
useProxy = QMPset->value( "QMPInternet/useProxy", false ).toBool();
if ( useProxy )
useProxy = getServer( QMPset->value( "QMPInternet/proxy" ).toString(), proxyAddr, proxyPort );
fisW = QMPset->value( "CDAudio/fisW" ).toInt();
fisH = QMPset->value( "CDAudio/fisH" ).toInt();
fs.ui.canCloseTB->setChecked( QMPset->value( "CDAudio/canCloseTB", false ).toBool() );
curF = QMPset->value( "CDAudio/curF" ).toString();
savsek = QMPset->value( "CDAudio/seek" ).toInt();
Enabled = QMPset->value( "CDAudio/Enabled", true ).toBool();
speed = QMPset->value( "CDAudio/speed", 1 ).toInt();
clrB = QMPset->value( "CDAudio/clrB", true ).toBool();
currCD = QMPset->value( "CDAudio/currCD" ).toString();
if ( currCD.isEmpty() )
loadFirst = true;
useDefaultCacheDir = QMPset->value( "CDAudio/useDefaultCacheDir", true ).toBool();
useCDDB = QMPset->value( "CDAudio/useCDDB", true ).toBool();
useUserDatabase = QMPset->value( "CDAudio/useUserDatabase", false ).toBool();
useFDB = QMPset->value( "CDAudio/useFDB", true ).toBool();
useCddbp = QMPset->value( "CDAudio/useCddbp", false).toBool();
userDatabaseServer = QMPset->value( "CDAudio/userDatabaseServer" ).toString();
readCDTXT = QMPset->value( "CDAudio/readCDTXT", true ).toBool();
if ( !useUserDatabase && !useFDB )
useFDB = true;
delete QMPset;
}
示例5: luaL_checkstring
// get_player_ip()
int ModApiServer::l_get_player_ip(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
const char * name = luaL_checkstring(L, 1);
RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name);
if(player == NULL)
{
lua_pushnil(L); // no such player
return 1;
}
try
{
Address addr = getServer(L)->getPeerAddress(player->getPeerId());
std::string ip_str = addr.serializeString();
lua_pushstring(L, ip_str.c_str());
return 1;
} catch (const con::PeerNotFoundException &) {
dstream << FUNCTION_NAME << ": peer was not found" << std::endl;
lua_pushnil(L); // error
return 1;
}
}
示例6: read_v3s16
// rollback_get_node_actions(pos, range, seconds, limit) -> {{actor, pos, time, oldnode, newnode}, ...}
int ModApiRollback::l_rollback_get_node_actions(lua_State *L)
{
v3s16 pos = read_v3s16(L, 1);
int range = luaL_checknumber(L, 2);
time_t seconds = (time_t) luaL_checknumber(L, 3);
int limit = luaL_checknumber(L, 4);
Server *server = getServer(L);
IRollbackManager *rollback = server->getRollbackManager();
if (rollback == NULL) {
return 0;
}
std::list<RollbackAction> actions = rollback->getNodeActors(pos, range, seconds, limit);
std::list<RollbackAction>::iterator iter = actions.begin();
lua_createtable(L, actions.size(), 0);
for (unsigned int i = 1; iter != actions.end(); ++iter, ++i) {
lua_createtable(L, 0, 5); // Make a table with enough space pre-allocated
lua_pushstring(L, iter->actor.c_str());
lua_setfield(L, -2, "actor");
push_v3s16(L, iter->p);
lua_setfield(L, -2, "pos");
lua_pushnumber(L, iter->unix_time);
lua_setfield(L, -2, "time");
push_RollbackNode(L, iter->n_old);
lua_setfield(L, -2, "oldnode");
push_RollbackNode(L, iter->n_new);
lua_setfield(L, -2, "newnode");
lua_rawseti(L, -2, i); // Add action table to main table
}
return 1;
}
示例7: getServer
// register_schematic({schematic}, replacements={})
int ModApiMapgen::l_register_schematic(lua_State *L)
{
SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr;
StringMap replace_names;
if (lua_istable(L, 2))
read_schematic_replacements(L, 2, &replace_names);
Schematic *schem = load_schematic(L, 1, schemmgr->getNodeDef(),
&replace_names);
if (!schem)
return 0;
ObjDefHandle handle = schemmgr->add(schem);
if (handle == OBJDEF_INVALID_HANDLE) {
delete schem;
return 0;
}
lua_pushinteger(L, handle);
return 1;
}
示例8: getServer
// set_mapgen_setting_noiseparams(name, noiseparams, set_default)
// set mapgen config values for noise parameters
int ModApiMapgen::l_set_mapgen_setting_noiseparams(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
MapSettingsManager *settingsmgr =
getServer(L)->getEmergeManager()->map_settings_mgr;
const char *name = luaL_checkstring(L, 1);
NoiseParams np;
if (read_noiseparams(L, 2, &np))
return 0;
bool override_meta = lua_isboolean(L, 3) ? lua_toboolean(L, 3) : false;
if (!settingsmgr->setMapSettingNoiseParams(name, &np, override_meta)) {
errorstream << "set_mapgen_setting_noiseparams: cannot set '"
<< name << "' after initialization" << std::endl;
}
return 0;
}
示例9: getChangeId
BSONObj ChangeLogType::toBSON() const {
BSONObjBuilder builder;
if (_changeId)
builder.append(changeId.name(), getChangeId());
if (_server)
builder.append(server.name(), getServer());
if (_shard)
builder.append(shard.name(), getShard());
if (_clientAddr)
builder.append(clientAddr.name(), getClientAddr());
if (_time)
builder.append(time.name(), getTime());
if (_what)
builder.append(what.name(), getWhat());
if (_ns)
builder.append(ns.name(), getNS());
if (_details)
builder.append(details.name(), getDetails());
return builder.obj();
}
示例10: getServer
// place_schematic(p, schematic, rotation, replacement)
int ModApiMapgen::l_place_schematic(lua_State *L)
{
MAP_LOCK_REQUIRED;
Map *map = &(getEnv(L)->getMap());
SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr;
//// Read position
v3s16 p = check_v3s16(L, 1);
//// Read rotation
int rot = ROTATE_0;
const char *enumstr = lua_tostring(L, 3);
if (enumstr)
string_to_enum(es_Rotation, rot, std::string(enumstr));
//// Read force placement
bool force_placement = true;
if (lua_isboolean(L, 5))
force_placement = lua_toboolean(L, 5);
//// Read node replacements
StringMap replace_names;
if (lua_istable(L, 4))
read_schematic_replacements(L, 4, &replace_names);
//// Read schematic
Schematic *schem = get_or_load_schematic(L, 2, schemmgr, &replace_names);
if (!schem) {
errorstream << "place_schematic: failed to get schematic" << std::endl;
return 0;
}
schem->placeOnMap(map, p, 0, (Rotation)rot, force_placement);
lua_pushboolean(L, true);
return 1;
}
示例11: getServer
void ScriptApiNode::node_on_receive_fields(v3s16 p,
const std::string &formname,
const std::map<std::string, std::string> &fields,
ServerActiveObject *sender)
{
SCRIPTAPI_PRECHECKHEADER
INodeDefManager *ndef = getServer()->ndef();
// If node doesn't exist, we don't know what callback to call
MapNode node = getEnv()->getMap().getNodeNoEx(p);
if(node.getContent() == CONTENT_IGNORE)
return;
// Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), "on_receive_fields"))
return;
// Call function
// param 1
push_v3s16(L, p);
// param 2
lua_pushstring(L, formname.c_str());
// param 3
lua_newtable(L);
for(std::map<std::string, std::string>::const_iterator
i = fields.begin(); i != fields.end(); i++){
const std::string &name = i->first;
const std::string &value = i->second;
lua_pushstring(L, name.c_str());
lua_pushlstring(L, value.c_str(), value.size());
lua_settable(L, -3);
}
// param 4
objectrefGetOrCreate(sender);
if(lua_pcall(L, 4, 0, 0))
scriptError("error: %s", lua_tostring(L, -1));
}
示例12: checkobject
// set_sky(self, bgcolor, type, list, clouds = true)
int ObjectRef::l_set_sky(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
RemotePlayer *player = getplayer(ref);
if (player == NULL)
return 0;
video::SColor bgcolor(255,255,255,255);
read_color(L, 2, &bgcolor);
std::string type = luaL_checkstring(L, 3);
std::vector<std::string> params;
if (lua_istable(L, 4)) {
lua_pushnil(L);
while (lua_next(L, 4) != 0) {
// key at index -2 and value at index -1
if (lua_isstring(L, -1))
params.emplace_back(readParam<std::string>(L, -1));
else
params.emplace_back("");
// removes value, keeps key for next iteration
lua_pop(L, 1);
}
}
if (type == "skybox" && params.size() != 6)
throw LuaError("skybox expects 6 textures");
bool clouds = true;
if (lua_isboolean(L, 5))
clouds = readParam<bool>(L, 5);
getServer(L)->setSky(player, bgcolor, type, params, clouds);
lua_pushboolean(L, true);
return 1;
}
示例13: log_deprecated
// set_mapgen_params(params)
// set mapgen parameters
int ModApiMapgen::l_set_mapgen_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
log_deprecated(L, "set_mapgen_params is deprecated; "
"use set_mapgen_setting instead");
if (!lua_istable(L, 1))
return 0;
MapSettingsManager *settingsmgr =
getServer(L)->getEmergeManager()->map_settings_mgr;
lua_getfield(L, 1, "mgname");
if (lua_isstring(L, -1))
settingsmgr->setMapSetting("mg_name", lua_tostring(L, -1), true);
lua_getfield(L, 1, "seed");
if (lua_isnumber(L, -1))
settingsmgr->setMapSetting("seed", lua_tostring(L, -1), true);
lua_getfield(L, 1, "water_level");
if (lua_isnumber(L, -1))
settingsmgr->setMapSetting("water_level", lua_tostring(L, -1), true);
lua_getfield(L, 1, "chunksize");
if (lua_isnumber(L, -1))
settingsmgr->setMapSetting("chunksize", lua_tostring(L, -1), true);
warn_if_field_exists(L, 1, "flagmask",
"Deprecated: flags field now includes unset flags.");
lua_getfield(L, 1, "flags");
if (lua_isstring(L, -1))
settingsmgr->setMapSetting("mg_flags", lua_tostring(L, -1), true);
return 0;
}
示例14: checkobject
// set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
int ObjectRef::l_set_local_animation(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
Player *player = getplayer(ref);
if (player == NULL)
return 0;
// Do it
v2s32 frames[4];
for (int i=0;i<4;i++) {
if (!lua_isnil(L, 2+1))
frames[i] = read_v2s32(L, 2+i);
}
float frame_speed = 30;
if (!lua_isnil(L, 6))
frame_speed = lua_tonumber(L, 6);
if (!getServer(L)->setLocalPlayerAnimations(player, frames, frame_speed))
return 0;
lua_pushboolean(L, true);
return 0;
}
示例15: lua_pushcfunction
bool ScriptApiItem::item_OnUse(ItemStack &item,
ServerActiveObject *user, const PointedThing &pointed)
{
SCRIPTAPI_PRECHECKHEADER
lua_pushcfunction(L, script_error_handler);
int errorhandler = lua_gettop(L);
// Push callback function on stack
if(!getItemCallback(item.name.c_str(), "on_use"))
return false;
// Call function
LuaItemStack::create(L, item);
objectrefGetOrCreate(user);
pushPointedThing(pointed);
if(lua_pcall(L, 3, 1, errorhandler))
scriptError();
if(!lua_isnil(L, -1))
item = read_item(L,-1, getServer());
lua_pop(L, 2); // Pop item and error handler
return true;
}