Remove trailing whitespace.

This commit is contained in:
Mark de Wever 2009-01-01 10:28:26 +00:00
parent a5d1d2e969
commit 973a0a7d5c
250 changed files with 2209 additions and 2209 deletions

View file

@ -247,7 +247,7 @@ void show_about(display &disp, std::string campaign)
CKey key;
bool last_escape;
surface textbox = create_compatible_surface(video.getSurface(), middle_dest.w, middle_dest.h);
SDL_SetAlpha(textbox, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);
bool recalculate_textbox = true;
@ -324,7 +324,7 @@ void show_about(display &disp, std::string campaign)
if (key[SDLK_DOWN] && scroll_speed > 0) {
--scroll_speed;
}
events::pump();
events::raise_process_event();
events::raise_draw_event();

View file

@ -80,7 +80,7 @@ bool remove_local_addon(const std::string& addon, std::string* log)
messages << "Failed to delete directory/file: " << addon_dir << ".cfg\n";
ret = false;
}
if(log != NULL) {
*log = messages.str();
}
@ -338,7 +338,7 @@ namespace {
}
}
}
/**
* Creates a more human-readable representation of a file size.
*
@ -350,7 +350,7 @@ namespace {
static std::string format_file_size(const std::string& size_str)
{
double size = lexical_cast_default<double>(size_str,0.0);
const double k = 1024;
if(size > 0.0) {
std::string size_postfix = _("B"); // bytes
@ -366,7 +366,7 @@ namespace {
}
}
}
std::ostringstream stream;
#ifdef _MSC_VER
// Visual C++ makes 'precision' set the number of decimal places.
@ -383,7 +383,7 @@ namespace {
return "";
}
}
/**
* Return a short string describing an add-on's type.
*
@ -414,7 +414,7 @@ namespace {
return _("addon_type^(unknown)");
}
}
/**
* Checks if an add-on's dependencies are met.
*
@ -429,7 +429,7 @@ namespace {
std::vector<std::string>::const_iterator i;
std::string missing = "";
size_t count_missing = 0;
foreach(const std::string& i, deplist) {
if (std::find(installed.begin(), installed.end(), i) == installed.end()) {
missing += "\n" + i;
@ -452,7 +452,7 @@ namespace {
}
return true;
}
void upload_addon_to_server(game_display& disp, const std::string& addon, network::connection sock)
{
config request_terms;
@ -478,10 +478,10 @@ namespace {
return;
}
}
config cfg;
get_addon_info(addon,cfg);
std::string passphrase = cfg["passphrase"];
// generate a random passphrase and write it to disk
// if the .pbl file doesn't provide one already
@ -493,19 +493,19 @@ namespace {
cfg["passphrase"] = passphrase;
set_addon_info(addon,cfg);
}
cfg["name"] = addon;
config addon_data;
archive_addon(addon,addon_data);
data.clear();
data.add_child("upload",cfg).add_child("data",addon_data);
LOG_NET << "uploading add-on...\n";
// @todo Should be enabled once the campaign server can be recompiled.
network::send_data(data, sock, true);
sock = dialogs::network_send_dialog(disp,_("Sending add-on"),data,sock);
if(!sock) {
return;
@ -518,21 +518,21 @@ namespace {
dlg.show();
}
}
void delete_remote_addon(game_display& disp, const std::string& addon, network::connection sock)
{
config cfg;
get_addon_info(addon,cfg);
config msg;
msg["name"] = addon;
msg["passphrase"] = cfg["passphrase"];
config data;
data.add_child("delete",msg);
network::send_data(data, sock, true);
sock = network::receive_data(data,sock,5000);
if(!sock) {
gui::show_error_message(disp, _("Connection timed out"));
@ -545,7 +545,7 @@ namespace {
dlg.show();
}
}
bool install_addon(game_display& disp, config& cfg, const config* const addons_tree,
const std::string& addon_id, const std::string& addon_title,
const std::string& addon_type_str, const std::string& addon_uploads_str,
@ -586,7 +586,7 @@ namespace {
gui::show_error_message(disp, _("The add-on has an invalid file or directory name and can not be installed."));
return false;
}
// add revision info to the addon archive
config* maindir = cfg.find_child("dir", "name", addon_id);
if(maindir == NULL) {
@ -598,7 +598,7 @@ namespace {
LOG_CFG << "generating version info for addon '" << addon_id << "'\n";
config f;
f["name"] = "_info.cfg";
utils::string_map info_tab;
info_tab["type"] = addon_type_str.empty() ? addon_type_str : std::string("unknown");
info_tab["uploads"] = addon_uploads_str;
@ -652,7 +652,7 @@ namespace {
*do_refresh = true;
return true;
}
void addons_update_dlg(game_display& disp, config& cfg, const config::child_list& remote_addons_list,
const network::manager& net_manager, const network::connection& sock,
bool* do_refresh)
@ -711,20 +711,20 @@ namespace {
gui::dialog dlg(disp, warn_title, warn_entrytxt + unsafe_list.str(), gui::MESSAGE);
dlg.show();
}
if(safe_matches.empty()) {
gui::dialog dlg(disp, _("No add-ons to update"), _("Could not find any updated add-ons on this server."),
gui::MESSAGE);
dlg.show();
return;
}
// column contents
std::vector<std::string> addons, titles, oldversions, newversions, options, filtered_opts;
std::vector<int> sizes;
std::vector<std::string> types, uploads;
std::string sep(1, COLUMN_SEPARATOR);
const std::string& heading =
(formatter() << HEADING_PREFIX << sep << _("Name") << sep << _("Old version") << sep << _("New version") << sep
@ -745,7 +745,7 @@ namespace {
const std::string& sizef = format_file_size(size);
const std::string& oldver = safe_local_versions[i];
const std::string& newver = remote_version_map[name];
std::string author = c["author"];
std::string title = c["title"];
if(title.empty()) {
@ -755,7 +755,7 @@ namespace {
utils::truncate_as_wstring(title, 20);
utils::truncate_as_wstring(author, 16);
//add negative sizes to reverse the sort order
sizes.push_back(-atoi(size.c_str()));
@ -844,7 +844,7 @@ namespace {
failed_titles.push_back(titles[i]);
}
}
if(!result) {
assert(failed_titles.empty() == false);
std::string failed_titles_list_fmt;
@ -862,7 +862,7 @@ namespace {
err_dlg.show();
return;
}
const std::string msg_title = _("Update succeeded");
const std::string msg_message = !upd_all ? _("Add-on updated successfully.") :
_("All add-ons updated successfully.");
@ -878,13 +878,13 @@ namespace {
if(address_components.empty()) {
return;
}
const std::string old_host = preferences::campaign_server();
const int remote_port = lexical_cast_default<int>(address_components.back(),
DEFAULT_CAMPAIGND_PORT);
remote_host = address_components.front();
preferences::set_campaign_server(remote_host);
try {
const network::manager net_manager;
const network::connection sock =
@ -895,7 +895,7 @@ namespace {
preferences::set_campaign_server(old_host);
return;
}
config cfg;
cfg.add_child("request_campaign_list");
network::send_data(cfg, sock, true);
@ -909,19 +909,19 @@ namespace {
gui::show_error_message(disp, (*error)["message"]);
return;
}
config const * const addons_tree = cfg.child("campaigns");
if(addons_tree == NULL) {
gui::show_error_message(disp, _("An error occurred while communicating with the server."));
return;
}
const config::child_list& addon_cfgs = addons_tree->get_children("campaign");
if(update_mode) {
addons_update_dlg(disp, cfg, addon_cfgs, net_manager, sock, do_refresh);
return;
}
// column contents
std::vector<std::string> addons, titles, versions, uploads, types, options, options_to_filter;
std::vector<int> sizes;
@ -936,7 +936,7 @@ namespace {
const std::vector< std::string >& publish_options = available_addons();
std::vector< std::string > delete_options;
foreach(const config* i, addon_cfgs) {
const config& c = *i;
@ -952,27 +952,27 @@ namespace {
versions.push_back(c["version"]);
uploads.push_back(c["uploads"]);
types.push_back(type_str);
if(std::count(publish_options.begin(), publish_options.end(), name) != 0) {
delete_options.push_back(name);
}
std::string title = c["title"];
if(title == "") {
title = name;
std::replace(title.begin(),title.end(),'_',' ');
}
titles.push_back(title);
std::string version = c["version"], author = c["author"];
utils::truncate_as_wstring(title, 20);
utils::truncate_as_wstring(version, 12);
utils::truncate_as_wstring(author, 16);
//add negative sizes to reverse the sort order
sizes.push_back(-atoi(size.c_str()));
std::string icon = c["icon"];
if(icon.find("units/") != std::string::npos &&
icon.find_first_of('~') == std::string::npos) {
@ -991,7 +991,7 @@ namespace {
// icon paths shouldn't be filtered!
options_to_filter.push_back(text_columns);
}
std::string pub_option_text, del_option_text;
foreach(const std::string& pub, publish_options) {
@ -1011,7 +1011,7 @@ namespace {
gui::show_error_message(disp, _("There are no add-ons available for download from this server."));
return;
}
gui::menu::basic_sorter sorter;
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_alpha_sort(4).set_numeric_sort(5).set_position_sort(6,sizes);
@ -1019,7 +1019,7 @@ namespace {
_("Choose the add-on to download."),
gui::OK_CANCEL);
gui::menu::imgsel_style addon_style(gui::menu::bluebg_style);
//make sure the icon isn't too big
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
gui::menu *addon_menu = new gui::menu(disp.video(), options, false, -1,
@ -1037,21 +1037,21 @@ namespace {
if(index < 0) {
return;
}
// Handle deletion option
if(index >= int(addons.size() + publish_options.size())) {
const std::string& addon = delete_options[index - int(addons.size() + publish_options.size())];
delete_remote_addon(disp, addon, sock);
return;
}
// Handle publish option
if(index >= int(addons.size())) {
const std::string& addon = publish_options[index - int(addons.size())];
upload_addon_to_server(disp, addon, sock);
return;
}
// Handle download
install_addon(disp, cfg, addons_tree, addons[index], titles[index], types[index],
uploads[index], versions[index], net_manager, sock, do_refresh);
@ -1069,7 +1069,7 @@ namespace {
e.show(disp);
}
}
void uninstall_local_addons(game_display& disp, bool* should_reload_cfg)
{
std::vector<std::string> addons;
@ -1082,7 +1082,7 @@ namespace {
if (addons.empty()) {
/** @todo should use a dialog which always shows the close button. */
gui2::show_message(disp.video(), _("Error"),
gui2::show_message(disp.video(), _("Error"),
_("You have no add-ons installed."));
return;
}
@ -1160,7 +1160,7 @@ void manage_addons(game_display& disp)
bool do_refresh = false;
std::string remote_host;
const std::string default_host = preferences::campaign_server();
gui2::taddon_connect addon_dlg;
addon_dlg.set_host_name(default_host);

View file

@ -59,7 +59,7 @@ void archive_addon(const std::string& addon_name, class config& cfg);
/** Unarchives an add-on from campaignd's retrieved config object. */
void unarchive_addon(const class config& cfg);
/**
/**
* Shows the game add-ons manager dialog.
*
* @param disp game_display instance to draw on.

View file

@ -372,10 +372,10 @@ bool ai::recruit_usage(const std::string& usage)
//FIXME: This message should be suppressed when WML author
//chooses the default recruitment pattern.
const std::string warning = "At difficulty level " +
state_.sog().difficulty + ", trying to recruit a:" +
state_.sog().difficulty + ", trying to recruit a:" +
usage + " but no unit of that type (usage=) is"
" available. Check the recruit and [ai]"
" recruitment_pattern keys for team '" +
" recruitment_pattern keys for team '" +
current_team().name() + "' (" +
lexical_cast<std::string>(info_.team_num) + ")"
" against the usage key of the"
@ -1543,7 +1543,7 @@ bool ai::move_to_targets(std::map<map_location, paths>& possible_moves,
targets = find_targets(leader,enemy_dstsrc);
targets.insert(targets.end(),additional_targets_.begin(),
additional_targets_.end());
LOG_AI << "Found " << targets.size() << " targets\n";
LOG_AI << "Found " << targets.size() << " targets\n";
if(targets.empty()) {
return false;
}

View file

@ -137,7 +137,7 @@ protected:
public:
struct attack_analysis : public game_logic::formula_callable
{
attack_analysis() :
attack_analysis() :
game_logic::formula_callable(),
target(),
movements(),
@ -258,7 +258,7 @@ protected:
/**
* Function to form a group of units suitable for moving along the route, 'route'.
*
*
* @Returns The location which the group may reach this
* turn. Stores the locations of the units in
* the group in 'units'.
@ -378,7 +378,7 @@ private:
const std::multimap<map_location,map_location>& dstsrc,
const std::map<map_location,paths>& possible_moves,
const std::multimap<map_location,map_location>& enemy_dstsrc) const;
int recruiting_preferred_;
static const int min_recruiting_value_to_force_recruit = 28;
protected:
@ -386,7 +386,7 @@ protected:
};
class ai_manager {
public:
public:
static boost::intrusive_ptr<ai_interface> get_ai( std::string, ai_interface::info& );
static int reap_ais() ;

View file

@ -221,7 +221,7 @@ void ai::do_attack_analysis(
}
// Find out how vulnerable we are to attack from enemy units in this hex.
//FIXME: suokko's r29531 multiplied this by a constant 1.5. ?
//FIXME: suokko's r29531 multiplied this by a constant 1.5. ?
const double vulnerability = power_projection(tiles[j],enemy_dstsrc);
// Calculate how much support we have on this hex from allies.
@ -235,7 +235,7 @@ void ai::do_attack_analysis(
//FIXME: this code was in sukko's r29531 Correct?
// scale vulnerability to 60 hp unit
if(cur_position >= 0 && rating < best_rating
&& (vulnerability/surround_bonus*30.0)/unit_itor->second.hitpoints() -
&& (vulnerability/surround_bonus*30.0)/unit_itor->second.hitpoints() -
(support*surround_bonus*30.0)/unit_itor->second.max_hitpoints()
> best_vulnerability - best_support) {
continue;
@ -747,7 +747,7 @@ double ai::power_projection(const map_location& loc, const move_map& dstsrc, bo
return res / 100000.;
}
/**
/**
* There is no real hope for us: we should try to do some damage to the enemy.
* We can spend some cycles here, since it's rare.
*/

View file

@ -192,7 +192,7 @@ namespace dfool {
// LOG_STREAM(info, ai)<<"filter4:"<<std::endl;
filtered_units_.push_back(*i);
}
}
// LOG_STREAM(info, ai)<<"filter:"<<std::endl;
return filtered_units_;

View file

@ -102,7 +102,7 @@ public:
virtual void play_turn() = 0;
/**
* Function called when a a new turn is played
* Function called when a a new turn is played
* Derived persistant AIs should call this function each turn (expect first)
*/
virtual void new_turn() {
@ -190,19 +190,19 @@ protected:
* @param remove_destinations a pointer to a set of possible destinations
* to omit.
*/
void calculate_possible_moves(std::map<location,paths>& possible_moves,
move_map& srcdst, move_map& dstsrc, bool enemy,
bool assume_full_movement=false,
void calculate_possible_moves(std::map<location,paths>& possible_moves,
move_map& srcdst, move_map& dstsrc, bool enemy,
bool assume_full_movement=false,
const std::set<location>* remove_destinations=NULL) const;
/**
* A more fundamental version of calculate_possible_moves which allows the
* use of a speculative unit map.
*/
void calculate_moves(const unit_map& units,
std::map<location,paths>& possible_moves, move_map& srcdst,
void calculate_moves(const unit_map& units,
std::map<location,paths>& possible_moves, move_map& srcdst,
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
const std::set<location>* remove_destinations=NULL,
const std::set<location>* remove_destinations=NULL,
bool see_all=false) const;
/**
@ -216,7 +216,7 @@ protected:
*/
bool recruit(const std::string& unit_name, location loc=location());
/**
/**
* Functions to retrieve the 'info' object.
* Used by derived classes to discover all necessary game information.
*/

View file

@ -840,12 +840,12 @@ void ai::move_leader_to_keep(const move_map& enemy_dstsrc)
if(leader == units_.end() || leader->second.incapacitated()) {
return;
}
// Find where the leader can move
const paths leader_paths(map_, units_, leader->first,
teams_, false, false, current_team());
const map_location& start_pos = nearest_keep(leader->first);
std::map<map_location,paths> possible_moves;
possible_moves.insert(std::pair<map_location,paths>(leader->first,leader_paths));
@ -858,13 +858,13 @@ void ai::move_leader_to_keep(const move_map& enemy_dstsrc)
// Make a map of the possible locations the leader can move to,
// ordered by the distance from the keep.
std::multimap<int,map_location> moves_toward_keep;
// The leader can't move to his keep, try to move to the closest location
// to the keep where there are no enemies in range.
const int current_distance = distance_between(leader->first,start_pos);
for(paths::routes_map::const_iterator i = leader_paths.routes.begin();
i != leader_paths.routes.end(); ++i) {
const int new_distance = distance_between(i->first,start_pos);
if(new_distance < current_distance) {
moves_toward_keep.insert(std::pair<int,map_location>(new_distance,i->first));

View file

@ -2170,8 +2170,8 @@ int python_ai::run_shell()
return cret; //Py_Main(argc, argv);
}
python_ai::python_ai(ai_interface::info& info) :
ai_interface(info),
python_ai::python_ai(ai_interface::info& info) :
ai_interface(info),
exception(QUIT),
src_dst_(),
dst_src_(),

View file

@ -26,8 +26,8 @@
#include <numeric>
#define DBG_AI LOG_STREAM(debug, ai)
#define LOG_AI LOG_STREAM(info, ai)
#define DBG_AI LOG_STREAM(debug, ai)
#define LOG_AI LOG_STREAM(info, ai)
#define WRN_AI LOG_STREAM(warn, ai)
// Basic strategy
@ -39,7 +39,7 @@
// - If 0 ignore village.
// - If 1 capture and remove unit from available list.
// - Else store.
//
//
// 4. Remove units who can't reach a village.
//
// 5. Dispatch single solutions:
@ -51,10 +51,10 @@
// - For villages that can be captured by 1 unit, dispatch that unit.
// - how many villages left?
// - If 1 dispatch a unit.
//
//
// 6. If no units we finish.
//
// At this point we have X villages with Y units left where
// At this point we have X villages with Y units left where
// X > 1 && Y > 1 and every unit can reach at least 2 villages
// and every village can be visited by at least 2 units.
//
@ -65,15 +65,15 @@
// In the following example:
//
// village x1,y1 x2,y2 x3,y3 x4,y4
// unit
// unit
// 1 X X X X
// 2 - X X -
// 3 X - - X
//
// We want to find squares of 2 units who both can reach the same village.
// We want to find squares of 2 units who both can reach the same village.
//
// village x1,y1 x2,y2 x3,y3 x4,y4
// unit
// unit
// ___________
// 1 X| |X X| |X
// _| | | |_
@ -82,17 +82,17 @@
// |_________|
// __ __
// 3 X| - - |X
//
//
// 8. - Find a square where at least 1 unit can visit only 2 villages.
// - Dispatch the units.
// - Could the second unit also visit 2 villages and where the 2 villages
// only visitable by two units?
// - Yes found a perfect solution for them
// - Yes found a perfect solution for them
// - Reduce the village count.
// - Restart ourselves recursively.
// - Finsished.
//
// - No.
// - No.
// - Remove the taken villages from the list.
// - Go to step 5.
//
@ -109,10 +109,10 @@ namespace {
/** debug log level for AI enabled? */
bool debug = false;
typedef std::map<map_location /* unit location */,
typedef std::map<map_location /* unit location */,
std::vector<map_location /* villages we can reach */> > treachmap;
typedef std::vector<std::pair<map_location /* destination */,
typedef std::vector<std::pair<map_location /* destination */,
map_location /* start */ > > tmoves;
}
@ -151,7 +151,7 @@ static void full_dispatch(treachmap& reachmap, tmoves& moves);
static void dump_reachmap(treachmap& reachmap);
bool ai::get_villages(std::map<map_location,paths>& possible_moves,
const move_map& dstsrc, const move_map& enemy_dstsrc,
const move_map& dstsrc, const move_map& enemy_dstsrc,
unit_map::iterator &leader)
{
DBG_AI << "deciding which villages we want...\n";
@ -168,11 +168,11 @@ bool ai::get_villages(std::map<map_location,paths>& possible_moves,
debug = (!lg::debug.dont_log(lg::ai));
// Find our units who can move.
treachmap reachmap;
treachmap reachmap;
for(unit_map::const_iterator u_itor = units_.begin();
u_itor != units_.end(); ++u_itor) {
if(u_itor->second.side() == team_num_
if(u_itor->second.side() == team_num_
&& u_itor->second.movement_left()) {
reachmap.insert(std::make_pair(u_itor->first, std::vector<map_location>()));
}
@ -264,15 +264,15 @@ void ai::find_villages(
{
std::map<location, double> vulnerability;
const bool passive_leader = recruiting_preferred_ ||
const bool passive_leader = recruiting_preferred_ ||
utils::string_bool(current_team().ai_parameters()["passive_leader"]);
size_t min_distance = 100000;
// When a unit is dispatched we need to make sure we don't
// dispatch this unit a second time, so store them here.
std::vector<map_location> dispatched_units;
for(std::multimap<map_location, map_location>::const_iterator
for(std::multimap<map_location, map_location>::const_iterator
j = dstsrc.begin();
j != dstsrc.end(); ++j) {
@ -347,14 +347,14 @@ void ai::find_villages(
}
const unit& un = u->second;
//FIXME: suokko turned this 2:1 to 1.5:1.0.
//FIXME: suokko turned this 2:1 to 1.5:1.0.
//and dropped the second term of the multiplication. Is that better?
const double threat_multipler = (current_loc == leader_loc?2:1) * current_team().caution() * 10;
if(un.hitpoints() < (threat_multipler*threat*2*un.defense_modifier(map_.get_terrain(current_loc)))/100) {
continue;
}
// If the next and previous destination differs from our current destination,
// If the next and previous destination differs from our current destination,
// we're the only one who can reach the village -> dispatch.
std::multimap<map_location, map_location>::const_iterator next = j;
++next; // j + 1 fails
@ -363,8 +363,8 @@ void ai::find_villages(
if(!at_begin) {
--prev;
}
#if 1
if((next == dstsrc.end() || next->first != current_loc)
#if 1
if((next == dstsrc.end() || next->first != current_loc)
&& (at_begin || prev->first != current_loc)) {
DBG_AI << "Dispatched unit at " << j->second << " to village " << j->first << '\n';
@ -374,11 +374,11 @@ void ai::find_villages(
dispatched_units.push_back(j->second);
continue;
}
#endif
#endif
reachmap[j->second].push_back(current_loc);
}
DBG_AI << moves.size() << " units already dispatched, "
DBG_AI << moves.size() << " units already dispatched, "
<< reachmap.size() << " left to evaluate.\n";
}
@ -407,7 +407,7 @@ static void dispatch(treachmap& reachmap, tmoves& moves)
} else {
DBG_AI << "dispatch_unit_simple() couldn't dispatch more units.\n";
}
}
}
if(dispatch_village_simple(reachmap, moves, village_count)) {
dispatched = true;
@ -419,7 +419,7 @@ static void dispatch(treachmap& reachmap, tmoves& moves)
DBG_AI << "dispatch_village_simple() couldn't dispatch more units.\n";
}
}
if(reachmap.size() != 0 && dispatched) {
DBG_AI << reachmap.size() << " unit(s) left restarting simple dispatching.\n";
@ -432,7 +432,7 @@ static void dispatch(treachmap& reachmap, tmoves& moves)
return;
}
DBG_AI << reachmap.size() << " units left for complex dispatch with "
DBG_AI << reachmap.size() << " units left for complex dispatch with "
<< village_count << " villages left.\n";
dump_reachmap(reachmap);
@ -445,7 +445,7 @@ static void dispatch(treachmap& reachmap, tmoves& moves)
static bool dispatch_unit_simple(treachmap& reachmap, tmoves& moves)
{
bool result = false;
treachmap::iterator itor = reachmap.begin();
while(itor != reachmap.end()) {
if(itor->second.size() == 1) {
@ -473,7 +473,7 @@ static bool dispatch_unit_simple(treachmap& reachmap, tmoves& moves)
if(reachmap.size() == 1) {
// One unit left.
DBG_AI << "Dispatched _last_ unit at " << reachmap.begin()->first
DBG_AI << "Dispatched _last_ unit at " << reachmap.begin()->first
<< " to village " << reachmap.begin()->second[0] << '\n';
moves.push_back(std::make_pair(
@ -497,13 +497,13 @@ static bool dispatch_village_simple(
dispatched = false;
// build the reverse map
std::map<map_location /*village location*/,
std::map<map_location /*village location*/,
std::vector<map_location /* units that can reach it*/> >reversemap;
treachmap::const_iterator itor = reachmap.begin();
for(;itor != reachmap.end(); ++itor) {
for(std::vector<map_location>::const_iterator
for(std::vector<map_location>::const_iterator
v_itor = itor->second.begin();
v_itor != itor->second.end(); ++v_itor) {
@ -562,7 +562,7 @@ static treachmap::iterator remove_unit(
assert(unit->second.empty());
if(unit->first == leader_loc && best_leader_loc != map_location::null_location) {
DBG_AI << "Dispatch leader at " << leader_loc << " closer to the keep at "
DBG_AI << "Dispatch leader at " << leader_loc << " closer to the keep at "
<< best_leader_loc << '\n';
moves.push_back(std::make_pair(best_leader_loc, leader_loc));
@ -597,10 +597,10 @@ static void dispatch_complex(
// We want to test the units, the ones who can reach the least
// villages first so this is our lookup map.
std::multimap<size_t /* villages_per_unit value*/,
std::multimap<size_t /* villages_per_unit value*/,
size_t /*villages_per_unit index*/> unit_lookup;
std::vector</*unit*/std::vector</*village*/bool> >
std::vector</*unit*/std::vector</*village*/bool> >
matrix(reachmap.size(), std::vector<bool>(village_count, false));
treachmap::const_iterator itor = reachmap.begin();
@ -615,7 +615,7 @@ static void dispatch_complex(
size_t v_index;
// find the index of the v in the villages
std::vector<map_location>::const_iterator v_itor =
std::vector<map_location>::const_iterator v_itor =
std::find(villages.begin(), villages.end(), itor->second[v]);
if(v_itor == villages.end()) {
v_index = villages.size(); // will be the last element after push_back.
@ -625,7 +625,7 @@ static void dispatch_complex(
}
units_per_village[v_index]++;
matrix[u][v_index] = true;
}
}
@ -663,8 +663,8 @@ static void dispatch_complex(
}
// Test the special case, everybody can reach all villages
const bool reach_all = ((village_count == unit_count)
&& (std::accumulate(villages_per_unit.begin(), villages_per_unit.end(), size_t())
const bool reach_all = ((village_count == unit_count)
&& (std::accumulate(villages_per_unit.begin(), villages_per_unit.end(), size_t())
== (village_count * unit_count)));
if(reach_all) {
@ -679,8 +679,8 @@ static void dispatch_complex(
::const_iterator src_itor = unit_lookup.begin();
while(src_itor != unit_lookup.end() && src_itor->first == 2) {
for(std::multimap<size_t, size_t>::const_iterator
for(std::multimap<size_t, size_t>::const_iterator
dst_itor = unit_lookup.begin();
dst_itor != unit_lookup.end(); ++ dst_itor) {
@ -697,7 +697,7 @@ static void dispatch_complex(
);
size_t matched = std::count(result.begin(), result.end(), true);
// we found a solution, dispatch
if(matched == 2) {
// Collect data
@ -707,8 +707,8 @@ static void dispatch_complex(
const map_location village1 = villages[first - result.begin()];
const map_location village2 = villages[second - result.begin()];
const bool perfect = (src_itor->first == 2 &&
dst_itor->first == 2 &&
const bool perfect = (src_itor->first == 2 &&
dst_itor->first == 2 &&
units_per_village[first - result.begin()] == 2 &&
units_per_village[second - result.begin()] == 2);
@ -724,7 +724,7 @@ static void dispatch_complex(
// Remove the units
reachmap.erase(units[src_itor->second]);
reachmap.erase(units[dst_itor->second]);
// Evaluate and start correct function.
if(perfect) {
// We did a perfect dispatch 2 units who could visit 2 villages.
@ -751,7 +751,7 @@ static void dispatch_complex(
// ***** ***** Do all permutations.
// Now walk through all possible permutations
// - test whether the suggestion is possible
// - does it result in max_villages
// - does it result in max_villages
// - dispatch and ready
// - is it's result better as the last best
// - store
@ -766,8 +766,8 @@ static void dispatch_complex(
const size_t max_options = 8;
if(unit_count >= max_options && village_count >= max_options) {
DBG_AI << "Too many units " << unit_count << " and villages "
<< village_count<<" found, evaluate only the first "
DBG_AI << "Too many units " << unit_count << " and villages "
<< village_count<<" found, evaluate only the first "
<< max_options << " options;\n";
std::vector<size_t> perm (max_options, 0);
@ -797,7 +797,7 @@ static void dispatch_complex(
std::copy(best_result.begin(), best_result.end(), std::back_inserter(moves));
// Clean up the reachmap for dispatched units.
for(std::vector<std::pair<map_location, map_location> >::const_iterator
for(std::vector<std::pair<map_location, map_location> >::const_iterator
itor = best_result.begin(); itor != best_result.end(); ++itor) {
reachmap.erase(itor->second);
}
@ -838,7 +838,7 @@ static void dispatch_complex(
// clean up the reachmap we need to test whether the leader is still there
// and if so remove him manually to get him dispatched.
for(std::vector<std::pair<map_location, map_location> >::const_iterator
for(std::vector<std::pair<map_location, map_location> >::const_iterator
itor = best_result.begin(); itor != best_result.end(); ++itor) {
reachmap.erase(itor->second);
}
@ -881,7 +881,7 @@ static void dispatch_complex(
// clean up the reachmap we need to test whether the leader is still there
// and if so remove him manually to get him dispatched.
for(std::vector<std::pair<map_location, map_location> >::const_iterator
for(std::vector<std::pair<map_location, map_location> >::const_iterator
itor = best_result.begin(); itor != best_result.end(); ++itor) {
reachmap.erase(itor->second);
}
@ -897,7 +897,7 @@ static void dispatch_complex(
static void full_dispatch(treachmap& reachmap, tmoves& moves)
{
treachmap::const_iterator itor = reachmap.begin();
for(size_t i = 0; i < reachmap.size(); ++i, ++itor) {
for(size_t i = 0; i < reachmap.size(); ++i, ++itor) {
DBG_AI << "Dispatched unit at " << itor->first
<< " to village " << itor->second[i] << '\n';
moves.push_back(std::make_pair(itor->second[i], itor->first));
@ -910,16 +910,16 @@ static void dump_reachmap(treachmap& reachmap)
return;
}
for(treachmap::const_iterator itor =
for(treachmap::const_iterator itor =
reachmap.begin(); itor != reachmap.end(); ++itor) {
std::cerr << "Reachlist for unit at " << itor->first;
if(itor->second.empty()) {
std::cerr << "\tNone";
}
for(std::vector<map_location>::const_iterator
for(std::vector<map_location>::const_iterator
v_itor = itor->second.begin();
v_itor != itor->second.end(); ++v_itor) {
@ -934,7 +934,7 @@ static void dump_reachmap(treachmap& reachmap)
// small helper rule to test the matching rules
// building rule
//make ai_village.o && g++-3.3 -o ai_village about.o actions.o ai.o ai_dfool.o ai_attack.o ai_move.o ai_python.o ai_village.o animated_game.o attack_prediction.o config_adapter.o dialogs.o floating_textbox.o game_display.o game_events.o game_preferences.o game_preferences_display.o gamestatus.o generate_report.o generic_event.o halo.o help.o intro.o leader_list.o menu_events.o mouse_events.o multiplayer.o multiplayer_ui.o multiplayer_wait.o multiplayer_connect.o multiplayer_create.o multiplayer_lobby.o network.o network_worker.o pathfind.o playcampaign.o play_controller.o playmp_controller.o playsingle_controller.o playturn.o publish_campaign.o replay.o replay_controller.o sha1.o settings.o statistics.o team.o terrain_filter.o titlescreen.o tooltips.o unit.o unit_abilities.o unit_animation.o unit_display.o unit_frame.o unit_map.o unit_types.o upload_log.o variable.o widgets/combo.o widgets/scrollpane.o -L. -lwesnoth-core -lSDL_image -lSDL_mixer -lSDL_net -L/usr/lib -lSDL -L/usr/lib -lpython2.4 -lfreetype -lz -L/usr/lib -lfribidi libwesnoth.a -lboost_iostreams -lX11 -L/usr/lib -R/usr/lib
/*
/*
// gcc-3.3 -O0
Option count : 1 duration 0 ms
Option count : 2 duration 0 ms
@ -973,7 +973,7 @@ Option count : 9 duration 261 ms
Option count : 10 duration 2336 ms
Option count : 11 duration 26684 ms
*/
*/
int main()
{
const size_t max_matrix = 100;
@ -993,7 +993,7 @@ int main()
// Permutations for 0 are quite senseless.
std::vector<std::pair<map_location,map_location> > best_result;
for(size_t option = 1; option < max_matrix; ++option) {
// Set up the permuation
// Set up the permuation
std::vector<size_t> perm (option, 0);
for(size_t i = 0; i < option; ++i) {
perm[i] = i;

View file

@ -98,8 +98,8 @@ protected:
friend class unit_animation;
int starting_frame_time_;
// backward compatibility for teleport anims
void remove_frames_until(int starting_time);
void remove_frames_after(int ending_time);
void remove_frames_until(int starting_time);
void remove_frames_after(int ending_time);
private:
struct frame

View file

@ -13,7 +13,7 @@
*/
/**
* @file animated_game.cpp
* @file animated_game.cpp
* Template instantiations for wesnoth-game.
*/

View file

@ -13,7 +13,7 @@
*/
/**
* @file array.hpp
* @file array.hpp
* Template for arrays.
*/

View file

@ -46,7 +46,7 @@
//helper macro for the simple operator cases defined below
#define ASSERT_OP(a,op,b) ASSERT_LOG((a) op (b), #a " " #op " " #b " (" << (a) << " " #op " " << (b) << ")")
//various asserts of standard "equality" tests, such as "equals", "not equals", "greater than", etc.
//various asserts of standard "equality" tests, such as "equals", "not equals", "greater than", etc.
//Example usage ASSERT_GE(x, y);
//on failure this will cerr "assertion failed: x >= y (value_of_x >= value_of_y)"
#define ASSERT_EQ(a,b) ASSERT_OP(a,==,b)

View file

@ -72,7 +72,7 @@ void a_star_world::poss_a_star_node::addPage()
a_star_world::poss_a_star_node::poss_a_star_node() :
vectPageAStarNode_(),
nbElemByPage_(size_t((4096 - 24) / sizeof(a_star_node))),
capacity_(0),
capacity_(0),
curIndex_(0)
{
assert(nbElemByPage_ > 0);
@ -117,9 +117,9 @@ void a_star_world::poss_a_star_node::clear()
}
a_star_world::a_star_world() :
pool_(new poss_a_star_node),
pool_(new poss_a_star_node),
vectAStarNode_(),
width_(0),
width_(0),
nbNode_(0)
{
}

View file

@ -22,7 +22,7 @@ See the COPYING file for more details.
struct a_star_node
{
public:
a_star_node() :
g(0.0),
h(0.0),
@ -57,7 +57,7 @@ public:
// (see shortest_path_calculator::cost)
return distance_between(src, dst) -
(300.0 - sqrt( xdiff*xdiff + ydiff*ydiff)) / 3000000.0;
// TODO: move the heuristic function into the cost_calculator
// so we can use case-specific heuristic
// and clean the definition of these numbers

View file

@ -30,10 +30,10 @@
// -DCHECK for testing correctness
// (run tools/wesnoth-attack-sim.c --check on output)
#if defined(BENCHMARK) || defined(CHECK)
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#endif
#ifdef ATTACK_PREDICTION_DEBUG
@ -731,16 +731,16 @@ void combatant::consider_levelup(combatant &opp) {
}
// fully healed unless dead
hp_dist.back() = 1 - hp_dist.front();
} else if (u_.experience + ((opp.u_.level == 0) ? 4 : opp.u_.level * 8)
} else if (u_.experience + ((opp.u_.level == 0) ? 4 : opp.u_.level * 8)
>= u_.max_experience) {
// if we kill, we will level up. So then the damage we had
// becomes less probable since it's now conditional on us not
// levelling up. This doesn't apply to the probability of us
// dying, of course.
float scalefactor =
float scalefactor =
(1 - hp_dist.front() - opp.hp_dist.front()) / (1 - hp_dist.front());
std::vector<double>::iterator i;
i = hp_dist.begin();

View file

@ -26,11 +26,11 @@ static void format_prob(char str_buf[10], const float prob)
if(prob > 0.9995) {
snprintf(str_buf, 10, "100 %%");
} else if(prob >= 0.1) {
snprintf(str_buf, 10, "%4.1f %%",
} else if(prob >= 0.1) {
snprintf(str_buf, 10, "%4.1f %%",
static_cast<float>(100.0 * (prob + 0.0005)));
} else {
snprintf(str_buf, 10, " %3.1f %%",
} else {
snprintf(str_buf, 10, " %3.1f %%",
static_cast<float>(100.0 * (prob + 0.0005)));
}
@ -43,21 +43,21 @@ const int battle_prediction_pane::inter_column_gap_ = 30;
const int battle_prediction_pane::inter_units_gap_ = 30;
const int battle_prediction_pane::max_hp_distrib_rows_ = 10;
battle_prediction_pane::battle_prediction_pane(display &disp,
const battle_context& bc, const gamemap& map, const
std::vector<team>& teams, const unit_map& units,
const gamestatus& status, const map_location& attacker_loc,
battle_prediction_pane::battle_prediction_pane(display &disp,
const battle_context& bc, const gamemap& map, const
std::vector<team>& teams, const unit_map& units,
const gamestatus& status, const map_location& attacker_loc,
const map_location& defender_loc) :
gui::preview_pane(disp.video()),
disp_(disp),
bc_(bc),
map_(map),
teams_(teams),
units_(units),
status_(status),
attacker_loc_(attacker_loc),
defender_loc_(defender_loc),
attacker_(units.find(attacker_loc)->second),
gui::preview_pane(disp.video()),
disp_(disp),
bc_(bc),
map_(map),
teams_(teams),
units_(units),
status_(status),
attacker_loc_(attacker_loc),
defender_loc_(defender_loc),
attacker_(units.find(attacker_loc)->second),
defender_(units.find(defender_loc)->second),
attacker_label_(),
defender_label_(),
@ -557,4 +557,4 @@ attack_prediction_displayer::RESULT attack_prediction_displayer::button_pressed(
return gui::CONTINUE_DIALOG;
}

View file

@ -129,7 +129,7 @@ bool terrain_builder::tilemap::on_map(const map_location &loc) const
}
return true;
}
terrain_builder::tile& terrain_builder::tilemap::operator[](const map_location &loc)
@ -148,7 +148,7 @@ const terrain_builder::tile& terrain_builder::tilemap::operator[] (const map_loc
terrain_builder::terrain_builder(const config& cfg, const config& level,
const gamemap* m, const std::string& offmap_image) :
map_(m),
map_(m),
tile_map_(map().w(), map().h()),
terrain_by_type_(),
building_rules_()
@ -245,7 +245,7 @@ void terrain_builder::rebuild_terrain(const map_location &loc)
img_loc.add_frame(100,image::locator("terrain/" + filename + ".png"));
img_loc.start_animation(0, true);
btile.images_background.push_back(img_loc);
//Combine base and overlay image if neccessary
if(map().get_terrain_info(map().get_terrain(loc)).is_combined()) {
const std::string filename_ovl =
@ -660,7 +660,7 @@ void terrain_builder::parse_mapstring(const std::string &mapstring,
add_constraints(br.constraints, map_location(x, y), t_translation::STAR, global_images);
} else {
ERR_NG << "Invalid terrain (" << t_translation::write_terrain_code(terrain) << ") in builder map\n";
assert(false);
assert(false);
return;
}
x += 2;
@ -795,9 +795,9 @@ void terrain_builder::parse_config(const config &cfg)
building_ruleset::const_iterator rule;
for(rule = building_rules_.begin(); rule != building_rules_.end(); ++rule) {
std::cerr << ">> New rule: image_background = "
std::cerr << ">> New rule: image_background = "
<< "\n>> Location " << rule->second.location_constraints
<< "\n>> Probability " << rule->second.probability
<< "\n>> Probability " << rule->second.probability
<< "\n>> Precedence " << rule->second.precedence << '\n';
for(constraint_set::const_iterator constraint = rule->second.constraints.begin();

View file

@ -46,11 +46,11 @@ class terrain_builder
public:
/** Used as a parameter for the get_terrain_at function. */
enum ADJACENT_TERRAIN_TYPE {
ADJACENT_BACKGROUND, /**<
ADJACENT_BACKGROUND, /**<
* Represents terrains which are to be
* drawn behind unit sprites
*/
ADJACENT_FOREGROUND /**<
ADJACENT_FOREGROUND /**<
* Represents terrains which are to be
* drawn in front of them.
*/
@ -76,15 +76,15 @@ public:
*/
terrain_builder(const config& cfg, const config &level,
const gamemap* map, const std::string& offmap_image);
const gamemap& map() const { return *map_; }
/**
* Updates internals that cache map size. This should be called when the map
/**
* Updates internals that cache map size. This should be called when the map
* size has changed.
*/
void reload_map();
void change_map(const gamemap* m);
/** Returns a vector of strings representing the images to load & blit
@ -139,7 +139,7 @@ public:
rule_image_variant(const std::string &image_string, const std::string &tod) :
image_string(image_string),
image(),
tod(tod)
tod(tod)
{};
/** A string representing either the filename for an image, or
@ -221,7 +221,7 @@ public:
*/
struct terrain_constraint
{
terrain_constraint() :
terrain_constraint() :
loc(),
terrain_types_match(),
set_flag(),
@ -230,7 +230,7 @@ public:
images()
{};
terrain_constraint(map_location loc) :
terrain_constraint(map_location loc) :
loc(loc),
terrain_types_match(),
set_flag(),
@ -363,7 +363,7 @@ private:
/**
* Constructs a tilemap of dimensions x * y
*/
tilemap(int x, int y) :
tilemap(int x, int y) :
tiles_((x + 4) * (y + 4)),
x_(x),
y_(y)
@ -397,7 +397,7 @@ private:
* Resets the whole tile map
*/
void reset();
/**
* Rebuilds the map to a new set of dimensions
*/
@ -723,7 +723,7 @@ private:
* A pointer to the gamemap class used in the current level.
*/
const gamemap* map_;
/**
* The tile_map_ for the current level, which is filled by the
* build_terrains_ method to contain "tiles" representing images

View file

@ -326,7 +326,7 @@ variant terrain_callable::get_value(const std::string& key) const
} else
return variant();
}
void terrain_callable::get_inputs(std::vector<game_logic::formula_input>* inputs) const
{
using game_logic::FORMULA_READ_ONLY;
@ -335,4 +335,4 @@ void terrain_callable::get_inputs(std::vector<game_logic::formula_input>* inputs
inputs->push_back(game_logic::formula_input("loc", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("id", FORMULA_READ_ONLY));
}

View file

@ -137,12 +137,12 @@ namespace {
if(childpid == 0) {
/*** We're the child process ***/
// execute the script, we run is a separate thread and share the
// execute the script, we run is a separate thread and share the
// output which will make the logging look ugly.
execlp(script.c_str(), script.c_str(), addon.c_str(), (char *)NULL);
// exec() and family never return; if they do, we have a problem
std::cerr << "ERROR: exec failed with errno " << errno << " for addon " << addon
std::cerr << "ERROR: exec failed with errno " << errno << " for addon " << addon
<< '\n';
exit(errno);
@ -166,10 +166,10 @@ namespace {
return lexical_cast_default<int>(cfg_["port"], DEFAULT_CAMPAIGND_PORT);
}
campaign_server::campaign_server(const std::string& cfgfile,
campaign_server::campaign_server(const std::string& cfgfile,
size_t min_thread, size_t max_thread) :
cfg_(),
file_(cfgfile),
file_(cfgfile),
net_manager_(min_thread,max_thread),
server_manager_(load_config()),
hooks_(),
@ -237,7 +237,7 @@ namespace {
// Convert all addons to gzip
config::child_list camps = campaigns().get_children("campaign");
LOG_CS << "Converting all stored addons to gzip format. Number of addons: " << camps.size() <<"\n";
for (config::child_list::iterator itor = camps.begin();
itor != camps.end(); ++itor)
{
@ -250,12 +250,12 @@ namespace {
continue;
}
read_compressed(data, *binary_stream);
scoped_ostream gzip_stream = ostream_file((**itor)["filename"]);
config_writer writer(*gzip_stream, true, "",compress_level_);
writer.write(data);
}
cfg_["converted_to_gzipped_data"] = "yes";
}
if (cfg_["encoded"] != "yes")
@ -263,7 +263,7 @@ namespace {
// Convert all addons to gzip
config::child_list camps = campaigns().get_children("campaign");
LOG_CS << "Encoding all stored campaigns. Number of addons: " << camps.size() <<"\n";
for (config::child_list::iterator itor = camps.begin();
itor != camps.end(); ++itor)
{
@ -278,7 +278,7 @@ namespace {
boost::iostreams::filtering_stream<boost::iostreams::output> out_filter;
out_filter.push(boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(compress_level_)));
out_filter.push(*out_file);
unsigned char c = in_filter.get();
while( in_filter.good())
{
@ -297,7 +297,7 @@ namespace {
}
}
cfg_["encoded"] = "yes";
}
}
@ -305,9 +305,9 @@ namespace {
void campaign_server::run()
{
convert_binary_to_gzip();
if (!cfg_["control_socket"].empty())
input_ = new input_stream(cfg_["control_socket"]);
input_ = new input_stream(cfg_["control_socket"]);
bool gzipped;
network::connection sock = 0;
for(int increment = 0; ; ++increment) {
@ -407,7 +407,7 @@ namespace {
scoped_istream stream = istream_file((*campaign)["filename"]);
config cfg;
read_gz(cfg, *stream);
std::cerr << " size: " <<
std::cerr << " size: " <<
(network::send_data(cfg, sock, false)/1024)
<< "kb\n";
}
@ -541,7 +541,7 @@ namespace {
continue;
}
if((*campaign)["passphrase"] != (*erase)["passphrase"]
if((*campaign)["passphrase"] != (*erase)["passphrase"]
&& (campaigns()["master_password"] == ""
|| campaigns()["master_password"] != (*erase)["passphrase"])) {

View file

@ -13,7 +13,7 @@
*/
/**
* @file cavegen.cpp
* @file cavegen.cpp
* Map-generator for caves.
*/
@ -27,11 +27,11 @@
#define LOG_NG LOG_STREAM(info, engine)
cave_map_generator::cave_map_generator(const config* cfg) :
cave_map_generator::cave_map_generator(const config* cfg) :
wall_(t_translation::CAVE_WALL),
clear_(t_translation::CAVE),
clear_(t_translation::CAVE),
village_(t_translation::UNDERGROUND_VILLAGE),
castle_(t_translation::DWARVEN_CASTLE),
castle_(t_translation::DWARVEN_CASTLE),
keep_(t_translation::DWARVEN_KEEP),
map_(),
starting_positions_(),
@ -39,11 +39,11 @@ cave_map_generator::cave_map_generator(const config* cfg) :
chambers_(),
passages_(),
res_(),
cfg_(cfg),
width_(50),
cfg_(cfg),
width_(50),
height_(50),
village_density_(0),
flipx_(false),
village_density_(0),
flipx_(false),
flipy_(false)
{
if(cfg_ == NULL) {
@ -125,7 +125,7 @@ config cave_map_generator::create_scenario(const std::vector<std::string>& /*arg
LOG_NG << "outputting map....\n";
res_["map_data"] = gamemap::default_map_header +
res_["map_data"] = gamemap::default_map_header +
t_translation::write_game_map(map_, starting_positions_);
LOG_NG << "returning result...\n";

View file

@ -32,7 +32,7 @@ public:
void user_config(display& /* disp*/) { return; }
std::string name() const { return "cave"; }
std::string config_name() const;
std::string create_map(const std::vector<std::string>& args);
@ -70,11 +70,11 @@ private:
void place_passage(const passage& p);
// Note we assume a border size of 1.
bool on_board(const map_location& loc) const
bool on_board(const map_location& loc) const
{
return loc.x > 0 && loc.y > 0 &&
loc.x < static_cast<long>(width_ - 2) &&
loc.y < static_cast<long>(height_ - 2);
loc.y < static_cast<long>(height_ - 2);
}
void set_terrain(map_location loc, t_translation::t_terrain t);

View file

@ -26,8 +26,8 @@
#include "SDL_syswm.h"
/**
The following are two classes which wrap the SDL's interface to X,
including locking/unlocking, and which manage the atom internment.
The following are two classes which wrap the SDL's interface to X,
including locking/unlocking, and which manage the atom internment.
They exist mainly to make the actual clipboard code somewhat readable.
*/
class XHelper
@ -151,17 +151,17 @@ public:
/**
Note: unfortunately, SDL does not keep track of event timestamps.
This means we are forced to use CurrentTime in many spots and
are unable to perform many safety checks.
Hence, the code below is not compliant to the ICCCM, and
may ocassionally suffer from race conditions if an X client
is connected to the server over a slow/high-latency link.
This means we are forced to use CurrentTime in many spots and
are unable to perform many safety checks.
Hence, the code below is not compliant to the ICCCM, and
may ocassionally suffer from race conditions if an X client
is connected to the server over a slow/high-latency link.
This implementation is also very minimal.
The text is assumed to be reasonably small, as INCR transactions
are not supported.
The text is assumed to be reasonably small, as INCR transactions
are not supported.
MULTIPLE is not supported either.
We provide UTF8_STRING, COMPOUND_TEXT, and TEXT,
We provide UTF8_STRING, COMPOUND_TEXT, and TEXT,
and try to grab all of them, plus STRING (which is latin1).
*/
@ -169,7 +169,7 @@ public:
/**
We primarily. keep a copy of the string to response to data requests,
but it also has an another function: in case we're both the source
and destination, we just copy it across; this is so that we don't
and destination, we just copy it across; this is so that we don't
have to handle SelectionRequest events while waiting for SelectionNotify.
To make this work, however, this gets cleared when we loose CLIPBOARD.
*/
@ -177,7 +177,7 @@ static std::string clipboard_string;
/**
The following string is used for the mouse selection aka PRIMARY
Unix behaviour is mouse selection is stored in primary
Unix behaviour is mouse selection is stored in primary
active selection goes to CLIPBOARD.
*/
static std::string primary_string;
@ -249,7 +249,7 @@ void handle_system_event(const SDL_Event& event)
UseX x11;
if(xev.xselectionclear.selection == x11->XA_CLIPBOARD()) {
clipboard_string.clear();
clipboard_string.clear();
} else if(xev.xselectionclear.selection == XA_PRIMARY) {
primary_string.clear();
}
@ -267,14 +267,14 @@ void copy_to_clipboard(const std::string& text, const bool mouse)
if(mouse) {
primary_string = text;
XSetSelectionOwner(x11->dpy(), XA_PRIMARY, x11->window(), CurrentTime);
} else {
} else {
clipboard_string = text;
XSetSelectionOwner(x11->dpy(), x11->XA_CLIPBOARD(), x11->window(), CurrentTime);
}
}
/**
* Tries to grab a given target.
* Tries to grab a given target.
* Returns true if successful, false otherwise.
*/
static bool try_grab_target(Atom source, Atom target, std::string& ret)
@ -337,13 +337,13 @@ static bool try_grab_target(Atom source, Atom target, std::string& ret)
}
std::string copy_from_clipboard(const bool mouse)
{
{
// in-wesnoth copy-paste
if(mouse && !primary_string.empty()) {
return primary_string;
}
if (!mouse && !clipboard_string.empty()) {
return clipboard_string;
return clipboard_string;
}
UseX x11;

View file

@ -26,7 +26,7 @@
*
* @param text The text to copy.
* @param mouse Is the selection done by the mouse? On UNIX systems there
* are multiple clipboards and the mouse selction uses a
* are multiple clipboards and the mouse selction uses a
* different clipboard. Ignored on other systems.
*/
void copy_to_clipboard(const std::string& text, const bool mouse);
@ -35,7 +35,7 @@ void copy_to_clipboard(const std::string& text, const bool mouse);
* Copies text from the clipboard.
*
* @param mouse Is the pasting done by the mouse?
*
*
* @returns String on clipbaord.
*/
std::string copy_from_clipboard(const bool mouse);

View file

@ -42,7 +42,7 @@ namespace game_config {
return cache;
}
config_cache::config_cache() :
config_cache::config_cache() :
force_valid_cache_(false),
use_cache_(true),
not_valid_cache_(false),
@ -126,8 +126,8 @@ namespace game_config {
// call foreach define is: second.write(config_writer,first);
std::for_each(defines_map.begin(), defines_map.end(),
boost::bind(&preproc_define::write,
boost::bind(&preproc_map::value_type::second,_1),
boost::ref(writer),
boost::bind(&preproc_map::value_type::second,_1),
boost::ref(writer),
boost::bind(&preproc_map::value_type::first,_1)));
}
@ -137,7 +137,7 @@ namespace game_config {
scoped_istream stream = istream_file(path);
read_gz(cfg, *stream);
}
preproc_map& config_cache::make_copy_map()
{
return config_cache_transaction::instance().get_active_map(defines_map_);
@ -208,7 +208,7 @@ namespace game_config {
config checksum_cfg;
read_file(fname_checksum, checksum_cfg);
dir_checksum = file_tree_checksum(checksum_cfg);
}
}
} catch(config::error&) {
ERR_CACHE << "cache checksum is corrupt\n";
} catch(io_exception&) {
@ -273,11 +273,11 @@ namespace game_config {
read_file(path, cfg);
DBG_CACHE << "Reading cached defines from: " << path << "\n";
// use static preproc_define::read_pair(config*) to make a object
// and pass that object config_cache_transaction::insert_to_active method
std::for_each(cfg.ordered_begin(), cfg.ordered_end(),
add_define_from_file());
add_define_from_file());
}
void config_cache::read_defines_queue()
@ -302,7 +302,7 @@ namespace game_config {
{
// activate path defines
scoped_preproc_define_list defines;
scoped_preproc_define_list defines;
std::for_each(path_defines_.lower_bound(path),path_defines_.upper_bound(path),
boost::bind(&scoped_preproc_define_list::push_back,
boost::ref(defines),
@ -394,8 +394,8 @@ namespace game_config {
config_cache_transaction::state config_cache_transaction::state_ = FREE;
config_cache_transaction* config_cache_transaction::active_ = 0;
config_cache_transaction::config_cache_transaction()
config_cache_transaction::config_cache_transaction()
: define_filenames_()
, active_map_()
{
@ -403,7 +403,7 @@ namespace game_config {
state_ = NEW;
active_ = this;
}
config_cache_transaction::~config_cache_transaction()
{
state_ = FREE;
@ -412,7 +412,7 @@ namespace game_config {
void config_cache_transaction::lock()
{
state_ = LOCKED;
state_ = LOCKED;
}
const config_cache_transaction::filenames& config_cache_transaction::get_define_files() const
@ -434,7 +434,7 @@ namespace game_config {
std::insert_iterator<preproc_map>(active_map_, active_map_.begin()));
if ( get_state() == NEW)
state_ = ACTIVE;
}
}
return active_map_;
}

View file

@ -14,7 +14,7 @@
/**
* this file implements game config caching
* to speed up startup
* to speed up startup
***/
#ifndef CONFIG_CACHE_HPP_INCLUDED
@ -69,7 +69,7 @@ namespace game_config {
**/
~scoped_preproc_define_internal()
{
if(add_)
if(add_)
{
if (path_.empty())
T::instance().remove_define(name_);
@ -180,7 +180,7 @@ namespace game_config {
* Force cache checksum validation.
**/
void recheck_filetree_checksum();
};
struct add_define_from_file;
@ -210,10 +210,10 @@ namespace game_config {
/**
* Used to let std::for_each insert new defines to active_map
* map to active
* map to active
**/
void insert_to_active(const preproc_map::value_type& def);
private:
static state state_;
static config_cache_transaction* active_;

View file

@ -803,7 +803,7 @@ void dialog::action(dialog_process_info& info)
set_result(CONTINUE_DIALOG);
info.first_time = true;
}
}

View file

@ -121,10 +121,10 @@ class dialog;
class filter_textbox : public gui::dialog_textbox {
public:
filter_textbox(CVideo& video, const std::string& header,
const std::vector<std::string>& items,
const std::vector<std::string>& items_to_filter, size_t header_row,
dialog& dialog, int width = 250) :
filter_textbox(CVideo& video, const std::string& header,
const std::vector<std::string>& items,
const std::vector<std::string>& items_to_filter, size_t header_row,
dialog& dialog, int width = 250) :
dialog_textbox(new label(video, header), video, width),
items_(items),
items_to_filter_(items_to_filter),

View file

@ -19,12 +19,12 @@
controller_base::controller_base(
int ticks, const config& game_config, CVideo& /*video*/) :
game_config_(game_config),
ticks_(ticks),
game_config_(game_config),
ticks_(ticks),
key_(),
browse_(false),
scrolling_(false)
{
{
}
controller_base::~controller_base()
@ -36,7 +36,7 @@ int controller_base::get_ticks() {
}
bool controller_base::can_execute_command(
hotkey::HOTKEY_COMMAND /*command*/, int /*index*/) const
hotkey::HOTKEY_COMMAND /*command*/, int /*index*/) const
{
return false;
}
@ -79,13 +79,13 @@ void controller_base::handle_event(const SDL_Event& event)
post_mouse_press(event);
if (get_mouse_handler_base().get_show_menu()){
show_menu(get_display().get_theme().context_menu()->items(),event.button.x,event.button.y,true);
}
}
break;
case SDL_ACTIVEEVENT:
if (event.active.type == SDL_APPMOUSEFOCUS && event.active.gain == 0) {
if (get_mouse_handler_base().is_dragging()) {
//simulate mouse button up when the app has lost mouse focus
//this should be a general fix for the issue when the mouse
//this should be a general fix for the issue when the mouse
//is dragged out of the game window and then the button is released
int x, y;
Uint8 mouse_flags = SDL_GetMouseState(&x, &y);
@ -97,7 +97,7 @@ void controller_base::handle_event(const SDL_Event& event)
e.button.x = x;
e.button.y = y;
get_mouse_handler_base().mouse_press(event.button, browse_);
post_mouse_press(event);
post_mouse_press(event);
}
}
}
@ -107,12 +107,12 @@ void controller_base::handle_event(const SDL_Event& event)
}
}
bool controller_base::have_keyboard_focus()
bool controller_base::have_keyboard_focus()
{
return true;
}
void controller_base::process_keydown_event(const SDL_Event& /*event*/)
void controller_base::process_keydown_event(const SDL_Event& /*event*/)
{
//no action by default
}
@ -129,26 +129,26 @@ bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse
{
bool scrolling = false;
bool mouse_in_window = SDL_GetAppState() & SDL_APPMOUSEFOCUS;
const int scroll_threshold = (preferences::mouse_scroll_enabled())
const int scroll_threshold = (preferences::mouse_scroll_enabled())
? preferences::mouse_scroll_threshold()
: 0;
if ((key[SDLK_UP] && have_keyboard_focus())
if ((key[SDLK_UP] && have_keyboard_focus())
|| (mousey < scroll_threshold && mouse_in_window)) {
get_display().scroll(0,-preferences::scroll_speed());
scrolling = true;
}
if ((key[SDLK_DOWN] && have_keyboard_focus())
if ((key[SDLK_DOWN] && have_keyboard_focus())
|| (mousey > get_display().h() - scroll_threshold && mouse_in_window)) {
get_display().scroll(0,preferences::scroll_speed());
scrolling = true;
}
if ((key[SDLK_LEFT] && have_keyboard_focus())
if ((key[SDLK_LEFT] && have_keyboard_focus())
|| (mousex < scroll_threshold && mouse_in_window)) {
get_display().scroll(-preferences::scroll_speed(),0);
scrolling = true;
}
if ((key[SDLK_RIGHT] && have_keyboard_focus())
if ((key[SDLK_RIGHT] && have_keyboard_focus())
|| (mousex > get_display().w() - scroll_threshold && mouse_in_window)) {
get_display().scroll(preferences::scroll_speed(),0);
scrolling = true;
@ -179,7 +179,7 @@ void controller_base::play_slice()
events::pump();
events::raise_process_event();
events::raise_draw_event();
slice_before_scroll();
const theme::menu* const m = get_display().menu_pressed();
if(m != NULL) {
@ -187,13 +187,13 @@ void controller_base::play_slice()
show_menu(m->items(),menu_loc.x+1,menu_loc.y + menu_loc.h + 1,false);
return;
}
int mousex, mousey;
Uint8 mouse_flags = SDL_GetMouseState(&mousex, &mousey);
tooltips::process(mousex, mousey);
tooltips::process(mousex, mousey);
bool was_scrolling = scrolling_;
scrolling_ = handle_scroll(key, mousex, mousey, mouse_flags);
get_display().draw();
if (!scrolling_) {
if (was_scrolling) {

View file

@ -45,12 +45,12 @@ protected:
* and other things like menu.
*/
virtual void slice_before_scroll();
/**
* Called at the very end of play_slice
*/
virtual void slice_end();
/**
* Inherited from command_executor, still declared pure virtual but might
* provide some defaults
@ -64,8 +64,8 @@ protected:
* Get a reference to a display member a derived class uses
*/
virtual display& get_display() = 0;
/**
* Derived classes should override this to return false when arrow keys
* should not scroll the map, hotkeys not processed etc, for example
@ -73,41 +73,41 @@ protected:
* @returns true when arrow keys should scroll the map, false otherwise
*/
virtual bool have_keyboard_focus();
/**
* Handle scrolling by keyboard and moving mouse near map edges
* @see is_keyboard_scroll_active
* @return true when there was any scrolling, false otherwise
*/
bool handle_scroll(CKey& key, int mousex, int mousey, int mouse_flags);
/**
* Process mouse- and keypress-events from SDL.
/**
* Process mouse- and keypress-events from SDL.
* Not virtual but calls various virtual function to allow specialized
* behaviour of derived classess.
*/
void handle_event(const SDL_Event& event);
/**
/**
* Process keydown (only when the general map display does not have focus).
* Overriden in derived classes
*/
virtual void process_keydown_event(const SDL_Event& event);
/**
/**
* Process keyup (always).
* Overriden in derived classes
*/
virtual void process_keyup_event(const SDL_Event& event);
/**
/**
* Called after processing a mouse button up or down event
* Overriden in derived classes
*/
virtual void post_mouse_press(const SDL_Event& event);
virtual void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const;
const config& game_config_;

View file

@ -66,7 +66,7 @@ public:
typedef typename thelper<T>::type type;
};
} // namespace utils
} // namespace utils
/**
* Allow no copies.
@ -81,7 +81,7 @@ public:
/** The type to use in the copy constructor and assignment operator. */
typedef typename utils::treference_type<const T>::type rhs_type;
void copy(rhs_type /*rhs*/)
void copy(rhs_type /*rhs*/)
{
BOOST_STATIC_ASSERT(sizeof(T) == 0);
}
@ -99,11 +99,11 @@ public:
/** The type to use in the copy constructor and assignment operator. */
typedef typename utils::treference_type<const T>::type rhs_type;
void copy(rhs_type /*rhs*/)
{
void copy(rhs_type /*rhs*/)
{
#if COPY_POLICY_DEBUG
std::cerr << __func__ << ".\n";
#endif
#endif
}
};
@ -120,13 +120,13 @@ public:
/** The type to use in the copy constructor and assignment operator. */
typedef typename utils::treference_type<const T>::type rhs_type;
void copy(rhs_type rhs)
{
void copy(rhs_type rhs)
{
#if COPY_POLICY_DEBUG
std::cerr << __func__ << ".\n";
#endif
#endif
if(&rhs != this) {
static_cast<typename utils::treference_type<T>::type>(*this).clone();
static_cast<typename utils::treference_type<T>::type>(*this).clone();
}
}
};
@ -146,10 +146,10 @@ public:
typedef typename utils::treference_type<T>::type rhs_type;
void copy(rhs_type rhs)
{
{
#if COPY_POLICY_DEBUG
std::cerr << __func__ << ".\n";
#endif
#endif
if(&rhs != this) {
rhs.invalidate();
}
@ -159,23 +159,23 @@ public:
/**
* Helper class to add a policy to an existing class.
*
* This
* This
*/
template <
class base,
template<class> class copy_policy
template<class> class copy_policy
>
struct tcopy_policy : public base, public copy_policy<tcopy_policy<base, copy_policy> >
{
typedef copy_policy<tcopy_policy<base, copy_policy> > policy;
/*
/*
* This typedef first was
* typedef typename tcopy_policy<base, copy_policy>::rhs_type rhs_type;
*
* Unfortunately MSVC 2008 chokes on it and aborts with an internal
* compiler error. So used another name for the type.
*/
typedef typename tcopy_policy<base, copy_policy>::rhs_type
typedef typename tcopy_policy<base, copy_policy>::rhs_type
tcopy_policy_rhs_type;
tcopy_policy()
@ -187,17 +187,17 @@ struct tcopy_policy : public base, public copy_policy<tcopy_policy<base, copy_po
#endif
}
tcopy_policy(tcopy_policy_rhs_type rhs)
tcopy_policy(tcopy_policy_rhs_type rhs)
: base(rhs)
, policy(rhs)
{
{
#if COPY_POLICY_DEBUG
std::cerr << "tcopy_policy: copy constructor.\n";
#endif
copy(rhs);
copy(rhs);
}
tcopy_policy& operator=(tcopy_policy_rhs_type rhs)
tcopy_policy& operator=(tcopy_policy_rhs_type rhs)
{
#if COPY_POLICY_DEBUG
std::cerr << "tcopy_policy: assignment operator.\n";

View file

@ -32,7 +32,7 @@ struct manager
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NO_CURSOR, NUM_CURSORS };
/**
* This function uses temporary the b&w cursors while the display is busy.
* This function uses temporary the b&w cursors while the display is busy.
* If used, the colour-cursors will be reused when the display is ready again.
*/
void temporary_use_bw();

View file

@ -373,14 +373,14 @@ class save_preview_pane : public gui::preview_pane
{
public:
save_preview_pane(CVideo &video, const config& game_config, gamemap* map,
const std::vector<save_info>& info,
const std::vector<config*>& summaries,
const std::vector<save_info>& info,
const std::vector<config*>& summaries,
const gui::filter_textbox& textbox) :
gui::preview_pane(video),
game_config_(&game_config),
map_(map), info_(&info),
summaries_(&summaries),
index_(0),
gui::preview_pane(video),
game_config_(&game_config),
map_(map), info_(&info),
summaries_(&summaries),
index_(0),
map_cache_(),
textbox_(textbox)
{
@ -497,7 +497,7 @@ void save_preview_pane::draw_contents()
ypos = std::max<int>(ypos,map_rect.y + map_rect.h + save_preview_border);
SDL_BlitSurface(map_surf,NULL,screen,&map_rect);
}
char* old_locale = std::setlocale(LC_TIME, get_locale().localename.c_str());
char time_buf[256] = {0};
const save_info& save = (*info_)[index_];
@ -687,7 +687,7 @@ std::string load_game_dialog(display& disp, const config& game_config, bool* sho
delete_save save_deleter(disp,*filter,games,summaries);
gui::dialog_button_info delete_button(&save_deleter,_("Delete Save"));
lmenu.add_button(delete_button,
game_config::small_gui ? gui::dialog::BUTTON_HELP : gui::dialog::BUTTON_EXTRA);
@ -908,16 +908,16 @@ void unit_preview_pane::draw_contents()
}
}
units_list_preview_pane::units_list_preview_pane(game_display& disp,
units_list_preview_pane::units_list_preview_pane(game_display& disp,
const gamemap* map, const unit& u, TYPE type, bool on_left_side) :
unit_preview_pane(disp, map, NULL, type, on_left_side),
unit_preview_pane(disp, map, NULL, type, on_left_side),
units_(&unit_store_),
unit_store_(1, u)
{
}
units_list_preview_pane::units_list_preview_pane(game_display& disp,
const gamemap* map, std::vector<unit>& units,
units_list_preview_pane::units_list_preview_pane(game_display& disp,
const gamemap* map, std::vector<unit>& units,
const gui::filter_textbox* filter, TYPE type, bool on_left_side) :
unit_preview_pane(disp, map, filter, type, on_left_side),
units_(&units),
@ -1005,7 +1005,7 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
det.type_name = t->type_name();
det.level = t->level();
det.alignment = unit_type::alignment_description(t->alignment(), t->genders().front());
race_map const& rcm = unit_type_data::types().races();
race_map::const_iterator ri = rcm.find(t->race());
if(ri != rcm.end()) {

View file

@ -75,24 +75,24 @@ namespace {
}
display::display(CVideo& video, const gamemap* map, const config& theme_cfg, const config& cfg, const config& level) :
screen_(video),
map_(map),
viewpoint_(NULL),
xpos_(0),
screen_(video),
map_(map),
viewpoint_(NULL),
xpos_(0),
ypos_(0),
theme_(theme_cfg, screen_area()),
zoom_(DefaultZoom),
zoom_(DefaultZoom),
last_zoom_(SmallZoom),
builder_(new terrain_builder(cfg, level, map, theme_.border().tile_image)),
minimap_(NULL),
minimap_(NULL),
minimap_location_(empty_rect),
redrawMinimap_(false),
redrawMinimap_(false),
redraw_background_(true),
invalidateAll_(true),
invalidateAll_(true),
grid_(false),
diagnostic_label_(0),
diagnostic_label_(0),
panelsDrawn_(false),
turbo_speed_(2),
turbo_speed_(2),
turbo_(false),
invalidateGameStatus_(true),
map_labels_(new map_labels(*this, 0)),
@ -111,11 +111,11 @@ display::display(CVideo& video, const gamemap* map, const config& theme_cfg, con
mouseoverHex_(),
highlighted_locations_(),
keys_(),
#if TDRAWING_BUFFER_USES_VECTOR
#if TDRAWING_BUFFER_USES_VECTOR
drawing_buffer_(LAYER_LAST_LAYER),
#else
#else
drawing_buffer_(),
#endif
#endif
map_screenshot_(false),
fps_handle_(0),
idle_anim_(preferences::idle_anim()),
@ -278,7 +278,7 @@ const map_location display::pixel_position_to_hex(int x, int y) const
return map_location(x_base + x_modifier - offset, y_base + y_modifier - offset);
// NOTE: This code to get nearest_hex and second_nearest_hex
// is not used anymore. However, it can be usefull later.
// So, keep it here for the moment.
@ -438,7 +438,7 @@ map_location display::minimap_location_on(int x, int y)
loc.x = 0;
else if (loc.x >= get_map().w())
loc.x = get_map().w() - 1;
if (loc.y < 0)
loc.y = 0;
else if (loc.y >= get_map().h())
@ -463,7 +463,7 @@ int display::screenshot(std::string filename, bool map_screenshot)
SDL_Rect area = max_map_area();
map_screenshot_surf_ = create_compatible_surface(screen_.getSurface(), area.w, area.h);
if (map_screenshot_surf_ == NULL) {
// Memory problem ?
std::cerr << "Can't create the screenshot surface. Maybe too big, try dezooming.\n";
@ -521,7 +521,7 @@ void display::create_buttons()
const std::vector<theme::menu>& buttons = theme_.menus();
for(std::vector<theme::menu>::const_iterator i = buttons.begin(); i != buttons.end(); ++i) {
gui::button b(screen_,i->title(),string_to_button_type(i->type()),i->image());
DBG_DP << "drawing button " << i->get_id() << "\n";
DBG_DP << "drawing button " << i->get_id() << "\n";
b.set_id(i->get_id());
const SDL_Rect& loc = i->location(screen_area());
b.set_location(loc.x,loc.y);
@ -698,27 +698,27 @@ void display::drawing_buffer_commit()
clip_rect_setter set_clip_rect(dst, clip_rect);
// Simply go down all levels in the drawing_buffer_ and render them.
for(tdrawing_buffer::const_iterator
layer_itor = drawing_buffer_.begin(),
for(tdrawing_buffer::const_iterator
layer_itor = drawing_buffer_.begin(),
layer_itor_end = drawing_buffer_.end();
layer_itor != layer_itor_end; ++layer_itor) {
for(std::map<int, std::vector<tblit> >::const_iterator
#if TDRAWING_BUFFER_USES_VECTOR
for(std::map<int, std::vector<tblit> >::const_iterator
#if TDRAWING_BUFFER_USES_VECTOR
drawing_iterator = layer_itor->begin(),
drawing_iterator_end = layer_itor->end();
#else
#else
drawing_iterator = layer_itor->second.begin(),
drawing_iterator_end = layer_itor->second.end();
#endif
#endif
drawing_iterator != drawing_iterator_end; ++drawing_iterator) {
for(std::vector<tblit>::const_iterator
for(std::vector<tblit>::const_iterator
blit_itor = drawing_iterator->second.begin(),
blit_itor_end = drawing_iterator->second.end();
blit_itor != blit_itor_end; ++blit_itor) {
for(std::vector<surface>::const_iterator
for(std::vector<surface>::const_iterator
surface_itor = blit_itor->surf.begin(),
surface_itor_end = blit_itor->surf.end();
surface_itor != surface_itor_end; ++surface_itor) {
@ -728,7 +728,7 @@ void display::drawing_buffer_commit()
// to pass to each call to SDL_BlitSurface.
SDL_Rect dstrect = { blit_itor->x, blit_itor->y, 0, 0 };
if(blit_itor->clip.x || blit_itor->clip.y
if(blit_itor->clip.x || blit_itor->clip.y
||blit_itor->clip.w ||blit_itor->clip.h) {
SDL_Rect srcrect = blit_itor->clip;
@ -749,16 +749,16 @@ void display::drawing_buffer_clear()
{
#if TDRAWING_BUFFER_USES_VECTOR
// Note clear the items, the vector should remain the same size.
for(tdrawing_buffer::iterator layer_itor =
drawing_buffer_.begin(),
for(tdrawing_buffer::iterator layer_itor =
drawing_buffer_.begin(),
layer_itor_end = drawing_buffer_.end();
layer_itor != layer_itor_end; ++layer_itor) {
layer_itor->clear();
}
#else
#else
drawing_buffer_.clear();
#endif
#endif
}
void display::sunset(const size_t delay)
@ -841,13 +841,13 @@ static void draw_panel(CVideo& video, const theme::panel& panel, std::vector<gui
{
//log_scope("draw panel");
DBG_DP << "drawing panel " << panel.get_id() << "\n";
surface surf(image::get_image(panel.image()));
const SDL_Rect screen = screen_area();
SDL_Rect& loc = panel.location(screen);
DBG_DP << "panel location: x=" << loc.x << ", y=" << loc.y
DBG_DP << "panel location: x=" << loc.x << ", y=" << loc.y
<< ", w=" << loc.w << ", h=" << loc.h << "\n";
if(!surf.null()) {
@ -960,7 +960,7 @@ static void draw_background(surface screen, const SDL_Rect& area, const std::str
}
}
void display::draw_text_in_hex(const map_location& loc,
void display::draw_text_in_hex(const map_location& loc,
const tdrawing_layer layer, const std::string& text,
size_t font_size, SDL_Color color, double x_in_hex, double y_in_hex)
{
@ -1001,7 +1001,7 @@ void display::clear_hex_overlay(const map_location& loc)
}
}
void display::render_unit_image(int x, int y,const display::tdrawing_layer drawing_layer,
void display::render_unit_image(int x, int y,const display::tdrawing_layer drawing_layer,
const int drawing_order, surface image,
bool hreverse, bool greyscale, fixed_t alpha,
Uint32 blendto, double blend_ratio, double submerged,bool vreverse)
@ -1046,7 +1046,7 @@ void display::render_unit_image(int x, int y,const display::tdrawing_layer drawi
const int submerge_height = std::min<int>(surf->h,std::max<int>(0,int(surf->h*(1.0-submerged))));
SDL_Rect srcrect = {0,0,surf->w,submerge_height};
drawing_buffer_add(drawing_layer, drawing_order, tblit(x, y, surf, srcrect));
@ -1205,7 +1205,7 @@ void display::enable_menu(const std::string& item, bool enable)
if(index >= buttons_.size()) {
assert(false);
return;
}
}
buttons_[index].enable(enable);
}
}
@ -1640,7 +1640,7 @@ void display::scroll_to_tiles(const std::vector<map_location>& locs,
if (scroll_type == ONSCREEN) {
// when doing an ONSCREEN scroll we do not center the target unless needed
SDL_Rect r = map_area();
SDL_Rect r = map_area();
int map_center_x = r.x + r.w/2;
int map_center_y = r.y + r.h/2;
@ -1790,17 +1790,17 @@ void display::redraw_everything()
labels().recalculate_labels();
redraw_background_ = true;
int ticks1 = SDL_GetTicks();
invalidate_all();
int ticks2 = SDL_GetTicks();
draw(true,true);
int ticks3 = SDL_GetTicks();
INFO_DP << "invalidate and draw: " << (ticks3 - ticks2) << " and " << (ticks2 - ticks1) << "\n";
foreach (boost::function<void(display&)> f, redraw_observers_) {
f(*this);
}
}
}
void display::add_redraw_observer(boost::function<void(display&)> f)
@ -1825,14 +1825,14 @@ void display::draw(bool update,bool force) {
update_time_of_day();
if(!get_map().empty()) {
//int simulate_delay = 0;
/*
/*
* draw_invalidated() also invalidates the halos, so also needs to be
* ran if invalidated_.empty() == true.
*/
if(!invalidated_.empty() || preferences::show_haloes()) {
changed = true;
draw_invalidated();
draw_invalidated();
invalidated_.clear();
}
drawing_buffer_commit();
@ -1860,7 +1860,7 @@ void display::clear_screen()
{
surface const disp(screen_.getSurface());
SDL_Rect area = screen_area();
SDL_FillRect(disp, &area, SDL_MapRGB(disp->format, 0, 0, 0));
SDL_FillRect(disp, &area, SDL_MapRGB(disp->format, 0, 0, 0));
}
const SDL_Rect& display::get_clip_rect()
@ -1881,12 +1881,12 @@ void display::draw_invalidated() {
SDL_Rect hex_rect = {xpos, ypos, zoom_, zoom_};
if(!rects_overlap(hex_rect,clip_rect)) {
continue;
}
}
draw_hex(loc);
// If the tile is at the border, we start to blend it
if(!on_map && !off_map_tile) {
draw_border(loc, xpos, ypos);
}
}
}
}
@ -1895,7 +1895,7 @@ void display::draw_hex(const map_location& loc) {
int ypos = get_location_y(loc);
int drawing_order = loc.get_drawing_order();
image::TYPE image_type = get_image_type(loc);
const bool on_map = get_map().on_board(loc);
const bool on_map = get_map().on_board(loc);
const bool off_map_tile = (get_map().get_terrain(loc) == t_translation::OFF_MAP_USER);
if(!shrouded(loc)) {
// unshrouded terrain (the normal case)
@ -1908,7 +1908,7 @@ void display::draw_hex(const map_location& loc) {
get_terrain_images(loc,tod_.id,image_type,ADJACENT_FOREGROUND)));
// drawing_buffer_add(LAYER_TERRAIN_FG, drawing_order, tblit(xpos, ypos,
// get_terrain_images(*it,tod.id,image_type,ADJACENT_FOREGROUND)));
// Draw the grid, if that's been enabled
if(grid_ && on_map && !off_map_tile) {
drawing_buffer_add(LAYER_TERRAIN_TMP_BG, drawing_order, tblit(xpos, ypos,
@ -1931,7 +1931,7 @@ void display::draw_hex(const map_location& loc) {
if(loc == mouseoverHex_ && (on_map || (in_editor() && get_map().on_board_with_border(loc))) && mouseover_hex_overlay_ != NULL) {
drawing_buffer_add(LAYER_TERRAIN_TMP_BG, drawing_order, tblit(xpos, ypos, mouseover_hex_overlay_));
}
// Apply shroud, fog and linger overlay
if(shrouded(loc)) {
// We apply void also on off-map tiles
@ -1956,7 +1956,7 @@ void display::draw_hex(const map_location& loc) {
SDL_Rect bg_rect = {0, 0, text->w, text->h};
SDL_FillRect(bg, &bg_rect, 0xaa000000);
off_x -= text->w / 2;
if (draw_terrain_codes_) {
if (draw_terrain_codes_) {
off_y -= text->h;
} else {
off_y -= text->h / 2;
@ -1972,13 +1972,13 @@ void display::draw_hex(const map_location& loc) {
SDL_Rect bg_rect = {0, 0, text->w, text->h};
SDL_FillRect(bg, &bg_rect, 0xaa000000);
off_x -= text->w / 2;
if (!draw_coordinates_) {
if (!draw_coordinates_) {
off_y -= text->h / 2;
}
drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, bg));
drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, text));
}
}
}
}
image::TYPE display::get_image_type(const map_location& /*loc*/) {
@ -1990,7 +1990,7 @@ void display::update_time_of_day() {
}
void display::draw_sidebar() {
}
@ -2203,7 +2203,7 @@ bool display::invalidate(const map_location& loc)
{
if(invalidateAll_)
return false;
return invalidated_.insert(loc).second;
}
@ -2236,7 +2236,7 @@ bool display::rectangle_need_update(const SDL_Rect& rect) const
{
if(invalidateAll_)
return true;
rect_of_hexes hexes = hexes_under_rect(rect);
rect_of_hexes::iterator i = hexes.begin(), end = hexes.end();
for (;i != end; ++i) {

View file

@ -12,8 +12,8 @@
See the COPYING file for more details.
*/
/**
* @file display.hpp
/**
* @file display.hpp
*
* map_display and display: classes which take care of
* displaying the map and game-data on the screen.
@ -68,15 +68,15 @@ public:
display(CVideo& video, const gamemap* map, const config& theme_cfg,
const config& cfg, const config& level);
virtual ~display();
/**
* Updates internals that cache map size. This should be called when the map
/**
* Updates internals that cache map size. This should be called when the map
* size has changed.
*/
void reload_map();
void change_map(const gamemap* m);
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
@ -185,7 +185,7 @@ public:
int left;
int right;
int top[2]; // for even and odd values of x, respectively
int bottom[2];
int bottom[2];
/** very simple iterator to walk into the rect_of_hexes */
struct iterator {
@ -217,7 +217,7 @@ public:
return viewpoint_ && viewpoint_->shrouded(loc);
}
/** Returns true if location (x,y) is covered in fog. */
bool fogged(const map_location& loc) const {
bool fogged(const map_location& loc) const {
return viewpoint_ && viewpoint_->fogged(loc);
}
@ -226,26 +226,26 @@ public:
* (to more clearly show where hexes are)
*/
void set_grid(const bool grid) { grid_ = grid; }
/** Getter for the x,y debug overlay on tiles */
bool get_draw_coordinates() { return draw_coordinates_; }
/** Setter for the x,y debug overlay on tiles */
void set_draw_coordinates(bool value) { draw_coordinates_ = value; }
/** Getter for the terrain code debug overlay on tiles */
bool get_draw_terrain_codes() { return draw_terrain_codes_; }
/** Setter for the terrain code debug overlay on tiles */
void set_draw_terrain_codes(bool value) { draw_terrain_codes_ = value; }
void set_draw_terrain_codes(bool value) { draw_terrain_codes_ = value; }
/** Save a (map-)screenshot and return the estimated file size */
int screenshot(std::string filename, bool map_screenshot = false);
/** Invalidates entire screen, including all tiles and sidebar. Calls redraw observers. */
void redraw_everything();
/** Adds a redraw observer, a function object to be called when redraw_everything is used */
void add_redraw_observer(boost::function<void(display&)> f);
/** Clear the redraw observers */
void clear_redraw_observers();
@ -260,15 +260,15 @@ public:
// Will be overridden in the display subclass
virtual void draw_minimap_units() {};
/** Function to invalidate all tiles. */
void invalidate_all();
/** Function to invalidate a specific tile for redrawing. */
bool invalidate(const map_location& loc);
bool invalidate(const std::set<map_location>& locs);
/** invalidate all hexes under the rectangle rect (in screen coordinates) */
bool invalidate_locations_in_rect(const SDL_Rect& rect);
@ -279,7 +279,7 @@ public:
* Function to invalidate animated terrains which may have changed.
*/
virtual void invalidate_animations();
/**
* Per-location invalidation called by invalidate_animations()
* defaults to no action, overriden by derived classes
@ -298,21 +298,21 @@ public:
* These functions require a prerendered surface.
* Since they are drawn at the top, they are not influenced by TOD, shroud etc.
*/
void set_hex_overlay(const map_location& loc, const surface& image)
void set_hex_overlay(const map_location& loc, const surface& image)
{ hex_overlay_[loc] = image; }
void clear_hex_overlay(const map_location& loc);
void set_selected_hex_overlay(const surface& image)
void set_selected_hex_overlay(const surface& image)
{ selected_hex_overlay_ = image; }
void clear_selected_hex_overlay()
void clear_selected_hex_overlay()
{ selected_hex_overlay_ = NULL; }
void set_mouseover_hex_overlay(const surface& image)
void set_mouseover_hex_overlay(const surface& image)
{ mouseover_hex_overlay_ = image; }
void clear_mouseover_hex_overlay()
void clear_mouseover_hex_overlay()
{ mouseover_hex_overlay_ = NULL; }
/**
@ -336,7 +336,7 @@ public:
void rebuild_all();
const theme::menu* menu_pressed();
/**
* Finds the menu which has a given item in it,
* and enables or disables it.
@ -347,7 +347,7 @@ public:
/** Delay routines: use these not SDL_Delay (for --nogui). */
void delay(unsigned int milliseconds) const;
/**
* Set/Get whether 'turbo' mode is on.
* When turbo mode is on, everything moves much faster.
@ -429,7 +429,7 @@ public:
/** Check if a tile is fully on screen. */
bool tile_on_screen(const map_location& loc);
/**
/**
* Draws invalidated items.
* If update is true, will also copy the display to the frame buffer.
* If force is true, will not skip frames, even if running behind.
@ -477,13 +477,13 @@ protected:
* invalidated hexes takes place. No action here by default.
*/
virtual void pre_draw() {}
/**
* Get the clipping rectangle for drawing.
* Virtual since the editor might use a slightly different approach.
*/
virtual const SDL_Rect& get_clip_rect();
/**
* Only called when there's actual redrawing to do. Loops through
* invalidated locations and redraws them. Derived classes can override
@ -491,18 +491,18 @@ protected:
* base class's function.
*/
virtual void draw_invalidated();
/**
* Hook for actions to take right after draw() calls drawing_buffer_commit
* No action here by default.
*/
virtual void post_commit() {}
virtual void post_commit() {}
/**
* Redraws a single gamemap location.
*/
virtual void draw_hex(const map_location& loc);
/**
* @returns the image type to be used for the passed hex
* (mostly to do with brightening like for mouseover)
@ -513,13 +513,13 @@ protected:
* Update time of day member to the tod to be used in the current drawing
*/
virtual void update_time_of_day();
/**
* Called near the end of a draw operation, derived classes can use this
* Called near the end of a draw operation, derived classes can use this
* to render a specific sidebar. Very similar to post_commit.
*/
virtual void draw_sidebar();
/**
* Draws the border tile overlay.
* The routine determines by itself which border it is on
@ -626,7 +626,7 @@ public:
int x; /**< x screen coordinate to render at. */
int y; /**< y screen coordinate to render at. */
std::vector<surface> surf; /**< surface(s) to render. */
SDL_Rect clip; /**<
SDL_Rect clip; /**<
* The clipping area of the source if
* ommitted the entire source is used.
*/
@ -639,35 +639,35 @@ public:
* If needed in WML use the name and map that to the enum value.
*/
enum tdrawing_layer{
LAYER_TERRAIN_BG, /**<
LAYER_TERRAIN_BG, /**<
* Layer for the terrain drawn behind the
* unit.
*/
LAYER_TERRAIN_TMP_BG, /**<
LAYER_TERRAIN_TMP_BG, /**<
* Layer which holds stuff that needs to be
* sorted out further, but under units.
*/
LAYER_UNIT_FIRST, /**< Reserve layeres to be selected for WML. */
LAYER_UNIT_BG = LAYER_UNIT_FIRST+10, /**< Used for the ellipse behind the unit. */
LAYER_UNIT_DEFAULT=LAYER_UNIT_FIRST+40,/**<default layer for drawing units */
LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50, /**<
LAYER_TERRAIN_FG = LAYER_UNIT_FIRST+50, /**<
* Layer for the terrain drawn in front of
* the unit.
*/
LAYER_UNIT_MOVE_DEFAULT=LAYER_UNIT_FIRST+60/**<default layer for drawing moving units */,
LAYER_UNIT_FG = LAYER_UNIT_FIRST+80, /**<
LAYER_UNIT_FG = LAYER_UNIT_FIRST+80, /**<
* Used for the ellipse in front of the
* unit.
*/
LAYER_UNIT_MISSILE_DEFAULT = LAYER_UNIT_FIRST+90, /**< default layer for missile frames*/
LAYER_UNIT_LAST=LAYER_UNIT_FIRST+100,
LAYER_TERRAIN_TMP_FG, /**<
LAYER_TERRAIN_TMP_FG, /**<
* Layer which holds stuff that needs to be
* sorted out further, but on top of units.
*/
LAYER_REACHMAP, /**< "black stripes" on unreachable hexes. */
LAYER_FOG_SHROUD, /**< Fog and shroud. */
LAYER_UNIT_BAR, /**<
LAYER_UNIT_BAR, /**<
* Unit bars and overlays are drawn on this
* layer (for testing here).
*/
@ -676,7 +676,7 @@ public:
LAYER_LINGER_OVERLAY, /**< The overlay used for the linger mode. */
LAYER_BORDER, /**< The border of the map. */
LAYER_LAST_LAYER /**<
LAYER_LAST_LAYER /**<
* Don't draw to this layer it's a dummy to
* size the vector.
*/
@ -794,9 +794,9 @@ private:
double idle_anim_rate_;
surface map_screenshot_surf_;
std::vector<boost::function<void(display&)> > redraw_observers_;
/** Debug flag - overlay x,y coords on tiles */
bool draw_coordinates_;
/** Debug flag - overlay terrain codes on tiles */

View file

@ -180,7 +180,7 @@ editor_action_paste* editor_action_paint_area::perform(map_context& mc) const
std::auto_ptr<editor_action_paste> undo(new editor_action_paste(mf));
perform_without_undo(mc);
return undo.release();
}
}
void editor_action_paint_area::perform_without_undo(map_context& mc) const
{
mc.draw_terrain(t_, area_, one_layer_);
@ -300,8 +300,8 @@ editor_action_deselect* editor_action_select_all::perform(map_context& mc) const
mc.get_map().select_all();
std::set<map_location> all = mc.get_map().selection();
std::set<map_location> undo_locs;
std::set_difference(all.begin(), all.end(),
current.begin(), current.end(),
std::set_difference(all.begin(), all.end(),
current.begin(), current.end(),
std::inserter(undo_locs, undo_locs.begin()));
mc.set_everything_changed();
return new editor_action_deselect(undo_locs);

View file

@ -65,8 +65,8 @@ class editor_action_extendable : public editor_action
{
}
/**
* The crux of the extendable contract. This member function must be
* implemented so that the undo behaviour is consistent, exactly the
* The crux of the extendable contract. This member function must be
* implemented so that the undo behaviour is consistent, exactly the
* same as would be with separate undo actions for every part of
* the drag.
*/
@ -74,7 +74,7 @@ class editor_action_extendable : public editor_action
};
/**
* Container action wrapping several actions into one.
* Container action wrapping several actions into one.
* The actions are performed in the order they are added,
* i.e. in the usual iteration order through the container.
*/
@ -88,7 +88,7 @@ class editor_action_chain : public editor_action
actions_()
{
}
/**
* Create an action chain from a deque of action pointers.
* Note: the action chain assumes ownership of the pointers.
@ -97,7 +97,7 @@ class editor_action_chain : public editor_action
: actions_(actions)
{
}
/**
* Create an action chain by wrapping around a single action pointer.
* Note: the action chain assumes ownership of the pointer.
@ -106,22 +106,22 @@ class editor_action_chain : public editor_action
: actions_(1, action)
{
}
/**
* The destructor deletes all the owned action pointers
*/
~editor_action_chain();
/**
* Go through the chain and add up all the action counts
*/
int action_count() const;
/**
* Add an action at the end of the chain
*/
void append_action(editor_action* a);
/**
* Add an action at the beginning of the chain
*/
@ -133,13 +133,13 @@ class editor_action_chain : public editor_action
* "empty" actions around.
*/
bool empty() const;
/**
* Remove the last added action and return it, transfering
* ownership to the caller
*/
editor_action* pop_last_action();
/**
* Remove the first added action and return it, transfering
* ownership to the caller
@ -150,12 +150,12 @@ class editor_action_chain : public editor_action
* Perform all the actions in order and create a undo action chain
*/
editor_action_chain* perform(map_context& m) const;
/**
* Perform all the actions in order
*/
void perform_without_undo(map_context& m) const;
protected:
/**
* The action pointers owned by this action chain
@ -164,8 +164,8 @@ class editor_action_chain : public editor_action
};
/**
* Base class for actions which act on a specified location (and possibly on other locations
/**
* Base class for actions which act on a specified location (and possibly on other locations
* that can be derived from the staring hex)
*/
class editor_action_location : public editor_action
@ -179,13 +179,13 @@ class editor_action_location : public editor_action
map_location loc_;
};
/** Base class for actions which in addition to acting on a hex,
/** Base class for actions which in addition to acting on a hex,
* act with one terrain type, i.e. paint-related actions.
*/
class editor_action_location_terrain : public editor_action_location
{
public:
editor_action_location_terrain(map_location loc,
editor_action_location_terrain(map_location loc,
t_translation::t_terrain t)
: editor_action_location(loc), t_(t)
{
@ -230,7 +230,7 @@ class editor_action_paste : public editor_action_extendable
};
/**
* Draw -- replace a hex at a given location with a given terrain. Since this is
* Draw -- replace a hex at a given location with a given terrain. Since this is
* a lot simpler than a brush paint, it is separate at least for now
* (it is somewhat redundant)
*/
@ -241,7 +241,7 @@ class editor_action_paint_hex : public editor_action_location_terrain
: editor_action_location_terrain(loc, t)
{
}
editor_action_paint_hex* perform(map_context& mc) const;
editor_action_paint_hex* perform(map_context& mc) const;
void perform_without_undo(map_context& mc) const;
};
@ -251,7 +251,7 @@ class editor_action_paint_hex : public editor_action_location_terrain
class editor_action_paint_area : public editor_action_area
{
public:
editor_action_paint_area(const std::set<map_location>& area,
editor_action_paint_area(const std::set<map_location>& area,
t_translation::t_terrain t, bool one_layer=false)
: editor_action_area(area), t_(t), one_layer_(one_layer)
{
@ -269,7 +269,7 @@ class editor_action_paint_area : public editor_action_area
class editor_action_fill : public editor_action_location_terrain
{
public:
editor_action_fill(map_location loc,
editor_action_fill(map_location loc,
t_translation::t_terrain t, bool one_layer=false)
: editor_action_location_terrain(loc, t), one_layer_(one_layer)
{
@ -431,7 +431,7 @@ class editor_action_create_mask : public editor_action
class editor_action_plot_route : public editor_action_location_terrain
{
public:
editor_action_plot_route(map_location l1,
editor_action_plot_route(map_location l1,
t_translation::t_terrain t, map_location l2)
: editor_action_location_terrain(l1, t)
, loc2_(l2)

View file

@ -16,11 +16,11 @@
* @file action_base.hpp
* Base class for editor actions
*
* An action is constructed in response to a user command, then executed on
* An action is constructed in response to a user command, then executed on
* the map. An undo action is returned by default via pointer, caller-owned).
* It is possible to call an action without creating the undo action.
* Actions report failure via exceptions.
* Code that only deals with actions polymorphically should only need to
* Code that only deals with actions polymorphically should only need to
* include this header file.
*/
@ -48,7 +48,7 @@ class editor_action
public:
editor_action();
virtual ~editor_action();
/**
* Perform the action, returning an undo action that,
* when performed, shall reverse any effects of this
@ -58,17 +58,17 @@ class editor_action
* return the undo object.
*/
virtual editor_action* perform(map_context&) const;
/**
* Perform the action without creating an undo action.
*/
virtual void perform_without_undo(map_context&) const = 0;
/**
* @return the actual number of actions contained within
*/
virtual int action_count() const;
/**
* A textual description of the action. For use
* e.g. in the undo menu, to have a "Undo: Fill with
@ -77,17 +77,17 @@ class editor_action
* message.
*/
virtual std::string get_description();
/**
* Debugging aid. Return an unique identifier of this Action.
*/
int get_id() const { return id_; }
/**
* Debugging aid. Return number of existing instances of Actions.
*/
static int get_instance_count() { return instance_count_; }
private:
static int next_id_;
static int instance_count_;
@ -98,7 +98,7 @@ class editor_action
//TODO: add messages etc
struct editor_action_exception : public editor_exception
{
editor_action_exception(const std::string& msg)
editor_action_exception(const std::string& msg)
: editor_exception(msg)
{
}

View file

@ -34,12 +34,12 @@ public:
* Construct a default (empty) brush. Note that not even the hotspot is affected by default,
*/
brush();
/**
* Construct a brush object from config
*/
explicit brush(const config& cfg);
/**
* Add a location to the brush. If it already exists nothing will change.
*/
@ -50,23 +50,23 @@ public:
* is in given location
*/
std::set<map_location> project(const map_location& hotspot) const;
/**
* @return the name of this brush
*/
const std::string name() const { return name_; }
/**
* @return the image of this brush
*/
const std::string image() const { return image_; }
protected:
/**
* The relative locations of the brush
*/
std::set<map_location> relative_tiles_;
std::string name_;
std::string image_;
};

View file

@ -12,9 +12,9 @@
See the COPYING file for more details.
*/
/**
/**
* @file editor_common.hpp
* Main (common) editor header. Contains forward declarations for most classes,
* Main (common) editor header. Contains forward declarations for most classes,
* logging macro definitions and base exception declarations
*/

View file

@ -117,7 +117,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video, m
init_tods(game_config);
init_sidebar(game_config);
init_music(game_config);
hotkey_set_mouse_action(hotkey::HOTKEY_EDITOR_TOOL_PAINT);
hotkey_set_mouse_action(hotkey::HOTKEY_EDITOR_TOOL_PAINT);
rng_.reset(new rand_rng::rng());
rng_setter_.reset(new rand_rng::set_random_generator(rng_.get()));
hotkey::get_hotkey(hotkey::HOTKEY_QUIT_GAME).set_description(_("Quit Editor"));
@ -125,7 +125,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video, m
cursor::set(cursor::NORMAL);
image::set_colour_adjustment(preferences::editor_r(), preferences::editor_g(), preferences::editor_b());
refresh_all();
events::raise_draw_event();
events::raise_draw_event();
}
void editor_controller::init_gui(CVideo& video)
@ -164,11 +164,11 @@ void editor_controller::init_brushes(const config& game_config)
void editor_controller::init_mouse_actions(const config& game_config)
{
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT,
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT,
new mouse_action_paint(foreground_terrain_, background_terrain_, &brush_, key_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL,
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL,
new mouse_action_fill(foreground_terrain_, background_terrain_, key_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
new mouse_action_select(&brush_, key_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION,
new mouse_action_starting_position(key_)));
@ -187,7 +187,7 @@ void editor_controller::init_mouse_actions(const config& game_config)
if (i != mouse_actions_.end()) {
mouse_action_hints_.insert(std::make_pair(i->first, (*c)["text"]));
}
}
}
}
void editor_controller::init_map_generators(const config& game_config)
@ -312,13 +312,13 @@ void editor_controller::close_current_context()
if (map_contexts_.size() == 1) {
create_default_context();
map_contexts_.erase(map_contexts_.begin());
} else if (current_context_index_ ==
} else if (current_context_index_ ==
static_cast<int>(map_contexts_.size()) - 1) {
map_contexts_.pop_back();
current_context_index_--;
} else {
map_contexts_.erase(map_contexts_.begin() + current_context_index_);
map_contexts_.erase(map_contexts_.begin() + current_context_index_);
}
map_context_refresher(*this, *current);
delete current;
@ -354,7 +354,7 @@ void editor_controller::editor_settings_dialog()
image::colour_adjustment_resetter adjust_resetter;
dialog.set_use_mdi(use_mdi_);
dialog.show(gui().video());
int res = dialog.get_retval();
if(res == gui2::twindow::OK) {
image::set_colour_adjustment(dialog.get_red(), dialog.get_green(), dialog.get_blue());
@ -412,7 +412,7 @@ void editor_controller::new_map_dialog()
gui2::teditor_new_map dialog;
dialog.set_map_width(get_map().w());
dialog.set_map_height(get_map().h());
dialog.show(gui().video());
int res = dialog.get_retval();
if(res == gui2::twindow::OK) {
@ -526,7 +526,7 @@ void editor_controller::resize_map_dialog()
dialog.set_map_height(get_map().h());
dialog.set_old_map_width(get_map().w());
dialog.set_old_map_height(get_map().h());
dialog.show(gui().video());
int res = dialog.get_retval();
if(res == gui2::twindow::OK) {
@ -742,7 +742,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
return true; //editor hotkeys we can always do
case HOTKEY_EDITOR_MAP_SAVE:
case HOTKEY_EDITOR_SWITCH_MAP:
case HOTKEY_EDITOR_CLOSE_MAP:
case HOTKEY_EDITOR_CLOSE_MAP:
return true;
case HOTKEY_EDITOR_MAP_REVERT:
return !get_map_context().get_filename().empty();
@ -759,7 +759,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int
return !get_map().selection().empty();
case HOTKEY_EDITOR_SELECTION_ROTATE:
case HOTKEY_EDITOR_SELECTION_FLIP:
case HOTKEY_EDITOR_SELECTION_GENERATE:
case HOTKEY_EDITOR_SELECTION_GENERATE:
return false; //not implemented
case HOTKEY_EDITOR_PASTE:
return !clipboard_.empty();
@ -870,7 +870,7 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
case HOTKEY_EDITOR_CLIPBOARD_FLIP_VERTICAL:
clipboard_.flip_vertical();
update_mouse_action_highlights();
return true;
return true;
case HOTKEY_EDITOR_BRUSH_NEXT:
cycle_brush();
return true;
@ -970,7 +970,7 @@ void editor_controller::expand_open_maps_menu(std::vector<std::string>& items)
if (filename.empty()) {
filename = _("(New Map)");
}
std::string label = "[" + lexical_cast<std::string>(mci) + "] "
std::string label = "[" + lexical_cast<std::string>(mci) + "] "
+ filename;
contexts.push_back(label);
}
@ -987,7 +987,7 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
return;
}
}
std::vector<std::string> items = items_arg;
hotkey::HOTKEY_COMMAND command;
std::vector<std::string>::iterator i = items.begin();
@ -1068,7 +1068,7 @@ void editor_controller::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command)
gui().set_report_content(reports::EDIT_LEFT_BUTTON_FUNCTION,
hotkey::get_hotkey(command).get_description());
gui().set_toolbar_hint(mouse_action_hints_[command]);
gui().invalidate_game_status();
gui().invalidate_game_status();
} else {
ERR_ED << "Invalid hotkey command (" << (int)command << ") passed to set_mouse_action\n";
}

View file

@ -60,69 +60,69 @@ class editor_map;
/**
* The editor_controller class containts the mouse and keyboard event handling
* routines for the editor. It also serves as the main editor class with the
* routines for the editor. It also serves as the main editor class with the
* general logic.
*/
class editor_controller : public controller_base,
class editor_controller : public controller_base,
public events::mouse_handler_base,
private boost::noncopyable
{
public:
/**
* The constructor. A initial map context can be specified here, the controller
* The constructor. A initial map context can be specified here, the controller
* will assume ownership and delete the pointer during destruction, but changes
* to the map can be retrieved between the main loop's end and the controller's
* destruction.
*/
editor_controller(const config &game_config, CVideo& video, map_context* init_map_context = NULL);
~editor_controller();
/** Editor main loop */
EXIT_STATUS main_loop();
/** Process a hotkey quit command */
void hotkey_quit();
/** Show a quit confirmation dialog and if confirmed quit with the given exit status */
void quit_confirm(EXIT_STATUS status);
/** Display the settings dialog, used to control e.g. the lighting settings */
void editor_settings_dialog();
/**
* Shows an are-you-sure dialog if the map was modified.
* @return true if the user confirmed or the map was not modified, false otherwise
*/
bool confirm_discard();
/** Get the current map context object */
map_context& get_map_context() { return *map_contexts_[current_context_index_]; }
/** Get the current map context object - const version */
const map_context& get_map_context() const { return *map_contexts_[current_context_index_]; }
/** Get the map from the current map context object */
editor_map& get_map() { return get_map_context().get_map(); }
/** Get the map from the current map context object - const version*/
const editor_map& get_map() const { return get_map_context().get_map(); }
/**
* Add a map context. The controller assumes ownership.
/**
* Add a map context. The controller assumes ownership.
* @return the index of the added map context in the map_contexts_ array
*/
int add_map_context(map_context* mc);
/** Creates a default map context object, used to ensure there is always at least one. */
void create_default_context();
/** Closes the active map context. Switches to a valid context afterward or creates a dummy one. */
void close_current_context();
/** Switches the context to the one under the specified index. */
void switch_context(const int index);
/** Display a load map dialog and process user input. */
void load_map_dialog();
@ -143,40 +143,40 @@ class editor_controller : public controller_base,
/** Display a load map dialog and process user input. */
void resize_map_dialog();
/**
* Save the map under a given filename.
* @return true on success
*/
bool save_map_as(const std::string& filename);
/**
* Save the map under a given filename. Displays an error message on failure.
* @return true on success
*/
bool save_map(bool display_confirmation = false);
/**
* Create a new map.
*/
void new_map(int width, int height, t_translation::t_terrain fill, bool new_context);
/**
* Load a map given the filename
*/
void load_map(const std::string& filename, bool new_context);
/**
* Revert the map by reloading it from disk
*/
void revert_map();
/**
* Reload the map after ot has significantly changed (when e.g. the dimensions changed).
* This is necessary to avoid issues with parts of the map being cached in the display class.
*/
void reload_map();
/**
* Refresh everything, i.e. invalidate all hexes and redraw them. Does *not* reload the map.
*/
@ -184,49 +184,49 @@ class editor_controller : public controller_base,
/** command_executor override */
bool can_execute_command(hotkey::HOTKEY_COMMAND, int index = -1) const;
/** command_executor override */
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const;
/** command_executor override */
bool execute_command(hotkey::HOTKEY_COMMAND command, int index = -1);
/** Menu expanding for open maps list */
void expand_open_maps_menu(std::vector<std::string>& items);
/** controller_base override */
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
/** Cycle to the next brush. */
void cycle_brush();
/** Show the preferences dialog */
void preferences();
/** Grid toggle */
void toggle_grid();
/** Copy the selection on the current map to the clipboard */
void copy_selection();
/** Cut the selection from the current map to the clipboard */
void cut_selection();
/** Fill the selection with the foreground terrain */
void fill_selection();
/**
* Set the current mouse action based on a hotkey id
*/
void hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND command);
/**
* @return true if the mouse action identified by the hotkey is active
*/
bool is_mouse_action_set(hotkey::HOTKEY_COMMAND command) const;
void update_mouse_action_highlights();
/* mouse_handler_base overrides */
void mouse_motion(int x, int y, const bool browse, bool update);
editor_display& gui() { return *gui_; }
@ -239,92 +239,92 @@ class editor_controller : public controller_base,
bool right_click(int x, int y, const bool browse);
void right_drag_end(int x, int y, const bool browse);
void right_mouse_up(int x, int y, const bool browse);
void set_mouseover_overlay();
void clear_mouseover_overlay();
protected:
/* controller_base overrides */
void process_keyup_event(const SDL_Event& event);
mouse_handler_base& get_mouse_handler_base();
editor_display& get_display();
editor_display& get_display();
/** Get the current brush */
brush* get_brush();
/** Get the current mouse action */
mouse_action* get_mouse_action();
/**
* Perform an action, then delete the action object.
* The pointer can be NULL, in which case nothing will happen.
*/
void perform_delete(editor_action* action);
/**
* Peform an action on the current map_context, then refresh the display
* Peform an action on the current map_context, then refresh the display
* and delete the pointer. The pointer can be NULL, in which case nothing will happen.
*/
void perform_refresh_delete(editor_action* action, bool drag_part = false);
/**
* Peform an action on the current map_context, then refresh the display.
*/
void perform_refresh(const editor_action& action, bool drag_part = false);
/**
* Callback for the editor settings dialog to allow on-the-fly
* Callback for the editor settings dialog to allow on-the-fly
* updating of the lighting display on the game map behing the dialog
*/
void editor_settings_dialog_redraw_callback(int r, int g, int b);
private:
/** init the display object and general set-up */
private:
/** init the display object and general set-up */
void init_gui(CVideo& video);
/** init the sidebar objects */
void init_sidebar(const config& game_config);
/** init the brushes */
void init_brushes(const config& game_config);
/** init the mouse actions (tools) */
void init_mouse_actions(const config& game_config);
/** init available random map generators */
void init_map_generators(const config& game_config);
/** init the available time-of-day settings */
void init_tods(const config& game_config);
/** init background music for the editor */
void init_music(const config& game_config);
/** Load editor-specific tooltips */
void load_tooltips();
void redraw_toolbar();
/** Reload images */
void refresh_image_cache();
/**
* Refresh the display after an action has been performed.
* Refresh the display after an action has been performed.
* The map context contains details of what needs to be refreshed.
*/
void refresh_after_action(bool drag_part = false);
/**
* Replace the current map context and refresh accordingly
*/
void replace_map_context(const map_context& new_mc);
/**
* Callback function passed to display to be called on each redraw_everything run.
* Redraws toolbar, brush bar and related items.
*/
void display_redraw_callback(display&);
/**
* Undos an action in the current map context
*/
@ -334,20 +334,20 @@ class editor_controller : public controller_base,
* Redos an action in the current map context
*/
void redo();
boost::scoped_ptr<rand_rng::rng> rng_;
boost::scoped_ptr<rand_rng::set_random_generator> rng_setter_;
/** The currently opened map context object */
std::vector<map_context*> map_contexts_;
/** Index into the map_contexts_ array */
int current_context_index_;
/** The display object used and owned by the editor. */
boost::scoped_ptr<editor_display> gui_;
/** Available random map generators */
std::vector<map_generator*> map_generators_;
@ -356,56 +356,56 @@ class editor_controller : public controller_base,
/** Legacy object required by the legacy terrain palette and brush bar */
boost::scoped_ptr<size_specs> size_specs_;
/** The terrain palette */
boost::scoped_ptr<terrain_palette> palette_;
/** The brush selector */
boost::scoped_ptr<brush_bar> brush_bar_;
/* managers */
boost::scoped_ptr<preferences::display_manager> prefs_disp_manager_;
tooltips::manager tooltip_manager_;
boost::scoped_ptr<font::floating_label_context> floating_label_manager_;
boost::scoped_ptr<font::floating_label_context> floating_label_manager_;
/** Quit main loop flag */
bool do_quit_;
EXIT_STATUS quit_mode_;
/** All available brushes */
std::vector<brush> brushes_;
/** The current brush */
brush* brush_;
typedef std::map<hotkey::HOTKEY_COMMAND, mouse_action*> mouse_action_map;
/** The mouse actions */
mouse_action_map mouse_actions_;
typedef std::map<hotkey::HOTKEY_COMMAND, std::string> mouse_action_string_map;
/** Usage tips for mouse actions */
mouse_action_string_map mouse_action_hints_;
/** The current mouse action */
mouse_action* mouse_action_;
/** Toolbar-requires-redraw flag */
bool toolbar_dirty_;
/** Palette's active fg tereain */
t_translation::t_terrain foreground_terrain_;
/** Palette's active fg tereain */
t_translation::t_terrain background_terrain_;
t_translation::t_terrain background_terrain_;
/** Clipboard map_fragment -- used for copy-paste. */
map_fragment clipboard_;
/** Flag to rebuild terrain on every terrain change */
bool auto_update_transitions_;
bool use_mdi_;
/** Default directory for map load/save as dialogs */
std::string default_dir_;
};

View file

@ -101,7 +101,7 @@ void editor_display::draw_sidebar()
refresh_report(reports::POSITION, reports::report(lexical_cast<std::string>(mouseoverHex_)));
}
refresh_report(reports::VILLAGES, reports::report(lexical_cast<std::string>(get_map().villages().size())));
refresh_report(reports::EDITOR2_TOOL_HINT, reports::report(toolbar_hint_));
refresh_report(reports::EDITOR2_TOOL_HINT, reports::report(toolbar_hint_));
}

View file

@ -29,7 +29,7 @@ public:
bool in_editor() const { return true; }
void add_brush_loc(const map_location& hex);
void set_brush_locs(const std::set<map_location>& hexes);
void set_brush_locs(const std::set<map_location>& hexes);
void clear_brush_locs();
void remove_brush_loc(const map_location& hex);
const editor_map& map() const { return static_cast<const editor_map&>(get_map()); }
@ -42,12 +42,12 @@ protected:
* The editor uses different rules for terrain highligting (e.g. selections)
*/
image::TYPE get_image_type(const map_location& loc);
void draw_hex(const map_location& loc);
const SDL_Rect& get_clip_rect();
void draw_sidebar();
std::set<map_location> brush_locations_;
std::string toolbar_hint_;
};

View file

@ -15,7 +15,7 @@
#define GETTEXT_DOMAIN "wesnoth-editor"
/**
* @file editor/editor_layout.cpp
* @file editor/editor_layout.cpp
* Set various sizes for the screen-layout of the map editor.
*/
@ -29,7 +29,7 @@ namespace {
namespace editor2 {
size_specs::size_specs()
size_specs::size_specs()
: terrain_size(default_terrain_size)
, terrain_padding(2)
, terrain_space(terrain_size + terrain_padding)

View file

@ -35,7 +35,7 @@ EXIT_STATUS start(config& game_conf, CVideo& video, const std::string& filename
if (!filename.empty()) {
try {
mc.reset(new map_context(game_conf, filename));
LOG_ED << "Map " << filename << " loaded. "
LOG_ED << "Map " << filename << " loaded. "
<< mc->get_map().w() << " by " << mc->get_map().h() << "\n";
} catch (editor_map_load_exception& e) {
std::stringstream ss;

View file

@ -19,21 +19,21 @@ class config;
class CVideo;
namespace editor2 {
enum EXIT_STATUS {
EXIT_NORMAL,
EXIT_QUIT_TO_DESKTOP,
EXIT_ERROR
};
/**
/**
* Main interface for launching the editor from the title screen.
* @returns How the editor was exited (whether the intent was to
* @returns How the editor was exited (whether the intent was to
* go back to the titlescreen or quit to desktop altogeter)
*/
EXIT_STATUS start(config& game_config, CVideo& video, const std::string& filename = "");
} //end namespace editor2
#endif

View file

@ -80,7 +80,7 @@ editor_map editor_map::load_from_file(const config& game_config, const std::stri
log_scope2(editor, "Loading map " + filename);
std::string map_string = read_file(filename, false);
if (map_string.empty()) {
std::string message = _("Empty map file or file not found");
throw editor_map_load_exception(filename, message);
@ -93,7 +93,7 @@ editor_map editor_map::load_from_file(const config& game_config, const std::stri
} catch (twml_exception& e) {
throw wrap_exc("wml", e.user_message, filename);
} catch (config::error& e) {
throw wrap_exc("config", e.message, filename);
throw wrap_exc("config", e.message, filename);
}
}
@ -159,7 +159,7 @@ std::set<map_location> editor_map::get_contigious_terrain_tiles(const map_locati
} while (!queue.empty());
return result;
}
std::set<map_location> editor_map::set_starting_position_labels(display& disp)
{
std::set<map_location> label_locs;
@ -298,7 +298,7 @@ gamemap editor_map::mask_to(const gamemap& target) const
bool editor_map::same_size_as(const gamemap& other) const
{
return h() == other.h()
return h() == other.h()
&& w() == other.w();
}
@ -389,7 +389,7 @@ void editor_map::shrink_right(int count)
}
tiles_.resize(tiles_.size() - count);
w_ -= count;
total_width_ -= count;
total_width_ -= count;
}
void editor_map::shrink_left(int count)
@ -399,7 +399,7 @@ void editor_map::shrink_left(int count)
}
tiles_.erase(tiles_.begin(), tiles_.begin() + count);
w_ -= count;
total_width_ -= count;
total_width_ -= count;
}
void editor_map::shrink_top(int count)

View file

@ -25,7 +25,7 @@ namespace editor2 {
struct editor_map_operation_exception : public editor_exception
{
editor_map_operation_exception()
editor_map_operation_exception()
: editor_exception("Map operation error. Check debug log for details.")
{
}
@ -33,7 +33,7 @@ struct editor_map_operation_exception : public editor_exception
struct editor_map_integrity_error : public editor_exception
{
editor_map_integrity_error()
editor_map_integrity_error()
: editor_exception("Map integrity error. Check debug log for details.")
{
}
@ -52,101 +52,101 @@ struct editor_map_load_exception : public editor_exception
/**
* This class adds extra editor-specific functionality to a normal gamemap.
*/
class editor_map : public gamemap
*/
class editor_map : public gamemap
{
public:
editor_map(const config& terrain_cfg, const std::string& data);
editor_map(const config& terrain_cfg, size_t width, size_t height, t_translation::t_terrain filler);
editor_map(const config& terrain_cfg, const gamemap& map);
explicit editor_map(const gamemap& map);
static editor_map load_from_file(const config& game_config, const std::string& filename);
~editor_map();
/**
/**
* Debugging aid. Check if the widths and heights correspond to the actual map data sizes.
*/
void sanity_check();
/**
* Get a contigious set of tiles having the same terrain as the starting location.
* Useful for flood fill or magic wand selection
* @return a contigious set of locations that will always contain at least the starting element
*/
std::set<map_location> get_contigious_terrain_tiles(const map_location& start) const;
/**
* Set labels for staring positions in the given display object.
* @return the locations where the labels were added
*/
std::set<map_location> set_starting_position_labels(display& disp);
/**
* @return true when the location is part of the selection, false otherwise
*/
bool in_selection(const map_location& loc) const;
/**
* Add a location to the selection. The location should be valid (i.e. on the map)
* @return true if the selected hexes set was modified
*/
bool add_to_selection(const map_location& loc);
/**
* Remove a location to the selection. The location does not actually have to be selected
* @return true if the selected hexes set was modified
*/
bool remove_from_selection(const map_location& loc);
/**
* Return the selection set.
*/
const std::set<map_location> selection() const { return selection_; }
/**
* Clear the selection
*/
void clear_selection();
/**
* Invert the selection, i.e. select all the map hexes that were not selected.
*/
void invert_selection();
/**
* Select all map hexes
*/
void select_all();
/**
* @return true if the entire map is selected, false otherwise
*/
bool everything_selected() const;
/**
* Ensure no off-map tiles are in the selection
*/
void sanitize_selection();
/**
/**
* Resize the map. If the filler is NONE, the border terrain will be copied
* when expanding, otherwise the fill er terrain will be inserted there
*/
void resize(int width, int height, int x_offset, int y_offset,
t_translation::t_terrain filler = t_translation::NONE_TERRAIN);
/**
* A sort-of diff operation returning a mask that, when applied to the current editor_map,
* will transform it into the target map.
*/
gamemap mask_to(const gamemap& target) const;
bool same_size_as(const gamemap& other) const;
protected:

View file

@ -63,8 +63,8 @@ terrain_palette::terrain_palette(display &gui, const size_specs &sizes,
{
// Get the available terrains temporary in terrains_
terrains_ = map().get_terrain_list();
//move "invalid" terrains to the end
//move "invalid" terrains to the end
size_t size = terrains_.size();
for (size_t i = 0; i < size; ++i) {
if (is_invalid_terrain(terrains_[i])) {
@ -106,10 +106,10 @@ terrain_palette::terrain_palette(display &gui, const size_specs &sizes,
continue;
// add the terrain to the requested groups
const std::vector<std::string>& key =
const std::vector<std::string>& key =
utils::split(t_info.editor_group());
for(std::vector<std::string>::const_iterator k_itor = key.begin();
for(std::vector<std::string>::const_iterator k_itor = key.begin();
k_itor != key.end(); ++k_itor)
{
terrain_map_[*k_itor].push_back(*t_itor);
@ -378,7 +378,7 @@ void terrain_palette::draw(bool force) {
if (bot_button_.pressed()) {
scroll_down();
}
foreach (terrain_group& g, terrain_groups_) {
if (g.button.pressed()) {
checked_group_btn_ = &g.button;
@ -386,7 +386,7 @@ void terrain_palette::draw(bool force) {
break;
}
}
foreach (terrain_group& g, terrain_groups_) {
if (&g.button == checked_group_btn_) {
g.button.set_check(true);
@ -394,7 +394,7 @@ void terrain_palette::draw(bool force) {
g.button.set_check(false);
}
}
if (!dirty() && !force) {
return;
}
@ -518,9 +518,9 @@ void terrain_palette::load_tooltips()
// restorer_.restore();
// }
brush_bar::brush_bar(display &gui, const size_specs &sizes,
brush_bar::brush_bar(display &gui, const size_specs &sizes,
std::vector<brush>& brushes, brush** the_brush)
: gui::widget(gui.video()), size_specs_(sizes), gui_(gui),
: gui::widget(gui.video()), size_specs_(sizes), gui_(gui),
selected_(0), brushes_(brushes), the_brush_(the_brush),
size_(30) {
adjust_size();
@ -600,7 +600,7 @@ void brush_bar::draw(bool force) {
ERR_ED << "Image " << filename << " not found." << std::endl;
continue;
}
if (static_cast<unsigned>(image->w) != size_
if (static_cast<unsigned>(image->w) != size_
|| static_cast<unsigned>(image->h) != size_) {
image.assign(scale_surface(image, size_, size_));
}

View file

@ -39,7 +39,7 @@ namespace editor2 {
/**
* Stores the info about the data in editor-groups.cfg in a nice format.
*
* Helper struct which for some reason can't be moved to the cpp file.
* Helper struct which for some reason can't be moved to the cpp file.
*/
struct terrain_group
{
@ -57,7 +57,7 @@ public:
const config& cfg,
t_translation::t_terrain& fore,
t_translation::t_terrain& back);
const gamemap& map() const { return gui_.get_map(); }
/** Scroll the terrain-palette up one step if possible. */
@ -84,7 +84,7 @@ public:
t_translation::t_terrain selected_fg_terrain() const;
/** Return the currently selected background terrain. */
t_translation::t_terrain selected_bg_terrain() const;
void swap();
/** Select a foreground terrain. */
@ -95,9 +95,9 @@ public:
void update_selected_terrains();
/**
* Draw the palette.
* Draw the palette.
*
* If force is true everything will be redrawn,
* If force is true everything will be redrawn,
* even though it is not invalidated.
*/
void draw(bool force=false);
@ -109,7 +109,7 @@ public:
size_t num_terrains() const;
/**
* Update the size of this widget.
* Update the size of this widget.
*
* Use if the size_specs have changed.
*/
@ -122,9 +122,9 @@ private:
void draw_old(bool);
/**
* To be called when a mouse click occurs.
* To be called when a mouse click occurs.
*
* Check if the coordinates is a terrain that may be chosen,
* Check if the coordinates is a terrain that may be chosen,
* and select the terrain if that is the case.
*/
void left_mouse_click(const int mousex, const int mousey);
@ -145,9 +145,9 @@ private:
unsigned int tstart_;
/**
* This map contains all editor_group as defined in terrain.cfg
* and associate with the group there.
* The group 'all' is added automatically, and all terrains
* This map contains all editor_group as defined in terrain.cfg
* and associate with the group there.
* The group 'all' is added automatically, and all terrains
* are also automatically stored in this group.
*/
std::map<std::string, t_translation::t_list> terrain_map_;
@ -164,9 +164,9 @@ private:
std::vector<terrain_group> terrain_groups_;
/**
* The group buttons behave like a radio group.
* The group buttons behave like a radio group.
*
* This one points to the selected button, this value should not be 0
* This one points to the selected button, this value should not be 0
* otherwise things will fail. Thus should be set in constructor.
*/
gui::button *checked_group_btn_;
@ -190,7 +190,7 @@ public:
void select_brush(int index);
/**
* Draw the palette. If force is true, everything
* Draw the palette. If force is true, everything
* will be redrawn, even though it is not dirty.
*/
void draw(bool force=false);
@ -198,7 +198,7 @@ public:
virtual void handle_event(const SDL_Event& event);
/**
* Update the size of this widget.
* Update the size of this widget.
*
* Use if the size_specs have changed.
*/
@ -206,7 +206,7 @@ public:
private:
/**
* To be called when a mouse click occurs.
* To be called when a mouse click occurs.
*
* Check if the coordinates is a terrain that may be chosen, and select the
* terrain if that is the case.

View file

@ -63,7 +63,7 @@ map_context::~map_context()
clear_stack(redo_stack_);
}
void map_context::draw_terrain(t_translation::t_terrain terrain,
void map_context::draw_terrain(t_translation::t_terrain terrain,
const map_location& loc, bool one_layer_only)
{
if (!one_layer_only) {
@ -72,12 +72,12 @@ void map_context::draw_terrain(t_translation::t_terrain terrain,
draw_terrain_actual(terrain, loc, one_layer_only);
}
void map_context::draw_terrain_actual(t_translation::t_terrain terrain,
void map_context::draw_terrain_actual(t_translation::t_terrain terrain,
const map_location& loc, bool one_layer_only)
{
if (!map_.on_board_with_border(loc)) {
//requests for painting off the map are ignored in set_terrain anyway,
//but ideally we should not have any
//but ideally we should not have any
LOG_ED << "Attempted to draw terrain off the map (" << loc << ")\n";
return;
}
@ -94,7 +94,7 @@ void map_context::draw_terrain_actual(t_translation::t_terrain terrain,
}
}
void map_context::draw_terrain(t_translation::t_terrain terrain,
void map_context::draw_terrain(t_translation::t_terrain terrain,
const std::set<map_location>& locs, bool one_layer_only)
{
if (!one_layer_only) {
@ -140,7 +140,7 @@ void map_context::clear_starting_position_labels(display& disp)
disp.labels().clear_all();
starting_position_label_locs_.clear();
}
void map_context::set_starting_position_labels(display& disp)
{
std::set<map_location> new_label_locs = map_.set_starting_position_labels(disp);
@ -196,7 +196,7 @@ void map_context::perform_action(const editor_action& action)
trim_stack(undo_stack_);
clear_stack(redo_stack_);
}
void map_context::perform_partial_action(const editor_action& action)
{
LOG_ED << "Performing (partial) action " << action.get_id() << ", actions count is " << action.get_instance_count() << "\n";

View file

@ -26,11 +26,11 @@ namespace editor2 {
/**
* This class wraps around a map to provide a conscise interface for the editor to work with.
* The actual map object can change rapidly (be assigned to), the map context persists
* The actual map object can change rapidly (be assigned to), the map context persists
* data (like the undo stacks) in this case. The functionality is here, not in editor_controller
* as e.g. the undo stack is part of the map, not the editor as a whole. This might allow many
* maps to be open at the same time.
*/
*/
class map_context
{
public:
@ -38,44 +38,44 @@ public:
* A map context can only by created from an existing map
*/
explicit map_context(const editor_map& map);
/**
* Create map_context from a map file. If the map cannot be
* loaded, an exception will be thrown and the object will
* not be constructed.
*/
map_context(const config& game_config, const std::string& filename);
~map_context();
/**
* Map accesor
*/
editor_map& get_map() { return map_; };
/**
* Map accesor - const version
*/
const editor_map& get_map() const { return map_; }
/**
* Draw a terrain on a single location on the map.
* Draw a terrain on a single location on the map.
* Sets the refresh flags accordingly.
*/
void draw_terrain(t_translation::t_terrain terrain, const map_location& loc,
void draw_terrain(t_translation::t_terrain terrain, const map_location& loc,
bool one_layer_only = false);
/**
* Actual drawing function used by both overloaded variants of draw_terrain.
*/
void draw_terrain_actual(t_translation::t_terrain terrain, const map_location& loc,
bool one_layer_only = false);
/**
* Draw a terrain on a set of locations on the map.
* Draw a terrain on a set of locations on the map.
* Sets the refresh flags accordingly.
*/
void draw_terrain(t_translation::t_terrain terrain, const std::set<map_location>& locs,
void draw_terrain(t_translation::t_terrain terrain, const std::set<map_location>& locs,
bool one_layer_only = false);
/**
@ -83,82 +83,82 @@ public:
* set when the map size has changed or the map was reassigned.
*/
bool needs_reload() const { return needs_reload_; }
/**
* Setter for the reload flag
*/
void set_needs_reload(bool value=true) { needs_reload_ = value; }
/**
* Getter for the terrain rebuild flag. Set whenever any terrain has changed.
* Getter for the terrain rebuild flag. Set whenever any terrain has changed.
*/
bool needs_terrain_rebuild() const { return needs_terrain_rebuild_; }
/**
* Setter for the terrain rebuild flag
*/
void set_needs_terrain_rebuild(bool value=true) { needs_terrain_rebuild_ = value; }
/**
* Getter fo the labels reset flag. Set when the labels need to be refreshed.
*/
bool needs_labels_reset() const { return needs_labels_reset_; }
/**
* Setter for the labels reset flag
*/
void set_needs_labels_reset(bool value=true) { needs_labels_reset_ = value; }
const std::set<map_location> changed_locations() const { return changed_locations_; }
void clear_changed_locations();
void add_changed_location(const map_location& loc);
void add_changed_location(const std::set<map_location>& locs);
void set_everything_changed();
bool everything_changed() const;
void clear_starting_position_labels(display& disp);
void set_starting_position_labels(display& disp);
void reset_starting_position_labels(display& disp);
const std::string& get_filename() const { return filename_; }
void set_filename(const std::string& fn) { filename_ = fn; }
/**
* Saves the map under the current filename. Filename must be valid.
* May throw an exception on failure.
*/
bool save();
void load_map(const config& game_config, const std::string& filename);
void set_map(const editor_map& map);
/**
* Performs an action (thus modyfying the map). An appropriate undo action is added to
* the undo stack. The redo stack is cleared. Note that this may throw, use caution
* when calling this with a dereferennced pointer that you own (i.e. use a smart pointer).
*/
void perform_action(const editor_action& action);
/**
* Performs a partial action, assumes that the top undo action has been modified to
* maintain coherent state of the undo stacks, and so a new undo action is not
* created.
*/
void perform_partial_action(const editor_action& action);
/** @return whether the map was modified since the last save */
bool modified() const;
/** Clear the modified state */
void clear_modified();
/** @return true when undo can be performed, false otherwise */
bool can_undo() const;
/** @return true when redo can be performed, false otherwise */
bool can_redo() const;
@ -179,7 +179,7 @@ public:
/** Re-does a previousle undid action, and puts it back in the undo stack. */
void redo();
/**
* Un-does a single step from a undo action chain. The action is separated
* from the chain and it's undo (the redo) is added as a standalone action
@ -187,18 +187,18 @@ public:
* Precodnition: the last undo action has to actually be an action chain.
*/
void partial_undo();
/**
* Clear the undo and redo stacks
*/
void clear_undo_redo();
protected:
/**
* The map object of this map_context.
*/
editor_map map_;
/**
* Container type used to store actions in the undo and redo stacks
*/
@ -220,58 +220,58 @@ protected:
* This is the implementation of both undo and redo which only differ in the direction.
*/
void perform_action_between_stacks(action_stack& from, action_stack& to);
/**
* The actual filename of this map. An empty string indicates a new map.
*/
std::string filename_;
/**
* The undo stack. A double-ended queues due to the need to add items to one end,
* and remove from both when performing the undo or when trimming the size. This container owns
* all contents, i.e. no action in the stack shall be deleted, and unless otherwise noted the contents
* all contents, i.e. no action in the stack shall be deleted, and unless otherwise noted the contents
* could be deleted at an time during normal operation of the stack. To work on an action, either
* remove it from the container or make a copy. Actions are inserted at the back of the container
* and disappear from the front when the capacity is exceeded.
* @todo Use boost's pointer-owning container?
*/
action_stack undo_stack_;
/**
* The redo stack. @see undo_stack_
*/
action_stack redo_stack_;
/**
* Action stack (i.e. undo and redo) maximum size
*/
static const size_t max_action_stack_size_;
/**
* Number of actions performed since the map was saved. Zero means the map was not modified.
*/
int actions_since_save_;
int actions_since_save_;
/**
* Cache of set starting position labels. Necessary for removing them.
*/
std::set<map_location> starting_position_label_locs_;
/**
* Refresh flag indicating the map in this context should be completely reloaded by the display
*/
bool needs_reload_;
/**
* Refresh flag indicating the terrain in the map has changed and requires a rebuild
*/
bool needs_terrain_rebuild_;
/**
* Refresh flag indicating the labels in the map have changed
*/
bool needs_labels_reset_;
std::set<map_location> changed_locations_;
bool everything_changed_;
};

View file

@ -99,7 +99,7 @@ map_location map_fragment::center_of_bounds() const
if (loc.y < top_left.y) top_left.y = loc.y;
else if (loc.y > bottom_right.y) bottom_right.y = loc.y;
}
map_location c((top_left.x + bottom_right.x) / 2,
map_location c((top_left.x + bottom_right.x) / 2,
(top_left.y + bottom_right.y) / 2);
return c;
}

View file

@ -37,7 +37,7 @@ struct tile_info
: offset(offset), terrain(map.get_terrain(offset))
{
}
map_location offset;
t_translation::t_terrain terrain;
};
@ -52,47 +52,47 @@ class map_fragment
* Create an empty map fragment.
*/
map_fragment();
/**
* Create a map fragment from the specified locations on the map.
*/
map_fragment(const gamemap& map, const std::set<map_location>& area);
/**
* Add a single location and pull its info from the map.
*/
void add_tile(const gamemap& map, const map_location& loc);
/**
* Add many locations and pull their info from the map.
*/
void add_tiles(const gamemap& map, const std::set<map_location>& loc);
/**
* Get the tile_info vector.
*/
const std::vector<tile_info>& get_items() const { return items_; }
/**
* Get the area covered by this map fragment.
*/
std::set<map_location> get_area() const;
/**
* Get the area covered by this map fragment, shifted by an offset.
*/
std::set<map_location> get_offset_area(const map_location& offset) const;
/**
* Paste the map fragment into the map, treating loc as the (0,0) point (offset).
*/
void paste_into(gamemap& map, const map_location& loc) const;
/**
* Shift all tiles in the map fragment by the specified offset.
*/
void shift(const map_location& offset);
/**
* Return a location at the top left corner of this fragment's
* bounding rectangle
@ -108,27 +108,27 @@ class map_fragment
* Get the center of the map fragment, mass-wise.
*/
map_location center_of_mass() const;
/**
* Shift the map fragment so that all locations have nonnegative coordinates
*/
void normalize();
/**
* Shift the map fragment so it is roughly centered around the (0,0) point, bounds-wise.
*/
void center_by_bounds();
/**
* Shift the map fragment so it is roughly centered around the (0,0) point, mass-wise.
*/
void center_by_mass();
/**
* @return true if the map_fragment is empty
*/
bool empty() const;
/**
* Rotate the map fragment 60 degrees clockwise around (0,0)
*/
@ -138,7 +138,7 @@ class map_fragment
* Rotate the map fragment 60 degrees counter-clockwise around (0,0)
*/
void rotate_60_ccw();
/**
* Flip the map fragment horizontally
*/
@ -147,13 +147,13 @@ class map_fragment
/**
* Flip the map fragment vertically
*/
void flip_vertical();
void flip_vertical();
/**
* Debug dump to a string
*/
std::string dump() const;
protected:
/**
* The data of this map_fragment

View file

@ -56,13 +56,13 @@ editor_action* mouse_action::click_right(
return NULL;
}
editor_action* mouse_action::drag_left(editor_display& /*disp*/,
editor_action* mouse_action::drag_left(editor_display& /*disp*/,
int /*x*/, int /*y*/, bool& /*partial*/, editor_action* /*last_undo*/)
{
return NULL;
}
editor_action* mouse_action::drag_right(editor_display& /*disp*/,
editor_action* mouse_action::drag_right(editor_display& /*disp*/,
int /*x*/, int /*y*/, bool& /*partial*/, editor_action* /*last_undo*/)
{
return NULL;
@ -122,12 +122,12 @@ void mouse_action::set_mouse_overlay(editor_display& disp)
disp.set_mouseover_hex_overlay(NULL);
}
bool mouse_action::has_alt_modifier() const
bool mouse_action::has_alt_modifier() const
{
return key_[SDLK_RALT] || key_[SDLK_LALT];
}
bool mouse_action::has_shift_modifier() const
bool mouse_action::has_shift_modifier() const
{
return key_[SDLK_RSHIFT] || key_[SDLK_LSHIFT];
}
@ -135,15 +135,15 @@ bool mouse_action::has_shift_modifier() const
void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
t_translation::t_terrain bg)
{
surface image_fg(image::get_image("terrain/"
surface image_fg(image::get_image("terrain/"
+ disp.get_map().get_terrain_info(fg).editor_image() + ".png"));
surface image_bg(image::get_image("terrain/"
surface image_bg(image::get_image("terrain/"
+ disp.get_map().get_terrain_info(bg).editor_image() + ".png"));
if (image_fg == NULL || image_bg == NULL) {
ERR_ED << "Missing terrain icon\n";
disp.set_mouseover_hex_overlay(NULL);
return;
return;
}
// Create a transparent surface of the right size.
@ -177,7 +177,7 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, t_translation
//apply mask so the overlay is contained within the mouseover hex
surface mask(image::get_image("terrain/alphamask.png"));
image = mask_surface(image, mask);
// Add the alpha factor and scale the image
image = scale_surface(adjust_surface_alpha(image, alpha), zoom, zoom);
@ -205,13 +205,13 @@ editor_action* brush_drag_mouse_action::click_right(editor_display& disp, int x,
return click_perform_right(disp, affected_hexes(disp, hex));
}
editor_action* brush_drag_mouse_action::drag_left(editor_display& disp,
editor_action* brush_drag_mouse_action::drag_left(editor_display& disp,
int x, int y, bool& partial, editor_action* last_undo)
{
return drag_generic<&brush_drag_mouse_action::click_perform_left>(disp, x, y, partial, last_undo);
}
editor_action* brush_drag_mouse_action::drag_right(editor_display& disp,
editor_action* brush_drag_mouse_action::drag_right(editor_display& disp,
int x, int y, bool& partial, editor_action* last_undo)
{
return drag_generic<&brush_drag_mouse_action::click_perform_right>(disp, x, y, partial, last_undo);

View file

@ -25,7 +25,7 @@ class CKey;
namespace editor2 {
/**
* A mouse action receives events from the controller, and responds to them by creating
* A mouse action receives events from the controller, and responds to them by creating
* an appropriate editor_action object. Mouse actions may store some temporary data
* such as the last clicked hex for better handling of click-drag. They should *not* modify
* the map or trigger refreshes, but may set brush locations and similar overlays that
@ -42,28 +42,28 @@ public:
}
virtual ~mouse_action() {}
/**
* Mouse move (not a drag). Never changes anything (other than temporary highlihts and similar)
*/
void move(editor_display& disp, const map_location& hex);
/**
* Unconditionally update the brush highlights for the current tool when hex is the center location
*/
void update_brush_highlights(editor_display& disp, const map_location& hex);
/**
* Locations that would be affected by a click, used by move to update highlights. Defauts to higlight the mouseover hex.
* Maybe also used for actually performing the action in click() or drag().
*/
virtual std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
/**
* A click, possibly the beginning of a drag. Must be overriden.
*/
virtual editor_action* click_left(editor_display& disp, int x, int y) = 0;
/**
* A click, possibly the beginning of a drag. Must be overriden.
*/
@ -73,7 +73,7 @@ public:
* Drag operation. A click should have occured earlier. Defaults to no action.
*/
virtual editor_action* drag_left(editor_display& disp, int x, int y, bool& partial, editor_action* last_undo);
/**
* Drag operation. A click should have occured earlier. Defaults to no action.
*/
@ -83,54 +83,54 @@ public:
* The end of dragging. Defaults to no action.
*/
virtual editor_action* drag_end(editor_display& disp, int x, int y);
virtual editor_action* up_left(editor_display& disp, int x, int y);
virtual editor_action* up_right(editor_display& disp, int x, int y);
/**
* Function called by the controller on a key event for the current mouse action.
* Defaults to starting position processing.
*/
virtual editor_action* key_event(editor_display& disp, const SDL_Event& e);
/**
* Helper variable setter - pointer to a toolbar menu/button used for highlighting
* Helper variable setter - pointer to a toolbar menu/button used for highlighting
* the current action. Should always be NULL or point to a valid menu.
*/
void set_toolbar_button(const theme::menu* value) { toolbar_button_ = value; }
/**
* Getter for the (possibly NULL) associated menu/button.
* Getter for the (possibly NULL) associated menu/button.
*/
const theme::menu* toolbar_button() const { return toolbar_button_; }
/**
* Set the mouse overlay for this action. Defaults to an empty overlay.
*/
virtual void set_mouse_overlay(editor_display& disp);
protected:
bool has_alt_modifier() const;
bool has_shift_modifier() const;
/**
/**
* Helper function for derived classes that need a active-terrain mouse overlay
*/
void set_terrain_mouse_overlay(editor_display& disp, t_translation::t_terrain fg,
t_translation::t_terrain bg);
/**
* The hex previously used in move operations
*/
map_location previous_move_hex_;
/**
* Key presses, used for modifiers (alt, shift) in some operations
*/
const CKey& key_;
private:
/**
* Pointer to an associated menu/button, if such exists
@ -150,17 +150,17 @@ public:
, brush_(brush)
{
}
/**
* The affected hexes of a brush action are the result of projecting the current brush on the mouseover hex
*/
std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
/**
* The actual action function which is called by click() and drag(). Derived classes override this instead of click() and drag().
*/
virtual editor_action* click_perform_left(editor_display& disp, const std::set<map_location>& hexes) = 0;
/**
* The actual action function which is called by click() and drag(). Derived classes override this instead of click() and drag().
*/
@ -175,35 +175,35 @@ public:
* Calls click_perform_right()
*/
editor_action* click_right(editor_display& disp, int x, int y);
/**
* Calls click_perform() for every new hex the mouse is dragged into.
* @todo partial actions support and merging of many drag actions into one
*/
editor_action* drag_left(editor_display& disp, int x, int y, bool& partial, editor_action* last_undo);
/**
* Calls click_perform for every new hex the mouse is dragged into.
* @todo partial actions support and merging of many drag actions into one
*/
editor_action* drag_right(editor_display& disp, int x, int y, bool& partial, editor_action* last_undo);
/**
* End of dragging.
* @todo partial actions (the entire drag should end up as one action)
*/
editor_action* drag_end(editor_display& disp, int x, int y);
editor_action* drag_end(editor_display& disp, int x, int y);
protected:
/** Brush accessor */
const brush& get_brush();
/**
* The previous hex dragged into.
* @todo keep a set of all "visited" locations to reduce action count in long drags that hit the same hexes multiple times?
*/
map_location previous_drag_hex_;
private:
/**
* Template helper gathering actions common for both drag_right and drag_left.
@ -228,15 +228,15 @@ private:
class mouse_action_paint : public brush_drag_mouse_action
{
public:
mouse_action_paint(const t_translation::t_terrain& terrain_left,
const t_translation::t_terrain& terrain_right,
mouse_action_paint(const t_translation::t_terrain& terrain_left,
const t_translation::t_terrain& terrain_right,
const brush* const * const brush, const CKey& key)
: brush_drag_mouse_action(brush, key)
, terrain_left_(terrain_left)
, terrain_right_(terrain_right)
{
}
/**
* Create an appropriate editor_action and return it
*/
@ -248,7 +248,7 @@ public:
editor_action* click_perform_right(editor_display& disp, const std::set<map_location>& hexes);
void set_mouse_overlay(editor_display& disp);
protected:
const t_translation::t_terrain& terrain_left_;
const t_translation::t_terrain& terrain_right_;
@ -264,17 +264,17 @@ public:
: brush_drag_mouse_action(brush, key)
{
}
/**
* Overriden to allow special behaviour based on modifier keys
*/
std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
/**
* Force a fake "move" event to update brush overlay on key event
*/
editor_action* key_event(editor_display& disp, const SDL_Event& e);
/**
* Left click/drag selects
*/
@ -284,7 +284,7 @@ public:
* Right click/drag deselects
*/
editor_action* click_perform_right(editor_display& disp, const std::set<map_location>& hexes);
virtual void set_mouse_overlay(editor_display& disp);
};
@ -298,12 +298,12 @@ public:
: mouse_action(key), paste_(paste)
{
}
/**
* Show an outline of where the paste will go
*/
std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
/**
* Return a paste with offset action
*/
@ -313,9 +313,9 @@ public:
* Right click does nothing for now
*/
editor_action* click_right(editor_display& disp, int x, int y);
virtual void set_mouse_overlay(editor_display& disp);
protected:
/**
* Reference to the buffer used for pasting (e.g. the clipboard)
@ -336,31 +336,31 @@ public:
, terrain_right_(terrain_right)
{
}
/**
* Tiles that will be painted to, possibly use modifier keys here
*/
std::set<map_location> affected_hexes(editor_display& disp, const map_location& hex);
/**
* Left / right click fills with the respective terrain
*/
editor_action* click_left(editor_display& disp, int x, int y);
/**
* Left / right click fills with the respective terrain
*/
editor_action* click_right(editor_display& disp, int x, int y);
virtual void set_mouse_overlay(editor_display& disp);
protected:
const t_translation::t_terrain& terrain_left_;
const t_translation::t_terrain& terrain_right_;
};
/**
* Set starting position action.
* Set starting position action.
*/
class mouse_action_starting_position : public mouse_action
{
@ -369,7 +369,7 @@ public:
: mouse_action(key), click_(false)
{
}
/**
* Left click displays a player-number-selector dialog and then creates an action
* or returns NULL if cancel was pressed or there would be no change.
@ -383,11 +383,11 @@ public:
* Do this on mouse up to avoid drag issue,
*/
editor_action* up_right(editor_display& disp, int x, int y);
editor_action* click_right(editor_display& disp, int x, int y);
virtual void set_mouse_overlay(editor_display& disp);
private:
bool click_;
};

View file

@ -44,9 +44,9 @@ namespace {
struct context
{
context() :
context() :
handlers(),
focused_handler(-1)
focused_handler(-1)
{
}

View file

@ -39,11 +39,11 @@ int show_file_chooser_dialog(display &disp, std::string &filename,
return d.result();
}
file_dialog::file_dialog(display &disp, const std::string& file_path,
file_dialog::file_dialog(display &disp, const std::string& file_path,
const std::string& title, bool show_directory_buttons) :
gui::dialog(disp, title, file_path, gui::OK_CANCEL),
show_directory_buttons_(show_directory_buttons),
files_list_(NULL),
gui::dialog(disp, title, file_path, gui::OK_CANCEL),
show_directory_buttons_(show_directory_buttons),
files_list_(NULL),
last_selection_(0),
last_textbox_text_(),
chosen_file_()
@ -219,7 +219,7 @@ void file_dialog::action(gui::dialog_process_info &dp_info) {
{
chosen_file_ = unformat_filename(textbox_text());
last_textbox_text_ = textbox_text();
// Do type-a-head search in listbox
files_list_->select_file(textbox_text());
}

View file

@ -58,7 +58,7 @@ private:
/// index of the button pressed, or -1 if the dialog was canceled
/// through keypress.
int show_file_chooser_dialog(display &displ, std::string &filename,
std::string const &title, bool show_directory_buttons = true,
std::string const &title, bool show_directory_buttons = true,
const std::string& file_to_search = "",
int xloc = -1, int yloc = -1);

View file

@ -13,15 +13,15 @@
*/
/**
* @file filesystem.cpp
* @file filesystem.cpp
* File-IO
*/
#include "global.hpp"
// Include files for opendir(3), readdir(3), etc.
// These files may vary from platform to platform,
// since these functions are NOT ANSI-conforming functions.
// Include files for opendir(3), readdir(3), etc.
// These files may vary from platform to platform,
// since these functions are NOT ANSI-conforming functions.
// They may have to be altered to port to new platforms
//for mkdir
@ -83,7 +83,7 @@ bool ends_with(const std::string& str, const std::string& suffix)
#define FINALCFG "_final.cfg"
#define INITIALCFG "_initial.cfg"
// Don't pass directory as reference, it seems to break on
// Don't pass directory as reference, it seems to break on
// arklinux with GCC-4.3.
void get_files_in_dir(const std::string directory,
std::vector<std::string>* files,
@ -93,8 +93,8 @@ void get_files_in_dir(const std::string directory,
FILE_REORDER_OPTION reorder,
file_tree_checksum* checksum)
{
// If we have a path to find directories in,
// then convert relative pathnames to be rooted
// If we have a path to find directories in,
// then convert relative pathnames to be rooted
// on the wesnoth path
#ifndef __AMIGAOS4__
if(!directory.empty() && directory[0] != '/' && !game_config::path.empty()){
@ -143,7 +143,7 @@ void get_files_in_dir(const std::string directory,
if(entry->d_name[0] == '.')
continue;
#ifdef __APPLE__
// HFS Mac OS X decomposes filenames using combining unicode characters.
// HFS Mac OS X decomposes filenames using combining unicode characters.
// Try to get the precomposed form.
char macname[MAXNAMLEN+1];
CFStringRef cstr = CFStringCreateWithCString(NULL,
@ -159,7 +159,7 @@ void get_files_in_dir(const std::string directory,
CFRelease(mut_str);
const std::string basename = macname;
#else
// generic Unix
// generic Unix
const std::string basename = entry->d_name;
#endif /* !APPLE */
@ -187,12 +187,12 @@ void get_files_in_dir(const std::string directory,
}
checksum->sum_size += st.st_size;
checksum->nfiles++;
}
}
} else if (S_ISDIR(st.st_mode)) {
if (filter == SKIP_MEDIA_DIR
&& (basename == "images"|| basename == "sounds"))
continue;
if (reorder == DO_REORDER &&
::stat((fullname+"/"+MAINCFG).c_str(), &st)!=-1 &&
S_ISREG(st.st_mode)) {
@ -461,7 +461,7 @@ const std::string PREFERENCES_DIR = ".wesnoth" + std::string(game_config::versio
if(path.empty()) {
game_config::preferences_dir = get_cwd() + "/userdata";
} else if (path.size() > 2 && path[1] == ':') {
//allow absolute path override
//allow absolute path override
game_config::preferences_dir = path;
} else {
BOOL (*SHGetSpecialFolderPath)(HWND, LPTSTR, int, BOOL);
@ -729,7 +729,7 @@ bool file_exists(const std::string& name)
#ifdef _WIN32
struct stat st;
return (::stat(name.c_str(), &st) == 0);
#else
#else
struct stat st;
return (::stat(name.c_str(), &st) != -1);
#endif
@ -778,13 +778,13 @@ std::string next_filename(const std::string &dirname, unsigned int max)
/**
* Returns true if the file ends with '.gz'.
*
*
* @param filename The name to test.
*/
bool is_gzip_file(const std::string& filename)
{
return (filename.length() > 3
&& filename.substr(filename.length() - 3) == ".gz");
{
return (filename.length() > 3
&& filename.substr(filename.length() - 3) == ".gz");
}
file_tree_checksum::file_tree_checksum()

View file

@ -13,7 +13,7 @@
*/
/**
* @file filesystem.hpp
* @file filesystem.hpp
* Declarations for File-IO.
*/
@ -44,8 +44,8 @@ enum FILE_FILTER { NO_FILTER, SKIP_MEDIA_DIR};
enum FILE_REORDER_OPTION { DONT_REORDER, DO_REORDER };
/**
* Populates 'files' with all the files and
* 'dirs' with all the directories in dir.
* Populates 'files' with all the files and
* 'dirs' with all the directories in dir.
* If files or dirs are NULL they will not be used.
*
* mode: determines whether the entire path or just the filename is retrieved.
@ -95,7 +95,7 @@ bool delete_directory(const std::string& dirname);
// Basic disk I/O:
/** Basic disk I/O - read file.
/** Basic disk I/O - read file.
* The bool relative_from_game_path determines whether relative paths should be treated as relative
* to the game path (true) or to the current directory from which Wesnoth was run (false).
* The non-const version will update the string if the game path is prepended.
@ -157,21 +157,21 @@ int file_size(const std::string& fname);
bool ends_with(const std::string& str, const std::string& suffix);
/**
* Returns the base filename of a file, with directory name stripped.
* Returns the base filename of a file, with directory name stripped.
* Equivalent to a portable basename() function.
*/
std::string file_name(const std::string& file);
/**
* Returns the directory name of a file, with filename stripped.
* Returns the directory name of a file, with filename stripped.
* Equivalent to a portable dirname()
*/
std::string directory_name(const std::string& file);
/**
* The paths manager is responsible for recording the various paths
* that binary files may be located at.
* It should be passed a config object which holds binary path information.
* The paths manager is responsible for recording the various paths
* that binary files may be located at.
* It should be passed a config object which holds binary path information.
* This is in the format
*@verbatim
* [binary_path]
@ -206,7 +206,7 @@ void clear_binary_paths_cache();
const std::vector<std::string>& get_binary_paths(const std::string& type);
/**
* Returns a complete path to the actual file of a given a type of binary,
* Returns a complete path to the actual file of a given a type of binary,
* or an empty string if the file isn't present.
*/
std::string get_binary_file_location(const std::string& type, const std::string& filename);

View file

@ -110,14 +110,14 @@ DIR *opendir(char const *name)
DIR *result = NULL;
DWORD dwAttr;
// Must be a valid name
// Must be a valid name
if( !name ||
!*name ||
(dwAttr = GetFileAttributes(name)) == 0xFFFFFFFF)
{
errno = ENOENT;
}
// Must be a directory
// Must be a directory
else if(!(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
{
errno = ENOTDIR;
@ -142,7 +142,7 @@ DIR *opendir(char const *name)
}
else
{
// Save the directory, in case of rewind.
// Save the directory, in case of rewind.
(void)lstrcpyA(result->directory, name);
(void)lstrcpyA(result->dirent.d_name, result->find_data.cFileName);
result->dirent.d_mode = (int)result->find_data.dwFileAttributes;

View file

@ -23,10 +23,10 @@
#include <ctime>
namespace gui{
floating_textbox::floating_textbox() :
box_(NULL),
check_(NULL),
mode_(TEXTBOX_NONE),
floating_textbox::floating_textbox() :
box_(NULL),
check_(NULL),
mode_(TEXTBOX_NONE),
label_string_(),
label_(0)
{}

View file

@ -81,31 +81,31 @@ std::vector<std::string> font_names;
struct text_chunk
{
text_chunk(subset_id subset) :
text_chunk(subset_id subset) :
subset(subset),
text(),
ucs2_text()
{
}
text_chunk(subset_id subset, std::string const & text) :
subset(subset),
text_chunk(subset_id subset, std::string const & text) :
subset(subset),
text(text),
ucs2_text()
{
}
text_chunk(subset_id subset, ucs2_string const & ucs2_text) :
subset(subset),
text_chunk(subset_id subset, ucs2_string const & ucs2_text) :
subset(subset),
text(),
ucs2_text(ucs2_text)
ucs2_text(ucs2_text)
{
}
text_chunk(subset_id subset, std::string const & text, ucs2_string const & ucs2_text) :
subset(subset),
text(text),
ucs2_text(ucs2_text)
text_chunk(subset_id subset, std::string const & text, ucs2_string const & ucs2_text) :
subset(subset),
text(text),
ucs2_text(ucs2_text)
{
}
@ -312,7 +312,7 @@ void manager::update_font_path() const
void manager::init() const
{
#ifdef CAIRO_HAS_FT_FONT
if(!FcConfigAppFontAddDir( FcConfigGetCurrent(),
if(!FcConfigAppFontAddDir( FcConfigGetCurrent(),
reinterpret_cast<const FcChar8*>
((game_config::path + "/fonts/").c_str()))) {
@ -325,7 +325,7 @@ void manager::init() const
foreach(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
foreach(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf")
AddFontResource(file.c_str());
}
@ -342,7 +342,7 @@ void manager::deinit() const
foreach(const std::string& path, get_binary_paths("fonts")) {
std::vector<std::string> files;
get_files_in_dir(path, &files, NULL, ENTIRE_FILE_PATH);
foreach(const std::string& file, files)
foreach(const std::string& file, files)
if(file.substr(file.length() - 4) == ".ttf")
RemoveFontResource(file.c_str());
}
@ -485,14 +485,14 @@ void text_surface::bidi_cvt()
}
#endif
text_surface::text_surface(std::string const &str, int size,
text_surface::text_surface(std::string const &str, int size,
SDL_Color color, int style) :
hash_(0),
font_size_(size),
color_(color),
style_(style),
w_(-1),
h_(-1),
hash_(0),
font_size_(size),
color_(color),
style_(style),
w_(-1),
h_(-1),
str_(str),
initialized_(false),
chunks_(),
@ -508,11 +508,11 @@ text_surface::text_surface(std::string const &str, int size,
}
text_surface::text_surface(int size, SDL_Color color, int style) :
hash_(0),
font_size_(size),
color_(color),
style_(style),
w_(-1),
hash_(0),
font_size_(size),
color_(color),
style_(style),
w_(-1),
h_(-1),
str_(),
initialized_(false),
@ -564,7 +564,7 @@ void text_surface::measure() const
itor->ucs2_text.push_back(0);
}
TTF_SizeUNICODE(ttfont,
TTF_SizeUNICODE(ttfont,
static_cast<Uint16 const *>(&(itor->ucs2_text.front())), &w, &h);
w_ += w;
h_ = std::max<int>(h_, h);
@ -610,7 +610,7 @@ std::vector<surface> const &text_surface::get_surfaces() const
continue;
font_style_setter const style_setter(ttfont, style_);
surface s = surface(TTF_RenderUNICODE_Blended(ttfont,
surface s = surface(TTF_RenderUNICODE_Blended(ttfont,
static_cast<Uint16 const *>(&(itor->ucs2_text.front())), color_));
if(!s.null())
surfs_.push_back(s);
@ -676,7 +676,7 @@ static surface render_text(const std::string& text, int fontsize, const SDL_Colo
size_t width = 0, height = 0;
for(std::vector< std::string >::const_iterator ln = lines.begin(), ln_end = lines.end(); ln != ln_end; ++ln) {
SDL_Color col = colour;
int sz = fontsize;
int text_style = style;
@ -758,7 +758,7 @@ SDL_Rect draw_text_line(surface gui_surface, const SDL_Rect& area, int size,
}
if(area.w == 0) { // no place to draw
SDL_Rect res = {0,0,0,0};
SDL_Rect res = {0,0,0,0};
return res;
}
@ -995,7 +995,7 @@ surface floating_label::create_surface()
// background is blurred shadow of the text
//TODO add a little extra space for the blur of letters with a lower part
surface background = shadow_image(foreground, false);
if (background == NULL) {
ERR_FT << "could not create floating label's shadow" << std::endl;
surf_ = create_optimized_surface(foreground);

View file

@ -24,7 +24,7 @@
* something like this: (ostringstream() << n).str() to convert an integer to a
* string, all in one line instead you have to use this far more tedious
* approach:
* ostringstream s;
* ostringstream s;
* s << n;
* s.str();
* This class corrects this shortcoming, allowing something like this:

View file

@ -60,19 +60,19 @@ private:
struct formula_error
{
formula_error()
formula_error()
: type()
, formula()
, filename()
, line(0)
, line(0)
{}
formula_error(const std::string& type, const std::string& formula,
const std::string& file, int line)
formula_error(const std::string& type, const std::string& formula,
const std::string& file, int line)
: type(type)
, formula(formula)
, filename(file)
, line(line)
, line(line)
{}
std::string type;

View file

@ -63,8 +63,8 @@ public:
ai.swap_move_map(backup);
}
swapper(formula_ai& ai, position_callable& pos) :
ai(ai),
a(ai.get_info().units),
ai(ai),
a(ai.get_info().units),
b(pos.units_),
backup()
{
@ -131,7 +131,7 @@ public:
private:
variant execute(const formula_callable& variables) const {
const map_location loc = convert_variant<location_callable>(args()[0]->evaluate(variables))->loc();
variant items = args()[1]->evaluate(variables);
variant items = args()[1]->evaluate(variables);
int best = 1000000;
int best_i = -1;
@ -245,7 +245,7 @@ private:
vars.push_back(variant(new unit_callable(*un)));
}
}
++un;
++un;
}
return variant(&vars);
}
@ -299,7 +299,7 @@ private:
if (args().size() > 3) weapon = args()[3]->evaluate(variables).as_int();
else weapon = -1;
battle_context bc(ai_.get_info().map, ai_.get_info().teams, ai_.get_info().units,
ai_.get_info().state, convert_variant<location_callable>(args()[1]->evaluate(variables))->loc(),
ai_.get_info().state, convert_variant<location_callable>(args()[1]->evaluate(variables))->loc(),
convert_variant<location_callable>(args()[2]->evaluate(variables))->loc(), weapon, -1, 1.0, NULL,
&ai_.get_info().units.find(convert_variant<location_callable>(args()[0]->evaluate(variables))->loc())->second);
std::vector<double> hp_dist = bc.get_attacker_combatant().hp_dist;
@ -326,7 +326,7 @@ private:
status.push_back(variant("Zombiefied"));
vars.push_back(variant(new outcome_callable(hitLeft, prob, status)));
hitLeft.clear();
prob.clear();
prob.clear();
status.clear();
hp_dist = bc.get_defender_combatant().hp_dist;
it = hp_dist.begin();
@ -676,31 +676,31 @@ private:
};
class is_unowned_village_function : public function_expression {
public:
public:
explicit is_unowned_village_function(const args_list& args, const formula_ai& ai)
: function_expression("is_unowned_village", args, 2, 3),
ai_(ai)
{}
private:
private:
variant execute(const formula_callable& variables) const {
const gamemap& m = convert_variant<gamemap_callable>(args()[0]->evaluate(variables))->get_gamemap();
const gamemap& m = convert_variant<gamemap_callable>(args()[0]->evaluate(variables))->get_gamemap();
const std::set<map_location>& my_villages = ai_.current_team().villages();
map_location loc;
if(args().size() == 2) {
loc = convert_variant<location_callable>(args()[1]->evaluate(variables))->loc();
} else {
loc = map_location( args()[1]->evaluate(variables).as_int() - 1,
args()[2]->evaluate(variables).as_int() - 1 );
}
loc = map_location( args()[1]->evaluate(variables).as_int() - 1,
args()[2]->evaluate(variables).as_int() - 1 );
}
if(m.is_village(loc) && (my_villages.count(loc)==0) ) {
return variant(true);
} else {
return variant(false);
}
}
}
const formula_ai& ai_;
};
@ -802,7 +802,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(100 - un.defense_modifier(ai_.get_info().map[loc]));
}
@ -813,7 +813,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(100 - un.movement_type().defense_modifier(ai_.get_info().map, ai_.get_info().map[loc]));
}
@ -847,7 +847,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(un.defense_modifier(ai_.get_info().map[loc]));
}
@ -858,7 +858,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(un.movement_type().defense_modifier(ai_.get_info().map, ai_.get_info().map[loc]));
}
@ -892,7 +892,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(un.movement_cost(ai_.get_info().map[loc]));
}
@ -903,7 +903,7 @@ private:
if(!ai_.get_info().map.on_board(loc)) {
return variant();
}
return variant(un.movement_type().movement_cost(ai_.get_info().map, ai_.get_info().map[loc]));
}
@ -965,7 +965,7 @@ private:
const formula_ai& ai_;
};
class max_possible_damage_with_retaliation_function : public function_expression {
public:
@ -1016,7 +1016,7 @@ private:
best_ranged = dmg;
}
}
//we have max damage inflicted by attacker, now we need to search for max possible damage of defender (search only for attack with the same range)
vars.push_back(variant(best_melee));
vars.push_back(variant(best_ranged));
@ -1040,7 +1040,7 @@ private:
vars.push_back(variant(best_melee));
vars.push_back(variant(best_ranged));
return variant(&vars);
} else
{
const unit_type& defender = convert_variant<unit_type_callable>(u2)->get_unit_type();
@ -1084,7 +1084,7 @@ private:
} else
{
const unit_type& attacker = convert_variant<unit_type_callable>(u1)->get_unit_type();
att_attacks = attacker.attacks();
att_attacks = attacker.attacks();
const unit_callable* u_defender = try_convert_variant<unit_callable>(u2);
if (u_defender)
@ -1102,7 +1102,7 @@ private:
best_ranged = dmg;
}
}
//we have max damage inflicted by attacker, now we need to search for max possible damage of defender (search only for attack with the same range)
vars.push_back(variant(best_melee));
vars.push_back(variant(best_ranged));
@ -1126,7 +1126,7 @@ private:
vars.push_back(variant(best_melee));
vars.push_back(variant(best_ranged));
return variant(&vars);
} else
{
const unit_type& defender = convert_variant<unit_type_callable>(u2)->get_unit_type();
@ -1164,17 +1164,17 @@ private:
vars.push_back(variant(best_melee));
vars.push_back(variant(best_ranged));
return variant(&vars);
return variant(&vars);
}
}
}
const formula_ai& ai_;
};
}
}
namespace game_logic {
namespace game_logic {
expression_ptr ai_function_symbol_table::create_function(const std::string &fn,
const std::vector<expression_ptr>& args) const {
if(fn == "outcomes") {
@ -1238,25 +1238,25 @@ expression_ptr ai_function_symbol_table::create_function(const std::string &fn,
}
}
void ai_function_symbol_table::register_candidate_move(const std::string name,
const std::string type, const_formula_ptr formula, const_formula_ptr eval,
void ai_function_symbol_table::register_candidate_move(const std::string name,
const std::string type, const_formula_ptr formula, const_formula_ptr eval,
const_formula_ptr precondition, const std::vector<std::string>& args)
{
candidate_move_ptr new_move(new candidate_move(name,type,eval,formula));
candidate_moves.push_back(new_move);
function_symbol_table::add_formula_function(name, formula,
function_symbol_table::add_formula_function(name, formula,
precondition, args);
}
}
formula_ai::formula_ai(info& i) :
formula_ai::formula_ai(info& i) :
ai(i),
recruit_formula_(),
move_formula_(),
possible_moves_(),
move_maps_valid_(false),
move_maps_valid_(false),
srcdst_(),
dstsrc_(),
full_srcdst_(),
@ -1280,10 +1280,10 @@ formula_ai::formula_ai(info& i) :
}
// Register candidate moves in function symbol table
config::const_child_itors rc_moves =
config::const_child_itors rc_moves =
ai_param.child_range("register_candidate_move");
for(config::const_child_iterator i = rc_moves.first;
for(config::const_child_iterator i = rc_moves.first;
i != rc_moves.second; ++i) {
const t_string& name = (**i)["name"];
const t_string& inputs = (**i)["inputs"];
@ -1296,12 +1296,12 @@ formula_ai::formula_ai(info& i) :
game_logic::const_formula_ptr eval_formula(
new game_logic::formula((**i)["evaluation"], &function_table));
const formula_ptr precondition_formula =
game_logic::formula::create_optional_formula((**i)["precondition"],
const formula_ptr precondition_formula =
game_logic::formula::create_optional_formula((**i)["precondition"],
&function_table);
function_table.register_candidate_move(name, (**i)["type"],
action_formula, eval_formula,
action_formula, eval_formula,
precondition_formula, args);
}
catch(formula_error& e) {
@ -1335,7 +1335,7 @@ formula_ai::formula_ai(info& i) :
handle_exception(e, "Error while registering function '" + name + "'");
}
}
try{
recruit_formula_ = game_logic::formula::create_optional_formula(current_team().ai_parameters()["recruit"], &function_table);
}
@ -1381,7 +1381,7 @@ void formula_ai::display_message(const std::string& msg)
}
void formula_ai::new_turn()
void formula_ai::new_turn()
{
move_maps_valid_ = false;
ai::new_turn();
@ -1612,10 +1612,10 @@ bool formula_ai::execute_variant(const variant& var, bool commandline)
get_info().map.w(), get_info().map.h());
int movement = unit_it->second.movement_left();
for (std::vector<map_location>::const_iterator loc_iter = route.steps.begin() + 1 ; loc_iter !=route.steps.end(); ++loc_iter) {
const int move_cost = unit_it->second.movement_cost(get_info().map[*(loc_iter+1)]);
if ( move_cost > movement ) {
break;
}
@ -1650,10 +1650,10 @@ bool formula_ai::execute_variant(const variant& var, bool commandline)
get_info().map.w(), get_info().map.h());
int movement = unit_it->second.movement_left();
for (std::vector<map_location>::const_iterator loc_iter = route.steps.begin() + 1 ; loc_iter !=route.steps.end(); ++loc_iter) {
const int move_cost = unit_it->second.movement_cost(get_info().map[*(loc_iter+1)]);
if ( move_cost > movement ) {
break;
}
@ -1848,7 +1848,7 @@ variant formula_ai::get_value(const std::string& key) const
} else if(key == "my_side")
{
return variant(new team_callable((*get_info().state.teams)[get_info().team_num-1]));
} else if(key == "my_side_number")
{
return variant(get_info().team_num-1);
@ -2043,7 +2043,7 @@ void formula_ai::get_inputs(std::vector<formula_input>* inputs) const
inputs->push_back(game_logic::formula_input("my_recruits", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("recruits_of_side", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("units", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("units_of_side", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("units_of_side", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("my_units", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("enemy_units", FORMULA_READ_ONLY));
inputs->push_back(game_logic::formula_input("villages", FORMULA_READ_ONLY));
@ -2079,10 +2079,10 @@ variant formula_ai::get_keeps() const
return keeps_cache_;
}
bool formula_ai::can_attack(const map_location unit_loc,
bool formula_ai::can_attack(const map_location unit_loc,
const map_location enemy_loc) const {
move_map::iterator i;
std::pair<move_map::iterator,
std::pair<move_map::iterator,
move_map::iterator> unit_moves;
unit_moves = srcdst_.equal_range(unit_loc);
for(i = unit_moves.first; i != unit_moves.second; ++i) {
@ -2095,13 +2095,13 @@ bool formula_ai::can_attack(const map_location unit_loc,
}
void candidate_move::evaluate_move(const formula_ai* ai, unit_map& units,
void candidate_move::evaluate_move(const formula_ai* ai, unit_map& units,
size_t team_num) {
score_ = -1000;
if(type_ == "attack") {
for(unit_map::unit_iterator me = units.begin() ; me != units.end() ; ++me)
{
if( (me->second.side() == team_num) &&
if( (me->second.side() == team_num) &&
(me->second.has_moved() == false) ) {
for(unit_map::unit_iterator target = units.begin() ; target != units.end() ; ++target) {
if( (target->second.side() != team_num) &&
@ -2123,7 +2123,7 @@ void candidate_move::evaluate_move(const formula_ai* ai, unit_map& units,
} else {
for(unit_map::unit_iterator i = units.begin() ; i != units.end() ; ++i)
{
if( (i->second.side() == team_num) &&
if( (i->second.side() == team_num) &&
(i->second.has_moved() == false) ) {
game_logic::map_formula_callable callable((formula_callable*) ai);
callable.add_ref();

View file

@ -40,7 +40,7 @@ public:
enemy_unit_()
{};
void evaluate_move(const formula_ai* ai, unit_map& units, size_t team_num);
void evaluate_move(const formula_ai* ai, unit_map& units, size_t team_num);
int get_score() const {return score_;}
std::string get_type() const {return type_;}
@ -50,7 +50,7 @@ public:
struct move_compare {
bool operator() (const boost::shared_ptr<candidate_move> lmove,
const boost::shared_ptr<candidate_move> rmove) const
const boost::shared_ptr<candidate_move> rmove) const
{
return lmove->get_score() < rmove->get_score();
}
@ -68,36 +68,36 @@ private:
};
typedef boost::shared_ptr<candidate_move> candidate_move_ptr;
typedef boost::shared_ptr<candidate_move> candidate_move_ptr;
typedef std::set<game_logic::candidate_move_ptr, game_logic::candidate_move::move_compare> candidate_move_set;
class ai_function_symbol_table : public function_symbol_table {
public:
explicit ai_function_symbol_table(formula_ai& ai) :
explicit ai_function_symbol_table(formula_ai& ai) :
ai_(ai),
move_functions(),
candidate_moves()
{}
void register_candidate_move(const std::string name, const std::string type,
const_formula_ptr formula, const_formula_ptr eval,
const_formula_ptr formula, const_formula_ptr eval,
const_formula_ptr precondition, const std::vector<std::string>& args);
std::vector<candidate_move_ptr>::iterator candidate_move_begin() {
return candidate_moves.begin();
}
return candidate_moves.begin();
}
std::vector<candidate_move_ptr>::iterator candidate_move_end() {
return candidate_moves.end();
}
return candidate_moves.end();
}
private:
formula_ai& ai_;
std::set<std::string> move_functions;
std::vector<candidate_move_ptr> candidate_moves;
expression_ptr create_function(const std::string& fn,
const std::vector<expression_ptr>& args) const;
const std::vector<expression_ptr>& args) const;
};
}
@ -118,7 +118,7 @@ public:
std::string evaluate(const std::string& formula_str);
struct move_map_backup {
move_map_backup() :
move_map_backup() :
move_maps_valid(false),
srcdst(),
dstsrc(),
@ -144,7 +144,7 @@ public:
const variant& get_keeps_cache() const { return keeps_cache_; }
// Check if given unit loc can reach attack range of enemy loc
// Check if given unit loc can reach attack range of enemy loc
bool can_attack (const map_location, const map_location) const;
const std::map<location,paths>& get_possible_moves() const { prepare_move(); return possible_moves_; }

View file

@ -70,7 +70,7 @@ public:
serialize_to_string(str);
}
bool has_key(const std::string& key) const
bool has_key(const std::string& key) const
{ return !query_value(key).is_null(); }
protected:

View file

@ -465,8 +465,8 @@ class variant_comparator : public formula_callable {
fallback_->get_inputs(inputs);
}
public:
variant_comparator(const expression_ptr& expr, const formula_callable& fallback) :
expr_(expr),
variant_comparator(const expression_ptr& expr, const formula_callable& fallback) :
expr_(expr),
fallback_(&fallback),
a_(),
b_()
@ -764,17 +764,17 @@ private:
}
variant key_value_pair::get_value(const std::string& key) const
{
if(key == "key")
{
return key_;
} else
if(key == "value")
{
return value_;
variant key_value_pair::get_value(const std::string& key) const
{
if(key == "key")
{
return key_;
} else
if(key == "value")
{
return value_;
} else
return variant();
return variant();
}
void key_value_pair::get_inputs(std::vector<game_logic::formula_input>* inputs) const {

View file

@ -71,10 +71,10 @@ class key_value_pair : public formula_callable {
variant value_;
variant get_value(const std::string& key) const;
void get_inputs(std::vector<game_logic::formula_input>* inputs) const;
public:
explicit key_value_pair(const variant& key, const variant& value) : key_(key), value_(value) {}
void get_inputs(std::vector<game_logic::formula_input>* inputs) const;
public:
explicit key_value_pair(const variant& key, const variant& value) : key_(key), value_(value) {}
};
class formula_function_expression : public function_expression {
@ -108,7 +108,7 @@ public:
{}
function_expression_ptr generate_function_expression(const std::vector<expression_ptr>& args) const;
};
};
class function_symbol_table {
std::map<std::string, formula_function> custom_formulas_;

View file

@ -61,7 +61,7 @@ token get_token(iterator& i1, iterator i2) {
res.type = t.type;
res.begin = i1;
i1 = res.end = i1 + match.length();
return res;
}
}

View file

@ -24,13 +24,13 @@ typedef std::string::const_iterator iterator;
enum TOKEN_TYPE { TOKEN_OPERATOR, TOKEN_STRING_LITERAL,
TOKEN_IDENTIFIER, TOKEN_INTEGER,
TOKEN_LPARENS, TOKEN_RPARENS,
TOKEN_LSQUARE, TOKEN_RSQUARE,
TOKEN_LSQUARE, TOKEN_RSQUARE,
TOKEN_COMMA, TOKEN_SEMICOLON,
TOKEN_WHITESPACE, TOKEN_EOL, TOKEN_KEYWORD,
TOKEN_COMMENT, TOKEN_POINTER };
struct token {
token() :
type(TOKEN_COMMENT),
begin(),
@ -48,7 +48,7 @@ struct token {
token get_token(iterator& i1, iterator i2);
struct token_error
struct token_error
{
token_error() : description_(), formula_() {}
token_error(const std::string& dsc, const std::string& formula) : description_(dsc), formula_(formula) {}

View file

@ -409,9 +409,9 @@ game_controller::game_controller(int argc, char** argv) :
#ifdef _WIN32
// use c_str to ensure that index 1 points to valid element since c_str() returns null-terminated string
if(val.c_str()[1] == ':') {
#else
#else
if(val[0] == '/') {
#endif
#endif
game_config::path = val;
} else {
game_config::path = get_cwd() + '/' + val;
@ -810,7 +810,7 @@ bool game_controller::play_multiplayer_mode()
std::cerr << "Could not find any non-random faction for side " << side_num << "\n";
return false;
}
std::cerr << " Faction " << (*side)["name"] <<
std::cerr << " Faction " << (*side)["name"] <<
" selected for side " << side_num << ".\n";
}
@ -1168,7 +1168,7 @@ bool game_controller::goto_editor()
if (start_editor(loaded_game_) == editor2::EXIT_QUIT_TO_DESKTOP) {
return false;
}
loaded_game_ = "";
loaded_game_ = "";
}
return true;
}
@ -1840,10 +1840,10 @@ static int process_command_args(int argc, char** argv) {
return 0;
} else if(val == "--python-shell") {
int ret = python_ai::run_shell();
if (ret==0) {
if (ret==0) {
return 0;
} else {
return 2;
return 2;
}
#endif
} else if(val == "--config-dir") {

View file

@ -89,7 +89,7 @@ namespace game_config
std::string level_image;
std::string ellipsis_image;
std::string default_victory_music;
std::string default_defeat_music;

View file

@ -115,7 +115,7 @@ namespace game_config
extern const version_info wesnoth_version;
extern const version_info min_savegame_version;
extern const std::string test_version;
/**
* Tests whether the given version is compatible with the
* running version, i.e. >= MIN_SAVEGAME_VERSION.

View file

@ -263,7 +263,7 @@ void game_display::pre_draw() {
previous_invalidated_.swap(invalidated_);
invalidated_.insert(previous_invalidated_.begin(),previous_invalidated_.end());
// call invalidate_animation again to deal with new conflict arising from the merge
// no conflict, if a hex was invalidated last turn but not this turn, then
// no conflict, if a hex was invalidated last turn but not this turn, then
// * case of no unit in neighbour hex=> no propagation
// * case of unit in hex but was there last turn=>its hexes are invalidated too
// * case of unit inhex not there last turn => it moved, so was invalidated previously
@ -281,9 +281,9 @@ std::vector<map_location> game_display::get_invalidated_unit_locations() {
foreach (const map_location& loc, invalidated_) {
if ((temp_unit_ && temp_unit_loc_ == loc) || units_.find(loc) != units_.end()) {
unit_locations.push_back(loc);
}
}
}
//sorted according to a drawing ordering object in order to render correctly
//sorted according to a drawing ordering object in order to render correctly
std::sort(unit_locations.begin(), unit_locations.end(), ordered_draw());
return unit_locations;
}
@ -294,7 +294,7 @@ image::TYPE game_display::get_image_type(const map_location& loc) {
if (loc == mouseoverHex_ || loc == attack_indicator_src_) {
return image::BRIGHTENED;
} else if (loc == selectedHex_) {
unit_map::iterator un = find_visible_unit(units_, loc, get_map(),
unit_map::iterator un = find_visible_unit(units_, loc, get_map(),
teams_,teams_[currentTeam_]);
if (un != units_.end()) {
return image::BRIGHTENED;
@ -313,7 +313,7 @@ void game_display::draw_invalidated()
redraw_units(unit_invals);
}
void game_display::post_commit()
void game_display::post_commit()
{
halo::render();
}
@ -327,11 +327,11 @@ void game_display::draw_hex(const map_location& loc)
int ypos = get_location_y(loc);
int drawing_order = loc.get_drawing_order();
tblit blit(xpos, ypos);
image::TYPE image_type = get_image_type(loc);
display::draw_hex(loc);
if(!is_shrouded) {
typedef overlay_map::const_iterator Itor;
std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
@ -345,9 +345,9 @@ void game_display::draw_hex(const map_location& loc)
}
}
// village-control flags.
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos, get_flag(loc)));
drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, tblit(xpos, ypos, get_flag(loc)));
}
// Draw the time-of-day mask on top of the terrain in the hex.
// tod may differ from tod if hex is illuminated.
std::string tod_hex_mask = timeofday_at(status_,units_,loc,get_map()).image_mask;
@ -396,7 +396,7 @@ void game_display::draw_hex(const map_location& loc)
if(!is_shrouded && on_map) {
draw_movement_info(loc);
}
//simulate_delay += 1;
//simulate_delay += 1;
}
void game_display::update_time_of_day()

View file

@ -45,9 +45,9 @@ public:
const gamemap& map, const gamestatus& status,
const std::vector<team>& t, const config& theme_cfg,
const config& cfg, const config& level);
static game_display* create_dummy_display(CVideo& video);
~game_display();
static game_display* get_singleton() { return singleton_ ;}
@ -112,7 +112,7 @@ public:
/** Reset highlighting of paths. */
void unhighlight_reach();
/**
* Sets the route along which footsteps are drawn to show movement of a
* unit. If NULL, no route is displayed. route does not have to remain
@ -147,41 +147,41 @@ protected:
* game_display pre_draw does specific things related e.g. to unit rendering
*/
void pre_draw();
/**
* This function runs through invalidated_ and returns a vector of tiles
* containing units, sorted according to a custom ordering
*/
std::vector<map_location> get_invalidated_unit_locations();
/**
* Hex brightening for game - take units into account
*/
image::TYPE get_image_type(const map_location& loc);
/**
* Draws units on specified hexes
*/
void redraw_units(const std::vector<map_location>& invalidated_unit_locations);
void draw_invalidated();
void post_commit();
void draw_hex(const map_location& loc);
void update_time_of_day();
/**
* Animated hex invalidation specific to gameplay
*/
void invalidate_animations();
/**
* Extra game per-location invalidation (village ownership)
*/
void invalidate_animations_location(const map_location& loc);
virtual void draw_minimap_units();
public:
@ -194,7 +194,7 @@ public:
void clear_attack_indicator();
/** Function to get attack direction suffix. */
std::string attack_indicator_direction() const {
std::string attack_indicator_direction() const {
return map_location::write_direction(
attack_indicator_src_.get_relative_dir(attack_indicator_dst_));
}
@ -205,7 +205,7 @@ public:
* An overlay is an image that is displayed on top of the tile.
* One tile may have multiple overlays.
*/
void add_overlay(const map_location& loc, const std::string& image,
void add_overlay(const map_location& loc, const std::string& image,
const std::string& halo="", const std::string& team_name="",
const std::string& fogged="yes");
@ -388,7 +388,7 @@ private:
std::vector<animated<image::locator> > flags_;
/**
* the tiles invalidated at last redraw,
* the tiles invalidated at last redraw,
* to simplify the cleaning up of tiles left by units
*/
std::set<map_location> previous_invalidated_;

View file

@ -19,8 +19,8 @@
namespace game {
struct error {
error() :
message()
error() :
message()
{}
error(const std::string& msg) : message(msg)
{}
@ -52,7 +52,7 @@ struct game_error : public error {
//an exception object used to signal that the user has decided to abort
//a game, and load another game instead
struct load_game_exception {
load_game_exception(const std::string& game, bool show_replay, bool cancel_orders)
load_game_exception(const std::string& game, bool show_replay, bool cancel_orders)
: game(game), show_replay(show_replay), cancel_orders(cancel_orders) {}
std::string game;
bool show_replay;

View file

@ -2521,7 +2521,7 @@ namespace {
const std::string result = cfg["result"].base_str(); //do not translate
const std::string endlevel_music = cfg["music"];
const bool carryover_report = utils::string_bool(cfg["carryover_report"],true);
const bool save = utils::string_bool(cfg["save"],true);
const bool linger_mode = utils::string_bool(cfg["linger_mode"],true);

View file

@ -87,7 +87,7 @@ manager::manager() :
[history_id]
[line]
message = foobar
[/line]
[/line]
*/
const config::child_map& history_id_list = history->all_children();
typedef std::pair<std::string, config::child_list> hack;
@ -125,12 +125,12 @@ manager::~manager()
[history_id]
[line]
message = foobar
[/line]
[/line]
*/
config history;
typedef std::pair<std::string, std::vector<std::string> > hack;
foreach(const hack& history_id, history_map) {
config history_id_cfg; // [history_id]
foreach(const std::string& line, history_id.second) {
config cfg; // [line]
@ -777,7 +777,7 @@ void set_custom_command(const std::string& command) {
/**
* Returns a pointer to the history vector associated with given id
* making a new one if it doesn't exist.
*
*
* @todo FIXME only used for gui2. Could be used for the above histories.
*/
std::vector<std::string>* get_history(const std::string& id) {

View file

@ -52,7 +52,7 @@ namespace preferences {
void clear_ignores();
bool is_friend(const std::string& nick);
bool is_ignored(const std::string& nick);
bool sort_list();
void _set_sort_list(bool show);
@ -63,7 +63,7 @@ namespace preferences {
std::string network_host();
void set_network_host(const std::string& host);
unsigned int get_ping_timeout();
void set_ping_timeout(unsigned int timeout);

View file

@ -144,7 +144,7 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
UI_sound_slider_(disp.video()), bell_slider_(disp.video()),
scroll_slider_(disp.video()), gamma_slider_(disp.video()),
chat_lines_slider_(disp.video()), buffer_size_slider_(disp.video()),
idle_anim_slider_(disp.video()), autosavemax_slider_(disp.video()),
idle_anim_slider_(disp.video()), autosavemax_slider_(disp.video()),
turbo_slider_(disp.video()),
@ -1194,7 +1194,7 @@ std::string show_wesnothd_server_search(display& disp)
#ifndef WESNOTH_PREFIX
#define WESNOTH_PREFIX "/usr"
#endif
#endif
const std::string filename = "wesnothd";
std::string path = WESNOTH_PREFIX + std::string("/bin");
if (!is_directory(path))
@ -1215,7 +1215,7 @@ std::string show_wesnothd_server_search(display& disp)
symbols["filename"] = filename;
const std::string title = vgettext("Find $filename server binary to host networked games", symbols);
int res = dialogs::show_file_chooser_dialog(disp, path, title, false, filename);
if (res == 0)
return path;

View file

@ -170,7 +170,7 @@ void gamestatus::remove_time_area(const std::string& area_id)
while(i != areas_.end()) {
if((*i).id == area_id) {
i = areas_.erase(i);
} else {
} else {
++i;
}
}
@ -271,9 +271,9 @@ time_of_day gamestatus::get_time_of_day(int illuminated, const map_location& loc
if(loc.valid()) {
for(std::vector<area_time_of_day>::const_iterator i = areas_.begin(); i != areas_.end(); ++i) {
if(i->hexes.count(loc) == 1) {
VALIDATE(i->times.size(), _("No time of day has been defined."));
res = i->times[(n_turn-1)%i->times.size()];
break;
}
@ -391,7 +391,7 @@ void gamestatus::set_turn(unsigned int num)
this->add_turns(numTurns_ - num);
}
turn_ = num;
LOG_NG << "changed current turn number from " << old_num << " to " << num << '\n';
}
@ -603,7 +603,7 @@ static void write_player(config_writer &out, const player_info& player)
snprintf(buf,sizeof(buf),"%d",player.gold);
out.write_key_val("gold", buf);
const std::string gold_add = player.gold_add ? "true" : "false";
out.write_key_val("gold_add", gold_add);
@ -653,7 +653,7 @@ void write_game(const game_state& gamestate, config& cfg, WRITE_GAME_MODE mode)
cfg["random_seed"] = lexical_cast<std::string>(gamestate.rng().get_random_seed());
cfg["random_calls"] = lexical_cast<std::string>(gamestate.rng().get_random_calls());
cfg["end_text"] = gamestate.end_text;
cfg["end_text_duration"] = str_cast<unsigned int>(gamestate.end_text_duration);
@ -1220,7 +1220,7 @@ static void clear_wmi(std::map<std::string, wml_menu_item*>& gs_wmi) {
gs_wmi.clear();
}
game_state::game_state(const game_state& state) :
game_state::game_state(const game_state& state) :
/* default construct everything to silence compiler warnings. */
variable_set(),
label(),

View file

@ -56,7 +56,7 @@ struct player_info
std::string name; /**< Stores the current_player name */
int gold; /**< Amount of gold the player has saved */
bool gold_add; /**<
bool gold_add; /**<
* Amount of gold is added to the
* starting gold, if not it uses the
* highest of the two.
@ -102,7 +102,7 @@ public:
/** Return the Nth player, or NULL if no such player exists. */
player_info* get_player(const std::string& id);
/**
* Loads the recall list.
*
@ -220,12 +220,12 @@ public:
bool next_turn();
static bool is_start_ToD(const std::string&);
/**
* Adds a new local time area from config, making it follow its own
* time-of-day sequence.
*
* @param cfg Config object containing x,y range/list of
* @param cfg Config object containing x,y range/list of
* locations and desired [time] information.
*/
void add_time_area(const config& cfg);

View file

@ -26,6 +26,6 @@
// Disable warning about deprecated functions.
#pragma warning(disable: 4996)
#endif
#endif
#endif

View file

@ -104,7 +104,7 @@ public:
void set_visible_area(const SDL_Rect& area);
/** Inherited from twidget. */
void impl_draw_children(surface& frame_buffer)
void impl_draw_children(surface& frame_buffer)
{ grid_.draw_children(frame_buffer); }
/** Inherited from twidget. */

View file

@ -85,7 +85,7 @@ std::string get_base_filename()
* Shows the size info of
* children/widgets.
*/
const unsigned STATE_INFO = 1 << 1; /**<
const unsigned STATE_INFO = 1 << 1; /**<
* Shows the state info of widgets.
*/
unsigned level_ = 0;

View file

@ -193,7 +193,7 @@ static void set_scrollbar_mode(tgrid* scrollbar_grid, tscrollbar_* scrollbar,
scrollbar->set_item_count(items);
scrollbar->set_visible_items(visible_items);
const bool scrollbar_needed =
const bool scrollbar_needed =
items > visible_items;
if(!scrollbar_needed) {
@ -246,13 +246,13 @@ void tscrollbar_container::
// Set vertical scrollbar
set_scrollbar_mode(vertical_scrollbar_grid_, vertical_scrollbar_,
vertical_scrollbar_mode_,
vertical_scrollbar_mode_,
content_grid_->get_height(),
content_->get_height());
// Set horizontal scrollbar
set_scrollbar_mode(horizontal_scrollbar_grid_, horizontal_scrollbar_,
horizontal_scrollbar_mode_,
horizontal_scrollbar_mode_,
content_grid_->get_width(),
content_->get_width());
@ -290,7 +290,7 @@ void tscrollbar_container::set_visible_area(const SDL_Rect& area)
tcontainer_::set_visible_area(area);
// Now get the visible part of the content.
content_visible_area_ =
content_visible_area_ =
get_rect_union(area, content_->get_screen_rect());
content_grid_->set_visible_area(content_visible_area_);
@ -315,7 +315,7 @@ const twidget* tscrollbar_container::find_widget(const tpoint& coordinate,
{
assert(content_ && content_grid_);
const twidget* result =
const twidget* result =
tcontainer_::find_widget(coordinate, must_be_active);
if(result != content_) {
@ -328,17 +328,17 @@ const twidget* tscrollbar_container::find_widget(const tpoint& coordinate,
bool tscrollbar_container::does_block_easy_close() const
{
assert(vertical_scrollbar_grid_
assert(vertical_scrollbar_grid_
&& vertical_scrollbar_
&& horizontal_scrollbar_grid_
&& horizontal_scrollbar_);
const bool vertical_block = vertical_scrollbar_grid_->is_visible()
&& !(vertical_scrollbar_->at_begin()
const bool vertical_block = vertical_scrollbar_grid_->is_visible()
&& !(vertical_scrollbar_->at_begin()
&& vertical_scrollbar_->at_end());
const bool horizontal_block = horizontal_scrollbar_grid_->is_visible()
&& !(horizontal_scrollbar_->at_begin()
const bool horizontal_block = horizontal_scrollbar_grid_->is_visible()
&& !(horizontal_scrollbar_->at_begin()
&& horizontal_scrollbar_->at_end());
return vertical_block || horizontal_block;

View file

@ -223,7 +223,7 @@ private:
/** Dummy spacer to hold the contents location. */
tspacer *content_;
/**
/**
* Cache for the visible area for the content.
*
* The visible area for the content needs to be updated when scrolling.

View file

@ -63,9 +63,9 @@ void twidget::set_size(const tpoint& origin, const tpoint& size)
SDL_Rect twidget::get_dirty_rect() const
{
return drawing_action_ == DRAWN
return drawing_action_ == DRAWN
? get_screen_rect()
: clip_rect_;
: clip_rect_;
}
twindow* twidget::get_window()
@ -108,7 +108,7 @@ void twidget::populate_dirty_list(twindow& caller,
if(!is_visible()) {
return;
}
if(drawing_action_ == NOT_DRAWN) {
return;
}
@ -153,32 +153,32 @@ void twidget::set_visible_area(const SDL_Rect& area)
}
void twidget::draw_background(surface& frame_buffer)
{
{
if(drawing_action_ == PARTLY_DRAWN) {
clip_rect_setter clip(frame_buffer, clip_rect_);
impl_draw_background(frame_buffer);
impl_draw_background(frame_buffer);
} else {
impl_draw_background(frame_buffer);
impl_draw_background(frame_buffer);
}
}
void twidget::draw_children(surface& frame_buffer)
{
{
if(drawing_action_ == PARTLY_DRAWN) {
clip_rect_setter clip(frame_buffer, clip_rect_);
impl_draw_children(frame_buffer);
impl_draw_children(frame_buffer);
} else {
impl_draw_children(frame_buffer);
impl_draw_children(frame_buffer);
}
}
void twidget::draw_foreground(surface& frame_buffer)
{
void twidget::draw_foreground(surface& frame_buffer)
{
if(drawing_action_ == PARTLY_DRAWN) {
clip_rect_setter clip(frame_buffer, clip_rect_);
impl_draw_foreground(frame_buffer);
impl_draw_foreground(frame_buffer);
} else {
impl_draw_foreground(frame_buffer);
impl_draw_foreground(frame_buffer);
}
}

View file

@ -104,7 +104,7 @@ public:
*/
INVISIBLE };
/**
/**
* Visibility set by the engine.
*
* This state only will be used if the widget is visible, depending on
@ -495,13 +495,13 @@ public:
/** Returns the screen origin of the widget. */
tpoint get_origin() const { return tpoint(screen_x_, screen_y_); }
/**
/**
* Gets the sizes in one rect structure.
*
* @todo this function can be renamed to get_rect() when the old get_rect
* has been removed.
*/
SDL_Rect get_screen_rect() const
SDL_Rect get_screen_rect() const
{ return create_rect(get_origin(), get_size()); }
/**
@ -568,7 +568,7 @@ public:
/** Returns the dirty state for a widget, final function. */
bool get_dirty() const { return dirty_; }
/**
/**
* Draws the background of a widget.
*
* Subclasses should override impl_draw_background instead of changing

View file

@ -332,7 +332,7 @@ void twindow::draw()
for(std::vector<twidget*>::iterator itor = item.begin();
itor != item.end(); ++itor) {
if(!(**itor).is_visible()
if(!(**itor).is_visible()
|| (**itor).get_drawing_action() == twidget::NOT_DRAWN) {
item.erase(itor, item.end());

View file

@ -380,7 +380,7 @@ private:
void do_show_help_popup(const tpoint& location, const t_string& help_popup);
/** Inherited from tevent_handler. */
void do_remove_help_popup()
void do_remove_help_popup()
{ help_popup_.set_visible(twidget::HIDDEN); }
/** Inherited from tevent_handler. */

View file

@ -158,7 +158,7 @@ public:
twidget* build () const;
tscrollbar_container::tscrollbar_mode
tscrollbar_container::tscrollbar_mode
vertical_scrollbar_mode,
horizontal_scrollbar_mode;

View file

@ -13,7 +13,7 @@
*/
/**
* @file halo.cpp
* @file halo.cpp
* Maintain halo-effects for units and items.
* Examples: white mage, lighthouse.
*/
@ -99,13 +99,13 @@ std::set<int> changing_haloes;
effect::effect(int xpos, int ypos, const animated<std::string>::anim_description& img,
const map_location& loc, ORIENTATION orientation, bool infinite) :
images_(img),
orientation_(orientation),
x_(xpos),
images_(img),
orientation_(orientation),
x_(xpos),
y_(ypos),
surf_(NULL),
buffer_(NULL),
rect_(empty_rect),
surf_(NULL),
buffer_(NULL),
rect_(empty_rect),
loc_(loc),
overlayed_hexes_()
{
@ -140,16 +140,16 @@ bool effect::render()
if(disp->shrouded(loc_)) {
return false;
} else {
// The location of a halo is an x,y value and not a map location.
// This means when a map is zoomed, the halo's won't move,
// This glitch is most visible on [item] haloes.
// This workaround always recalculates the location of the halo
// (item haloes have a location parameter to hide them under the shroud)
// The location of a halo is an x,y value and not a map location.
// This means when a map is zoomed, the halo's won't move,
// This glitch is most visible on [item] haloes.
// This workaround always recalculates the location of the halo
// (item haloes have a location parameter to hide them under the shroud)
// and reapplies that location.
// It might be optimized by storing and comparing the zoom value.
set_location(
disp->get_location_x(loc_) + disp->hex_size() / 2,
disp->get_location_y(loc_) + disp->hex_size() / 2);
disp->get_location_x(loc_) + disp->hex_size() / 2,
disp->get_location_y(loc_) + disp->hex_size() / 2);
}
}
@ -176,7 +176,7 @@ bool effect::render()
rect_ = rect;
SDL_Rect clip_rect = disp->map_outside_area();
// If rendered the first time, need to determine the area affected.
// If rendered the first time, need to determine the area affected.
// If a halo changes size, it is not updated.
if(overlayed_hexes_.empty()) {
display::rect_of_hexes hexes = disp->hexes_under_rect(rect);
@ -220,7 +220,7 @@ void effect::unrender()
SDL_Rect clip_rect = disp->map_outside_area();
const clip_rect_setter clip_setter(screen,clip_rect);
// Due to scrolling, the location of the rendered halo
// Due to scrolling, the location of the rendered halo
// might have changed; recalculate
const map_location zero_loc(0,0);
const int screenx = disp->get_location_x(zero_loc);
@ -312,7 +312,7 @@ void set_location(int handle, int x, int y)
void remove(int handle)
{
// Silently ignore invalid haloes.
// Silently ignore invalid haloes.
// This happens when Wesnoth is being terminated as well.
if(handle == NO_HALO || haloes.find(handle) == haloes.end()) {
return;
@ -355,12 +355,12 @@ void unrender(std::set<map_location> invalidated_locations)
// Find all halo's in a the invalidated area
size_t halo_count;
// Repeat until set of haloes in the invalidated area didn't change
// Repeat until set of haloes in the invalidated area didn't change
// (including none found) or all exisiting haloes are found.
do {
halo_count = invalidated_haloes.size();
for(itor = haloes.begin(); itor != haloes.end(); ++itor) {
// Test all haloes not yet in the set
// Test all haloes not yet in the set
// which match one of the locations
if(invalidated_haloes.find(itor->first) == invalidated_haloes.end() &&
itor->second.on_location(invalidated_locations)) {
@ -405,11 +405,11 @@ void render()
return;
}
// Keep track of not rendered new images they have to be kept scheduled
// Keep track of not rendered new images they have to be kept scheduled
// for rendering otherwise the invalidation area is never properly set
std::set<int> unrendered_new_haloes;
// Render the haloes:
// Render the haloes:
// iterate through all the haloes and draw if in either set
for(std::map<int, effect>::iterator itor = haloes.begin();
itor != haloes.end(); ++itor) {

Some files were not shown because too many files have changed in this diff Show more