Example #1
0
static int init_level(void)
{
    demo_play_init(USER_REPLAY_FILE, level, mode,
                   curr.score, curr.balls, curr.times);

    /*
     * Init both client and server, then process the first batch
     * of commands generated by the server to sync client to
     * server.
     */

    if (game_client_init(level_file(level)) &&
        game_server_init(level_file(level), level_time(level), goal_e))
    {
        game_client_sync(demo_fp);
        audio_music_fade_to(2.0f, level_song(level));
        return 1;
    }

    demo_play_stop(1);
    return 0;
}
Example #2
0
bool isLevelFileValid()
{
    QString file_name = "/Users/Parth/Documents/QT/RvZ/rvz_levels.csv";
    QFile level_file(file_name);

    //Displays warning if file is not readable and exits program
    if(!level_file.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        QMessageBox::warning(0,"Cannot execute RvZ","rvz_levels.csv does not exist or is unreadable!",
                             QMessageBox::Ok);
        return 0;
    }
    else
        return 1;
}
Example #3
0
static void start_over_level(int i)
{
    struct level *l = get_level(i);

    if (level_opened(l) || config_cheat())
    {
        gui_set_image(shot_id, level_shot(l));

        set_score_board(level_score(l, SCORE_COIN), -1,
                        level_score(l, SCORE_TIME), -1,
                        level_score(l, SCORE_GOAL), -1);

        if (file_id)
            gui_set_label(file_id, level_file(l));
    }
}
Example #4
0
void level_class::load(std::string file_name)
{
    char         temp_char = ' ';
    float        temp_float;
    std::string  temp_string_key;
    std::string  temp_string_value;
    int          count;
    std::string  data_line;
    std::fstream level_file(file_name.c_str(),std::ios::in|std::ios::binary);
    if (level_file.is_open())
    {
        while ( level_file.good() )
        {
            getline(level_file,data_line);
            {
                temp_char = data_line[0];
                if((temp_char != '#') && ((int)data_line.length() > 2))
                {
                    temp_char         = '#';
                    temp_string_key   = "";
                    temp_string_value = "";
                    count = 0;
                    while(temp_char != ' ')
                    {
                        temp_char = data_line[count];
                        if(temp_char != ' ') temp_string_key += temp_char;
                        count++;
                        if(count > (int)data_line.length()) (temp_char = ' ');
                    }
                    while((temp_char == ' ') || (temp_char == '='))
                    {
                        temp_char = data_line[count];
                        count++;
                        if(count > (int)data_line.length()) (temp_char = '#');
                    }
                    count--;
                    while(temp_char != ' ')
                    {
                        temp_char = data_line[count];
                        if(temp_char != ' ') temp_string_value += temp_char;
                        count++;
                        if(count > (int)data_line.length()) (temp_char = ' ');
                    }
                    temp_float = atof(temp_string_value.c_str());
                    if (temp_string_key == "NPC_Type")
                    {
                        level_class::NPC_type = (int)temp_float;
                    }
                    if (temp_string_key == "BOSS")
                    {
                        if ((int)temp_float == 1) level_class::BOSS = true;
                        else level_class::BOSS = false;
                    }
                    if (temp_string_key == "Music_Track")
                    {
                        level_class::music_track = (int)temp_float;
                    }
                    if (temp_string_key == "Background_00")
                    {
                        level_class::background_00 = (int)temp_float;
                    }
                    if (temp_string_key == "Background_01")
                    {
                        level_class::background_01 = (int)temp_float;
                    }
                    if (temp_string_key == "Speed")
                    {
                        level_class::speed = temp_float;
                    }
                    if (temp_string_key == "NPC_Spawn_Rate")
                    {
                        level_class::NPC_spawn_rate       = (int)temp_float;
                        level_class::NPC_spawn_rate_count = (int)temp_float;
                    }
                    if (temp_string_key == "NPC_Projectile_Spawn_Rate")
                    {
                        level_class::NPC_projectile_spawn_rate       = (int)temp_float;
                    }
                    if (temp_string_key == "Victory_Kills")
                    {
                        level_class::victory_kills= (int)temp_float;
                    }
                    if (temp_string_key == "Victory_Spawned")
                    {
                        level_class::victory_spawened       = (int)temp_float;
                    }
                    if (temp_string_key == "Victory_Score")
                    {
                        level_class::victory_score       = (int)temp_float;
                    }
                    if (temp_string_key == "Number_Of_Waves")
                    {
                        level_class::number_of_waves       = (int)temp_float - 1;
                    }
                    if (temp_string_key == "Wave_00_Wave_Size")
                    {
                        level_class::wave[ 0].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_00_NPC_Type")
                    {
                        level_class::wave[ 0].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_00_Spawn_Pattern")
                    {
                        level_class::wave[ 0].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_01_Wave_Size")
                    {
                        level_class::wave[ 1].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_01_NPC_Type")
                    {
                        level_class::wave[ 1].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_01_Spawn_Pattern")
                    {
                        level_class::wave[ 1].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_02_Wave_Size")
                    {
                        level_class::wave[ 2].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_02_NPC_Type")
                    {
                        level_class::wave[ 2].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_02_Spawn_Pattern")
                    {
                        level_class::wave[ 2].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_03_Wave_Size")
                    {
                        level_class::wave[ 3].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_03_NPC_Type")
                    {
                        level_class::wave[ 3].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_03_Spawn_Pattern")
                    {
                        level_class::wave[ 3].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_04_Wave_Size")
                    {
                        level_class::wave[ 4].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_04_NPC_Type")
                    {
                        level_class::wave[ 4].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_04_Spawn_Pattern")
                    {
                        level_class::wave[ 4].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_05_Wave_Size")
                    {
                        level_class::wave[ 5].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_05_NPC_Type")
                    {
                        level_class::wave[ 5].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_05_Spawn_Pattern")
                    {
                        level_class::wave[ 5].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_06_Wave_Size")
                    {
                        level_class::wave[ 6].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_06_NPC_Type")
                    {
                        level_class::wave[ 6].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_06_Spawn_Pattern")
                    {
                        level_class::wave[ 6].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_07_Wave_Size")
                    {
                        level_class::wave[ 7].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_07_NPC_Type")
                    {
                        level_class::wave[ 7].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_07_Spawn_Pattern")
                    {
                        level_class::wave[ 7].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_08_Wave_Size")
                    {
                        level_class::wave[ 8].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_08_NPC_Type")
                    {
                        level_class::wave[ 8].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_08_Spawn_Pattern")
                    {
                        level_class::wave[ 8].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_09_Wave_Size")
                    {
                        level_class::wave[ 9].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_09_NPC_Type")
                    {
                        level_class::wave[ 9].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_09_Spawn_Pattern")
                    {
                        level_class::wave[ 9].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_10_Wave_Size")
                    {
                        level_class::wave[10].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_10_NPC_Type")
                    {
                        level_class::wave[10].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_10_Spawn_Pattern")
                    {
                        level_class::wave[10].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_11_Wave_Size")
                    {
                        level_class::wave[11].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_11_NPC_Type")
                    {
                        level_class::wave[11].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_11_Spawn_Pattern")
                    {
                        level_class::wave[11].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_12_Wave_Size")
                    {
                        level_class::wave[12].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_12_NPC_Type")
                    {
                        level_class::wave[12].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_12_Spawn_Pattern")
                    {
                        level_class::wave[12].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_13_Wave_Size")
                    {
                        level_class::wave[13].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_13_NPC_Type")
                    {
                        level_class::wave[13].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_13_Spawn_Pattern")
                    {
                        level_class::wave[13].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_14_Wave_Size")
                    {
                        level_class::wave[14].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_14_NPC_Type")
                    {
                        level_class::wave[14].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_14_Spawn_Pattern")
                    {
                        level_class::wave[14].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_15_Wave_Size")
                    {
                        level_class::wave[15].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_15_NPC_Type")
                    {
                        level_class::wave[15].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_15_Spawn_Pattern")
                    {
                        level_class::wave[15].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_16_Wave_Size")
                    {
                        level_class::wave[16].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_16_NPC_Type")
                    {
                        level_class::wave[16].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_16_Spawn_Pattern")
                    {
                        level_class::wave[16].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_17_Wave_Size")
                    {
                        level_class::wave[17].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_17_NPC_Type")
                    {
                        level_class::wave[17].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_17_Spawn_Pattern")
                    {
                        level_class::wave[17].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_18_Wave_Size")
                    {
                        level_class::wave[18].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_18_NPC_Type")
                    {
                        level_class::wave[18].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_18_Spawn_Pattern")
                    {
                        level_class::wave[18].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_19_Wave_Size")
                    {
                        level_class::wave[19].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_19_NPC_Type")
                    {
                        level_class::wave[19].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_19_Spawn_Pattern")
                    {
                        level_class::wave[19].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_20_Wave_Size")
                    {
                        level_class::wave[20].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_20_NPC_Type")
                    {
                        level_class::wave[20].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_20_Spawn_Pattern")
                    {
                        level_class::wave[20].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_21_Wave_Size")
                    {
                        level_class::wave[21].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_21_NPC_Type")
                    {
                        level_class::wave[21].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_21_Spawn_Pattern")
                    {
                        level_class::wave[21].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_22_Wave_Size")
                    {
                        level_class::wave[22].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_22_NPC_Type")
                    {
                        level_class::wave[22].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_22_Spawn_Pattern")
                    {
                        level_class::wave[22].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_23_Wave_Size")
                    {
                        level_class::wave[23].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_23_NPC_Type")
                    {
                        level_class::wave[23].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_23_Spawn_Pattern")
                    {
                        level_class::wave[23].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_24_Wave_Size")
                    {
                        level_class::wave[24].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_24_NPC_Type")
                    {
                        level_class::wave[24].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_24_Spawn_Pattern")
                    {
                        level_class::wave[24].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_25_Wave_Size")
                    {
                        level_class::wave[25].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_25_NPC_Type")
                    {
                        level_class::wave[25].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_25_Spawn_Pattern")
                    {
                        level_class::wave[25].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_26_Wave_Size")
                    {
                        level_class::wave[26].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_26_NPC_Type")
                    {
                        level_class::wave[26].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_26_Spawn_Pattern")
                    {
                        level_class::wave[26].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_27_Wave_Size")
                    {
                        level_class::wave[27].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_27_NPC_Type")
                    {
                        level_class::wave[27].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_27_Spawn_Pattern")
                    {
                        level_class::wave[27].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_28_Wave_Size")
                    {
                        level_class::wave[28].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_28_NPC_Type")
                    {
                        level_class::wave[28].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_28_Spawn_Pattern")
                    {
                        level_class::wave[28].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_29_Wave_Size")
                    {
                        level_class::wave[29].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_29_NPC_Type")
                    {
                        level_class::wave[29].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_29_Spawn_Pattern")
                    {
                        level_class::wave[29].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_30_Wave_Size")
                    {
                        level_class::wave[30].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_30_NPC_Type")
                    {
                        level_class::wave[30].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_30_Spawn_Pattern")
                    {
                        level_class::wave[30].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_31_Wave_Size")
                    {
                        level_class::wave[31].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_31_NPC_Type")
                    {
                        level_class::wave[31].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_31_Spawn_Pattern")
                    {
                        level_class::wave[31].spawn_pattern       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_32_Wave_Size")
                    {
                        level_class::wave[32].wave_size       = temp_float;
                    }
                    if (temp_string_key == "Wave_32_NPC_Type")
                    {
                        level_class::wave[32].npc_type       = (int)temp_float;
                    }
                    if (temp_string_key == "Wave_32_Spawn_Pattern")
                    {
                        level_class::wave[32].spawn_pattern       = (int)temp_float;
                    }
                }
            }
        }
        level_file.close();
    }
}
bool level_editor_widget::open_level_core_func
	( const string& n_level_file_name )
{
	fstream level_file( n_level_file_name, ios_base::in );
	
	if ( !level_file.is_open() )
	{
		cout << "Unable to open " << n_level_file_name 
			<< " for reading.\n";
		return false;
	}
	
	level_file.close();
	
	//if ( the_core_widget != NULL )
	//{
	//	the_core_widget->level_file_name = n_level_file_name;
	//}
	
	core_widgets_tab_widget->clear();
	the_level.sublevel_vec.clear();
	
	sprite_properties_widget_enabled_vec.clear();
	
	
	
	if ( !the_core_widget_vec.empty() )
	{
		//for ( auto& core_widget : the_core_widget_vec )
		//{
		//	//delete core_widget;
		//	core_widget.reset(NULL);
		//}
		the_core_widget_vec.clear();
	}
	
	
	if ( !core_widget_scroll_area_vec.empty() )
	{
		//for ( auto& scroll_area : core_widget_scroll_area_vec )
		//{
		//	//delete scroll_area;
		//	scroll_area.reset(NULL);
		//}
		core_widget_scroll_area_vec.clear();
	}
	
	//the_core_widget_vec.clear();
	
	
	
	level temp_level;
	
	xml_document doc;
	
	xml_parse_result result = doc.load_file(n_level_file_name.c_str());
	
	
	
	auto parse_sublevel_block_data_node 
		= [&]( xml_node& sublevel_block_data_node, u32 sublevel_index )
	{
		sublevel& the_sublevel 
			= temp_level.sublevel_vec.at(sublevel_index);
		
		string block_data_str = sublevel_block_data_node.text().get();
		
		//cout << ( block_data_str.at(0) == '\n' ) << endl;
		
		// Get rid of the initial "\n".
		block_data_str = block_data_str.substr(1);
		
		stringstream block_data_sstm(block_data_str);
		
		string line;
		
		u32 j = 0; 
		
		while ( getline( block_data_sstm, line, '\n' ) )
		{
			if ( j >= the_sublevel.real_size_2d.y )
			{
				continue;
			}
			
			u32 i = 0;
			
			stringstream line_sstm(line);
			
			string block_type_str;
			
			//// This is a vector for ONE ROW of block_type's.
			//vector<block_type> block_type_row;
			
			while ( getline( line_sstm, block_type_str, ',' ) )
			{
				if ( i >= the_sublevel.real_size_2d.x )
				{
					continue;
				}
				
				stringstream block_type_sstm;
				
				block_type_sstm << block_type_str;
				block_type_sstm >> the_sublevel
					.uncompressed_block_data_vec_2d.at(j).at(i).type;
				
				++i;
			}
			
			++j;
		}
		
		
	};