///// overmap legacy deserialization, replaced with json serialization June 2015 // throws std::exception (most likely as JsonError) void overmap::unserialize_legacy(std::istream & fin) { // DEBUG VARS int nummg = 0; char datatype; int cx, cy, cz, cs, cp, cd, cdying, horde, tx, ty, intr; std::string cstr; city tmp; std::list<item> npc_inventory; if ( fin.peek() == '#' ) { std::string vline; getline(fin, vline); } int z = 0; // assumption while (fin >> datatype) { if (datatype == 'L') { // Load layer data, and switch to layer fin >> z; std::string tmp_ter; oter_id tmp_otid(0); if (z >= 0 && z < OVERMAP_LAYERS) { int count = 0; std::unordered_map<tripoint, std::string> needs_conversion; for (int j = 0; j < OMAPY; j++) { for (int i = 0; i < OMAPX; i++) { if (count == 0) { fin >> tmp_ter >> count; if( obsolete_terrain( tmp_ter ) ) { for( int p = i; p < i+count; p++ ) { needs_conversion.emplace( tripoint( p, j, z-OVERMAP_DEPTH ), tmp_ter ); } tmp_otid = oter_id( 0 ); } else if( oter_str_id( tmp_ter ).is_valid() ) { tmp_otid = oter_id( tmp_ter ); } else if( tmp_ter.compare( 0, 7, "mall_a_" ) == 0 && oter_str_id( tmp_ter + "_north" ).is_valid() ) { tmp_otid = oter_id( tmp_ter + "_north" ); } else if( tmp_ter.compare( 0, 13, "necropolis_a_" ) == 0 && oter_str_id( tmp_ter + "_north" ).is_valid() ) { tmp_otid = oter_id( tmp_ter + "_north" ); } else { debugmsg("Loaded bad ter! ter %s", tmp_ter.c_str()); tmp_otid = oter_id( 0 ); } } count--; layer[z].terrain[i][j] = tmp_otid; //otermap[tmp_ter].loadid; layer[z].visible[i][j] = false; } } convert_terrain( needs_conversion ); } else {
bool tutorial_game::init() { // TODO: clean up old tutorial calendar::turn = HOURS( 12 ); // Start at noon for( auto &elem : tutorials_seen ) { elem = false; } g->scent.reset(); g->temperature = 65; // We use a Z-factor of 10 so that we don't plop down tutorial rooms in the // middle of the "real" game world g->u.normalize(); g->u.str_cur = g->u.str_max; g->u.per_cur = g->u.per_max; g->u.int_cur = g->u.int_max; g->u.dex_cur = g->u.dex_max; for( int i = 0; i < num_hp_parts; i++ ) { g->u.hp_cur[i] = g->u.hp_max[i]; } const oter_id rock( "rock" ); //~ default name for the tutorial g->u.name = _( "John Smith" ); g->u.prof = profession::generic(); int lx = 50, ly = 50; // overmap terrain coordinates auto &starting_om = overmap_buffer.get( 0, 0 ); for( int i = 0; i < OMAPX; i++ ) { for( int j = 0; j < OMAPY; j++ ) { starting_om.ter( i, j, -1 ) = rock; // Start with the overmap revealed starting_om.seen( i, j, 0 ) = true; } } starting_om.ter( lx, ly, 0 ) = oter_id( "tutorial" ); starting_om.ter( lx, ly, -1 ) = oter_id( "tutorial" ); starting_om.clear_mon_groups(); g->u.toggle_trait( trait_id( "QUICK" ) ); item lighter( "lighter", 0 ); lighter.invlet = 'e'; g->u.inv.add_item( lighter, true, false ); g->u.set_skill_level( skill_id( "gun" ), 5 ); g->u.set_skill_level( skill_id( "melee" ), 5 ); g->load_map( omt_to_sm_copy( tripoint( lx, ly, 0 ) ) ); g->u.setx( 2 ); g->u.sety( 4 ); // This shifts the view to center the players pos g->update_map( g->u ); return true; }
void mission_type::load( JsonObject &jo, const std::string & ) { mandatory( jo, was_loaded, "name", name, translated_string_reader ); mandatory( jo, was_loaded, "difficulty", difficulty ); mandatory( jo, was_loaded, "value", value ); auto djo = jo.get_object( "dialogue" ); // @todo There should be a cleaner way to do it mandatory( djo, was_loaded, "describe", dialogue[ "describe" ] ); mandatory( djo, was_loaded, "offer", dialogue[ "offer" ] ); mandatory( djo, was_loaded, "accepted", dialogue[ "accepted" ] ); mandatory( djo, was_loaded, "rejected", dialogue[ "rejected" ] ); mandatory( djo, was_loaded, "advice", dialogue[ "advice" ] ); mandatory( djo, was_loaded, "inquire", dialogue[ "inquire" ] ); mandatory( djo, was_loaded, "success", dialogue[ "success" ] ); mandatory( djo, was_loaded, "success_lie", dialogue[ "success_lie" ] ); mandatory( djo, was_loaded, "failure", dialogue[ "failure" ] ); optional( jo, was_loaded, "urgent", urgent ); optional( jo, was_loaded, "item", item_id ); optional( jo, was_loaded, "count", item_count, 1 ); goal = jo.get_enum_value<decltype(goal)>( "goal" ); assign_function( jo, "place", place, tripoint_function_map ); assign_function( jo, "start", start, mission_function_map ); assign_function( jo, "end", end, mission_function_map ); assign_function( jo, "fail", fail, mission_function_map ); if( jo.has_int( "deadline_low" ) ) { deadline_low = DAYS( jo.get_int( "deadline_low" ) ); } if( jo.has_int( "deadline_high" ) ) { deadline_high = DAYS( jo.get_int( "deadline_high" ) ); } if( jo.has_member( "origins" ) ) { origins.clear(); for( auto &m : jo.get_tags( "origins" ) ) { origins.emplace_back( io::string_to_enum_look_up( io::origin_map, m ) ); } } if( jo.has_member( "followup" ) ) { follow_up = mission_type_id( jo.get_string( "followup" ) ); } if( jo.has_member( "destination" ) ) { target_id = oter_id( jo.get_string( "destination" ) ); } }
mission::mission() { type = NULL; description = ""; status = mission_status::yet_to_start; value = 0; uid = -1; target = tripoint(INT_MIN, INT_MIN, INT_MIN); item_id = "null"; item_count = 1; target_id = oter_id( 0 ); recruit_class = NC_NONE; target_npc_id = -1; monster_type = "mon_null"; monster_kill_goal = -1; deadline = 0; npc_id = -1; good_fac_id = -1; bad_fac_id = -1; step = 0; player_id = -1; }