• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ getServer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中getServer函数的典型用法代码示例。如果您正苦于以下问题:C++ getServer函数的具体用法?C++ getServer怎么用?C++ getServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getServer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:kwolekr,项目名称:minetest,代码行数:24,代码来源:l_mapgen.cpp


示例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;
}
开发者ID:kwolekr,项目名称:minetest,代码行数:39,代码来源:l_mapgen.cpp


示例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;
}
开发者ID:yzziizzy,项目名称:minetest,代码行数:24,代码来源:l_server.cpp


示例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;
}
开发者ID:darwinbeing,项目名称:Hifi-Pod,代码行数:39,代码来源:save.cpp


示例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;
	}
}
开发者ID:yzziizzy,项目名称:minetest,代码行数:23,代码来源:l_server.cpp


示例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;
}
开发者ID:Falcon-peregrinus,项目名称:freeminer,代码行数:40,代码来源:l_rollback.cpp


示例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;
}
开发者ID:multicoder,项目名称:minetest,代码行数:23,代码来源:l_mapgen.cpp


示例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;
}
开发者ID:kwolekr,项目名称:minetest,代码行数:24,代码来源:l_mapgen.cpp


示例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();
}
开发者ID:EvgeniyPatlan,项目名称:percona-server-mongodb,代码行数:22,代码来源:type_changelog.cpp


示例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;
}
开发者ID:DarkDracoon,项目名称:minetest,代码行数:39,代码来源:l_mapgen.cpp


示例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));
}
开发者ID:Imberflur,项目名称:minetest,代码行数:38,代码来源:s_node.cpp


示例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;
}
开发者ID:rubenwardy,项目名称:minetest,代码行数:39,代码来源:l_object.cpp


示例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;
}
开发者ID:DarkDracoon,项目名称:minetest,代码行数:40,代码来源:l_mapgen.cpp


示例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;
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:24,代码来源:l_object.cpp


示例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;
}
开发者ID:0151n,项目名称:minetest,代码行数:23,代码来源:s_item.cpp


示例16: qDebug

    void Client::parseSetInfo()
    {
        qDebug() << "SetInfo received!";

        if (this->status_!=ST_ADMIN)
        {
            qDebug() << "cmd not allowed";
            this->disconnectFromHost();
            return;
        }

        if (buf_.size()< CMD1_SETINFO_SIZE) // TODO: remove magic number
            return;     // not all data avaliable

        qint16 clientId=getClientId(buf_);
        QString caption=getClientCaption(buf_);

        getServer()->setClientCaption(clientId,caption);

        buf_ = buf_.right(buf_.size() - CMD1_SETINFO_SIZE);
        if (buf_.size() > 0)
            onDataReceived();   // If something in buffer - parse again
    }
开发者ID:Delta3system,项目名称:delta3-server,代码行数:23,代码来源:client.cpp


示例17: lua_pushcfunction

bool ScriptApiNode::node_on_dig(v3s16 p, MapNode node,
		ServerActiveObject *digger)
{
	SCRIPTAPI_PRECHECKHEADER

	lua_pushcfunction(L, script_error_handler);
	int errorhandler = lua_gettop(L);

	INodeDefManager *ndef = getServer()->ndef();

	// Push callback function on stack
	if(!getItemCallback(ndef->get(node).name.c_str(), "on_dig"))
		return false;

	// Call function
	push_v3s16(L, p);
	pushnode(L, node, ndef);
	objectrefGetOrCreate(digger);
	if(lua_pcall(L, 3, 0, errorhandler))
		scriptError();
	lua_pop(L, 1); // Pop error handler
	return true;
}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:23,代码来源:s_node.cpp


示例18: luaL_checkstring

// kick_player(name, [reason]) -> success
int ModApiServer::l_kick_player(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	const char *name = luaL_checkstring(L, 1);
	std::string message;
	if (lua_isstring(L, 2))
	{
		message = std::string("Kicked: ") + lua_tostring(L, 2);
	}
	else
	{
		message = "Kicked.";
	}
	Player *player = getEnv(L)->getPlayer(name);
	if (player == NULL)
	{
		lua_pushboolean(L, false); // No such player
		return 1;
	}
	getServer(L)->DenyAccess_Legacy(player->peer_id, utf8_to_wide(message));
	lua_pushboolean(L, true);
	return 1;
}
开发者ID:00c,项目名称:minetest,代码行数:24,代码来源:l_server.cpp


示例19: luaL_checkstring

// kick_player(name, [reason]) -> success
int ModApiServer::l_kick_player(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	const char *name = luaL_checkstring(L, 1);
	std::string message;
	if (lua_isstring(L, 2))
	{
		message = std::string("Kicked: ") + lua_tostring(L, 2);
	}
	else
	{
		message = "Kicked.";
	}

	RemotePlayer *player = dynamic_cast<ServerEnvironment *>(getEnv(L))->getPlayer(name);
	if (player == NULL) {
		lua_pushboolean(L, false); // No such player
		return 1;
	}
	getServer(L)->DenyAccess(player->peer_id, message);
	lua_pushboolean(L, true);
	return 1;
}
开发者ID:alexxvk,项目名称:freeminer,代码行数:24,代码来源:l_server.cpp


示例20: 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::list<std::string> mods_unsorted, mods_sorted;
	getServer(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(std::list<std::string>::iterator i = mods_unsorted.begin();
			i != mods_unsorted.end(); ++i) {
		bool added = false;
		for(std::list<std::string>::iterator x = mods_sorted.begin();
				x != mods_sorted.end(); ++x) {
			// I doubt anybody using Minetest will be using
			// anything not ASCII based :)
			if(i->compare(*x) <= 0) {
				mods_sorted.insert(x, *i);
				added = true;
				break;
			}
		}
		if(!added)
			mods_sorted.push_back(*i);
	}

	// Package them up for Lua
	lua_createtable(L, mods_sorted.size(), 0);
	std::list<std::string>::iterator iter = mods_sorted.begin();
	for (u16 i = 0; iter != mods_sorted.end(); iter++) {
		lua_pushstring(L, iter->c_str());
		lua_rawseti(L, -2, ++i);
	}
	return 1;
}
开发者ID:1CoreyDev1,项目名称:minetest,代码行数:39,代码来源:l_server.cpp



注:本文中的getServer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ getService函数代码示例发布时间:2022-05-28
下一篇:
C++ getSequence函数代码示例发布时间:2022-05-28
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap