Merge branch 'cppcheck'

This commit is contained in:
Mark de Wever 2013-07-07 18:56:07 +02:00
commit 7e82ad53ea
8 changed files with 31 additions and 28 deletions

View file

@ -169,19 +169,13 @@ void arrow::update_symbols()
std::string const mods = "~RC(FF00FF>"+ color_ + ")"; //magenta to current color
std::string const dirname = "arrows/";
map_location::DIRECTION exit_dir = map_location::NDIRECTIONS;
map_location::DIRECTION enter_dir = map_location::NDIRECTIONS;
std::string prefix = "";
std::string suffix = "";
std::string image_filename = "";
arrow_path_t::const_iterator const arrow_start_hex = path_.begin();
arrow_path_t::const_iterator const arrow_pre_end_hex = path_.end() - 2;
arrow_path_t::const_iterator const arrow_end_hex = path_.end() - 1;
bool start = false;
bool pre_end = false;
bool end = false;
bool teleport_out = false;
bool teleport_in = false;
arrow_path_t::iterator hex;
for (hex = path_.begin(); hex != path_.end(); ++hex)
@ -189,10 +183,12 @@ void arrow::update_symbols()
prefix = "";
suffix = "";
image_filename = "";
start = pre_end = end = false;
bool start = false;
bool pre_end = false;
bool end = false;
// teleport in if we teleported out last hex
teleport_in = teleport_out;
bool teleport_in = teleport_out;
teleport_out = false;
// Determine some special cases
@ -206,12 +202,12 @@ void arrow::update_symbols()
teleport_out = true;
// calculate enter and exit directions, if available
enter_dir = map_location::NDIRECTIONS;
map_location::DIRECTION enter_dir = map_location::NDIRECTIONS;
if (!start && !teleport_in)
{
enter_dir = hex->get_relative_dir(*(hex-1));
}
exit_dir = map_location::NDIRECTIONS;
map_location::DIRECTION exit_dir = map_location::NDIRECTIONS;
if (!end && !teleport_out)
{
exit_dir = hex->get_relative_dir(*(hex+1));

View file

@ -425,7 +425,7 @@ void dialog::refresh()
dialog::dimension_measurements dialog::layout(int xloc, int yloc)
{
CVideo& screen = disp_.video();
surface const scr = screen.getSurface();
const surface& scr = screen.getSurface();
dimension_measurements dim;
dim.x = xloc;

View file

@ -1413,7 +1413,7 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
void display::draw_all_panels()
{
surface const screen(screen_.getSurface());
const surface& screen(screen_.getSurface());
const std::vector<theme::panel>& panels = theme_.panels();
for(std::vector<theme::panel>::const_iterator p = panels.begin(); p != panels.end(); ++p) {
@ -1793,7 +1793,7 @@ void display::draw_minimap()
}
}
const surface screen(screen_.getSurface());
const surface& screen(screen_.getSurface());
clip_rect_setter clip_setter(screen, &area);
SDL_Color back_color = {31,31,23,255};

View file

@ -184,7 +184,7 @@ void context_manager::new_map_dialog()
int w = get_map().w();
int h = get_map().h();
if(gui2::teditor_new_map::execute(w, h, gui_.video())) {
const t_translation::t_terrain fill = get_selected_bg_terrain();
const t_translation::t_terrain& fill = get_selected_bg_terrain();
new_map(w, h, fill, true);
}
}

View file

@ -1334,7 +1334,7 @@ std::string show_wesnothd_server_search(display& disp)
}
else
{
old_path = "";
old_path.clear();
}
#ifndef _WIN32

View file

@ -91,15 +91,6 @@ public:
msg_label->set_label("");
}
std::string escape(const std::string &str)
{
// need pango escape here
std::string result = utils::replace(str, "&", "&amp;");
result = utils::replace(result, "<", "&lt;");
result = utils::replace(result, ">", "&gt;");
return result;
}
int count_of_pages()
{
int size = chat_log_history.size();
@ -126,9 +117,25 @@ public:
std::string nick_prefix = "<span color=\""+color+"\">";
std::string nick_suffix ="</span> ";
if (me) {
str << nick_prefix << "&lt;" << escape(preferences::get_chat_timestamp(t.time())) << escape(t.nick()) << escape(t.text().substr(3))<<"&gt;" <<nick_suffix << std::endl;
str << nick_prefix
<< "&lt;"
<< font::escape_text(
preferences::get_chat_timestamp(t.time()))
<< font::escape_text(t.nick())
<< font::escape_text(t.text().substr(3))
<<"&gt;"
<<nick_suffix
<< std::endl;
} else {
str << nick_prefix << "&lt;" << escape(preferences::get_chat_timestamp(t.time())) << escape(t.nick()) << "&gt;"<< nick_suffix << escape(t.text()) << std::endl;
str << nick_prefix
<< "&lt;"
<< font::escape_text(
preferences::get_chat_timestamp(t.time()))
<< font::escape_text(t.nick())
<< "&gt;"
<< nick_suffix
<< font::escape_text(t.text())
<< std::endl;
}
}
}

View file

@ -3226,7 +3226,7 @@ void show_help(display &disp, const section &toplevel_sec,
const resize_lock prevent_resizing;
CVideo& screen = disp.video();
surface const scr = screen.getSurface();
const surface& scr = screen.getSurface();
const int width = std::min<int>(font::relative_size(900), scr->w - font::relative_size(20));
const int height = std::min<int>(font::relative_size(800), scr->h - font::relative_size(150));

View file

@ -231,7 +231,7 @@ static void do_resolve_rects(const config& cfg, config& resolved_config, config*
ERR_DP << "Use of ref= outside a [resolution] block\n";
} else {
//DBG_DP << ">> Looking for " << cfg["ref"] << "\n";
const config ref = find_ref (cfg["ref"], *resol_cfg);
const config& ref = find_ref (cfg["ref"], *resol_cfg);
if (ref["id"].empty()) {
ERR_DP << "Reference to non-existent rect id \"" << cfg["ref"] << "\"\n";