本文整理汇总了C++中DSTACK函数的典型用法代码示例。如果您正苦于以下问题:C++ DSTACK函数的具体用法?C++ DSTACK怎么用?C++ DSTACK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DSTACK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DSTACK
void 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;
}
}
}
示例2: run_tests
void 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;
}
示例3: run_tests
void 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();
}
示例4: DSTACK
void 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);
}
示例5: DSTACK
MapSector * 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;
}
示例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);
}
示例7: getCraftingResult
// Crafting helper
bool 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;
}
示例8: DSTACK
void 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;
}
示例9: DSTACK
InventoryItem* 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);
}
示例10: DSTACK
content_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") {
示例11: main
int 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();
//.........这里部分代码省略.........
示例12: ThreadStarted
void *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;
//.........这里部分代码省略.........
示例13: DSTACK
void *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;
}
示例14: DSTACK
void 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(
//.........这里部分代码省略.........
示例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 {
//.........这里部分代码省略.........