本文整理汇总了C++中debugmsg函数的典型用法代码示例。如果您正苦于以下问题:C++ debugmsg函数的具体用法?C++ debugmsg怎么用?C++ debugmsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debugmsg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:GlyphGryph,项目名称:Cataclysm-DDA,代码行数:39,代码来源:veh_typedef.cpp
示例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;
}
开发者ID:Acherontius,项目名称:Cataclysm-DDA,代码行数:35,代码来源:color.cpp
示例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;
}
开发者ID:EpicMan,项目名称:Cataclysm,代码行数:24,代码来源:monster.cpp
示例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 )];
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:24,代码来源:bodypart.cpp
示例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';
}
开发者ID:UNGLinux,项目名称:Obase,代码行数:36,代码来源:docmd.c
示例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;
}
开发者ID:Waladil,项目名称:Cataclysm-DDA,代码行数:24,代码来源:inventory.cpp
示例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;
}
开发者ID:3lsilver,项目名称:astmanproxy,代码行数:36,代码来源:config.c
示例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;
}
}
开发者ID:TheGrifter,项目名称:Cataclysm-DDA,代码行数:37,代码来源:item_factory.cpp
示例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);
}
开发者ID:Uvadzucumi,项目名称:Cataclysm,代码行数:24,代码来源:mission_start.cpp
示例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;
}
}
开发者ID:3721assistant,项目名称:Cataclysm-DDA,代码行数:24,代码来源:faction.cpp
示例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() );
}
}
}
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:38,代码来源:npc_class.cpp
示例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() );
}
}
}
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:37,代码来源:profession.cpp
示例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);
}
开发者ID:UNGLinux,项目名称:Obase,代码行数:45,代码来源:child.c
示例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);
}
}
}
//.........这里部分代码省略.........
开发者ID:JohnnyScatman,项目名称:Cataclysm-DDA,代码行数:101,代码来源:mission_start.cpp
示例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
}
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:82,代码来源:monfaction.cpp
示例16: vehicle
void game::init_vehicles()
{
vehicle *veh;
int index = 0;
int pi;
vtypes.push_back(new vehicle(this, (vhtype_id)index++)); // veh_null
vtypes.push_back(new vehicle(this, (vhtype_id)index++)); // veh_custom
#define VEHICLE(nm) { veh = new vehicle(this, (vhtype_id)index++); veh->name = nm; vtypes.push_back(veh); }
#define PART(mdx, mdy, id) { pi = veh->install_part(mdx, mdy, id); \
if (pi < 0) debugmsg("init_vehicles: '%s' part '%s'(%d) can't be installed to %d,%d", veh->name.c_str(), vpart_list[id].name, veh->parts.size(), mdx, mdy); }
// name
VEHICLE (_("Bicycle"));
// o
// #
// o
// dx, dy, part_id
PART (0, 0, vp_frame_v2);
PART (0, 0, vp_saddle);
PART (0, 0, vp_controls);
PART (0, 0, vp_engine_foot_crank);
PART (1, 0, vp_wheel_bicycle);
PART (-1, 0, vp_wheel_bicycle);
PART (-1, 0, vp_cargo_box);
// name
VEHICLE (_("Motorcycle Chassis"));
// o
// ^
// #
// o
// dx, dy, part_id
PART (0, 0, vp_frame_v2);
PART (0, 0, vp_saddle);
PART (1, 0, vp_frame_handle);
PART (1, 0, vp_fuel_tank_gas);
PART (-1, 0, vp_wheel_motorbike);
// name
VEHICLE (_("Motorcycle"));
// o
// ^
// #
// o
// dx, dy, part_id
PART (0, 0, vp_frame_v2);
PART (0, 0, vp_saddle);
PART (0, 0, vp_controls);
PART (0, 0, vp_engine_gas_v2);
PART (1, 0, vp_frame_handle);
PART (1, 0, vp_head_light);
PART (1, 0, vp_fuel_tank_gas);
PART (2, 0, vp_wheel_motorbike);
PART (-1, 0, vp_wheel_motorbike);
PART (-1, 0, vp_cargo_box);
// name
VEHICLE (_("Quad Bike"));
// 0^0
// #
// 0H0
// dx, dy, part_id
PART (0, 0, vp_frame_v2);
PART (0, 0, vp_saddle);
PART (0, 0, vp_controls);
PART (1, 0, vp_frame_cover);
PART (1, 0, vp_engine_gas_v2);
PART (1, 0, vp_head_light);
PART (1, 0, vp_fuel_tank_gas);
PART (1, 0, vp_steel_plate);
PART (-1,0, vp_frame_h);
PART (-1,0, vp_cargo_trunk);
PART (-1,0, vp_steel_plate);
PART (1, -1, vp_wheel_motorbike);
PART (1, 1, vp_wheel_motorbike);
PART (-1,-1, vp_wheel_motorbike);
PART (-1, 1, vp_wheel_motorbike);
// name
VEHICLE (_("Quad Bike Chassis"));
// 0^0
// #
// 0H0
// dx, dy, part_id
PART (0, 0, vp_frame_v2);
PART (0, 0, vp_saddle);
PART (1, 0, vp_frame_cover);
PART (-1,0, vp_frame_h);
PART (1, -1, vp_wheel_motorbike);
PART (-1,-1, vp_wheel_motorbike);
PART (-1, 1, vp_wheel_motorbike);
// name
VEHICLE (_("Car"));
// o--o
//.........这里部分代码省略.........
开发者ID:AndClayton,项目名称:Cataclysm-DDA,代码行数:101,代码来源:veh_typedef.cpp
示例17: return
// If we're not using lua, need to define Use_function in a way to always call the C++ function
int use_function::call(player* player_instance, item* item_instance, bool active) {
if(function_type == USE_FUNCTION_CPP) {
// If it's a C++ function, simply call it with the given arguments.
iuse tmp;
return (tmp.*cpp_function)(player_instance, item_instance, active);
} else {
#ifdef LUA
// We'll be using lua_state a lot!
lua_State* L = lua_state;
// If it's a lua function, the arguments have to be wrapped in
// lua userdata's and passed on the lua stack.
// We will now call the function f(player, item, active)
update_globals(L);
// Push the lua function on top of the stack
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_function);
// Push the item on top of the stack.
int item_in_registry;
{
item** item_userdata = (item**) lua_newuserdata(L, sizeof(item*));
*item_userdata = item_instance;
// Save a reference to the item in the registry so that we can deallocate it
// when we're done.
item_in_registry = luah_store_in_registry(L, -1);
// Set the metatable for the item.
luah_setmetatable(L, "item_metatable");
}
// Push the "active" parameter on top of the stack.
lua_pushboolean(L, active);
// Call the iuse function
int err = lua_pcall(L, 3, 1, 0);
if(err) {
// Error handling.
const char* error = lua_tostring(L, -1);
debugmsg("Error in lua iuse function: %s", error);
}
// Make sure the now outdated parameters we passed to lua aren't
// being used anymore by setting a metatable that will error on
// access.
luah_remove_from_registry(L, item_in_registry);
luah_setmetatable(L, "outdated_metatable");
return lua_tointeger(L, -1);
#else
// If LUA isn't defined and for some reason we registered a lua function,
// simply do nothing.
return 0;
#endif
}
}
开发者ID:Doffeh,项目名称:Cataclysm-DDA,代码行数:64,代码来源:catalua.cpp
示例18: debugmsg
bool player::install_bionics(game *g, it_bionic* type)
{
if (type == NULL) {
debugmsg("Tried to install NULL bionic");
return false;
}
std::string bio_name = type->name.substr(5); // Strip off "CBM: "
WINDOW* w = newwin(25, 80, 0, 0);
int pl_skill = int_cur +
skillLevel("electronics").level() * 4 +
skillLevel("firstaid").level() * 3 +
skillLevel("mechanics").level() * 2;
int skint = int(pl_skill / 4);
int skdec = int((pl_skill * 10) / 4) % 10;
// Header text
mvwprintz(w, 0, 0, c_white, "Installing bionics:");
mvwprintz(w, 0, 20, type->color, bio_name.c_str());
// Dividing bars
for (int i = 0; i < 80; i++) {
mvwputch(w, 1, i, c_ltgray, LINE_OXOX);
mvwputch(w, 21, i, c_ltgray, LINE_OXOX);
}
// Init the list of bionics
for (unsigned int i = 1; i < type->options.size(); i++) {
bionic_id id = type->options[i];
mvwprintz(w, i + 2, 0, (has_bionic(id) ? c_ltred : c_ltblue),
bionics[id].name.c_str());
}
// Helper text
mvwprintz(w, 2, 40, c_white, "Difficulty of this module: %d",
type->difficulty);
mvwprintz(w, 3, 40, c_white, "Your installation skill: %d.%d",
skint, skdec);
mvwprintz(w, 4, 40, c_white, "Installation requires high intelligence,");
mvwprintz(w, 5, 40, c_white, "and skill in electronics, first aid, and");
mvwprintz(w, 6, 40, c_white, "mechanics (in that order of importance).");
int chance_of_success = int((100 * pl_skill) /
(pl_skill + 4 * type->difficulty));
mvwprintz(w, 8, 40, c_white, "Chance of success:");
nc_color col_suc;
if (chance_of_success >= 95)
col_suc = c_green;
else if (chance_of_success >= 80)
col_suc = c_ltgreen;
else if (chance_of_success >= 60)
col_suc = c_yellow;
else if (chance_of_success >= 35)
col_suc = c_ltred;
else
col_suc = c_red;
mvwprintz(w, 8, 59, col_suc, "%d%%%%", chance_of_success);
mvwprintz(w, 10, 40, c_white, "Failure may result in crippling damage,");
mvwprintz(w, 11, 40, c_white, "loss of existing bionics, genetic damage");
mvwprintz(w, 12, 40, c_white, "or faulty installation.");
wrefresh(w);
if (type->id == itm_bionics_battery) { // No selection list; just confirm
mvwprintz(w, 2, 0, h_ltblue, "Battery Level +%d", BATTERY_AMOUNT);
mvwprintz(w, 22, 0, c_ltblue, "\
Installing this bionic will increase your total battery capacity by %d.\n\
Batteries are necessary for most bionics to function. They also require a\n\
charge mechanism, which must be installed from another CBM.", BATTERY_AMOUNT);
char ch;
wrefresh(w);
do
ch = getch();
while (ch != 'q' && ch != '\n' && ch != KEY_ESCAPE);
if (ch == '\n') {
practice("electronics", (100 - chance_of_success) * 1.5);
practice("firstaid", (100 - chance_of_success) * 1.0);
practice("mechanics", (100 - chance_of_success) * 0.5);
int success = chance_of_success - rng(1, 100);
if (success > 0) {
g->add_msg("Successfully installed batteries.");
max_power_level += BATTERY_AMOUNT;
} else
bionics_install_failure(g, this, success);
werase(w);
delwin(w);
g->refresh_all();
return true;
}
werase(w);
delwin(w);
g->refresh_all();
return false;
}
开发者ID:AkrionXxarr,项目名称:Cataclysm-DDA,代码行数:96,代码来源:bionics.cpp
示例19: debugmsg
void game::wishitem( player *p, int x, int y, int z)
{
if ( p == NULL && x <= 0 ) {
debugmsg("game::wishitem(): invalid parameters");
return;
}
const std::vector<std::string> standard_itype_ids = item_controller->get_all_itype_ids();
int prev_amount, amount = 1;
uimenu wmenu;
wmenu.w_x = 0;
wmenu.w_width = TERMX;
wmenu.pad_right = ( TERMX / 2 > 40 ? TERMX - 40 : TERMX / 2 );
wmenu.return_invalid = true;
wmenu.selected = uistate.wishitem_selected;
wish_item_callback *cb = new wish_item_callback( standard_itype_ids );
wmenu.callback = cb;
for (size_t i = 0; i < standard_itype_ids.size(); i++) {
item ity( standard_itype_ids[i], 0 );
wmenu.addentry( i, true, 0, string_format( _( "%.*s" ), wmenu.pad_right - 5,
ity.tname( 1, false ).c_str() ) );
wmenu.entries[i].extratxt.txt = string_format("%c", ity.symbol());
wmenu.entries[i].extratxt.color = ity.color();
wmenu.entries[i].extratxt.left = 1;
}
do {
wmenu.query();
if ( wmenu.ret >= 0 ) {
item granted(standard_itype_ids[wmenu.ret], calendar::turn);
prev_amount = amount;
if (p != NULL) {
amount = std::atoi(
string_input_popup(_("How many?"), 20, to_string( amount ),
granted.tname()).c_str());
}
if (dynamic_cast<wish_item_callback *>(wmenu.callback)->incontainer) {
granted = granted.in_its_container();
}
if ( p != NULL ) {
for (int i = 0; i < amount; i++) {
p->i_add(granted);
}
p->invalidate_crafting_inventory();
} else if ( x >= 0 && y >= 0 ) {
m.add_item_or_charges( tripoint( x, y, z ), granted);
wmenu.keypress = 'q';
}
if ( amount > 0 ) {
dynamic_cast<wish_item_callback *>(wmenu.callback)->msg =
_("Wish granted. Wish for more or hit 'q' to quit.");
}
uistate.wishitem_selected = wmenu.ret;
if ( !amount ) {
amount = prev_amount;
}
}
} while ( wmenu.keypress != 'q' && wmenu.keypress != KEY_ESCAPE && wmenu.keypress != ' ' );
delete wmenu.callback;
wmenu.callback = NULL;
return;
}
开发者ID:Madnus,项目名称:Cataclysm-DDA,代码行数:61,代码来源:wish.cpp
示例20: newwin
//.........这里部分代码省略.........
it.contents[0].charges > 0)
wprintw(w_inv, " (%d)", it.contents[0].charges);
}
cur_line++;
}
if (start > 0)
mvwprintw(w_inv, maxitems + 4, 0, "< Go Back");
if (cur_it < u.inv.size())
mvwprintw(w_inv, maxitems + 4, 12, "> More items");
wrefresh(w_inv);
ch = input();
if (ch >= '0'&& ch <= '9') {
ch = (char)ch - '0';
count *= 10;
count += ch;
} else if (u.has_item(ch)) {
item& it = u.inv.item_by_letter(ch);
if (it.is_null()) { // Not from inventory
int found = false;
for (int i = 0; i < weapon_and_armor.size() && !found; i++) {
if (weapon_and_armor[i] == ch) {
weapon_and_armor.erase(weapon_and_armor.begin() + i);
found = true;
print_inv_statics(this, w_inv, "Multidrop:", weapon_and_armor);
}
}
if (!found) {
if ( ch == u.weapon.invlet &&
std::find(unreal_itype_ids.begin(), unreal_itype_ids.end(), u.weapon.type->id) != unreal_itype_ids.end()){
if (!warned_about_bionic)
add_msg("You cannot drop your %s.", u.weapon.tname(this).c_str());
warned_about_bionic = true;
} else {
weapon_and_armor.push_back(ch);
print_inv_statics(this, w_inv, "Multidrop:", weapon_and_armor);
}
}
} else {
int index = -1;
for (int i = 0; i < stacks.size(); ++i) {
if (stacks[i]->front().invlet == it.invlet) {
index = i;
break;
}
}
if (index == -1) {
debugmsg("Inventory got out of sync with inventory slice?");
}
if (count == 0) {
if (it.count_by_charges())
{
if (dropping[it.invlet] == 0)
dropping[it.invlet] = -1;
else
dropping[it.invlet] = 0;
}
else
{
if (dropping[it.invlet] == 0)
dropping[it.invlet] = stacks[index]->size();
else
dropping[it.invlet] = 0;
}
}
else if (count >= stacks[index]->size() && !it.count_by_charges())
dropping[it.invlet] = stacks[index]->size();
else
dropping[it.invlet] = count;
count = 0;
}
}
} while (ch != '\n' && ch != KEY_ESCAPE && ch != ' ');
werase(w_inv);
delwin(w_inv);
erase();
refresh_all();
std::vector<item> ret;
if (ch != '\n')
return ret; // Canceled!
for (std::map<char,int>::iterator it = dropping.begin(); it != dropping.end(); it++) {
if (it->second == -1)
ret.push_back( u.inv.remove_item_by_letter( it->first));
else if (it->second && u.inv.item_by_letter( it->first).count_by_charges()) {
int charges = u.inv.item_by_letter( it->first).charges;// >= it->second ? : it->second;
ret.push_back( u.inv.remove_item_by_charges( it->first, it->second > charges ? charges : it->second));
} else if (it->second)
for (int j = it->second; j > 0; j--)
ret.push_back( u.inv.remove_item_by_letter( it->first));
}
for (int i = 0; i < weapon_and_armor.size(); i++)
ret.push_back(u.i_rem(weapon_and_armor[i]));
return ret;
}
开发者ID:InfernoZeus,项目名称:Cataclysm-DDA,代码行数:101,代码来源:inventory_ui.cpp
注:本文中的debugmsg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论