fixed Wesbowl scenario bugs

This commit is contained in:
Dave White 2004-05-10 21:53:01 +00:00
parent c08d413157
commit 69079e0291
6 changed files with 57 additions and 15 deletions

View file

@ -4,6 +4,12 @@
turns=20
id=multiplayer1
objectives="
Victory:
@Move either ball to your opponent's endzone more times than they move their ball to yours
Defeat:
#Opponent moves the balls to your endzone more times than you move them to theirs"
{DAWN}
{MORNING}
{AFTERNOON}

View file

@ -1596,6 +1596,10 @@ size_t move_unit(display* disp, const game_data& gamedata,
}
}
if(move_recorder != NULL) {
move_recorder->add_movement(steps.front(),steps.back());
}
const bool event_mutated = game_events::fire("moveto",steps.back());
if(undo_stack != NULL) {
@ -1607,9 +1611,6 @@ size_t move_unit(display* disp, const game_data& gamedata,
}
}
if(move_recorder != NULL)
move_recorder->add_movement(steps.front(),steps.back());
if(disp != NULL) {
disp->set_route(NULL);

View file

@ -1256,6 +1256,16 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
SDL_FillRect(dst,&filled_xp_area,xp_colour);
}
}
const std::vector<std::string>& overlays = it->second.overlays();
for(std::vector<std::string>::const_iterator ov = overlays.begin(); ov != overlays.end(); ++ov) {
const scoped_sdl_surface img(image::get_image(*ov));
std::cerr << "drawing overlay: '" << *ov << "'\n";
if(img.get() != NULL) {
std::cerr << "AA\n";
draw_unit(xpos,ypos,img);
}
}
}
void display::draw_tile_adjacent(int x, int y, image::TYPE image_type, ADJACENT_TERRAIN_TYPE type)
@ -1419,16 +1429,6 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
}
}
const std::vector<std::string>& overlays = un->second.overlays();
for(std::vector<std::string>::const_iterator ov = overlays.begin(); ov != overlays.end(); ++ov) {
const scoped_sdl_surface img(image::get_image(*ov));
std::cerr << "drawing overlay: '" << *ov << "'\n";
if(img.get() != NULL) {
std::cerr << "AA\n";
draw_unit(xpos,ypos,img);
}
}
if(grid_) {
scoped_sdl_surface grid_surface(image::get_image("terrain/grid.png"));
if(grid_surface != NULL) {

View file

@ -862,7 +862,7 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
//if we're not replaying, or if we are replaying and there is no choice
//to be made, show the dialog.
if(recorder.at_end() || options.empty()) {
if(get_replay_source().at_end() || options.empty()) {
const std::string msg = config::interpolate_variables_into_string(lang_message.empty() ? cfg["message"] : lang_message);
option_chosen = gui::show_dialog(*screen,surface,caption,msg,
options.empty() ? gui::MESSAGE : gui::OK_ONLY,
@ -879,7 +879,7 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
//otherwise if a choice has to be made, get it from the replay data
else {
const config* const action = recorder.get_next_action();
const config* const action = get_replay_source().get_next_action();
if(action == NULL || action->get_children("choose").empty()) {
std::cerr << "choice expected but none found\n";
throw replay::error();

View file

@ -522,12 +522,45 @@ void replay::add_config(const config& cfg, MARK_SENT mark)
}
}
namespace {
replay* replay_src = NULL;
struct replay_source_manager
{
replay_source_manager(replay* o) : old_(replay_src)
{
replay_src = o;
}
~replay_source_manager()
{
replay_src = old_;
}
private:
replay* const old_;
};
}
replay& get_replay_source()
{
if(replay_src != NULL) {
return *replay_src;
} else {
return recorder;
}
}
bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
unit_map& units,
std::vector<team>& teams, int team_num, const gamestatus& state,
game_state& state_of_game, replay* obj)
{
log_scope("do replay");
const replay_source_manager replay_manager(obj);
replay& replayer = (obj != NULL) ? *obj : recorder;
clear_shroud(disp,state,map,gameinfo,units,teams,team_num-1);

View file

@ -111,6 +111,8 @@ private:
int skip_;
};
replay& get_replay_source();
extern replay recorder;
//replays up to one turn from the recorder object