void do_level( char_data* ch, char* argument ) { int i; if( is_confused_pet( ch ) ) return; if( *argument != '\0' ) { if( !number_arg( argument, i ) ) send( ch, "Unknown syntax - see help level.\r\n" ); else if( i > LEVEL_HERO ) send( ch, "Gaining levels beyond %d via exp is impossible.\r\n", LEVEL_HERO ); else if( i < 2 ) send( ch, "Levels below 2 do not require exp.\r\n" ); else send( ch, "Gaining level %s costs %d exp.\r\n", number_word( i, ch ), exp_for_level( i-1 ) ); return; } if( is_mob( ch ) ) return; if( ch->shdata->level >= LEVEL_AVATAR ) { send( ch, "You are level %d.\r\n", ch->shdata->level ); return; } send( ch, "You need %d exp and %d quest points to level.\r\n", exp_for_level( ch )-ch->exp, 0 ); send( ch, "[ You have acquired %d exp points so far. ]\r\n", ch->exp ); }
int time_arg( char*& argument, char_data* ch ) { int i; if( !strcasecmp( argument, "forever" ) ) return 0; if( !number_arg( argument, i ) ) { send( ch, "Length of time must be of format <number> <units>.\r\n" ); return -1; } if( i < 1 ) { send( ch, "Only positive definite time periods are acceptable.\r\n" ); return -1; } if( *argument == '\0' ) { send( ch, "Please specify a unit of time.\r\n" ); return -1; } if( matches( argument, "seconds" ) ) return i; if( matches( argument, "minutes" ) ) return 60*i; if( matches( argument, "hours" ) ) return 60*60*i; if( matches( argument, "days" ) ) return 24*60*60*i; if( matches( argument, "years" ) ) return 365*24*60*60*i; send( ch, "Unknown unit of time.\r\nKnown units are seconds, minutes, hours,\ days, and years.\r\n" ); return -1; }
help_data* find_help( char_data* ch, const char* argument ) { help_data* help; int first = -2; int pos; if( number_arg( argument, pos ) ) { if( pos < 0 || pos >= max_help ) { send( ch, "There is no help file with that index.\n\r" ); return NULL; } if( !can_read( ch, help_list[pos] ) ) { send( ch, "You do not have the required permission.\n\r" ); return NULL; } return help_list[pos]; } pos = pntr_search( help_list, max_help, argument ); if( pos >= 0 ) { if( can_read( ch, help_list[pos] ) ) return help_list[pos]; pos++; } else pos = -pos-1; for( ; pos < max_help; pos++ ) { help = help_list[pos]; if( !fmatches( argument, help->name ) ) break; if( can_read( ch, help ) ) { if( first != -2 ) { if( first != -1 ) { page( ch, "More than one match was found - please be more\ specific in what topic you\n\rwant help on.\n\r\n\r" ); page( ch, " [%3d] %s:%15s%s\n\r", first, help_cat_table[help_list[first]->category].name, "", help_list[first]->name ); first = -1; } page( ch, " [%3d] %s:%15s%s\n\r", pos, help_cat_table[help->category].name, "", help->name ); } else { first = pos; } }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); logog::Cout* logog_cout (new logog::Cout); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog_cout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple mesh search test", ' ', "0.1"); // Define a value argument and add it to the command line. // A value arg defines a flag and a type of value that it expects, // such as "-m meshfile". TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"test.msh","string"); // Add the argument mesh_arg to the CmdLine object. The CmdLine object // uses this Arg to parse the command line. cmd.add( mesh_arg ); TCLAP::ValueArg<unsigned> number_arg("n","number-of-test-points","the number of test points",true,10000,"positive number"); cmd.add( number_arg ); TCLAP::ValueArg<bool> contiguous_arg("c","use-contiguous-memory","use a contiguous memory for the test",false,true,"yes or no | 1 or 0"); cmd.add( contiguous_arg ); cmd.parse( argc, argv ); std::string fname (mesh_arg.getValue()); FileIO::MeshIO mesh_io; #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); #endif BaseLib::RunTime run_time; run_time.start(); MeshLib::Mesh* mesh (mesh_io.loadMeshFromFile(fname)); #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); #endif run_time.stop(); INFO ("time for reading: %f s", run_time.elapsed()); // *** preparing test data std::vector<MeshLib::Node*> const& nodes(mesh->getNodes()); std::vector<GeoLib::Point*> pnts_for_search; unsigned n(std::min(static_cast<unsigned>(nodes.size()), number_arg.getValue())); for (size_t k(0); k<n; k++) { pnts_for_search.push_back(new GeoLib::Point(nodes[k]->getCoords())); } std::vector<size_t> idx_found_nodes; testMeshGridAlgorithm(mesh, pnts_for_search, idx_found_nodes, contiguous_arg.getValue()); for (size_t k(0); k<n; k++) { delete pnts_for_search[k]; } delete mesh; delete custom_format; delete logog_cout; LOGOG_SHUTDOWN(); }