您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FATAL_ERROR_IF函数代码示例

51自学网 2021-06-01 20:40:40
  C++
这篇教程C++ FATAL_ERROR_IF函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了FATAL_ERROR_IF函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getMapgenFactory

void EmergeManager::initMapgens(){	if (m_mapgens.size())		return;	MapgenFactory *mgfactory = getMapgenFactory(params.mg_name);	if (!mgfactory) {		errorstream << "EmergeManager: mapgen " << params.mg_name <<			" not registered; falling back to " << DEFAULT_MAPGEN << std::endl;		params.mg_name = DEFAULT_MAPGEN;		mgfactory = getMapgenFactory(params.mg_name);		FATAL_ERROR_IF(mgfactory == NULL, "Couldn't use any mapgen!");	}	if (!params.sparams) {		params.sparams = mgfactory->createMapgenParams();		params.sparams->readParams(g_settings);	}	for (u32 i = 0; i != m_threads.size(); i++) {		Mapgen *mg = mgfactory->createMapgen(i, &params, this);		m_mapgens.push_back(mg);	}}
开发者ID:viphotman,项目名称:minetest,代码行数:26,


示例2: writeU8

void CNodeDefManager::serialize(std::ostream &os, u16 protocol_version) const{	writeU8(os, 1); // version	u16 count = 0;	std::ostringstream os2(std::ios::binary);	for (u32 i = 0; i < m_content_features.size(); i++) {		if (i == CONTENT_IGNORE || i == CONTENT_AIR				|| i == CONTENT_UNKNOWN)			continue;		const ContentFeatures *f = &m_content_features[i];		if (f->name == "")			continue;		writeU16(os2, i);		// Wrap it in a string to allow different lengths without		// strict version incompatibilities		std::ostringstream wrapper_os(std::ios::binary);		f->serialize(wrapper_os, protocol_version);		os2<<serializeString(wrapper_os.str());		// must not overflow		u16 next = count + 1;		FATAL_ERROR_IF(next < count, "Overflow");		count++;	}	writeU16(os, count);	os << serializeLongString(os2.str());}
开发者ID:ERIIX,项目名称:minetest,代码行数:27,


示例3: FATAL_ERROR_IF

bool GUIEngine::setTexture(texture_layer layer, std::string texturepath,		bool tile_image, unsigned int minsize){	video::IVideoDriver* driver = m_device->getVideoDriver();	FATAL_ERROR_IF(driver == 0, "Could not get video driver");	if (m_textures[layer].texture != NULL)	{		driver->removeTexture(m_textures[layer].texture);		m_textures[layer].texture = NULL;	}	if ((texturepath == "") || !fs::PathExists(texturepath))	{		return false;	}	m_textures[layer].texture = driver->getTexture(texturepath.c_str());	m_textures[layer].tile    = tile_image;	m_textures[layer].minsize = minsize;	if (m_textures[layer].texture == NULL)	{		return false;	}	return true;}
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:28,


示例4: data_rw

scene::IAnimatedMesh* Client::getMesh(const std::string &filename){	StringMap::const_iterator it = m_mesh_data.find(filename);	if (it == m_mesh_data.end()) {		errorstream << "Client::getMesh(): Mesh not found: /"" << filename			<< "/"" << std::endl;		return NULL;	}	const std::string &data    = it->second;	scene::ISceneManager *smgr = m_device->getSceneManager();	// Create the mesh, remove it from cache and return it	// This allows unique vertex colors and other properties for each instance	Buffer<char> data_rw(data.c_str(), data.size()); // Const-incorrect Irrlicht	io::IFileSystem *irrfs = m_device->getFileSystem();	io::IReadFile *rfile   = irrfs->createMemoryReadFile(			*data_rw, data_rw.getSize(), filename.c_str());	FATAL_ERROR_IF(!rfile, "Could not create/open RAM file");	scene::IAnimatedMesh *mesh = smgr->getMesh(rfile);	rfile->drop();	// NOTE: By playing with Irrlicht refcounts, maybe we could cache a bunch	// of uniquely named instances and re-use them	mesh->grab();	smgr->getMeshCache()->removeMesh(mesh);	return mesh;}
开发者ID:BlockMen,项目名称:minetest,代码行数:27,


示例5: getStack

// Push the list of callbacks (a lua table).// Then push nargs arguments.// Then call this function, which// - runs the callbacks// - replaces the table and arguments with the return value,//     computed depending on modevoid ScriptApiBase::runCallbacksRaw(int nargs,		RunCallbacksMode mode, const char *fxn){	lua_State *L = getStack();	FATAL_ERROR_IF(lua_gettop(L) < nargs + 1, "Not enough arguments");	// Insert error handler	lua_pushcfunction(L, script_error_handler);	int errorhandler = lua_gettop(L) - nargs - 1;	lua_insert(L, errorhandler);	// Insert run_callbacks between error handler and table	lua_getglobal(L, "core");	lua_getfield(L, -1, "run_callbacks");	lua_remove(L, -2);	lua_insert(L, errorhandler + 1);	// Insert mode after table	lua_pushnumber(L, (int)mode);	lua_insert(L, errorhandler + 3);	// Stack now looks like this:	// ... <error handler> <run_callbacks> <table> <mode> <arg#1> <arg#2> ... <arg#n>	int result = lua_pcall(L, nargs + 2, 1, errorhandler);	if (result != 0)		scriptError(result, fxn);	lua_remove(L, -2); // Remove error handler}
开发者ID:JohnWayne1986,项目名称:minetest,代码行数:36,


示例6: lua_getglobal

int ModApiUtil::l_request_insecure_environment(lua_State *L){	NO_MAP_LOCK_REQUIRED;	// Just return _G if security is disabled	if (!ScriptApiSecurity::isSecure(L)) {		lua_getglobal(L, "_G");		return 1;	}	// We have to make sure that this function is being called directly by	// a mod, otherwise a malicious mod could override this function and	// steal its return value.	lua_Debug info;	// Make sure there's only one item below this function on the stack...	if (lua_getstack(L, 2, &info)) {		return 0;	}	FATAL_ERROR_IF(!lua_getstack(L, 1, &info), "lua_getstack() failed");	FATAL_ERROR_IF(!lua_getinfo(L, "S", &info), "lua_getinfo() failed");	// ...and that that item is the main file scope.	if (strcmp(info.what, "main") != 0) {		return 0;	}	// Get mod name	lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);	if (!lua_isstring(L, -1)) {		return 0;	}	// Check secure.trusted_mods	const char *mod_name = lua_tostring(L, -1);	std::string trusted_mods = g_settings->get("secure.trusted_mods");	trusted_mods.erase(std::remove_if(trusted_mods.begin(),			trusted_mods.end(), static_cast<int(*)(int)>(&std::isspace)),			trusted_mods.end());	std::vector<std::string> mod_list = str_split(trusted_mods, ',');	if (std::find(mod_list.begin(), mod_list.end(), mod_name) ==			mod_list.end()) {		return 0;	}	// Push insecure environment	lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);	return 1;}
开发者ID:CasimirKaPazi,项目名称:minetest,代码行数:47,


示例7: getenv

const char *getHomeOrFail(){	const char *home = getenv("HOME");	// In rare cases the HOME environment variable may be unset	FATAL_ERROR_IF(!home,		"Required environment variable HOME is not set");	return home;}
开发者ID:HybridDog,项目名称:minetest,代码行数:8,


示例8: FATAL_ERROR_IF

ClientEvent *Client::getClientEvent(){	FATAL_ERROR_IF(m_client_event_queue.empty(),			"Cannot getClientEvent, queue is empty.");	ClientEvent *event = m_client_event_queue.front();	m_client_event_queue.pop();	return event;}
开发者ID:EXio4,项目名称:minetest,代码行数:9,


示例9: setSystemPaths

bool setSystemPaths(){	char buf[BUFSIZ];	// Find path of executable and set path_share relative to it	FATAL_ERROR_IF(!getCurrentExecPath(buf, sizeof(buf)),		"Failed to get current executable path");	pathRemoveFile(buf, '//');	// Use "./bin/.."	path_share = std::string(buf) + "//..";	// Use "C:/Documents and Settings/user/Application Data/<PROJECT_NAME>"	DWORD len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf));	FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA");	path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME;	return true;}
开发者ID:HybridDog,项目名称:minetest,代码行数:19,


示例10: gen_srp_v

// Call lower level SRP code to generate a verifier with the// given pointers. Contains the preparations, call parameters// and error checking common to all srp verifier generation code.// See docs of srp_create_salted_verification_key for more info.static inline void gen_srp_v(const std::string &name,	const std::string &password, char **salt, size_t *salt_len,	char **bytes_v, size_t *len_v){	std::string n_name = lowercase(name);	SRP_Result res = srp_create_salted_verification_key(SRP_SHA256, SRP_NG_2048,		n_name.c_str(), (const unsigned char *)password.c_str(),		password.size(), (unsigned char **)salt, salt_len,		(unsigned char **)bytes_v, len_v, NULL, NULL);	FATAL_ERROR_IF(res != SRP_OK, "Couldn't create salted SRP verifier");}
开发者ID:00c,项目名称:minetest,代码行数:15,


示例11: DSTACK

void ClientEnvironment::setLocalPlayer(LocalPlayer *player){	DSTACK(FUNCTION_NAME);	/*		It is a failure if already is a local player	*/	FATAL_ERROR_IF(m_local_player != NULL,		"Local player already allocated");	m_local_player = player;}
开发者ID:DomtronVox,项目名称:minetest,代码行数:11,


示例12: getFont

unsigned int FontEngine::getTextHeight(unsigned int font_size, FontMode mode){	irr::gui::IGUIFont* font = getFont(font_size, mode);	// use current skin font as fallback	if (font == NULL) {		font = m_env->getSkin()->getFont();	}	FATAL_ERROR_IF(font == NULL, "Could not get skin font");	return font->getDimension(L"Some unimportant example String").Height;}
开发者ID:proller,项目名称:minetest,代码行数:12,


示例13: switch

void Client::startAuth(AuthMechanism chosen_auth_mechanism){	m_chosen_auth_mech = chosen_auth_mechanism;	switch (chosen_auth_mechanism) {		case AUTH_MECHANISM_FIRST_SRP: {			// send srp verifier to server			NetworkPacket resp_pkt(TOSERVER_FIRST_SRP, 0);			char *salt, *bytes_v;			std::size_t len_salt, len_v;			salt = NULL;			getSRPVerifier(getPlayerName(), m_password,				&salt, &len_salt, &bytes_v, &len_v);			resp_pkt				<< std::string((char*)salt, len_salt)				<< std::string((char*)bytes_v, len_v)				<< (u8)((m_password == "") ? 1 : 0);			free(salt);			free(bytes_v);			Send(&resp_pkt);			break;		}		case AUTH_MECHANISM_SRP:		case AUTH_MECHANISM_LEGACY_PASSWORD: {			u8 based_on = 1;			if (chosen_auth_mechanism == AUTH_MECHANISM_LEGACY_PASSWORD) {				m_password = translatePassword(getPlayerName(), m_password);				based_on = 0;			}			std::string playername_u = lowercase(getPlayerName());			m_auth_data = srp_user_new(SRP_SHA256, SRP_NG_2048,				getPlayerName().c_str(), playername_u.c_str(),				(const unsigned char *) m_password.c_str(),				m_password.length(), NULL, NULL);			char *bytes_A = 0;			size_t len_A = 0;			SRP_Result res = srp_user_start_authentication(				(struct SRPUser *) m_auth_data, NULL, NULL, 0,				(unsigned char **) &bytes_A, &len_A);			FATAL_ERROR_IF(res != SRP_OK, "Creating local SRP user failed.");			NetworkPacket resp_pkt(TOSERVER_SRP_BYTES_A, 0);			resp_pkt << std::string(bytes_A, len_A) << based_on;			Send(&resp_pkt);			break;		}		case AUTH_MECHANISM_NONE:			break; // not handled in this method	}}
开发者ID:BlockMen,项目名称:minetest,代码行数:52,


示例14: mbtowc

KeyPress::KeyPress(const char *name){	if (strlen(name) == 0) {		Key = irr::KEY_KEY_CODES_COUNT;		Char = L'/0';		m_name = "";		return;	}	if (strlen(name) <= 4) {		// Lookup by resulting character		int chars_read = mbtowc(&Char, name, 1);		FATAL_ERROR_IF(chars_read != 1, "Unexpected multibyte character");		try {			struct table_key k = lookup_keychar(Char);			m_name = k.Name;			Key = k.Key;			return;		} catch (UnknownKeycode &e) {};	} else {		// Lookup by name		m_name = name;		try {			struct table_key k = lookup_keyname(name);			Key = k.Key;			Char = k.Char;			return;		} catch (UnknownKeycode &e) {};	}	// It's not a known key, complain and try to do something	Key = irr::KEY_KEY_CODES_COUNT;	int chars_read = mbtowc(&Char, name, 1);	FATAL_ERROR_IF(chars_read != 1, "Unexpected multibyte character");	m_name = "";	warningstream << "KeyPress: Unknown key '" << name << "', falling back to first char.";}
开发者ID:Caellian,项目名称:minetest,代码行数:37,


示例15: luaL_newstate

ScriptApiBase::ScriptApiBase(){	#ifdef SCRIPTAPI_LOCK_DEBUG	m_locked = false;	#endif	m_luastack = luaL_newstate();	FATAL_ERROR_IF(!m_luastack, "luaL_newstate() failed");	luaL_openlibs(m_luastack);	// Add and save an error handler	lua_pushcfunction(m_luastack, script_error_handler);	m_errorhandler = lua_gettop(m_luastack);	// Make the ScriptApiBase* accessible to ModApiBase	lua_pushlightuserdata(m_luastack, this);	lua_setfield(m_luastack, LUA_REGISTRYINDEX, "scriptapi");	// If we are using LuaJIT add a C++ wrapper function to catch	// exceptions thrown in Lua -> C++ calls#if USE_LUAJIT	lua_pushlightuserdata(m_luastack, (void*) script_exception_wrapper);	luaJIT_setmode(m_luastack, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);	lua_pop(m_luastack, 1);#endif	// Add basic globals	lua_newtable(m_luastack);	lua_setglobal(m_luastack, "core");	lua_pushstring(m_luastack, DIR_DELIM);	lua_setglobal(m_luastack, "DIR_DELIM");	lua_pushstring(m_luastack, porting::getPlatformName());	lua_setglobal(m_luastack, "PLATFORM");	// m_secure gets set to true inside	// ScriptApiSecurity::initializeSecurity(), if neccessary.	// Default to false otherwise	m_secure = false;	m_server = NULL;	m_environment = NULL;	m_guiengine = NULL;}
开发者ID:4aiman,项目名称:Magichet-stable,代码行数:46,


示例16: registerItem

	virtual void registerItem(const ItemDefinition &def)	{		verbosestream<<"ItemDefManager: registering /""<<def.name<<"/""<<std::endl;		// Ensure that the "" item (the hand) always has ToolCapabilities		if (def.name.empty())			FATAL_ERROR_IF(!def.tool_capabilities, "Hand does not have ToolCapabilities");		if(m_item_definitions.count(def.name) == 0)			m_item_definitions[def.name] = new ItemDefinition(def);		else			*(m_item_definitions[def.name]) = def;		// Remove conflicting alias if it exists		bool alias_removed = (m_aliases.erase(def.name) != 0);		if(alias_removed)			infostream<<"ItemDefManager: erased alias "<<def.name					<<" because item was defined"<<std::endl;	}
开发者ID:EXio4,项目名称:minetest,代码行数:18,


示例17: FATAL_ERROR_IF

EmergeThread *EmergeManager::getOptimalThread(){	size_t nthreads = m_threads.size();	FATAL_ERROR_IF(nthreads == 0, "No emerge threads!");	size_t index = 0;	size_t nitems_lowest = m_threads[0]->m_block_queue.size();	for (size_t i = 1; i < nthreads; i++) {		size_t nitems = m_threads[i]->m_block_queue.size();		if (nitems < nitems_lowest) {			index = i;			nitems_lowest = nitems;		}	}	return m_threads[index];}
开发者ID:viphotman,项目名称:minetest,代码行数:19,


示例18: FATAL_ERROR_IF

void Client::sendInventoryFields(const std::string &formname,		const StringMap &fields){	size_t fields_size = fields.size();	FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of inventory fields");	NetworkPacket pkt(TOSERVER_INVENTORY_FIELDS, 0);	pkt << formname << (u16) (fields_size & 0xFFFF);	StringMap::const_iterator it;	for (it = fields.begin(); it != fields.end(); ++it) {		const std::string &name  = it->first;		const std::string &value = it->second;		pkt << name;		pkt.putLongString(value);	}	Send(&pkt);}
开发者ID:BlockMen,项目名称:minetest,代码行数:19,


示例19: os

std::string ClientMediaDownloader::serializeRequiredHashSet(){	std::ostringstream os(std::ios::binary);	writeU32(os, MTHASHSET_FILE_SIGNATURE); // signature	writeU16(os, 1);                        // version	// Write list of hashes of files that have not been	// received (found in cache) yet	for (std::map<std::string, FileStatus*>::iterator			it = m_files.begin();			it != m_files.end(); ++it) {		if (!it->second->received) {			FATAL_ERROR_IF(it->second->sha1.size() != 20, "Invalid SHA1 size");			os << it->second->sha1;		}	}	return os.str();}
开发者ID:00c,项目名称:minetest,代码行数:20,


示例20: FATAL_ERROR_IF

void Client::sendNodemetaFields(v3s16 p, const std::string &formname,		const std::map<std::string, std::string> &fields){	size_t fields_size = fields.size();	FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of nodemeta fields");	NetworkPacket pkt(TOSERVER_NODEMETA_FIELDS, 0);	pkt << p << formname << (u16) (fields_size & 0xFFFF);	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;		pkt << name;		pkt.putLongString(value);	}	Send(&pkt);}
开发者ID:LeMagnesium,项目名称:minetest,代码行数:21,


示例21: sanity_check

void LuaLBM::trigger(ServerEnvironment *env, v3s16 p, MapNode n){	ServerScripting *scriptIface = env->getScriptIface();	scriptIface->realityCheck();	lua_State *L = scriptIface->getStack();	sanity_check(lua_checkstack(L, 20));	StackUnroller stack_unroller(L);	int error_handler = PUSH_ERROR_HANDLER(L);	// Get registered_lbms	lua_getglobal(L, "core");	lua_getfield(L, -1, "registered_lbms");	luaL_checktype(L, -1, LUA_TTABLE);	lua_remove(L, -2); // Remove core	// Get registered_lbms[m_id]	lua_pushnumber(L, m_id);	lua_gettable(L, -2);	FATAL_ERROR_IF(lua_isnil(L, -1), "Entry with given id not found in registered_lbms table");	lua_remove(L, -2); // Remove registered_lbms	scriptIface->setOriginFromTable(-1);	// Call action	luaL_checktype(L, -1, LUA_TTABLE);	lua_getfield(L, -1, "action");	luaL_checktype(L, -1, LUA_TFUNCTION);	lua_remove(L, -2); // Remove registered_lbms[m_id]	push_v3s16(L, p);	pushnode(L, n, env->getGameDef()->ndef());	int result = lua_pcall(L, 2, 0, error_handler);	if (result)		scriptIface->scriptError(result, "LuaLBM::trigger");	lua_pop(L, 1); // Pop error handler}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:39,


示例22: os

/*	u16 command	u16 number of files requested	for each file {		u16 length of name		string name	}*/void Client::request_media(const std::vector<std::string> &file_requests){	std::ostringstream os(std::ios_base::binary);	writeU16(os, TOSERVER_REQUEST_MEDIA);	size_t file_requests_size = file_requests.size();	FATAL_ERROR_IF(file_requests_size > 0xFFFF, "Unsupported number of file requests");	// Packet dynamicly resized	NetworkPacket pkt(TOSERVER_REQUEST_MEDIA, 2 + 0);	pkt << (u16) (file_requests_size & 0xFFFF);	for (const std::string &file_request : file_requests) {		pkt << file_request;	}	Send(&pkt);	infostream << "Client: Sending media request list to server ("			<< file_requests.size() << " files. packet size)" << std::endl;}
开发者ID:EXio4,项目名称:minetest,代码行数:30,


示例23: init_args

bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args){    init_args(game_params, cmd_args);    // List video modes if requested    if (list_video_modes)        return print_video_modes();    if (!init_engine(game_params.log_level)) {        errorstream << "Could not initialize game engine." << std::endl;        return false;    }    // Create time getter    g_timegetter = new IrrlichtTimeGetter(device);    // Speed tests (done after irrlicht is loaded to get timer)    if (cmd_args.getFlag("speedtests")) {        dstream << "Running speed tests" << std::endl;        speed_tests();        return true;    }    video::IVideoDriver *video_driver = device->getVideoDriver();    if (video_driver == NULL) {        errorstream << "Could not initialize video driver." << std::endl;        return false;    }    porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);    /*    	This changes the minimum allowed number of vertices in a VBO.    	Default is 500.    */    //driver->setMinHardwareBufferVertexCount(50);    // Create game callback for menus    g_gamecallback = new MainGameCallback(device);    device->setResizable(true);    if (random_input)        input = new RandomInputHandler();    else        input = new RealInputHandler(device, receiver);    smgr = device->getSceneManager();    smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);    guienv = device->getGUIEnvironment();    skin = guienv->getSkin();    skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));    skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0));    skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30));    skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));    skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50));    skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));    g_fontengine = new FontEngine(g_settings, guienv);    FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed.");#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2    // Irrlicht 1.8 input colours    skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));    skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 96, 134, 49));#endif    // Create the menu clouds    if (!g_menucloudsmgr)        g_menucloudsmgr = smgr->createNewSceneManager();    if (!g_menuclouds)        g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(),                                  g_menucloudsmgr, -1, rand(), 100);    g_menuclouds->update(v2f(0, 0), video::SColor(255, 200, 200, 255));    scene::ICameraSceneNode* camera;    camera = g_menucloudsmgr->addCameraSceneNode(0,             v3f(0, 0, 0), v3f(0, 60, 100));    camera->setFarValue(10000);    /*    	GUI stuff    */    ChatBackend chat_backend;    // If an error occurs, this is set to something by menu().    // It is then displayed before	the menu shows on the next call to menu()    std::string error_message;    bool first_loop = true;    /*    	Menu-game loop    */    bool retval = true;    bool *kill = porting::signal_handler_killstatus();    while (device->run() && !*kill && !g_gamecallback->shutdown_requested)    {//.........这里部分代码省略.........
开发者ID:4aiman,项目名称:MultiCraft,代码行数:101,


示例24: getItemMesh

void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result){	ITextureSource *tsrc = client->getTextureSource();	IItemDefManager *idef = client->getItemDefManager();	const NodeDefManager *ndef = client->getNodeDefManager();	const ItemDefinition &def = item.getDefinition(idef);	const ContentFeatures &f = ndef->get(def.name);	content_t id = ndef->getId(def.name);	FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized");		scene::SMesh *mesh = nullptr;	// Shading is on by default	result->needs_shading = true;	// If inventory_image is defined, it overrides everything else	if (!def.inventory_image.empty()) {		mesh = getExtrudedMesh(tsrc, def.inventory_image,			def.inventory_overlay);		result->buffer_colors.emplace_back();		// overlay is white, if present		result->buffer_colors.emplace_back(true, video::SColor(0xFFFFFFFF));		// Items with inventory images do not need shading		result->needs_shading = false;	} else if (def.type == ITEM_NODE) {		if (f.mesh_ptr[0]) {			mesh = cloneMesh(f.mesh_ptr[0]);			scaleMesh(mesh, v3f(0.12, 0.12, 0.12));			postProcessNodeMesh(mesh, f, false, false, nullptr,				&result->buffer_colors);		} else {			switch (f.drawtype) {				case NDT_PLANTLIKE: {					mesh = getExtrudedMesh(tsrc,						tsrc->getTextureName(f.tiles[0].layers[0].texture_id),						tsrc->getTextureName(f.tiles[0].layers[1].texture_id));					// Add color					const TileLayer &l0 = f.tiles[0].layers[0];					result->buffer_colors.emplace_back(l0.has_color, l0.color);					const TileLayer &l1 = f.tiles[0].layers[1];					result->buffer_colors.emplace_back(l1.has_color, l1.color);					break;				}				case NDT_PLANTLIKE_ROOTED: {					mesh = getExtrudedMesh(tsrc,						tsrc->getTextureName(f.special_tiles[0].layers[0].texture_id), "");					// Add color					const TileLayer &l0 = f.special_tiles[0].layers[0];					result->buffer_colors.emplace_back(l0.has_color, l0.color);					break;				}				case NDT_NORMAL:				case NDT_ALLFACES:				case NDT_LIQUID:				case NDT_FLOWINGLIQUID: {					scene::IMesh *cube = g_extrusion_mesh_cache->createCube();					mesh = cloneMesh(cube);					cube->drop();					scaleMesh(mesh, v3f(1.2, 1.2, 1.2));					// add overlays					postProcessNodeMesh(mesh, f, false, false, nullptr,						&result->buffer_colors);					break;				}				default: {					mesh = createSpecialNodeMesh(client, id, &result->buffer_colors);					scaleMesh(mesh, v3f(0.12, 0.12, 0.12));				}			}		}		u32 mc = mesh->getMeshBufferCount();		for (u32 i = 0; i < mc; ++i) {			scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);			video::SMaterial &material = buf->getMaterial();			material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;			material.setFlag(video::EMF_BILINEAR_FILTER, false);			material.setFlag(video::EMF_TRILINEAR_FILTER, false);			material.setFlag(video::EMF_BACK_FACE_CULLING, true);			material.setFlag(video::EMF_LIGHTING, false);		}		rotateMeshXZby(mesh, -45);		rotateMeshYZby(mesh, -30);	}	result->mesh = mesh;}
开发者ID:Gael-de-Sailly,项目名称:minetest,代码行数:88,


示例25: ReceiveAll

void Client::step(float dtime){	// Limit a bit	if(dtime > 2.0)		dtime = 2.0;	if(m_ignore_damage_timer > dtime)		m_ignore_damage_timer -= dtime;	else		m_ignore_damage_timer = 0.0;	m_animation_time += dtime;	if(m_animation_time > 60.0)		m_animation_time -= 60.0;	m_time_of_day_update_timer += dtime;	ReceiveAll();	/*		Packet counter	*/	{		float &counter = m_packetcounter_timer;		counter -= dtime;		if(counter <= 0.0)		{			counter = 20.0;			infostream << "Client packetcounter (" << m_packetcounter_timer					<< "):"<<std::endl;			m_packetcounter.print(infostream);			m_packetcounter.clear();		}	}	// UGLY hack to fix 2 second startup delay caused by non existent	// server client startup synchronization in local server or singleplayer mode	static bool initial_step = true;	if (initial_step) {		initial_step = false;	}	else if(m_state == LC_Created) {		float &counter = m_connection_reinit_timer;		counter -= dtime;		if(counter <= 0.0) {			counter = 2.0;			LocalPlayer *myplayer = m_env.getLocalPlayer();			FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment.");			sendInit(myplayer->getName());		}		// Not connected, return		return;	}	/*		Do stuff if connected	*/	/*		Run Map's timers and unload unused data	*/	const float map_timer_and_unload_dtime = 5.25;	if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {		ScopeProfiler sp(g_profiler, "Client: map timer and unload");		std::vector<v3s16> deleted_blocks;		m_env.getMap().timerUpdate(map_timer_and_unload_dtime,			g_settings->getFloat("client_unload_unused_data_timeout"),			g_settings->getS32("client_mapblock_limit"),			&deleted_blocks);		/*			Send info to server			NOTE: This loop is intentionally iterated the way it is.		*/		std::vector<v3s16>::iterator i = deleted_blocks.begin();		std::vector<v3s16> sendlist;		for(;;) {			if(sendlist.size() == 255 || i == deleted_blocks.end()) {				if(sendlist.empty())					break;				/*					[0] u16 command					[2] u8 count					[3] v3s16 pos_0					[3+6] v3s16 pos_1					...				*/				sendDeletedBlocks(sendlist);				if(i == deleted_blocks.end())					break;				sendlist.clear();			}//.........这里部分代码省略.........
开发者ID:EXio4,项目名称:minetest,代码行数:101,


示例26: DSTACK

void Client::step(float dtime){	DSTACK(FUNCTION_NAME);	// Limit a bit	if(dtime > 2.0)		dtime = 2.0;	if(m_ignore_damage_timer > dtime)		m_ignore_damage_timer -= dtime;	else		m_ignore_damage_timer = 0.0;	m_animation_time += dtime;	if(m_animation_time > 60.0)		m_animation_time -= 60.0;	m_time_of_day_update_timer += dtime;	ReceiveAll();	/*		Packet counter	*/	{		float &counter = m_packetcounter_timer;		counter -= dtime;		if(counter <= 0.0)		{			counter = 20.0;			infostream << "Client packetcounter (" << m_packetcounter_timer					<< "):"<<std::endl;			m_packetcounter.print(infostream);			m_packetcounter.clear();		}	}	// UGLY hack to fix 2 second startup delay caused by non existent	// server client startup synchronization in local server or singleplayer mode	static bool initial_step = true;	if (initial_step) {		initial_step = false;	}	else if(m_state == LC_Created) {		float &counter = m_connection_reinit_timer;		counter -= dtime;		if(counter <= 0.0) {			counter = 2.0;			Player *myplayer = m_env.getLocalPlayer();			FATAL_ERROR_IF(myplayer == NULL, "Local player not found in environment.");			// Send TOSERVER_INIT_LEGACY			// [0] u16 TOSERVER_INIT_LEGACY			// [2] u8 SER_FMT_VER_HIGHEST_READ			// [3] u8[20] player_name			// [23] u8[28] password (new in some version)			// [51] u16 minimum supported network protocol version (added sometime)			// [53] u16 maximum supported network protocol version (added later than the previous one)			char pName[PLAYERNAME_SIZE];			char pPassword[PASSWORD_SIZE];			memset(pName, 0, PLAYERNAME_SIZE * sizeof(char));			memset(pPassword, 0, PASSWORD_SIZE * sizeof(char));			std::string hashed_password = translatePassword(myplayer->getName(), m_password);			snprintf(pName, PLAYERNAME_SIZE, "%s", myplayer->getName());			snprintf(pPassword, PASSWORD_SIZE, "%s", hashed_password.c_str());			sendLegacyInit(pName, pPassword);			if (LATEST_PROTOCOL_VERSION >= 25)				sendInit(myplayer->getName());		}		// Not connected, return		return;	}	/*		Do stuff if connected	*/	/*		Run Map's timers and unload unused data	*/	const float map_timer_and_unload_dtime = 5.25;	if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime)) {		ScopeProfiler sp(g_profiler, "Client: map timer and unload");		std::vector<v3s16> deleted_blocks;		m_env.getMap().timerUpdate(map_timer_and_unload_dtime,			g_settings->getFloat("client_unload_unused_data_timeout"),			g_settings->getS32("client_mapblock_limit"),			&deleted_blocks);		/*			Send info to server			NOTE: This loop is intentionally iterated the way it is.		*///.........这里部分代码省略.........
开发者ID:BlockMen,项目名称:minetest,代码行数:101,



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


C++ FATFS_LinkDriver函数代码示例
C++ FATAL_ERROR函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。