Pry the map_label.cpp code the rest of the way loose from replay.cpp.

If clearing of old labels during replays stops working, suspect this commit.
This commit is contained in:
Eric S. Raymond 2007-06-28 13:04:22 +00:00
parent 00c2437836
commit 4439a0c763
5 changed files with 14 additions and 30 deletions

View file

@ -2074,10 +2074,9 @@ bool event_handler::handle_event_command(const queued_event& event_info,
terrain_label label(screen->labels(),cfg.get_config());
screen->labels().set_label(label.location(),
label.text(),
0,
label.team_name(),
label.colour());
label.text(),
label.team_name(),
label.colour());
}
LOG_NG << "done handling command...\n";

View file

@ -20,7 +20,6 @@
#include "language.hpp"
#include "map_label.hpp"
#include "wassert.hpp"
#include "replay.hpp"
#include "game_events.hpp"
namespace {
@ -145,10 +144,9 @@ void map_labels::set_team(const team* team)
const terrain_label* map_labels::set_label(const gamemap::location& loc,
const std::string& text,
replay* replay,
const std::string team_name,
const SDL_Color colour)
const std::string& text,
const std::string team_name,
const SDL_Color colour)
{
terrain_label* res = 0;
const team_label_map::const_iterator current_label_map = labels_.find(team_name);
@ -160,12 +158,8 @@ const terrain_label* map_labels::set_label(const gamemap::location& loc,
// Found old checking if need to erase it
if(text.empty())
{
if (replay)
{
const_cast<terrain_label*>(current_label->second)->set_text("");
replay->add_label(current_label->second);
}
const_cast<terrain_label*>(current_label->second)->set_text("");
res = new terrain_label("",team_name,loc,*this,colour);
delete current_label->second;
const_cast<label_map&>(current_label_map->second).erase(loc);
@ -187,10 +181,6 @@ const terrain_label* map_labels::set_label(const gamemap::location& loc,
const_cast<terrain_label*>(current_label->second)->update_info(text,
team_name,
colour);
if (replay)
{
replay->add_label(current_label->second);
}
res = const_cast<terrain_label*>(current_label->second);
}
}
@ -212,10 +202,6 @@ const terrain_label* map_labels::set_label(const gamemap::location& loc,
add_label(loc,label);
res = label;
if (replay)
{
replay->add_label(label);
}
if (update)
{

View file

@ -24,7 +24,6 @@ class config;
class display;
class terrain_label;
class replay;
class game_state;
@ -47,7 +46,6 @@ public:
const terrain_label* get_label(const gamemap::location& loc);
const terrain_label* set_label(const gamemap::location& loc,
const std::string& text,
replay* = 0,
const std::string team = "",
const SDL_Color colour = font::NORMAL_COLOUR);

View file

@ -1399,7 +1399,9 @@ namespace events{
else {
colour = team::get_side_colour(gui_->viewing_team() + 1);
}
gui_->labels().set_label(mousehandler.get_last_hex(), d.textbox_text(), &recorder, team_name, colour);
const terrain_label *res = gui_->labels().set_label(mousehandler.get_last_hex(), d.textbox_text(), team_name, colour);
if (res)
recorder.add_label(res);
}
}

View file

@ -696,10 +696,9 @@ bool do_replay(game_display& disp, const gamemap& map, const game_data& gameinfo
terrain_label label(disp.labels(),*child);
disp.labels().set_label(label.location(),
label.text(),
0,
label.team_name(),
label.colour());
label.text(),
label.team_name(),
label.colour());
} else if((child = cfg->child("clear_labels")) != NULL) {