本文整理汇总了C++中debugmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ debugmsg函数的具体用法?C++ debugmsg怎么用?C++ debugmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debugmsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/**
*Works through cached vehicle definitions and creates vehicle objects from them.
*/
void game::finalize_vehicles()
{
int part_x = 0, part_y = 0;
std::string part_id = "";
vehicle *next_vehicle;
while (vehprototypes.size() > 0){
vehicle_prototype *proto = vehprototypes.front();
vehprototypes.pop();
next_vehicle = new vehicle(this, proto->id.c_str());
next_vehicle->name = _(proto->name.c_str());
for (int i = 0; i < proto->parts.size(); ++i)
{
point p = proto->parts[i].first;
part_x = p.x;
part_y = p.y;
part_id = proto->parts[i].second;
if(next_vehicle->install_part(part_x, part_y, part_id) < 0) {
debugmsg("init_vehicles: '%s' part '%s'(%d) can't be installed to %d,%d",
next_vehicle->name.c_str(), part_id.c_str(),
next_vehicle->parts.size(), part_x, part_y);
}
}
for (int i = 0; i < proto->item_spawns.size(); i++) {
next_vehicle->item_spawns.push_back(proto->item_spawns[i]);
}
vtypes[next_vehicle->type] = next_vehicle;
delete proto;
}
}
示例2: color_from_string
/**
* Given the name of a color, returns the nc_color value that matches. If
* no match is found, c_unset is returned.
* Special cases:
* {"black" , c_black}, // missing default prefix c_
* {"<c|h|i>_black" , h_black}, // has prefix c_ or h_ or i_
* {"dark_gray_red" , c_dkgray_red}, // dark_ instead of dk
* {"light_blue_red" , c_ltblue_red}, // light_ instead of lt
* @param new_color The color to get, as a std::string.
* @return The nc_color constant that matches the input.
*/
nc_color color_from_string(const std::string &color)
{
std::string new_color = color;
if ( new_color.substr(1, 1) != "_" ) { //c_ //i_ //h_
new_color = "c_" + new_color;
}
const std::pair<std::string, std::string> pSearch[2] = {{"light_", "lt"}, {"dark_", "dk"}};
for (int i=0; i < 2; ++i) {
size_t pos = 0;
while ((pos = new_color.find(pSearch[i].first, pos)) != std::string::npos) {
new_color.replace(pos, pSearch[i].first.length(), pSearch[i].second);
pos += pSearch[i].second.length();
}
}
const nc_color col = all_colors.name_to_color(new_color);
if ( col > 0 ) {
return col;
}
debugmsg("color_from_string: couldn't parse color: %s", color.c_str());
return c_unset;
}
示例3: debugmsg
bool monster::is_fleeing(player &u)
{
// fleefactor is by default the agressiveness of the animal, minus the
// percentage of remaining HP times four. So, aggresiveness of 5 has a
// fleefactor of 2 AT MINIMUM.
if (type->hp == 0) {
debugmsg("%s has type->hp of 0!", type->name.c_str());
return false;
}
if (friendly != 0)
return false;
int fleefactor = type->agro - ((4 * (type->hp - hp)) / type->hp);
if (u.has_trait(PF_ANIMALEMPATH) && has_flag(MF_ANIMAL)) {
if (type->agro > 0) // Agressive animals flee instead
fleefactor -= 5;
}
if (u.has_trait(PF_TERRIFYING))
fleefactor -= 1;
if (fleefactor > 0)
return false;
return true;
}
示例4: bodypart_ids
const bodypart_ids &convert_bp( body_part bp )
{
static const std::vector<bodypart_ids> body_parts = {
bodypart_ids( "torso" ),
bodypart_ids( "head" ),
bodypart_ids( "eyes" ),
bodypart_ids( "mouth" ),
bodypart_ids( "arm_l" ),
bodypart_ids( "arm_r" ),
bodypart_ids( "hand_l" ),
bodypart_ids( "hand_r" ),
bodypart_ids( "leg_l" ),
bodypart_ids( "leg_r" ),
bodypart_ids( "foot_l" ),
bodypart_ids( "foot_r" ),
bodypart_ids( "num_bp" ),
};
if( bp > num_bp || bp < bp_torso ) {
debugmsg( "Invalid body part token %d", bp );
return body_parts[ num_bp ];
}
return body_parts[static_cast<size_t>( bp )];
}
示例5: rcmptime
static void
rcmptime(struct stat *st, struct subcmd *sbcmds, char **env)
{
DIR *d;
DIRENTRY *dp;
char *cp;
char *optarget;
int len;
debugmsg(DM_CALL, "rcmptime(%x) start", st);
if ((d = opendir((char *) target)) == NULL) {
error("%s: open directory failed: %s", target, SYSERR);
return;
}
optarget = ptarget;
len = ptarget - target;
while ((dp = readdir(d)) != NULL) {
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
continue;
if (len + 1 + (int)strlen(dp->d_name) >= BUFSIZ - 1) {
error("%s/%s: Name too long\n", target, dp->d_name);
continue;
}
ptarget = optarget;
*ptarget++ = '/';
cp = dp->d_name;
while ((*ptarget++ = *cp++) != '\0')
;
ptarget--;
cmptime(target, sbcmds, env);
}
(void) closedir((DIR *) d);
ptarget = optarget;
*ptarget = '\0';
}
示例6: debugmsg
item inventory::reduce_charges_internal(const Locator &locator, long quantity)
{
int pos = 0;
for (invstack::iterator iter = items.begin(); iter != items.end(); ++iter) {
if (item_matches_locator(iter->front(), locator, pos)) {
if (!iter->front().count_by_charges()) {
debugmsg("Tried to remove %s by charges, but item is not counted by charges",
iter->front().tname().c_str());
}
item ret = iter->front();
if (quantity > iter->front().charges) {
debugmsg("Charges: Tried to remove charges that does not exist, \
removing maximum available charges instead");
quantity = iter->front().charges;
}
ret.charges = quantity;
iter->front().charges -= quantity;
if (iter->front().charges <= 0) {
items.erase(iter);
}
return ret;
}
++pos;
}
示例7: ReadConfig
int ReadConfig() {
FILE *FP;
char buf[1024];
char cfn[80];
memset( &pc, 0, sizeof pc );
/* Set nonzero config defaults */
pc.asteriskwritetimeout = 100;
pc.clientwritetimeout = 100;
pc.sslclhellotimeout = 500;
sprintf(cfn, "%s/%s", CDIR, CFILE);
FP = fopen( cfn, "r" );
if ( !FP ) {
fprintf(stderr, "Unable to open config file: %s/%s!\n", CDIR, CFILE);
exit( 1 );
}
if (debug)
debugmsg("config: parsing configuration file: %s", cfn);
while ( fgets( buf, sizeof buf, FP ) ) {
if (*buf == ';' || *buf == '\r' || *buf == '\n' || *buf == '#') continue;
processline(buf);
}
fclose(FP);
/* initialize SSL layer with our server certfile */
init_secure(pc.certfile);
return 0;
}
示例8: if
//Grab color, with appropriate error handling
nc_color Item_factory::color_from_string(std::string new_color){
if("red"==new_color){
return c_red;
} else if("blue"==new_color){
return c_blue;
} else if("green"==new_color){
return c_green;
} else if("light_cyan"==new_color){
return c_ltcyan;
} else if("brown"==new_color){
return c_brown;
} else if("light_red"==new_color){
return c_ltred;
} else if("white"==new_color){
return c_white;
} else if("light_blue"==new_color){
return c_ltblue;
} else if("yellow"==new_color){
return c_yellow;
} else if("magenta"==new_color){
return c_magenta;
} else if("cyan"==new_color){
return c_cyan;
} else if("light_gray"==new_color){
return c_ltgray;
} else if("dark_gray"==new_color){
return c_dkgray;
} else if("light_green"==new_color){
return c_ltgreen;
} else if("pink"==new_color){
return c_pink;
} else {
debugmsg("Received invalid color property %s. Color is required.", new_color.c_str());
return c_white;
}
}
示例9: debugmsg
void mission_start::place_dog(game *g, mission *miss)
{
int city_id = g->cur_om.closest_city( g->om_location() );
point house = g->cur_om.random_house_in_city(city_id);
npc* dev = g->find_npc(miss->npc_id);
if (dev == NULL) {
debugmsg("Couldn't find NPC! %d", miss->npc_id);
return;
}
g->u.i_add( item(g->itypes[itm_dog_whistle], 0) );
g->add_msg(_("%s gave you a dog whistle."), dev->name.c_str());
miss->target = house;
// Make it seen on our map
for (int x = house.x - 6; x <= house.x + 6; x++) {
for (int y = house.y - 6; y <= house.y + 6; y++)
g->cur_om.seen(x, y) = true;
}
tinymap doghouse(&(g->itypes), &(g->mapitems), &(g->traps));
doghouse.load(g, house.x * 2, house.y * 2);
doghouse.add_spawn(mon_dog, 1, SEEX, SEEY, true, -1, miss->uid);
doghouse.save(&(g->cur_om), int(g->turn), house.x * 2, house.y * 2);
}
示例10: debugmsg
void faction::load_faction_template(std::string ident)
{
faction_map::iterator found = _all_faction.find(ident);
if (found != _all_faction.end()) {
id = found->second.id;
name = found->second.name;
likes_u = found->second.likes_u;
respects_u = found->second.respects_u;
known_by_u = found->second.known_by_u;
size = found->second.size;
power = found->second.power;
good = found->second.good;
strength = found->second.strength;
sneak = found->second.sneak;
crime = found->second.crime;
cult = found->second.cult;
desc = found->second.desc;
return;
} else {
debugmsg("Tried to get invalid faction: %s", ident.c_str());
return;
}
}
示例11: debugmsg
void npc_class::check_consistency()
{
for( const auto &legacy : legacy_ids ) {
if( !npc_class_factory.is_valid( legacy ) ) {
debugmsg( "Missing legacy npc class %s", legacy.c_str() );
}
}
for( auto &cl : npc_class_factory.get_all() ) {
if( !item_group::group_is_defined( cl.shopkeeper_item_group ) ) {
debugmsg( "Missing shopkeeper item group %s", cl.shopkeeper_item_group.c_str() );
}
if( !cl.worn_override.empty() && !item_group::group_is_defined( cl.worn_override ) ) {
debugmsg( "Missing worn override item group %s", cl.worn_override.c_str() );
}
if( !cl.carry_override.empty() && !item_group::group_is_defined( cl.carry_override ) ) {
debugmsg( "Missing carry override item group %s", cl.carry_override.c_str() );
}
if( !cl.weapon_override.empty() && !item_group::group_is_defined( cl.weapon_override ) ) {
debugmsg( "Missing weapon override item group %s", cl.weapon_override.c_str() );
}
for( const auto &pr : cl.skills ) {
if( !pr.first.is_valid() ) {
debugmsg( "Invalid skill %s", pr.first.c_str() );
}
}
for( const auto &pr : cl.traits ) {
if( !pr.first.is_valid() ) {
debugmsg( "Invalid trait %s", pr.first.c_str() );
}
}
}
}
示例12: check_item_definitions
void profession::check_definition() const
{
check_item_definitions( legacy_starting_items );
check_item_definitions( legacy_starting_items_female );
check_item_definitions( legacy_starting_items_male );
if( !no_bonus.empty() && !item::type_is_defined( no_bonus ) ) {
debugmsg( "no_bonus item '%s' is not an itype_id", no_bonus.c_str() );
}
if( !item_group::group_is_defined( _starting_items ) ) {
debugmsg( "_starting_items group is undefined" );
}
if( !item_group::group_is_defined( _starting_items_male ) ) {
debugmsg( "_starting_items_male group is undefined" );
}
if( !item_group::group_is_defined( _starting_items_female ) ) {
debugmsg( "_starting_items_female group is undefined" );
}
for( auto const &a : _starting_CBMs ) {
if( !a.is_valid() ) {
debugmsg( "bionic %s for profession %s does not exist", a.c_str(), id.c_str() );
}
}
for( auto &t : _starting_traits ) {
if( !t.is_valid() ) {
debugmsg( "trait %s for profession %s does not exist", t.c_str(), id.c_str() );
}
}
for( const auto &elem : _starting_skills ) {
if( !elem.first.is_valid() ) {
debugmsg( "skill %s for profession %s does not exist", elem.first.c_str(), id.c_str() );
}
}
}
示例13: readchild
/*
* Read input from a child process.
*/
static void
readchild(CHILD *child)
{
char rbuf[BUFSIZ];
ssize_t amt;
debugmsg(DM_CALL, "[readchild(%s, %d, %d) start]",
child->c_name, child->c_pid, child->c_readfd);
/*
* Check that this is a valid child.
*/
if (child->c_name == NULL || child->c_readfd <= 0) {
debugmsg(DM_MISC, "[readchild(%s, %d, %d) bad child]",
child->c_name, child->c_pid, child->c_readfd);
return;
}
/*
* Read from child and display the result.
*/
while ((amt = read(child->c_readfd, rbuf, sizeof(rbuf))) > 0) {
/* XXX remove these debug calls */
debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %zd bytes]",
child->c_name, child->c_pid, child->c_readfd, amt);
(void) xwrite(fileno(stdout), rbuf, amt);
debugmsg(DM_MISC, "[readchild(%s, %d, %d) write done]",
child->c_name, child->c_pid, child->c_readfd);
}
debugmsg(DM_MISC, "readchild(%s, %d, %d) done: amt = %zd errno = %d\n",
child->c_name, child->c_pid, child->c_readfd, amt, errno);
/*
* See if we've reached EOF
*/
if (amt == 0)
debugmsg(DM_MISC, "readchild(%s, %d, %d) at EOF\n",
child->c_name, child->c_pid, child->c_readfd);
}
示例14: debugmsg
void mission_start::place_npc_software(mission *miss)
{
npc* dev = g->find_npc(miss->npc_id);
if (dev == NULL) {
debugmsg("Couldn't find NPC! %d", miss->npc_id);
return;
}
g->u.i_add( item("usb_drive", 0) );
add_msg(_("%s gave you a USB drive."), dev->name.c_str());
std::string type = "house";
switch (dev->myclass) {
case NC_HACKER:
miss->item_id = "software_hacking";
break;
case NC_DOCTOR:
miss->item_id = "software_medical";
type = "s_pharm";
miss->follow_up = MISSION_GET_ZOMBIE_BLOOD_ANAL;
break;
case NC_SCIENTIST:
miss->item_id = "software_math";
break;
default:
miss->item_id = "software_useless";
}
int dist = 0;
point place;
if (type == "house") {
int city_id = g->cur_om->closest_city( g->om_location() );
place = g->cur_om->random_house_in_city(city_id);
// make it global coordinates
place.x += g->cur_om->pos().x * OMAPX;
place.y += g->cur_om->pos().y * OMAPY;
} else {
place = overmap_buffer.find_closest(g->om_global_location(), type, dist, false);
}
miss->target = place;
overmap_buffer.reveal(place, 6, g->levz);
tinymap compmap;
compmap.load_abs(place.x * 2, place.y * 2, g->levz, false);
point comppoint;
oter_id oter = g->cur_om->ter(place.x, place.y, 0);
if (oter == "house_north" || oter == "house_east"
|| oter == "house_south" || oter == "house_west") {
std::vector<point> valid;
for (int x = 0; x < SEEX * 2; x++) {
for (int y = 0; y < SEEY * 2; y++) {
if (compmap.ter(x, y) == t_floor && compmap.furn(x, y) == f_null) {
bool okay = false;
for (int x2 = x - 1; x2 <= x + 1 && !okay; x2++) {
for (int y2 = y - 1; y2 <= y + 1 && !okay; y2++) {
if (compmap.furn(x2, y2) == f_bed || compmap.furn(x2, y2) == f_dresser) {
okay = true;
valid.push_back( point(x, y) );
}
}
}
}
}
}
if (valid.empty()) {
comppoint = point( rng(6, SEEX * 2 - 7), rng(6, SEEY * 2 - 7) );
} else {
comppoint = valid[rng(0, valid.size() - 1)];
}
} else if (oter == "s_pharm_north") {
bool found = false;
for (int x = SEEX * 2 - 1; x > 0 && !found; x--) {
for (int y = SEEY * 2 - 1; y > 0 && !found; y--) {
if (compmap.ter(x, y) == t_floor) {
found = true;
comppoint = point(x, y);
}
}
}
} else if (oter == "s_pharm_east") {
bool found = false;
for (int x = 0; x < SEEX * 2 && !found; x++) {
for (int y = SEEY * 2 - 1; y > 0 && !found; y--) {
if (compmap.ter(x, y) == t_floor) {
found = true;
comppoint = point(x, y);
}
}
}
} else if (oter == "s_pharm_south") {
bool found = false;
for (int x = 0; x < SEEX * 2 && !found; x++) {
for (int y = 0; y < SEEY * 2 && !found; y++) {
if (compmap.ter(x, y) == t_floor) {
found = true;
comppoint = point(x, y);
}
}
}
//.........这里部分代码省略.........
示例15: debugmsg
void monfactions::finalize()
{
if( faction_list.empty() ) {
debugmsg( "No monster factions found." );
return;
}
// Create a tree of faction dependence
std::multimap< mfaction_id, mfaction_id > child_map;
std::set< mfaction_id > unloaded; // To check if cycles exist
std::queue< mfaction_id > queue;
for( auto &faction : faction_list ) {
unloaded.insert( faction.loadid );
if( faction.loadid == faction.base_faction ) {
// No parent = root of the (a?) tree
queue.push( faction.loadid );
continue;
}
// Point parent to children
if( faction.base_faction >= 0 ) {
child_map.insert( std::make_pair( faction.base_faction, faction.loadid ) );
}
// Set faction as friendly to itself if not explicitly set to anything
if( faction.attitude_map.count( faction.loadid ) == 0 ) {
faction.attitude_map[faction.loadid] = MFA_FRIENDLY;
}
}
if( queue.empty() && !faction_list.empty() ) {
debugmsg( "No valid root monster faction!" );
return;
}
// Set uninitialized factions to be children of the root.
// If more than one root exists, use the first one.
const auto root = queue.front();
for( auto &faction : faction_list ) {
if( faction.base_faction < 0 ) {
faction.base_faction = root;
// If it is the (new) root, connecting it to own parent (self) would create a cycle.
// So only try to connect it to the parent if it isn't own parent.
if( faction.base_faction != faction.loadid ) {
child_map.insert( std::make_pair( faction.base_faction, faction.loadid ) );
}
}
}
// Traverse the tree (breadth-first), starting from root
while( !queue.empty() ) {
mfaction_id cur = queue.front();
queue.pop();
if( unloaded.count( cur ) != 0 ) {
unloaded.erase( cur );
} else {
debugmsg( "Tried to load monster faction %s more than once", cur.obj().id.c_str() );
continue;
}
auto children = child_map.equal_range( cur );
for( auto &it = children.first; it != children.second; ++it ) {
// Copy attributes to child
apply_base_faction( cur, it->second );
queue.push( it->second );
}
}
// Bad json
if( !unloaded.empty() ) {
std::string names;
for( auto &fac : unloaded ) {
names.append( fac.id().str() );
names.append( " " );
auto &the_faction = faction_list[fac];
the_faction.base_faction = root;
}
debugmsg( "Cycle encountered when processing monster factions. Bad factions:\n %s", names.c_str() );
}
faction_list.shrink_to_fit(); // Save a couple of bytes
}