/** * Clears shroud (and fog) at the provided location and its immediate neighbors. * This is an aid for the [teleport] action, allowing the destination to be * cleared before teleporting, while the unit's full visual range gets cleared * after. * The @a viewer is needed for correct firing of sighted events. * * @return whether or not information was uncovered (i.e. returns true if the * locations in question were fogged/shrouded under shared vision/maps). */ bool shroud_clearer::clear_dest(const map_location &dest, const unit &viewer) { team & viewing_team = resources::gameboard->get_team(viewer.side()); // A pair of dummy variables needed to simplify some logic. std::size_t enemies, friends; // Abort if there is nothing to clear. if ( !viewing_team.fog_or_shroud() ) return false; // Cache some values. const map_location & real_loc = viewer.get_location(); const std::size_t viewer_id = viewer.underlying_id(); // Clear the destination. bool cleared_something = clear_loc(viewing_team, dest, dest, real_loc, viewer_id, true, enemies, friends); // Clear the adjacent hexes (will be seen even if vision is 0, and the // graphics do not work so well for an isolated cleared hex). adjacent_loc_array_t adjacent; get_adjacent_tiles(dest, adjacent.data()); for (unsigned i = 0; i < adjacent.size(); ++i ) if ( clear_loc(viewing_team, adjacent[i], dest, real_loc, viewer_id, true, enemies, friends) ) cleared_something = true; if ( cleared_something ) invalidate_after_clear(); return cleared_something; }
void game_start(master* m, bmp* bg, char* level_to_read, char* bg_music) { p_shift = 0; first_platform = true; inc = 0; //background drawing clear_loc(pixel_buffer,0,0,319,239,bg); alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)); clear_loc(pixel_buffer,0,0,319,239,bg); alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)); m->ab->wav = init_read_wav(bg_music); //reads wav file into buffer fill_buffer(m->ab); sd_read_level(level_to_read, m->l); object_spawn_init(m); init_char_update(m); //start timer IOWR_16DIRECT(TIMER_0_BASE, 4, 0x5); //start timer //enable audio interrupt alt_up_audio_enable_write_interrupt(m->ab->audio_dev); //enable character interrupt IOWR_16DIRECT(TIMER_2_BASE, 4, 0x5); //enable object spawning interrupt IOWR_16DIRECT(TIMER_1_BASE, 4, 0x5); }
/** * Clears shroud (and fog) around the provided location for @a view_team * based on @a sight_range, @a costs, and @a slowed. * This will also record sighted events, which should be either fired or * explicitly dropped. (The sighter is the unit with underlying id @a viewer_id.) * * This should only be called if delayed shroud updates is off. * It is wasteful to call this if view_team uses neither fog nor shroud. * * @param real_loc The actual location of the viewing unit. * (This is used to avoid having a unit sight itself.) * @param known_units These locations are not checked for uncovered units. * @param enemy_count Incremented for each enemy uncovered (excluding known_units). * @param friend_count Incremented for each friend uncovered (excluding known_units). * @param spectator Will be told of uncovered units (excluding known_units). * @param instant If false, then drawing delays (used to make movement look better) are allowed. * * @return whether or not information was uncovered (i.e. returns true if any * locations in visual range were fogged/shrouded under shared vision/maps). */ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team, std::size_t viewer_id, int sight_range, bool slowed, const movetype::terrain_costs & costs, const map_location & real_loc, const std::set<map_location>* known_units, std::size_t * enemy_count, std::size_t * friend_count, move_unit_spectator * spectator, bool instant) { // Give animations a chance to progress; see bug #20324. if ( !instant && display::get_singleton() ) display::get_singleton()->draw(true); bool cleared_something = false; // Dummy variables to make some logic simpler. std::size_t enemies=0, friends=0; if ( enemy_count == nullptr ) enemy_count = &enemies; if ( friend_count == nullptr ) friend_count = &friends; // Make sure the jamming map is up-to-date. if ( view_team_ != &view_team ) { calculate_jamming(&view_team); // Give animations a chance to progress; see bug #20324. if ( !instant && display::get_singleton() ) display::get_singleton()->draw(true); } // Determine the hexes to clear. pathfind::vision_path sight(costs, slowed, sight_range, view_loc, jamming_); // Give animations a chance to progress; see bug #20324. if ( !instant && display::get_singleton() ) display::get_singleton()->draw(true); // Clear the fog. for (const pathfind::paths::step &dest : sight.destinations) { bool known = known_units && known_units->count(dest.curr) != 0; if ( clear_loc(view_team, dest.curr, view_loc, real_loc, viewer_id, !known, *enemy_count, *friend_count, spectator) ) cleared_something = true; } //TODO guard with game_config option for (const map_location &dest : sight.edges) { bool known = known_units && known_units->count(dest) != 0; if ( clear_loc(view_team, dest, view_loc, real_loc, viewer_id, !known, *enemy_count, *friend_count, spectator) ) cleared_something = true; } return cleared_something; }