Fixed some of miyo's bugs

This commit is contained in:
Dave White 2003-09-24 10:10:13 +00:00
parent 62b4528345
commit 0736d9a9b1
5 changed files with 23 additions and 8 deletions

View File

@ -796,9 +796,12 @@ size_t move_unit(display* disp, const gamemap& map,
std::vector<gamemap::location>::const_iterator step;
for(step = route.begin()+1; step != route.end(); ++step) {
const gamemap::TERRAIN terrain = map[step->x][step->y];
const unit_map::const_iterator enemy_unit = units.find(*step);
const int mv = u.type().movement_type().movement_cost(map,terrain);
if(mv > moves_left) {
if(mv > moves_left || enemy_unit != units.end() &&
teams[team_num].is_enemy(enemy_unit->second.side())) {
break;
} else {
moves_left -= mv;

View File

@ -292,6 +292,11 @@ int play_game(int argc, char** argv)
gui::show_dialog(disp,NULL,"",
string_table["bad_save_message"],gui::OK_ONLY);
continue;
} catch(config::error& e) {
gui::show_dialog(disp,NULL,"",
string_table["bad_save_message"] + ": " + e.message + "\n",
gui::OK_ONLY);
continue;
}
recorder = replay(state.replay_data);

View File

@ -135,6 +135,8 @@ void find_routes(const gamemap& map, const game_data& gamedata,
std::vector<team>& teams,
bool ignore_zocs, bool allow_teleport)
{
team& current_team = teams[u.side()-1];
//find adjacent tiles
std::vector<gamemap::location> locs(6);
get_adjacent_tiles(loc,&locs[0]);
@ -147,7 +149,7 @@ void find_routes(const gamemap& map, const game_data& gamedata,
//teleport to
for(std::vector<gamemap::location>::const_iterator t = towers.begin();
t != towers.end(); ++t) {
if(!teams[u.side()-1].owns_tower(*t))
if(!current_team.owns_tower(*t))
continue;
locs.push_back(*t);
@ -166,7 +168,8 @@ void find_routes(const gamemap& map, const game_data& gamedata,
//see if the tile is on top of an enemy unit
const std::map<gamemap::location,unit>::const_iterator unit_it =
units.find(locs[i]);
if(unit_it != units.end() && unit_it->second.side() != u.side())
if(unit_it != units.end() &&
current_team.is_enemy(unit_it->second.side()))
continue;
//find the terrain of the adjacent location
@ -184,7 +187,7 @@ void find_routes(const gamemap& map, const game_data& gamedata,
continue;
const bool zoc = enemy_zoc(map,units,currentloc,
teams[u.side()-1],u.side()) &&
current_team,u.side()) &&
!ignore_zocs;
paths::route new_route = routes[loc];
new_route.steps.push_back(loc);
@ -250,6 +253,10 @@ double shortest_path_calculator::cost(const gamemap::location& loc,
if(!map_.on_board(loc))
return 100000.0;
const unit_map::const_iterator enemy_unit = units_.find(loc);
if(enemy_unit != units_.end() && team_.is_enemy(enemy_unit->second.side()))
return 100000.0;
if(unit_.type().is_skirmisher() == false) {
gamemap::location adj[6];
get_adjacent_tiles(loc,adj);

View File

@ -286,7 +286,7 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config,
catch(replay::error& e) {
gui::show_dialog(gui,NULL,"","The file you loaded is corrupt "
"or from a different version of the game",gui::OK_ONLY);
return DEFEAT;
return QUIT;
}
} //end for(;;)

View File

@ -56,8 +56,8 @@ button::button(display& disp, const std::string& label, button::TYPE type,
textRect_.x = 0;
textRect_.y = 0;
textRect_.w = 1024;
textRect_.h = 768;
textRect_.w = disp.x();
textRect_.h = disp.y();
textRect_ = font::draw_text(NULL,textRect_,font_size,
font::NORMAL_COLOUR,label_,0,0);
@ -145,7 +145,7 @@ void button::draw()
default: break;
}
const SDL_Rect clipArea = {0,0,1024,768};
const SDL_Rect clipArea = {0,0,display_->x(),display_->y()};
const int textx = x_ + image->w/2 - textRect_.w/2 + offset;
const int texty = y_ + image->h/2 - textRect_.h/2 + offset;