NULL -> nullptr
A few cases of NULL were missed, since changing them led to errors (Mainly instances where it was passed to a boost::function)
This commit is contained in:
parent
486cf46993
commit
3ac7f8d970
423 changed files with 2380 additions and 2390 deletions
|
@ -108,7 +108,7 @@ int main (int argc, char **argv)
|
||||||
}
|
}
|
||||||
gArgs.push_back(argv[i]);
|
gArgs.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
gArgs.push_back(NULL);
|
gArgs.push_back(nullptr);
|
||||||
|
|
||||||
[SDLApplication sharedApplication];
|
[SDLApplication sharedApplication];
|
||||||
[NSBundle loadNibNamed:@"SDLMain" owner:NSApp];
|
[NSBundle loadNibNamed:@"SDLMain" owner:NSApp];
|
||||||
|
|
|
@ -73,16 +73,16 @@ int SDL_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
|
||||||
/* Initialize and do basic error checking */
|
/* Initialize and do basic error checking */
|
||||||
if (!dst)
|
if (!dst)
|
||||||
{
|
{
|
||||||
SDL_SetError("Argument 2 to SDL_SavePNG_RW can't be NULL, expecting SDL_RWops*\n");
|
SDL_SetError("Argument 2 to SDL_SavePNG_RW can't be nullptr, expecting SDL_RWops*\n");
|
||||||
return (SAVEPNG_ERROR);
|
return (SAVEPNG_ERROR);
|
||||||
}
|
}
|
||||||
if (!surface)
|
if (!surface)
|
||||||
{
|
{
|
||||||
SDL_SetError("Argument 1 to SDL_SavePNG_RW can't be NULL, expecting SDL_Surface*\n");
|
SDL_SetError("Argument 1 to SDL_SavePNG_RW can't be nullptr, expecting SDL_Surface*\n");
|
||||||
if (freedst) SDL_RWclose(dst);
|
if (freedst) SDL_RWclose(dst);
|
||||||
return (SAVEPNG_ERROR);
|
return (SAVEPNG_ERROR);
|
||||||
}
|
}
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, png_error_SDL, NULL); /* err_ptr, err_fn, warn_fn */
|
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, png_error_SDL, nullptr); /* err_ptr, err_fn, warn_fn */
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
{
|
{
|
||||||
SDL_SetError("Unable to png_create_write_struct on %s\n", PNG_LIBPNG_VER_STRING);
|
SDL_SetError("Unable to png_create_write_struct on %s\n", PNG_LIBPNG_VER_STRING);
|
||||||
|
@ -93,7 +93,7 @@ int SDL_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
|
||||||
if (!info_ptr)
|
if (!info_ptr)
|
||||||
{
|
{
|
||||||
SDL_SetError("Unable to png_create_info_struct\n");
|
SDL_SetError("Unable to png_create_info_struct\n");
|
||||||
png_destroy_write_struct(&png_ptr, NULL);
|
png_destroy_write_struct(&png_ptr, nullptr);
|
||||||
if (freedst) SDL_RWclose(dst);
|
if (freedst) SDL_RWclose(dst);
|
||||||
return (SAVEPNG_ERROR);
|
return (SAVEPNG_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ int SDL_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup our RWops writer */
|
/* Setup our RWops writer */
|
||||||
png_set_write_fn(png_ptr, dst, png_write_SDL, NULL); /* w_ptr, write_fn, flush_fn */
|
png_set_write_fn(png_ptr, dst, png_write_SDL, nullptr); /* w_ptr, write_fn, flush_fn */
|
||||||
|
|
||||||
/* Prepare chunks */
|
/* Prepare chunks */
|
||||||
colortype = PNG_COLOR_MASK_COLOR;
|
colortype = PNG_COLOR_MASK_COLOR;
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include <algorithm> // for max
|
#include <algorithm> // for max
|
||||||
#include <boost/foreach.hpp> // for auto_any_base, etc
|
#include <boost/foreach.hpp> // for auto_any_base, etc
|
||||||
#include <boost/scoped_ptr.hpp> // for scoped_ptr
|
#include <boost/scoped_ptr.hpp> // for scoped_ptr
|
||||||
#include <cstddef> // for NULL
|
|
||||||
#include <map> // for map, map<>::mapped_type
|
#include <map> // for map, map<>::mapped_type
|
||||||
#include <ostream> // for operator<<, basic_ostream, etc
|
#include <ostream> // for operator<<, basic_ostream, etc
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ void show_about(CVideo &video, const std::string &campaign)
|
||||||
{
|
{
|
||||||
boost::scoped_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
|
boost::scoped_ptr<cursor::setter> cur(new cursor::setter(cursor::WAIT));
|
||||||
surface& screen = video.getSurface();
|
surface& screen = video.getSurface();
|
||||||
if (screen == NULL) return;
|
if (screen == nullptr) return;
|
||||||
|
|
||||||
// If the title is multi-line, we need to split it accordingly or we
|
// If the title is multi-line, we need to split it accordingly or we
|
||||||
// get slight scrolling glitches in the credits screen.
|
// get slight scrolling glitches in the credits screen.
|
||||||
|
@ -350,14 +349,14 @@ void show_about(CVideo &video, const std::string &campaign)
|
||||||
|
|
||||||
if (redraw_mapimage) {
|
if (redraw_mapimage) {
|
||||||
// draw map to screen, thus erasing all text
|
// draw map to screen, thus erasing all text
|
||||||
sdl_blit(map_image_scaled, NULL, screen, NULL);
|
sdl_blit(map_image_scaled, nullptr, screen, nullptr);
|
||||||
update_rect(screen_rect);
|
update_rect(screen_rect);
|
||||||
|
|
||||||
// redraw the dialog
|
// redraw the dialog
|
||||||
f.draw_background();
|
f.draw_background();
|
||||||
f.draw_border();
|
f.draw_border();
|
||||||
// cache the dialog background (alpha blending + blurred map)
|
// cache the dialog background (alpha blending + blurred map)
|
||||||
sdl_blit(screen, &text_rect, text_surf, NULL);
|
sdl_blit(screen, &text_rect, text_surf, nullptr);
|
||||||
redraw_mapimage = false;
|
redraw_mapimage = false;
|
||||||
} else {
|
} else {
|
||||||
// redraw the saved part of the dialog where text scrolled
|
// redraw the saved part of the dialog where text scrolled
|
||||||
|
@ -385,7 +384,7 @@ void show_about(CVideo &video, const std::string &campaign)
|
||||||
// since the real drawing on screen is clipped,
|
// since the real drawing on screen is clipped,
|
||||||
// we do a dummy one to get the height of the not clipped line.
|
// we do a dummy one to get the height of the not clipped line.
|
||||||
// (each time because special format characters may change it)
|
// (each time because special format characters may change it)
|
||||||
const int line_height = font::draw_text(NULL, text_rect, def_size, def_color,
|
const int line_height = font::draw_text(nullptr, text_rect, def_size, def_color,
|
||||||
text[line], 0,0).h;
|
text[line], 0,0).h;
|
||||||
|
|
||||||
if(is_new_line) {
|
if(is_new_line) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit &u,
|
||||||
const map_location& u_loc, int u_attack_num, bool attacking,
|
const map_location& u_loc, int u_attack_num, bool attacking,
|
||||||
const unit &opp, const map_location& opp_loc,
|
const unit &opp, const map_location& opp_loc,
|
||||||
const attack_type *opp_weapon, const unit_map& units) :
|
const attack_type *opp_weapon, const unit_map& units) :
|
||||||
weapon(NULL),
|
weapon(nullptr),
|
||||||
attack_num(u_attack_num),
|
attack_num(u_attack_num),
|
||||||
is_attacker(attacking),
|
is_attacker(attacking),
|
||||||
is_poisoned(u.get_state(unit::STATE_POISONED)),
|
is_poisoned(u.get_state(unit::STATE_POISONED)),
|
||||||
|
@ -323,8 +323,8 @@ battle_context::battle_context(const unit_map& units,
|
||||||
const map_location& attacker_loc, const map_location& defender_loc,
|
const map_location& attacker_loc, const map_location& defender_loc,
|
||||||
int attacker_weapon, int defender_weapon, double aggression,
|
int attacker_weapon, int defender_weapon, double aggression,
|
||||||
const combatant *prev_def, const unit* attacker_ptr) :
|
const combatant *prev_def, const unit* attacker_ptr) :
|
||||||
attacker_stats_(NULL), defender_stats_(NULL), attacker_combatant_(NULL),
|
attacker_stats_(nullptr), defender_stats_(nullptr), attacker_combatant_(nullptr),
|
||||||
defender_combatant_(NULL)
|
defender_combatant_(nullptr)
|
||||||
{
|
{
|
||||||
const unit &attacker = attacker_ptr ? *attacker_ptr : *units.find(attacker_loc);
|
const unit &attacker = attacker_ptr ? *attacker_ptr : *units.find(attacker_loc);
|
||||||
const unit &defender = *units.find(defender_loc);
|
const unit &defender = *units.find(defender_loc);
|
||||||
|
@ -344,8 +344,8 @@ battle_context::battle_context(const unit_map& units,
|
||||||
|
|
||||||
// If those didn't have to generate statistics, do so now.
|
// If those didn't have to generate statistics, do so now.
|
||||||
if (!attacker_stats_) {
|
if (!attacker_stats_) {
|
||||||
const attack_type *adef = NULL;
|
const attack_type *adef = nullptr;
|
||||||
const attack_type *ddef = NULL;
|
const attack_type *ddef = nullptr;
|
||||||
if (attacker_weapon >= 0) {
|
if (attacker_weapon >= 0) {
|
||||||
VALIDATE(attacker_weapon < static_cast<int>(attacker.attacks().size()),
|
VALIDATE(attacker_weapon < static_cast<int>(attacker.attacks().size()),
|
||||||
_("An invalid attacker weapon got selected."));
|
_("An invalid attacker weapon got selected."));
|
||||||
|
@ -372,14 +372,14 @@ battle_context::battle_context(const battle_context_unit_stats &att,
|
||||||
const battle_context_unit_stats &def) :
|
const battle_context_unit_stats &def) :
|
||||||
attacker_stats_(new battle_context_unit_stats(att)),
|
attacker_stats_(new battle_context_unit_stats(att)),
|
||||||
defender_stats_(new battle_context_unit_stats(def)),
|
defender_stats_(new battle_context_unit_stats(def)),
|
||||||
attacker_combatant_(NULL),
|
attacker_combatant_(nullptr),
|
||||||
defender_combatant_(NULL)
|
defender_combatant_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
battle_context::battle_context(const battle_context &other) :
|
battle_context::battle_context(const battle_context &other) :
|
||||||
attacker_stats_(NULL), defender_stats_(NULL), attacker_combatant_(NULL),
|
attacker_stats_(nullptr), defender_stats_(nullptr), attacker_combatant_(nullptr),
|
||||||
defender_combatant_(NULL)
|
defender_combatant_(nullptr)
|
||||||
{
|
{
|
||||||
*this = other;
|
*this = other;
|
||||||
}
|
}
|
||||||
|
@ -401,8 +401,8 @@ battle_context& battle_context::operator=(const battle_context &other)
|
||||||
delete defender_combatant_;
|
delete defender_combatant_;
|
||||||
attacker_stats_ = new battle_context_unit_stats(*other.attacker_stats_);
|
attacker_stats_ = new battle_context_unit_stats(*other.attacker_stats_);
|
||||||
defender_stats_ = new battle_context_unit_stats(*other.defender_stats_);
|
defender_stats_ = new battle_context_unit_stats(*other.defender_stats_);
|
||||||
attacker_combatant_ = other.attacker_combatant_ ? new combatant(*other.attacker_combatant_, *attacker_stats_) : NULL;
|
attacker_combatant_ = other.attacker_combatant_ ? new combatant(*other.attacker_combatant_, *attacker_stats_) : nullptr;
|
||||||
defender_combatant_ = other.defender_combatant_ ? new combatant(*other.defender_combatant_, *defender_stats_) : NULL;
|
defender_combatant_ = other.defender_combatant_ ? new combatant(*other.defender_combatant_, *defender_stats_) : nullptr;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -491,12 +491,12 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
||||||
if (choices.size() == 1) {
|
if (choices.size() == 1) {
|
||||||
*defender_weapon = choose_defender_weapon(attacker, defender, choices[0], units,
|
*defender_weapon = choose_defender_weapon(attacker, defender, choices[0], units,
|
||||||
attacker_loc, defender_loc, prev_def);
|
attacker_loc, defender_loc, prev_def);
|
||||||
const attack_type *def_weapon = *defender_weapon >= 0 ? &defender.attacks()[*defender_weapon] : NULL;
|
const attack_type *def_weapon = *defender_weapon >= 0 ? &defender.attacks()[*defender_weapon] : nullptr;
|
||||||
attacker_stats_ = new battle_context_unit_stats(attacker, attacker_loc, choices[0],
|
attacker_stats_ = new battle_context_unit_stats(attacker, attacker_loc, choices[0],
|
||||||
true, defender, defender_loc, def_weapon, units);
|
true, defender, defender_loc, def_weapon, units);
|
||||||
if (attacker_stats_->disable) {
|
if (attacker_stats_->disable) {
|
||||||
delete attacker_stats_;
|
delete attacker_stats_;
|
||||||
attacker_stats_ = NULL;
|
attacker_stats_ = nullptr;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const attack_type &att = attacker.attacks()[choices[0]];
|
const attack_type &att = attacker.attacks()[choices[0]];
|
||||||
|
@ -506,8 +506,8 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiple options: simulate them, save best.
|
// Multiple options: simulate them, save best.
|
||||||
battle_context_unit_stats *best_att_stats = NULL, *best_def_stats = NULL;
|
battle_context_unit_stats *best_att_stats = nullptr, *best_def_stats = nullptr;
|
||||||
combatant *best_att_comb = NULL, *best_def_comb = NULL;
|
combatant *best_att_comb = nullptr, *best_def_comb = nullptr;
|
||||||
|
|
||||||
for (i = 0; i < choices.size(); ++i) {
|
for (i = 0; i < choices.size(); ++i) {
|
||||||
const attack_type &att = attacker.attacks()[choices[i]];
|
const attack_type &att = attacker.attacks()[choices[i]];
|
||||||
|
@ -515,7 +515,7 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
||||||
attacker_loc, defender_loc, prev_def);
|
attacker_loc, defender_loc, prev_def);
|
||||||
// If that didn't simulate, do so now.
|
// If that didn't simulate, do so now.
|
||||||
if (!attacker_combatant_) {
|
if (!attacker_combatant_) {
|
||||||
const attack_type *def = NULL;
|
const attack_type *def = nullptr;
|
||||||
if (def_weapon >= 0) {
|
if (def_weapon >= 0) {
|
||||||
def = &defender.attacks()[def_weapon];
|
def = &defender.attacks()[def_weapon];
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
||||||
true, defender, defender_loc, def, units);
|
true, defender, defender_loc, def, units);
|
||||||
if (attacker_stats_->disable) {
|
if (attacker_stats_->disable) {
|
||||||
delete attacker_stats_;
|
delete attacker_stats_;
|
||||||
attacker_stats_ = NULL;
|
attacker_stats_ = nullptr;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
defender_stats_ = new battle_context_unit_stats(defender, defender_loc, def_weapon, false,
|
defender_stats_ = new battle_context_unit_stats(defender, defender_loc, def_weapon, false,
|
||||||
|
@ -548,10 +548,10 @@ int battle_context::choose_attacker_weapon(const unit &attacker,
|
||||||
delete attacker_stats_;
|
delete attacker_stats_;
|
||||||
delete defender_stats_;
|
delete defender_stats_;
|
||||||
}
|
}
|
||||||
attacker_combatant_ = NULL;
|
attacker_combatant_ = nullptr;
|
||||||
defender_combatant_ = NULL;
|
defender_combatant_ = nullptr;
|
||||||
attacker_stats_ = NULL;
|
attacker_stats_ = nullptr;
|
||||||
defender_stats_ = NULL;
|
defender_stats_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
attacker_combatant_ = best_att_comb;
|
attacker_combatant_ = best_att_comb;
|
||||||
|
@ -792,9 +792,9 @@ namespace {
|
||||||
|
|
||||||
attack::attack(const map_location &attacker, const map_location &defender,
|
attack::attack(const map_location &attacker, const map_location &defender,
|
||||||
int attack_with, int defend_with, bool update_display) :
|
int attack_with, int defend_with, bool update_display) :
|
||||||
bc_(NULL),
|
bc_(nullptr),
|
||||||
a_stats_(NULL),
|
a_stats_(nullptr),
|
||||||
d_stats_(NULL),
|
d_stats_(nullptr),
|
||||||
abs_n_attack_(0),
|
abs_n_attack_(0),
|
||||||
abs_n_defend_(0),
|
abs_n_defend_(0),
|
||||||
update_att_fog_(false),
|
update_att_fog_(false),
|
||||||
|
@ -821,10 +821,10 @@ namespace {
|
||||||
config ev_data;
|
config ev_data;
|
||||||
config& a_weapon_cfg = ev_data.add_child("first");
|
config& a_weapon_cfg = ev_data.add_child("first");
|
||||||
config& d_weapon_cfg = ev_data.add_child("second");
|
config& d_weapon_cfg = ev_data.add_child("second");
|
||||||
if(a_stats_->weapon != NULL && a_.valid()) {
|
if(a_stats_->weapon != nullptr && a_.valid()) {
|
||||||
a_stats_->weapon->write(a_weapon_cfg);
|
a_stats_->weapon->write(a_weapon_cfg);
|
||||||
}
|
}
|
||||||
if(d_stats_->weapon != NULL && d_.valid()) {
|
if(d_stats_->weapon != nullptr && d_.valid()) {
|
||||||
d_stats_->weapon->write(d_weapon_cfg);
|
d_stats_->weapon->write(d_weapon_cfg);
|
||||||
}
|
}
|
||||||
if(a_weapon_cfg["name"].empty()) {
|
if(a_weapon_cfg["name"].empty()) {
|
||||||
|
@ -869,11 +869,11 @@ namespace {
|
||||||
// Fix pointer to weapons
|
// Fix pointer to weapons
|
||||||
const_cast<battle_context_unit_stats*>(a_stats_)->weapon =
|
const_cast<battle_context_unit_stats*>(a_stats_)->weapon =
|
||||||
a_.valid() && a_.weapon_ >= 0
|
a_.valid() && a_.weapon_ >= 0
|
||||||
? &a_.get_unit().attacks()[a_.weapon_] : NULL;
|
? &a_.get_unit().attacks()[a_.weapon_] : nullptr;
|
||||||
|
|
||||||
const_cast<battle_context_unit_stats*>(d_stats_)->weapon =
|
const_cast<battle_context_unit_stats*>(d_stats_)->weapon =
|
||||||
d_.valid() && d_.weapon_ >= 0
|
d_.valid() && d_.weapon_ >= 0
|
||||||
? &d_.get_unit().attacks()[d_.weapon_] : NULL;
|
? &d_.get_unit().attacks()[d_.weapon_] : nullptr;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1119,7 @@ namespace {
|
||||||
|
|
||||||
if (!attacker.valid()) {
|
if (!attacker.valid()) {
|
||||||
unit_display::unit_die(defender.loc_, defender.get_unit(),
|
unit_display::unit_die(defender.loc_, defender.get_unit(),
|
||||||
NULL, defender_stats->weapon);
|
nullptr, defender_stats->weapon);
|
||||||
} else {
|
} else {
|
||||||
unit_display::unit_die(defender.loc_, defender.get_unit(),
|
unit_display::unit_die(defender.loc_, defender.get_unit(),
|
||||||
attacker_stats->weapon, defender_stats->weapon,
|
attacker_stats->weapon, defender_stats->weapon,
|
||||||
|
@ -1310,8 +1310,8 @@ namespace {
|
||||||
u.set_experience(u.experience() + d_.xp_);
|
u.set_experience(u.experience() + d_.xp_);
|
||||||
}
|
}
|
||||||
|
|
||||||
unit_display::unit_sheath_weapon(a_.loc_,a_.valid()?&a_.get_unit():NULL,a_stats_->weapon,
|
unit_display::unit_sheath_weapon(a_.loc_,a_.valid()?&a_.get_unit():nullptr,a_stats_->weapon,
|
||||||
d_stats_->weapon,d_.loc_,d_.valid()?&d_.get_unit():NULL);
|
d_stats_->weapon,d_.loc_,d_.valid()?&d_.get_unit():nullptr);
|
||||||
|
|
||||||
if (update_display_){
|
if (update_display_){
|
||||||
resources::screen->invalidate_unit();
|
resources::screen->invalidate_unit();
|
||||||
|
@ -1427,7 +1427,7 @@ namespace
|
||||||
|
|
||||||
//if ai_advancement_ is the default advancement the following code will
|
//if ai_advancement_ is the default advancement the following code will
|
||||||
//have no effect because get_advancements returns an empty list.
|
//have no effect because get_advancements returns an empty list.
|
||||||
if(ai_advancement_ != NULL)
|
if(ai_advancement_ != nullptr)
|
||||||
{
|
{
|
||||||
unit_map::iterator u = resources::units->find(loc_);
|
unit_map::iterator u = resources::units->find(loc_);
|
||||||
const std::vector<std::string>& options = u->advances_to();
|
const std::vector<std::string>& options = u->advances_to();
|
||||||
|
@ -1604,7 +1604,7 @@ void advance_unit(map_location loc, const std::string &advance_to,
|
||||||
std::vector<int> not_seeing = actions::get_sides_not_seeing(*u);
|
std::vector<int> not_seeing = actions::get_sides_not_seeing(*u);
|
||||||
|
|
||||||
// Create the advanced unit.
|
// Create the advanced unit.
|
||||||
bool use_amla = mod_option != NULL;
|
bool use_amla = mod_option != nullptr;
|
||||||
unit_ptr new_unit = use_amla ? get_amla_unit(*u, *mod_option) :
|
unit_ptr new_unit = use_amla ? get_amla_unit(*u, *mod_option) :
|
||||||
get_advanced_unit(*u, advance_to);
|
get_advanced_unit(*u, advance_to);
|
||||||
if ( !use_amla )
|
if ( !use_amla )
|
||||||
|
|
|
@ -48,7 +48,7 @@ inline unsigned swarm_blows(unsigned min_blows, unsigned max_blows, unsigned hp,
|
||||||
/** Structure describing the statistics of a unit involved in the battle. */
|
/** Structure describing the statistics of a unit involved in the battle. */
|
||||||
struct battle_context_unit_stats
|
struct battle_context_unit_stats
|
||||||
{
|
{
|
||||||
const attack_type *weapon; /**< The weapon used by the unit to attack the opponent, or NULL if there is none. */
|
const attack_type *weapon; /**< The weapon used by the unit to attack the opponent, or nullptr if there is none. */
|
||||||
int attack_num; /**< Index into unit->attacks() or -1 for none. */
|
int attack_num; /**< Index into unit->attacks() or -1 for none. */
|
||||||
bool is_attacker; /**< True if the unit is the attacker. */
|
bool is_attacker; /**< True if the unit is the attacker. */
|
||||||
bool is_poisoned; /**< True if the unit is poisoned at the beginning of the battle. */
|
bool is_poisoned; /**< True if the unit is poisoned at the beginning of the battle. */
|
||||||
|
@ -109,7 +109,7 @@ struct battle_context_unit_stats
|
||||||
battle_context_unit_stats(int dmg, int blows, int hitpoints, int maximum_hp,
|
battle_context_unit_stats(int dmg, int blows, int hitpoints, int maximum_hp,
|
||||||
int hit_chance, bool drain, bool slows, bool slowed,
|
int hit_chance, bool drain, bool slows, bool slowed,
|
||||||
bool berserk, bool first, bool do_swarm) :
|
bool berserk, bool first, bool do_swarm) :
|
||||||
weapon(NULL), attack_num(0), is_attacker(true), // These are not used in attack prediction.
|
weapon(nullptr), attack_num(0), is_attacker(true), // These are not used in attack prediction.
|
||||||
is_poisoned(false), is_slowed(slowed),
|
is_poisoned(false), is_slowed(slowed),
|
||||||
slows(slows), drains(drain), petrifies(false), plagues(false),
|
slows(slows), drains(drain), petrifies(false), plagues(false),
|
||||||
poisons(false), backstab_pos(false), swarm(do_swarm), firststrike(first), disable(false),
|
poisons(false), backstab_pos(false), swarm(do_swarm), firststrike(first), disable(false),
|
||||||
|
@ -145,8 +145,8 @@ public:
|
||||||
battle_context(const unit_map &units,
|
battle_context(const unit_map &units,
|
||||||
const map_location& attacker_loc, const map_location& defender_loc,
|
const map_location& attacker_loc, const map_location& defender_loc,
|
||||||
int attacker_weapon = -1, int defender_weapon = -1,
|
int attacker_weapon = -1, int defender_weapon = -1,
|
||||||
double aggression = 0.0, const combatant *prev_def = NULL,
|
double aggression = 0.0, const combatant *prev_def = nullptr,
|
||||||
const unit* attacker_ptr=NULL);
|
const unit* attacker_ptr=nullptr);
|
||||||
|
|
||||||
/** Used by the AI which caches battle_context_unit_stats */
|
/** Used by the AI which caches battle_context_unit_stats */
|
||||||
battle_context(const battle_context_unit_stats &att, const battle_context_unit_stats &def);
|
battle_context(const battle_context_unit_stats &att, const battle_context_unit_stats &def);
|
||||||
|
@ -163,8 +163,8 @@ public:
|
||||||
const battle_context_unit_stats& get_defender_stats() const { return *defender_stats_; }
|
const battle_context_unit_stats& get_defender_stats() const { return *defender_stats_; }
|
||||||
|
|
||||||
/** Get the simulation results. */
|
/** Get the simulation results. */
|
||||||
const combatant &get_attacker_combatant(const combatant *prev_def = NULL);
|
const combatant &get_attacker_combatant(const combatant *prev_def = nullptr);
|
||||||
const combatant &get_defender_combatant(const combatant *prev_def = NULL);
|
const combatant &get_defender_combatant(const combatant *prev_def = nullptr);
|
||||||
|
|
||||||
/** Given this harm_weight, is this attack better than that? */
|
/** Given this harm_weight, is this attack better than that? */
|
||||||
bool better_attack(class battle_context &that, double harm_weight);
|
bool better_attack(class battle_context &that, double harm_weight);
|
||||||
|
@ -213,7 +213,7 @@ void attack_unit_and_advance(const map_location &attacker, const map_location &d
|
||||||
*/
|
*/
|
||||||
struct advance_unit_params
|
struct advance_unit_params
|
||||||
{
|
{
|
||||||
advance_unit_params(const map_location& loc) : loc_(loc), ai_advancements_(NULL), force_dialog_(false), fire_events_(true), animate_(true) {}
|
advance_unit_params(const map_location& loc) : loc_(loc), ai_advancements_(nullptr), force_dialog_(false), fire_events_(true), animate_(true) {}
|
||||||
advance_unit_params& ai_advancements(const ai::unit_advancements_aspect& value) {ai_advancements_ = &value; return *this;}
|
advance_unit_params& ai_advancements(const ai::unit_advancements_aspect& value) {ai_advancements_ = &value; return *this;}
|
||||||
advance_unit_params& force_dialog(bool value) {force_dialog_ = value; return *this;}
|
advance_unit_params& force_dialog(bool value) {force_dialog_ = value; return *this;}
|
||||||
advance_unit_params& fire_events(bool value) {fire_events_ = value; return *this;}
|
advance_unit_params& fire_events(bool value) {fire_events_ = value; return *this;}
|
||||||
|
@ -245,17 +245,17 @@ unit_ptr get_amla_unit(const unit &u, const config &mod_option);
|
||||||
* that we're going to delete, since deletion would invalidate the reference.
|
* that we're going to delete, since deletion would invalidate the reference.
|
||||||
*/
|
*/
|
||||||
void advance_unit(map_location loc, const std::string &advance_to,
|
void advance_unit(map_location loc, const std::string &advance_to,
|
||||||
const bool &fire_event = true, const config * mod_option = NULL);
|
const bool &fire_event = true, const config * mod_option = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function which tests if the unit at loc is currently affected by leadership.
|
* function which tests if the unit at loc is currently affected by leadership.
|
||||||
* (i.e. has a higher-level 'leadership' unit next to it).
|
* (i.e. has a higher-level 'leadership' unit next to it).
|
||||||
* If it does, then the location of the leader unit will be returned,
|
* If it does, then the location of the leader unit will be returned,
|
||||||
* Otherwise map_location::null_location() will be returned.
|
* Otherwise map_location::null_location() will be returned.
|
||||||
* If 'bonus' is not NULL, the % bonus will be stored in it.
|
* If 'bonus' is not nullptr, the % bonus will be stored in it.
|
||||||
*/
|
*/
|
||||||
map_location under_leadership(const unit_map& units, const map_location& loc,
|
map_location under_leadership(const unit_map& units, const map_location& loc,
|
||||||
int* bonus=NULL);
|
int* bonus=nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount that a unit's damage should be multiplied by
|
* Returns the amount that a unit's damage should be multiplied by
|
||||||
|
|
|
@ -133,7 +133,7 @@ namespace { // Helpers for get_recalls()
|
||||||
*/
|
*/
|
||||||
void add_leader_filtered_recalls(const unit_const_ptr leader,
|
void add_leader_filtered_recalls(const unit_const_ptr leader,
|
||||||
std::vector< unit_const_ptr > & result,
|
std::vector< unit_const_ptr > & result,
|
||||||
std::set<size_t> * already_added = NULL)
|
std::set<size_t> * already_added = nullptr)
|
||||||
{
|
{
|
||||||
const team& leader_team = (*resources::teams)[leader->side()-1];
|
const team& leader_team = (*resources::teams)[leader->side()-1];
|
||||||
const std::string& save_id = leader_team.save_id();
|
const std::string& save_id = leader_team.save_id();
|
||||||
|
@ -153,7 +153,7 @@ namespace { // Helpers for get_recalls()
|
||||||
if ( ufilt(recall_unit, map_location::null_location()) )
|
if ( ufilt(recall_unit, map_location::null_location()) )
|
||||||
{
|
{
|
||||||
result.push_back(recall_unit_ptr);
|
result.push_back(recall_unit_ptr);
|
||||||
if ( already_added != NULL )
|
if ( already_added != nullptr )
|
||||||
already_added->insert(underlying_id);
|
already_added->insert(underlying_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat
|
||||||
}
|
}
|
||||||
// Make sure the unit appears (if either !show or the animation is suppressed).
|
// Make sure the unit appears (if either !show or the animation is suppressed).
|
||||||
new_unit_itor->set_hidden(false);
|
new_unit_itor->set_hidden(false);
|
||||||
if ( resources::screen != NULL ) {
|
if ( resources::screen != nullptr ) {
|
||||||
resources::screen->invalidate(current_loc);
|
resources::screen->invalidate(current_loc);
|
||||||
resources::screen->redraw_minimap();
|
resources::screen->redraw_minimap();
|
||||||
}
|
}
|
||||||
|
@ -720,7 +720,7 @@ void recruit_unit(const unit_type & u_type, int side_num, const map_location & l
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the screen.
|
// Update the screen.
|
||||||
if ( resources::screen != NULL )
|
if ( resources::screen != nullptr )
|
||||||
resources::screen->invalidate_game_status();
|
resources::screen->invalidate_game_status();
|
||||||
// Other updates were done by place_recruit().
|
// Other updates were done by place_recruit().
|
||||||
}
|
}
|
||||||
|
@ -767,7 +767,7 @@ bool recall_unit(const std::string & id, team & current_team,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the screen.
|
// Update the screen.
|
||||||
if ( resources::screen != NULL )
|
if ( resources::screen != nullptr )
|
||||||
resources::screen->invalidate_game_status();
|
resources::screen->invalidate_game_status();
|
||||||
// Other updates were done by place_recruit().
|
// Other updates were done by place_recruit().
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ void move_unit_spectator::set_unit(const unit_map::const_iterator &u)
|
||||||
bool get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event)
|
bool get_village(const map_location& loc, int side, bool *action_timebonus, bool fire_event)
|
||||||
{
|
{
|
||||||
std::vector<team> &teams = *resources::teams;
|
std::vector<team> &teams = *resources::teams;
|
||||||
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : NULL;
|
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||||
if (t && t->owns_village(loc)) {
|
if (t && t->owns_village(loc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -174,10 +174,10 @@ bool get_village(const map_location& loc, int side, bool *action_timebonus, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not_defeated) {
|
if(not_defeated) {
|
||||||
if (resources::screen != NULL) {
|
if (resources::screen != nullptr) {
|
||||||
resources::screen->invalidate(loc);
|
resources::screen->invalidate(loc);
|
||||||
}
|
}
|
||||||
return t->get_village(loc, old_owner_side, fire_event ? resources::gamedata : NULL);
|
return t->get_village(loc, old_owner_side, fire_event ? resources::gamedata : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -236,7 +236,7 @@ namespace { // Private helpers for move_unit()
|
||||||
const route_iterator & current,
|
const route_iterator & current,
|
||||||
const route_iterator & other);
|
const route_iterator & other);
|
||||||
/// AI moves are supposed to not change the "goto" order.
|
/// AI moves are supposed to not change the "goto" order.
|
||||||
bool is_ai_move() const { return spectator_ != NULL; }
|
bool is_ai_move() const { return spectator_ != nullptr; }
|
||||||
/// Checks how far it appears we can move this turn.
|
/// Checks how far it appears we can move this turn.
|
||||||
route_iterator plot_turn(const route_iterator & start,
|
route_iterator plot_turn(const route_iterator & start,
|
||||||
const route_iterator & stop);
|
const route_iterator & stop);
|
||||||
|
@ -534,7 +534,7 @@ namespace { // Private helpers for move_unit()
|
||||||
bool new_animation)
|
bool new_animation)
|
||||||
{
|
{
|
||||||
// Clear the fog.
|
// Clear the fog.
|
||||||
if ( clearer_.clear_unit(hex, *move_it_, *current_team_, NULL,
|
if ( clearer_.clear_unit(hex, *move_it_, *current_team_, nullptr,
|
||||||
&enemy_count_, &friend_count_, spectator_,
|
&enemy_count_, &friend_count_, spectator_,
|
||||||
!new_animation) )
|
!new_animation) )
|
||||||
{
|
{
|
||||||
|
@ -651,7 +651,7 @@ namespace { // Private helpers for move_unit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the shroud clearer.
|
// Update the shroud clearer.
|
||||||
clearer_.cache_units(current_uses_fog_ ? current_team_ : NULL);
|
clearer_.cache_units(current_uses_fog_ ? current_team_ : nullptr);
|
||||||
|
|
||||||
|
|
||||||
// Abort for null routes.
|
// Abort for null routes.
|
||||||
|
@ -1274,14 +1274,14 @@ size_t move_unit_from_replay(const std::vector<map_location> &steps,
|
||||||
bool continued_move,bool skip_ally_sighted, bool show_move)
|
bool continued_move,bool skip_ally_sighted, bool show_move)
|
||||||
{
|
{
|
||||||
// Evaluate this move.
|
// Evaluate this move.
|
||||||
unit_mover mover(steps, NULL, continued_move,skip_ally_sighted);
|
unit_mover mover(steps, nullptr, continued_move,skip_ally_sighted);
|
||||||
if ( !mover.check_expected_movement() )
|
if ( !mover.check_expected_movement() )
|
||||||
{
|
{
|
||||||
replay::process_error("found corrupt movement in replay.");
|
replay::process_error("found corrupt movement in replay.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return move_unit_internal(undo_stack, show_move, NULL, mover);
|
return move_unit_internal(undo_stack, show_move, nullptr, mover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ private:
|
||||||
* Returns true if getting the village triggered a mutating event.
|
* Returns true if getting the village triggered a mutating event.
|
||||||
* side can be 0 to make teh village uncaptured.
|
* side can be 0 to make teh village uncaptured.
|
||||||
*/
|
*/
|
||||||
bool get_village(const map_location& loc, int side, bool *time_bonus = NULL, bool fire_event = true);
|
bool get_village(const map_location& loc, int side, bool *time_bonus = nullptr, bool fire_event = true);
|
||||||
|
|
||||||
/// Moves a unit across the board.
|
/// Moves a unit across the board.
|
||||||
/// And enters the synced context.
|
/// And enters the synced context.
|
||||||
|
@ -105,8 +105,8 @@ size_t move_unit_and_record(const std::vector<map_location> &steps,
|
||||||
undo_list* undo_stack,
|
undo_list* undo_stack,
|
||||||
bool continued_move = false,
|
bool continued_move = false,
|
||||||
bool show_move = true,
|
bool show_move = true,
|
||||||
bool* interrupted = NULL,
|
bool* interrupted = nullptr,
|
||||||
move_unit_spectator* move_spectator = NULL);
|
move_unit_spectator* move_spectator = nullptr);
|
||||||
|
|
||||||
/// Moves a unit across the board.
|
/// Moves a unit across the board.
|
||||||
/// to be called from replay when we are already in the synced context.
|
/// to be called from replay when we are already in the synced context.
|
||||||
|
|
|
@ -15,7 +15,7 @@ void shroud_clearing_action::return_village()
|
||||||
team ¤t_team = resources::controller->current_team();
|
team ¤t_team = resources::controller->current_team();
|
||||||
const map_location back = route.back();
|
const map_location back = route.back();
|
||||||
if(resources::gameboard->map().is_village(back)) {
|
if(resources::gameboard->map().is_village(back)) {
|
||||||
get_village(back, original_village_owner, NULL, false);
|
get_village(back, original_village_owner, nullptr, false);
|
||||||
//MP_COUNTDOWN take away capture bonus
|
//MP_COUNTDOWN take away capture bonus
|
||||||
if(take_village_timebonus) {
|
if(take_village_timebonus) {
|
||||||
current_team.set_action_bonus_count(current_team.action_bonus_count() - 1);
|
current_team.set_action_bonus_count(current_team.action_bonus_count() - 1);
|
||||||
|
@ -27,7 +27,7 @@ void shroud_clearing_action::take_village()
|
||||||
team ¤t_team = resources::controller->current_team();
|
team ¤t_team = resources::controller->current_team();
|
||||||
const map_location back = route.back();
|
const map_location back = route.back();
|
||||||
if(resources::gameboard->map().is_village(back)) {
|
if(resources::gameboard->map().is_village(back)) {
|
||||||
get_village(back, current_team.side(), NULL, false);
|
get_village(back, current_team.side(), nullptr, false);
|
||||||
//MP_COUNTDOWN restore capture bonus
|
//MP_COUNTDOWN restore capture bonus
|
||||||
if(take_village_timebonus) {
|
if(take_village_timebonus) {
|
||||||
current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
|
current_team.set_action_bonus_count(1 + current_team.action_bonus_count());
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
#include <boost/ptr_container/ptr_sequence_adapter.hpp>
|
||||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||||
#include <cassert> // for assert
|
#include <cassert> // for assert
|
||||||
#include <cstddef> // for NULL
|
|
||||||
#include <ostream> // for operator<<, basic_ostream, etc
|
#include <ostream> // for operator<<, basic_ostream, etc
|
||||||
#include <set> // for set
|
#include <set> // for set
|
||||||
|
|
||||||
|
@ -76,12 +75,12 @@ namespace actions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an undo_action based on a config.
|
* Creates an undo_action based on a config.
|
||||||
* @return a pointer that must be deleted, or NULL if the @a cfg could not be parsed.
|
* @return a pointer that must be deleted, or nullptr if the @a cfg could not be parsed.
|
||||||
*/
|
*/
|
||||||
undo_action_base * undo_list::create_action(const config & cfg)
|
undo_action_base * undo_list::create_action(const config & cfg)
|
||||||
{
|
{
|
||||||
const std::string str = cfg["type"];
|
const std::string str = cfg["type"];
|
||||||
undo_action_base * res = NULL;
|
undo_action_base * res = nullptr;
|
||||||
// The general division of labor in this function is that the various
|
// The general division of labor in this function is that the various
|
||||||
// constructors will parse the "unit" child config, while this function
|
// constructors will parse the "unit" child config, while this function
|
||||||
// parses everything else.
|
// parses everything else.
|
||||||
|
@ -101,13 +100,13 @@ undo_action_base * undo_list::create_action(const config & cfg)
|
||||||
// Bad data.
|
// Bad data.
|
||||||
ERR_NG << "Invalid recruit found in [undo] or [redo]; unit type '"
|
ERR_NG << "Invalid recruit found in [undo] or [redo]; unit type '"
|
||||||
<< child["type"] << "' was not found.\n";
|
<< child["type"] << "' was not found.\n";
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
res = new undo::recruit_action(cfg, *u_type, map_location(cfg.child_or_empty("leader"), NULL));
|
res = new undo::recruit_action(cfg, *u_type, map_location(cfg.child_or_empty("leader"), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( str == "recall" )
|
else if ( str == "recall" )
|
||||||
res = new undo::recall_action(cfg, map_location(cfg.child_or_empty("leader"), NULL));
|
res = new undo::recall_action(cfg, map_location(cfg.child_or_empty("leader"), nullptr));
|
||||||
|
|
||||||
else if ( str == "dismiss" )
|
else if ( str == "dismiss" )
|
||||||
res = new undo::dismiss_action(cfg, cfg.child("unit"));
|
res = new undo::dismiss_action(cfg, cfg.child("unit"));
|
||||||
|
@ -121,7 +120,7 @@ undo_action_base * undo_list::create_action(const config & cfg)
|
||||||
{
|
{
|
||||||
// Unrecognized type.
|
// Unrecognized type.
|
||||||
ERR_NG << "Unrecognized undo action type: " << str << "." << std::endl;
|
ERR_NG << "Unrecognized undo action type: " << str << "." << std::endl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace actions {
|
||||||
struct undo_action_base : boost::noncopyable
|
struct undo_action_base : boost::noncopyable
|
||||||
{
|
{
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
/// This is the only way to get NULL view_info.
|
/// This is the only way to get nullptr view_info.
|
||||||
undo_action_base()
|
undo_action_base()
|
||||||
{ }
|
{ }
|
||||||
// Virtual destructor to support derived classes.
|
// Virtual destructor to support derived classes.
|
||||||
|
|
|
@ -140,7 +140,7 @@ map_location unit_creator::find_location(const config &cfg, const unit* pass_che
|
||||||
const bool pass((place == "leader_passable") || (place == "map_passable"));
|
const bool pass((place == "leader_passable") || (place == "map_passable"));
|
||||||
if ( place != "map_overwrite" ) {
|
if ( place != "map_overwrite" ) {
|
||||||
loc = find_vacant_tile(loc, pathfind::VACANT_ANY,
|
loc = find_vacant_tile(loc, pathfind::VACANT_ANY,
|
||||||
pass ? pass_check : NULL, NULL, board_);
|
pass ? pass_check : nullptr, nullptr, board_);
|
||||||
}
|
}
|
||||||
if(loc.valid() && board_->map().on_board(loc)) {
|
if(loc.valid() && board_->map().on_board(loc)) {
|
||||||
return loc;
|
return loc;
|
||||||
|
@ -205,7 +205,7 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
|
||||||
preferences::encountered_units().insert(new_unit.type_id());
|
preferences::encountered_units().insert(new_unit.type_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool show = show_ && (resources::screen !=NULL) && !resources::screen->fogged(loc);
|
bool show = show_ && (resources::screen !=nullptr) && !resources::screen->fogged(loc);
|
||||||
bool animate = show && anim;
|
bool animate = show && anim;
|
||||||
|
|
||||||
if (get_village_) {
|
if (get_village_) {
|
||||||
|
@ -216,11 +216,11 @@ void unit_creator::post_create(const map_location &loc, const unit &new_unit, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only fire the events if it's safe; it's not if we're in the middle of play_controller::reset_gamestate()
|
// Only fire the events if it's safe; it's not if we're in the middle of play_controller::reset_gamestate()
|
||||||
if (resources::lua_kernel != NULL) {
|
if (resources::lua_kernel != nullptr) {
|
||||||
resources::game_events->pump().fire("unit placed", loc);
|
resources::game_events->pump().fire("unit placed", loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resources::screen!=NULL) {
|
if (resources::screen!=nullptr) {
|
||||||
|
|
||||||
if (invalidate_ ) {
|
if (invalidate_ ) {
|
||||||
resources::screen->invalidate(loc);
|
resources::screen->invalidate(loc);
|
||||||
|
|
|
@ -31,7 +31,7 @@ class unit;
|
||||||
class unit_creator
|
class unit_creator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unit_creator(team &tm, const map_location &start_pos, game_board* board = NULL);
|
unit_creator(team &tm, const map_location &start_pos, game_board* board = nullptr);
|
||||||
unit_creator& allow_show(bool b);
|
unit_creator& allow_show(bool b);
|
||||||
unit_creator& allow_get_village(bool b);
|
unit_creator& allow_get_village(bool b);
|
||||||
unit_creator& allow_rename_side(bool b);
|
unit_creator& allow_rename_side(bool b);
|
||||||
|
@ -44,13 +44,13 @@ public:
|
||||||
* @retval map_location::null_location() if unit is to be put into recall list
|
* @retval map_location::null_location() if unit is to be put into recall list
|
||||||
* @retval valid on-board map location otherwise
|
* @retval valid on-board map location otherwise
|
||||||
*/
|
*/
|
||||||
map_location find_location(const config &cfg, const unit* pass_check=NULL);
|
map_location find_location(const config &cfg, const unit* pass_check=nullptr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a unit on map without firing any events (so, usable during team construction in gamestatus)
|
* adds a unit on map without firing any events (so, usable during team construction in gamestatus)
|
||||||
*/
|
*/
|
||||||
void add_unit(const config &cfg, const vconfig* vcfg = NULL);
|
void add_unit(const config &cfg, const vconfig* vcfg = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void post_create(const map_location &loc, const unit &new_unit, bool anim);
|
void post_create(const map_location &loc, const unit &new_unit, bool anim);
|
||||||
|
|
|
@ -75,15 +75,15 @@ static void create_jamming_map(std::map<map_location, int> & jamming,
|
||||||
* Determines if @a loc is within @a viewer's visual range.
|
* Determines if @a loc is within @a viewer's visual range.
|
||||||
* This is a moderately expensive function (vision is recalculated
|
* This is a moderately expensive function (vision is recalculated
|
||||||
* with each call), so avoid using it heavily.
|
* with each call), so avoid using it heavily.
|
||||||
* If @a jamming is left as NULL, the jamming map is also calculated
|
* If @a jamming is left as nullptr, the jamming map is also calculated
|
||||||
* with each invocation.
|
* with each invocation.
|
||||||
*/
|
*/
|
||||||
static bool can_see(const unit & viewer, const map_location & loc,
|
static bool can_see(const unit & viewer, const map_location & loc,
|
||||||
const std::map<map_location, int> * jamming = NULL)
|
const std::map<map_location, int> * jamming = nullptr)
|
||||||
{
|
{
|
||||||
// Make sure we have a "jamming" map.
|
// Make sure we have a "jamming" map.
|
||||||
std::map<map_location, int> local_jamming;
|
std::map<map_location, int> local_jamming;
|
||||||
if ( jamming == NULL ) {
|
if ( jamming == nullptr ) {
|
||||||
create_jamming_map(local_jamming, (*resources::teams)[viewer.side()-1]);
|
create_jamming_map(local_jamming, (*resources::teams)[viewer.side()-1]);
|
||||||
jamming = &local_jamming;
|
jamming = &local_jamming;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ inline void shroud_clearer::record_sighting(
|
||||||
/**
|
/**
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
shroud_clearer::shroud_clearer() : jamming_(), sightings_(), view_team_(NULL)
|
shroud_clearer::shroud_clearer() : jamming_(), sightings_(), view_team_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ shroud_clearer::~shroud_clearer()
|
||||||
* Causes this object's "jamming" map to be recalculated.
|
* Causes this object's "jamming" map to be recalculated.
|
||||||
* This gets called as needed, and can also be manually invoked
|
* This gets called as needed, and can also be manually invoked
|
||||||
* via cache_units().
|
* via cache_units().
|
||||||
* @param[in] new_team The team whose vision will be used. If NULL, the
|
* @param[in] new_team The team whose vision will be used. If nullptr, the
|
||||||
* jamming map will be cleared.
|
* jamming map will be cleared.
|
||||||
*/
|
*/
|
||||||
void shroud_clearer::calculate_jamming(const team * new_team)
|
void shroud_clearer::calculate_jamming(const team * new_team)
|
||||||
|
@ -198,7 +198,7 @@ void shroud_clearer::calculate_jamming(const team * new_team)
|
||||||
jamming_.clear();
|
jamming_.clear();
|
||||||
view_team_ = new_team;
|
view_team_ = new_team;
|
||||||
|
|
||||||
if ( view_team_ == NULL )
|
if ( view_team_ == nullptr )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Build the map.
|
// Build the map.
|
||||||
|
@ -345,9 +345,9 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
|
||||||
bool cleared_something = false;
|
bool cleared_something = false;
|
||||||
// Dummy variables to make some logic simpler.
|
// Dummy variables to make some logic simpler.
|
||||||
size_t enemies=0, friends=0;
|
size_t enemies=0, friends=0;
|
||||||
if ( enemy_count == NULL )
|
if ( enemy_count == nullptr )
|
||||||
enemy_count = &enemies;
|
enemy_count = &enemies;
|
||||||
if ( friend_count == NULL )
|
if ( friend_count == nullptr )
|
||||||
friend_count = &friends;
|
friend_count = &friends;
|
||||||
|
|
||||||
// Make sure the jamming map is up-to-date.
|
// Make sure the jamming map is up-to-date.
|
||||||
|
@ -441,7 +441,7 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, team &view_team,
|
||||||
|
|
||||||
return clear_unit(view_loc, view_team, viewer.underlying_id,
|
return clear_unit(view_loc, view_team, viewer.underlying_id,
|
||||||
viewer.sight_range, viewer.slowed, viewer.costs,
|
viewer.sight_range, viewer.slowed, viewer.costs,
|
||||||
real_loc, NULL, NULL, NULL, NULL, instant);
|
real_loc, nullptr, nullptr, nullptr, nullptr, instant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ std::vector<int> get_sides_not_seeing(const unit & target)
|
||||||
/**
|
/**
|
||||||
* Fires sighted events for the sides that can see @a target.
|
* Fires sighted events for the sides that can see @a target.
|
||||||
* If @a cache is supplied, only those sides might get events.
|
* If @a cache is supplied, only those sides might get events.
|
||||||
* If @a cache is NULL, all sides might get events.
|
* If @a cache is nullptr, all sides might get events.
|
||||||
* This function is for the sighting *of* units that clear the shroud; it is
|
* This function is for the sighting *of* units that clear the shroud; it is
|
||||||
* the complement of shroud_clearer::fire_events(), which handles sighting *by*
|
* the complement of shroud_clearer::fire_events(), which handles sighting *by*
|
||||||
* units that clear the shroud.
|
* units that clear the shroud.
|
||||||
|
@ -638,8 +638,8 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
|
||||||
const map_location & target_loc = target.get_location();
|
const map_location & target_loc = target.get_location();
|
||||||
|
|
||||||
// Determine the teams that (probably) should get events.
|
// Determine the teams that (probably) should get events.
|
||||||
std::vector<bool> needs_event(teams_size, cache == NULL);
|
std::vector<bool> needs_event(teams_size, cache == nullptr);
|
||||||
if ( cache != NULL ) {
|
if ( cache != nullptr ) {
|
||||||
// Flag just the sides in the cache as needing events.
|
// Flag just the sides in the cache as needing events.
|
||||||
BOOST_FOREACH (int side, *cache)
|
BOOST_FOREACH (int side, *cache)
|
||||||
needs_event[side-1] = true;
|
needs_event[side-1] = true;
|
||||||
|
@ -657,7 +657,7 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
|
||||||
create_jamming_map(jamming_cache[i], teams[i]);
|
create_jamming_map(jamming_cache[i], teams[i]);
|
||||||
|
|
||||||
// Look for units that can be used as the second unit in sighted events.
|
// Look for units that can be used as the second unit in sighted events.
|
||||||
std::vector<const unit *> second_units(teams_size, NULL);
|
std::vector<const unit *> second_units(teams_size, nullptr);
|
||||||
std::vector<size_t> distances(teams_size, UINT_MAX);
|
std::vector<size_t> distances(teams_size, UINT_MAX);
|
||||||
BOOST_FOREACH (const unit & viewer, *resources::units) {
|
BOOST_FOREACH (const unit & viewer, *resources::units) {
|
||||||
const size_t index = viewer.side() - 1;
|
const size_t index = viewer.side() - 1;
|
||||||
|
@ -683,7 +683,7 @@ bool actor_sighted(const unit & target, const std::vector<int> * cache)
|
||||||
// Raise events for the appropriate teams.
|
// Raise events for the appropriate teams.
|
||||||
const game_events::entity_location target_entity(target);
|
const game_events::entity_location target_entity(target);
|
||||||
for ( size_t i = 0; i != teams_size; ++i )
|
for ( size_t i = 0; i != teams_size; ++i )
|
||||||
if ( second_units[i] != NULL ) {
|
if ( second_units[i] != nullptr ) {
|
||||||
resources::game_events->pump().raise(sighted_str, target_entity, game_events::entity_location(*second_units[i]));
|
resources::game_events->pump().raise(sighted_str, target_entity, game_events::entity_location(*second_units[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ public:
|
||||||
/// It can also be called if it is desirable to calculate the cache
|
/// It can also be called if it is desirable to calculate the cache
|
||||||
/// in advance of fog clearing.
|
/// in advance of fog clearing.
|
||||||
/// @param[in] new_team The team whose vision will be used. If left as
|
/// @param[in] new_team The team whose vision will be used. If left as
|
||||||
/// NULL, the cache will be just be cleared (to be
|
/// nullptr, the cache will be just be cleared (to be
|
||||||
/// recalculated later as needed).
|
/// recalculated later as needed).
|
||||||
void cache_units(const team * new_team=NULL) { calculate_jamming(new_team); }
|
void cache_units(const team * new_team=nullptr) { calculate_jamming(new_team); }
|
||||||
// cache_units() is currently a near-synonym for calculate_jamming(). The
|
// cache_units() is currently a near-synonym for calculate_jamming(). The
|
||||||
// reason for the two names is so the private function says what it does,
|
// reason for the two names is so the private function says what it does,
|
||||||
// while the public one says why it might be invoked.
|
// while the public one says why it might be invoked.
|
||||||
|
@ -77,22 +77,22 @@ public:
|
||||||
size_t viewer_id, int sight_range, bool slowed,
|
size_t viewer_id, int sight_range, bool slowed,
|
||||||
const movetype::terrain_costs & costs,
|
const movetype::terrain_costs & costs,
|
||||||
const map_location & real_loc,
|
const map_location & real_loc,
|
||||||
const std::set<map_location>* known_units = NULL,
|
const std::set<map_location>* known_units = nullptr,
|
||||||
size_t * enemy_count = NULL, size_t * friend_count = NULL,
|
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
|
||||||
move_unit_spectator * spectator = NULL, bool instant = true);
|
move_unit_spectator * spectator = nullptr, bool instant = true);
|
||||||
/// Clears shroud (and fog) around the provided location for @a view_team
|
/// Clears shroud (and fog) around the provided location for @a view_team
|
||||||
/// as if @a viewer was standing there.
|
/// as if @a viewer was standing there.
|
||||||
bool clear_unit(const map_location &view_loc,
|
bool clear_unit(const map_location &view_loc,
|
||||||
const unit &viewer, team &view_team,
|
const unit &viewer, team &view_team,
|
||||||
const std::set<map_location>* known_units = NULL,
|
const std::set<map_location>* known_units = nullptr,
|
||||||
size_t * enemy_count = NULL, size_t * friend_count = NULL,
|
size_t * enemy_count = nullptr, size_t * friend_count = nullptr,
|
||||||
move_unit_spectator * spectator = NULL, bool instant = true);
|
move_unit_spectator * spectator = nullptr, bool instant = true);
|
||||||
/// Clears shroud (and fog) around the provided location for @a view_team
|
/// Clears shroud (and fog) around the provided location for @a view_team
|
||||||
/// as if @a viewer was standing there. Setting @a instant to false
|
/// as if @a viewer was standing there. Setting @a instant to false
|
||||||
/// allows some drawing delays that are used to make movement look better.
|
/// allows some drawing delays that are used to make movement look better.
|
||||||
bool clear_unit(const map_location &view_loc, const unit &viewer,
|
bool clear_unit(const map_location &view_loc, const unit &viewer,
|
||||||
team &view_team, bool instant)
|
team &view_team, bool instant)
|
||||||
{ return clear_unit(view_loc, viewer, view_team, NULL, NULL, NULL, NULL, instant); }
|
{ return clear_unit(view_loc, viewer, view_team, nullptr, nullptr, nullptr, nullptr, instant); }
|
||||||
/// Clears shroud (and fog) around the provided location for @a view_team
|
/// Clears shroud (and fog) around the provided location for @a view_team
|
||||||
/// as if @a viewer was standing there.
|
/// as if @a viewer was standing there.
|
||||||
bool clear_unit(const map_location &view_loc, team &view_team,
|
bool clear_unit(const map_location &view_loc, team &view_team,
|
||||||
|
@ -126,7 +126,7 @@ private:
|
||||||
bool clear_loc(team &tm, const map_location &loc, const map_location &view_loc,
|
bool clear_loc(team &tm, const map_location &loc, const map_location &view_loc,
|
||||||
const map_location &event_non_loc, size_t viewer_id,
|
const map_location &event_non_loc, size_t viewer_id,
|
||||||
bool check_units, size_t &enemy_count, size_t &friend_count,
|
bool check_units, size_t &enemy_count, size_t &friend_count,
|
||||||
move_unit_spectator * spectator = NULL);
|
move_unit_spectator * spectator = nullptr);
|
||||||
|
|
||||||
/// Convenience wrapper for adding sighting data to the sightings_ vector.
|
/// Convenience wrapper for adding sighting data to the sightings_ vector.
|
||||||
inline void record_sighting(const unit & seen, const map_location & seen_loc,
|
inline void record_sighting(const unit & seen, const map_location & seen_loc,
|
||||||
|
@ -143,7 +143,7 @@ private: // data
|
||||||
/// Returns the sides that cannot currently see @a target.
|
/// Returns the sides that cannot currently see @a target.
|
||||||
std::vector<int> get_sides_not_seeing(const unit & target);
|
std::vector<int> get_sides_not_seeing(const unit & target);
|
||||||
/// Fires sighted events for the sides that can see @a target.
|
/// Fires sighted events for the sides that can see @a target.
|
||||||
bool actor_sighted(const unit & target, const std::vector<int> * cache = NULL);
|
bool actor_sighted(const unit & target, const std::vector<int> * cache = nullptr);
|
||||||
|
|
||||||
|
|
||||||
/// Function that recalculates the fog of war.
|
/// Function that recalculates the fog of war.
|
||||||
|
|
|
@ -37,8 +37,8 @@ addons_client::addons_client(CVideo& v, const std::string& address)
|
||||||
, addr_(address)
|
, addr_(address)
|
||||||
, host_()
|
, host_()
|
||||||
, port_()
|
, port_()
|
||||||
, conn_(NULL)
|
, conn_(nullptr)
|
||||||
, stat_(NULL)
|
, stat_(nullptr)
|
||||||
, last_error_()
|
, last_error_()
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& address_components =
|
const std::vector<std::string>& address_components =
|
||||||
|
@ -272,8 +272,8 @@ bool addons_client::update_last_error(config& response_cfg)
|
||||||
|
|
||||||
void addons_client::check_connected() const
|
void addons_client::check_connected() const
|
||||||
{
|
{
|
||||||
assert(conn_ != NULL);
|
assert(conn_ != nullptr);
|
||||||
if(conn_ == NULL) {
|
if(conn_ == nullptr) {
|
||||||
ERR_ADDONS << "not connected to server" << std::endl;
|
ERR_ADDONS << "not connected to server" << std::endl;
|
||||||
throw not_connected_to_server();
|
throw not_connected_to_server();
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,7 @@ addon_op_result do_resolve_addon_dependencies(CVideo& v, addons_client& client,
|
||||||
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
|
addon_style.scale_images(font::relative_size(72), font::relative_size(72));
|
||||||
gui::menu* addon_menu = new gui::menu(
|
gui::menu* addon_menu = new gui::menu(
|
||||||
v, options, false, -1,
|
v, options, false, -1,
|
||||||
gui::dialog::max_menu_width, NULL, &addon_style, false);
|
gui::dialog::max_menu_width, nullptr, &addon_style, false);
|
||||||
dlg.set_menu(addon_menu);
|
dlg.set_menu(addon_menu);
|
||||||
|
|
||||||
cursor_setter.reset();
|
cursor_setter.reset();
|
||||||
|
@ -431,7 +431,7 @@ public:
|
||||||
|
|
||||||
virtual gui::dialog_button_action::RESULT button_pressed(int filter_choice)
|
virtual gui::dialog_button_action::RESULT button_pressed(int filter_choice)
|
||||||
{
|
{
|
||||||
assert(filter_ != NULL);
|
assert(filter_ != nullptr);
|
||||||
|
|
||||||
const int menu_selection = filter_->get_index(filter_choice);
|
const int menu_selection = filter_->get_index(filter_choice);
|
||||||
if(menu_selection < 0) { return gui::CONTINUE_DIALOG; }
|
if(menu_selection < 0) { return gui::CONTINUE_DIALOG; }
|
||||||
|
@ -526,7 +526,7 @@ struct addon_pointer_list_sorter
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline bool operator()(const addons_list::value_type* a, const addons_list::value_type* b) {
|
inline bool operator()(const addons_list::value_type* a, const addons_list::value_type* b) {
|
||||||
assert(a != NULL && b != NULL);
|
assert(a != nullptr && b != nullptr);
|
||||||
|
|
||||||
if(dir_ == DIRECTION_DESCENDING) {
|
if(dir_ == DIRECTION_DESCENDING) {
|
||||||
const addons_list::value_type* c = a;
|
const addons_list::value_type* c = a;
|
||||||
|
|
|
@ -340,16 +340,16 @@ const unit *move_result::get_unit()
|
||||||
unit_map::const_iterator un = resources::units->find(from_);
|
unit_map::const_iterator un = resources::units->find(from_);
|
||||||
if (un==resources::units->end()){
|
if (un==resources::units->end()){
|
||||||
set_error(E_NO_UNIT);
|
set_error(E_NO_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const unit *u = &*un;
|
const unit *u = &*un;
|
||||||
if (u->side() != get_side()) {
|
if (u->side() != get_side()) {
|
||||||
set_error(E_NOT_OWN_UNIT);
|
set_error(E_NOT_OWN_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (u->incapacitated()) {
|
if (u->incapacitated()) {
|
||||||
set_error(E_INCAPACITATED_UNIT);
|
set_error(E_INCAPACITATED_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
@ -469,10 +469,10 @@ void move_result::do_execute()
|
||||||
if (from_ != to_) {
|
if (from_ != to_) {
|
||||||
size_t num_steps = ::actions::move_unit_and_record(
|
size_t num_steps = ::actions::move_unit_and_record(
|
||||||
/*std::vector<map_location> steps*/ route_->steps,
|
/*std::vector<map_location> steps*/ route_->steps,
|
||||||
/*::actions::undo_list* undo_stack*/ NULL,
|
/*::actions::undo_list* undo_stack*/ nullptr,
|
||||||
/*bool continue_move*/ true, ///@todo 1.9 set to false after implemeting interrupt awareness
|
/*bool continue_move*/ true, ///@todo 1.9 set to false after implemeting interrupt awareness
|
||||||
/*bool show_move*/ preferences::show_ai_moves(),
|
/*bool show_move*/ preferences::show_ai_moves(),
|
||||||
/*bool* interrupted*/ NULL,
|
/*bool* interrupted*/ nullptr,
|
||||||
/*::actions::move_unit_spectator* move_spectator*/ &move_spectator);
|
/*::actions::move_unit_spectator* move_spectator*/ &move_spectator);
|
||||||
|
|
||||||
if ( num_steps > 0 ) {
|
if ( num_steps > 0 ) {
|
||||||
|
@ -688,7 +688,7 @@ const unit_type *recruit_result::get_unit_type_known(const std::string &recruit)
|
||||||
const unit_type *type = unit_types.find(recruit);
|
const unit_type *type = unit_types.find(recruit);
|
||||||
if (!type) {
|
if (!type) {
|
||||||
set_error(E_UNKNOWN_OR_DUMMY_UNIT_TYPE);
|
set_error(E_UNKNOWN_OR_DUMMY_UNIT_TYPE);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
@ -791,7 +791,7 @@ void recruit_result::do_execute()
|
||||||
// Assert that recruit_location_ has been validated.
|
// Assert that recruit_location_ has been validated.
|
||||||
// This should be implied by is_success() once check_before() has been
|
// This should be implied by is_success() once check_before() has been
|
||||||
// called, so this is a guard against future breakage.
|
// called, so this is a guard against future breakage.
|
||||||
assert(location_checked_ && u != NULL);
|
assert(location_checked_ && u != nullptr);
|
||||||
|
|
||||||
if(resources::simulation_){
|
if(resources::simulation_){
|
||||||
bool gamestate_changed = simulated_recruit(get_side(), u, recruit_location_);
|
bool gamestate_changed = simulated_recruit(get_side(), u, recruit_location_);
|
||||||
|
@ -831,16 +831,16 @@ const unit *stopunit_result::get_unit()
|
||||||
unit_map::const_iterator un = resources::units->find(unit_location_);
|
unit_map::const_iterator un = resources::units->find(unit_location_);
|
||||||
if (un==resources::units->end()){
|
if (un==resources::units->end()){
|
||||||
set_error(E_NO_UNIT);
|
set_error(E_NO_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const unit *u = &*un;
|
const unit *u = &*un;
|
||||||
if (u->side() != get_side()) {
|
if (u->side() != get_side()) {
|
||||||
set_error(E_NOT_OWN_UNIT);
|
set_error(E_NOT_OWN_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (u->incapacitated()) {
|
if (u->incapacitated()) {
|
||||||
set_error(E_INCAPACITATED_UNIT);
|
set_error(E_INCAPACITATED_UNIT);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,7 +469,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *aspect_factories;
|
static factory_map *aspect_factories;
|
||||||
if (aspect_factories==NULL) {
|
if (aspect_factories==nullptr) {
|
||||||
aspect_factories = new factory_map;
|
aspect_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *aspect_factories;
|
return *aspect_factories;
|
||||||
|
@ -515,7 +515,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *aspect_factories;
|
static factory_map *aspect_factories;
|
||||||
if (aspect_factories==NULL) {
|
if (aspect_factories==nullptr) {
|
||||||
aspect_factories = new factory_map;
|
aspect_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *aspect_factories;
|
return *aspect_factories;
|
||||||
|
|
|
@ -76,7 +76,7 @@ component* component::get_child(const path_element &child)
|
||||||
if (i!=property_handlers_.end()) {
|
if (i!=property_handlers_.end()) {
|
||||||
return i->second->handle_get(child);
|
return i->second->handle_get(child);
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,8 +138,8 @@ property_handler_map& component::property_handlers()
|
||||||
|
|
||||||
static component *find_component(component *root, const std::string &path, path_element &tail)
|
static component *find_component(component *root, const std::string &path, path_element &tail)
|
||||||
{
|
{
|
||||||
if (root==NULL) {
|
if (root==nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//match path elements in [modify_ai] tag
|
//match path elements in [modify_ai] tag
|
||||||
|
@ -170,15 +170,15 @@ static component *find_component(component *root, const std::string &path, path_
|
||||||
elements.push_back(pe);
|
elements.push_back(pe);
|
||||||
}
|
}
|
||||||
if (elements.size()<1) {
|
if (elements.size()<1) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< path_element >::iterator k_max = elements.end()-1;
|
std::vector< path_element >::iterator k_max = elements.end()-1;
|
||||||
for (std::vector< path_element >::iterator k = elements.begin(); k!=k_max; ++k) {
|
for (std::vector< path_element >::iterator k = elements.begin(); k!=k_max; ++k) {
|
||||||
//not last
|
//not last
|
||||||
c = c->get_child(*k);
|
c = c->get_child(*k);
|
||||||
if (c==NULL) {
|
if (c==nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ bool component_manager::add_component(component *root, const std::string &path,
|
||||||
{
|
{
|
||||||
path_element tail;
|
path_element tail;
|
||||||
component *c = find_component(root,path,tail);
|
component *c = find_component(root,path,tail);
|
||||||
if (c==NULL) {
|
if (c==nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const config &ch = cfg.child(tail.property);
|
const config &ch = cfg.child(tail.property);
|
||||||
|
@ -207,7 +207,7 @@ bool component_manager::change_component(component *root, const std::string &pat
|
||||||
{
|
{
|
||||||
path_element tail;
|
path_element tail;
|
||||||
component *c = find_component(root,path,tail);
|
component *c = find_component(root,path,tail);
|
||||||
if (c==NULL) {
|
if (c==nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const config &ch = cfg.child(tail.property);
|
const config &ch = cfg.child(tail.property);
|
||||||
|
@ -221,7 +221,7 @@ bool component_manager::delete_component(component *root, const std::string &pat
|
||||||
{
|
{
|
||||||
path_element tail;
|
path_element tail;
|
||||||
component *c = find_component(root,path,tail);
|
component *c = find_component(root,path,tail);
|
||||||
if (c==NULL) {
|
if (c==nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return c->delete_child(tail);
|
return c->delete_child(tail);
|
||||||
|
@ -254,7 +254,7 @@ std::string component_manager::print_component_tree(component *root, const std::
|
||||||
component *c;
|
component *c;
|
||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
c = find_component(root,path,tail);
|
c = find_component(root,path,tail);
|
||||||
if (c==NULL) {
|
if (c==nullptr) {
|
||||||
ERR_AI_COMPONENT << "unable to find component" <<std::endl;
|
ERR_AI_COMPONENT << "unable to find component" <<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ component* component_manager::get_component(component *root, const std::string &
|
||||||
path_element tail;
|
path_element tail;
|
||||||
return find_component(root, path, tail);
|
return find_component(root, path, tail);
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end of namespace ai
|
} //end of namespace ai
|
||||||
|
|
|
@ -31,7 +31,7 @@ static lg::log_domain log_ai_engine("ai/engine");
|
||||||
|
|
||||||
engine::engine( readonly_context &context, const config &cfg )
|
engine::engine( readonly_context &context, const config &cfg )
|
||||||
: ai_(context)
|
: ai_(context)
|
||||||
, ai_context_(NULL)
|
, ai_context_(nullptr)
|
||||||
, engine_(cfg["engine"])
|
, engine_(cfg["engine"])
|
||||||
, id_(cfg["id"])
|
, id_(cfg["id"])
|
||||||
, name_(cfg["name"])
|
, name_(cfg["name"])
|
||||||
|
|
|
@ -124,7 +124,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *engine_factories;
|
static factory_map *engine_factories;
|
||||||
if (engine_factories==NULL) {
|
if (engine_factories==nullptr) {
|
||||||
engine_factories = new factory_map;
|
engine_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *engine_factories;
|
return *engine_factories;
|
||||||
|
|
|
@ -187,7 +187,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *goal_factories;
|
static factory_map *goal_factories;
|
||||||
if (goal_factories==NULL) {
|
if (goal_factories==nullptr) {
|
||||||
goal_factories = new factory_map;
|
goal_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *goal_factories;
|
return *goal_factories;
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
if (i!=values_.end()){
|
if (i!=values_.end()){
|
||||||
return &*(*i);
|
return &*(*i);
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
bool handle_change(const path_element &child, config cfg)
|
bool handle_change(const path_element &child, config cfg)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +235,7 @@ public:
|
||||||
if (a!=aspects_.end()){
|
if (a!=aspects_.end()){
|
||||||
return &*a->second;
|
return &*a->second;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handle_change(const path_element &child, config cfg)
|
bool handle_change(const path_element &child, config cfg)
|
||||||
|
|
|
@ -158,7 +158,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *candidate_action_factories;
|
static factory_map *candidate_action_factories;
|
||||||
if (candidate_action_factories==NULL) {
|
if (candidate_action_factories==nullptr) {
|
||||||
candidate_action_factories = new factory_map;
|
candidate_action_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *candidate_action_factories;
|
return *candidate_action_factories;
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
|
|
||||||
static factory_map& get_list() {
|
static factory_map& get_list() {
|
||||||
static factory_map *stage_factories;
|
static factory_map *stage_factories;
|
||||||
if (stage_factories==NULL) {
|
if (stage_factories==nullptr) {
|
||||||
stage_factories = new factory_map;
|
stage_factories = new factory_map;
|
||||||
}
|
}
|
||||||
return *stage_factories;
|
return *stage_factories;
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
#include <boost/smart_ptr/intrusive_ptr.hpp> // for intrusive_ptr
|
#include <boost/smart_ptr/intrusive_ptr.hpp> // for intrusive_ptr
|
||||||
#include <boost/smart_ptr/shared_ptr.hpp> // for dynamic_pointer_cast, etc
|
#include <boost/smart_ptr/shared_ptr.hpp> // for dynamic_pointer_cast, etc
|
||||||
#include <cmath> // for sqrt
|
#include <cmath> // for sqrt
|
||||||
#include <cstdlib> // for NULL, abs
|
#include <cstdlib> // for abs
|
||||||
#include <ctime> // for time
|
#include <ctime> // for time
|
||||||
#include <iterator> // for back_inserter
|
#include <iterator> // for back_inserter
|
||||||
#include <ostream> // for operator<<, basic_ostream, etc
|
#include <ostream> // for operator<<, basic_ostream, etc
|
||||||
|
@ -346,7 +346,7 @@ const team& readonly_context_impl::current_team() const
|
||||||
void readonly_context_impl::log_message(const std::string& msg)
|
void readonly_context_impl::log_message(const std::string& msg)
|
||||||
{
|
{
|
||||||
if(game_config::debug) {
|
if(game_config::debug) {
|
||||||
resources::screen->get_chat_manager().add_chat_message(time(NULL), "ai", get_side(), msg,
|
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "ai", get_side(), msg,
|
||||||
events::chat_handler::MESSAGE_PUBLIC, false);
|
events::chat_handler::MESSAGE_PUBLIC, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
|
||||||
// deactivate terrain filtering if it's just the dummy 'matches nothing'
|
// deactivate terrain filtering if it's just the dummy 'matches nothing'
|
||||||
static const config only_not_tag("not");
|
static const config only_not_tag("not");
|
||||||
if(remove_destinations && remove_destinations->to_config() == only_not_tag) {
|
if(remove_destinations && remove_destinations->to_config() == only_not_tag) {
|
||||||
remove_destinations = NULL;
|
remove_destinations = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<map_location,pathfind::paths>::iterator m = res.begin(); m != res.end(); ++m) {
|
for(std::map<map_location,pathfind::paths>::iterator m = res.begin(); m != res.end(); ++m) {
|
||||||
|
@ -424,7 +424,7 @@ void readonly_context_impl::calculate_moves(const unit_map& units, std::map<map_
|
||||||
const map_location& src = m->first;
|
const map_location& src = m->first;
|
||||||
const map_location& dst = dest.curr;
|
const map_location& dst = dest.curr;
|
||||||
|
|
||||||
if(remove_destinations != NULL && remove_destinations->match(dst)) {
|
if(remove_destinations != nullptr && remove_destinations->match(dst)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ const std::set<map_location>& readonly_context_impl::keeps() const
|
||||||
|
|
||||||
|
|
||||||
keeps_cache::keeps_cache()
|
keeps_cache::keeps_cache()
|
||||||
: map_(NULL)
|
: map_(nullptr)
|
||||||
, keeps_()
|
, keeps_()
|
||||||
{
|
{
|
||||||
ai::manager::add_turn_started_observer(this);
|
ai::manager::add_turn_started_observer(this);
|
||||||
|
@ -1040,14 +1040,14 @@ const map_location& readonly_context_impl::nearest_keep(const map_location& loc)
|
||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const map_location* res = NULL;
|
const map_location* res = nullptr;
|
||||||
int closest = -1;
|
int closest = -1;
|
||||||
for(std::set<map_location>::const_iterator i = keeps.begin(); i != keeps.end(); ++i) {
|
for(std::set<map_location>::const_iterator i = keeps.begin(); i != keeps.end(); ++i) {
|
||||||
if (avoided_locations.find(*i)!=avoided_locations.end()) {
|
if (avoided_locations.find(*i)!=avoided_locations.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const int distance = distance_between(*i,loc);
|
const int distance = distance_between(*i,loc);
|
||||||
if(res == NULL || distance < closest) {
|
if(res == nullptr || distance < closest) {
|
||||||
closest = distance;
|
closest = distance;
|
||||||
res = &*i;
|
res = &*i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,11 +199,11 @@ public:
|
||||||
virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
||||||
move_map& srcdst, move_map& dstsrc, bool enemy,
|
move_map& srcdst, move_map& dstsrc, bool enemy,
|
||||||
bool assume_full_movement=false,
|
bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL) const = 0;
|
const terrain_filter* remove_destinations=nullptr) const = 0;
|
||||||
virtual void calculate_moves(const unit_map& units,
|
virtual void calculate_moves(const unit_map& units,
|
||||||
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
||||||
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL,
|
const terrain_filter* remove_destinations=nullptr,
|
||||||
bool see_all=false) const = 0;
|
bool see_all=false) const = 0;
|
||||||
|
|
||||||
virtual const game_info& get_info() const = 0;
|
virtual const game_info& get_info() const = 0;
|
||||||
|
@ -465,7 +465,7 @@ public:
|
||||||
class side_context_proxy : public virtual side_context {
|
class side_context_proxy : public virtual side_context {
|
||||||
public:
|
public:
|
||||||
side_context_proxy()
|
side_context_proxy()
|
||||||
: target_(NULL)
|
: target_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ private:
|
||||||
class readonly_context_proxy : public virtual readonly_context, public virtual side_context_proxy {
|
class readonly_context_proxy : public virtual readonly_context, public virtual side_context_proxy {
|
||||||
public:
|
public:
|
||||||
readonly_context_proxy()
|
readonly_context_proxy()
|
||||||
: target_(NULL)
|
: target_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,7 +588,7 @@ public:
|
||||||
virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
virtual void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
||||||
move_map& srcdst, move_map& dstsrc, bool enemy,
|
move_map& srcdst, move_map& dstsrc, bool enemy,
|
||||||
bool assume_full_movement=false,
|
bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL) const
|
const terrain_filter* remove_destinations=nullptr) const
|
||||||
{
|
{
|
||||||
target_->calculate_possible_moves(possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations);
|
target_->calculate_possible_moves(possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations);
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ public:
|
||||||
virtual void calculate_moves(const unit_map& units,
|
virtual void calculate_moves(const unit_map& units,
|
||||||
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
||||||
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL,
|
const terrain_filter* remove_destinations=nullptr,
|
||||||
bool see_all=false) const
|
bool see_all=false) const
|
||||||
{
|
{
|
||||||
target_->calculate_moves(units, possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations, see_all);
|
target_->calculate_moves(units, possible_moves, srcdst, dstsrc, enemy, assume_full_movement, remove_destinations, see_all);
|
||||||
|
@ -1006,7 +1006,7 @@ private:
|
||||||
class readwrite_context_proxy : public virtual readwrite_context, public virtual readonly_context_proxy {
|
class readwrite_context_proxy : public virtual readwrite_context, public virtual readonly_context_proxy {
|
||||||
public:
|
public:
|
||||||
readwrite_context_proxy()
|
readwrite_context_proxy()
|
||||||
: target_(NULL)
|
: target_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1280,7 +1280,7 @@ public:
|
||||||
void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
void calculate_possible_moves(std::map<map_location,pathfind::paths>& possible_moves,
|
||||||
move_map& srcdst, move_map& dstsrc, bool enemy,
|
move_map& srcdst, move_map& dstsrc, bool enemy,
|
||||||
bool assume_full_movement=false,
|
bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL) const;
|
const terrain_filter* remove_destinations=nullptr) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A more fundamental version of calculate_possible_moves which allows the
|
* A more fundamental version of calculate_possible_moves which allows the
|
||||||
|
@ -1292,7 +1292,7 @@ public:
|
||||||
void calculate_moves(const unit_map& units,
|
void calculate_moves(const unit_map& units,
|
||||||
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
std::map<map_location,pathfind::paths>& possible_moves, move_map& srcdst,
|
||||||
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
move_map& dstsrc, bool enemy, bool assume_full_movement=false,
|
||||||
const terrain_filter* remove_destinations=NULL,
|
const terrain_filter* remove_destinations=nullptr,
|
||||||
bool see_all=false) const;
|
bool see_all=false) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,
|
||||||
assert(!movements.empty());
|
assert(!movements.empty());
|
||||||
std::vector<std::pair<map_location,map_location> >::const_iterator m;
|
std::vector<std::pair<map_location,map_location> >::const_iterator m;
|
||||||
|
|
||||||
battle_context *prev_bc = NULL;
|
battle_context *prev_bc = nullptr;
|
||||||
const combatant *prev_def = NULL;
|
const combatant *prev_def = nullptr;
|
||||||
|
|
||||||
for (m = movements.begin(); m != movements.end(); ++m) {
|
for (m = movements.begin(); m != movements.end(); ++m) {
|
||||||
// We fix up units map to reflect what this would look like.
|
// We fix up units map to reflect what this would look like.
|
||||||
|
@ -340,7 +340,7 @@ variant attack_analysis::get_value(const std::string& key) const
|
||||||
} else if(key == "movements") {
|
} else if(key == "movements") {
|
||||||
std::vector<variant> res;
|
std::vector<variant> res;
|
||||||
for(size_t n = 0; n != movements.size(); ++n) {
|
for(size_t n = 0; n != movements.size(); ++n) {
|
||||||
map_formula_callable* item = new map_formula_callable(NULL);
|
map_formula_callable* item = new map_formula_callable(nullptr);
|
||||||
item->add("src", variant(new location_callable(movements[n].first)));
|
item->add("src", variant(new location_callable(movements[n].first)));
|
||||||
item->add("dst", variant(new location_callable(movements[n].second)));
|
item->add("dst", variant(new location_callable(movements[n].second)));
|
||||||
res.push_back(variant(item));
|
res.push_back(variant(item));
|
||||||
|
|
|
@ -386,7 +386,7 @@ double move_leader_to_keep_phase::evaluate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. + 3.
|
// 2. + 3.
|
||||||
const unit* best_leader = NULL;
|
const unit* best_leader = nullptr;
|
||||||
map_location best_keep;
|
map_location best_keep;
|
||||||
int shortest_distance = 99999;
|
int shortest_distance = 99999;
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ double move_leader_to_keep_phase::evaluate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best_leader == NULL) {
|
if (best_leader == nullptr) {
|
||||||
return BAD_SCORE;
|
return BAD_SCORE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
default_ai_context_proxy()
|
default_ai_context_proxy()
|
||||||
: target_(NULL)
|
: target_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ void recruitment::execute() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
action_result_ptr action_result;
|
action_result_ptr action_result;
|
||||||
config* job = NULL;
|
config* job = nullptr;
|
||||||
do { // Recruitment loop
|
do { // Recruitment loop
|
||||||
recruit_situation_change_observer_.reset_gamestate_changed();
|
recruit_situation_change_observer_.reset_gamestate_changed();
|
||||||
|
|
||||||
|
@ -471,7 +471,7 @@ action_result_ptr recruitment::execute_recruit(const std::string& type, data& le
|
||||||
*/
|
*/
|
||||||
const std::string* recruitment::get_appropriate_recall(const std::string& type,
|
const std::string* recruitment::get_appropriate_recall(const std::string& type,
|
||||||
const data& leader_data) const {
|
const data& leader_data) const {
|
||||||
const std::string* best_recall_id = NULL;
|
const std::string* best_recall_id = nullptr;
|
||||||
double best_recall_value = -1;
|
double best_recall_value = -1;
|
||||||
BOOST_FOREACH(const unit_const_ptr & recall_unit, current_team().recall_list()) {
|
BOOST_FOREACH(const unit_const_ptr & recall_unit, current_team().recall_list()) {
|
||||||
if (type != recall_unit->type_id()) {
|
if (type != recall_unit->type_id()) {
|
||||||
|
@ -533,7 +533,7 @@ data* recruitment::get_best_leader_from_ratio_scores(std::vector<data>& leader_d
|
||||||
std::random_shuffle(leader_data.begin(), leader_data.end());
|
std::random_shuffle(leader_data.begin(), leader_data.end());
|
||||||
|
|
||||||
// Find which leader should recruit according to ratio_scores.
|
// Find which leader should recruit according to ratio_scores.
|
||||||
data* best_leader_data = NULL;
|
data* best_leader_data = nullptr;
|
||||||
double biggest_difference = -99999.;
|
double biggest_difference = -99999.;
|
||||||
BOOST_FOREACH(data& data, leader_data) {
|
BOOST_FOREACH(data& data, leader_data) {
|
||||||
if (!leader_matches_job(data, job)) {
|
if (!leader_matches_job(data, job)) {
|
||||||
|
@ -1024,12 +1024,12 @@ void recruitment::do_combat_analysis(std::vector<data>* leader_data) {
|
||||||
/**
|
/**
|
||||||
* For Combat Analysis.
|
* For Combat Analysis.
|
||||||
* Returns the cached combat value for two unit types
|
* Returns the cached combat value for two unit types
|
||||||
* or NULL if there is none or terrain defenses are not within range.
|
* or nullptr if there is none or terrain defenses are not within range.
|
||||||
*/
|
*/
|
||||||
const double* recruitment::get_cached_combat_value(const std::string& a, const std::string& b,
|
const double* recruitment::get_cached_combat_value(const std::string& a, const std::string& b,
|
||||||
double a_defense, double b_defense) {
|
double a_defense, double b_defense) {
|
||||||
double best_distance = 999;
|
double best_distance = 999;
|
||||||
const double* best_value = NULL;
|
const double* best_value = nullptr;
|
||||||
const std::set<cached_combat_value>& cache = combat_cache_[a][b];
|
const std::set<cached_combat_value>& cache = combat_cache_[a][b];
|
||||||
BOOST_FOREACH(const cached_combat_value& entry, cache) {
|
BOOST_FOREACH(const cached_combat_value& entry, cache) {
|
||||||
double distance_a = std::abs(entry.a_defense - a_defense);
|
double distance_a = std::abs(entry.a_defense - a_defense);
|
||||||
|
@ -1117,7 +1117,7 @@ void recruitment::simulate_attack(
|
||||||
double attacker_defense, double defender_defense,
|
double attacker_defense, double defender_defense,
|
||||||
double* damage_to_attacker, double* damage_to_defender) const {
|
double* damage_to_attacker, double* damage_to_defender) const {
|
||||||
if(!attacker || !defender || !damage_to_attacker || !damage_to_defender) {
|
if(!attacker || !defender || !damage_to_attacker || !damage_to_defender) {
|
||||||
ERR_AI_RECRUITMENT << "NULL pointer in simulate_attack()" << std::endl;
|
ERR_AI_RECRUITMENT << "nullptr pointer in simulate_attack()" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const std::vector<attack_type> attacker_weapons = attacker->attacks();
|
const std::vector<attack_type> attacker_weapons = attacker->attacks();
|
||||||
|
@ -1147,7 +1147,7 @@ void recruitment::simulate_attack(
|
||||||
best_def_response.reset(new attack_simulation(
|
best_def_response.reset(new attack_simulation(
|
||||||
attacker, defender,
|
attacker, defender,
|
||||||
attacker_defense, defender_defense,
|
attacker_defense, defender_defense,
|
||||||
&att_weapon, NULL, average_lawful_bonus_));
|
&att_weapon, nullptr, average_lawful_bonus_));
|
||||||
}
|
}
|
||||||
if (!best_att_attack || best_def_response->better_result(best_att_attack.get(), false)) {
|
if (!best_att_attack || best_def_response->better_result(best_att_attack.get(), false)) {
|
||||||
best_att_attack = best_def_response;
|
best_att_attack = best_def_response;
|
||||||
|
@ -1167,7 +1167,7 @@ void recruitment::simulate_attack(
|
||||||
* We call a [recruit] tag a "job".
|
* We call a [recruit] tag a "job".
|
||||||
*/
|
*/
|
||||||
config* recruitment::get_most_important_job() {
|
config* recruitment::get_most_important_job() {
|
||||||
config* most_important_job = NULL;
|
config* most_important_job = nullptr;
|
||||||
int most_important_importance = -1;
|
int most_important_importance = -1;
|
||||||
int biggest_number = -1;
|
int biggest_number = -1;
|
||||||
BOOST_FOREACH(config& job, recruitment_instructions_.child_range("recruit")) {
|
BOOST_FOREACH(config& job, recruitment_instructions_.child_range("recruit")) {
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
#include <boost/lexical_cast.hpp> // for lexical_cast
|
#include <boost/lexical_cast.hpp> // for lexical_cast
|
||||||
#include <boost/shared_ptr.hpp> // for shared_ptr
|
#include <boost/shared_ptr.hpp> // for shared_ptr
|
||||||
#include <cassert> // for assert
|
#include <cassert> // for assert
|
||||||
#include <ctime> // for NULL, time
|
#include <ctime> // for time
|
||||||
#include <map> // for multimap<>::const_iterator, etc
|
#include <map> // for multimap<>::const_iterator, etc
|
||||||
#include <sstream> // for operator<<, basic_ostream, etc
|
#include <sstream> // for operator<<, basic_ostream, etc
|
||||||
#include <stack> // for stack
|
#include <stack> // for stack
|
||||||
|
@ -91,7 +91,7 @@ formula_ai::formula_ai(readonly_context &context, const config &cfg)
|
||||||
:
|
:
|
||||||
readonly_context_proxy(),
|
readonly_context_proxy(),
|
||||||
game_logic::formula_callable(),
|
game_logic::formula_callable(),
|
||||||
ai_ptr_(NULL),
|
ai_ptr_(nullptr),
|
||||||
cfg_(cfg),
|
cfg_(cfg),
|
||||||
recursion_counter_(context.get_recursion_count()),
|
recursion_counter_(context.get_recursion_count()),
|
||||||
keeps_cache_(),
|
keeps_cache_(),
|
||||||
|
@ -126,7 +126,7 @@ void formula_ai::handle_exception(game_logic::formula_error& e, const std::strin
|
||||||
|
|
||||||
void formula_ai::display_message(const std::string& msg) const
|
void formula_ai::display_message(const std::string& msg) const
|
||||||
{
|
{
|
||||||
resources::screen->get_chat_manager().add_chat_message(time(NULL), "wfl", get_side(), msg,
|
resources::screen->get_chat_manager().add_chat_message(time(nullptr), "wfl", get_side(), msg,
|
||||||
events::chat_handler::MESSAGE_PUBLIC, false);
|
events::chat_handler::MESSAGE_PUBLIC, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ std::string formula_ai::evaluate(const std::string& formula_str)
|
||||||
callable.add_ref();
|
callable.add_ref();
|
||||||
|
|
||||||
//formula_debugger fdb;
|
//formula_debugger fdb;
|
||||||
const variant v = f.evaluate(callable,NULL);
|
const variant v = f.evaluate(callable,nullptr);
|
||||||
|
|
||||||
if (ai_ptr_) {
|
if (ai_ptr_) {
|
||||||
variant var = execute_variant(v, *ai_ptr_, true );
|
variant var = execute_variant(v, *ai_ptr_, true );
|
||||||
|
@ -495,7 +495,7 @@ variant formula_ai::execute_variant(const variant& var, ai_context &ai_, bool co
|
||||||
ERR_AI << "ERROR #" << 5001 << " while executing 'continue' formula keyword" << std::endl;
|
ERR_AI << "ERROR #" << 5001 << " while executing 'continue' formula keyword" << std::endl;
|
||||||
|
|
||||||
if( safe_call )
|
if( safe_call )
|
||||||
error = variant(new safe_call_result(NULL, 5001));
|
error = variant(new safe_call_result(nullptr, 5001));
|
||||||
}
|
}
|
||||||
} else if( action.is_string() && (action.as_string() == "end_turn" || action.as_string() == "end" ) ) {
|
} else if( action.is_string() && (action.as_string() == "end_turn" || action.as_string() == "end" ) ) {
|
||||||
return variant();
|
return variant();
|
||||||
|
@ -553,7 +553,7 @@ void formula_ai::add_formula_function(const std::string& name, const_formula_ptr
|
||||||
namespace {
|
namespace {
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
variant villages_from_set(const Container& villages,
|
variant villages_from_set(const Container& villages,
|
||||||
const std::set<map_location>* exclude=NULL) {
|
const std::set<map_location>* exclude=nullptr) {
|
||||||
std::vector<variant> vars;
|
std::vector<variant> vars;
|
||||||
BOOST_FOREACH(const map_location& loc, villages) {
|
BOOST_FOREACH(const map_location& loc, villages) {
|
||||||
if(exclude && exclude->count(loc)) {
|
if(exclude && exclude->count(loc)) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ void move_map_callable::get_inputs(std::vector<game_logic::formula_input>* input
|
||||||
int move_callable::do_compare(const formula_callable* callable) const
|
int move_callable::do_compare(const formula_callable* callable) const
|
||||||
{
|
{
|
||||||
const move_callable* mv_callable = dynamic_cast<const move_callable*>(callable);
|
const move_callable* mv_callable = dynamic_cast<const move_callable*>(callable);
|
||||||
if(mv_callable == NULL) {
|
if(mv_callable == nullptr) {
|
||||||
return formula_callable::do_compare(callable);
|
return formula_callable::do_compare(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ int move_callable::do_compare(const formula_callable* callable) const
|
||||||
int move_partial_callable::do_compare(const formula_callable* callable) const
|
int move_partial_callable::do_compare(const formula_callable* callable) const
|
||||||
{
|
{
|
||||||
const move_partial_callable* mv_callable = dynamic_cast<const move_partial_callable*>(callable);
|
const move_partial_callable* mv_callable = dynamic_cast<const move_partial_callable*>(callable);
|
||||||
if(mv_callable == NULL) {
|
if(mv_callable == nullptr) {
|
||||||
return formula_callable::do_compare(callable);
|
return formula_callable::do_compare(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void outcome_callable::get_inputs(std::vector<game_logic::formula_input>* inputs
|
||||||
attack_callable::attack_callable(const map_location& move_from,
|
attack_callable::attack_callable(const map_location& move_from,
|
||||||
const map_location& src, const map_location& dst, int weapon)
|
const map_location& src, const map_location& dst, int weapon)
|
||||||
: move_from_(move_from), src_(src), dst_(dst),
|
: move_from_(move_from), src_(src), dst_(dst),
|
||||||
bc_(*resources::units, src, dst, weapon, -1, 1.0, NULL,
|
bc_(*resources::units, src, dst, weapon, -1, 1.0, nullptr,
|
||||||
&*resources::units->find(move_from))
|
&*resources::units->find(move_from))
|
||||||
{
|
{
|
||||||
type_ = ATTACK_C;
|
type_ = ATTACK_C;
|
||||||
|
@ -143,7 +143,7 @@ void attack_callable::get_inputs(std::vector<game_logic::formula_input>* inputs)
|
||||||
int attack_callable::do_compare(const game_logic::formula_callable* callable)
|
int attack_callable::do_compare(const game_logic::formula_callable* callable)
|
||||||
const {
|
const {
|
||||||
const attack_callable* a_callable = dynamic_cast<const attack_callable*>(callable);
|
const attack_callable* a_callable = dynamic_cast<const attack_callable*>(callable);
|
||||||
if(a_callable == NULL) {
|
if(a_callable == nullptr) {
|
||||||
return formula_callable::do_compare(callable);
|
return formula_callable::do_compare(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ variant safe_call_result::get_value(const std::string& key) const {
|
||||||
return variant(status_);
|
return variant(status_);
|
||||||
|
|
||||||
if(key == "object") {
|
if(key == "object") {
|
||||||
if( failed_callable_ != NULL)
|
if( failed_callable_ != nullptr)
|
||||||
return variant(failed_callable_);
|
return variant(failed_callable_);
|
||||||
else
|
else
|
||||||
return variant();
|
return variant();
|
||||||
|
|
|
@ -258,7 +258,7 @@ void attack_candidate_action::evaluate(ai::formula_ai* ai, unit_map& units)
|
||||||
|
|
||||||
for(variant_iterator i = filtered_my_units.begin() ; i != filtered_my_units.end() ; ++i) {
|
for(variant_iterator i = filtered_my_units.begin() ; i != filtered_my_units.end() ; ++i) {
|
||||||
const unit_callable* u_callable = dynamic_cast<const unit_callable*>( (*i).as_callable() );
|
const unit_callable* u_callable = dynamic_cast<const unit_callable*>( (*i).as_callable() );
|
||||||
if(u_callable == NULL) {
|
if(u_callable == nullptr) {
|
||||||
ERR_AI << "ERROR in "<< get_name() << "Candidate Action: Filter formula returned table that does not contain units" << std::endl;
|
ERR_AI << "ERROR in "<< get_name() << "Candidate Action: Filter formula returned table that does not contain units" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ void attack_candidate_action::evaluate(ai::formula_ai* ai, unit_map& units)
|
||||||
|
|
||||||
for(variant_iterator i = filtered_enemy_units.begin() ; i != filtered_enemy_units.end() ; ++i) {
|
for(variant_iterator i = filtered_enemy_units.begin() ; i != filtered_enemy_units.end() ; ++i) {
|
||||||
const unit_callable* u_callable = dynamic_cast<const unit_callable*>( (*i).as_callable() );
|
const unit_callable* u_callable = dynamic_cast<const unit_callable*>( (*i).as_callable() );
|
||||||
if(u_callable == NULL) {
|
if(u_callable == nullptr) {
|
||||||
ERR_AI << "ERROR in "<< get_name() << "Candidate Action: Filter formula returned table that does not contain units" << std::endl;
|
ERR_AI << "ERROR in "<< get_name() << "Candidate Action: Filter formula returned table that does not contain units" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ std::string engine_fai::evaluate(const std::string &str)
|
||||||
|
|
||||||
void engine_fai::set_ai_context(ai_context *context)
|
void engine_fai::set_ai_context(ai_context *context)
|
||||||
{
|
{
|
||||||
if (context!=NULL) {
|
if (context!=nullptr) {
|
||||||
DBG_AI_ENGINE_FAI << "fai engine: ai_context is set" << std::endl;
|
DBG_AI_ENGINE_FAI << "fai engine: ai_context is set" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
DBG_AI_ENGINE_FAI << "fai engine: ai_context is cleared" << std::endl;
|
DBG_AI_ENGINE_FAI << "fai engine: ai_context is cleared" << std::endl;
|
||||||
|
|
|
@ -65,7 +65,7 @@ class unit_adapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
int damage_from(const attack_type& attack) const {
|
int damage_from(const attack_type& attack) const {
|
||||||
if(unit_type_ != NULL) {
|
if(unit_type_ != nullptr) {
|
||||||
return unit_type_->movement_type().resistance_against(attack);
|
return unit_type_->movement_type().resistance_against(attack);
|
||||||
} else {
|
} else {
|
||||||
return unit_->damage_from(attack, false, map_location());
|
return unit_->damage_from(attack, false, map_location());
|
||||||
|
@ -75,7 +75,7 @@ class unit_adapter {
|
||||||
// FIXME: we return a vector by value because unit_type and unit APIs
|
// FIXME: we return a vector by value because unit_type and unit APIs
|
||||||
// disagree as to what should be returned by their attacks() method
|
// disagree as to what should be returned by their attacks() method
|
||||||
std::vector<attack_type> attacks() const {
|
std::vector<attack_type> attacks() const {
|
||||||
if(unit_type_ != NULL) {
|
if(unit_type_ != nullptr) {
|
||||||
return unit_type_->attacks();
|
return unit_type_->attacks();
|
||||||
} else {
|
} else {
|
||||||
return unit_->attacks();
|
return unit_->attacks();
|
||||||
|
@ -83,7 +83,7 @@ class unit_adapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
int movement_cost(const t_translation::t_terrain & terrain) const {
|
int movement_cost(const t_translation::t_terrain & terrain) const {
|
||||||
if(unit_type_ != NULL) {
|
if(unit_type_ != nullptr) {
|
||||||
return unit_type_->movement_type().movement_cost(terrain);
|
return unit_type_->movement_type().movement_cost(terrain);
|
||||||
} else {
|
} else {
|
||||||
return unit_->movement_cost(terrain);
|
return unit_->movement_cost(terrain);
|
||||||
|
@ -581,19 +581,19 @@ private:
|
||||||
|
|
||||||
const unit_callable* u_call = try_convert_variant<unit_callable>(u);
|
const unit_callable* u_call = try_convert_variant<unit_callable>(u);
|
||||||
|
|
||||||
if (u_call == NULL) {
|
if (u_call == nullptr) {
|
||||||
return variant();
|
return variant();
|
||||||
}
|
}
|
||||||
|
|
||||||
const unit& un = u_call->get_unit();
|
const unit& un = u_call->get_unit();
|
||||||
|
|
||||||
map_location const* loc = NULL;
|
map_location const* loc = nullptr;
|
||||||
|
|
||||||
if(args().size()==2) {
|
if(args().size()==2) {
|
||||||
loc = &convert_variant<location_callable>(args()[1]->evaluate(variables,add_debug_info(fdb,1,"timeofday_modifier:location")))->loc();
|
loc = &convert_variant<location_callable>(args()[1]->evaluate(variables,add_debug_info(fdb,1,"timeofday_modifier:location")))->loc();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loc == NULL) {
|
if (loc == nullptr) {
|
||||||
loc = &u_call->get_location();
|
loc = &u_call->get_location();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,7 +760,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
battle_context bc(units, convert_variant<location_callable>(args()[1]->evaluate(variables,add_debug_info(fdb,1,"calculate_outcome:attacker_attack_location")))->loc(),
|
battle_context bc(units, convert_variant<location_callable>(args()[1]->evaluate(variables,add_debug_info(fdb,1,"calculate_outcome:attacker_attack_location")))->loc(),
|
||||||
defender_location, weapon, -1, 1.0, NULL, &*units.find(attacker_location));
|
defender_location, weapon, -1, 1.0, nullptr, &*units.find(attacker_location));
|
||||||
std::vector<double> hp_dist = bc.get_attacker_combatant().hp_dist;
|
std::vector<double> hp_dist = bc.get_attacker_combatant().hp_dist;
|
||||||
std::vector<double>::iterator it = hp_dist.begin();
|
std::vector<double>::iterator it = hp_dist.begin();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "units/unit.hpp"
|
#include "units/unit.hpp"
|
||||||
#include "units/map.hpp" // for unit_map::const_iterator, etc
|
#include "units/map.hpp" // for unit_map::const_iterator, etc
|
||||||
|
|
||||||
#include <cstddef> // for NULL
|
|
||||||
#include <ostream> // for operator<<, basic_ostream, etc
|
#include <ostream> // for operator<<, basic_ostream, etc
|
||||||
#include <string> // for string, char_traits, etc
|
#include <string> // for string, char_traits, etc
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
@ -82,7 +81,7 @@ const std::vector<std::string> unit_advancements_aspect::get_advancements(const
|
||||||
|
|
||||||
LOG_LUA << "Entering unit_advancements_aspect::get_advancements() in instance " << this << " with unit " << unit_id << " on (x,y) = (" << unit_x << ", " << unit_y << ")\n";
|
LOG_LUA << "Entering unit_advancements_aspect::get_advancements() in instance " << this << " with unit " << unit_id << " on (x,y) = (" << unit_x << ", " << unit_y << ")\n";
|
||||||
|
|
||||||
if(L_ == NULL || ref_ == LUA_REFNIL)
|
if(L_ == nullptr || ref_ == LUA_REFNIL)
|
||||||
{
|
{
|
||||||
//If we end up here, most likely the aspect don't use the lua-engine.
|
//If we end up here, most likely the aspect don't use the lua-engine.
|
||||||
//Just to make sure:
|
//Just to make sure:
|
||||||
|
|
|
@ -165,7 +165,7 @@ static int cfun_ai_get_suitable_keep(lua_State *L)
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
|
||||||
ai::readonly_context &context = get_readonly_context(L);
|
ai::readonly_context &context = get_readonly_context(L);
|
||||||
unit* leader = NULL;
|
unit* leader = nullptr;
|
||||||
if (lua_isuserdata(L, index))
|
if (lua_isuserdata(L, index))
|
||||||
{
|
{
|
||||||
leader = luaW_tounit(L, index);
|
leader = luaW_tounit(L, index);
|
||||||
|
@ -820,7 +820,7 @@ static int impl_ai_aspect_get(lua_State* L)
|
||||||
(void) aspect;
|
(void) aspect;
|
||||||
} else if(typesafe_aspect<unit_advancements_aspect>* aspect = try_aspect_as<unit_advancements_aspect>(iter->second)) {
|
} else if(typesafe_aspect<unit_advancements_aspect>* aspect = try_aspect_as<unit_advancements_aspect>(iter->second)) {
|
||||||
const unit_advancements_aspect& val = aspect->get();
|
const unit_advancements_aspect& val = aspect->get();
|
||||||
int my_side = luaW_getglobal(L, "ai", "side", NULL) - 1;
|
int my_side = luaW_getglobal(L, "ai", "side", nullptr) - 1;
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
for (unit_map::const_iterator u = resources::units->begin(); u != resources::units->end(); ++u) {
|
for (unit_map::const_iterator u = resources::units->begin(); u != resources::units->end(); ++u) {
|
||||||
if (!u.valid() || u->side() != my_side) {
|
if (!u.valid() || u->side() != my_side) {
|
||||||
|
@ -911,7 +911,7 @@ static int impl_ai_get(lua_State* L)
|
||||||
{ "check_recruit", &cfun_ai_check_recruit },
|
{ "check_recruit", &cfun_ai_check_recruit },
|
||||||
//{ "",},
|
//{ "",},
|
||||||
//{ "",},
|
//{ "",},
|
||||||
{ NULL, NULL } };
|
{ nullptr, nullptr } };
|
||||||
for (const luaL_Reg* p = callbacks; p->name; ++p) {
|
for (const luaL_Reg* p = callbacks; p->name; ++p) {
|
||||||
if(m == p->name) {
|
if(m == p->name) {
|
||||||
lua_pushlightuserdata(L, &engine); // [-1: engine ...]
|
lua_pushlightuserdata(L, &engine); // [-1: engine ...]
|
||||||
|
@ -940,7 +940,7 @@ static int impl_ai_get(lua_State* L)
|
||||||
{ "stopunit_attacks", &cfun_ai_execute_stopunit_attacks },
|
{ "stopunit_attacks", &cfun_ai_execute_stopunit_attacks },
|
||||||
{ "stopunit_moves", &cfun_ai_execute_stopunit_moves },
|
{ "stopunit_moves", &cfun_ai_execute_stopunit_moves },
|
||||||
{ "synced_command", &cfun_ai_execute_synced_command },
|
{ "synced_command", &cfun_ai_execute_synced_command },
|
||||||
{ NULL, NULL } };
|
{ nullptr, nullptr } };
|
||||||
for (const luaL_Reg* p = mutating_callbacks; p->name; ++p) {
|
for (const luaL_Reg* p = mutating_callbacks; p->name; ++p) {
|
||||||
if(m == p->name) {
|
if(m == p->name) {
|
||||||
lua_pushlightuserdata(L, &engine);
|
lua_pushlightuserdata(L, &engine);
|
||||||
|
@ -985,7 +985,7 @@ lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engin
|
||||||
char const *m = lua_tostring(L, -1);
|
char const *m = lua_tostring(L, -1);
|
||||||
ERR_LUA << "error while initializing ai: " <<m << '\n';
|
ERR_LUA << "error while initializing ai: " <<m << '\n';
|
||||||
lua_pop(L, 2);//return with stack size 0 []
|
lua_pop(L, 2);//return with stack size 0 []
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
//push data table here
|
//push data table here
|
||||||
size_t idx = generate_and_push_ai_state(L, engine); // [-1: AI state -2: AI code]
|
size_t idx = generate_and_push_ai_state(L, engine); // [-1: AI state -2: AI code]
|
||||||
|
@ -1027,7 +1027,7 @@ lua_ai_action_handler* lua_ai_action_handler::create(lua_State *L, char const *c
|
||||||
char const *m = lua_tostring(L, -1);
|
char const *m = lua_tostring(L, -1);
|
||||||
ERR_LUA << "error while creating ai function: " <<m << '\n';
|
ERR_LUA << "error while creating ai function: " <<m << '\n';
|
||||||
lua_pop(L, 2);//return with stack size 0 []
|
lua_pop(L, 2);//return with stack size 0 []
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the ai elements table from the registry.
|
// Retrieve the ai elements table from the registry.
|
||||||
|
|
|
@ -258,7 +258,7 @@ engine_lua::engine_lua( readonly_context &context, const config &cfg )
|
||||||
config data(cfg.child_or_empty("data"));
|
config data(cfg.child_or_empty("data"));
|
||||||
config args(cfg.child_or_empty("args"));
|
config args(cfg.child_or_empty("args"));
|
||||||
|
|
||||||
if (lua_ai_context_) { // The context might be NULL if the config contains errors
|
if (lua_ai_context_) { // The context might be nullptr if the config contains errors
|
||||||
lua_ai_context_->set_persistent_data(data);
|
lua_ai_context_->set_persistent_data(data);
|
||||||
lua_ai_context_->set_arguments(args);
|
lua_ai_context_->set_arguments(args);
|
||||||
lua_ai_context_->update_state();
|
lua_ai_context_->update_state();
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace ai {
|
||||||
boost::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n)
|
boost::shared_ptr<aspect_attacks_lua_filter> lua_object<aspect_attacks_lua_filter>::to_type(lua_State *L, int n)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<aspect_attacks_lua_filter> att(new aspect_attacks_lua_filter);
|
boost::shared_ptr<aspect_attacks_lua_filter> att(new aspect_attacks_lua_filter);
|
||||||
att->lua = NULL;
|
att->lua = nullptr;
|
||||||
att->ref_own_ = att->ref_enemy_ = -1;
|
att->ref_own_ = att->ref_enemy_ = -1;
|
||||||
if(!lua_istable(L, n)) {
|
if(!lua_istable(L, n)) {
|
||||||
return att;
|
return att;
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
#include <algorithm> // for min
|
#include <algorithm> // for min
|
||||||
#include <boost/foreach.hpp> // for auto_any_base, etc
|
#include <boost/foreach.hpp> // for auto_any_base, etc
|
||||||
#include <cassert> // for assert
|
#include <cassert> // for assert
|
||||||
#include <cstddef> // for NULL
|
|
||||||
#include <iterator> // for reverse_iterator, etc
|
#include <iterator> // for reverse_iterator, etc
|
||||||
#include <map> // for _Rb_tree_iterator, etc
|
#include <map> // for _Rb_tree_iterator, etc
|
||||||
#include <ostream> // for operator<<, basic_ostream, etc
|
#include <ostream> // for operator<<, basic_ostream, etc
|
||||||
|
@ -79,7 +78,7 @@ static lg::log_domain log_ai_mod("ai/mod");
|
||||||
#define ERR_AI_MOD LOG_STREAM(err, log_ai_mod)
|
#define ERR_AI_MOD LOG_STREAM(err, log_ai_mod)
|
||||||
|
|
||||||
holder::holder( side_number side, const config &cfg )
|
holder::holder( side_number side, const config &cfg )
|
||||||
: ai_(), side_context_(NULL), readonly_context_(NULL), readwrite_context_(NULL), default_ai_context_(NULL), side_(side), cfg_(cfg)
|
: ai_(), side_context_(nullptr), readonly_context_(nullptr), readwrite_context_(nullptr), default_ai_context_(nullptr), side_(side), cfg_(cfg)
|
||||||
{
|
{
|
||||||
DBG_AI_MANAGER << describe_ai() << "Preparing new AI holder" << std::endl;
|
DBG_AI_MANAGER << describe_ai() << "Preparing new AI holder" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -87,19 +86,19 @@ holder::holder( side_number side, const config &cfg )
|
||||||
|
|
||||||
void holder::init( side_number side )
|
void holder::init( side_number side )
|
||||||
{
|
{
|
||||||
if (side_context_ == NULL) {
|
if (side_context_ == nullptr) {
|
||||||
side_context_ = new side_context_impl(side,cfg_);
|
side_context_ = new side_context_impl(side,cfg_);
|
||||||
} else {
|
} else {
|
||||||
side_context_->set_side(side);
|
side_context_->set_side(side);
|
||||||
}
|
}
|
||||||
if (readonly_context_ == NULL){
|
if (readonly_context_ == nullptr){
|
||||||
readonly_context_ = new readonly_context_impl(*side_context_,cfg_);
|
readonly_context_ = new readonly_context_impl(*side_context_,cfg_);
|
||||||
readonly_context_->on_readonly_context_create();
|
readonly_context_->on_readonly_context_create();
|
||||||
}
|
}
|
||||||
if (readwrite_context_ == NULL){
|
if (readwrite_context_ == nullptr){
|
||||||
readwrite_context_ = new readwrite_context_impl(*readonly_context_,cfg_);
|
readwrite_context_ = new readwrite_context_impl(*readonly_context_,cfg_);
|
||||||
}
|
}
|
||||||
if (default_ai_context_ == NULL){
|
if (default_ai_context_ == nullptr){
|
||||||
default_ai_context_ = new default_ai_context_impl(*readwrite_context_,cfg_);
|
default_ai_context_ = new default_ai_context_impl(*readwrite_context_,cfg_);
|
||||||
}
|
}
|
||||||
if (!this->ai_){
|
if (!this->ai_){
|
||||||
|
@ -163,7 +162,7 @@ void holder::modify_side_ai_config(config cfg)
|
||||||
DBG_AI_MANAGER << "after transforming [modify_side][ai] into new syntax, config contains:"<< std::endl << cfg << std::endl;
|
DBG_AI_MANAGER << "after transforming [modify_side][ai] into new syntax, config contains:"<< std::endl << cfg << std::endl;
|
||||||
|
|
||||||
// TODO: Also add [goal] tags. And what about [stage] or [engine] tags? (Maybe they're not important.)
|
// TODO: Also add [goal] tags. And what about [stage] or [engine] tags? (Maybe they're not important.)
|
||||||
if (this->readonly_context_ == NULL) {
|
if (this->readonly_context_ == nullptr) {
|
||||||
// if not initialized, append that config to the bottom of base cfg
|
// if not initialized, append that config to the bottom of base cfg
|
||||||
// then, merge aspects with the same id
|
// then, merge aspects with the same id
|
||||||
cfg_.merge_with(cfg);
|
cfg_.merge_with(cfg);
|
||||||
|
@ -221,16 +220,16 @@ config holder::to_config() const
|
||||||
} else {
|
} else {
|
||||||
config cfg = ai_->to_config();
|
config cfg = ai_->to_config();
|
||||||
cfg["version"] = "10703";
|
cfg["version"] = "10703";
|
||||||
if (this->side_context_!=NULL) {
|
if (this->side_context_!=nullptr) {
|
||||||
cfg.merge_with(this->side_context_->to_side_context_config());
|
cfg.merge_with(this->side_context_->to_side_context_config());
|
||||||
}
|
}
|
||||||
if (this->readonly_context_!=NULL) {
|
if (this->readonly_context_!=nullptr) {
|
||||||
cfg.merge_with(this->readonly_context_->to_readonly_context_config());
|
cfg.merge_with(this->readonly_context_->to_readonly_context_config());
|
||||||
}
|
}
|
||||||
if (this->readwrite_context_!=NULL) {
|
if (this->readwrite_context_!=nullptr) {
|
||||||
cfg.merge_with(this->readwrite_context_->to_readwrite_context_config());
|
cfg.merge_with(this->readwrite_context_->to_readwrite_context_config());
|
||||||
}
|
}
|
||||||
if (this->default_ai_context_!=NULL) {
|
if (this->default_ai_context_!=nullptr) {
|
||||||
cfg.merge_with(this->default_ai_context_->to_default_ai_context_config());
|
cfg.merge_with(this->default_ai_context_->to_default_ai_context_config());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +243,7 @@ const std::string holder::describe_ai()
|
||||||
{
|
{
|
||||||
std::string sidestr = std::to_string(this->side_);
|
std::string sidestr = std::to_string(this->side_);
|
||||||
|
|
||||||
if (this->ai_!=NULL) {
|
if (this->ai_!=nullptr) {
|
||||||
return this->ai_->describe_self()+std::string(" for side ")+sidestr+std::string(" : ");
|
return this->ai_->describe_self()+std::string(" for side ")+sidestr+std::string(" : ");
|
||||||
} else {
|
} else {
|
||||||
return std::string("not initialized ai with id=[")+cfg_["id"]+std::string("] for side ")+sidestr+std::string(" : ");
|
return std::string("not initialized ai with id=[")+cfg_["id"]+std::string("] for side ")+sidestr+std::string(" : ");
|
||||||
|
@ -304,10 +303,10 @@ const std::string holder::get_ai_identifier() const
|
||||||
component* holder::get_component(component *root, const std::string &path) {
|
component* holder::get_component(component *root, const std::string &path) {
|
||||||
if (!game_config::debug) // Debug guard
|
if (!game_config::debug) // Debug guard
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root == NULL) // Return root component(ai_)
|
if (root == nullptr) // Return root component(ai_)
|
||||||
{
|
{
|
||||||
if (!this->ai_) {
|
if (!this->ai_) {
|
||||||
this->init(this->side_);
|
this->init(this->side_);
|
||||||
|
@ -340,7 +339,7 @@ int manager::num_interact_ = 0;
|
||||||
|
|
||||||
void manager::set_ai_info(const game_info& i)
|
void manager::set_ai_info(const game_info& i)
|
||||||
{
|
{
|
||||||
if (ai_info_!=NULL){
|
if (ai_info_!=nullptr){
|
||||||
clear_ai_info();
|
clear_ai_info();
|
||||||
}
|
}
|
||||||
ai_info_ = new game_info(i);
|
ai_info_ = new game_info(i);
|
||||||
|
@ -350,7 +349,7 @@ void manager::set_ai_info(const game_info& i)
|
||||||
|
|
||||||
void manager::clear_ai_info(){
|
void manager::clear_ai_info(){
|
||||||
delete ai_info_;
|
delete ai_info_;
|
||||||
ai_info_ = NULL;
|
ai_info_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -723,7 +722,7 @@ void manager::modify_active_ai_config_old_for_side ( side_number side, const con
|
||||||
|
|
||||||
void manager::modify_active_ai_for_side ( side_number side, const config &cfg )
|
void manager::modify_active_ai_for_side ( side_number side, const config &cfg )
|
||||||
{
|
{
|
||||||
if (ai_info_==NULL) {
|
if (ai_info_==nullptr) {
|
||||||
//replay ?
|
//replay ?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ bool simulated_synced_command(){
|
||||||
// Helper functions.
|
// Helper functions.
|
||||||
void helper_check_village(const map_location& loc, int side){
|
void helper_check_village(const map_location& loc, int side){
|
||||||
std::vector<team> &teams = *resources::teams;
|
std::vector<team> &teams = *resources::teams;
|
||||||
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : NULL;
|
team *t = unsigned(side - 1) < teams.size() ? &teams[side - 1] : nullptr;
|
||||||
if(t && t->owns_village(loc)){
|
if(t && t->owns_village(loc)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ void helper_check_village(const map_location& loc, int side){
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
|
|
||||||
if(has_leader){
|
if(has_leader){
|
||||||
t->get_village(loc, old_owner_side, NULL);
|
t->get_village(loc, old_owner_side, nullptr);
|
||||||
DBG_AI_SIM_ACTIONS << "side " << side << " gets village at " << loc << std::endl;
|
DBG_AI_SIM_ACTIONS << "side " << side << " gets village at " << loc << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ public:
|
||||||
std::vector<double> & col_sums) const;
|
std::vector<double> & col_sums) const;
|
||||||
|
|
||||||
/// Returns true if the specified plane might have data in it.
|
/// Returns true if the specified plane might have data in it.
|
||||||
bool plane_used(unsigned p) const { return p < NUM_PLANES && plane_[p] != NULL; }
|
bool plane_used(unsigned p) const { return p < NUM_PLANES && plane_[p] != nullptr; }
|
||||||
|
|
||||||
unsigned int num_rows() const { return rows_; }
|
unsigned int num_rows() const { return rows_; }
|
||||||
unsigned int num_cols() const { return cols_; }
|
unsigned int num_cols() const { return cols_; }
|
||||||
|
@ -253,9 +253,9 @@ prob_matrix::prob_matrix(unsigned int a_max, unsigned int b_max,
|
||||||
|
|
||||||
// Allocate the needed planes.
|
// Allocate the needed planes.
|
||||||
plane_[NEITHER_SLOWED] = new_plane();
|
plane_[NEITHER_SLOWED] = new_plane();
|
||||||
plane_[A_SLOWED] = !need_a_slowed ? NULL : new_plane();
|
plane_[A_SLOWED] = !need_a_slowed ? nullptr : new_plane();
|
||||||
plane_[B_SLOWED] = !need_b_slowed ? NULL : new_plane();
|
plane_[B_SLOWED] = !need_b_slowed ? nullptr : new_plane();
|
||||||
plane_[BOTH_SLOWED] = !(need_a_slowed && need_b_slowed) ? NULL : new_plane();
|
plane_[BOTH_SLOWED] = !(need_a_slowed && need_b_slowed) ? nullptr : new_plane();
|
||||||
|
|
||||||
// Initialize the probability distribution.
|
// Initialize the probability distribution.
|
||||||
initialize_plane(NEITHER_SLOWED, a_cur, b_cur, a_initial[0], b_initial[0]);
|
initialize_plane(NEITHER_SLOWED, a_cur, b_cur, a_initial[0], b_initial[0]);
|
||||||
|
@ -1799,7 +1799,7 @@ static void run(unsigned specific_battle)
|
||||||
list_combatant(*stats[i], i+1);
|
list_combatant(*stats[i], i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, nullptr);
|
||||||
// Go through all fights with two attackers (j and k attacking i).
|
// Go through all fights with two attackers (j and k attacking i).
|
||||||
for (i = 0; i < NUM_UNITS; ++i) {
|
for (i = 0; i < NUM_UNITS; ++i) {
|
||||||
for (j = 0; j < NUM_UNITS; ++j) {
|
for (j = 0; j < NUM_UNITS; ++j) {
|
||||||
|
@ -1825,7 +1825,7 @@ static void run(unsigned specific_battle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gettimeofday(&end, NULL);
|
gettimeofday(&end, nullptr);
|
||||||
|
|
||||||
timer_sub(&end, &start, &total);
|
timer_sub(&end, &start, &total);
|
||||||
|
|
||||||
|
@ -1924,7 +1924,7 @@ int main(int argc, char *argv[])
|
||||||
att_stats[i] = parse_unit(&argv);
|
att_stats[i] = parse_unit(&argv);
|
||||||
att[i] = new combatant(*att_stats[i]);
|
att[i] = new combatant(*att_stats[i]);
|
||||||
}
|
}
|
||||||
att[i] = NULL;
|
att[i] = nullptr;
|
||||||
|
|
||||||
for (i = 0; att[i]; ++i) {
|
for (i = 0; att[i]; ++i) {
|
||||||
debug(("Fighting next attacker\n"));
|
debug(("Fighting next attacker\n"));
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct battle_context_unit_stats;
|
||||||
struct combatant
|
struct combatant
|
||||||
{
|
{
|
||||||
/** Construct a combatant. */
|
/** Construct a combatant. */
|
||||||
combatant(const battle_context_unit_stats &u, const combatant *prev = NULL);
|
combatant(const battle_context_unit_stats &u, const combatant *prev = nullptr);
|
||||||
|
|
||||||
/** Copy constructor */
|
/** Copy constructor */
|
||||||
combatant(const combatant &that, const battle_context_unit_stats &u);
|
combatant(const combatant &that, const battle_context_unit_stats &u);
|
||||||
|
|
|
@ -151,7 +151,7 @@ void battle_prediction_pane::get_unit_strings(const battle_context_unit_stats& s
|
||||||
char str_buf[10];
|
char str_buf[10];
|
||||||
|
|
||||||
// With a weapon.
|
// With a weapon.
|
||||||
if(stats.weapon != NULL) {
|
if(stats.weapon != nullptr) {
|
||||||
|
|
||||||
// Set specials context (for safety, it should not have changed normally).
|
// Set specials context (for safety, it should not have changed normally).
|
||||||
const attack_type *weapon = stats.weapon;
|
const attack_type *weapon = stats.weapon;
|
||||||
|
@ -162,7 +162,7 @@ void battle_prediction_pane::get_unit_strings(const battle_context_unit_stats& s
|
||||||
unit_abilities::effect dmg_effect(dmg_specials, weapon->damage(), stats.backstab_pos);
|
unit_abilities::effect dmg_effect(dmg_specials, weapon->damage(), stats.backstab_pos);
|
||||||
|
|
||||||
// Get the SET damage modifier, if any.
|
// Get the SET damage modifier, if any.
|
||||||
const unit_abilities::individual_effect *set_dmg_effect = NULL;
|
const unit_abilities::individual_effect *set_dmg_effect = nullptr;
|
||||||
unit_abilities::effect::const_iterator i;
|
unit_abilities::effect::const_iterator i;
|
||||||
for(i = dmg_effect.begin(); i != dmg_effect.end(); ++i) {
|
for(i = dmg_effect.begin(); i != dmg_effect.end(); ++i) {
|
||||||
if(i->type == unit_abilities::SET) {
|
if(i->type == unit_abilities::SET) {
|
||||||
|
@ -172,7 +172,7 @@ void battle_prediction_pane::get_unit_strings(const battle_context_unit_stats& s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either user the SET modifier or the base weapon damage.
|
// Either user the SET modifier or the base weapon damage.
|
||||||
if(set_dmg_effect == NULL) {
|
if(set_dmg_effect == nullptr) {
|
||||||
left_strings.push_back(weapon->name());
|
left_strings.push_back(weapon->name());
|
||||||
str.str("");
|
str.str("");
|
||||||
str << weapon->damage();
|
str << weapon->damage();
|
||||||
|
@ -534,7 +534,7 @@ attack_prediction_displayer::RESULT attack_prediction_displayer::button_pressed(
|
||||||
std::vector<gui::preview_pane*> preview_panes;
|
std::vector<gui::preview_pane*> preview_panes;
|
||||||
preview_panes.push_back(&battle_pane);
|
preview_panes.push_back(&battle_pane);
|
||||||
|
|
||||||
gui::show_dialog(resources::screen->video(), NULL, _("Damage Calculations"), "", gui::OK_ONLY, NULL, &preview_panes);
|
gui::show_dialog(resources::screen->video(), nullptr, _("Damage Calculations"), "", gui::OK_ONLY, nullptr, &preview_panes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui::CONTINUE_DIALOG;
|
return gui::CONTINUE_DIALOG;
|
||||||
|
|
|
@ -71,7 +71,7 @@ version_table_manager::version_table_manager()
|
||||||
, features()
|
, features()
|
||||||
{
|
{
|
||||||
SDL_version sdl_version;
|
SDL_version sdl_version;
|
||||||
const SDL_version* sdl_rt_version = NULL;
|
const SDL_version* sdl_rt_version = nullptr;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -172,7 +172,7 @@ version_table_manager::version_table_manager()
|
||||||
|
|
||||||
#ifdef HAVE_LIBPNG
|
#ifdef HAVE_LIBPNG
|
||||||
compiled[LIB_PNG] = PNG_LIBPNG_VER_STRING;
|
compiled[LIB_PNG] = PNG_LIBPNG_VER_STRING;
|
||||||
linked[LIB_PNG] = png_get_libpng_ver(NULL);
|
linked[LIB_PNG] = png_get_libpng_ver(nullptr);
|
||||||
names[LIB_PNG] = "libpng";
|
names[LIB_PNG] = "libpng";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ time_t monotonic_clock()
|
||||||
return ts.tv_sec;
|
return ts.tv_sec;
|
||||||
#else
|
#else
|
||||||
#warning monotonic_clock() is not truly monotonic!
|
#warning monotonic_clock() is not truly monotonic!
|
||||||
return time(NULL);
|
return time(nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ void server::fire(const std::string& hook, const std::string& addon)
|
||||||
// We are the child process. Execute the script. We run as a
|
// We are the child process. Execute the script. We run as a
|
||||||
// separate thread sharing stdout/stderr, which will make the
|
// separate thread sharing stdout/stderr, which will make the
|
||||||
// log look ugly.
|
// log look ugly.
|
||||||
execlp(script.c_str(), script.c_str(), addon.c_str(), static_cast<char *>(NULL));
|
execlp(script.c_str(), script.c_str(), addon.c_str(), static_cast<char *>(nullptr));
|
||||||
|
|
||||||
// exec() and family never return; if they do, we have a problem
|
// 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
|
||||||
|
@ -447,7 +447,7 @@ void server::run()
|
||||||
network::connection err_sock = 0;
|
network::connection err_sock = 0;
|
||||||
network::connection const * err_connection = boost::get_error_info<network::connection_info>(e);
|
network::connection const * err_connection = boost::get_error_info<network::connection_info>(e);
|
||||||
|
|
||||||
if(err_connection != NULL) {
|
if(err_connection != nullptr) {
|
||||||
err_sock = *err_connection;
|
err_sock = *err_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ void server::handle_request_campaign_list(const server::request& req)
|
||||||
{
|
{
|
||||||
LOG_CS << "sending campaign list to " << req.addr << " using gzip";
|
LOG_CS << "sending campaign list to " << req.addr << " using gzip";
|
||||||
|
|
||||||
time_t epoch = time(NULL);
|
time_t epoch = time(nullptr);
|
||||||
config campaign_list;
|
config campaign_list;
|
||||||
|
|
||||||
campaign_list["timestamp"] = epoch;
|
campaign_list["timestamp"] = epoch;
|
||||||
|
@ -627,7 +627,7 @@ void server::handle_upload(const server::request& req)
|
||||||
config data = upload.child("data");
|
config data = upload.child("data");
|
||||||
|
|
||||||
const std::string& name = upload["name"];
|
const std::string& name = upload["name"];
|
||||||
config *campaign = NULL;
|
config *campaign = nullptr;
|
||||||
|
|
||||||
bool passed_name_utf8_check = false;
|
bool passed_name_utf8_check = false;
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ void server::handle_upload(const server::request& req)
|
||||||
LOG_CS << "Upload aborted - incorrect passphrase.\n";
|
LOG_CS << "Upload aborted - incorrect passphrase.\n";
|
||||||
send_error("Add-on rejected: The add-on already exists, and your passphrase was incorrect.", req.sock);
|
send_error("Add-on rejected: The add-on already exists, and your passphrase was incorrect.", req.sock);
|
||||||
} else {
|
} else {
|
||||||
const time_t upload_ts = time(NULL);
|
const time_t upload_ts = time(nullptr);
|
||||||
|
|
||||||
LOG_CS << "Upload is owner upload.\n";
|
LOG_CS << "Upload is owner upload.\n";
|
||||||
|
|
||||||
|
@ -721,11 +721,11 @@ void server::handle_upload(const server::request& req)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool existing_upload = campaign != NULL;
|
const bool existing_upload = campaign != nullptr;
|
||||||
|
|
||||||
std::string message = "Add-on accepted.";
|
std::string message = "Add-on accepted.";
|
||||||
|
|
||||||
if(campaign == NULL) {
|
if(campaign == nullptr) {
|
||||||
campaign = &campaigns().add_child("campaign");
|
campaign = &campaigns().add_child("campaign");
|
||||||
(*campaign)["original_timestamp"] = upload_ts;
|
(*campaign)["original_timestamp"] = upload_ts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ carryover* carryover_info::get_side(std::string save_id){
|
||||||
return &side;
|
return &side;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ t_string config::attribute_value::t_str() const
|
||||||
*/
|
*/
|
||||||
bool config::attribute_value::blank() const
|
bool config::attribute_value::blank() const
|
||||||
{
|
{
|
||||||
return boost::get<const boost::blank>(&value_) != NULL;
|
return boost::get<const boost::blank>(&value_) != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -881,7 +881,7 @@ const config::attribute_value *config::get(const std::string &key) const
|
||||||
{
|
{
|
||||||
check_valid();
|
check_valid();
|
||||||
attribute_map::const_iterator i = values.find(key);
|
attribute_map::const_iterator i = values.find(key);
|
||||||
return i != values.end() ? &i->second : NULL;
|
return i != values.end() ? &i->second : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
config::attribute_value &config::operator[](const std::string &key)
|
config::attribute_value &config::operator[](const std::string &key)
|
||||||
|
@ -985,7 +985,7 @@ namespace {
|
||||||
struct config_clear_state
|
struct config_clear_state
|
||||||
{
|
{
|
||||||
config_clear_state()
|
config_clear_state()
|
||||||
: c(NULL)
|
: c(nullptr)
|
||||||
, mi()
|
, mi()
|
||||||
, vi(0)
|
, vi(0)
|
||||||
{
|
{
|
||||||
|
@ -1090,14 +1090,14 @@ void config::get_diff(const config& c, config& res) const
|
||||||
check_valid(c);
|
check_valid(c);
|
||||||
check_valid(res);
|
check_valid(res);
|
||||||
|
|
||||||
config* inserts = NULL;
|
config* inserts = nullptr;
|
||||||
|
|
||||||
attribute_map::const_iterator i;
|
attribute_map::const_iterator i;
|
||||||
for(i = values.begin(); i != values.end(); ++i) {
|
for(i = values.begin(); i != values.end(); ++i) {
|
||||||
if(i->second.blank()) continue;
|
if(i->second.blank()) continue;
|
||||||
const attribute_map::const_iterator j = c.values.find(i->first);
|
const attribute_map::const_iterator j = c.values.find(i->first);
|
||||||
if(j == c.values.end() || (i->second != j->second && !i->second.blank() )) {
|
if(j == c.values.end() || (i->second != j->second && !i->second.blank() )) {
|
||||||
if(inserts == NULL) {
|
if(inserts == nullptr) {
|
||||||
inserts = &res.add_child("insert");
|
inserts = &res.add_child("insert");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1105,13 +1105,13 @@ void config::get_diff(const config& c, config& res) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config* deletes = NULL;
|
config* deletes = nullptr;
|
||||||
|
|
||||||
for(i = c.values.begin(); i != c.values.end(); ++i) {
|
for(i = c.values.begin(); i != c.values.end(); ++i) {
|
||||||
if(i->second.blank()) continue;
|
if(i->second.blank()) continue;
|
||||||
const attribute_map::const_iterator itor = values.find(i->first);
|
const attribute_map::const_iterator itor = values.find(i->first);
|
||||||
if(itor == values.end() || itor->second.blank()) {
|
if(itor == values.end() || itor->second.blank()) {
|
||||||
if(deletes == NULL) {
|
if(deletes == nullptr) {
|
||||||
deletes = &res.add_child("delete");
|
deletes = &res.add_child("delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the attribute with the given @a key
|
* Returns a pointer to the attribute with the given @a key
|
||||||
* or NULL if it does not exist.
|
* or nullptr if it does not exist.
|
||||||
*/
|
*/
|
||||||
const attribute_value *get(const std::string &key) const;
|
const attribute_value *get(const std::string &key) const;
|
||||||
|
|
||||||
|
|
|
@ -48,13 +48,13 @@ const int dialog::message_font_size = font::SIZE_PLUS;
|
||||||
const int dialog::caption_font_size = font::SIZE_LARGE;
|
const int dialog::caption_font_size = font::SIZE_LARGE;
|
||||||
const size_t dialog::left_padding = font::relative_size(10);
|
const size_t dialog::left_padding = font::relative_size(10);
|
||||||
const size_t dialog::right_padding = font::relative_size(10);
|
const size_t dialog::right_padding = font::relative_size(10);
|
||||||
const size_t dialog::image_h_pad = font::relative_size(/*image_ == NULL ? 0 :*/ 10);
|
const size_t dialog::image_h_pad = font::relative_size(/*image_ == nullptr ? 0 :*/ 10);
|
||||||
const size_t dialog::top_padding = font::relative_size(10);
|
const size_t dialog::top_padding = font::relative_size(10);
|
||||||
const size_t dialog::bottom_padding = font::relative_size(10);
|
const size_t dialog::bottom_padding = font::relative_size(10);
|
||||||
|
|
||||||
const int dialog::max_menu_width = -1;
|
const int dialog::max_menu_width = -1;
|
||||||
|
|
||||||
menu * dialog::empty_menu = NULL;
|
menu * dialog::empty_menu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -97,11 +97,11 @@ dialog::dimension_measurements::dimension_measurements() :
|
||||||
dialog::dialog(CVideo& video, const std::string& title, const std::string& message,
|
dialog::dialog(CVideo& video, const std::string& title, const std::string& message,
|
||||||
const DIALOG_TYPE type, const style& dialog_style) :
|
const DIALOG_TYPE type, const style& dialog_style) :
|
||||||
video_(video),
|
video_(video),
|
||||||
image_(NULL),
|
image_(nullptr),
|
||||||
title_(title),
|
title_(title),
|
||||||
style_(dialog_style),
|
style_(dialog_style),
|
||||||
title_widget_(NULL),
|
title_widget_(nullptr),
|
||||||
message_(NULL),
|
message_(nullptr),
|
||||||
type_(type),
|
type_(type),
|
||||||
menu_(get_empty_menu(video)),
|
menu_(get_empty_menu(video)),
|
||||||
preview_panes_(),
|
preview_panes_(),
|
||||||
|
@ -111,9 +111,9 @@ dialog::dialog(CVideo& video, const std::string& title, const std::string& messa
|
||||||
top_buttons_(),
|
top_buttons_(),
|
||||||
frame_buttons_(),
|
frame_buttons_(),
|
||||||
topic_(),
|
topic_(),
|
||||||
help_button_(NULL),
|
help_button_(nullptr),
|
||||||
text_widget_(NULL),
|
text_widget_(nullptr),
|
||||||
frame_(NULL),
|
frame_(nullptr),
|
||||||
dim_(),
|
dim_(),
|
||||||
result_(CONTINUE_DIALOG)
|
result_(CONTINUE_DIALOG)
|
||||||
{
|
{
|
||||||
|
@ -270,8 +270,8 @@ void dialog::set_menu_items(const std::vector<std::string> &menu_items, bool kee
|
||||||
*/
|
*/
|
||||||
menu * dialog::get_empty_menu(CVideo& video)
|
menu * dialog::get_empty_menu(CVideo& video)
|
||||||
{
|
{
|
||||||
if ( empty_menu == NULL ) {
|
if ( empty_menu == nullptr ) {
|
||||||
empty_menu = new gui::menu(video, empty_string_vector, false, -1, -1, NULL, &menu::simple_style);
|
empty_menu = new gui::menu(video, empty_string_vector, false, -1, -1, nullptr, &menu::simple_style);
|
||||||
empty_menu->leave();
|
empty_menu->leave();
|
||||||
}
|
}
|
||||||
return empty_menu;
|
return empty_menu;
|
||||||
|
@ -369,7 +369,7 @@ void dialog::draw_contents()
|
||||||
|
|
||||||
dialog_frame& dialog::get_frame()
|
dialog_frame& dialog::get_frame()
|
||||||
{
|
{
|
||||||
if(frame_ == NULL) {
|
if(frame_ == nullptr) {
|
||||||
frame_buttons_.clear();
|
frame_buttons_.clear();
|
||||||
for(button_iterator b = standard_buttons_.begin(); b != standard_buttons_.end(); ++b)
|
for(button_iterator b = standard_buttons_.begin(); b != standard_buttons_.end(); ++b)
|
||||||
{
|
{
|
||||||
|
@ -382,7 +382,7 @@ dialog_frame& dialog::get_frame()
|
||||||
|
|
||||||
void dialog::clear_background() {
|
void dialog::clear_background() {
|
||||||
delete frame_;
|
delete frame_;
|
||||||
frame_ = NULL;
|
frame_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dialog::draw_frame()
|
void dialog::draw_frame()
|
||||||
|
@ -411,7 +411,7 @@ void dialog::update_widget_positions()
|
||||||
if(get_menu().height() > 0) {
|
if(get_menu().height() > 0) {
|
||||||
menu_->leave();
|
menu_->leave();
|
||||||
menu_->join();
|
menu_->join();
|
||||||
menu_->set_numeric_keypress_selection(text_widget_ == NULL);
|
menu_->set_numeric_keypress_selection(text_widget_ == nullptr);
|
||||||
menu_->set_width( dim_.menu_width );
|
menu_->set_width( dim_.menu_width );
|
||||||
menu_->set_max_width( dim_.menu_width ); //lock the menu width
|
menu_->set_max_width( dim_.menu_width ); //lock the menu width
|
||||||
if(dim_.menu_height >= 0) {
|
if(dim_.menu_height >= 0) {
|
||||||
|
@ -471,7 +471,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
|
||||||
dim.x = xloc;
|
dim.x = xloc;
|
||||||
dim.y = yloc;
|
dim.y = yloc;
|
||||||
|
|
||||||
const bool use_textbox = (text_widget_ != NULL);
|
const bool use_textbox = (text_widget_ != nullptr);
|
||||||
int text_widget_width = 0;
|
int text_widget_width = 0;
|
||||||
int text_widget_height = 0;
|
int text_widget_height = 0;
|
||||||
if(use_textbox) {
|
if(use_textbox) {
|
||||||
|
@ -479,7 +479,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
|
||||||
dim.textbox.w = std::min<size_t>(screen.getx()/2,std::max<size_t>(area.w,text_widget_->width()));
|
dim.textbox.w = std::min<size_t>(screen.getx()/2,std::max<size_t>(area.w,text_widget_->width()));
|
||||||
dim.textbox.h = std::min<size_t>(screen.gety()/2,std::max<size_t>(area.h,text_widget_->height()));
|
dim.textbox.h = std::min<size_t>(screen.gety()/2,std::max<size_t>(area.h,text_widget_->height()));
|
||||||
text_widget_width = dim.textbox.w;
|
text_widget_width = dim.textbox.w;
|
||||||
text_widget_width += (text_widget_->get_label() == NULL) ? 0 : text_widget_->get_label()->width();
|
text_widget_width += (text_widget_->get_label() == nullptr) ? 0 : text_widget_->get_label()->width();
|
||||||
text_widget_height = dim.textbox.h + message_font_size;
|
text_widget_height = dim.textbox.h + message_font_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
|
||||||
}
|
}
|
||||||
unsigned int caption_width = 0;
|
unsigned int caption_width = 0;
|
||||||
unsigned int caption_height = 0;
|
unsigned int caption_height = 0;
|
||||||
if (image_ != NULL && image_->caption() != NULL) {
|
if (image_ != nullptr && image_->caption() != nullptr) {
|
||||||
caption_width = image_->caption()->width();
|
caption_width = image_->caption()->width();
|
||||||
caption_height = image_->caption()->height();
|
caption_height = image_->caption()->height();
|
||||||
}
|
}
|
||||||
|
@ -547,11 +547,11 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
|
||||||
}
|
}
|
||||||
|
|
||||||
const int menu_hpadding = font::relative_size((dim.message.h > 0 && use_menu) ? 10 : 0);
|
const int menu_hpadding = font::relative_size((dim.message.h > 0 && use_menu) ? 10 : 0);
|
||||||
const size_t image_h_padding = (image_ == NULL)? 0 : image_h_pad;
|
const size_t image_h_padding = (image_ == nullptr)? 0 : image_h_pad;
|
||||||
const size_t padding_width = left_padding + right_padding + image_h_padding;
|
const size_t padding_width = left_padding + right_padding + image_h_padding;
|
||||||
const size_t padding_height = top_padding + bottom_padding + menu_hpadding;
|
const size_t padding_height = top_padding + bottom_padding + menu_hpadding;
|
||||||
const size_t image_width = (image_ == NULL) ? 0 : image_->width();
|
const size_t image_width = (image_ == nullptr) ? 0 : image_->width();
|
||||||
const size_t image_height = (image_ == NULL) ? 0 : image_->height();
|
const size_t image_height = (image_ == nullptr) ? 0 : image_->height();
|
||||||
const size_t total_text_height = dim.message.h + caption_height;
|
const size_t total_text_height = dim.message.h + caption_height;
|
||||||
|
|
||||||
size_t text_width = dim.message.w;
|
size_t text_width = dim.message.w;
|
||||||
|
@ -702,7 +702,7 @@ dialog::dimension_measurements dialog::layout(int xloc, int yloc)
|
||||||
dim.message.x = dim.x + left_padding;
|
dim.message.x = dim.x + left_padding;
|
||||||
dim.message.y = dim.y + top_padding + caption_height;
|
dim.message.y = dim.y + top_padding + caption_height;
|
||||||
|
|
||||||
if(image_ != NULL) {
|
if(image_ != nullptr) {
|
||||||
const int x = dim.x + left_padding;
|
const int x = dim.x + left_padding;
|
||||||
const int y = dim.y + top_padding;
|
const int y = dim.y + top_padding;
|
||||||
dim.message.x += image_width + image_h_padding;
|
dim.message.x += image_width + image_h_padding;
|
||||||
|
@ -764,7 +764,7 @@ int dialog::process(dialog_process_info &info)
|
||||||
info.key[SDLK_ESCAPE] || info.key[SDLK_KP_ENTER];
|
info.key[SDLK_ESCAPE] || info.key[SDLK_KP_ENTER];
|
||||||
info.double_clicked = menu_->double_clicked();
|
info.double_clicked = menu_->double_clicked();
|
||||||
const bool use_menu = (menu_ != empty_menu);
|
const bool use_menu = (menu_ != empty_menu);
|
||||||
const bool use_text_input = (text_widget_!=NULL);
|
const bool use_text_input = (text_widget_!=nullptr);
|
||||||
const bool has_input = (use_menu||use_text_input);//input of any sort has to be made
|
const bool has_input = (use_menu||use_text_input);//input of any sort has to be made
|
||||||
|
|
||||||
if((((!info.key_down && (info.key[SDLK_RETURN] || info.key[SDLK_KP_ENTER])) || info.double_clicked) &&
|
if((((!info.key_down && (info.key[SDLK_RETURN] || info.key[SDLK_KP_ENTER])) || info.double_clicked) &&
|
||||||
|
@ -851,7 +851,7 @@ int dialog::process(dialog_process_info &info)
|
||||||
}
|
}
|
||||||
|
|
||||||
int dialog_button::action(dialog_process_info &info) {
|
int dialog_button::action(dialog_process_info &info) {
|
||||||
if(handler_ != NULL) {
|
if(handler_ != nullptr) {
|
||||||
menu &menu_ref = parent_->get_menu();
|
menu &menu_ref = parent_->get_menu();
|
||||||
dialog_button_action::RESULT res = handler_->button_pressed(menu_ref.selection());
|
dialog_button_action::RESULT res = handler_->button_pressed(menu_ref.selection());
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ int standard_dialog_button::action(dialog_process_info &/*info*/) {
|
||||||
|
|
||||||
void dialog::set_image(surface surf, const std::string &caption)
|
void dialog::set_image(surface surf, const std::string &caption)
|
||||||
{
|
{
|
||||||
label *label_ptr = NULL;
|
label *label_ptr = nullptr;
|
||||||
if(!caption.empty()) {
|
if(!caption.empty()) {
|
||||||
label_ptr = new label(video_, caption, caption_font_size, font::NORMAL_COLOR, false);
|
label_ptr = new label(video_, caption, caption_font_size, font::NORMAL_COLOR, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,9 +151,9 @@ private:
|
||||||
class dialog_button : public button {
|
class dialog_button : public button {
|
||||||
public:
|
public:
|
||||||
dialog_button(CVideo& video, const std::string& label, TYPE type=TYPE_PRESS,
|
dialog_button(CVideo& video, const std::string& label, TYPE type=TYPE_PRESS,
|
||||||
int simple_result=CONTINUE_DIALOG, dialog_button_action *handler=NULL)
|
int simple_result=CONTINUE_DIALOG, dialog_button_action *handler=nullptr)
|
||||||
: button(video,label,type,"",DEFAULT_SPACE,false), simple_result_(simple_result),
|
: button(video,label,type,"",DEFAULT_SPACE,false), simple_result_(simple_result),
|
||||||
parent_(NULL), handler_(handler)
|
parent_(nullptr), handler_(handler)
|
||||||
{}
|
{}
|
||||||
void set_parent(class dialog *parent) {
|
void set_parent(class dialog *parent) {
|
||||||
parent_ = parent;
|
parent_ = parent;
|
||||||
|
@ -237,8 +237,8 @@ public:
|
||||||
void set_image(dialog_image *const img) { delete image_; image_ = img; }
|
void set_image(dialog_image *const img) { delete image_; image_ = img; }
|
||||||
void set_image(surface surf, const std::string &caption="");
|
void set_image(surface surf, const std::string &caption="");
|
||||||
void set_menu(menu *const m) { if ( menu_ != empty_menu ) delete menu_;
|
void set_menu(menu *const m) { if ( menu_ != empty_menu ) delete menu_;
|
||||||
menu_ = m == NULL ? empty_menu : m; }
|
menu_ = m == nullptr ? empty_menu : m; }
|
||||||
void set_menu(const std::vector<std::string> & menu_items, menu::sorter* sorter=NULL);
|
void set_menu(const std::vector<std::string> & menu_items, menu::sorter* sorter=nullptr);
|
||||||
void set_menu_items(const std::vector<std::string> &menu_items, bool keep_selection=false);
|
void set_menu_items(const std::vector<std::string> &menu_items, bool keep_selection=false);
|
||||||
|
|
||||||
//add_pane - preview panes are not currently memory managed
|
//add_pane - preview panes are not currently memory managed
|
||||||
|
@ -283,7 +283,7 @@ public:
|
||||||
/// Must not be called if any instances of this class exist.
|
/// Must not be called if any instances of this class exist.
|
||||||
/// Should be called if the display goes out of scope.
|
/// Should be called if the display goes out of scope.
|
||||||
/// (Currently called by ~game_launcher.)
|
/// (Currently called by ~game_launcher.)
|
||||||
static void delete_empty_menu() { delete empty_menu; empty_menu = NULL; }
|
static void delete_empty_menu() { delete empty_menu; empty_menu = nullptr; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void set_result(const int result) { result_ = result; }
|
void set_result(const int result) { result_ = result; }
|
||||||
|
@ -304,7 +304,7 @@ private:
|
||||||
//process - execute a single dialog processing loop and return the result
|
//process - execute a single dialog processing loop and return the result
|
||||||
int process(dialog_process_info &info);
|
int process(dialog_process_info &info);
|
||||||
|
|
||||||
/// A pointer to this empty menu is used instead of NULL (for menu_).
|
/// A pointer to this empty menu is used instead of nullptr (for menu_).
|
||||||
static menu * empty_menu;
|
static menu * empty_menu;
|
||||||
/// Provides create-on-use semantics for empty_menu.
|
/// Provides create-on-use semantics for empty_menu.
|
||||||
static menu * get_empty_menu(CVideo& video);
|
static menu * get_empty_menu(CVideo& video);
|
||||||
|
@ -316,7 +316,7 @@ private:
|
||||||
const style& style_;
|
const style& style_;
|
||||||
label *title_widget_, *message_;
|
label *title_widget_, *message_;
|
||||||
DIALOG_TYPE type_;
|
DIALOG_TYPE type_;
|
||||||
gui::menu *menu_; // Never NULL; it equals empty_menu if there is currently no menu.
|
gui::menu *menu_; // Never nullptr; it equals empty_menu if there is currently no menu.
|
||||||
std::vector<preview_pane*> preview_panes_;
|
std::vector<preview_pane*> preview_panes_;
|
||||||
std::vector< std::pair<dialog_button*,BUTTON_LOCATION> > button_pool_;
|
std::vector< std::pair<dialog_button*,BUTTON_LOCATION> > button_pool_;
|
||||||
std::vector<dialog_button*> standard_buttons_;
|
std::vector<dialog_button*> standard_buttons_;
|
||||||
|
|
|
@ -211,14 +211,14 @@ void controller_base::play_slice(bool is_delay_enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
const theme::menu* const m = get_display().menu_pressed();
|
const theme::menu* const m = get_display().menu_pressed();
|
||||||
if(m != NULL) {
|
if(m != nullptr) {
|
||||||
const SDL_Rect& menu_loc = m->location(get_display().screen_area());
|
const SDL_Rect& menu_loc = m->location(get_display().screen_area());
|
||||||
show_menu(m->items(),menu_loc.x+1,menu_loc.y + menu_loc.h + 1,false, get_display());
|
show_menu(m->items(),menu_loc.x+1,menu_loc.y + menu_loc.h + 1,false, get_display());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const theme::action* const a = get_display().action_pressed();
|
const theme::action* const a = get_display().action_pressed();
|
||||||
if(a != NULL) {
|
if(a != nullptr) {
|
||||||
const SDL_Rect& action_loc = a->location(get_display().screen_area());
|
const SDL_Rect& action_loc = a->location(get_display().screen_area());
|
||||||
execute_action(a->items(), action_loc.x+1, action_loc.y + action_loc.h + 1,false);
|
execute_action(a->items(), action_loc.x+1, action_loc.y + action_loc.h + 1,false);
|
||||||
|
|
||||||
|
|
|
@ -79,17 +79,17 @@ protected:
|
||||||
/**
|
/**
|
||||||
* Get (optionally) a soundsources manager a derived class uses
|
* Get (optionally) a soundsources manager a derived class uses
|
||||||
*/
|
*/
|
||||||
virtual soundsource::manager * get_soundsource_man() { return NULL; }
|
virtual soundsource::manager * get_soundsource_man() { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get (optionally) a plugins context a derived class uses
|
* Get (optionally) a plugins context a derived class uses
|
||||||
*/
|
*/
|
||||||
virtual plugins_context * get_plugins_context() { return NULL; }
|
virtual plugins_context * get_plugins_context() { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get (optionally) a command executor to handle context menu events
|
* Get (optionally) a command executor to handle context menu events
|
||||||
*/
|
*/
|
||||||
virtual hotkey::command_executor * get_hotkey_command_executor() { return NULL; }
|
virtual hotkey::command_executor * get_hotkey_command_executor() { return nullptr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derived classes should override this to return false when arrow keys
|
* Derived classes should override this to return false when arrow keys
|
||||||
|
|
|
@ -37,8 +37,8 @@ static bool use_color_cursors()
|
||||||
static SDL_Cursor* create_cursor(surface surf)
|
static SDL_Cursor* create_cursor(surface surf)
|
||||||
{
|
{
|
||||||
const surface nsurf(make_neutral_surface(surf));
|
const surface nsurf(make_neutral_surface(surf));
|
||||||
if(nsurf == NULL) {
|
if(nsurf == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The width must be a multiple of 8 (SDL requirement)
|
// The width must be a multiple of 8 (SDL requirement)
|
||||||
|
@ -82,7 +82,7 @@ static SDL_Cursor* create_cursor(surface surf)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
SDL_Cursor* cache[cursor::NUM_CURSORS] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
|
||||||
tribool cache_color[cursor::NUM_CURSORS] = {
|
tribool cache_color[cursor::NUM_CURSORS] = {
|
||||||
indeterminate, indeterminate, indeterminate, indeterminate,
|
indeterminate, indeterminate, indeterminate, indeterminate,
|
||||||
indeterminate, indeterminate, indeterminate, indeterminate,
|
indeterminate, indeterminate, indeterminate, indeterminate,
|
||||||
|
@ -112,7 +112,7 @@ bool have_focus = true;
|
||||||
static SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
static SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
||||||
{
|
{
|
||||||
bool is_color = use_color_cursors();
|
bool is_color = use_color_cursors();
|
||||||
if(cache[type] == NULL || indeterminate(cache_color[type]) || cache_color[type] != is_color) {
|
if(cache[type] == nullptr || indeterminate(cache_color[type]) || cache_color[type] != is_color) {
|
||||||
const std::string prefix = is_color ? "cursors/" : "cursors-bw/";
|
const std::string prefix = is_color ? "cursors/" : "cursors-bw/";
|
||||||
const surface surf(image::get_image(prefix + (is_color ? color_images : bw_images)[type]));
|
const surface surf(image::get_image(prefix + (is_color ? color_images : bw_images)[type]));
|
||||||
if (is_color) {
|
if (is_color) {
|
||||||
|
@ -129,9 +129,9 @@ static SDL_Cursor* get_cursor(cursor::CURSOR_TYPE type)
|
||||||
static void clear_cache()
|
static void clear_cache()
|
||||||
{
|
{
|
||||||
for(size_t n = 0; n != cursor::NUM_CURSORS; ++n) {
|
for(size_t n = 0; n != cursor::NUM_CURSORS; ++n) {
|
||||||
if(cache[n] != NULL) {
|
if(cache[n] != nullptr) {
|
||||||
SDL_FreeCursor(cache[n]);
|
SDL_FreeCursor(cache[n]);
|
||||||
cache[n] = NULL;
|
cache[n] = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ void set(CURSOR_TYPE type)
|
||||||
SDL_Cursor * cursor_image = get_cursor(current_cursor);
|
SDL_Cursor * cursor_image = get_cursor(current_cursor);
|
||||||
|
|
||||||
// Causes problem on Mac:
|
// Causes problem on Mac:
|
||||||
//if (cursor_image != NULL && cursor_image != SDL_GetCursor())
|
//if (cursor_image != nullptr && cursor_image != SDL_GetCursor())
|
||||||
SDL_SetCursor(cursor_image);
|
SDL_SetCursor(cursor_image);
|
||||||
|
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
|
|
@ -88,7 +88,7 @@ DBusHandlerResult filter_dbus_signal(DBusConnection *, DBusMessage *buf, void *)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
dbus_message_get_args(buf, NULL,
|
dbus_message_get_args(buf, nullptr,
|
||||||
DBUS_TYPE_UINT32, &id,
|
DBUS_TYPE_UINT32, &id,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ DBusHandlerResult filter_dbus_signal(DBusConnection *, DBusMessage *buf, void *)
|
||||||
DBusConnection *get_dbus_connection()
|
DBusConnection *get_dbus_connection()
|
||||||
{
|
{
|
||||||
static bool initted = false;
|
static bool initted = false;
|
||||||
static DBusConnection *connection = NULL;
|
static DBusConnection *connection = nullptr;
|
||||||
|
|
||||||
if (!initted)
|
if (!initted)
|
||||||
{
|
{
|
||||||
|
@ -116,9 +116,9 @@ DBusConnection *get_dbus_connection()
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
ERR_DU << "Failed to open DBus session: " << err.message << '\n';
|
ERR_DU << "Failed to open DBus session: " << err.message << '\n';
|
||||||
dbus_error_free(&err);
|
dbus_error_free(&err);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
dbus_connection_add_filter(connection, filter_dbus_signal, NULL, NULL);
|
dbus_connection_add_filter(connection, filter_dbus_signal, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
if (connection) {
|
if (connection) {
|
||||||
dbus_connection_read_write(connection, 0);
|
dbus_connection_read_write(connection, 0);
|
||||||
|
@ -159,7 +159,7 @@ uint32_t send_dbus_notification(DBusConnection *connection, uint32_t replaces_id
|
||||||
const char *app_icon = app_icon_.c_str();
|
const char *app_icon = app_icon_.c_str();
|
||||||
const char *summary = owner.c_str();
|
const char *summary = owner.c_str();
|
||||||
const char *body = message.c_str();
|
const char *body = message.c_str();
|
||||||
const char **actions = NULL;
|
const char **actions = nullptr;
|
||||||
dbus_message_append_args(buf,
|
dbus_message_append_args(buf,
|
||||||
DBUS_TYPE_STRING, &app_icon,
|
DBUS_TYPE_STRING, &app_icon,
|
||||||
DBUS_TYPE_STRING, &summary,
|
DBUS_TYPE_STRING, &summary,
|
||||||
|
@ -189,7 +189,7 @@ uint32_t send_dbus_notification(DBusConnection *connection, uint32_t replaces_id
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
dbus_message_get_args(ret, NULL,
|
dbus_message_get_args(ret, nullptr,
|
||||||
DBUS_TYPE_UINT32, &id,
|
DBUS_TYPE_UINT32, &id,
|
||||||
DBUS_TYPE_INVALID);
|
DBUS_TYPE_INVALID);
|
||||||
dbus_message_unref(ret);
|
dbus_message_unref(ret);
|
||||||
|
|
|
@ -71,7 +71,7 @@ bool open_object(const std::string& path_or_url)
|
||||||
ERR_DU << "open_object(): fork() failed" << std::endl;
|
ERR_DU << "open_object(): fork() failed" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
} else if(child == 0) {
|
} else if(child == 0) {
|
||||||
execlp(launcher, launcher, path_or_url.c_str(), reinterpret_cast<char*>(NULL));
|
execlp(launcher, launcher, path_or_url.c_str(), nullptr);
|
||||||
_exit(1); // This shouldn't happen.
|
_exit(1); // This shouldn't happen.
|
||||||
} else if(waitpid(child, &child_status, 0) == -1) {
|
} else if(waitpid(child, &child_status, 0) == -1) {
|
||||||
ERR_DU << "open_object(): waitpid() failed" << std::endl;
|
ERR_DU << "open_object(): waitpid() failed" << std::endl;
|
||||||
|
@ -97,7 +97,7 @@ bool open_object(const std::string& path_or_url)
|
||||||
|
|
||||||
std::wstring u16path = unicode_cast<std::wstring>(path_or_url);
|
std::wstring u16path = unicode_cast<std::wstring>(path_or_url);
|
||||||
|
|
||||||
const ptrdiff_t res = reinterpret_cast<ptrdiff_t>(ShellExecute(NULL, L"open", u16path.c_str(), NULL, NULL, SW_SHOW));
|
const ptrdiff_t res = reinterpret_cast<ptrdiff_t>(ShellExecute(nullptr, L"open", u16path.c_str(), nullptr, nullptr, SW_SHOW));
|
||||||
if(res <= 32) {
|
if(res <= 32) {
|
||||||
ERR_DU << "open_object(): ShellExecute() failed (" << res << ")" << std::endl;
|
ERR_DU << "open_object(): ShellExecute() failed (" << res << ")" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -67,7 +67,7 @@ bool on_wine()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetProcAddress(ntdll, "wine_get_version") != NULL;
|
return GetProcAddress(ntdll, "wine_get_version") != nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ bool on_wine()
|
||||||
*/
|
*/
|
||||||
struct posix_pipe_release_policy
|
struct posix_pipe_release_policy
|
||||||
{
|
{
|
||||||
void operator()(std::FILE* f) const { if(f != NULL) { pclose(f); } }
|
void operator()(std::FILE* f) const { if(f != nullptr) { pclose(f); } }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,19 +22,19 @@
|
||||||
|
|
||||||
#include "video.hpp" // CVideo class holds the twindow -> SDL_Window object which contains the handle of the main window
|
#include "video.hpp" // CVideo class holds the twindow -> SDL_Window object which contains the handle of the main window
|
||||||
|
|
||||||
NOTIFYICONDATA* windows_tray_notification::nid = NULL;
|
NOTIFYICONDATA* windows_tray_notification::nid = nullptr;
|
||||||
bool windows_tray_notification::message_reset = false;
|
bool windows_tray_notification::message_reset = false;
|
||||||
|
|
||||||
void windows_tray_notification::destroy_tray_icon()
|
void windows_tray_notification::destroy_tray_icon()
|
||||||
{
|
{
|
||||||
if (nid == NULL) {
|
if (nid == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message_reset){
|
if (!message_reset){
|
||||||
Shell_NotifyIcon(NIM_DELETE, nid);
|
Shell_NotifyIcon(NIM_DELETE, nid);
|
||||||
delete nid;
|
delete nid;
|
||||||
nid = NULL;
|
nid = nullptr;
|
||||||
} else {
|
} else {
|
||||||
message_reset = false;
|
message_reset = false;
|
||||||
}
|
}
|
||||||
|
@ -72,23 +72,23 @@ void windows_tray_notification::handle_system_event(const SDL_Event& event)
|
||||||
bool windows_tray_notification::create_tray_icon()
|
bool windows_tray_notification::create_tray_icon()
|
||||||
{
|
{
|
||||||
// getting handle to a 32x32 icon, contained in "WESNOTH_ICON" icon group of wesnoth.exe resources
|
// getting handle to a 32x32 icon, contained in "WESNOTH_ICON" icon group of wesnoth.exe resources
|
||||||
const HMODULE wesnoth_exe = GetModuleHandle(NULL);
|
const HMODULE wesnoth_exe = GetModuleHandle(nullptr);
|
||||||
if (wesnoth_exe == NULL) {
|
if (wesnoth_exe == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HRSRC group_icon_info = FindResource(wesnoth_exe, TEXT("WESNOTH_ICON"), RT_GROUP_ICON);
|
const HRSRC group_icon_info = FindResource(wesnoth_exe, TEXT("WESNOTH_ICON"), RT_GROUP_ICON);
|
||||||
if (group_icon_info == NULL) {
|
if (group_icon_info == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGLOBAL hGlobal = LoadResource(wesnoth_exe, group_icon_info);
|
HGLOBAL hGlobal = LoadResource(wesnoth_exe, group_icon_info);
|
||||||
if (hGlobal == NULL) {
|
if (hGlobal == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PBYTE group_icon_res = static_cast<PBYTE>(LockResource(hGlobal));
|
const PBYTE group_icon_res = static_cast<PBYTE>(LockResource(hGlobal));
|
||||||
if (group_icon_res == NULL) {
|
if (group_icon_res == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,27 +98,27 @@ bool windows_tray_notification::create_tray_icon()
|
||||||
}
|
}
|
||||||
|
|
||||||
const HRSRC icon_info = FindResource(wesnoth_exe, MAKEINTRESOURCE(nID), MAKEINTRESOURCE(3));
|
const HRSRC icon_info = FindResource(wesnoth_exe, MAKEINTRESOURCE(nID), MAKEINTRESOURCE(3));
|
||||||
if (icon_info == NULL) {
|
if (icon_info == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
hGlobal = LoadResource(wesnoth_exe, icon_info);
|
hGlobal = LoadResource(wesnoth_exe, icon_info);
|
||||||
if (hGlobal == NULL) {
|
if (hGlobal == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PBYTE icon_res = static_cast<PBYTE>(LockResource(hGlobal));
|
const PBYTE icon_res = static_cast<PBYTE>(LockResource(hGlobal));
|
||||||
if (icon_res == NULL) {
|
if (icon_res == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HICON icon = CreateIconFromResource(icon_res, SizeofResource(wesnoth_exe, icon_info), TRUE, 0x00030000);
|
const HICON icon = CreateIconFromResource(icon_res, SizeofResource(wesnoth_exe, icon_info), TRUE, 0x00030000);
|
||||||
if (icon == NULL) {
|
if (icon == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HWND window = get_window_handle();
|
const HWND window = get_window_handle();
|
||||||
if (window == NULL) {
|
if (window == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ HWND windows_tray_notification::get_window_handle()
|
||||||
sdl::twindow* window = CVideo::get_singleton().get_window();
|
sdl::twindow* window = CVideo::get_singleton().get_window();
|
||||||
// SDL 1.2 keeps track of window handles internally whereas SDL 2.0 allows the caller control over which window to use
|
// SDL 1.2 keeps track of window handles internally whereas SDL 2.0 allows the caller control over which window to use
|
||||||
if (!window || SDL_GetWindowWMInfo (static_cast<SDL_Window *> (*window), &wmInfo) != SDL_TRUE) {
|
if (!window || SDL_GetWindowWMInfo (static_cast<SDL_Window *> (*window), &wmInfo) != SDL_TRUE) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wmInfo.info.win.window;
|
return wmInfo.info.win.window;
|
||||||
|
@ -186,7 +186,7 @@ HWND windows_tray_notification::get_window_handle()
|
||||||
void windows_tray_notification::switch_to_wesnoth_window()
|
void windows_tray_notification::switch_to_wesnoth_window()
|
||||||
{
|
{
|
||||||
const HWND window = get_window_handle();
|
const HWND window = get_window_handle();
|
||||||
if (window == NULL) {
|
if (window == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,11 +212,11 @@ bool windows_tray_notification::show(std::string title, std::string message)
|
||||||
{
|
{
|
||||||
adjust_length(title, message);
|
adjust_length(title, message);
|
||||||
|
|
||||||
const bool tray_icon_exist = nid != NULL;
|
const bool tray_icon_exist = nid != nullptr;
|
||||||
if (!tray_icon_exist) {
|
if (!tray_icon_exist) {
|
||||||
const bool tray_icon_created = create_tray_icon();
|
const bool tray_icon_created = create_tray_icon();
|
||||||
if (!tray_icon_created) {
|
if (!tray_icon_created) {
|
||||||
const bool memory_allocated = nid != NULL;
|
const bool memory_allocated = nid != nullptr;
|
||||||
if (memory_allocated) {
|
if (memory_allocated) {
|
||||||
destroy_tray_icon();
|
destroy_tray_icon();
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ void show_objectives(const std::string &scenarioname, const std::string &objecti
|
||||||
int recruit_dialog(display& disp, std::vector< const unit_type* >& units, const std::vector< std::string >& items, int side, const std::string& title_suffix)
|
int recruit_dialog(display& disp, std::vector< const unit_type* >& units, const std::vector< std::string >& items, int side, const std::string& title_suffix)
|
||||||
{
|
{
|
||||||
dialogs::unit_types_preview_pane unit_preview(
|
dialogs::unit_types_preview_pane unit_preview(
|
||||||
units, NULL, side);
|
units, nullptr, side);
|
||||||
std::vector<gui::preview_pane*> preview_panes;
|
std::vector<gui::preview_pane*> preview_panes;
|
||||||
preview_panes.push_back(&unit_preview);
|
preview_panes.push_back(&unit_preview);
|
||||||
|
|
||||||
|
@ -843,7 +843,7 @@ void unit_preview_pane::draw_contents()
|
||||||
|
|
||||||
SDL_Rect image_rect = sdl::create_rect(area.x, area.y, 0, 0);
|
SDL_Rect image_rect = sdl::create_rect(area.x, area.y, 0, 0);
|
||||||
|
|
||||||
if(unit_image != NULL) {
|
if(unit_image != nullptr) {
|
||||||
SDL_Rect rect = sdl::create_rect(
|
SDL_Rect rect = sdl::create_rect(
|
||||||
right_align
|
right_align
|
||||||
? area.x
|
? area.x
|
||||||
|
@ -852,7 +852,7 @@ void unit_preview_pane::draw_contents()
|
||||||
, unit_image->w
|
, unit_image->w
|
||||||
, unit_image->h);
|
, unit_image->h);
|
||||||
|
|
||||||
sdl_blit(unit_image,NULL,screen,&rect);
|
sdl_blit(unit_image,nullptr,screen,&rect);
|
||||||
image_rect = rect;
|
image_rect = rect;
|
||||||
|
|
||||||
if(!det.overlays.empty()) {
|
if(!det.overlays.empty()) {
|
||||||
|
@ -867,7 +867,7 @@ void unit_preview_pane::draw_contents()
|
||||||
os = scale_surface(os, rect.w, rect.h, false);
|
os = scale_surface(os, rect.w, rect.h, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_blit(os, NULL, screen, &rect);
|
sdl_blit(os, nullptr, screen, &rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -980,7 +980,7 @@ void unit_preview_pane::draw_contents()
|
||||||
|
|
||||||
|
|
||||||
units_list_preview_pane::units_list_preview_pane(unit_const_ptr u, TYPE type, bool on_left_side) :
|
units_list_preview_pane::units_list_preview_pane(unit_const_ptr u, TYPE type, bool on_left_side) :
|
||||||
unit_preview_pane(NULL, type, on_left_side),
|
unit_preview_pane(nullptr, type, on_left_side),
|
||||||
units_(boost::make_shared<const std::vector<unit_const_ptr> >(1, u))
|
units_(boost::make_shared<const std::vector<unit_const_ptr> >(1, u))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1073,7 +1073,7 @@ unit_types_preview_pane::unit_types_preview_pane(
|
||||||
|
|
||||||
size_t unit_types_preview_pane::size() const
|
size_t unit_types_preview_pane::size() const
|
||||||
{
|
{
|
||||||
return (unit_types_!=NULL) ? unit_types_->size() : 0;
|
return (unit_types_!=nullptr) ? unit_types_->size() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unit_types_preview_pane::details unit_types_preview_pane::get_details() const
|
const unit_types_preview_pane::details unit_types_preview_pane::get_details() const
|
||||||
|
@ -1081,7 +1081,7 @@ const unit_types_preview_pane::details unit_types_preview_pane::get_details() co
|
||||||
const unit_type* t = (*unit_types_)[index_];
|
const unit_type* t = (*unit_types_)[index_];
|
||||||
details det;
|
details det;
|
||||||
|
|
||||||
if (t==NULL)
|
if (t==nullptr)
|
||||||
return det;
|
return det;
|
||||||
|
|
||||||
// Make sure the unit type is built with enough data for our needs.
|
// Make sure the unit type is built with enough data for our needs.
|
||||||
|
@ -1148,7 +1148,7 @@ void unit_types_preview_pane::process_event()
|
||||||
assert(resources::screen);
|
assert(resources::screen);
|
||||||
if (details_button_.pressed() && index_ >= 0 && index_ < int(size())) {
|
if (details_button_.pressed() && index_ >= 0 && index_ < int(size())) {
|
||||||
const unit_type* type = (*unit_types_)[index_];
|
const unit_type* type = (*unit_types_)[index_];
|
||||||
if (type != NULL)
|
if (type != nullptr)
|
||||||
help::show_unit_description(resources::screen->video(), *type);
|
help::show_unit_description(resources::screen->video(), *type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
std::vector<std::string> overlays;
|
std::vector<std::string> overlays;
|
||||||
};
|
};
|
||||||
|
|
||||||
unit_preview_pane(const gui::filter_textbox *filter = NULL,
|
unit_preview_pane(const gui::filter_textbox *filter = nullptr,
|
||||||
TYPE type = SHOW_ALL, bool left_side = true);
|
TYPE type = SHOW_ALL, bool left_side = true);
|
||||||
|
|
||||||
bool show_above() const;
|
bool show_above() const;
|
||||||
|
@ -109,7 +109,7 @@ class units_list_preview_pane : public dialogs::unit_preview_pane
|
||||||
public:
|
public:
|
||||||
units_list_preview_pane(unit_const_ptr u, TYPE type = SHOW_ALL, bool left_side = true);
|
units_list_preview_pane(unit_const_ptr u, TYPE type = SHOW_ALL, bool left_side = true);
|
||||||
units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > & units,
|
units_list_preview_pane(const boost::shared_ptr<const std::vector<unit_const_ptr > > & units,
|
||||||
const gui::filter_textbox *filter = NULL,
|
const gui::filter_textbox *filter = nullptr,
|
||||||
TYPE type = SHOW_ALL, bool left_side = true);
|
TYPE type = SHOW_ALL, bool left_side = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -125,7 +125,7 @@ class unit_types_preview_pane : public dialogs::unit_preview_pane
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
unit_types_preview_pane(
|
unit_types_preview_pane(
|
||||||
std::vector<const unit_type*>& unit_types, const gui::filter_textbox* filterbox=NULL,
|
std::vector<const unit_type*>& unit_types, const gui::filter_textbox* filterbox=nullptr,
|
||||||
int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
|
int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -163,7 +163,7 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
zoom_(DefaultZoom),
|
zoom_(DefaultZoom),
|
||||||
fake_unit_man_(new fake_unit_manager(*this)),
|
fake_unit_man_(new fake_unit_manager(*this)),
|
||||||
builder_(new terrain_builder(level, &dc_->map(), theme_.border().tile_image)),
|
builder_(new terrain_builder(level, &dc_->map(), theme_.border().tile_image)),
|
||||||
minimap_(NULL),
|
minimap_(nullptr),
|
||||||
minimap_location_(sdl::empty_rect),
|
minimap_location_(sdl::empty_rect),
|
||||||
redrawMinimap_(false),
|
redrawMinimap_(false),
|
||||||
redraw_background_(true),
|
redraw_background_(true),
|
||||||
|
@ -191,9 +191,9 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
sliders_(),
|
sliders_(),
|
||||||
invalidated_(),
|
invalidated_(),
|
||||||
previous_invalidated_(),
|
previous_invalidated_(),
|
||||||
mouseover_hex_overlay_(NULL),
|
mouseover_hex_overlay_(nullptr),
|
||||||
tod_hex_mask1(NULL),
|
tod_hex_mask1(nullptr),
|
||||||
tod_hex_mask2(NULL),
|
tod_hex_mask2(nullptr),
|
||||||
fog_images_(),
|
fog_images_(),
|
||||||
shroud_images_(),
|
shroud_images_(),
|
||||||
selectedHex_(),
|
selectedHex_(),
|
||||||
|
@ -208,13 +208,13 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
reach_map_(),
|
reach_map_(),
|
||||||
reach_map_old_(),
|
reach_map_old_(),
|
||||||
reach_map_changed_(true),
|
reach_map_changed_(true),
|
||||||
overlays_(NULL),
|
overlays_(nullptr),
|
||||||
fps_handle_(0),
|
fps_handle_(0),
|
||||||
invalidated_hexes_(0),
|
invalidated_hexes_(0),
|
||||||
drawn_hexes_(0),
|
drawn_hexes_(0),
|
||||||
idle_anim_(preferences::idle_anim()),
|
idle_anim_(preferences::idle_anim()),
|
||||||
idle_anim_rate_(1.0),
|
idle_anim_rate_(1.0),
|
||||||
map_screenshot_surf_(NULL),
|
map_screenshot_surf_(nullptr),
|
||||||
redraw_observers_(),
|
redraw_observers_(),
|
||||||
draw_coordinates_(false),
|
draw_coordinates_(false),
|
||||||
draw_terrain_codes_(false),
|
draw_terrain_codes_(false),
|
||||||
|
@ -227,7 +227,7 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
//The following assertion fails when starting a campaign
|
//The following assertion fails when starting a campaign
|
||||||
assert(singleton_ == NULL);
|
assert(singleton_ == nullptr);
|
||||||
singleton_ = this;
|
singleton_ = this;
|
||||||
|
|
||||||
resources::fake_units = fake_unit_man_.get();
|
resources::fake_units = fake_unit_man_.get();
|
||||||
|
@ -237,7 +237,7 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
read(level.child_or_empty("display"));
|
read(level.child_or_empty("display"));
|
||||||
|
|
||||||
if(video.non_interactive()
|
if(video.non_interactive()
|
||||||
&& (get_video_surface() != NULL
|
&& (get_video_surface() != nullptr
|
||||||
&& video.faked())) {
|
&& video.faked())) {
|
||||||
screen_.lock_updates(true);
|
screen_.lock_updates(true);
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,8 @@ display::display(const display_context * dc, CVideo& video, boost::weak_ptr<wb::
|
||||||
|
|
||||||
display::~display()
|
display::~display()
|
||||||
{
|
{
|
||||||
singleton_ = NULL;
|
singleton_ = nullptr;
|
||||||
resources::fake_units = NULL;
|
resources::fake_units = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ void display::reinit_flags_for_side(size_t side)
|
||||||
|
|
||||||
void display::init_flags_for_side_internal(size_t n, const std::string& side_color)
|
void display::init_flags_for_side_internal(size_t n, const std::string& side_color)
|
||||||
{
|
{
|
||||||
assert(dc_ != NULL);
|
assert(dc_ != nullptr);
|
||||||
assert(n < dc_->teams().size());
|
assert(n < dc_->teams().size());
|
||||||
assert(n < flags_.size());
|
assert(n < flags_.size());
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ void display::init_flags_for_side_internal(size_t n, const std::string& side_col
|
||||||
sdl::timage display::get_flag(const map_location& loc)
|
sdl::timage display::get_flag(const map_location& loc)
|
||||||
{
|
{
|
||||||
if(!get_map().is_village(loc)) {
|
if(!get_map().is_village(loc)) {
|
||||||
return surface(NULL);
|
return surface(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
||||||
|
@ -360,7 +360,7 @@ sdl::timage display::get_flag(const map_location& loc)
|
||||||
surface display::get_flag(const map_location& loc)
|
surface display::get_flag(const map_location& loc)
|
||||||
{
|
{
|
||||||
if(!get_map().is_village(loc)) {
|
if(!get_map().is_village(loc)) {
|
||||||
return surface(NULL);
|
return surface(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
||||||
|
@ -374,7 +374,7 @@ surface display::get_flag(const map_location& loc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return surface(NULL);
|
return surface(nullptr);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ void display::set_team(size_t teamindex, bool show_everything)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labels().set_team(NULL);
|
labels().set_team(nullptr);
|
||||||
dont_show_all_ = false;
|
dont_show_all_ = false;
|
||||||
}
|
}
|
||||||
labels().recalculate_labels();
|
labels().recalculate_labels();
|
||||||
|
@ -777,7 +777,7 @@ bool display::screenshot(const std::string& filename, bool map_screenshot)
|
||||||
SDL_Rect area = max_map_area();
|
SDL_Rect area = max_map_area();
|
||||||
map_screenshot_surf_ = create_compatible_surface(screen_.getSurface(), area.w, area.h);
|
map_screenshot_surf_ = create_compatible_surface(screen_.getSurface(), area.w, area.h);
|
||||||
|
|
||||||
if (map_screenshot_surf_ == NULL) {
|
if (map_screenshot_surf_ == nullptr) {
|
||||||
// Memory problem ?
|
// Memory problem ?
|
||||||
ERR_DP << "Could not create screenshot surface, try zooming out.\n";
|
ERR_DP << "Could not create screenshot surface, try zooming out.\n";
|
||||||
return false;
|
return false;
|
||||||
|
@ -805,13 +805,13 @@ bool display::screenshot(const std::string& filename, bool map_screenshot)
|
||||||
if (!res) {
|
if (!res) {
|
||||||
// Need to do this ASAP or spurious messages result due to
|
// Need to do this ASAP or spurious messages result due to
|
||||||
// redraw_everything calling SDL too (e.g. "SDL_UpperBlit: passed
|
// redraw_everything calling SDL too (e.g. "SDL_UpperBlit: passed
|
||||||
// a NULL surface")
|
// a nullptr surface")
|
||||||
ERR_DP << "Map screenshot failed: " << SDL_GetError() << '\n';
|
ERR_DP << "Map screenshot failed: " << SDL_GetError() << '\n';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//NOTE: need to be sure that we free this huge surface (is it enough?)
|
//NOTE: need to be sure that we free this huge surface (is it enough?)
|
||||||
map_screenshot_surf_ = NULL;
|
map_screenshot_surf_ = nullptr;
|
||||||
|
|
||||||
// restore normal rendering
|
// restore normal rendering
|
||||||
map_screenshot_= false;
|
map_screenshot_= false;
|
||||||
|
@ -832,7 +832,7 @@ gui::button* display::find_action_button(const std::string& id)
|
||||||
return &action_buttons_[i];
|
return &action_buttons_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::button* display::find_menu_button(const std::string& id)
|
gui::button* display::find_menu_button(const std::string& id)
|
||||||
|
@ -842,7 +842,7 @@ gui::button* display::find_menu_button(const std::string& id)
|
||||||
return &menu_buttons_[i];
|
return &menu_buttons_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gui::zoom_slider* display::find_slider(const std::string& id)
|
gui::zoom_slider* display::find_slider(const std::string& id)
|
||||||
|
@ -852,7 +852,7 @@ gui::zoom_slider* display::find_slider(const std::string& id)
|
||||||
return &sliders_[i];
|
return &sliders_[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display::layout_buttons()
|
void display::layout_buttons()
|
||||||
|
@ -1166,7 +1166,7 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(terrains != NULL) {
|
if(terrains != nullptr) {
|
||||||
// Cache the offmap name.
|
// Cache the offmap name.
|
||||||
// Since it is themeable it can change,
|
// Since it is themeable it can change,
|
||||||
// so don't make it static.
|
// so don't make it static.
|
||||||
|
@ -1371,7 +1371,7 @@ void display::drawing_buffer_commit()
|
||||||
SDL_Rect dstrect = sdl::create_rect(blit.x(), blit.y(), 0, 0);
|
SDL_Rect dstrect = sdl::create_rect(blit.x(), blit.y(), 0, 0);
|
||||||
SDL_Rect srcrect = blit.clip();
|
SDL_Rect srcrect = blit.clip();
|
||||||
SDL_Rect *srcrectArg = (srcrect.x | srcrect.y | srcrect.w | srcrect.h)
|
SDL_Rect *srcrectArg = (srcrect.x | srcrect.y | srcrect.w | srcrect.h)
|
||||||
? &srcrect : NULL;
|
? &srcrect : nullptr;
|
||||||
sdl_blit(surf, srcrectArg, screen, &dstrect);
|
sdl_blit(surf, srcrectArg, screen, &dstrect);
|
||||||
//NOTE: the screen part should already be marked as 'to update'
|
//NOTE: the screen part should already be marked as 'to update'
|
||||||
}
|
}
|
||||||
|
@ -1507,7 +1507,7 @@ static void draw_panel(CVideo &video, const theme::panel& panel, std::vector<gui
|
||||||
surf.assign(tile_surface(surf,loc.w,loc.h));
|
surf.assign(tile_surface(surf,loc.w,loc.h));
|
||||||
}
|
}
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
blit_surface(surf, NULL, target, &loc);
|
blit_surface(surf, nullptr, target, &loc);
|
||||||
#else
|
#else
|
||||||
video.blit_surface(loc.x, loc.y, surf);
|
video.blit_surface(loc.x, loc.y, surf);
|
||||||
update_rect(loc);
|
update_rect(loc);
|
||||||
|
@ -1545,7 +1545,7 @@ static void draw_label(CVideo& video, surface target, const theme::label& label)
|
||||||
surf.assign(scale_surface(surf,loc.w,loc.h));
|
surf.assign(scale_surface(surf,loc.w,loc.h));
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_blit(surf,NULL,target,&loc);
|
sdl_blit(surf,nullptr,target,&loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text.empty() == false) {
|
if(text.empty() == false) {
|
||||||
|
@ -1615,12 +1615,12 @@ void display::draw_panel_image(SDL_Rect *clip)
|
||||||
update_panel_image_ = false;
|
update_panel_image_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clip != NULL)
|
if (clip != nullptr)
|
||||||
GPU_SetClip(get_render_target(), clip->x, clip->y, clip->w, clip->h);
|
GPU_SetClip(get_render_target(), clip->x, clip->y, clip->w, clip->h);
|
||||||
|
|
||||||
video().draw_texture(panel_image_, 0, 0);
|
video().draw_texture(panel_image_, 0, 0);
|
||||||
|
|
||||||
if (clip != NULL)
|
if (clip != nullptr)
|
||||||
GPU_UnsetClip(get_render_target());
|
GPU_UnsetClip(get_render_target());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1652,7 +1652,7 @@ static void draw_background(surface screen, const SDL_Rect& area, const std::str
|
||||||
for(unsigned int w = 0, w_off = area.x; w < w_count; ++w, w_off += width) {
|
for(unsigned int w = 0, w_off = area.x; w < w_count; ++w, w_off += width) {
|
||||||
for(unsigned int h = 0, h_off = area.y; h < h_count; ++h, h_off += height) {
|
for(unsigned int h = 0, h_off = area.y; h < h_count; ++h, h_off += height) {
|
||||||
SDL_Rect clip = sdl::create_rect(w_off, h_off, 0, 0);
|
SDL_Rect clip = sdl::create_rect(w_off, h_off, 0, 0);
|
||||||
sdl_blit(background, NULL, screen, &clip);
|
sdl_blit(background, nullptr, screen, &clip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1719,7 +1719,7 @@ void display::render_image(int x, int y, const display::tdrawing_layer drawing_l
|
||||||
bool hreverse, bool greyscale, fixed_t alpha,
|
bool hreverse, bool greyscale, fixed_t alpha,
|
||||||
Uint32 blendto, double blend_ratio, double submerged, bool vreverse)
|
Uint32 blendto, double blend_ratio, double submerged, bool vreverse)
|
||||||
{
|
{
|
||||||
if (image==NULL)
|
if (image==nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_Rect image_rect = sdl::create_rect(x, y, image->w, image->h);
|
SDL_Rect image_rect = sdl::create_rect(x, y, image->w, image->h);
|
||||||
|
@ -1751,7 +1751,7 @@ void display::render_image(int x, int y, const display::tdrawing_layer drawing_l
|
||||||
surf = adjust_surface_alpha(surf, alpha, false);
|
surf = adjust_surface_alpha(surf, alpha, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(surf == NULL) {
|
if(surf == nullptr) {
|
||||||
ERR_DP << "surface lost..." << std::endl;
|
ERR_DP << "surface lost..." << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1897,13 +1897,13 @@ const theme::action* display::action_pressed()
|
||||||
const size_t index = i - action_buttons_.begin();
|
const size_t index = i - action_buttons_.begin();
|
||||||
if(index >= theme_.actions().size()) {
|
if(index >= theme_.actions().size()) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return &theme_.actions()[index];
|
return &theme_.actions()[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const theme::menu* display::menu_pressed()
|
const theme::menu* display::menu_pressed()
|
||||||
|
@ -1913,13 +1913,13 @@ const theme::menu* display::menu_pressed()
|
||||||
const size_t index = i - menu_buttons_.begin();
|
const size_t index = i - menu_buttons_.begin();
|
||||||
if(index >= theme_.menus().size()) {
|
if(index >= theme_.menus().size()) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return theme_.get_menu_item(i->id());
|
return theme_.get_menu_item(i->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display::enable_menu(const std::string& item, bool enable)
|
void display::enable_menu(const std::string& item, bool enable)
|
||||||
|
@ -2087,13 +2087,13 @@ void display::draw_minimap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
minimap_location_ = image::draw_minimap(screen_, area, get_map(), &dc_->teams()[currentTeam_], NULL);
|
minimap_location_ = image::draw_minimap(screen_, area, get_map(), &dc_->teams()[currentTeam_], nullptr);
|
||||||
|
|
||||||
draw_minimap_units();
|
draw_minimap_units();
|
||||||
#else
|
#else
|
||||||
if(minimap_ == NULL || minimap_->w > area.w || minimap_->h > area.h) {
|
if(minimap_ == nullptr || minimap_->w > area.w || minimap_->h > area.h) {
|
||||||
minimap_ = image::getMinimap(area.w, area.h, get_map(), &dc_->teams()[currentTeam_], (selectedHex_.valid() && !is_blindfolded()) ? &reach_map_ : NULL);
|
minimap_ = image::getMinimap(area.w, area.h, get_map(), &dc_->teams()[currentTeam_], (selectedHex_.valid() && !is_blindfolded()) ? &reach_map_ : nullptr);
|
||||||
if(minimap_ == NULL) {
|
if(minimap_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2916,7 +2916,7 @@ void display::draw_hex(const map_location& loc) {
|
||||||
image::get_texture(tod_hex_mask,image::SCALED_TO_HEX));
|
image::get_texture(tod_hex_mask,image::SCALED_TO_HEX));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(tod_hex_mask1 != NULL || tod_hex_mask2 != NULL) {
|
if(tod_hex_mask1 != nullptr || tod_hex_mask2 != nullptr) {
|
||||||
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos, tod_hex_mask1);
|
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos, tod_hex_mask1);
|
||||||
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos, tod_hex_mask2);
|
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos, tod_hex_mask2);
|
||||||
} else if(!tod_hex_mask.empty()) {
|
} else if(!tod_hex_mask.empty()) {
|
||||||
|
@ -2930,7 +2930,7 @@ void display::draw_hex(const map_location& loc) {
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
&& !mouseover_hex_overlay_.null()) {
|
&& !mouseover_hex_overlay_.null()) {
|
||||||
#else
|
#else
|
||||||
&& mouseover_hex_overlay_ != NULL) {
|
&& mouseover_hex_overlay_ != nullptr) {
|
||||||
#endif
|
#endif
|
||||||
drawing_buffer_add(LAYER_MOUSEOVER_OVERLAY, loc, xpos, ypos, mouseover_hex_overlay_);
|
drawing_buffer_add(LAYER_MOUSEOVER_OVERLAY, loc, xpos, ypos, mouseover_hex_overlay_);
|
||||||
}
|
}
|
||||||
|
@ -3078,7 +3078,7 @@ void display::draw_image_for_report(surface& img, SDL_Rect& rect)
|
||||||
img.assign(scale_surface(img,rect.w,rect.h));
|
img.assign(scale_surface(img,rect.w,rect.h));
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_blit(img,NULL,screen_.getSurface(),&target);
|
sdl_blit(img,nullptr,screen_.getSurface(),&target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3108,7 +3108,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
reports::context temp_context = reports::context(*dc_, *this, *resources::tod_manager, wb_.lock(), mhb);
|
reports::context temp_context = reports::context(*dc_, *this, *resources::tod_manager, wb_.lock(), mhb);
|
||||||
|
|
||||||
const config generated_cfg = new_cfg ? config() : reports_object_->generate_report(report_name, temp_context);
|
const config generated_cfg = new_cfg ? config() : reports_object_->generate_report(report_name, temp_context);
|
||||||
if ( new_cfg == NULL )
|
if ( new_cfg == nullptr )
|
||||||
new_cfg = &generated_cfg;
|
new_cfg = &generated_cfg;
|
||||||
|
|
||||||
SDL_Rect &rect = reportRects_[report_name];
|
SDL_Rect &rect = reportRects_[report_name];
|
||||||
|
@ -3141,7 +3141,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
// TODO: handle this somehow for SDL_gpu
|
// TODO: handle this somehow for SDL_gpu
|
||||||
/*if (rect.w > 0 && rect.h > 0) {
|
/*if (rect.w > 0 && rect.h > 0) {
|
||||||
img.assign(get_surface_portion(screen_.getSurface(), rect));
|
img.assign(get_surface_portion(screen_.getSurface(), rect));
|
||||||
if (reportSurfaces_[report_name] == NULL) {
|
if (reportSurfaces_[report_name] == nullptr) {
|
||||||
ERR_DP << "Could not backup background for report!" << std::endl;
|
ERR_DP << "Could not backup background for report!" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3304,7 +3304,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
#else
|
#else
|
||||||
const theme::status_item *item = theme_.get_status_item(report_name);
|
const theme::status_item *item = theme_.get_status_item(report_name);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
reportSurfaces_[report_name].assign(NULL);
|
reportSurfaces_[report_name].assign(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3319,7 +3319,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
reports::context temp_context = reports::context(*dc_, *this, *resources::tod_manager, wb_.lock(), mhb);
|
reports::context temp_context = reports::context(*dc_, *this, *resources::tod_manager, wb_.lock(), mhb);
|
||||||
|
|
||||||
const config generated_cfg = new_cfg ? config() : reports_object_->generate_report(report_name, temp_context);
|
const config generated_cfg = new_cfg ? config() : reports_object_->generate_report(report_name, temp_context);
|
||||||
if ( new_cfg == NULL )
|
if ( new_cfg == nullptr )
|
||||||
new_cfg = &generated_cfg;
|
new_cfg = &generated_cfg;
|
||||||
|
|
||||||
SDL_Rect &rect = reportRects_[report_name];
|
SDL_Rect &rect = reportRects_[report_name];
|
||||||
|
@ -3336,14 +3336,14 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
report = *new_cfg;
|
report = *new_cfg;
|
||||||
|
|
||||||
if (surf) {
|
if (surf) {
|
||||||
sdl_blit(surf, NULL, screen_.getSurface(), &rect);
|
sdl_blit(surf, nullptr, screen_.getSurface(), &rect);
|
||||||
update_rect(rect);
|
update_rect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the rectangle has just changed, assign the surface to it
|
// If the rectangle has just changed, assign the surface to it
|
||||||
if (!surf || new_rect != rect)
|
if (!surf || new_rect != rect)
|
||||||
{
|
{
|
||||||
surf.assign(NULL);
|
surf.assign(nullptr);
|
||||||
rect = new_rect;
|
rect = new_rect;
|
||||||
|
|
||||||
// If the rectangle is present, and we are blitting text,
|
// If the rectangle is present, and we are blitting text,
|
||||||
|
@ -3352,7 +3352,7 @@ void display::refresh_report(std::string const &report_name, const config * new_
|
||||||
// unless they are transparent, but that is done later).
|
// unless they are transparent, but that is done later).
|
||||||
if (rect.w > 0 && rect.h > 0) {
|
if (rect.w > 0 && rect.h > 0) {
|
||||||
surf.assign(get_surface_portion(screen_.getSurface(), rect));
|
surf.assign(get_surface_portion(screen_.getSurface(), rect));
|
||||||
if (reportSurfaces_[report_name] == NULL) {
|
if (reportSurfaces_[report_name] == nullptr) {
|
||||||
ERR_DP << "Could not backup background for report!" << std::endl;
|
ERR_DP << "Could not backup background for report!" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3791,5 +3791,5 @@ void display::handle_event(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
display *display::singleton_ = NULL;
|
display *display::singleton_ = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public:
|
||||||
reports & reports_object,
|
reports & reports_object,
|
||||||
const config& theme_cfg, const config& level, bool auto_join=true);
|
const config& theme_cfg, const config& level, bool auto_join=true);
|
||||||
virtual ~display();
|
virtual ~display();
|
||||||
/// Returns the display object if a display object exists. Otherwise it returns NULL.
|
/// Returns the display object if a display object exists. Otherwise it returns nullptr.
|
||||||
/// the display object represents the game gui which handles themewml and drawing the map.
|
/// the display object represents the game gui which handles themewml and drawing the map.
|
||||||
/// A display object only exists during a game or while the mapeditor is running.
|
/// A display object only exists during a game or while the mapeditor is running.
|
||||||
static display* get_singleton() { return singleton_ ;}
|
static display* get_singleton() { return singleton_ ;}
|
||||||
|
@ -165,8 +165,8 @@ public:
|
||||||
void change_display_context(const display_context * dc);
|
void change_display_context(const display_context * dc);
|
||||||
const display_context & get_disp_context() const { return *dc_; }
|
const display_context & get_disp_context() const { return *dc_; }
|
||||||
virtual const tod_manager & get_tod_man() const; //!< This is implemented properly in game_display. The display:: impl could be pure virtual here but we decide not to.
|
virtual const tod_manager & get_tod_man() const; //!< This is implemented properly in game_display. The display:: impl could be pure virtual here but we decide not to.
|
||||||
virtual const game_data * get_game_data() const { return NULL; }
|
virtual const game_data * get_game_data() const { return nullptr; }
|
||||||
virtual game_lua_kernel * get_lua_kernel() const { return NULL; } //!< TODO: display should not work as a filter context, this was only done for expedience so that the unit animation code can have a convenient and correct filter context readily available. a more correct solution is most likely to pass it a filter context from unit_animator when it needs to be matched. (it's not possible to store filter contexts with animations, because animations are cached across scenarios.) Note that after these lines which return NULL, unit filters used in animations will not be able to make use of wml variables or lua scripting (but the latter was a bad idea anyways because it would be slow to constantly recompile the script.)
|
virtual game_lua_kernel * get_lua_kernel() const { return nullptr; } //!< TODO: display should not work as a filter context, this was only done for expedience so that the unit animation code can have a convenient and correct filter context readily available. a more correct solution is most likely to pass it a filter context from unit_animator when it needs to be matched. (it's not possible to store filter contexts with animations, because animations are cached across scenarios.) Note that after these lines which return nullptr, unit filters used in animations will not be able to make use of wml variables or lua scripting (but the latter was a bad idea anyways because it would be slow to constantly recompile the script.)
|
||||||
|
|
||||||
void reset_halo_manager();
|
void reset_halo_manager();
|
||||||
void reset_halo_manager(halo::manager & hm);
|
void reset_halo_manager(halo::manager & hm);
|
||||||
|
@ -386,7 +386,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Retrieves a pointer to a theme UI button.
|
* Retrieves a pointer to a theme UI button.
|
||||||
*
|
*
|
||||||
* @note The returned pointer may either be NULL, meaning the button
|
* @note The returned pointer may either be nullptr, meaning the button
|
||||||
* isn't defined by the current theme, or point to a valid
|
* isn't defined by the current theme, or point to a valid
|
||||||
* gui::button object. However, the objects retrieved will be
|
* gui::button object. However, the objects retrieved will be
|
||||||
* destroyed and recreated by draw() method calls. Do *NOT* store
|
* destroyed and recreated by draw() method calls. Do *NOT* store
|
||||||
|
@ -406,7 +406,7 @@ public:
|
||||||
|
|
||||||
void invalidate_theme() { panelsDrawn_ = false; }
|
void invalidate_theme() { panelsDrawn_ = false; }
|
||||||
|
|
||||||
void refresh_report(std::string const &report_name, const config * new_cfg=NULL);
|
void refresh_report(std::string const &report_name, const config * new_cfg=nullptr);
|
||||||
|
|
||||||
void draw_minimap_units();
|
void draw_minimap_units();
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ public:
|
||||||
{ mouseover_hex_overlay_ = image; }
|
{ mouseover_hex_overlay_ = image; }
|
||||||
|
|
||||||
void clear_mouseover_hex_overlay()
|
void clear_mouseover_hex_overlay()
|
||||||
{ mouseover_hex_overlay_ = NULL; }
|
{ mouseover_hex_overlay_ = nullptr; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -619,7 +619,7 @@ public:
|
||||||
* Schedule the minimap for recalculation.
|
* Schedule the minimap for recalculation.
|
||||||
* Useful if any terrain in the map has changed.
|
* Useful if any terrain in the map has changed.
|
||||||
*/
|
*/
|
||||||
void recalculate_minimap() {minimap_ = NULL; redrawMinimap_ = true; }
|
void recalculate_minimap() {minimap_ = nullptr; redrawMinimap_ = true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule the minimap to be redrawn.
|
* Schedule the minimap to be redrawn.
|
||||||
|
@ -1097,7 +1097,7 @@ protected:
|
||||||
void draw_all_panels();
|
void draw_all_panels();
|
||||||
|
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
void draw_panel_image(SDL_Rect *clip = NULL);
|
void draw_panel_image(SDL_Rect *clip = nullptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,10 +54,10 @@ bool display_context::would_be_discovered(const map_location & loc, int side_num
|
||||||
|
|
||||||
const unit * display_context::get_visible_unit(const map_location & loc, const team ¤t_team, bool see_all) const
|
const unit * display_context::get_visible_unit(const map_location & loc, const team ¤t_team, bool see_all) const
|
||||||
{
|
{
|
||||||
if (!map().on_board(loc)) return NULL;
|
if (!map().on_board(loc)) return nullptr;
|
||||||
const unit_map::const_iterator u = units().find(loc);
|
const unit_map::const_iterator u = units().find(loc);
|
||||||
if (!u.valid() || !u->is_visible_to_team(current_team, map(), see_all)) {
|
if (!u.valid() || !u->is_visible_to_team(current_team, map(), see_all)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return &*u;
|
return &*u;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ editor_action* editor_action_chain::pop_first_action() {
|
||||||
editor_action_chain* editor_action_chain::perform(map_context& mc) const {
|
editor_action_chain* editor_action_chain::perform(map_context& mc) const {
|
||||||
util::unique_ptr<editor_action_chain> undo(new editor_action_chain());
|
util::unique_ptr<editor_action_chain> undo(new editor_action_chain());
|
||||||
BOOST_FOREACH(editor_action* a, actions_) {
|
BOOST_FOREACH(editor_action* a, actions_) {
|
||||||
if (a != NULL) {
|
if (a != nullptr) {
|
||||||
undo->append_action(a->perform(mc));
|
undo->append_action(a->perform(mc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ editor_action_chain* editor_action_chain::perform(map_context& mc) const {
|
||||||
void editor_action_chain::perform_without_undo(map_context& mc) const
|
void editor_action_chain::perform_without_undo(map_context& mc) const
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(editor_action* a, actions_) {
|
BOOST_FOREACH(editor_action* a, actions_) {
|
||||||
if (a != NULL) {
|
if (a != nullptr) {
|
||||||
a->perform_without_undo(mc);
|
a->perform_without_undo(mc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ editor_action* editor_action_item_delete::perform(map_context& /*mc*/) const
|
||||||
// perform_without_undo(mc);
|
// perform_without_undo(mc);
|
||||||
// return undo.release();
|
// return undo.release();
|
||||||
// }
|
// }
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void editor_action_item_delete::perform_without_undo(map_context& /*mc*/) const
|
void editor_action_item_delete::perform_without_undo(map_context& /*mc*/) const
|
||||||
|
|
|
@ -63,7 +63,7 @@ editor_action* editor_action_label_delete::perform(map_context& mc) const
|
||||||
|
|
||||||
const terrain_label* deleted = mc.get_labels().get_label(loc_);
|
const terrain_label* deleted = mc.get_labels().get_label(loc_);
|
||||||
|
|
||||||
if (!deleted) return NULL;
|
if (!deleted) return nullptr;
|
||||||
|
|
||||||
undo.reset(new editor_action_label(loc_, deleted->text(), deleted->team_name()
|
undo.reset(new editor_action_label(loc_, deleted->text(), deleted->team_name()
|
||||||
, deleted->color(), deleted->visible_in_fog(), deleted->visible_in_shroud(), deleted->immutable(), deleted->category()));
|
, deleted->color(), deleted->visible_in_fog(), deleted->visible_in_shroud(), deleted->immutable(), deleted->category()));
|
||||||
|
|
|
@ -67,7 +67,7 @@ editor_action* editor_action_unit_delete::perform(map_context& mc) const
|
||||||
perform_without_undo(mc);
|
perform_without_undo(mc);
|
||||||
return undo.release();
|
return undo.release();
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void editor_action_unit_delete::perform_without_undo(map_context& mc) const
|
void editor_action_unit_delete::perform_without_undo(map_context& mc) const
|
||||||
|
|
|
@ -33,10 +33,10 @@ editor_action* editor_action_village::perform(map_context& mc) const
|
||||||
{
|
{
|
||||||
std::unique_ptr<editor_action> undo;
|
std::unique_ptr<editor_action> undo;
|
||||||
|
|
||||||
if(!mc.get_map().is_village(loc_)) return NULL;
|
if(!mc.get_map().is_village(loc_)) return nullptr;
|
||||||
std::vector<team>& teams = mc.get_teams();
|
std::vector<team>& teams = mc.get_teams();
|
||||||
team *t = unsigned(side_number_) < teams.size() ? &teams[side_number_] : NULL;
|
team *t = unsigned(side_number_) < teams.size() ? &teams[side_number_] : nullptr;
|
||||||
if (t && t->owns_village(loc_)) return NULL;
|
if (t && t->owns_village(loc_)) return nullptr;
|
||||||
|
|
||||||
undo.reset(new editor_action_village_delete(loc_));
|
undo.reset(new editor_action_village_delete(loc_));
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void editor_action_village::perform_without_undo(map_context& mc) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO 0 is a bad argument
|
//TODO 0 is a bad argument
|
||||||
teams[side_number_].get_village(loc_, 0, NULL);
|
teams[side_number_].get_village(loc_, 0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,37 +53,37 @@ std::set<map_location> mouse_action::affected_hexes(
|
||||||
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*/)
|
int /*x*/, int /*y*/, bool& /*partial*/, editor_action* /*last_undo*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
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*/)
|
int /*x*/, int /*y*/, bool& /*partial*/, editor_action* /*last_undo*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action::drag_end_left(
|
editor_action* mouse_action::drag_end_left(
|
||||||
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action::drag_end_right(
|
editor_action* mouse_action::drag_end_right(
|
||||||
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action::up_right(
|
editor_action* mouse_action::up_right(
|
||||||
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action::up_left(
|
editor_action* mouse_action::up_left(
|
||||||
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action::key_event(
|
editor_action* mouse_action::key_event(
|
||||||
|
@ -97,12 +97,12 @@ editor_action* mouse_action::key_event(
|
||||||
disp.scroll_to_tile(pos, display::WARP);
|
disp.scroll_to_tile(pos, display::WARP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!disp.map().on_board(previous_move_hex_) || event.type != SDL_KEYUP) {
|
if (!disp.map().on_board(previous_move_hex_) || event.type != SDL_KEYUP) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
editor_action* a = NULL;
|
editor_action* a = nullptr;
|
||||||
if ((has_alt_modifier() && (event.key.keysym.sym >= '1' && event.key.keysym.sym <= '9'))
|
if ((has_alt_modifier() && (event.key.keysym.sym >= '1' && event.key.keysym.sym <= '9'))
|
||||||
|| event.key.keysym.sym == SDLK_DELETE) {
|
|| event.key.keysym.sym == SDLK_DELETE) {
|
||||||
int res = event.key.keysym.sym - '0';
|
int res = event.key.keysym.sym - '0';
|
||||||
|
@ -119,7 +119,7 @@ editor_action* mouse_action::key_event(
|
||||||
|
|
||||||
void mouse_action::set_mouse_overlay(editor_display& disp)
|
void mouse_action::set_mouse_overlay(editor_display& disp)
|
||||||
{
|
{
|
||||||
disp.set_mouseover_hex_overlay(NULL);
|
disp.set_mouseover_hex_overlay(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mouse_action::has_alt_modifier() const
|
bool mouse_action::has_alt_modifier() const
|
||||||
|
@ -147,9 +147,9 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_trans
|
||||||
surface image_fg(image::get_image(disp.get_map().get_terrain_info(fg).editor_image()));
|
surface image_fg(image::get_image(disp.get_map().get_terrain_info(fg).editor_image()));
|
||||||
surface image_bg(image::get_image(disp.get_map().get_terrain_info(bg).editor_image()));
|
surface image_bg(image::get_image(disp.get_map().get_terrain_info(bg).editor_image()));
|
||||||
|
|
||||||
if (image_fg == NULL || image_bg == NULL) {
|
if (image_fg == nullptr || image_bg == nullptr) {
|
||||||
ERR_ED << "Missing terrain icon" << std::endl;
|
ERR_ED << "Missing terrain icon" << std::endl;
|
||||||
disp.set_mouseover_hex_overlay(NULL);
|
disp.set_mouseover_hex_overlay(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,12 +172,12 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_trans
|
||||||
// Blit left side
|
// Blit left side
|
||||||
image_fg = scale_surface(image_fg, new_size, new_size);
|
image_fg = scale_surface(image_fg, new_size, new_size);
|
||||||
SDL_Rect rcDestLeft = sdl::create_rect(offset, quarter_size, 0, 0);
|
SDL_Rect rcDestLeft = sdl::create_rect(offset, quarter_size, 0, 0);
|
||||||
blit_surface ( image_fg, NULL, image, &rcDestLeft );
|
blit_surface ( image_fg, nullptr, image, &rcDestLeft );
|
||||||
|
|
||||||
// Blit right side
|
// Blit right side
|
||||||
image_bg = scale_surface(image_bg, new_size, new_size);
|
image_bg = scale_surface(image_bg, new_size, new_size);
|
||||||
SDL_Rect rcDestRight = sdl::create_rect(half_size, quarter_size, 0, 0);
|
SDL_Rect rcDestRight = sdl::create_rect(half_size, quarter_size, 0, 0);
|
||||||
blit_surface ( image_bg, NULL, image, &rcDestRight );
|
blit_surface ( image_bg, nullptr, image, &rcDestRight );
|
||||||
|
|
||||||
//apply mask so the overlay is contained within the mouseover hex
|
//apply mask so the overlay is contained within the mouseover hex
|
||||||
image = mask_surface(image, image::get_hexmask());
|
image = mask_surface(image, image::get_hexmask());
|
||||||
|
@ -230,7 +230,7 @@ editor_action* brush_drag_mouse_action::drag_right(editor_display& disp,
|
||||||
editor_action* brush_drag_mouse_action::drag_end(
|
editor_action* brush_drag_mouse_action::drag_end(
|
||||||
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <editor_action* (brush_drag_mouse_action::*perform_func)(editor_display&, const std::set<map_location>&)>
|
template <editor_action* (brush_drag_mouse_action::*perform_func)(editor_display&, const std::set<map_location>&)>
|
||||||
|
@ -246,7 +246,7 @@ editor_action* brush_drag_mouse_action::drag_generic(editor_display& disp, int x
|
||||||
previous_drag_hex_ = hex;
|
previous_drag_hex_ = hex;
|
||||||
return a;
|
return a;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ editor_action* mouse_action_paint::click_left(editor_display& disp, int x, int y
|
||||||
if (has_ctrl_modifier()) {
|
if (has_ctrl_modifier()) {
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
terrain_palette_.select_fg_item(disp.map().get_terrain(hex));
|
terrain_palette_.select_fg_item(disp.map().get_terrain(hex));
|
||||||
return NULL;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
return brush_drag_mouse_action::click_left(disp, x, y);
|
return brush_drag_mouse_action::click_left(disp, x, y);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ editor_action* mouse_action_paint::click_right(editor_display& disp, int x, int
|
||||||
if (has_ctrl_modifier()) {
|
if (has_ctrl_modifier()) {
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
|
terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
|
||||||
return NULL;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
return brush_drag_mouse_action::click_right(disp, x, y);
|
return brush_drag_mouse_action::click_right(disp, x, y);
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ editor_action* mouse_action_paint::click_right(editor_display& disp, int x, int
|
||||||
editor_action* mouse_action_paint::click_perform_left(
|
editor_action* mouse_action_paint::click_perform_left(
|
||||||
editor_display& /*disp*/, const std::set<map_location>& hexes)
|
editor_display& /*disp*/, const std::set<map_location>& hexes)
|
||||||
{
|
{
|
||||||
if (has_ctrl_modifier()) return NULL;
|
if (has_ctrl_modifier()) return nullptr;
|
||||||
return new editor_action_chain(new editor_action_paint_area(
|
return new editor_action_chain(new editor_action_paint_area(
|
||||||
hexes, terrain_palette_.selected_fg_item(), has_shift_modifier()));
|
hexes, terrain_palette_.selected_fg_item(), has_shift_modifier()));
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ editor_action* mouse_action_paint::click_perform_left(
|
||||||
editor_action* mouse_action_paint::click_perform_right(
|
editor_action* mouse_action_paint::click_perform_right(
|
||||||
editor_display& /*disp*/, const std::set<map_location>& hexes)
|
editor_display& /*disp*/, const std::set<map_location>& hexes)
|
||||||
{
|
{
|
||||||
if (has_ctrl_modifier()) return NULL;
|
if (has_ctrl_modifier()) return nullptr;
|
||||||
return new editor_action_chain(new editor_action_paint_area(
|
return new editor_action_chain(new editor_action_paint_area(
|
||||||
hexes, terrain_palette_.selected_bg_item(), has_shift_modifier()));
|
hexes, terrain_palette_.selected_bg_item(), has_shift_modifier()));
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ editor_action* mouse_action_paste::click_left(editor_display& disp, int x, int y
|
||||||
|
|
||||||
editor_action* mouse_action_paste::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_action* mouse_action_paste::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_action_paste::set_mouse_overlay(editor_display& disp)
|
void mouse_action_paste::set_mouse_overlay(editor_display& disp)
|
||||||
|
@ -337,7 +337,7 @@ void mouse_action_paste::set_mouse_overlay(editor_display& disp)
|
||||||
surface image = create_neutral_surface(72,72);
|
surface image = create_neutral_surface(72,72);
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||||
blit_surface(image60, NULL, image, &r);
|
blit_surface(image60, nullptr, image, &r);
|
||||||
|
|
||||||
Uint8 alpha = 196;
|
Uint8 alpha = 196;
|
||||||
int size = image->w;
|
int size = image->w;
|
||||||
|
@ -359,7 +359,7 @@ editor_action* mouse_action_fill::click_left(editor_display& disp, int x, int y)
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (has_ctrl_modifier()) {
|
if (has_ctrl_modifier()) {
|
||||||
terrain_palette_.select_fg_item(disp.map().get_terrain(hex));
|
terrain_palette_.select_fg_item(disp.map().get_terrain(hex));
|
||||||
return NULL;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
/** @todo only take the base terrain into account when searching for contiguous terrain when painting base only */
|
/** @todo only take the base terrain into account when searching for contiguous terrain when painting base only */
|
||||||
//or use a different key modifier for that
|
//or use a different key modifier for that
|
||||||
|
@ -374,7 +374,7 @@ editor_action* mouse_action_fill::click_right(editor_display& disp, int x, int y
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (has_ctrl_modifier()) {
|
if (has_ctrl_modifier()) {
|
||||||
terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
|
terrain_palette_.select_bg_item(disp.map().get_terrain(hex));
|
||||||
return NULL;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
/** @todo only take the base terrain into account when searching for contiguous terrain when painting base only */
|
/** @todo only take the base terrain into account when searching for contiguous terrain when painting base only */
|
||||||
//or use a different key modifier for that
|
//or use a different key modifier for that
|
||||||
|
@ -392,11 +392,11 @@ void mouse_action_fill::set_mouse_overlay(editor_display& disp)
|
||||||
|
|
||||||
editor_action* mouse_action_starting_position::up_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_starting_position::up_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (!click_) return NULL;
|
if (!click_) return nullptr;
|
||||||
click_ = false;
|
click_ = false;
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.map().on_board(hex)) {
|
if (!disp.map().on_board(hex)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned player_starting_at_hex = disp.map().is_starting_position(hex);
|
const unsigned player_starting_at_hex = disp.map().is_starting_position(hex);
|
||||||
|
@ -412,7 +412,7 @@ editor_action* mouse_action_starting_position::up_left(editor_display& disp, int
|
||||||
dlg.show(disp.video());
|
dlg.show(disp.video());
|
||||||
|
|
||||||
unsigned new_player_at_hex = dlg.result(); // 1st player = 1
|
unsigned new_player_at_hex = dlg.result(); // 1st player = 1
|
||||||
editor_action* a = NULL;
|
editor_action* a = nullptr;
|
||||||
|
|
||||||
if(new_player_at_hex != player_starting_at_hex) {
|
if(new_player_at_hex != player_starting_at_hex) {
|
||||||
if(!new_player_at_hex) {
|
if(!new_player_at_hex) {
|
||||||
|
@ -432,7 +432,7 @@ editor_action* mouse_action_starting_position::up_left(editor_display& disp, int
|
||||||
editor_action* mouse_action_starting_position::click_left(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_action* mouse_action_starting_position::click_left(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
click_ = true;
|
click_ = true;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_starting_position::up_right(editor_display& disp, int x, int y)
|
editor_action* mouse_action_starting_position::up_right(editor_display& disp, int x, int y)
|
||||||
|
@ -442,13 +442,13 @@ editor_action* mouse_action_starting_position::up_right(editor_display& disp, in
|
||||||
if (player_starting_at_hex != -1) {
|
if (player_starting_at_hex != -1) {
|
||||||
return new editor_action_starting_position(map_location(), player_starting_at_hex);
|
return new editor_action_starting_position(map_location(), player_starting_at_hex);
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_starting_position::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_action* mouse_action_starting_position::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_action_starting_position::set_mouse_overlay(editor_display& disp)
|
void mouse_action_starting_position::set_mouse_overlay(editor_display& disp)
|
||||||
|
@ -459,7 +459,7 @@ void mouse_action_starting_position::set_mouse_overlay(editor_display& disp)
|
||||||
surface image = create_neutral_surface(72,72);
|
surface image = create_neutral_surface(72,72);
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||||
blit_surface(image60, NULL, image, &r);
|
blit_surface(image60, nullptr, image, &r);
|
||||||
|
|
||||||
Uint8 alpha = 196;
|
Uint8 alpha = 196;
|
||||||
int size = image->w;
|
int size = image->w;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
mouse_action(common_palette& palette, const CKey& key)
|
mouse_action(common_palette& palette, const CKey& key)
|
||||||
: previous_move_hex_()
|
: previous_move_hex_()
|
||||||
, key_(key)
|
, key_(key)
|
||||||
, toolbar_button_(NULL)
|
, toolbar_button_(nullptr)
|
||||||
, palette_(palette)
|
, palette_(palette)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,12 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
* the current action. Should always be nullptr or point to a valid menu.
|
||||||
*/
|
*/
|
||||||
void set_toolbar_button(const theme::menu* value) { toolbar_button_ = value; }
|
void set_toolbar_button(const theme::menu* value) { toolbar_button_ = value; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the (possibly NULL) associated menu/button.
|
* Getter for the (possibly nullptr) associated menu/button.
|
||||||
*/
|
*/
|
||||||
const theme::menu* toolbar_button() const { return toolbar_button_; }
|
const theme::menu* toolbar_button() const { return toolbar_button_; }
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Left click displays a player-number-selector dialog and then creates an action
|
* 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.
|
* or returns nullptr if cancel was pressed or there would be no change.
|
||||||
* Do this on mouse up to avoid drag issue.
|
* Do this on mouse up to avoid drag issue.
|
||||||
*/
|
*/
|
||||||
editor_action* up_left(editor_display& disp, int x, int y);
|
editor_action* up_left(editor_display& disp, int x, int y);
|
||||||
|
|
|
@ -47,7 +47,7 @@ void mouse_action_item::move(editor_display& disp, const map_location& hex)
|
||||||
// const item_map::const_item_iterator item_it = items.find(hex);
|
// const item_map::const_item_iterator item_it = items.find(hex);
|
||||||
// if (item_it != items.end()) {
|
// if (item_it != items.end()) {
|
||||||
//
|
//
|
||||||
// disp.set_mouseover_hex_overlay(NULL);
|
// disp.set_mouseover_hex_overlay(nullptr);
|
||||||
//
|
//
|
||||||
// SDL_Rect rect;
|
// SDL_Rect rect;
|
||||||
// rect.x = disp.get_location_x(hex);
|
// rect.x = disp.get_location_x(hex);
|
||||||
|
@ -71,7 +71,7 @@ editor_action* mouse_action_item::click_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
start_hex_ = disp.hex_clicked_on(x, y);
|
start_hex_ = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(start_hex_)) {
|
if (!disp.get_map().on_board(start_hex_)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const overlay& item = item_palette_.selected_fg_item();
|
const overlay& item = item_palette_.selected_fg_item();
|
||||||
|
@ -84,23 +84,23 @@ editor_action* mouse_action_item::click_left(editor_display& disp, int x, int y)
|
||||||
// set_item_mouse_overlay(disp, item_it->type());
|
// set_item_mouse_overlay(disp, item_it->type());
|
||||||
|
|
||||||
click_ = true;
|
click_ = true;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_item::drag_left(editor_display& disp, int x, int y, bool& /*partial*/, editor_action* /*last_undo*/)
|
editor_action* mouse_action_item::drag_left(editor_display& disp, int x, int y, bool& /*partial*/, editor_action* /*last_undo*/)
|
||||||
{
|
{
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
click_ = (hex == start_hex_);
|
click_ = (hex == start_hex_);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_item::up_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_item::up_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (!click_) return NULL;
|
if (!click_) return nullptr;
|
||||||
click_ = false;
|
click_ = false;
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex)) {
|
if (!disp.get_map().on_board(hex)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// item_type type = item_palette_.selected_fg_item();
|
// item_type type = item_palette_.selected_fg_item();
|
||||||
|
@ -113,7 +113,7 @@ editor_action* mouse_action_item::up_left(editor_display& disp, int x, int y)
|
||||||
// if (!new_item_type) {
|
// if (!new_item_type) {
|
||||||
// //TODO rewrite the error message.
|
// //TODO rewrite the error message.
|
||||||
// ERR_ED << "create item dialog returned inexistent or unusable item_type id '" << type_id << "'" << std::endl;
|
// ERR_ED << "create item dialog returned inexistent or unusable item_type id '" << type_id << "'" << std::endl;
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// const item_type &ut = *new_item_type;
|
// const item_type &ut = *new_item_type;
|
||||||
|
@ -123,22 +123,22 @@ editor_action* mouse_action_item::up_left(editor_display& disp, int x, int y)
|
||||||
// editor_action* action = new editor_action_item(hex, new_item);
|
// editor_action* action = new editor_action_item(hex, new_item);
|
||||||
// return action;
|
// return action;
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_item::drag_end_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_item::drag_end_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (click_) return NULL;
|
if (click_) return nullptr;
|
||||||
editor_action* action = NULL;
|
editor_action* action = nullptr;
|
||||||
|
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex))
|
if (!disp.get_map().on_board(hex))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
// const item_map& items = disp.get_items();
|
// const item_map& items = disp.get_items();
|
||||||
// const item_map::const_item_iterator item_it = items.find(start_hex_);
|
// const item_map::const_item_iterator item_it = items.find(start_hex_);
|
||||||
// if (item_it == items.end())
|
// if (item_it == items.end())
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
|
|
||||||
action = new editor_action_item_replace(start_hex_, hex);
|
action = new editor_action_item_replace(start_hex_, hex);
|
||||||
return action;
|
return action;
|
||||||
|
@ -159,7 +159,7 @@ editor_action* mouse_action_item::click_right(editor_display& disp, int x, int y
|
||||||
}
|
}
|
||||||
|
|
||||||
click_ = true;
|
click_ = true;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ editor_action* mouse_action_item::click_right(editor_display& disp, int x, int y
|
||||||
//{
|
//{
|
||||||
// map_location hex = disp.hex_clicked_on(x, y);
|
// map_location hex = disp.hex_clicked_on(x, y);
|
||||||
// if (previous_move_hex_ == hex)
|
// if (previous_move_hex_ == hex)
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//
|
//
|
||||||
// click_ = (start_hex_ == hex);
|
// click_ = (start_hex_ == hex);
|
||||||
// previous_move_hex_ = hex;
|
// previous_move_hex_ = hex;
|
||||||
|
@ -185,12 +185,12 @@ editor_action* mouse_action_item::click_right(editor_display& disp, int x, int y
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//editor_action* mouse_action_item::up_right(editor_display& disp, int /*x*/, int /*y*/)
|
//editor_action* mouse_action_item::up_right(editor_display& disp, int /*x*/, int /*y*/)
|
||||||
//{
|
//{
|
||||||
// if (!click_) return NULL;
|
// if (!click_) return nullptr;
|
||||||
// click_ = false;
|
// click_ = false;
|
||||||
//
|
//
|
||||||
// const item_map& items = disp.get_items();
|
// const item_map& items = disp.get_items();
|
||||||
|
@ -199,16 +199,16 @@ editor_action* mouse_action_item::click_right(editor_display& disp, int x, int y
|
||||||
// return new editor_action_item_delete(start_hex_);
|
// return new editor_action_item_delete(start_hex_);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//editor_action* mouse_action_item::drag_end_right(editor_display& disp, int x, int y)
|
//editor_action* mouse_action_item::drag_end_right(editor_display& disp, int x, int y)
|
||||||
//{
|
//{
|
||||||
// if (click_) return NULL;
|
// if (click_) return nullptr;
|
||||||
//
|
//
|
||||||
// map_location hex = disp.hex_clicked_on(x, y);
|
// map_location hex = disp.hex_clicked_on(x, y);
|
||||||
// if (!disp.get_map().on_board(hex))
|
// if (!disp.get_map().on_board(hex))
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//
|
//
|
||||||
// if(new_direction_ != old_direction_) {
|
// if(new_direction_ != old_direction_) {
|
||||||
//
|
//
|
||||||
|
@ -219,7 +219,7 @@ editor_action* mouse_action_item::click_right(editor_display& disp, int x, int y
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
editor_action* drag_end_left(editor_display& disp, int x, int y);
|
editor_action* drag_end_left(editor_display& disp, int x, int y);
|
||||||
|
|
||||||
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {
|
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set_mouse_overlay(editor_display& disp);
|
virtual void set_mouse_overlay(editor_display& disp);
|
||||||
|
|
|
@ -41,10 +41,10 @@ editor_action* mouse_action_map_label::drag_left(editor_display& disp, int x, in
|
||||||
|
|
||||||
/* Cursor is still on old hex field */
|
/* Cursor is still on old hex field */
|
||||||
if (hex == last_draged_)
|
if (hex == last_draged_)
|
||||||
return NULL;
|
return nullptr;
|
||||||
click_ = false;
|
click_ = false;
|
||||||
|
|
||||||
editor_action_chain* chain = NULL;
|
editor_action_chain* chain = nullptr;
|
||||||
const terrain_label* label = get_current_labels()->get_label(last_draged_);
|
const terrain_label* label = get_current_labels()->get_label(last_draged_);
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ editor_action* mouse_action_map_label::drag_left(editor_display& disp, int x, in
|
||||||
|
|
||||||
editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (!click_) return NULL;
|
if (!click_) return nullptr;
|
||||||
click_ = false;
|
click_ = false;
|
||||||
|
|
||||||
const map_location hex = disp.hex_clicked_on(x, y);
|
const map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex)) {
|
if (!disp.get_map().on_board(hex)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const terrain_label* old_label = editor::get_current_labels()->get_label(hex);
|
const terrain_label* old_label = editor::get_current_labels()->get_label(hex);
|
||||||
|
@ -80,7 +80,7 @@ editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int
|
||||||
|
|
||||||
gui2::teditor_edit_label d(label, immutable, visible_fog, visible_shroud, color, category);
|
gui2::teditor_edit_label d(label, immutable, visible_fog, visible_shroud, color, category);
|
||||||
|
|
||||||
editor_action* a = NULL;
|
editor_action* a = nullptr;
|
||||||
if(d.show(disp.video())) {
|
if(d.show(disp.video())) {
|
||||||
a = new editor_action_label(hex, label, team_name, color
|
a = new editor_action_label(hex, label, team_name, color
|
||||||
, visible_fog, visible_shroud, immutable, category);
|
, visible_fog, visible_shroud, immutable, category);
|
||||||
|
@ -91,7 +91,7 @@ editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int
|
||||||
|
|
||||||
editor_action* mouse_action_map_label::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_action* mouse_action_map_label::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_map_label::up_right(editor_display& disp, int x, int y)
|
editor_action* mouse_action_map_label::up_right(editor_display& disp, int x, int y)
|
||||||
|
@ -101,7 +101,7 @@ editor_action* mouse_action_map_label::up_right(editor_display& disp, int x, int
|
||||||
//TODO
|
//TODO
|
||||||
// const terrain_label* clicked_label = disp.map().get_map_labels().get_label(hex);
|
// const terrain_label* clicked_label = disp.map().get_map_labels().get_label(hex);
|
||||||
//if (!clicked_label)
|
//if (!clicked_label)
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
|
|
||||||
return new editor_action_label_delete(hex);
|
return new editor_action_label_delete(hex);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ void mouse_action_map_label::set_mouse_overlay(editor_display& disp)
|
||||||
surface image = create_neutral_surface(72,72);
|
surface image = create_neutral_surface(72,72);
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||||
blit_surface(image60, NULL, image, &r);
|
blit_surface(image60, nullptr, image, &r);
|
||||||
|
|
||||||
Uint8 alpha = 196;
|
Uint8 alpha = 196;
|
||||||
int size = image->w;
|
int size = image->w;
|
||||||
|
|
|
@ -49,12 +49,12 @@ editor_action* mouse_action_select::click_perform_left(
|
||||||
editor_action* mouse_action_select::click_perform_right(
|
editor_action* mouse_action_select::click_perform_right(
|
||||||
editor_display& /*disp*/, const std::set<map_location>& /*hexes*/)
|
editor_display& /*disp*/, const std::set<map_location>& /*hexes*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_select::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
editor_action* mouse_action_select::click_right(editor_display& /*disp*/, int /*x*/, int /*y*/)
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mouse_action_select::set_mouse_overlay(editor_display& disp)
|
void mouse_action_select::set_mouse_overlay(editor_display& disp)
|
||||||
|
|
|
@ -50,7 +50,7 @@ void mouse_action_unit::move(editor_display& disp, const map_location& hex)
|
||||||
const unit_map::const_unit_iterator unit_it = units.find(hex);
|
const unit_map::const_unit_iterator unit_it = units.find(hex);
|
||||||
if (unit_it != units.end()) {
|
if (unit_it != units.end()) {
|
||||||
|
|
||||||
disp.set_mouseover_hex_overlay(NULL);
|
disp.set_mouseover_hex_overlay(nullptr);
|
||||||
|
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
rect.x = disp.get_location_x(hex);
|
rect.x = disp.get_location_x(hex);
|
||||||
|
@ -77,7 +77,7 @@ editor_action* mouse_action_unit::click_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
start_hex_ = disp.hex_clicked_on(x, y);
|
start_hex_ = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(start_hex_)) {
|
if (!disp.get_map().on_board(start_hex_)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unit_map& units = disp.get_units();
|
const unit_map& units = disp.get_units();
|
||||||
|
@ -86,23 +86,23 @@ editor_action* mouse_action_unit::click_left(editor_display& disp, int x, int y)
|
||||||
set_unit_mouse_overlay(disp, unit_it->type());
|
set_unit_mouse_overlay(disp, unit_it->type());
|
||||||
|
|
||||||
click_ = true;
|
click_ = true;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_unit::drag_left(editor_display& disp, int x, int y, bool& /*partial*/, editor_action* /*last_undo*/)
|
editor_action* mouse_action_unit::drag_left(editor_display& disp, int x, int y, bool& /*partial*/, editor_action* /*last_undo*/)
|
||||||
{
|
{
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
click_ = (hex == start_hex_);
|
click_ = (hex == start_hex_);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* mouse_action_unit::up_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_unit::up_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (!click_) return NULL;
|
if (!click_) return nullptr;
|
||||||
click_ = false;
|
click_ = false;
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex)) {
|
if (!disp.get_map().on_board(hex)) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
unit_type type = unit_palette_.selected_fg_item();
|
unit_type type = unit_palette_.selected_fg_item();
|
||||||
|
@ -115,7 +115,7 @@ editor_action* mouse_action_unit::up_left(editor_display& disp, int x, int y)
|
||||||
if (!new_unit_type) {
|
if (!new_unit_type) {
|
||||||
//TODO rewrite the error message.
|
//TODO rewrite the error message.
|
||||||
ERR_ED << "create unit dialog returned inexistent or unusable unit_type id '" << type_id << "'" << std::endl;
|
ERR_ED << "create unit dialog returned inexistent or unusable unit_type id '" << type_id << "'" << std::endl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unit_type &ut = *new_unit_type;
|
const unit_type &ut = *new_unit_type;
|
||||||
|
@ -128,17 +128,17 @@ editor_action* mouse_action_unit::up_left(editor_display& disp, int x, int y)
|
||||||
|
|
||||||
editor_action* mouse_action_unit::drag_end_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_unit::drag_end_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
if (click_) return NULL;
|
if (click_) return nullptr;
|
||||||
editor_action* action = NULL;
|
editor_action* action = nullptr;
|
||||||
|
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex))
|
if (!disp.get_map().on_board(hex))
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
const unit_map& units = disp.get_units();
|
const unit_map& units = disp.get_units();
|
||||||
const unit_map::const_unit_iterator unit_it = units.find(start_hex_);
|
const unit_map::const_unit_iterator unit_it = units.find(start_hex_);
|
||||||
if (unit_it == units.end())
|
if (unit_it == units.end())
|
||||||
return NULL;
|
return nullptr;
|
||||||
|
|
||||||
action = new editor_action_unit_replace(start_hex_, hex);
|
action = new editor_action_unit_replace(start_hex_, hex);
|
||||||
return action;
|
return action;
|
||||||
|
@ -159,7 +159,7 @@ editor_action* mouse_action_unit::click_right(editor_display& disp, int x, int y
|
||||||
}
|
}
|
||||||
|
|
||||||
click_ = true;
|
click_ = true;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ editor_action* mouse_action_unit::click_right(editor_display& disp, int x, int y
|
||||||
//{
|
//{
|
||||||
// map_location hex = disp.hex_clicked_on(x, y);
|
// map_location hex = disp.hex_clicked_on(x, y);
|
||||||
// if (previous_move_hex_ == hex)
|
// if (previous_move_hex_ == hex)
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//
|
//
|
||||||
// click_ = (start_hex_ == hex);
|
// click_ = (start_hex_ == hex);
|
||||||
// previous_move_hex_ = hex;
|
// previous_move_hex_ = hex;
|
||||||
|
@ -185,12 +185,12 @@ editor_action* mouse_action_unit::click_right(editor_display& disp, int x, int y
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//editor_action* mouse_action_unit::up_right(editor_display& disp, int /*x*/, int /*y*/)
|
//editor_action* mouse_action_unit::up_right(editor_display& disp, int /*x*/, int /*y*/)
|
||||||
//{
|
//{
|
||||||
// if (!click_) return NULL;
|
// if (!click_) return nullptr;
|
||||||
// click_ = false;
|
// click_ = false;
|
||||||
//
|
//
|
||||||
// const unit_map& units = disp.get_units();
|
// const unit_map& units = disp.get_units();
|
||||||
|
@ -199,16 +199,16 @@ editor_action* mouse_action_unit::click_right(editor_display& disp, int x, int y
|
||||||
// return new editor_action_unit_delete(start_hex_);
|
// return new editor_action_unit_delete(start_hex_);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//editor_action* mouse_action_unit::drag_end_right(editor_display& disp, int x, int y)
|
//editor_action* mouse_action_unit::drag_end_right(editor_display& disp, int x, int y)
|
||||||
//{
|
//{
|
||||||
// if (click_) return NULL;
|
// if (click_) return nullptr;
|
||||||
//
|
//
|
||||||
// map_location hex = disp.hex_clicked_on(x, y);
|
// map_location hex = disp.hex_clicked_on(x, y);
|
||||||
// if (!disp.get_map().on_board(hex))
|
// if (!disp.get_map().on_board(hex))
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//
|
//
|
||||||
// if(new_direction_ != old_direction_) {
|
// if(new_direction_ != old_direction_) {
|
||||||
//
|
//
|
||||||
|
@ -219,7 +219,7 @@ editor_action* mouse_action_unit::click_right(editor_display& disp, int x, int y
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return NULL;
|
// return nullptr;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
editor_action* drag_end_left(editor_display& disp, int x, int y);
|
editor_action* drag_end_left(editor_display& disp, int x, int y);
|
||||||
|
|
||||||
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {
|
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set_mouse_overlay(editor_display& disp);
|
virtual void set_mouse_overlay(editor_display& disp);
|
||||||
|
|
|
@ -22,8 +22,8 @@ namespace editor {
|
||||||
editor_action* mouse_action_village::up_left(editor_display& disp, int x, int y)
|
editor_action* mouse_action_village::up_left(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex)) return NULL;
|
if (!disp.get_map().on_board(hex)) return nullptr;
|
||||||
if (!disp.get_map().is_village(hex)) return NULL;
|
if (!disp.get_map().is_village(hex)) return nullptr;
|
||||||
|
|
||||||
return new editor_action_village(hex, disp.playing_team());
|
return new editor_action_village(hex, disp.playing_team());
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ editor_action* mouse_action_village::up_left(editor_display& disp, int x, int y)
|
||||||
editor_action* mouse_action_village::up_right(editor_display& disp, int x, int y)
|
editor_action* mouse_action_village::up_right(editor_display& disp, int x, int y)
|
||||||
{
|
{
|
||||||
map_location hex = disp.hex_clicked_on(x, y);
|
map_location hex = disp.hex_clicked_on(x, y);
|
||||||
if (!disp.get_map().on_board(hex)) return NULL;
|
if (!disp.get_map().on_board(hex)) return nullptr;
|
||||||
if (!disp.get_map().is_village(hex)) return NULL;
|
if (!disp.get_map().is_village(hex)) return nullptr;
|
||||||
|
|
||||||
return new editor_action_village_delete(hex);
|
return new editor_action_village_delete(hex);
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void mouse_action_village::set_mouse_overlay(editor_display& disp)
|
||||||
surface image = create_neutral_surface(72,72);
|
surface image = create_neutral_surface(72,72);
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
SDL_Rect r = sdl::create_rect(6, 6, 0, 0);
|
||||||
blit_surface(image60, NULL, image, &r);
|
blit_surface(image60, nullptr, image, &r);
|
||||||
|
|
||||||
Uint8 alpha = 196;
|
Uint8 alpha = 196;
|
||||||
int size = image->w;
|
int size = image->w;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* No action.
|
* No action.
|
||||||
*/
|
*/
|
||||||
editor_action* click_left(editor_display& /*disp*/, int /*x*/, int /*y*/) {return NULL;}
|
editor_action* click_left(editor_display& /*disp*/, int /*x*/, int /*y*/) {return nullptr;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If clicked on a village hex field, assigns the ownership of it to the current side.
|
* If clicked on a village hex field, assigns the ownership of it to the current side.
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* No action.
|
* No action.
|
||||||
*/
|
*/
|
||||||
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {return NULL;}
|
editor_action* click_right(editor_display& /*disp*/, int /*x*/, int /*y*/) {return nullptr;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If clicked on a village hex field, unassigns it's ownership.
|
* If clicked on a village hex field, unassigns it's ownership.
|
||||||
|
|
|
@ -71,10 +71,10 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
|
||||||
, gui_(new editor_display(editor::get_dummy_display_context(), video, *reports_, controller_base::get_theme(game_config, "editor"), config()))
|
, gui_(new editor_display(editor::get_dummy_display_context(), video, *reports_, controller_base::get_theme(game_config, "editor"), config()))
|
||||||
, tods_()
|
, tods_()
|
||||||
, context_manager_(new context_manager(*gui_.get(), game_config_))
|
, context_manager_(new context_manager(*gui_.get(), game_config_))
|
||||||
, toolkit_(NULL)
|
, toolkit_(nullptr)
|
||||||
, tooltip_manager_(video)
|
, tooltip_manager_(video)
|
||||||
, floating_label_manager_(NULL)
|
, floating_label_manager_(nullptr)
|
||||||
, help_manager_(NULL)
|
, help_manager_(nullptr)
|
||||||
, do_quit_(false)
|
, do_quit_(false)
|
||||||
, quit_mode_(EXIT_ERROR)
|
, quit_mode_(EXIT_ERROR)
|
||||||
, music_tracks_()
|
, music_tracks_()
|
||||||
|
@ -163,12 +163,12 @@ void editor_controller::init_music(const config& game_config)
|
||||||
|
|
||||||
editor_controller::~editor_controller()
|
editor_controller::~editor_controller()
|
||||||
{
|
{
|
||||||
resources::units = NULL;
|
resources::units = nullptr;
|
||||||
resources::tod_manager = NULL;
|
resources::tod_manager = nullptr;
|
||||||
resources::teams = NULL;
|
resources::teams = nullptr;
|
||||||
|
|
||||||
resources::classification = NULL;
|
resources::classification = nullptr;
|
||||||
resources::mp_settings = NULL;
|
resources::mp_settings = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXIT_STATUS editor_controller::main_loop()
|
EXIT_STATUS editor_controller::main_loop()
|
||||||
|
@ -738,7 +738,7 @@ bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int i
|
||||||
toolkit_->get_palette_manager()->active_palette().swap();
|
toolkit_->get_palette_manager()->active_palette().swap();
|
||||||
return true;
|
return true;
|
||||||
case HOTKEY_EDITOR_PARTIAL_UNDO:
|
case HOTKEY_EDITOR_PARTIAL_UNDO:
|
||||||
if (dynamic_cast<const editor_action_chain*>(context_manager_->get_map_context().last_undo_action()) != NULL) {
|
if (dynamic_cast<const editor_action_chain*>(context_manager_->get_map_context().last_undo_action()) != nullptr) {
|
||||||
context_manager_->get_map_context().partial_undo();
|
context_manager_->get_map_context().partial_undo();
|
||||||
context_manager_->refresh_after_action();
|
context_manager_->refresh_after_action();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1228,20 +1228,20 @@ void editor_controller::mouse_motion(int x, int y, const bool /*browse*/,
|
||||||
if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
|
if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
|
||||||
map_location hex_clicked = gui().hex_clicked_on(x, y);
|
map_location hex_clicked = gui().hex_clicked_on(x, y);
|
||||||
if (context_manager_->get_map().on_board_with_border(drag_from_hex_) && is_dragging()) {
|
if (context_manager_->get_map().on_board_with_border(drag_from_hex_) && is_dragging()) {
|
||||||
editor_action* a = NULL;
|
editor_action* a = nullptr;
|
||||||
bool partial = false;
|
bool partial = false;
|
||||||
editor_action* last_undo = context_manager_->get_map_context().last_undo_action();
|
editor_action* last_undo = context_manager_->get_map_context().last_undo_action();
|
||||||
if (dragging_left_ && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) != 0) {
|
if (dragging_left_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(1)) != 0) {
|
||||||
if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
|
if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
|
||||||
a = toolkit_->get_mouse_action()->drag_left(*gui_, x, y, partial, last_undo);
|
a = toolkit_->get_mouse_action()->drag_left(*gui_, x, y, partial, last_undo);
|
||||||
} else if (dragging_right_ && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) != 0) {
|
} else if (dragging_right_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(3)) != 0) {
|
||||||
if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
|
if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
|
||||||
a = toolkit_->get_mouse_action()->drag_right(*gui_, x, y, partial, last_undo);
|
a = toolkit_->get_mouse_action()->drag_right(*gui_, x, y, partial, last_undo);
|
||||||
}
|
}
|
||||||
//Partial means that the mouse action has modified the
|
//Partial means that the mouse action has modified the
|
||||||
//last undo action and the controller shouldn't add
|
//last undo action and the controller shouldn't add
|
||||||
//anything to the undo stack (hence a different perform_ call)
|
//anything to the undo stack (hence a different perform_ call)
|
||||||
if (a != NULL) {
|
if (a != nullptr) {
|
||||||
boost::scoped_ptr<editor_action> aa(a);
|
boost::scoped_ptr<editor_action> aa(a);
|
||||||
if (partial) {
|
if (partial) {
|
||||||
context_manager_->get_map_context().perform_partial_action(*a);
|
context_manager_->get_map_context().perform_partial_action(*a);
|
||||||
|
|
|
@ -171,13 +171,13 @@ class editor_controller : public controller_base,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform an action, then delete the action object.
|
* Perform an action, then delete the action object.
|
||||||
* The pointer can be NULL, in which case nothing will happen.
|
* The pointer can be nullptr, in which case nothing will happen.
|
||||||
*/
|
*/
|
||||||
void perform_delete(editor_action* action);
|
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.
|
* and delete the pointer. The pointer can be nullptr, in which case nothing will happen.
|
||||||
*/
|
*/
|
||||||
void perform_refresh_delete(editor_action* action, bool drag_part = false);
|
void perform_refresh_delete(editor_action* action, bool drag_part = false);
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ context_manager::context_manager(editor_display& gui, const config& game_config)
|
||||||
, game_config_(game_config)
|
, game_config_(game_config)
|
||||||
, default_dir_(preferences::editor::default_dir())
|
, default_dir_(preferences::editor::default_dir())
|
||||||
, map_generators_()
|
, map_generators_()
|
||||||
, last_map_generator_(NULL)
|
, last_map_generator_(nullptr)
|
||||||
, current_context_index_(0)
|
, current_context_index_(0)
|
||||||
, auto_update_transitions_(preferences::editor::auto_update_transitions())
|
, auto_update_transitions_(preferences::editor::auto_update_transitions())
|
||||||
, map_contexts_()
|
, map_contexts_()
|
||||||
|
@ -415,7 +415,7 @@ void context_manager::expand_time_menu(std::vector<std::string>& items)
|
||||||
|
|
||||||
tod_manager* tod_m = get_map_context().get_time_manager();
|
tod_manager* tod_m = get_map_context().get_time_manager();
|
||||||
|
|
||||||
assert(tod_m != NULL);
|
assert(tod_m != nullptr);
|
||||||
|
|
||||||
BOOST_FOREACH(const time_of_day& time, tod_m->times()) {
|
BOOST_FOREACH(const time_of_day& time, tod_m->times()) {
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ map_context::map_context(const editor_map& map, const display& disp, bool pure_m
|
||||||
, victory_defeated_(true)
|
, victory_defeated_(true)
|
||||||
, random_time_(false)
|
, random_time_(false)
|
||||||
, active_area_(-1)
|
, active_area_(-1)
|
||||||
, labels_(disp, NULL)
|
, labels_(disp, nullptr)
|
||||||
, units_()
|
, units_()
|
||||||
, teams_()
|
, teams_()
|
||||||
, tod_manager_(new tod_manager(schedule))
|
, tod_manager_(new tod_manager(schedule))
|
||||||
|
@ -96,7 +96,7 @@ map_context::map_context(const config& game_config, const std::string& filename,
|
||||||
, victory_defeated_(true)
|
, victory_defeated_(true)
|
||||||
, random_time_(false)
|
, random_time_(false)
|
||||||
, active_area_(-1)
|
, active_area_(-1)
|
||||||
, labels_(disp, NULL)
|
, labels_(disp, nullptr)
|
||||||
, units_()
|
, units_()
|
||||||
, teams_()
|
, teams_()
|
||||||
, tod_manager_(new tod_manager(game_config.find_child("editor_times", "id", "default")))
|
, tod_manager_(new tod_manager(game_config.find_child("editor_times", "id", "default")))
|
||||||
|
@ -314,7 +314,7 @@ void map_context::load_scenario(const config& game_config)
|
||||||
teams_.push_back(t);
|
teams_.push_back(t);
|
||||||
|
|
||||||
BOOST_FOREACH(config &a_unit, side.child_range("unit")) {
|
BOOST_FOREACH(config &a_unit, side.child_range("unit")) {
|
||||||
map_location loc(a_unit, NULL);
|
map_location loc(a_unit, nullptr);
|
||||||
a_unit["side"] = i;
|
a_unit["side"] = i;
|
||||||
units_.add(loc, unit(a_unit, true) );
|
units_.add(loc, unit(a_unit, true) );
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ void map_context::perform_partial_action(const editor_action& action)
|
||||||
throw editor_logic_exception("Empty undo stack in perform_partial_action()");
|
throw editor_logic_exception("Empty undo stack in perform_partial_action()");
|
||||||
}
|
}
|
||||||
editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action());
|
editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action());
|
||||||
if (undo_chain == NULL) {
|
if (undo_chain == nullptr) {
|
||||||
throw editor_logic_exception("Last undo action not a chain in perform_partial_action()");
|
throw editor_logic_exception("Last undo action not a chain in perform_partial_action()");
|
||||||
}
|
}
|
||||||
editor_action* undo = action.perform(*this);
|
editor_action* undo = action.perform(*this);
|
||||||
|
@ -639,22 +639,22 @@ bool map_context::can_redo() const
|
||||||
|
|
||||||
editor_action* map_context::last_undo_action()
|
editor_action* map_context::last_undo_action()
|
||||||
{
|
{
|
||||||
return undo_stack_.empty() ? NULL : undo_stack_.back();
|
return undo_stack_.empty() ? nullptr : undo_stack_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_action* map_context::last_redo_action()
|
editor_action* map_context::last_redo_action()
|
||||||
{
|
{
|
||||||
return redo_stack_.empty() ? NULL : redo_stack_.back();
|
return redo_stack_.empty() ? nullptr : redo_stack_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const editor_action* map_context::last_undo_action() const
|
const editor_action* map_context::last_undo_action() const
|
||||||
{
|
{
|
||||||
return undo_stack_.empty() ? NULL : undo_stack_.back();
|
return undo_stack_.empty() ? nullptr : undo_stack_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
const editor_action* map_context::last_redo_action() const
|
const editor_action* map_context::last_redo_action() const
|
||||||
{
|
{
|
||||||
return redo_stack_.empty() ? NULL : redo_stack_.back();
|
return redo_stack_.empty() ? nullptr : redo_stack_.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_context::undo()
|
void map_context::undo()
|
||||||
|
@ -688,7 +688,7 @@ void map_context::partial_undo()
|
||||||
throw editor_logic_exception("Empty undo stack in partial_undo()");
|
throw editor_logic_exception("Empty undo stack in partial_undo()");
|
||||||
}
|
}
|
||||||
editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action());
|
editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action());
|
||||||
if (undo_chain == NULL) {
|
if (undo_chain == nullptr) {
|
||||||
throw editor_logic_exception("Last undo action not a chain in partial undo");
|
throw editor_logic_exception("Last undo action not a chain in partial undo");
|
||||||
}
|
}
|
||||||
//a partial undo performs the first action form the current action's action_chain that would be normally performed
|
//a partial undo performs the first action form the current action's action_chain that would be normally performed
|
||||||
|
|
|
@ -341,10 +341,10 @@ public:
|
||||||
/** @return true when redo can be performed, false otherwise */
|
/** @return true when redo can be performed, false otherwise */
|
||||||
bool can_redo() const;
|
bool can_redo() const;
|
||||||
|
|
||||||
/** @return a pointer to the last undo action or NULL if the undo stack is empty */
|
/** @return a pointer to the last undo action or nullptr if the undo stack is empty */
|
||||||
editor_action* last_undo_action();
|
editor_action* last_undo_action();
|
||||||
|
|
||||||
/** @return a pointer to the last redo action or NULL if the undo stack is empty */
|
/** @return a pointer to the last redo action or nullptr if the undo stack is empty */
|
||||||
editor_action* last_redo_action();
|
editor_action* last_redo_action();
|
||||||
|
|
||||||
/** const version of last_undo_action */
|
/** const version of last_undo_action */
|
||||||
|
|
|
@ -375,7 +375,7 @@ void editor_palette<Item>::draw_contents()
|
||||||
//typedef std::map<std::string, Item> item_map_wurscht;
|
//typedef std::map<std::string, Item> item_map_wurscht;
|
||||||
typename item_map::iterator item = item_map_.find(item_id);
|
typename item_map::iterator item = item_map_.find(item_id);
|
||||||
|
|
||||||
surface item_image(NULL);
|
surface item_image(nullptr);
|
||||||
std::stringstream tooltip_text;
|
std::stringstream tooltip_text;
|
||||||
draw_item((*item).second, item_image, tooltip_text);
|
draw_item((*item).second, item_image, tooltip_text);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<gui::widget>* get_widgets() { return NULL; }
|
std::vector<gui::widget>* get_widgets() { return nullptr; }
|
||||||
|
|
||||||
//group
|
//group
|
||||||
virtual void set_group(size_t /*index*/) {}
|
virtual void set_group(size_t /*index*/) {}
|
||||||
|
|
|
@ -68,11 +68,11 @@ void item_palette::draw_item(const overlay& item, surface& image, std::stringstr
|
||||||
filename << item.halo;
|
filename << item.halo;
|
||||||
|
|
||||||
image = image::get_image(filename.str());
|
image = image::get_image(filename.str());
|
||||||
if(image == NULL) {
|
if(image == nullptr) {
|
||||||
tooltip_text << "IMAGE NOT FOUND\n";
|
tooltip_text << "IMAGE NOT FOUND\n";
|
||||||
ERR_ED << "image for item type: '" << filename.str() << "' not found" << std::endl;
|
ERR_ED << "image for item type: '" << filename.str() << "' not found" << std::endl;
|
||||||
image = image::get_image(game_config::images::missing);
|
image = image::get_image(game_config::images::missing);
|
||||||
if (image == NULL) {
|
if (image == nullptr) {
|
||||||
ERR_ED << "Placeholder image not found" << std::endl;
|
ERR_ED << "Placeholder image not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,11 +166,11 @@ void terrain_palette::draw_item(const t_translation::t_terrain& terrain,
|
||||||
const std::string base_filename = map().get_terrain_info(base_terrain).editor_image();
|
const std::string base_filename = map().get_terrain_info(base_terrain).editor_image();
|
||||||
surface base_image(image::get_image(base_filename));
|
surface base_image(image::get_image(base_filename));
|
||||||
|
|
||||||
if(base_image == NULL) {
|
if(base_image == nullptr) {
|
||||||
tooltip_text << "BASE IMAGE NOT FOUND\n";
|
tooltip_text << "BASE IMAGE NOT FOUND\n";
|
||||||
ERR_ED << "image for terrain : '" << base_filename << "' not found" << std::endl;
|
ERR_ED << "image for terrain : '" << base_filename << "' not found" << std::endl;
|
||||||
base_image = image::get_image(game_config::images::missing);
|
base_image = image::get_image(game_config::images::missing);
|
||||||
if (base_image == NULL) {
|
if (base_image == nullptr) {
|
||||||
ERR_ED << "Placeholder image not found" << std::endl;
|
ERR_ED << "Placeholder image not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -184,11 +184,11 @@ void terrain_palette::draw_item(const t_translation::t_terrain& terrain,
|
||||||
|
|
||||||
const std::string filename = map().get_terrain_info(terrain).editor_image();
|
const std::string filename = map().get_terrain_info(terrain).editor_image();
|
||||||
image = image::get_image(filename);
|
image = image::get_image(filename);
|
||||||
if(image == NULL) {
|
if(image == nullptr) {
|
||||||
tooltip_text << "IMAGE NOT FOUND\n";
|
tooltip_text << "IMAGE NOT FOUND\n";
|
||||||
ERR_ED << "image for terrain: '" << filename << "' not found" << std::endl;
|
ERR_ED << "image for terrain: '" << filename << "' not found" << std::endl;
|
||||||
image = image::get_image(game_config::images::missing);
|
image = image::get_image(game_config::images::missing);
|
||||||
if (image == NULL) {
|
if (image == nullptr) {
|
||||||
ERR_ED << "Placeholder image not found" << std::endl;
|
ERR_ED << "Placeholder image not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ tristate_button::tristate_button(CVideo& video,
|
||||||
std::string button_image_name,
|
std::string button_image_name,
|
||||||
const bool auto_join) :
|
const bool auto_join) :
|
||||||
widget(video, auto_join),
|
widget(video, auto_join),
|
||||||
baseImage_(NULL), touchedBaseImage_(NULL), activeBaseImage_(NULL),
|
baseImage_(nullptr), touchedBaseImage_(nullptr), activeBaseImage_(nullptr),
|
||||||
itemImage_(NULL),
|
itemImage_(nullptr),
|
||||||
pressedDownImage_(NULL), pressedUpImage_(NULL), pressedBothImage_(NULL),
|
pressedDownImage_(nullptr), pressedUpImage_(nullptr), pressedBothImage_(nullptr),
|
||||||
pressedBothActiveImage_(NULL), pressedDownActiveImage_(NULL), pressedUpActiveImage_(NULL),
|
pressedBothActiveImage_(nullptr), pressedDownActiveImage_(nullptr), pressedUpActiveImage_(nullptr),
|
||||||
touchedDownImage_(NULL), touchedUpImage_(NULL), touchedBothImage_(NULL),
|
touchedDownImage_(nullptr), touchedUpImage_(nullptr), touchedBothImage_(nullptr),
|
||||||
textRect_(),
|
textRect_(),
|
||||||
state_(NORMAL), pressed_(false),
|
state_(NORMAL), pressed_(false),
|
||||||
base_height_(0), base_width_(0),
|
base_height_(0), base_width_(0),
|
||||||
|
@ -164,9 +164,9 @@ void tristate_button::enable(bool new_val) {
|
||||||
|
|
||||||
void tristate_button::draw_contents() {
|
void tristate_button::draw_contents() {
|
||||||
|
|
||||||
surface image(NULL);
|
surface image(nullptr);
|
||||||
|
|
||||||
surface overlay(NULL);
|
surface overlay(nullptr);
|
||||||
surface base = baseImage_;
|
surface base = baseImage_;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
@ -244,11 +244,11 @@ void tristate_button::draw_contents() {
|
||||||
|
|
||||||
//TODO avoid magic numbers
|
//TODO avoid magic numbers
|
||||||
SDL_Rect r = sdl::create_rect(1, 1, 0, 0);
|
SDL_Rect r = sdl::create_rect(1, 1, 0, 0);
|
||||||
blit_surface(nitem, NULL, nbase, &r);
|
blit_surface(nitem, nullptr, nbase, &r);
|
||||||
|
|
||||||
if (!overlay.null()) {
|
if (!overlay.null()) {
|
||||||
surface noverlay = make_neutral_surface(overlay);
|
surface noverlay = make_neutral_surface(overlay);
|
||||||
blit_surface(noverlay, NULL, nbase, NULL);
|
blit_surface(noverlay, nullptr, nbase, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO for later reference
|
// TODO for later reference
|
||||||
|
|
|
@ -86,11 +86,11 @@ void unit_palette::draw_item(const unit_type& u, surface& image, std::stringstre
|
||||||
<< team::get_side_color_index(gui_.viewing_side()) << ')';
|
<< team::get_side_color_index(gui_.viewing_side()) << ')';
|
||||||
|
|
||||||
image = image::get_image(filename.str());
|
image = image::get_image(filename.str());
|
||||||
if(image == NULL) {
|
if(image == nullptr) {
|
||||||
tooltip_text << "IMAGE NOT FOUND\n";
|
tooltip_text << "IMAGE NOT FOUND\n";
|
||||||
ERR_ED << "image for unit type: '" << filename.str() << "' not found" << std::endl;
|
ERR_ED << "image for unit type: '" << filename.str() << "' not found" << std::endl;
|
||||||
image = image::get_image(game_config::images::missing);
|
image = image::get_image(game_config::images::missing);
|
||||||
if (image == NULL) {
|
if (image == nullptr) {
|
||||||
ERR_ED << "Placeholder image not found" << std::endl;
|
ERR_ED << "Placeholder image not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ editor_toolkit::editor_toolkit(editor_display& gui, const CKey& key,
|
||||||
: gui_(gui)
|
: gui_(gui)
|
||||||
, key_(key)
|
, key_(key)
|
||||||
, palette_manager_()
|
, palette_manager_()
|
||||||
, mouse_action_(NULL)
|
, mouse_action_(nullptr)
|
||||||
, mouse_actions_()
|
, mouse_actions_()
|
||||||
, brush_(NULL)
|
, brush_(nullptr)
|
||||||
, brushes_()
|
, brushes_()
|
||||||
{
|
{
|
||||||
init_brushes(game_config);
|
init_brushes(game_config);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public:
|
||||||
virtual void volatile_draw() {}
|
virtual void volatile_draw() {}
|
||||||
virtual void volatile_undraw() {}
|
virtual void volatile_undraw() {}
|
||||||
|
|
||||||
virtual bool requires_event_focus(const SDL_Event * = NULL) const { return false; }
|
virtual bool requires_event_focus(const SDL_Event * = nullptr) const { return false; }
|
||||||
|
|
||||||
virtual void process_help_string(int /*mousex*/, int /*mousey*/) {}
|
virtual void process_help_string(int /*mousex*/, int /*mousey*/) {}
|
||||||
virtual void process_tooltip_string(int /*mousex*/, int /*mousey*/) {}
|
virtual void process_tooltip_string(int /*mousex*/, int /*mousey*/) {}
|
||||||
|
@ -102,7 +102,7 @@ void peek_for_resize();
|
||||||
struct pump_info {
|
struct pump_info {
|
||||||
pump_info() : resize_dimensions(), ticks_(0) {}
|
pump_info() : resize_dimensions(), ticks_(0) {}
|
||||||
std::pair<int,int> resize_dimensions;
|
std::pair<int,int> resize_dimensions;
|
||||||
int ticks(unsigned *refresh_counter=NULL, unsigned refresh_rate=1);
|
int ticks(unsigned *refresh_counter=nullptr, unsigned refresh_rate=1);
|
||||||
private:
|
private:
|
||||||
int ticks_; //0 if not calculated
|
int ticks_; //0 if not calculated
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
|
|
||||||
#include <boost/swap.hpp>
|
#include <boost/swap.hpp>
|
||||||
|
|
||||||
fake_unit_ptr::fake_unit_ptr() : unit_(), my_manager_(NULL) {}
|
fake_unit_ptr::fake_unit_ptr() : unit_(), my_manager_(nullptr) {}
|
||||||
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u) : unit_(u), my_manager_(NULL) {}
|
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u) : unit_(u), my_manager_(nullptr) {}
|
||||||
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u, fake_unit_manager * mgr) : unit_(u), my_manager_(NULL)
|
fake_unit_ptr::fake_unit_ptr(const internal_ptr & u, fake_unit_manager * mgr) : unit_(u), my_manager_(nullptr)
|
||||||
{
|
{
|
||||||
place_on_fake_unit_manager(mgr);
|
place_on_fake_unit_manager(mgr);
|
||||||
}
|
}
|
||||||
fake_unit_ptr::fake_unit_ptr(const fake_unit_ptr & ptr) : unit_(ptr.unit_), my_manager_(NULL) {}
|
fake_unit_ptr::fake_unit_ptr(const fake_unit_ptr & ptr) : unit_(ptr.unit_), my_manager_(nullptr) {}
|
||||||
|
|
||||||
void fake_unit_ptr::swap (fake_unit_ptr & o) {
|
void fake_unit_ptr::swap (fake_unit_ptr & o) {
|
||||||
boost::swap(unit_, o.unit_);
|
boost::swap(unit_, o.unit_);
|
||||||
|
@ -60,7 +60,7 @@ fake_unit_ptr & fake_unit_ptr::operator=(fake_unit_ptr other) {
|
||||||
this->~fake_unit();
|
this->~fake_unit();
|
||||||
new (this) fake_unit(a);
|
new (this) fake_unit(a);
|
||||||
// Restore our old manager.
|
// Restore our old manager.
|
||||||
if ( mgr != NULL )
|
if ( mgr != nullptr )
|
||||||
place_on_fake_unit_manager(mgr);
|
place_on_fake_unit_manager(mgr);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -113,7 +113,7 @@ fake_unit_ptr::~fake_unit_ptr()
|
||||||
* Duplicate additions are not allowed.
|
* Duplicate additions are not allowed.
|
||||||
*/
|
*/
|
||||||
void fake_unit_ptr::place_on_fake_unit_manager(fake_unit_manager * manager){
|
void fake_unit_ptr::place_on_fake_unit_manager(fake_unit_manager * manager){
|
||||||
assert(my_manager_ == NULL); //Can only be placed on 1 fake_unit_manager
|
assert(my_manager_ == nullptr); //Can only be placed on 1 fake_unit_manager
|
||||||
my_manager_=manager;
|
my_manager_=manager;
|
||||||
my_manager_->place_temporary_unit(unit_.get());
|
my_manager_->place_temporary_unit(unit_.get());
|
||||||
}
|
}
|
||||||
|
@ -125,9 +125,9 @@ void fake_unit_ptr::place_on_fake_unit_manager(fake_unit_manager * manager){
|
||||||
*/
|
*/
|
||||||
int fake_unit_ptr::remove_from_fake_unit_manager(){
|
int fake_unit_ptr::remove_from_fake_unit_manager(){
|
||||||
int ret(0);
|
int ret(0);
|
||||||
if(my_manager_ != NULL){
|
if(my_manager_ != nullptr){
|
||||||
ret = my_manager_->remove_temporary_unit(unit_.get());
|
ret = my_manager_->remove_temporary_unit(unit_.get());
|
||||||
my_manager_=NULL;
|
my_manager_=nullptr;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ file_dialog::file_dialog(CVideo& video, const std::string& file_path,
|
||||||
bool show_directory_buttons) :
|
bool show_directory_buttons) :
|
||||||
gui::dialog(video, title, file_path, gui::OK_CANCEL),
|
gui::dialog(video, title, file_path, gui::OK_CANCEL),
|
||||||
show_directory_buttons_(show_directory_buttons),
|
show_directory_buttons_(show_directory_buttons),
|
||||||
files_list_(NULL),
|
files_list_(nullptr),
|
||||||
last_selection_(-1),
|
last_selection_(-1),
|
||||||
last_textbox_text_(),
|
last_textbox_text_(),
|
||||||
chosen_file_(".."),
|
chosen_file_(".."),
|
||||||
|
|
|
@ -51,7 +51,7 @@ enum file_reorder_option { DONT_REORDER, DO_REORDER };
|
||||||
/**
|
/**
|
||||||
* Populates 'files' with all the files and
|
* Populates 'files' with all the files and
|
||||||
* 'dirs' with all the directories in dir.
|
* 'dirs' with all the directories in dir.
|
||||||
* If files or dirs are NULL they will not be used.
|
* If files or dirs are nullptr they will not be used.
|
||||||
*
|
*
|
||||||
* mode: determines whether the entire path or just the filename is retrieved.
|
* mode: determines whether the entire path or just the filename is retrieved.
|
||||||
* filter: determines if we skip images and sounds directories
|
* filter: determines if we skip images and sounds directories
|
||||||
|
@ -60,11 +60,11 @@ enum file_reorder_option { DONT_REORDER, DO_REORDER };
|
||||||
*/
|
*/
|
||||||
void get_files_in_dir(const std::string &dir,
|
void get_files_in_dir(const std::string &dir,
|
||||||
std::vector<std::string>* files,
|
std::vector<std::string>* files,
|
||||||
std::vector<std::string>* dirs=NULL,
|
std::vector<std::string>* dirs=nullptr,
|
||||||
file_name_option mode = FILE_NAME_ONLY,
|
file_name_option mode = FILE_NAME_ONLY,
|
||||||
file_filter_option filter = NO_FILTER,
|
file_filter_option filter = NO_FILTER,
|
||||||
file_reorder_option reorder = DONT_REORDER,
|
file_reorder_option reorder = DONT_REORDER,
|
||||||
file_tree_checksum* checksum = NULL);
|
file_tree_checksum* checksum = nullptr);
|
||||||
|
|
||||||
std::string get_dir(const std::string &dir);
|
std::string get_dir(const std::string &dir);
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace {
|
||||||
namespace filesystem {
|
namespace filesystem {
|
||||||
|
|
||||||
static void push_if_exists(std::vector<std::string> *vec, const path &file, bool full) {
|
static void push_if_exists(std::vector<std::string> *vec, const path &file, bool full) {
|
||||||
if (vec != NULL) {
|
if (vec != nullptr) {
|
||||||
if (full)
|
if (full)
|
||||||
vec->push_back(file.generic_string());
|
vec->push_back(file.generic_string());
|
||||||
else
|
else
|
||||||
|
@ -353,7 +353,7 @@ void get_files_in_dir(const std::string &dir,
|
||||||
}
|
}
|
||||||
push_if_exists(files, di->path(), mode == ENTIRE_FILE_PATH);
|
push_if_exists(files, di->path(), mode == ENTIRE_FILE_PATH);
|
||||||
|
|
||||||
if (checksum != NULL) {
|
if (checksum != nullptr) {
|
||||||
std::time_t mtime = bfs::last_write_time(di->path(), ec);
|
std::time_t mtime = bfs::last_write_time(di->path(), ec);
|
||||||
if (ec) {
|
if (ec) {
|
||||||
LOG_FS << "Failed to read modification time of " << di->path().string() << ": " << ec.message() << '\n';
|
LOG_FS << "Failed to read modification time of " << di->path().string() << ": " << ec.message() << '\n';
|
||||||
|
@ -391,13 +391,13 @@ void get_files_in_dir(const std::string &dir,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (files != NULL)
|
if (files != nullptr)
|
||||||
std::sort(files->begin(),files->end());
|
std::sort(files->begin(),files->end());
|
||||||
|
|
||||||
if (dirs != NULL)
|
if (dirs != nullptr)
|
||||||
std::sort(dirs->begin(),dirs->end());
|
std::sort(dirs->begin(),dirs->end());
|
||||||
|
|
||||||
if (files != NULL && reorder == DO_REORDER) {
|
if (files != nullptr && reorder == DO_REORDER) {
|
||||||
// move finalcfg_filename, if present, to the end of the vector
|
// move finalcfg_filename, if present, to the end of the vector
|
||||||
for (unsigned int i = 0; i < files->size(); i++) {
|
for (unsigned int i = 0; i < files->size(); i++) {
|
||||||
if (ends_with((*files)[i], "/" + finalcfg_filename)) {
|
if (ends_with((*files)[i], "/" + finalcfg_filename)) {
|
||||||
|
@ -523,8 +523,8 @@ void set_user_data_dir(std::string newprefdir)
|
||||||
|
|
||||||
wchar_t docs_path[MAX_PATH];
|
wchar_t docs_path[MAX_PATH];
|
||||||
|
|
||||||
HRESULT res = SHGetFolderPathW(NULL,
|
HRESULT res = SHGetFolderPathW(nullptr,
|
||||||
CSIDL_PERSONAL | CSIDL_FLAG_CREATE, NULL,
|
CSIDL_PERSONAL | CSIDL_FLAG_CREATE, nullptr,
|
||||||
SHGFP_TYPE_CURRENT,
|
SHGFP_TYPE_CURRENT,
|
||||||
docs_path);
|
docs_path);
|
||||||
if(res != S_OK) {
|
if(res != S_OK) {
|
||||||
|
@ -675,7 +675,7 @@ std::string get_exe_dir()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
wchar_t process_path[MAX_PATH];
|
wchar_t process_path[MAX_PATH];
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
GetModuleFileNameW(NULL, process_path, MAX_PATH);
|
GetModuleFileNameW(nullptr, process_path, MAX_PATH);
|
||||||
if (GetLastError() != ERROR_SUCCESS) {
|
if (GetLastError() != ERROR_SUCCESS) {
|
||||||
return get_cwd();
|
return get_cwd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ static void get_file_tree_checksum_internal(const std::string& path, file_tree_c
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<std::string> dirs;
|
std::vector<std::string> dirs;
|
||||||
get_files_in_dir(path,NULL,&dirs, ENTIRE_FILE_PATH, SKIP_MEDIA_DIR, DONT_REORDER, &res);
|
get_files_in_dir(path,nullptr,&dirs, ENTIRE_FILE_PATH, SKIP_MEDIA_DIR, DONT_REORDER, &res);
|
||||||
|
|
||||||
for(std::vector<std::string>::const_iterator j = dirs.begin(); j != dirs.end(); ++j) {
|
for(std::vector<std::string>::const_iterator j = dirs.begin(); j != dirs.end(); ++j) {
|
||||||
get_file_tree_checksum_internal(*j,res);
|
get_file_tree_checksum_internal(*j,res);
|
||||||
|
@ -218,8 +218,8 @@ SDL_RWops* load_RWops(const std::string &path) {
|
||||||
|
|
||||||
std::istream *ifs = istream_file(path);
|
std::istream *ifs = istream_file(path);
|
||||||
if(!ifs) {
|
if(!ifs) {
|
||||||
ERR_FS << "load_RWops: istream_file returned NULL on " << path << '\n';
|
ERR_FS << "load_RWops: istream_file returned nullptr on " << path << '\n';
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
rw->hidden.unknown.data1 = ifs;
|
rw->hidden.unknown.data1 = ifs;
|
||||||
|
|
|
@ -46,7 +46,7 @@ floating_label::floating_label(const std::string& text, const surface& surf)
|
||||||
#if 0
|
#if 0
|
||||||
: img_(),
|
: img_(),
|
||||||
#else
|
#else
|
||||||
: surf_(surf), buf_(NULL),
|
: surf_(surf), buf_(nullptr),
|
||||||
#endif
|
#endif
|
||||||
text_(text),
|
text_(text),
|
||||||
font_size_(SIZE_NORMAL),
|
font_size_(SIZE_NORMAL),
|
||||||
|
@ -96,7 +96,7 @@ sdl::timage floating_label::create_image()
|
||||||
|
|
||||||
surface foreground = text.render();
|
surface foreground = text.render();
|
||||||
|
|
||||||
if(foreground == NULL) {
|
if(foreground == nullptr) {
|
||||||
ERR_FT << "could not create floating label's text" << std::endl;
|
ERR_FT << "could not create floating label's text" << std::endl;
|
||||||
return sdl::timage();
|
return sdl::timage();
|
||||||
}
|
}
|
||||||
|
@ -106,14 +106,14 @@ sdl::timage floating_label::create_image()
|
||||||
// background is a dark tooltip box
|
// background is a dark tooltip box
|
||||||
surface background = create_neutral_surface(foreground->w + border_*2, foreground->h + border_*2);
|
surface background = create_neutral_surface(foreground->w + border_*2, foreground->h + border_*2);
|
||||||
|
|
||||||
if (background == NULL) {
|
if (background == nullptr) {
|
||||||
ERR_FT << "could not create tooltip box" << std::endl;
|
ERR_FT << "could not create tooltip box" << std::endl;
|
||||||
img_ = sdl::timage(foreground);
|
img_ = sdl::timage(foreground);
|
||||||
return img_;
|
return img_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 color = SDL_MapRGBA(foreground->format, bgcolor_.r,bgcolor_.g, bgcolor_.b, bgalpha_);
|
Uint32 color = SDL_MapRGBA(foreground->format, bgcolor_.r,bgcolor_.g, bgcolor_.b, bgalpha_);
|
||||||
sdl::fill_rect(background,NULL, color);
|
sdl::fill_rect(background,nullptr, color);
|
||||||
|
|
||||||
// we make the text less transparent, because the blitting on the
|
// we make the text less transparent, because the blitting on the
|
||||||
// dark background will darken the anti-aliased part.
|
// dark background will darken the anti-aliased part.
|
||||||
|
@ -123,7 +123,7 @@ sdl::timage floating_label::create_image()
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
||||||
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
|
|
||||||
img_ = sdl::timage(background);
|
img_ = sdl::timage(background);
|
||||||
}
|
}
|
||||||
|
@ -131,18 +131,18 @@ sdl::timage floating_label::create_image()
|
||||||
// background is blurred shadow of the text
|
// background is blurred shadow of the text
|
||||||
surface background = create_neutral_surface
|
surface background = create_neutral_surface
|
||||||
(foreground->w + 4, foreground->h + 4);
|
(foreground->w + 4, foreground->h + 4);
|
||||||
sdl::fill_rect(background, NULL, 0);
|
sdl::fill_rect(background, nullptr, 0);
|
||||||
SDL_Rect r = { 2, 2, 0, 0 };
|
SDL_Rect r = { 2, 2, 0, 0 };
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
background = shadow_image(background, false);
|
background = shadow_image(background, false);
|
||||||
|
|
||||||
if (background == NULL) {
|
if (background == nullptr) {
|
||||||
ERR_FT << "could not create floating label's shadow" << std::endl;
|
ERR_FT << "could not create floating label's shadow" << std::endl;
|
||||||
img_ = sdl::timage(foreground);
|
img_ = sdl::timage(foreground);
|
||||||
return img_;
|
return img_;
|
||||||
}
|
}
|
||||||
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
img_ = sdl::timage(background);
|
img_ = sdl::timage(background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,9 +169,9 @@ surface floating_label::create_surface()
|
||||||
|
|
||||||
surface foreground = text.render();
|
surface foreground = text.render();
|
||||||
|
|
||||||
if(foreground == NULL) {
|
if(foreground == nullptr) {
|
||||||
ERR_FT << "could not create floating label's text" << std::endl;
|
ERR_FT << "could not create floating label's text" << std::endl;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// combine foreground text with its background
|
// combine foreground text with its background
|
||||||
|
@ -179,14 +179,14 @@ surface floating_label::create_surface()
|
||||||
// background is a dark tooltip box
|
// background is a dark tooltip box
|
||||||
surface background = create_neutral_surface(foreground->w + border_*2, foreground->h + border_*2);
|
surface background = create_neutral_surface(foreground->w + border_*2, foreground->h + border_*2);
|
||||||
|
|
||||||
if (background == NULL) {
|
if (background == nullptr) {
|
||||||
ERR_FT << "could not create tooltip box" << std::endl;
|
ERR_FT << "could not create tooltip box" << std::endl;
|
||||||
surf_ = create_optimized_surface(foreground);
|
surf_ = create_optimized_surface(foreground);
|
||||||
return surf_;
|
return surf_;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 color = SDL_MapRGBA(foreground->format, bgcolor_.r,bgcolor_.g, bgcolor_.b, bgalpha_);
|
Uint32 color = SDL_MapRGBA(foreground->format, bgcolor_.r,bgcolor_.g, bgcolor_.b, bgalpha_);
|
||||||
sdl::fill_rect(background,NULL, color);
|
sdl::fill_rect(background,nullptr, color);
|
||||||
|
|
||||||
// we make the text less transparent, because the blitting on the
|
// we make the text less transparent, because the blitting on the
|
||||||
// dark background will darken the anti-aliased part.
|
// dark background will darken the anti-aliased part.
|
||||||
|
@ -196,7 +196,7 @@ surface floating_label::create_surface()
|
||||||
|
|
||||||
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
SDL_Rect r = sdl::create_rect( border_, border_, 0, 0);
|
||||||
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
|
|
||||||
surf_ = create_optimized_surface(background);
|
surf_ = create_optimized_surface(background);
|
||||||
// RLE compression seems less efficient for big semi-transparent area
|
// RLE compression seems less efficient for big semi-transparent area
|
||||||
|
@ -207,18 +207,18 @@ surface floating_label::create_surface()
|
||||||
// background is blurred shadow of the text
|
// background is blurred shadow of the text
|
||||||
surface background = create_neutral_surface
|
surface background = create_neutral_surface
|
||||||
(foreground->w + 4, foreground->h + 4);
|
(foreground->w + 4, foreground->h + 4);
|
||||||
sdl::fill_rect(background, NULL, 0);
|
sdl::fill_rect(background, nullptr, 0);
|
||||||
SDL_Rect r = { 2, 2, 0, 0 };
|
SDL_Rect r = { 2, 2, 0, 0 };
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
background = shadow_image(background, false);
|
background = shadow_image(background, false);
|
||||||
|
|
||||||
if (background == NULL) {
|
if (background == nullptr) {
|
||||||
ERR_FT << "could not create floating label's shadow" << std::endl;
|
ERR_FT << "could not create floating label's shadow" << std::endl;
|
||||||
surf_ = create_optimized_surface(foreground);
|
surf_ = create_optimized_surface(foreground);
|
||||||
return surf_;
|
return surf_;
|
||||||
}
|
}
|
||||||
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
SDL_SetAlpha(foreground,SDL_SRCALPHA,SDL_ALPHA_OPAQUE);
|
||||||
blit_surface(foreground, NULL, background, &r);
|
blit_surface(foreground, nullptr, background, &r);
|
||||||
surf_ = create_optimized_surface(background);
|
surf_ = create_optimized_surface(background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,30 +254,30 @@ void floating_label::draw(CVideo &video)
|
||||||
void floating_label::draw(surface screen)
|
void floating_label::draw(surface screen)
|
||||||
{
|
{
|
||||||
if(!visible_) {
|
if(!visible_) {
|
||||||
buf_.assign(NULL);
|
buf_.assign(nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(screen == NULL) {
|
if(screen == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_surface();
|
create_surface();
|
||||||
if(surf_ == NULL) {
|
if(surf_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(buf_ == NULL) {
|
if(buf_ == nullptr) {
|
||||||
buf_.assign(create_compatible_surface(screen, surf_->w, surf_->h));
|
buf_.assign(create_compatible_surface(screen, surf_->w, surf_->h));
|
||||||
if(buf_ == NULL) {
|
if(buf_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||||
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
||||||
sdl_copy_portion(screen,&rect,buf_,NULL);
|
sdl_copy_portion(screen,&rect,buf_,nullptr);
|
||||||
sdl_blit(surf_,NULL,screen,&rect);
|
sdl_blit(surf_,nullptr,screen,&rect);
|
||||||
|
|
||||||
update_rect(rect);
|
update_rect(rect);
|
||||||
}
|
}
|
||||||
|
@ -292,19 +292,19 @@ void floating_label::undraw(CVideo &video)
|
||||||
#else
|
#else
|
||||||
void floating_label::undraw(surface screen)
|
void floating_label::undraw(surface screen)
|
||||||
{
|
{
|
||||||
if(screen == NULL || buf_ == NULL) {
|
if(screen == nullptr || buf_ == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
SDL_Rect rect = sdl::create_rect(xpos(surf_->w), ypos_, surf_->w, surf_->h);
|
||||||
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
const clip_rect_setter clip_setter(screen, &clip_rect_);
|
||||||
sdl_blit(buf_,NULL,screen,&rect);
|
sdl_blit(buf_,nullptr,screen,&rect);
|
||||||
|
|
||||||
update_rect(rect);
|
update_rect(rect);
|
||||||
|
|
||||||
move(xmove_,ymove_);
|
move(xmove_,ymove_);
|
||||||
if(lifetime_ > 0) {
|
if(lifetime_ > 0) {
|
||||||
--lifetime_;
|
--lifetime_;
|
||||||
if(alpha_change_ != 0 && (xmove_ != 0.0 || ymove_ != 0.0) && surf_ != NULL) {
|
if(alpha_change_ != 0 && (xmove_ != 0.0 || ymove_ != 0.0) && surf_ != nullptr) {
|
||||||
// fade out moving floating labels
|
// fade out moving floating labels
|
||||||
// note that we don't optimize these surfaces since they will always change
|
// note that we don't optimize these surfaces since they will always change
|
||||||
surf_.assign(adjust_surface_alpha_add(surf_,alpha_change_,false));
|
surf_.assign(adjust_surface_alpha_add(surf_,alpha_change_,false));
|
||||||
|
@ -375,7 +375,7 @@ SDL_Rect get_floating_label_rect(int handle)
|
||||||
#else
|
#else
|
||||||
if(i != labels.end()) {
|
if(i != labels.end()) {
|
||||||
const surface surf = i->second.create_surface();
|
const surface surf = i->second.create_surface();
|
||||||
if(surf != NULL) {
|
if(surf != nullptr) {
|
||||||
return sdl::create_rect(0, 0, surf->w, surf->h);
|
return sdl::create_rect(0, 0, surf->w, surf->h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,8 +388,8 @@ floating_label_context::floating_label_context()
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
|
|
||||||
#else
|
#else
|
||||||
surface const screen = NULL;
|
surface const screen = nullptr;
|
||||||
if(screen != NULL) {
|
if(screen != nullptr) {
|
||||||
draw_floating_labels(screen);
|
draw_floating_labels(screen);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -409,8 +409,8 @@ floating_label_context::~floating_label_context()
|
||||||
#ifdef SDL_GPU
|
#ifdef SDL_GPU
|
||||||
//TODO
|
//TODO
|
||||||
#else
|
#else
|
||||||
surface const screen = NULL;
|
surface const screen = nullptr;
|
||||||
if(screen != NULL) {
|
if(screen != nullptr) {
|
||||||
undraw_floating_labels(screen);
|
undraw_floating_labels(screen);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ enum LABEL_SCROLL_MODE { ANCHOR_LABEL_SCREEN, ANCHOR_LABEL_MAP };
|
||||||
class floating_label
|
class floating_label
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
floating_label(const std::string& text, const surface& surface = NULL);
|
floating_label(const std::string& text, const surface& surface = nullptr);
|
||||||
|
|
||||||
void set_font_size(int font_size) {font_size_ = font_size;}
|
void set_font_size(int font_size) {font_size_ = font_size;}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue