这篇教程C++ DSTACK函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DSTACK函数的典型用法代码示例。如果您正苦于以下问题:C++ DSTACK函数的具体用法?C++ DSTACK怎么用?C++ DSTACK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DSTACK函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DSTACKvoid Client::ReceiveAll(){ DSTACK(__FUNCTION_NAME); for(;;) { try{ Receive(); } catch(con::NoIncomingDataException &e) { break; } catch(con::InvalidIncomingDataException &e) { infostream<<"Client::ReceiveAll(): " "InvalidIncomingDataException: what()=" <<e.what()<<std::endl; } }}
开发者ID:ray8888,项目名称:MINETEST-Minetest-classic-remoboray,代码行数:20,
示例2: run_testsvoid run_tests(){ return; //j DSTACK(__FUNCTION_NAME); infostream<<"run_tests() started"<<std::endl; TEST(TestUtilities); TEST(TestSettings); TEST(TestCompress); TEST(TestMapNode); TEST(TestVoxelManipulator); //TEST(TestMapBlock); //TEST(TestMapSector); if(INTERNET_SIMULATOR == false){ TEST(TestSocket); dout_con<<"=== BEGIN RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl; TEST(TestConnection); dout_con<<"=== END RUNNING UNIT TESTS FOR CONNECTION ==="<<std::endl; } infostream<<"run_tests() passed"<<std::endl;}
开发者ID:placki,项目名称:minetest-jachoo,代码行数:20,
示例3: run_testsvoid run_tests(){ DSTACK(__FUNCTION_NAME); u32 t1 = porting::getTime(PRECISION_MILLI); TestGameDef gamedef; log_set_lev_silence(LMT_ERROR, true); u32 num_modules_failed = 0; u32 num_total_tests_failed = 0; u32 num_total_tests_run = 0; std::vector<TestBase *> &testmods = TestManager::getTestModules(); for (size_t i = 0; i != testmods.size(); i++) { if (!testmods[i]->testModule(&gamedef)) num_modules_failed++; num_total_tests_failed += testmods[i]->num_tests_failed; num_total_tests_run += testmods[i]->num_tests_run; } u32 tdiff = porting::getTime(PRECISION_MILLI) - t1; log_set_lev_silence(LMT_ERROR, false); const char *overall_status = (num_modules_failed == 0) ? "PASSED" : "FAILED"; dstream << "++++++++++++++++++++++++++++++++++++++++" << "++++++++++++++++++++++++++++++++++++++++" << std::endl << "Unit Test Results: " << overall_status << std::endl << " " << num_modules_failed << " / " << testmods.size() << " failed modules (" << num_total_tests_failed << " / " << num_total_tests_run << " failed individual tests)." << std::endl << " Testing took " << tdiff << "ms total." << std::endl << "++++++++++++++++++++++++++++++++++++++++" << "++++++++++++++++++++++++++++++++++++++++" << std::endl; if (num_modules_failed) abort();}
开发者ID:Jetqvvf,项目名称:minetest,代码行数:41,
示例4: DSTACKvoid Server::SendInventory(PlayerSAO* playerSAO){ DSTACK(FUNCTION_NAME); UpdateCrafting(playerSAO->getPlayer()); /* Serialize it */ std::ostringstream os; playerSAO->getInventory()->serialize(os); std::string s = os.str(); MSGPACK_PACKET_INIT(TOCLIENT_INVENTORY, 1); PACK(TOCLIENT_INVENTORY_DATA, s); // Send as reliable m_clients.send(playerSAO->getPeerID(), 0, buffer, true);}
开发者ID:carriercomm,项目名称:freeminer,代码行数:21,
示例5: DSTACKMapSector * ClientMap::emergeSector(v2s16 p2d){ DSTACK(__FUNCTION_NAME); // Check that it doesn't exist already try{ return getSectorNoGenerate(p2d); } catch(InvalidPositionException &e) { } // Create a sector ClientMapSector *sector = new ClientMapSector(this, p2d, m_gamedef); { //JMutexAutoLock lock(m_sector_mutex); // Bulk comment-out m_sectors[p2d] = sector; } return sector;}
开发者ID:0gb-us,项目名称:minetest,代码行数:21,
示例6: DSTACK/* peer_id=0 adds with nobody to send to*/void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_server, bool urgent){ DSTACK(FUNCTION_NAME); assert(data); // pre-condition MutexAutoLock lock(m_mutex); if(urgent) m_urgents.insert(p); /* Find if block is already in queue. If it is, update the data and quit. */ for(std::vector<QueuedMeshUpdate*>::iterator i = m_queue.begin(); i != m_queue.end(); ++i) { QueuedMeshUpdate *q = *i; if(q->p == p) { if(q->data) delete q->data; q->data = data; if(ack_block_to_server) q->ack_block_to_server = true; return; } } /* Add the block */ QueuedMeshUpdate *q = new QueuedMeshUpdate; q->p = p; q->data = data; q->ack_block_to_server = ack_block_to_server; m_queue.push_back(q);}
开发者ID:BlockMen,项目名称:minetest,代码行数:43,
示例7: getCraftingResult// Crafting helperbool getCraftingResult(Inventory *inv, ItemStack& result, std::vector<ItemStack> &output_replacements, bool decrementInput, IGameDef *gamedef){ DSTACK(__FUNCTION_NAME); result.clear(); // Get the InventoryList in which we will operate InventoryList *clist = inv->getList("craft"); if(!clist) return false; // Mangle crafting grid to an another format CraftInput ci; ci.method = CRAFT_METHOD_NORMAL; ci.width = clist->getWidth() ? clist->getWidth() : 3; for(u16 i=0; i<clist->getSize(); i++) ci.items.push_back(clist->getItem(i)); // Find out what is crafted and add it to result item slot CraftOutput co; bool found = gamedef->getCraftDefManager()->getCraftResult( ci, co, output_replacements, decrementInput, gamedef); if(found) result.deSerialize(co.item, gamedef->getItemDefManager()); if(found && decrementInput) { // CraftInput has been changed, apply changes in clist for(u16 i=0; i<clist->getSize(); i++) { clist->changeItem(i, ci.items[i]); } } return found;}
开发者ID:BlazingGamer,项目名称:InfinityCraft,代码行数:39,
示例8: DSTACKvoid ItemStack::deSerialize(std::istream &is, IItemDefManager *itemdef){ DSTACK(__FUNCTION_NAME); clear(); // Read name name = deSerializeJsonStringIfNeeded(is); // Skip space std::string tmp; std::getline(is, tmp, ' '); if(!tmp.empty()) throw SerializationError("Unexpected text after item name"); if(name == "MaterialItem") { // Obsoleted on 2011-07-30 u16 material; is>>material; u16 materialcount; is>>materialcount; // Convert old materials if(material <= 0xff) material = content_translate_from_19_to_internal(material); if(material > 0xfff) throw SerializationError("Too large material number"); // Convert old id to name NameIdMapping legacy_nimap; content_mapnode_get_name_id_mapping(&legacy_nimap); legacy_nimap.getName(material, name); if(name == "") name = "unknown_block"; if (itemdef) name = itemdef->getAlias(name); count = materialcount; }
开发者ID:JakubVanek,项目名称:minetest,代码行数:38,
示例9: DSTACKInventoryItem* InventoryItem::deSerialize(std::istream &is, IGameDef *gamedef){ DSTACK(__FUNCTION_NAME); //is.imbue(std::locale("C")); // Read name std::string name; std::getline(is, name, ' '); if(name == "MaterialItem") { // u16 reads directly as a number (u8 doesn't) u16 material; is>>material; u16 count; is>>count; // Convert old materials if(material <= 0xff) material = content_translate_from_19_to_internal(material); if(material > MAX_CONTENT) throw SerializationError("Too large material number"); return new MaterialItem(gamedef, material, count); }
开发者ID:Neear,项目名称:minetest,代码行数:23,
示例10: DSTACKcontent_t InventoryItem::info(std::istream &is, u16 *count, u16 *wear, u16 *data){ DSTACK(__FUNCTION_NAME); content_t c = CONTENT_IGNORE; *count = 0; *wear = 0; *data = 0; //is.imbue(std::locale("C")); // Read name std::string name; std::getline(is, name, ' '); if (name == "MaterialItem") { // u16 reads directly as a number (u8 doesn't) u16 material; is>>material; is>>(*count); if (material > MAX_CONTENT) throw SerializationError("Too large material number"); c = material; }else if(name == "MaterialItem2") {
开发者ID:Jobava,项目名称:Voxelands,代码行数:23,
示例11: mainint main(int argc, char *argv[]){ int retval; debug_set_exception_handler(); log_add_output_maxlev(&main_stderr_log_out, LMT_ACTION); log_add_output_all_levs(&main_dstream_no_stderr_log_out); log_register_thread("main"); Settings cmd_args; bool cmd_args_ok = get_cmdline_opts(argc, argv, &cmd_args); if (!cmd_args_ok || cmd_args.getFlag("help") || cmd_args.exists("nonopt1")) { print_help(allowed_options); return cmd_args_ok ? 0 : 1; } if (cmd_args.getFlag("version")) { print_version(); return 0; } setup_log_params(cmd_args); porting::signal_handler_init(); porting::initializePaths(); if (!create_userdata_path()) { errorstream << "Cannot create user data directory" << std::endl; return 1; } // Initialize debug stacks debug_stacks_init(); DSTACK(__FUNCTION_NAME); // Debug handler BEGIN_DEBUG_EXCEPTION_HANDLER // List gameids if requested if (cmd_args.exists("gameid") && cmd_args.get("gameid") == "list") { list_game_ids(); return 0; } // List worlds if requested if (cmd_args.exists("world") && cmd_args.get("world") == "list") { list_worlds(); return 0; } GameParams game_params; if (!init_common(&game_params.log_level, cmd_args, argc, argv)) return 1;#ifndef __ANDROID__ // Run unit tests if (cmd_args.getFlag("run-unittests")) { run_tests(); return 0; }#endif#ifdef SERVER game_params.is_dedicated_server = true;#else game_params.is_dedicated_server = cmd_args.getFlag("server");#endif if (!game_configure(&game_params, cmd_args)) return 1; sanity_check(game_params.world_path != ""); infostream << "Using commanded world path [" << game_params.world_path << "]" << std::endl; //Run dedicated server if asked to or no other option g_settings->set("server_dedicated", game_params.is_dedicated_server ? "true" : "false"); if (game_params.is_dedicated_server) return run_dedicated_server(game_params, cmd_args) ? 0 : 1;#ifndef SERVER ClientLauncher launcher; retval = launcher.run(game_params, cmd_args) ? 0 : 1;#else retval = 0;#endif // Update configuration file if (g_settings_path != "") g_settings->updateConfigFile(g_settings_path.c_str()); print_modified_quicktune_values();//.........这里部分代码省略.........
开发者ID:t0suj4,项目名称:minetest,代码行数:101,
示例12: ThreadStartedvoid *EmergeThread::Thread() { ThreadStarted(); log_register_thread("EmergeThread" + itos(id)); DSTACK(__FUNCTION_NAME); BEGIN_DEBUG_EXCEPTION_HANDLER v3s16 last_tried_pos(-32768,-32768,-32768); // For error output v3s16 p; u8 flags = 0; map = (ServerMap *)&(m_server->m_env->getMap()); emerge = m_server->m_emerge; mapgen = emerge->mapgen[id]; enable_mapgen_debug_info = emerge->mapgen_debug_info; porting::setThreadName("EmergeThread"); while (!StopRequested()) try { if (!popBlockEmerge(&p, &flags)) { qevent.wait(); continue; } last_tried_pos = p; if (blockpos_over_limit(p)) continue; bool allow_generate = flags & BLOCK_EMERGE_ALLOWGEN; EMERGE_DBG_OUT("p=" PP(p) " allow_generate=" << allow_generate); /* Try to fetch block from memory or disk. If not found and asked to generate, initialize generator. */ BlockMakeData data; MapBlock *block = NULL; std::map<v3s16, MapBlock *> modified_blocks; if (getBlockOrStartGen(p, &block, &data, allow_generate) && mapgen) { { ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG); TimeTaker t("mapgen::make_block()"); mapgen->makeChunk(&data); if (enable_mapgen_debug_info == false) t.stop(true); // Hide output } { //envlock: usually 0ms, but can take either 30 or 400ms to acquire JMutexAutoLock envlock(m_server->m_env_mutex); ScopeProfiler sp(g_profiler, "EmergeThread: after " "Mapgen::makeChunk (envlock)", SPT_AVG); map->finishBlockMake(&data, modified_blocks); block = map->getBlockNoCreateNoEx(p); if (block) { /* Do some post-generate stuff */ v3s16 minp = data.blockpos_min * MAP_BLOCKSIZE; v3s16 maxp = data.blockpos_max * MAP_BLOCKSIZE + v3s16(1,1,1) * (MAP_BLOCKSIZE - 1); // Ignore map edit events, they will not need to be sent // to anybody because the block hasn't been sent to anybody MapEditEventAreaIgnorer ign(&m_server->m_ignore_map_edit_events_area, VoxelArea(minp, maxp)); try { // takes about 90ms with -O1 on an e3-1230v2 m_server->getScriptIface()->environment_OnGenerated( minp, maxp, emerge->getBlockSeed(minp)); } catch(LuaError &e) { m_server->setAsyncFatalError(e.what()); } EMERGE_DBG_OUT("ended up with: " << analyze_block(block)); m_server->m_env->activateBlock(block, 0); } } } /* Set sent status of modified blocks on clients */ // Add the originally fetched block to the modified list if (block) modified_blocks[p] = block; if (modified_blocks.size() > 0) { m_server->SetBlocksNotSent(modified_blocks); } } catch (VersionMismatchException &e) { std::ostringstream err; err << "World data version mismatch in MapBlock "<<PP(last_tried_pos)<<std::endl;//.........这里部分代码省略.........
开发者ID:Adam445,项目名称:minetest,代码行数:101,
示例13: DSTACKvoid *EmergeThread::run(){ DSTACK(FUNCTION_NAME); BEGIN_DEBUG_EXCEPTION_HANDLER v3s16 pos; m_map = (ServerMap *)&(m_server->m_env->getMap()); m_emerge = m_server->m_emerge; m_mapgen = m_emerge->m_mapgens[id]; enable_mapgen_debug_info = m_emerge->enable_mapgen_debug_info; try { while (!stopRequested()) { std::map<v3s16, MapBlock *> modified_blocks; BlockEmergeData bedata; BlockMakeData bmdata; EmergeAction action; MapBlock *block; if (!popBlockEmerge(&pos, &bedata)) { m_queue_event.wait(); continue; } if (blockpos_over_limit(pos)) continue; bool allow_gen = bedata.flags & BLOCK_EMERGE_ALLOW_GEN; EMERGE_DBG_OUT("pos=" PP(pos) " allow_gen=" << allow_gen); action = getBlockOrStartGen(pos, allow_gen, &block, &bmdata); if (action == EMERGE_GENERATED) { { ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG); TimeTaker t("mapgen::make_block()"); m_mapgen->makeChunk(&bmdata); if (enable_mapgen_debug_info == false) t.stop(true); // Hide output } block = finishGen(pos, &bmdata, &modified_blocks); } runCompletionCallbacks(pos, action, bedata.callbacks); if (block) modified_blocks[pos] = block; if (modified_blocks.size() > 0) m_server->SetBlocksNotSent(modified_blocks); } } catch (VersionMismatchException &e) { std::ostringstream err; err << "World data version mismatch in MapBlock " << PP(pos) << std::endl << "----" << std::endl << "/"" << e.what() << "/"" << std::endl << "See debug.txt." << std::endl << "World probably saved by a newer version of " PROJECT_NAME_C "." << std::endl; m_server->setAsyncFatalError(err.str()); } catch (SerializationError &e) { std::ostringstream err; err << "Invalid data in MapBlock " << PP(pos) << std::endl << "----" << std::endl << "/"" << e.what() << "/"" << std::endl << "See debug.txt." << std::endl << "You can ignore this using [ignore_world_load_errors = true]." << std::endl; m_server->setAsyncFatalError(err.str()); } END_DEBUG_EXCEPTION_HANDLER return NULL;}
开发者ID:viphotman,项目名称:minetest,代码行数:78,
示例14: DSTACKvoid ClientMap::renderMap(video::IVideoDriver* driver, s32 pass){ DSTACK(__FUNCTION_NAME); bool is_transparent_pass = pass == scene::ESNRP_TRANSPARENT; std::string prefix; if(pass == scene::ESNRP_SOLID) prefix = "CM: solid: "; else prefix = "CM: transparent: "; //ScopeProfiler sp(g_profiler, "CM::renderMap() " + prefix, SPT_AVG); /* Get time for measuring timeout. Measuring time is very useful for long delays when the machine is swapping a lot. */ //int time1 = time(0); /* Get animation parameters */ float animation_time = m_client->getAnimationTime(); int crack = m_client->getCrackLevel(); u32 daynight_ratio = m_client->getEnv().getDayNightRatio(); m_camera_mutex.Lock(); v3f camera_position = m_camera_position; f32 camera_fov = m_camera_fov * 1.1; m_camera_mutex.Unlock(); /* Get all blocks and draw all visible ones */ v3s16 cam_pos_nodes = floatToInt(camera_position, BS); u32 vertex_count = 0; u32 meshbuffer_count = 0; // For limiting number of mesh animations per frame u32 mesh_animate_count = 0; u32 mesh_animate_count_far = 0; // Blocks that were drawn and had a mesh u32 blocks_drawn = 0; // Blocks which had a corresponding meshbuffer for this pass u32 blocks_had_pass_meshbuf = 0; // Blocks from which stuff was actually drawn u32 blocks_without_stuff = 0; /* Draw the selected MapBlocks */ { //ScopeProfiler sp(g_profiler, prefix+"drawing blocks", SPT_AVG); MeshBufListList drawbufs; std::vector<MapBlock::mesh_type> used_meshes; //keep shared_ptr auto drawlist = m_drawlist.load(); auto lock = drawlist->lock_shared_rec(); used_meshes.reserve(drawlist->size()); //g_profiler->add("CM::renderMap()cnt"+ prefix, drawlist->size()); for(auto & ir : *drawlist) { auto block = ir.second; int mesh_step = getFarmeshStep(m_control, getNodeBlockPos(cam_pos_nodes), block->getPos()); // If the mesh of the block happened to get deleted, ignore it auto mapBlockMesh = block->getMesh(mesh_step); if (!mapBlockMesh) continue; float d = 0.0; if(isBlockInSight(block->getPos(), camera_position, m_camera_direction, camera_fov, 100000*BS, &d) == false) { continue; } used_meshes.emplace_back(mapBlockMesh); // Mesh animation { //JMutexAutoLock lock(block->mesh_mutex); mapBlockMesh->updateCameraOffset(m_camera_offset); // Pretty random but this should work somewhat nicely bool faraway = d >= BS*50; //bool faraway = d >= m_control.wanted_range * BS; if(mapBlockMesh->isAnimationForced() || !faraway || mesh_animate_count_far < (m_control.range_all ? 200 : 50)) { bool animated = mapBlockMesh->animate(//.........这里部分代码省略.........
开发者ID:prodigeni,项目名称:freeminer,代码行数:101,
示例15: run_dedicated_server/***************************************************************************** * Dedicated server *****************************************************************************/static bool run_dedicated_server(const GameParams &game_params, const Settings &cmd_args){ DSTACK("Dedicated server branch"); verbosestream << _("Using world path") << " [" << game_params.world_path << "]" << std::endl; verbosestream << _("Using gameid") << " [" << game_params.game_spec.id << "]" << std::endl; // Bind address std::string bind_str = g_settings->get("bind_address"); Address bind_addr(0, 0, 0, 0, game_params.socket_port); if (g_settings->getBool("ipv6_server")) { bind_addr.setAddress(in6addr_any); } try { if (!bind_str.empty()) bind_addr.Resolve(bind_str.c_str()); } catch (ResolveError &e) { infostream << "Resolving bind address /"" << bind_str << "/" failed: " << e.what() << " -- Listening on all addresses." << std::endl; } if (bind_addr.isIPv6() && !g_settings->getBool("enable_ipv6")) { errorstream << "Unable to listen on " << bind_addr.serializeString() << L" because IPv6 is disabled" << std::endl; return false; } // Database migration if (cmd_args.exists("migrate")) return migrate_database(game_params, cmd_args); if (cmd_args.exists("terminal")) {#if USE_CURSES bool name_ok = true; std::string admin_nick = g_settings->get("name"); name_ok = name_ok && !admin_nick.empty(); name_ok = name_ok && string_allowed(admin_nick, PLAYERNAME_ALLOWED_CHARS); if (!name_ok) { if (admin_nick.empty()) { errorstream << "No name given for admin. " << "Please check your minetest.conf that it " << "contains a 'name = ' to your main admin account." << std::endl; } else { errorstream << "Name for admin '" << admin_nick << "' is not valid. " << "Please check that it only contains allowed characters. " << "Valid characters are: " << PLAYERNAME_ALLOWED_CHARS_USER_EXPL << std::endl; } return false; } ChatInterface iface; bool &kill = *porting::signal_handler_killstatus(); try { // Create server Server server(game_params.world_path, game_params.game_spec, false, bind_addr.isIPv6(), &iface); g_term_console.setup(&iface, &kill, admin_nick); g_term_console.start(); server.start(bind_addr); // Run server dedicated_server_loop(server, kill); } catch (const ModError &e) { g_term_console.stopAndWaitforThread(); errorstream << "ModError: " << e.what() << std::endl; return false; } catch (const ServerError &e) { g_term_console.stopAndWaitforThread(); errorstream << "ServerError: " << e.what() << std::endl; return false; } // Tell the console to stop, and wait for it to finish, // only then leave context and free iface g_term_console.stop(); g_term_console.wait(); g_term_console.clearKillStatus(); } else {#else errorstream << "Cmd arg --terminal passed, but " << "compiled without ncurses. Ignoring." << std::endl; } {#endif try {//.........这里部分代码省略.........
开发者ID:Mab879,项目名称:freeminer,代码行数:101,
示例16: main//.........这里部分代码省略......... /* Low-level initialization */ // If trace is enabled, enable logging of certain things if(cmd_args.getFlag("trace")){ dstream<<_("Enabling trace level debug output")<<std::endl; log_trace_level_enabled = true; dout_con_ptr = &verbosestream; // this is somewhat old crap socket_enable_debug_output = true; // socket doesn't use log.h } // In certain cases, output info level on stderr if(cmd_args.getFlag("info") || cmd_args.getFlag("verbose") || cmd_args.getFlag("trace") || cmd_args.getFlag("speedtests")) log_add_output(&main_stderr_log_out, LMT_INFO); // In certain cases, output verbose level on stderr if(cmd_args.getFlag("verbose") || cmd_args.getFlag("trace")) log_add_output(&main_stderr_log_out, LMT_VERBOSE); porting::signal_handler_init(); bool &kill = *porting::signal_handler_killstatus(); porting::initializePaths(); // Create user data directory fs::CreateDir(porting::path_user); infostream<<"path_share = "<<porting::path_share<<std::endl; infostream<<"path_user = "<<porting::path_user<<std::endl; // Initialize debug stacks debug_stacks_init(); DSTACK(__FUNCTION_NAME); // Debug handler BEGIN_DEBUG_EXCEPTION_HANDLER // List gameids if requested if(cmd_args.exists("gameid") && cmd_args.get("gameid") == "list") { std::set<std::string> gameids = getAvailableGameIds(); for(std::set<std::string>::const_iterator i = gameids.begin(); i != gameids.end(); i++) dstream<<(*i)<<std::endl; return 0; } // List worlds if requested if(cmd_args.exists("world") && cmd_args.get("world") == "list"){ dstream<<_("Available worlds:")<<std::endl; std::vector<WorldSpec> worldspecs = getAvailableWorlds(); print_worldspecs(worldspecs, dstream); return 0; } // Print startup message infostream<<PROJECT_NAME<< " "<<_("with")<<" SER_FMT_VER_HIGHEST_READ="<<(int)SER_FMT_VER_HIGHEST_READ <<", "<<minetest_build_info <<std::endl; /* Basic initialization */
开发者ID:FessWolf,项目名称:minetest,代码行数:66,
示例17: DSTACKvoid MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio){ DSTACK(__FUNCTION_NAME); JMutexAutoLock lock(m_mutex); if(m_objects.empty()) return; core::map<s16, bool> ids_to_delete; { DSTACKF("%s: stepping objects", __FUNCTION_NAME); for(core::map<s16, MapBlockObject*>::Iterator i = m_objects.getIterator(); i.atEnd() == false; i++) { MapBlockObject *obj = i.getNode()->getValue(); DSTACKF("%s: stepping object type %i", __FUNCTION_NAME, obj->getTypeId()); obj->setBlockChanged(); if(server) { // Update light u8 light = LIGHT_MAX; try{ v3s16 relpos_i = floatToInt(obj->m_pos, BS); MapNode n = m_block->getNodeParent(relpos_i); light = n.getLightBlend(daynight_ratio); } catch(InvalidPositionException &e) {} obj->updateLight(light); bool to_delete = obj->serverStep(dtime, daynight_ratio); if(to_delete) ids_to_delete.insert(obj->m_id, true); } else { obj->clientStep(dtime); } } } { DSTACKF("%s: deleting objects", __FUNCTION_NAME); // Delete objects in delete queue for(core::map<s16, bool>::Iterator i = ids_to_delete.getIterator(); i.atEnd() == false; i++) { s16 id = i.getNode()->getKey(); MapBlockObject *obj = m_objects[id]; obj->setBlockChanged(); obj->removeFromScene(); delete obj; m_objects.remove(id); } } /* Wrap objects on server */ if(server == false) return; { DSTACKF("%s: object wrap loop", __FUNCTION_NAME); for(core::map<s16, MapBlockObject*>::Iterator i = m_objects.getIterator(); i.atEnd() == false; i++) { MapBlockObject *obj = i.getNode()->getValue(); v3s16 pos_i = floatToInt(obj->m_pos, BS); if(m_block->isValidPosition(pos_i)) { // No wrap continue; } bool impossible = wrapObject(obj); if(impossible) { // No wrap continue; } obj->setBlockChanged();//.........这里部分代码省略.........
开发者ID:DMV27,项目名称:minetest,代码行数:101,
示例18: mainint main(int argc, char *argv[]){ int retval = 0;#if USE_ENET if (enet_initialize() != 0) { std::cerr << "enet failed to initialize/n"; return EXIT_FAILURE; } atexit(enet_deinitialize);#endif debug_set_exception_handler(); g_logger.registerThread("Main"); g_logger.addOutputMaxLevel(&stderr_output, LL_ACTION); Settings cmd_args; bool cmd_args_ok = get_cmdline_opts(argc, argv, &cmd_args); if (!cmd_args_ok || cmd_args.getFlag("help") || cmd_args.exists("nonopt1")) { print_help(allowed_options); return cmd_args_ok ? 0 : 1; } if (cmd_args.getFlag("version")) { print_version(); return 0; } setup_log_params(cmd_args); porting::signal_handler_init();#ifdef __ANDROID__ porting::initAndroid(); porting::initializePathsAndroid();#else porting::initializePaths();#endif if (!create_userdata_path()) { errorstream << "Cannot create user data directory "<< porting::path_user << std::endl; //return 1; } // Initialize debug stacks DSTACK(FUNCTION_NAME); // Debug handler BEGIN_DEBUG_EXCEPTION_HANDLER // List gameids if requested if (cmd_args.exists("gameid") && cmd_args.get("gameid") == "list") { list_game_ids(); return 0; } // List worlds if requested if (cmd_args.exists("world") && cmd_args.get("world") == "list") { list_worlds(); return 0; } if (!init_common(cmd_args, argc, argv)) return 1; // parse settings from cmdline. must be after loading settings. maybe better to move for (int i = 1; i < argc; i++) { std::string arg_name = argv[i]; if (arg_name.substr(0, 2) == "--" || arg_name[0] != '-') continue; std::string name = arg_name.substr(1); std::string value; auto vpos = name.find('='); if (vpos != std::string::npos && name.size() > vpos) { value = name.substr(vpos+1); name.resize(vpos); } else { value = "1"; } g_settings->set(name, value); continue; }#if !defined(__ANDROID__) && !defined(_MSC_VER) // Run unit tests if (cmd_args.getFlag("run-unittests")) { return run_tests(); }#endif GameParams game_params;#ifdef SERVER game_params.is_dedicated_server = true;#else game_params.is_dedicated_server = cmd_args.getFlag("server");#endif//.........这里部分代码省略.........
开发者ID:Mab879,项目名称:freeminer,代码行数:101,
示例19: DSTACKvoid RemoteClient::GetNextBlocks ( ServerEnvironment *env, EmergeManager * emerge, float dtime, std::vector<PrioritySortedBlockTransfer> &dest){ DSTACK(FUNCTION_NAME); // Increment timers m_nothing_to_send_pause_timer -= dtime; m_nearest_unsent_reset_timer += dtime; if(m_nothing_to_send_pause_timer >= 0) return; RemotePlayer *player = env->getPlayer(peer_id); // This can happen sometimes; clients and players are not in perfect sync. if (!player) return; PlayerSAO *sao = player->getPlayerSAO(); if (!sao) return; // Won't send anything if already sending if(m_blocks_sending.size() >= g_settings->getU16 ("max_simultaneous_block_sends_per_client")) { //infostream<<"Not sending any blocks, Queue full."<<std::endl; return; } v3f playerpos = sao->getBasePosition(); const v3f &playerspeed = player->getSpeed(); v3f playerspeeddir(0,0,0); if(playerspeed.getLength() > 1.0*BS) playerspeeddir = playerspeed / playerspeed.getLength(); // Predict to next block v3f playerpos_predicted = playerpos + playerspeeddir*MAP_BLOCKSIZE*BS; v3s16 center_nodepos = floatToInt(playerpos_predicted, BS); v3s16 center = getNodeBlockPos(center_nodepos); // Camera position and direction v3f camera_pos = sao->getEyePosition(); v3f camera_dir = v3f(0,0,1); camera_dir.rotateYZBy(sao->getPitch()); camera_dir.rotateXZBy(sao->getYaw()); /*infostream<<"camera_dir=("<<camera_dir.X<<","<<camera_dir.Y<<"," <<camera_dir.Z<<")"<<std::endl;*/ /* Get the starting value of the block finder radius. */ if(m_last_center != center) { m_nearest_unsent_d = 0; m_last_center = center; } /*infostream<<"m_nearest_unsent_reset_timer=" <<m_nearest_unsent_reset_timer<<std::endl;*/ // Reset periodically to workaround for some bugs or stuff if(m_nearest_unsent_reset_timer > 20.0) { m_nearest_unsent_reset_timer = 0; m_nearest_unsent_d = 0; //infostream<<"Resetting m_nearest_unsent_d for " // <<server->getPlayerName(peer_id)<<std::endl; } //s16 last_nearest_unsent_d = m_nearest_unsent_d; s16 d_start = m_nearest_unsent_d; //infostream<<"d_start="<<d_start<<std::endl; u16 max_simul_sends_setting = g_settings->getU16 ("max_simultaneous_block_sends_per_client"); u16 max_simul_sends_usually = max_simul_sends_setting; /* Check the time from last addNode/removeNode. Decrease send rate if player is building stuff. */ m_time_from_building += dtime; if(m_time_from_building < g_settings->getFloat( "full_block_send_enable_min_time_from_building")) { max_simul_sends_usually = LIMITED_MAX_SIMULTANEOUS_BLOCK_SENDS; } /* Number of blocks sending + number of blocks selected for sending//.........这里部分代码省略.........
开发者ID:Ekdohibs,项目名称:minetest,代码行数:101,
示例20: main//.........这里部分代码省略......... if(cmd_args.getFlag("verbose") || cmd_args.getFlag("trace")) log_add_output(&main_stderr_log_out, LMT_VERBOSE); porting::signal_handler_init(); bool &kill = *porting::signal_handler_killstatus(); porting::initializePaths(); // Create user data directory fs::CreateDir(porting::path_user); init_gettext((porting::path_share+DIR_DELIM+".."+DIR_DELIM+"locale").c_str()); // Initialize debug streams#define DEBUGFILE "debug.txt"#if RUN_IN_PLACE std::string logfile = DEBUGFILE;#else std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;#endif if(cmd_args.exists("logfile")) logfile = cmd_args.get("logfile"); if(logfile != "") debugstreams_init(false, logfile.c_str()); else debugstreams_init(false, NULL); infostream<<"logfile = "<<logfile<<std::endl; infostream<<"path_share = "<<porting::path_share<<std::endl; infostream<<"path_user = "<<porting::path_user<<std::endl; // Initialize debug stacks debug_stacks_init(); DSTACK(__FUNCTION_NAME); // Debug handler BEGIN_DEBUG_EXCEPTION_HANDLER // List gameids if requested if(cmd_args.exists("gameid") && cmd_args.get("gameid") == "list") { std::set<std::string> gameids = getAvailableGameIds(); for(std::set<std::string>::const_iterator i = gameids.begin(); i != gameids.end(); i++) dstream<<(*i)<<std::endl; return 0; } // List worlds if requested if(cmd_args.exists("world") && cmd_args.get("world") == "list"){ dstream<<_("Available worlds:")<<std::endl; std::vector<WorldSpec> worldspecs = getAvailableWorlds(); print_worldspecs(worldspecs, dstream); return 0; } // Print startup message infostream<<PROJECT_NAME<< " "<<_("with")<<" SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST <<", "<<BUILD_INFO <<std::endl; /* Basic initialization */
开发者ID:Silenthal,项目名称:minetest,代码行数:66,
示例21: DSTACKvoid Server::ProcessData(NetworkPacket *pkt){ DSTACK(__FUNCTION_NAME); // Environment is locked first. //JMutexAutoLock envlock(m_env_mutex); ScopeProfiler sp(g_profiler, "Server::ProcessData"); auto peer_id = pkt->getPeerId(); std::string addr_s; try{ Address address = getPeerAddress(peer_id); addr_s = address.serializeString(); // drop player if is ip is banned if(m_banmanager->isIpBanned(addr_s)){ std::string ban_name = m_banmanager->getBanName(addr_s); infostream<<"Server: A banned client tried to connect from " <<addr_s<<"; banned name was " <<ban_name<<std::endl; // This actually doesn't seem to transfer to the client DenyAccess(peer_id, std::string("Your ip is banned. Banned name was ") + ban_name); return; } } catch(con::PeerNotFoundException &e) { /* * no peer for this packet found * most common reason is peer timeout, e.g. peer didn't * respond for some time, your server was overloaded or * things like that. */ verbosestream<<"Server::ProcessData(): Canceling: peer " <<peer_id<<" not found"<<std::endl; return; } try { auto datasize = pkt->getSize(); if(datasize < 2) return; int command; std::map<int, msgpack::object> packet; msgpack::unpacked msg; if (!con::parse_msgpack_packet(pkt->getString(0), datasize, &packet, &command, &msg)) { verbosestream<<"Server: Ignoring broken packet from " <<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl; return; } if(command == TOSERVER_INIT_LEGACY) { RemoteClient* client = getClient(peer_id, CS_Created); // If net_proto_version is set, this client has already been handled if(client->getState() > CS_Created) { verbosestream<<"Server: Ignoring multiple TOSERVER_INITs from " <<addr_s<<" (peer_id="<<peer_id<<")"<<std::endl; return; } verbosestream<<"Server: Got TOSERVER_INIT from "<<addr_s<<" (peer_id=" <<peer_id<<")"<<std::endl; // Do not allow multiple players in simple singleplayer mode. // This isn't a perfect way to do it, but will suffice for now if(m_simple_singleplayer_mode && m_clients.getClientIDs().size() > 1){ infostream<<"Server: Not allowing another client ("<<addr_s <<") to connect in simple singleplayer mode"<<std::endl; DenyAccess(peer_id, "Running in simple singleplayer mode."); return; } // First byte after command is maximum supported // serialization version u8 client_max; packet[TOSERVER_INIT_FMT].convert(&client_max); u8 our_max = SER_FMT_VER_HIGHEST_READ; // Use the highest version supported by both int deployed = std::min(client_max, our_max); // If it's lower than the lowest supported, give up. if(deployed < SER_FMT_CLIENT_VER_LOWEST) deployed = SER_FMT_VER_INVALID; if(deployed == SER_FMT_VER_INVALID) { actionstream<<"Server: A mismatched client tried to connect from " <<addr_s<<std::endl; infostream<<"Server: Cannot negotiate serialization version with " <<addr_s<<std::endl; DenyAccess(peer_id, std::string( "Your client's version is not supported./n" "Server version is ") + (g_version_string) + "."//.........这里部分代码省略.........
开发者ID:daniel-santos,项目名称:freeminer,代码行数:101,
示例22: DSTACKvoid ClientEnvironment::step(float dtime){ DSTACK(__FUNCTION_NAME); // Get some settings bool free_move = g_settings.getBool("free_move"); bool footprints = g_settings.getBool("footprints"); // Get local player LocalPlayer *lplayer = getLocalPlayer(); assert(lplayer); // collision info queue core::list<CollisionInfo> player_collisions; /* Get the speed the player is going */ bool is_climbing = lplayer->is_climbing; f32 player_speed = 0.001; // just some small value player_speed = lplayer->getSpeed().getLength(); /* Maximum position increment */ //f32 position_max_increment = 0.05*BS; f32 position_max_increment = 0.1*BS; // Maximum time increment (for collision detection etc) // time = distance / speed f32 dtime_max_increment = position_max_increment / player_speed; // Maximum time increment is 10ms or lower if(dtime_max_increment > 0.01) dtime_max_increment = 0.01; // Don't allow overly huge dtime if(dtime > 0.5) dtime = 0.5; f32 dtime_downcount = dtime; /* Stuff that has a maximum time increment */ u32 loopcount = 0; do { loopcount++; f32 dtime_part; if(dtime_downcount > dtime_max_increment) { dtime_part = dtime_max_increment; dtime_downcount -= dtime_part; } else { dtime_part = dtime_downcount; /* Setting this to 0 (no -=dtime_part) disables an infinite loop when dtime_part is so small that dtime_downcount -= dtime_part does nothing */ dtime_downcount = 0; } /* Handle local player */ { v3f lplayerpos = lplayer->getPosition(); // Apply physics if(free_move == false && is_climbing == false) { // Gravity v3f speed = lplayer->getSpeed(); if(lplayer->swimming_up == false) speed.Y -= 9.81 * BS * dtime_part * 2; // Water resistance if(lplayer->in_water_stable || lplayer->in_water) { f32 max_down = 2.0*BS; if(speed.Y < -max_down) speed.Y = -max_down; f32 max = 2.5*BS; if(speed.getLength() > max) { speed = speed / speed.getLength() * max; } } lplayer->setSpeed(speed); } /*//.........这里部分代码省略.........
开发者ID:MarkTraceur,项目名称:minetest-delta,代码行数:101,
示例23: main//.........这里部分代码省略......... Low-level initialization */ bool disable_stderr = false;#ifdef _WIN32 if(cmd_args.getFlag("dstream-on-stderr") == false) disable_stderr = true;#endif if(cmd_args.getFlag("info-on-stderr")) log_add_output(&main_stderr_log_out, LMT_INFO); porting::signal_handler_init(); bool &kill = *porting::signal_handler_killstatus(); // Initialize porting::path_data and porting::path_userdata porting::initializePaths(); // Create user data directory fs::CreateDir(porting::path_userdata); init_gettext((porting::path_data+DIR_DELIM+".."+DIR_DELIM+"locale").c_str()); // Initialize debug streams#ifdef RUN_IN_PLACE std::string debugfile = DEBUGFILE;#else std::string debugfile = porting::path_userdata+DIR_DELIM+DEBUGFILE;#endif debugstreams_init(disable_stderr, debugfile.c_str()); // Initialize debug stacks debug_stacks_init(); DSTACK(__FUNCTION_NAME); // Init material properties table //initializeMaterialProperties(); // Debug handler BEGIN_DEBUG_EXCEPTION_HANDLER // Print startup message actionstream<<PROJECT_NAME<< " with SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST <<", "<<BUILD_INFO <<std::endl; /* Basic initialization */ // Initialize default settings set_default_settings(g_settings); // Initialize sockets sockets_init(); atexit(sockets_cleanup); /* Read config file */ // Path of configuration file in use std::string configpath = ""; if(cmd_args.exists("config"))
开发者ID:Oblomov,项目名称:minetest,代码行数:67,
注:本文中的DSTACK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ DST_RET函数代码示例 C++ DST函数代码示例 |