diff --git a/src/actions.cpp b/src/actions.cpp index 6a1fd04f877..42f131fea39 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -796,9 +796,12 @@ size_t move_unit(display* disp, const gamemap& map, std::vector::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; diff --git a/src/game.cpp b/src/game.cpp index bd8cca131eb..c9725ee5df5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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); diff --git a/src/pathfind.cpp b/src/pathfind.cpp index b262ec8582c..912da3a429f 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -135,6 +135,8 @@ void find_routes(const gamemap& map, const game_data& gamedata, std::vector& teams, bool ignore_zocs, bool allow_teleport) { + team& current_team = teams[u.side()-1]; + //find adjacent tiles std::vector 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::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::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); diff --git a/src/playlevel.cpp b/src/playlevel.cpp index f2137d9446f..9dcd2ade57d 100644 --- a/src/playlevel.cpp +++ b/src/playlevel.cpp @@ -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(;;) diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index c059bba0c11..1504fe01fa9 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -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;