bool can_construct( const construction &con, const tripoint &p ) { // see if the special pre-function checks out bool place_okay = con.pre_special( p ); // see if the terrain type checks out if( !con.pre_terrain.empty() ) { if( con.pre_is_furniture ) { furn_id f = furn_id( con.pre_terrain ); place_okay &= g->m.furn( p ) == f; } else { ter_id t = ter_id( con.pre_terrain ); place_okay &= g->m.ter( p ) == t; } } // see if the flags check out place_okay &= std::all_of( con.pre_flags.begin(), con.pre_flags.end(), [&p] ( const std::string &flag ) { return g->m.has_flag( flag, p ); }); // make sure the construction would actually do something if( !con.post_terrain.empty() ) { if( con.post_is_furniture ) { furn_id f = furn_id( con.post_terrain ); place_okay &= g->m.furn( p ) != f; } else { ter_id t = ter_id( con.post_terrain ); place_okay &= g->m.ter( p ) != t; } } return place_okay; }
void clear_game( const ter_id &terrain ) { // Set to turn 0 to prevent solars from producing power calendar::turn = 0; for( monster &critter : g->all_monsters() ) { g->remove_zombie( critter ); } g->unload_npcs(); // Move player somewhere safe g->u.setpos( tripoint( 0, 0, 0 ) ); // Blind the player to avoid needless drawing-related overhead g->u.add_effect( effect_blind, 1_turns, num_bp, true ); for( const tripoint &p : g->m.points_in_rectangle( tripoint( 0, 0, 0 ), tripoint( MAPSIZE * SEEX, MAPSIZE * SEEY, 0 ) ) ) { g->m.furn_set( p, furn_id( "f_null" ) ); g->m.ter_set( p, terrain ); g->m.trap_set( p, trap_id( "tr_null" ) ); g->m.i_clear( p ); } for( wrapped_vehicle &veh : g->m.get_vehicles( tripoint( 0, 0, 0 ), tripoint( MAPSIZE * SEEX, MAPSIZE * SEEY, 0 ) ) ) { g->m.destroy_vehicle( veh.v ); } g->m.build_map_cache( 0, true ); }
void prepare_test() { player &dummy = g->u; // Remove first worn item until there are none left. std::list<item> temp; while( dummy.takeoff( dummy.i_at( -2 ), &temp ) ); for( trait_id tr : dummy.get_mutations() ) { dummy.unset_mutation( tr ); } // Prevent spilling, but don't cause encumbrance if( !dummy.has_trait( trait_id( "DEBUG_STORAGE" ) ) ) { dummy.set_mutation( trait_id( "DEBUG_STORAGE" ) ); } // Make stats nominal. dummy.str_cur = 8; dummy.dex_cur = 8; dummy.int_cur = 8; dummy.per_cur = 8; const tripoint spot( 60, 60, 0 ); dummy.setpos( spot ); g->m.ter_set( spot, ter_id( "t_dirt" ) ); g->m.furn_set( spot, furn_id( "f_null" ) ); g->m.i_clear( spot ); }
furn_id furnfind(const std::string & id) { if( furnmap.find(id) == furnmap.end() ) { debugmsg("Can't find %s",id.c_str()); return furn_id( 0 ); } return furnmap[id].loadid; }
bool submap::has_signage( const point &p ) const { if( frn[p.x][p.y] == furn_id( "f_sign" ) ) { return find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE ).result; } return false; }
const std::string submap::get_signage( const point &p ) const { if( frn[p.x][p.y] == furn_id( "f_sign" ) ) { const auto fresult = find_cosmetic( cosmetics, p, COSMETICS_SIGNAGE ); if( fresult.result ) { return cosmetics[ fresult.ndx ].str; } } return STRING_EMPTY; }
void load_furniture(JsonObject &jsobj) { if ( furnlist.empty() ) { furn_t new_null = null_furniture_t(); furnmap[new_null.id] = new_null; furnlist.push_back(new_null); } furn_t new_furniture; new_furniture.id = jsobj.get_string("id"); if ( new_furniture.id == "f_null" ) { return; } new_furniture.name = _(jsobj.get_string("name").c_str()); new_furniture.load_symbol( jsobj ); new_furniture.movecost = jsobj.get_int("move_cost_mod"); new_furniture.move_str_req = jsobj.get_int("required_str"); new_furniture.max_volume = jsobj.get_int("max_volume", MAX_VOLUME_IN_SQUARE); new_furniture.crafting_pseudo_item = jsobj.get_string("crafting_pseudo_item", ""); new_furniture.transparent = false; for( auto & flag : jsobj.get_string_array( "flags" ) ) { new_furniture.set_flag( flag ); } if(jsobj.has_member("examine_action")) { std::string function_name = jsobj.get_string("examine_action"); new_furniture.examine = iexamine_function_from_string(function_name); } else { //If not specified, default to no action new_furniture.examine = iexamine_function_from_string("none"); } new_furniture.open = ""; if ( jsobj.has_member("open") ) { new_furniture.open = jsobj.get_string("open"); } new_furniture.close = ""; if ( jsobj.has_member("close") ) { new_furniture.close = jsobj.get_string("close"); } new_furniture.bash.load(jsobj, "bash", true); new_furniture.deconstruct.load(jsobj, "deconstruct", true); new_furniture.loadid = furn_id( furnlist.size() ); furnmap[new_furniture.id] = new_furniture; furnlist.push_back(new_furniture); }
furn_t null_furniture_t() { furn_t new_furniture; new_furniture.id = "f_null"; new_furniture.name = _("nothing"); new_furniture.sym = ' '; new_furniture.color = c_white; new_furniture.movecost = 0; new_furniture.move_str_req = -1; new_furniture.transparent = true; new_furniture.set_flag("TRANSPARENT"); new_furniture.examine = iexamine_function_from_string("none"); new_furniture.loadid = furn_id( 0 ); new_furniture.open = ""; new_furniture.close = ""; new_furniture.max_volume = MAX_VOLUME_IN_SQUARE; return new_furniture; }
if (it_tmp.active) sm->active_item_count++; } else if (string_identifier == "C") { getline(fin, databuff); // Clear out the endline getline(fin, databuff); int index = sm->itm[itx][ity].size() - 1; it_tmp.load_info(databuff, master_game); sm->itm[itx][ity][index].put_in(it_tmp); if (it_tmp.active) sm->active_item_count++; } else if (string_identifier == "T") { fin >> itx >> ity >> t; sm->trp[itx][ity] = trap_id(t); } else if (string_identifier == "f") { fin >> itx >> ity >> t; sm->frn[itx][ity] = furn_id(t); } else if (string_identifier == "F") { fin >> itx >> ity >> t >> d >> a; if(!sm->fld[itx][ity].findField(field_id(t))) sm->field_count++; sm->fld[itx][ity].addField(field_id(t), d, a); } else if (string_identifier == "S") { char tmpfriend; int tmpfac = -1, tmpmis = -1; std::string spawnname; fin >> t >> a >> itx >> ity >> tmpfac >> tmpmis >> tmpfriend >> spawnname; spawn_point tmp(mon_id(t), a, itx, ity, tmpfac, tmpmis, (tmpfriend == '1'), spawnname); sm->spawns.push_back(tmp); } else if (string_identifier == "V") { vehicle * veh = new vehicle(master_game);
#include "game.h" #include "map.h" #include "map_helpers.h" #include "player.h" #include "enums.h" #include "game_constants.h" #include "type_id.h" TEST_CASE( "destroy_grabbed_furniture" ) { clear_map(); GIVEN( "Furniture grabbed by the player" ) { const tripoint test_origin( 60, 60, 0 ); g->u.setpos( test_origin ); const tripoint grab_point = test_origin + tripoint( 1, 0, 0 ); g->m.furn_set( grab_point, furn_id( "f_chair" ) ); g->u.grab( OBJECT_FURNITURE, grab_point ); WHEN( "The furniture grabbed by the player is destroyed" ) { g->m.destroy( grab_point ); THEN( "The player's grab is released" ) { CHECK( g->u.get_grab_type() == OBJECT_NONE ); CHECK( g->u.grab_point == tripoint_zero ); } } } } TEST_CASE( "map_bounds_checking" ) { // FIXME: There are issues with vehicle caching between maps, because // vehicles are stored in the global MAPBUFFER which all maps refer to. To
void set_furn_ids() { f_null = furn_id( "f_null" ); f_hay = furn_id( "f_hay" ); f_rubble = furn_id( "f_rubble" ); f_rubble_rock = furn_id( "f_rubble_rock" ); f_wreckage = furn_id( "f_wreckage" ); f_ash = furn_id( "f_ash" ); f_barricade_road = furn_id( "f_barricade_road" ); f_sandbag_half = furn_id( "f_sandbag_half" ); f_sandbag_wall = furn_id( "f_sandbag_wall" ); f_bulletin = furn_id( "f_bulletin" ); f_indoor_plant = furn_id( "f_indoor_plant" ); f_indoor_plant_y = furn_id( "f_indoor_plant_y" ); f_bed = furn_id( "f_bed" ); f_toilet = furn_id( "f_toilet" ); f_makeshift_bed = furn_id( "f_makeshift_bed" ); f_straw_bed = furn_id( "f_straw_bed" ); f_sink = furn_id( "f_sink" ); f_oven = furn_id( "f_oven" ); f_woodstove = furn_id( "f_woodstove" ); f_fireplace = furn_id( "f_fireplace" ); f_bathtub = furn_id( "f_bathtub" ); f_chair = furn_id( "f_chair" ); f_armchair = furn_id( "f_armchair" ); f_sofa = furn_id( "f_sofa" ); f_cupboard = furn_id( "f_cupboard" ); f_trashcan = furn_id( "f_trashcan" ); f_desk = furn_id( "f_desk" ); f_exercise = furn_id( "f_exercise" ); f_ball_mach = furn_id( "f_ball_mach" ); f_bench = furn_id( "f_bench" ); f_lane = furn_id( "f_lane" ); f_table = furn_id( "f_table" ); f_pool_table = furn_id( "f_pool_table" ); f_counter = furn_id( "f_counter" ); f_fridge = furn_id( "f_fridge" ); f_glass_fridge = furn_id( "f_glass_fridge" ); f_dresser = furn_id( "f_dresser" ); f_locker = furn_id( "f_locker" ); f_rack = furn_id( "f_rack" ); f_bookcase = furn_id( "f_bookcase" ); f_washer = furn_id( "f_washer" ); f_dryer = furn_id( "f_dryer" ); f_vending_c = furn_id( "f_vending_c" ); f_vending_o = furn_id( "f_vending_o" ); f_vending_reinforced = furn_id( "f_vending_reinforced" ); f_dumpster = furn_id( "f_dumpster" ); f_dive_block = furn_id( "f_dive_block" ); f_crate_c = furn_id( "f_crate_c" ); f_crate_o = furn_id( "f_crate_o" ); f_coffin_c = furn_id( "f_coffin_c" ); f_coffin_o = furn_id( "f_coffin_o" ); f_canvas_wall = furn_id( "f_canvas_wall" ); f_large_canvas_wall = furn_id( "f_large_canvas_wall" ); f_canvas_door = furn_id( "f_canvas_door" ); f_large_canvas_door = furn_id( "f_large_canvas_door" ); f_canvas_door_o = furn_id( "f_canvas_door_o" ); f_large_canvas_door_o = furn_id( "f_large_canvas_door_o" ); f_groundsheet = furn_id( "f_groundsheet" ); f_large_groundsheet = furn_id( "f_large_groundsheet" ); f_center_groundsheet = furn_id( "f_center_groundsheet" ); f_fema_groundsheet = furn_id( "f_fema_groundsheet" ); f_skin_wall = furn_id( "f_skin_wall" ); f_skin_door = furn_id( "f_skin_door" ); f_skin_door_o = furn_id( "f_skin_door_o" ); f_skin_groundsheet = furn_id( "f_skin_groundsheet" ); f_mutpoppy = furn_id( "f_mutpoppy" ); f_fungal_mass = furn_id( "f_fungal_mass" ); f_fungal_clump = furn_id( "f_fungal_clump" ); f_flower_fungal = furn_id( "f_flower_fungal" ); f_bluebell = furn_id( "f_bluebell" ); f_dahlia = furn_id( "f_dahlia" ); f_datura = furn_id( "f_datura" ); f_dandelion = furn_id( "f_dandelion" ); f_cattails = furn_id( "f_cattails" ); f_safe_c = furn_id( "f_safe_c" ); f_safe_l = furn_id( "f_safe_l" ); f_safe_o = furn_id( "f_safe_o" ); f_plant_seed = furn_id( "f_plant_seed" ); f_plant_seedling = furn_id( "f_plant_seedling" ); f_plant_mature = furn_id( "f_plant_mature" ); f_plant_harvest = furn_id( "f_plant_harvest" ); f_fvat_empty = furn_id( "f_fvat_empty" ); f_fvat_full = furn_id( "f_fvat_full" ); f_wood_keg = furn_id( "f_wood_keg" ); f_standing_tank = furn_id( "f_standing_tank" ); f_statue = furn_id( "f_statue" ); f_egg_sackbw = furn_id( "f_egg_sackbw" ); f_egg_sackcs = furn_id( "f_egg_sackcs" ); f_egg_sackws = furn_id( "f_egg_sackws" ); f_egg_sacke = furn_id( "f_egg_sacke" ); f_flower_marloss = furn_id( "f_flower_marloss" ); f_floor_canvas = furn_id( "f_floor_canvas" ); f_kiln_empty = furn_id( "f_kiln_empty" ); f_kiln_full = furn_id( "f_kiln_full" ); f_kiln_metal_empty = furn_id( "f_kiln_metal_empty" ); f_kiln_metal_full = furn_id( "f_kiln_metal_full" ); f_smoking_rack = furn_id( "f_smoking_rack" ); f_smoking_rack_active = furn_id( "f_smoking_rack_active" ); f_robotic_arm = furn_id( "f_robotic_arm" ); f_brazier = furn_id( "f_brazier" ); }
} #define merge_invlet_test_autoletter_off( name, dummy, from ) \ SECTION( std::string( name ) + " (auto letter off)" ) { \ get_options().get_option( "AUTO_INV_ASSIGN" ).setValue( "false" ); \ merge_invlet_test( dummy, from ); \ } TEST_CASE( "Inventory letter test", "[invlet]" ) { player &dummy = g->u; const tripoint spot( 60, 60, 0 ); clear_map(); dummy.setpos( spot ); g->m.ter_set( spot, ter_id( "t_dirt" ) ); g->m.furn_set( spot, furn_id( "f_null" ) ); if( !dummy.has_trait( trait_debug_storage ) ) { dummy.set_mutation( trait_debug_storage ); } invlet_test_autoletter_off( "Picking up items from the ground", dummy, GROUND, INVENTORY ); invlet_test_autoletter_off( "Wearing items from the ground", dummy, GROUND, WORN ); invlet_test_autoletter_off( "Wielding and wearing items from the ground", dummy, GROUND, WIELDED_OR_WORN ); invlet_test_autoletter_off( "Wearing items from inventory", dummy, INVENTORY, WORN ); stack_invlet_test_autoletter_off( "Wearing item from a stack in inventory", dummy, INVENTORY, WORN ); stack_invlet_test_autoletter_off( "Wielding item from a stack in inventory", dummy, INVENTORY, WIELDED_OR_WORN );
void load_furniture(JsonObject &jsobj) { if ( furnlist.empty() ) { furn_t new_null = null_furniture_t(); furnmap[new_null.id] = new_null; furnlist.push_back(new_null); } furn_t new_furniture; new_furniture.id = jsobj.get_string("id"); if ( new_furniture.id == "f_null" ) { return; } new_furniture.name = _(jsobj.get_string("name").c_str()); new_furniture.sym = jsobj.get_string("symbol").c_str()[0]; bool has_color = jsobj.has_member("color"); bool has_bgcolor = jsobj.has_member("bgcolor"); if(has_color && has_bgcolor) { debugmsg("Found both color and bgcolor for %s, use only one of these.", new_furniture.name.c_str()); new_furniture.color = c_white; } else if(has_color) { new_furniture.color = color_from_string(jsobj.get_string("color")); } else if(has_bgcolor) { new_furniture.color = bgcolor_from_string(jsobj.get_string("bgcolor")); } else { debugmsg("Furniture %s needs at least one of: color, bgcolor.", new_furniture.name.c_str()); } new_furniture.movecost = jsobj.get_int("move_cost_mod"); new_furniture.move_str_req = jsobj.get_int("required_str"); new_furniture.max_volume = jsobj.get_int("max_volume", MAX_VOLUME_IN_SQUARE); new_furniture.crafting_pseudo_item = jsobj.get_string("crafting_pseudo_item", ""); new_furniture.transparent = false; for( auto & flag : jsobj.get_string_array( "flags" ) ) { new_furniture.set_flag( flag ); } if(jsobj.has_member("examine_action")) { std::string function_name = jsobj.get_string("examine_action"); new_furniture.examine = iexamine_function_from_string(function_name); } else { //If not specified, default to no action new_furniture.examine = iexamine_function_from_string("none"); } new_furniture.open = ""; if ( jsobj.has_member("open") ) { new_furniture.open = jsobj.get_string("open"); } new_furniture.close = ""; if ( jsobj.has_member("close") ) { new_furniture.close = jsobj.get_string("close"); } new_furniture.bash.load(jsobj, "bash", true); new_furniture.deconstruct.load(jsobj, "deconstruct", true); new_furniture.loadid = furn_id( furnlist.size() ); furnmap[new_furniture.id] = new_furniture; furnlist.push_back(new_furniture); }