play_controller::play_controller(const config& level, game_state& state_of_game, const int ticks, const int num_turns, const config& game_config, CVideo& video, bool skip_replay) : controller_base(ticks, game_config, video), observer(), savegame_config(), animation_cache(), prefs_disp_manager_(), tooltips_manager_(), events_manager_(), halo_manager_(), labels_manager_(), help_manager_(&game_config), mouse_handler_(NULL, teams_, units_, map_), menu_handler_(NULL, units_, teams_, level, map_, game_config, state_of_game), soundsources_manager_(), tod_manager_(level, num_turns), pathfind_manager_(), persist_(), gui_(), statistics_context_(level["name"]), level_(level), teams_(), gamestate_(state_of_game), gamedata_(level), map_(game_config, level), units_(), undo_stack_(new actions::undo_list(level.child("undo_stack"))), whiteboard_manager_(), xp_mod_(level["experience_modifier"].to_int(100)), loading_game_(level["playing_team"].empty() == false), first_human_team_(-1), player_number_(1), first_player_(level_["playing_team"].to_int() + 1), start_turn_(tod_manager_.turn()), // tod_manager_ constructed above is_host_(true), skip_replay_(skip_replay), linger_(false), it_is_a_new_turn_(true), init_side_done_(level["init_side_done"].to_bool(true)), savenames_(), wml_commands_(), victory_when_enemies_defeated_(true), remove_from_carryover_on_defeat_(true), end_level_data_(), victory_music_(), defeat_music_(), scope_() { resources::controller = this; resources::gamedata = &gamedata_; resources::game_map = &map_; resources::persist = &persist_; resources::state_of_game = &gamestate_; resources::teams = &teams_; resources::tod_manager = &tod_manager_; resources::undo_stack = undo_stack_.get(); resources::units = &units_; persist_.start_transaction(); // Setup victory and defeat music set_victory_music_list(level_["victory_music"]); set_defeat_music_list(level_["defeat_music"]); game_config::add_color_info(level); hotkey::deactivate_all_scopes(); hotkey::set_scope_active(hotkey::SCOPE_GENERAL); hotkey::set_scope_active(hotkey::SCOPE_GAME); try { init(video); } catch (...) { clear_resources(); throw; } }
play_controller::~play_controller() { clear_resources(); }
play_controller::play_controller(const config& level, saved_game& state_of_game, const config& game_config, const ter_data_cache& tdata, CVideo& video, bool skip_replay) : controller_base(game_config, video) , observer() , quit_confirmation() , ticks_(SDL_GetTicks()) , tdata_(tdata) , gamestate_() , level_() , saved_game_(state_of_game) , tooltips_manager_() , whiteboard_manager_() , plugins_context_() , labels_manager_() , help_manager_(&game_config) , mouse_handler_(nullptr, *this) , menu_handler_(nullptr, *this, game_config) , hotkey_handler_(new hotkey_handler(*this, saved_game_)) , soundsources_manager_() , persist_() , gui_() , xp_mod_(new unit_experience_accelerator(level["experience_modifier"].to_int(100))) , statistics_context_(new statistics::scenario_context(level["name"])) , replay_(new replay(state_of_game.get_replay())) , skip_replay_(skip_replay) , linger_(false) , init_side_done_now_(false) , victory_when_enemies_defeated_(level["victory_when_enemies_defeated"].to_bool(true)) , remove_from_carryover_on_defeat_(level["remove_from_carryover_on_defeat"].to_bool(true)) , victory_music_() , defeat_music_() , scope_() , ignore_replay_errors_(false) , player_type_changed_(false) { copy_persistent(level, level_); resources::controller = this; resources::persist = &persist_; resources::recorder = replay_.get(); resources::classification = &saved_game_.classification(); resources::mp_settings = &saved_game_.mp_settings(); persist_.start_transaction(); // Setup victory and defeat music set_victory_music_list(level_["victory_music"]); set_defeat_music_list(level_["defeat_music"]); game_config::add_color_info(level); hotkey::deactivate_all_scopes(); hotkey::set_scope_active(hotkey::SCOPE_GAME); try { init(video, level); } catch (...) { clear_resources(); throw; } }
play_controller::~play_controller() { hotkey::delete_all_wml_hotkeys(); clear_resources(); }
static void twi_slave_rx( U8 u8_value ) { switch( s_status_cmd ) { case TWI_MEM_IDLE: s_u8_addr_pos = EEPROM_ADDR_LGT; // Init before receiving the target address. s_u32_addr = 0; // No break to continue on next case case TWI_MEM_ADDR: s_u8_addr_pos--; // Receiving the Nth Byte that makes the address (MSB first). s_u32_addr += ((U32)u8_value << (s_u8_addr_pos*8)); if( 0 == s_u8_addr_pos ) { // the address is completely received => switch to data mode. s_status_cmd = TWI_MEM_DATA; }else{ s_status_cmd = TWI_MEM_ADDR; } break; case TWI_MEM_DATA: // We are receiving data // Check that we're still in the range of the virtual mem if( TWI_MEM_SIZE > (s_u32_addr-VIRTUALMEM_ADDR_START) ) { s_memory[s_u32_addr-VIRTUALMEM_ADDR_START] = u8_value; // Do something if the Pi writes to the PI EVENT register if ((s_u32_addr-VIRTUALMEM_ADDR_START)==PI_EVENT_REG) { if (s_memory[PI_EVENT_REG]) { ioport_set_pin_level(I2C_FLAG,false); switch (s_memory[PI_EVENT_REG]) { case PI_NEW_PIECE_CONFIRM: if (s_memory[PIECE_TYPE_REG]/PIECE_TYPE_TBC == 1) { confirmNewPiece(); } s_memory[PI_EVENT_REG] = 0; break; case PI_NEW_PIECE_REJECT: rejectNewPiece(); s_memory[PI_EVENT_REG] = 0; break; case PI_RESOURCE_READ: clear_resources(); break; } //s_memory[PI_EVENT_REG] = 0; } } } s_u32_addr++; // Update to next position break; } }