Strip trailing whitespace.
This commit is contained in:
parent
31a683cd0f
commit
24c055cd44
43 changed files with 282 additions and 282 deletions
|
@ -234,7 +234,7 @@ protected:
|
|||
private:
|
||||
const std::string &get_available_for_recruiting(
|
||||
const team& my_team);
|
||||
const unit_type *get_unit_type_known(
|
||||
const unit_type *get_unit_type_known(
|
||||
const std::string &recruit);
|
||||
bool test_enough_gold(
|
||||
const team& my_team,
|
||||
|
|
|
@ -320,7 +320,7 @@ static bool image_exists(const n_token::t_token& name)
|
|||
{
|
||||
bool precached = (*name).find("..") == std::string::npos;
|
||||
|
||||
if(precached && image::precached_file_exists(name)) {
|
||||
if(precached && image::precached_file_exists(name)) {
|
||||
return true;
|
||||
} else if(image::exists(name)) {
|
||||
return true;
|
||||
|
@ -351,7 +351,7 @@ static std::vector<n_token::t_token> get_variations(const n_token::t_token& base
|
|||
cbase.replace(pos, 2, (*v));
|
||||
pos += (*v).size();
|
||||
}
|
||||
res.push_back(n_token::t_token(cbase));
|
||||
res.push_back(n_token::t_token(cbase));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ bool terrain_builder::load_images(building_rule &rule)
|
|||
|
||||
const size_t tilde = (*str).find('~');
|
||||
bool has_tilde = tilde != std::string::npos;
|
||||
const n_token::t_token filename = n_token::t_token("terrain/" + (has_tilde ? (*str).substr(0,tilde) : str));
|
||||
const n_token::t_token filename = n_token::t_token("terrain/" + (has_tilde ? (*str).substr(0,tilde) : str));
|
||||
|
||||
if(!image_exists(filename)){
|
||||
continue; // ignore missing frames
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace {
|
|||
static const config::t_token z_x("x", false);
|
||||
static const config::t_token z_y("y", false);
|
||||
static const config::t_token z_insert_child("insert_child", false);
|
||||
static const config::t_token z_delete_child("delete_child", false);
|
||||
static const config::t_token z_delete_child("delete_child", false);
|
||||
static const config::t_token z_change_child("change_child", false);
|
||||
static const config::t_token z_modified("modified", false);
|
||||
static const config::t_token z_insert("insert", false);
|
||||
|
@ -75,13 +75,13 @@ namespace{
|
|||
|
||||
|
||||
|
||||
config::attribute_value::attribute_value()
|
||||
config::attribute_value::attribute_value()
|
||||
: int_value_(),double_value_() , t_string_value_() , token_value_() , type_(EMPTY) , bool_value_()
|
||||
, is_bool_(false), is_int_(false), is_double_(false) ,is_t_string_(false), is_token_(false) { }
|
||||
|
||||
config::attribute_value::~attribute_value() {}
|
||||
|
||||
config::attribute_value::attribute_value(const config::attribute_value &that)
|
||||
config::attribute_value::attribute_value(const config::attribute_value &that)
|
||||
: int_value_ (that.int_value_),double_value_(that.double_value_)
|
||||
, t_string_value_(that.t_string_value_)
|
||||
, token_value_(that.token_value_), type_(that.type_) , bool_value_(that.bool_value_)
|
||||
|
@ -89,11 +89,11 @@ config::attribute_value::attribute_value(const config::attribute_value &that)
|
|||
,is_t_string_(that.is_t_string_), is_token_(that.is_token_) { }
|
||||
|
||||
config::attribute_value &config::attribute_value::operator=(const config::attribute_value &that) {
|
||||
bool_value_ = that.bool_value_; int_value_ = that.int_value_;
|
||||
bool_value_ = that.bool_value_; int_value_ = that.int_value_;
|
||||
double_value_ = that.double_value_; t_string_value_ = that.t_string_value_;
|
||||
token_value_ = that.token_value_; type_ = that.type_;
|
||||
is_bool_ = that.is_bool_; is_int_ = that.is_int_; is_double_ = that.is_double_;
|
||||
is_t_string_ = that.is_t_string_; is_token_ = that.is_token_;
|
||||
token_value_ = that.token_value_; type_ = that.type_;
|
||||
is_bool_ = that.is_bool_; is_int_ = that.is_int_; is_double_ = that.is_double_;
|
||||
is_t_string_ = that.is_t_string_; is_token_ = that.is_token_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ config::attribute_value &config::attribute_value::operator=(bool v)
|
|||
{
|
||||
type_ = BOOL;
|
||||
bool_value_ = v;
|
||||
is_bool_ = true; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
is_bool_ = true; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ config::attribute_value &config::attribute_value::operator=(int v)
|
|||
{
|
||||
type_ = INT;
|
||||
int_value_ = v;
|
||||
is_bool_ = false; is_int_ = true; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
is_bool_ = false; is_int_ = true; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -117,14 +117,14 @@ config::attribute_value &config::attribute_value::operator=(double v)
|
|||
{
|
||||
type_ = DOUBLE;
|
||||
double_value_ = v;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = true; is_t_string_ = false; is_token_ =false;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = true; is_t_string_ = false; is_token_ =false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
config::attribute_value &config::attribute_value::operator=(const t_token &v) {
|
||||
if (v == z_empty) {
|
||||
if (v == z_empty) {
|
||||
type_ = EMPTY;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =false;
|
||||
token_value_ = v; return *this; }
|
||||
if (v == z_yes || v == z_true) return *this = true;
|
||||
if (v == z_no || v == z_false) return *this = false;
|
||||
|
@ -140,7 +140,7 @@ config::attribute_value &config::attribute_value::operator=(const t_token &v) {
|
|||
if( (is >> d) && ! is.get(extra_char) ) { *this = d; is_token_=true; token_value_ = v; return *this; }
|
||||
|
||||
type_ = TOKEN;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =true;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =true;
|
||||
token_value_ = v;
|
||||
return *this;
|
||||
}
|
||||
|
@ -154,13 +154,13 @@ config::attribute_value &config::attribute_value::operator=(const std::string &v
|
|||
int i;
|
||||
char extra_char;
|
||||
if( (is >> i) && ! is.get(extra_char) ) { *this = i; return *this; }
|
||||
|
||||
|
||||
is.clear();
|
||||
is.str( v );
|
||||
double d;
|
||||
if( (is >> d) && ! is.get(extra_char) ) { *this = d; return *this; }
|
||||
type_ = TOKEN;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =true;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = false; is_token_ =true;
|
||||
token_value_ = t_token(v);
|
||||
return *this;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ config::attribute_value &config::attribute_value::operator=(const std::string &v
|
|||
config::attribute_value &config::attribute_value::operator=(const t_string &v) {
|
||||
if (!v.translatable()) { return *this = v.token(); }
|
||||
type_ = TSTRING;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = true; is_token_ =false;
|
||||
is_bool_ = false; is_int_ = false; is_double_ = false; is_t_string_ = true; is_token_ =false;
|
||||
t_string_value_ = v;
|
||||
return *this;
|
||||
}
|
||||
|
@ -191,13 +191,13 @@ bool config::attribute_value::operator==(const config::attribute_value &other) c
|
|||
bool operator==(const config::attribute_value &a, config::t_token const & b) {
|
||||
// if(a.type_ == a.EMPTY){return false;}
|
||||
//note: having 4 different acceptable boolean string values has a cost
|
||||
if ((a.type_ == a.BOOL) || ( a.is_bool_)){
|
||||
if ((a.type_ == a.BOOL) || ( a.is_bool_)){
|
||||
return (a.bool_value_ ?(b==config::z_true || b == config::z_yes) : (b == config::z_false || b == config::z_no)); }
|
||||
return a.token() == b;
|
||||
}
|
||||
bool operator==(const config::attribute_value &a, t_string const & b) {
|
||||
bool operator==(const config::attribute_value &a, t_string const & b) {
|
||||
// if(a.type_ == a.EMPTY){return false;}
|
||||
if ((a.type_ == a.BOOL) || ( a.is_bool_)){
|
||||
if ((a.type_ == a.BOOL) || ( a.is_bool_)){
|
||||
return (a.bool_value_ ? (b==tstring_true || b == tstring_yes) : (b == tstring_false || b == tstring_no)); }
|
||||
return a.t_str() == b; }
|
||||
|
||||
|
@ -238,15 +238,15 @@ t_token const & config::attribute_value::token() const {
|
|||
switch(type_){
|
||||
case (EMPTY) : return z_empty;
|
||||
case(BOOL) : return bool_value_ ? z_yes : z_no;
|
||||
case(INT) :
|
||||
case(INT) :
|
||||
is_token_ = true;
|
||||
token_value_ = t_token(str_cast(int_value_));
|
||||
return token_value_;
|
||||
case(DOUBLE) :
|
||||
case(DOUBLE) :
|
||||
is_token_ = true;
|
||||
token_value_ = t_token(str_cast(double_value_));
|
||||
return token_value_;
|
||||
case(TSTRING) :
|
||||
case(TSTRING) :
|
||||
return t_string_value_.token();
|
||||
default : break;
|
||||
}
|
||||
|
@ -260,16 +260,16 @@ std::string const & config::attribute_value::str() const {
|
|||
|
||||
|
||||
t_string const & config::attribute_value::t_str() const {
|
||||
if ((type_ == TSTRING) || ( is_t_string_)){
|
||||
if ((type_ == TSTRING) || ( is_t_string_)){
|
||||
return t_string_value_; }
|
||||
switch(type_){
|
||||
case (EMPTY) :
|
||||
case (EMPTY) :
|
||||
return tstring_empty;
|
||||
case(BOOL) :
|
||||
case(BOOL) :
|
||||
return bool_value_ ? tstring_yes : tstring_no;
|
||||
case(INT) :
|
||||
case(DOUBLE) :
|
||||
case(TOKEN) :
|
||||
case(INT) :
|
||||
case(DOUBLE) :
|
||||
case(TOKEN) :
|
||||
is_t_string_ = true;
|
||||
t_string_value_ = t_string(token());
|
||||
return t_string_value_;
|
||||
|
@ -356,7 +356,7 @@ bool config::has_old_attribute(const t_token &key, const t_token &old_key, const
|
|||
}
|
||||
return false;
|
||||
}
|
||||
bool config::has_old_attribute(const std::string &key, const std::string &old_key, const std::string& msg) const {
|
||||
bool config::has_old_attribute(const std::string &key, const std::string &old_key, const std::string& msg) const {
|
||||
return has_old_attribute(t_token(key), t_token(old_key), msg );}
|
||||
|
||||
|
||||
|
@ -431,7 +431,7 @@ config::child_itors config::child_range(const t_token& key) {
|
|||
|
||||
child_map::iterator i = children.find(key);
|
||||
if (i != children.end()) {
|
||||
return child_itors(child_iterator(i->second.begin()), child_iterator(i->second.end()));
|
||||
return child_itors(child_iterator(i->second.begin()), child_iterator(i->second.end()));
|
||||
}
|
||||
static child_list dummy;
|
||||
dummy.clear();
|
||||
|
@ -453,7 +453,7 @@ config::const_child_itors config::child_range(const t_token& key) const {
|
|||
return dummy_iters;
|
||||
}
|
||||
|
||||
config::const_child_itors config::child_range(const std::string& key) const { return child_range(t_token(key));}
|
||||
config::const_child_itors config::child_range(const std::string& key) const { return child_range(t_token(key));}
|
||||
unsigned config::child_count(const t_token &key) const {
|
||||
check_valid();
|
||||
|
||||
|
@ -483,7 +483,7 @@ config::t_const_child_range_index config::const_child_range_index(config::t_toke
|
|||
return index; }
|
||||
|
||||
|
||||
unsigned config::child_count(const std::string &key) const { return child_count(t_token(key)); }
|
||||
unsigned config::child_count(const std::string &key) const { return child_count(t_token(key)); }
|
||||
config &config::child(const t_token& key, int n)
|
||||
{
|
||||
check_valid();
|
||||
|
@ -794,7 +794,7 @@ struct config_has_value {
|
|||
config_has_value(const t_token& name, const t_token& value)
|
||||
: name_(name), value_(value) {}
|
||||
|
||||
bool operator()(const config* cfg) const {
|
||||
bool operator()(const config* cfg) const {
|
||||
return (*cfg)[name_] == value_; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
/// Define a token that compares faster than a string once created.
|
||||
/// It is preferable to use t_token as indices over strings
|
||||
typedef n_token::t_token t_token;
|
||||
|
||||
|
||||
static const t_token z_empty, z_yes, z_no, z_true, z_false, z_index;
|
||||
|
||||
/**
|
||||
|
@ -194,7 +194,7 @@ public:
|
|||
mutable double double_value_;
|
||||
mutable t_string t_string_value_;
|
||||
mutable t_token token_value_;
|
||||
|
||||
|
||||
attribute_type type_;
|
||||
mutable bool bool_value_ : 1;
|
||||
mutable bool is_bool_ : 1, is_int_ : 1, is_double_ : 1, is_t_string_ : 1, is_token_ : 1;
|
||||
|
@ -304,11 +304,11 @@ public:
|
|||
|
||||
/** Creates an index into the child range to allow for quick searches.
|
||||
key is the key for the child range and name is the column to index.
|
||||
i.e. if the list of save games is stored in a child called save with titles
|
||||
i.e. if the list of save games is stored in a child called save with titles
|
||||
then to create a container indexed by titles do
|
||||
|
||||
child_range_index(z_save, z_title);
|
||||
@Note the index is not stored in the config and is intended for
|
||||
@Note the index is not stored in the config and is intended for
|
||||
repeated searches of large child ranges.
|
||||
*/
|
||||
t_child_range_index child_range_index(const t_token& key, config::t_token const & name);
|
||||
|
@ -600,7 +600,7 @@ template <typename X> void config::attribute_value::apply_visitor(X & visitor) c
|
|||
switch(type_){
|
||||
case (EMPTY) : return visitor();
|
||||
case(BOOL) : return visitor(bool_value_);
|
||||
case(INT) : return visitor(int_value_);
|
||||
case(INT) : return visitor(int_value_);
|
||||
case(DOUBLE) : return visitor(double_value_);
|
||||
case(TOKEN) : return visitor(token_value_);
|
||||
case(TSTRING) : return visitor(t_string_value_);
|
||||
|
|
|
@ -212,7 +212,7 @@ bool animate_unit_advancement(const map_location &loc, size_t choice, const bool
|
|||
|
||||
if (!resources::screen->video().update_locked()) {
|
||||
unit_animator animator;
|
||||
bool with_bars = true;
|
||||
bool with_bars = true;
|
||||
static const config::t_token z_levelout("levelout", false);
|
||||
animator.add_animation(&*u, z_levelout, u->get_location(), map_location(), 0, with_bars);
|
||||
animator.start_animations();
|
||||
|
@ -394,7 +394,7 @@ void save_preview_pane::draw_contents()
|
|||
#ifdef LOW_MEM
|
||||
const surface image(image::get_image(leader->image()));
|
||||
#else
|
||||
const surface image(image::get_image(static_cast<std::string const &>(leader->image())
|
||||
const surface image(image::get_image(static_cast<std::string const &>(leader->image())
|
||||
+ "~RC(" + static_cast<std::string const &>(leader->flag_rgb()) + ">1)"));
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace game {
|
||||
|
||||
wml_syntax_error::wml_syntax_error(std::string const & reason)
|
||||
wml_syntax_error::wml_syntax_error(std::string const & reason)
|
||||
: output_("WML Syntax error:: Variable in WML string cannot be evaluated due to " + reason) {}
|
||||
|
||||
///Tries to parse the error message so that an arror <-- points to the location of the error
|
||||
|
@ -34,7 +34,7 @@ wml_syntax_error::wml_syntax_error(std::string const & str, size_t const & pos,
|
|||
ss << "-->\"";
|
||||
ss << str.substr(pos) << "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
else { ss << "\"<--"; }
|
||||
|
||||
output_ = ss.str();
|
||||
|
@ -55,10 +55,10 @@ wml_syntax_error::wml_syntax_error(t_tokens const & tokens, size_t const & p, st
|
|||
if((++i) != tokens.end()){
|
||||
ss << "\"";
|
||||
for(; i != tokens.end(); ++i){
|
||||
ss << *i; }
|
||||
ss << *i; }
|
||||
ss << "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
else { ss << "\"<--"; }
|
||||
|
||||
output_ = ss.str();
|
||||
|
|
|
@ -42,7 +42,7 @@ struct error : std::exception
|
|||
|
||||
/**
|
||||
///WML syntax error exception
|
||||
When parsing wml from a vector of tokens when the location of the error is known an exact
|
||||
When parsing wml from a vector of tokens when the location of the error is known an exact
|
||||
error message can be thrown.
|
||||
*/
|
||||
class wml_syntax_error : public std::exception {
|
||||
|
@ -55,7 +55,7 @@ class wml_syntax_error : public std::exception {
|
|||
wml_syntax_error(t_tokens const & tokens, size_t const & pos, std::string const & reason = "unknown reason");
|
||||
///Construct a wml syntax error with the unparsed string the position of the error and a reason for the error.
|
||||
wml_syntax_error(std::string const & tokens, size_t const & pos, std::string const & reason = "unknown reason");
|
||||
|
||||
|
||||
wml_syntax_error(std::string const & reason = "unknown reason");
|
||||
///Tries to parse the error message so that an arror <-- points to the location of the error
|
||||
virtual const char * what() const throw() ;
|
||||
|
|
|
@ -34,9 +34,9 @@ static const t_token z_sharp("#", false);
|
|||
|
||||
|
||||
template <typename T>
|
||||
t_tokenizer::t_tokenizer(T const & in)
|
||||
t_tokenizer::t_tokenizer(T const & in)
|
||||
: tokens_(), is_done_(false), is_valid_varname_(false), input_string_(static_cast<std::string const &>(in))
|
||||
, curr_pos_(0), end_(input_string_.size())
|
||||
, curr_pos_(0), end_(input_string_.size())
|
||||
, varname_start_(input_string_.npos){}
|
||||
|
||||
template <typename T>
|
||||
|
@ -52,7 +52,7 @@ t_tokens const & t_tokenizer::tokenize() {
|
|||
end_=input_string_.size();
|
||||
if(end_ == 0) {
|
||||
tokens_.push_back(z_empty);
|
||||
is_done_ = true; }
|
||||
is_done_ = true; }
|
||||
else {
|
||||
varname_start_=input_string_.npos;
|
||||
int guard(0);
|
||||
|
@ -71,7 +71,7 @@ t_tokens const & t_tokenizer::tokenize() {
|
|||
}
|
||||
|
||||
void t_tokenizer::grab_name(){
|
||||
if(varname_start_ != input_string_.npos){
|
||||
if(varname_start_ != input_string_.npos){
|
||||
t_token next_token(input_string_.substr(varname_start_, curr_pos_- varname_start_));
|
||||
tokens_.push_back(next_token);
|
||||
varname_start_=input_string_.npos;
|
||||
|
@ -80,7 +80,7 @@ void t_tokenizer::grab_name(){
|
|||
|
||||
void t_tokenizer::process_char(){
|
||||
if(curr_pos_ == end_){ grab_name(); is_done_=true; return; }
|
||||
|
||||
|
||||
//if the char at curr_pos is a control character then it is its own token
|
||||
//otherwise it is the start of a multicharacter token
|
||||
|
||||
|
@ -115,7 +115,7 @@ void t_tokenizer::process_char(){
|
|||
t_operation is a functor that does 2 things
|
||||
1. When provided with a token stack and a variable set it performs an operation like interpolation.
|
||||
2. When given a token stack an t_operation stack it performs its operation if it can do so without the
|
||||
variable set, otherwise it puts an operation on the instruction stack. This function can be called when the expression
|
||||
variable set, otherwise it puts an operation on the instruction stack. This function can be called when the expression
|
||||
is parsed in order to reduce the operations to their smallest set.
|
||||
*/
|
||||
|
||||
|
@ -147,14 +147,14 @@ void t_operation_formula::operator()(t_tokens & stack, variable_set const & var
|
|||
try {
|
||||
const game_logic::formula form(static_cast<std::string const &>(var_name) );
|
||||
t_token rhs(form.evaluate().string_cast());
|
||||
t_operation_append append(rhs);
|
||||
t_operation_append append(rhs);
|
||||
append(stack, variable_set);
|
||||
DEBUG_INTERP << string(var_name, static_cast<std::string const &>(rhs) ) << "\n";
|
||||
DEBUG_INTERP << string(var_name, static_cast<std::string const &>(rhs) ) << "\n";
|
||||
} catch(game_logic::formula_error& e) {
|
||||
ERR_INTERP << "Formula in WML string cannot be evaluated due to: "
|
||||
<< e.type << "\n\t--> \""
|
||||
<< e.formula << "\"\n";
|
||||
t_operation_append append(var_name);
|
||||
t_operation_append append(var_name);
|
||||
append(stack, variable_set);
|
||||
}
|
||||
}
|
||||
|
@ -174,12 +174,12 @@ void t_instructions::optimize(t_token const & unparsed) {
|
|||
t_operation_ptr const & first_op = (last_instruction_optimized == true) ? optimized.back() : *(i_not-1);
|
||||
|
||||
t_operation::t_reduce_result reduced =first_op->reduce(*i_not);
|
||||
|
||||
|
||||
if(reduced.second){
|
||||
DEBUG_INTERP <<"Reducing "<< *first_op << " + " << (**i_not) << " to "<< *reduced.first<<"\n";
|
||||
if(last_instruction_optimized){ optimized.pop_back(); }
|
||||
last_instruction_optimized = true;
|
||||
optimized.push_back(reduced.first); }
|
||||
optimized.push_back(reduced.first); }
|
||||
else{
|
||||
DEBUG_INTERP <<"Not reducing "<< *first_op << " + " << (**i_not) << " \n";
|
||||
if(last_instruction_optimized){ }
|
||||
|
@ -189,7 +189,7 @@ void t_instructions::optimize(t_token const & unparsed) {
|
|||
++i_not;
|
||||
}
|
||||
|
||||
if(! last_instruction_optimized){ optimized.push_back( ops_.back() ); }
|
||||
if(! last_instruction_optimized){ optimized.push_back( ops_.back() ); }
|
||||
|
||||
ops_.swap(optimized);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ void t_instructions::optimize(t_token const & unparsed) {
|
|||
if(ops_.size() == 1){
|
||||
t_operation_push op_push_unparsed(unparsed);
|
||||
if(op_push_unparsed == ops_[0]){ ops_.clear(); }
|
||||
|
||||
|
||||
}
|
||||
DEBUG_INTERP << "Optimized instructions : \n" << *this <<"\n";
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ std::ostream & operator<<(std::ostream &out, t_instructions const & a){
|
|||
out <<(**i) <<"\n";
|
||||
}
|
||||
return out; }
|
||||
|
||||
|
||||
|
||||
|
||||
std::ostream & operator<<(std::ostream &out, t_parse const & a){
|
||||
|
@ -234,8 +234,8 @@ std::ostream & operator<<(std::ostream &out, t_parse const & a){
|
|||
for(; i != ops.end(); ++i){ out << *i ;}
|
||||
return out<<" /OPS \n";
|
||||
}
|
||||
|
||||
t_parse::t_parse(n_token::t_token const & unparsed)
|
||||
|
||||
t_parse::t_parse(n_token::t_token const & unparsed)
|
||||
: token_(unparsed)
|
||||
, tokens_()
|
||||
, complete_parse_() {}
|
||||
|
@ -248,7 +248,7 @@ t_parse::t_parse(t_parse const & a )
|
|||
}
|
||||
|
||||
t_parse & t_parse::operator=(t_parse const & a) {
|
||||
token_ = (a.token_);
|
||||
token_ = (a.token_);
|
||||
complete_parse_ = a.complete_parse_;
|
||||
return *this; }
|
||||
|
||||
|
@ -277,29 +277,29 @@ t_tokens::iterator t_parse::do_parse_plain(t_tokens::iterator const & start_pos
|
|||
//$| inserts just a $
|
||||
if( peek_next(curr_pos) == z_bar){
|
||||
static const t_operation_ptr op(new t_operation_append(z_dollar));
|
||||
complete_parse_.ops().push_back(op);
|
||||
complete_parse_.ops().push_back(op);
|
||||
curr_pos+=2; }
|
||||
|
||||
|
||||
//A interpolation / formula
|
||||
else {
|
||||
else {
|
||||
size_t good_size = complete_parse_.ops().size();
|
||||
try {
|
||||
curr_pos = do_parse_interp(++curr_pos); }
|
||||
curr_pos = do_parse_interp(++curr_pos); }
|
||||
catch (game::wml_syntax_error & e) {
|
||||
ERR_INTERP << e.what()<<"\n";
|
||||
if(complete_parse_.ops().size() > good_size){
|
||||
if(complete_parse_.ops().size() > good_size){
|
||||
complete_parse_.ops().resize(good_size); } } } }
|
||||
|
||||
|
||||
//text variable name component
|
||||
else {
|
||||
t_operation_ptr op(new t_operation_append(*curr_pos));
|
||||
complete_parse_.ops().push_back(op);
|
||||
++curr_pos; }
|
||||
}
|
||||
complete_parse_.ops().push_back(op);
|
||||
++curr_pos; }
|
||||
}
|
||||
return curr_pos;
|
||||
}
|
||||
|
||||
t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos ){
|
||||
t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos ){
|
||||
bool found_part_of_name(false);
|
||||
t_tokens::iterator curr_pos = start_pos + 1;
|
||||
|
||||
|
@ -313,7 +313,7 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
if (is_good_for_varname(*start_pos)){
|
||||
found_part_of_name = true;
|
||||
t_operation_ptr op(new t_operation_push(*start_pos));
|
||||
complete_parse_.ops().push_back(op); }
|
||||
complete_parse_.ops().push_back(op); }
|
||||
|
||||
else if(*start_pos == z_dollar){
|
||||
// $| Creates a $ to allow for $ in the string
|
||||
|
@ -322,27 +322,27 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
|
||||
//A Nested interpolation / formula
|
||||
else {
|
||||
curr_pos = do_parse_interp(start_pos + 1);
|
||||
curr_pos = do_parse_interp(start_pos + 1);
|
||||
//todo this is a small lie if the interpolated result contains a control character
|
||||
found_part_of_name = true; } }
|
||||
|
||||
// $( ... ) Creates a WML formula
|
||||
else if (*start_pos == z_lparen){
|
||||
// $( ... ) Creates a WML formula
|
||||
else if (*start_pos == z_lparen){
|
||||
return do_parse_formula(start_pos); }
|
||||
|
||||
// Everything else is an error
|
||||
else { throw game::wml_syntax_error(tokens_, start_pos - tokens_.begin(), "missing variable name right after $"); }
|
||||
|
||||
|
||||
// Grab and append tokens until we reach the end of the variable name
|
||||
int bracket_nesting_level = 0;
|
||||
|
||||
while(curr_pos != tokens_.end()){
|
||||
while(curr_pos != tokens_.end()){
|
||||
|
||||
//text variable name component
|
||||
if (is_good_for_varname(*curr_pos)){
|
||||
found_part_of_name = true;
|
||||
t_operation_ptr op(new t_operation_append(*curr_pos));
|
||||
complete_parse_.ops().push_back(op);
|
||||
complete_parse_.ops().push_back(op);
|
||||
++curr_pos; }
|
||||
|
||||
else if(*curr_pos == z_dollar){
|
||||
|
@ -359,21 +359,21 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
else if(*curr_pos == z_lbracket){
|
||||
static const t_operation_ptr op(new t_operation_append(z_lbracket));
|
||||
complete_parse_.ops().push_back(op);
|
||||
++bracket_nesting_level;
|
||||
++bracket_nesting_level;
|
||||
++curr_pos; }
|
||||
else if(*curr_pos == z_rbracket){
|
||||
if((--bracket_nesting_level) < 0) { break; }
|
||||
if((--bracket_nesting_level) < 0) { break; }
|
||||
static const t_operation_ptr op(new t_operation_append(z_rbracket));
|
||||
complete_parse_.ops().push_back(op);
|
||||
complete_parse_.ops().push_back(op);
|
||||
++curr_pos; }
|
||||
|
||||
//Dots
|
||||
//two dots terminates variable expansion
|
||||
// That matters for random=, e.g. $x..$y
|
||||
else if(*curr_pos == z_dot){
|
||||
if(peek_next(curr_pos) == z_dot){ break; }
|
||||
if(peek_next(curr_pos) == z_dot){ break; }
|
||||
static const t_operation_ptr op(new t_operation_append(z_dot));
|
||||
complete_parse_.ops().push_back(op);
|
||||
complete_parse_.ops().push_back(op);
|
||||
++curr_pos; }
|
||||
|
||||
//A | terminates the variable name
|
||||
|
@ -387,11 +387,11 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
//Invalid variable name component
|
||||
else if (!is_good_for_varname(*curr_pos)){
|
||||
break; }
|
||||
|
||||
|
||||
//Never happen
|
||||
else { assert(false); }
|
||||
}
|
||||
|
||||
|
||||
// If the last character is '.', then it can't be a sub-variable.
|
||||
// It's probably meant to be a period instead. Don't include it.
|
||||
// Would need to do it repetitively if there are multiple '.'s at the end,
|
||||
|
@ -414,7 +414,7 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
if(! found_part_of_name) {
|
||||
throw game::wml_syntax_error(tokens_, start_pos - tokens_.begin()
|
||||
, "missing variable name after $ (valid characters are a-zA-Z0-9_)"); }
|
||||
|
||||
|
||||
//FInally an interpolation
|
||||
t_operation_ptr op(new t_operation_interp());
|
||||
complete_parse_.ops().push_back(op);
|
||||
|
@ -424,7 +424,7 @@ t_tokens::iterator t_parse::do_parse_interp(t_tokens::iterator const & start_pos
|
|||
/** do_parse forumal parses a formula invoked by $ (...) syntax
|
||||
*/
|
||||
t_tokens::iterator t_parse::do_parse_formula(t_tokens::iterator const & start_pos ){
|
||||
|
||||
|
||||
//Deal with the first token in the iterpolated variable
|
||||
if(start_pos == tokens_.end()){
|
||||
throw game::wml_syntax_error(tokens_, start_pos - tokens_.begin(), "formula hitting end of line"); }
|
||||
|
@ -451,7 +451,7 @@ t_tokens::iterator t_parse::do_parse_formula(t_tokens::iterator const & start_po
|
|||
else if(*curr_pos == z_rparen){
|
||||
if(!in_string && !in_comment) {
|
||||
--paren_nesting_level; }
|
||||
if( paren_nesting_level <= 0) { break; }
|
||||
if( paren_nesting_level <= 0) { break; }
|
||||
static const t_operation_ptr op(new t_operation_append(z_rparen));
|
||||
complete_parse_.ops().push_back(op); }
|
||||
|
||||
|
@ -481,7 +481,7 @@ t_tokens::iterator t_parse::do_parse_formula(t_tokens::iterator const & start_po
|
|||
t_operation_ptr op(new t_operation_append(*curr_pos));
|
||||
complete_parse_.ops().push_back(op); }
|
||||
}
|
||||
|
||||
|
||||
if(paren_nesting_level > 0) {
|
||||
throw game::wml_syntax_error(tokens_, curr_pos - tokens_.begin(), "formula in WML string cannot be evaluated due to "
|
||||
"missing closing paren"); }
|
||||
|
@ -489,11 +489,11 @@ t_tokens::iterator t_parse::do_parse_formula(t_tokens::iterator const & start_po
|
|||
t_operation_ptr op(new t_operation_formula());
|
||||
complete_parse_.ops().push_back(op);
|
||||
return ++curr_pos; //skip the closing right paren
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
t_parse_and_interpolator::t_parse_and_interpolator (t_parse_and_interpolator const & a)
|
||||
t_parse_and_interpolator::t_parse_and_interpolator (t_parse_and_interpolator const & a)
|
||||
: maybe_parsed_(a.maybe_parsed_), complete_parse_(a.complete_parse_), is_done_(a.is_done_){}
|
||||
|
||||
t_parse_and_interpolator & t_parse_and_interpolator::operator=(t_parse_and_interpolator const & a) {
|
||||
|
@ -505,6 +505,6 @@ std::ostream & operator<<(std::ostream &out, t_parse_and_interpolator const & a)
|
|||
|
||||
//static member
|
||||
t_parse_and_interpolator::t_all_parsed t_parse_and_interpolator::all_parsed_(t_parse_and_interpolator::t_parser(), CACHE_SIZE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ inline bool is_good_for_varname (t_token const & a){
|
|||
|
||||
///Break string/token into relevant tokens
|
||||
/** @class t_tokenizer breaks strings/tokens into vectors of tokens.
|
||||
Tokens are either a part of a variable name (alnum or _),
|
||||
Tokens are either a part of a variable name (alnum or _),
|
||||
a valid control character $|.[]()'#
|
||||
or everything else.
|
||||
or everything else.
|
||||
*/
|
||||
class t_tokenizer {
|
||||
t_tokens tokens_; /// tokens for output
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
/** Initialize the tokenizer with a std::string or a t_token
|
||||
@param[in] in a string/token static_castible to a string
|
||||
*/
|
||||
template <typename T> t_tokenizer(T const & in);
|
||||
template <typename T> t_tokenizer(T const & in);
|
||||
|
||||
/**Binds to a new string and tokenizes the string
|
||||
@param[in] in a string/token static_castible to a string
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
|
||||
/**@class
|
||||
Each t_operation is a functor that does 2 things
|
||||
1. When provided with a token stack and a variable set it performs an operation :
|
||||
1. When provided with a token stack and a variable set it performs an operation :
|
||||
push, append, interpolate (variable) or formula (interpolation).
|
||||
2. When provided with 2 operations, it returns a single operation that in the same as
|
||||
the two operations it possible.
|
||||
|
@ -169,7 +169,7 @@ struct t_operation {
|
|||
virtual bool operator==(t_operation_append const & /*first_op*/) const { return false; }
|
||||
virtual bool operator==(t_operation_interp const & /*first_op*/) const { return false; }
|
||||
virtual bool operator==(t_operation_formula const & /*first_op*/) const { return false; }
|
||||
|
||||
|
||||
private:
|
||||
static const t_operation_ptr void_op_; ///Operation ptr returned on failure, deferencing will cause a crash
|
||||
};
|
||||
|
@ -194,7 +194,7 @@ class t_operation_push : public t_operation {
|
|||
t_token x_;
|
||||
public:
|
||||
t_operation_push(t_token const & a) : x_(a){}
|
||||
|
||||
|
||||
virtual void operator()(t_tokens & stack, variable_set const & /*variable_set*/) const {
|
||||
stack.push_back(x_);
|
||||
DEBUG_INTERP << string() << "\n"; }
|
||||
|
@ -234,11 +234,11 @@ public:
|
|||
///Checks the cache for the append result and replaces the top token on the stack with the result
|
||||
virtual void operator()(t_tokens & stack, variable_set const & /*variable_set*/) const {
|
||||
if(!stack.empty()){
|
||||
t_token const &res = cache_.check(std::make_pair(stack.back(), x_));
|
||||
t_token const &res = cache_.check(std::make_pair(stack.back(), x_));
|
||||
if(res != stack.back()){
|
||||
DEBUG_INTERP << string(res) << "\n";
|
||||
stack.pop_back();
|
||||
stack.push_back(res); } }
|
||||
stack.push_back(res); } }
|
||||
|
||||
else {
|
||||
stack.push_back(x_); }
|
||||
|
@ -249,15 +249,15 @@ public:
|
|||
virtual t_reduce_result reduce(t_operation_ptr const & second_op) const {
|
||||
return second_op->reduce_flipped(*this); }
|
||||
|
||||
/// push->append is reduces to a push operation
|
||||
/// push->append is reduces to a push operation
|
||||
virtual t_reduce_result reduce_flipped(t_operation_push const & first_op) const {
|
||||
t_operation_ptr op(new t_operation_push(t_token(static_cast<std::string const &>(first_op.x())
|
||||
t_operation_ptr op(new t_operation_push(t_token(static_cast<std::string const &>(first_op.x())
|
||||
+ static_cast<std::string const &>(x()))));
|
||||
return std::make_pair(op, true); }
|
||||
|
||||
/// append->append is reduces to an append operation
|
||||
/// append->append is reduces to an append operation
|
||||
virtual t_reduce_result reduce_flipped(t_operation_append const & first_op) const {
|
||||
t_operation_ptr op(new t_operation_append(t_token(static_cast<std::string const &>(first_op.x())
|
||||
t_operation_ptr op(new t_operation_append(t_token(static_cast<std::string const &>(first_op.x())
|
||||
+ static_cast<std::string const &>(x()))));
|
||||
return std::make_pair(op, true); }
|
||||
|
||||
|
@ -274,7 +274,7 @@ private:
|
|||
};
|
||||
|
||||
/**@class t_operation_interp looksup the top token on the stack in the variable_set
|
||||
@param[in] variable_set
|
||||
@param[in] variable_set
|
||||
*/
|
||||
class t_operation_interp : public t_operation {
|
||||
|
||||
|
@ -285,10 +285,10 @@ public :
|
|||
|
||||
t_token var_name(stack.back());
|
||||
config::attribute_value stuffing(variable_set.get_variable_const(var_name ));
|
||||
DEBUG_INTERP << string(var_name, stuffing) << "\n";
|
||||
|
||||
DEBUG_INTERP << string(var_name, stuffing) << "\n";
|
||||
|
||||
stack.pop_back();
|
||||
t_operation_append append(stuffing.token());
|
||||
t_operation_append append(stuffing.token());
|
||||
append(stack, variable_set);
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ public:
|
|||
|
||||
///runs the instructions and places the results in @param[out] x
|
||||
void run(t_token & x, variable_set const & set) const {
|
||||
if ( ops_.empty() ) {
|
||||
if ( ops_.empty() ) {
|
||||
//DEBUG_INTERP << "Nothing to interpolate in "<<x<<"\n";
|
||||
return; }
|
||||
run_core(x, set);
|
||||
|
@ -360,24 +360,24 @@ public:
|
|||
/** @class t_parse parses tokens into instructions to perform the interpolation
|
||||
*/
|
||||
struct t_parse {
|
||||
|
||||
|
||||
n_token::t_token token_; ///The input token
|
||||
t_tokens tokens_; ///Its tokens
|
||||
|
||||
t_instructions complete_parse_;
|
||||
|
||||
friend std::ostream & operator<<(std::ostream &out, t_parse const & a);
|
||||
|
||||
|
||||
t_parse(n_token::t_token const & unparsed) ;
|
||||
t_parse(t_parse const & a );
|
||||
t_parse & operator=(t_parse const & a) ;
|
||||
|
||||
///Calculate a parse
|
||||
///Calculate a parse
|
||||
t_instructions & parse();
|
||||
|
||||
///Peeks at the next token
|
||||
t_token const & peek_next(t_tokens::iterator const & curr_pos );
|
||||
|
||||
|
||||
///Keep concatenating components until you see a $ which indicates some kind of interpolation
|
||||
t_tokens::iterator do_parse_plain(t_tokens::iterator const & start_pos );
|
||||
|
||||
|
@ -393,13 +393,13 @@ struct t_parse {
|
|||
/** @class Parses and possibly stores variables for subsequent interpolation */
|
||||
class t_parse_and_interpolator {
|
||||
|
||||
/// @class Generate a parse for an uncached token
|
||||
/// @class Generate a parse for an uncached token
|
||||
struct t_parser {
|
||||
t_instructions operator()(n_token::t_token const & unparsed){
|
||||
t_parse aparse(unparsed);
|
||||
t_instructions instructions(aparse.parse());
|
||||
instructions.optimize(unparsed);
|
||||
return instructions;
|
||||
return instructions;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -411,9 +411,9 @@ class t_parse_and_interpolator {
|
|||
n_token::t_token maybe_parsed_; ///input token and result
|
||||
t_instructions const * complete_parse_; ///instructions to interpolate this token
|
||||
bool is_done_;
|
||||
|
||||
|
||||
public:
|
||||
t_parse_and_interpolator (n_token::t_token const & unparsed)
|
||||
t_parse_and_interpolator (n_token::t_token const & unparsed)
|
||||
: maybe_parsed_(unparsed), complete_parse_(NULL), is_done_(false){}
|
||||
|
||||
t_parse_and_interpolator (t_parse_and_interpolator const & a);
|
||||
|
@ -432,14 +432,14 @@ public:
|
|||
n_token::t_token const & parse_and_interpolate(const variable_set& set) {
|
||||
parse();
|
||||
return interpolate(set); }
|
||||
|
||||
|
||||
///Fetch the parsed instructions from the cache
|
||||
t_parse_and_interpolator & parse(){
|
||||
complete_parse_ = & all_parsed_.check(maybe_parsed_);
|
||||
is_done_ = false;
|
||||
return *this; }
|
||||
|
||||
///Run the parsed instructions to do the interpolation.
|
||||
///Run the parsed instructions to do the interpolation.
|
||||
t_token const & interpolate(const variable_set& set){
|
||||
assert(complete_parse_);
|
||||
if(!is_done_){
|
||||
|
@ -447,7 +447,7 @@ public:
|
|||
return maybe_parsed_; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -790,7 +790,7 @@ namespace {
|
|||
t_active active_; ///Active event handlers
|
||||
t_active insert_buffer_; ///Event handlers added while pumping events
|
||||
std::set<config::t_token> remove_buffer_; ///Event handlers removed while pumping events
|
||||
bool buffering_;
|
||||
bool buffering_;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -803,15 +803,15 @@ namespace {
|
|||
* respects this class's buffering functionality.
|
||||
*/
|
||||
void add_event_handler(game_events::event_handler const & new_handler) {
|
||||
if(buffering_) { insert_buffer_.push_back(new_handler); }
|
||||
|
||||
if(buffering_) { insert_buffer_.push_back(new_handler); }
|
||||
|
||||
else {
|
||||
const config & cfg = new_handler.get_config();
|
||||
config::t_token const & id = cfg[z_id];
|
||||
if(id != n_token::t_token::z_empty()) {
|
||||
foreach( game_events::event_handler const & eh, active_) {
|
||||
config const & temp_config( eh.get_config());
|
||||
if(id == temp_config[z_id]) { return; }
|
||||
if(id == temp_config[z_id]) { return; }
|
||||
}
|
||||
}
|
||||
active_.push_back(new_handler);
|
||||
|
@ -878,7 +878,7 @@ namespace {
|
|||
|
||||
iterator end() { return active_.end(); }
|
||||
const_iterator end() const { return active_.end(); }
|
||||
|
||||
|
||||
};
|
||||
|
||||
t_event_handlers event_handlers;
|
||||
|
@ -1617,7 +1617,7 @@ WML_HANDLER_FUNCTION(set_variable, /*event_info*/, cfg)
|
|||
|
||||
|
||||
WML_HANDLER_FUNCTION(set_variables, /*event_info*/, cfg)
|
||||
{
|
||||
{
|
||||
const config::attribute_value & name = cfg[z_name];
|
||||
variable_info dest(name, true, variable_info::TYPE_CONTAINER);
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ WML_HANDLER_FUNCTION(set_variables, /*event_info*/, cfg)
|
|||
//if no separator is specified, explode the string
|
||||
if(separator == NULL)
|
||||
{
|
||||
for(std::string::const_iterator i=static_cast<std::string const &>(split_string).begin();
|
||||
for(std::string::const_iterator i=static_cast<std::string const &>(split_string).begin();
|
||||
i!=static_cast<std::string const &>(split_string).end(); ++i)
|
||||
{
|
||||
split_vector.push_back(config::t_token(std::string(1, *i)));
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
void write_config(config_writer& out, bool write_variables=true) const;
|
||||
|
||||
// Variable access
|
||||
//Prefer using token or attribute value interface as it is faster
|
||||
//Prefer using token or attribute value interface as it is faster
|
||||
|
||||
config::attribute_value &get_variable(const config::t_token &varname);
|
||||
virtual config::attribute_value get_variable_const(const config::t_token& varname) const;
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace image {
|
|||
bool exists(const locator& i_locator);
|
||||
|
||||
/// precache the existence of files in the subdir (ex: "terrain/")
|
||||
void precache_file_existence(const n_token::t_token& subdir = n_token::t_token::z_empty());
|
||||
void precache_file_existence(const n_token::t_token& subdir = n_token::t_token::z_empty());
|
||||
bool precached_file_exists(const n_token::t_token& file);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,17 +165,17 @@ struct luaW_pushscalar_visitor : public config::attribute_value::default_visitor
|
|||
using default_visitor::operator();
|
||||
lua_State *L;
|
||||
luaW_pushscalar_visitor(lua_State *l): L(l) {}
|
||||
void operator()()
|
||||
void operator()()
|
||||
{ lua_pushnil(L); }
|
||||
void operator()(bool const b)
|
||||
void operator()(bool const b)
|
||||
{ lua_pushboolean(L, b); }
|
||||
void operator()(int const i)
|
||||
{ lua_pushnumber(L, i); }
|
||||
void operator()(double d)
|
||||
void operator()(int const i)
|
||||
{ lua_pushnumber(L, i); }
|
||||
void operator()(double d)
|
||||
{ lua_pushnumber(L, d); }
|
||||
void operator()(t_string const &s)
|
||||
void operator()(t_string const &s)
|
||||
{ luaW_pushtstring(L, s); }
|
||||
void operator()(config::t_token const &s)
|
||||
void operator()(config::t_token const &s)
|
||||
{ lua_pushstring(L, s.c_str()); }
|
||||
void operator()(t_string const &s) const
|
||||
{ luaW_pushtstring(L, s); }
|
||||
|
|
|
@ -233,17 +233,17 @@ void parser::parse_variable()
|
|||
switch(tok_->current_token().type) {
|
||||
case token::STRING:
|
||||
// if(!variables.back().empty()){
|
||||
// variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
// variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
// + ' ' +static_cast<std::string const &>(tok_->current_token().value()));
|
||||
// //variables.back() += ' ';
|
||||
// } else {
|
||||
// variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
// variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
// + static_cast<std::string const &>(tok_->current_token().value()));
|
||||
|
||||
// // variables.back() += tok_->current_token().value();
|
||||
// }
|
||||
variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
+ ((!variables.back().empty()) ? " " :"")
|
||||
variables.back() = config::t_token( static_cast<std::string const &>(variables.back())
|
||||
+ ((!variables.back().empty()) ? " " :"")
|
||||
+ static_cast<std::string const &>(tok_->current_token().value()));
|
||||
break;
|
||||
case ',':
|
||||
|
@ -434,15 +434,15 @@ struct write_key_val_visitor : public config::attribute_value::default_visitor {
|
|||
|
||||
inline void write_start_not_tstring();
|
||||
|
||||
void operator()()
|
||||
void operator()()
|
||||
{ write_start_not_tstring(); out_ << "\"\""; }
|
||||
void operator()(bool b)
|
||||
void operator()(bool b)
|
||||
{ write_start_not_tstring(); out_ << (b ? "yes" : "no"); }
|
||||
void operator()(int i)
|
||||
void operator()(int i)
|
||||
{ write_start_not_tstring(); out_ << i; }
|
||||
void operator()(double d)
|
||||
void operator()(double d)
|
||||
{ write_start_not_tstring(); int i = d; if (d == i) out_ << i; else out_ << d; }
|
||||
void operator()(config::t_token const &s)
|
||||
void operator()(config::t_token const &s)
|
||||
{ write_start_not_tstring(); out_ << '"' << escaped_string(static_cast<std::string const &>(s)) << '"'; }
|
||||
inline void operator()(t_string const &s) ;
|
||||
};
|
||||
|
@ -454,7 +454,7 @@ struct write_key_val_visitor : public config::attribute_value::default_visitor {
|
|||
* That is the reason for not outputting the key beforehand and
|
||||
* letting this function do it.
|
||||
*/
|
||||
static void write_key_val_tstring(std::ostream &out_, unsigned level_, std::string &textdomain_,
|
||||
static void write_key_val_tstring(std::ostream &out_, unsigned level_, std::string &textdomain_,
|
||||
const std::string &key_, t_string const &value) {
|
||||
bool first = true;
|
||||
|
||||
|
|
|
@ -84,11 +84,11 @@ static const unsigned int CACHE_SIZE = 10000;
|
|||
typedef std::vector<n_token::t_token > t_out;
|
||||
|
||||
struct t_split_triad {
|
||||
n_token::t_token const val;
|
||||
char c;
|
||||
n_token::t_token const val;
|
||||
char c;
|
||||
int flags;
|
||||
t_split_triad(n_token::t_token const &v, char cc, int f) : val(v), c(cc), flags(f) {}
|
||||
bool operator==(t_split_triad const & a) const {
|
||||
bool operator==(t_split_triad const & a) const {
|
||||
return val ==a.val && c==a.c && flags==a.flags; }
|
||||
};
|
||||
|
||||
|
@ -106,7 +106,7 @@ struct t_calc_cache_item {
|
|||
std::vector<std::string> vstr(split(static_cast<std::string const &>(x.val), x.c, x.flags));
|
||||
t_out retval;
|
||||
foreach(std::string const & s, vstr){
|
||||
retval.push_back(n_token::t_token(s));
|
||||
retval.push_back(n_token::t_token(s));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -164,12 +164,12 @@ typedef std::vector<n_token::t_token > t_out;
|
|||
|
||||
struct t_paren_split_inputs {
|
||||
n_token::t_token const val;
|
||||
const char separator;
|
||||
const char separator;
|
||||
n_token::t_token const left;
|
||||
n_token::t_token const right;
|
||||
int flags;
|
||||
t_paren_split_inputs(n_token::t_token const &val, const char separator, n_token::t_token const &left
|
||||
, n_token::t_token const &right,int flags)
|
||||
, n_token::t_token const &right,int flags)
|
||||
: val(val), separator(separator), left(left), right(right), flags(flags){}
|
||||
bool operator==(t_paren_split_inputs const & a) const {
|
||||
return val ==a.val && separator==a.separator && left==a.left && right==a.right && flags==a.flags; }
|
||||
|
@ -191,7 +191,7 @@ struct t_calc_paren_cache_item {
|
|||
std::vector<std::string> vstr(utils::parenthetical_split((*x.val), x.separator, x.left, x.right, x.flags));
|
||||
t_out retval;
|
||||
foreach(std::string const & s, vstr){
|
||||
retval.push_back(n_token::t_token(s));
|
||||
retval.push_back(n_token::t_token(s));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ std::vector< n_token::t_token > parenthetical_split_token(n_token::t_token const
|
|||
const char separator, n_token::t_token const &left,
|
||||
n_token::t_token const &right, int flags) {
|
||||
static t_paren_cache my_cache(t_calc_paren_cache_item(), PAREN_CACHE_SIZE);
|
||||
return my_cache.check( t_paren_split_inputs(val, separator, left, right, flags ) );
|
||||
return my_cache.check( t_paren_split_inputs(val, separator, left, right, flags ) );
|
||||
}
|
||||
|
||||
std::vector< std::string > parenthetical_split(std::string const &val,
|
||||
|
|
|
@ -97,7 +97,7 @@ const token &tokenizer::next_token()
|
|||
skip_comment();
|
||||
|
||||
startlineno_ = lineno_;
|
||||
|
||||
|
||||
token_.set_start();
|
||||
// std::cerr<<"cc="<<current_<<" ";
|
||||
|
||||
|
@ -152,23 +152,23 @@ const token &tokenizer::next_token()
|
|||
}
|
||||
break;
|
||||
|
||||
case '[':
|
||||
case '[':
|
||||
token_.type = token::token_type(current_);
|
||||
token_.set_token(z_LBRACKET);
|
||||
break;
|
||||
case ']':
|
||||
case ']':
|
||||
token_.type = token::token_type(current_);
|
||||
token_.set_token(z_RBRACKET);
|
||||
break;
|
||||
case '/':
|
||||
case '/':
|
||||
token_.type = token::token_type(current_);
|
||||
token_.set_token(z_SLASH);
|
||||
break;
|
||||
case '\n':
|
||||
case '\n':
|
||||
token_.type = token::token_type(current_);
|
||||
token_.set_token(z_LF);
|
||||
break;
|
||||
case '=':
|
||||
case '=':
|
||||
token_.type = token::token_type(current_);
|
||||
token_.set_token(z_EQUALS);
|
||||
break;
|
||||
|
|
|
@ -69,7 +69,7 @@ struct token {
|
|||
|
||||
token_type type;
|
||||
mutable std::string value_;
|
||||
|
||||
|
||||
mutable n_token::t_token t_token_;
|
||||
mutable bool is_parsed_;
|
||||
|
||||
|
@ -88,7 +88,7 @@ struct token {
|
|||
}
|
||||
return t_token_;
|
||||
}
|
||||
|
||||
|
||||
void set_token(n_token::t_token const & t){
|
||||
t_token_ = t;
|
||||
is_parsed_=true;
|
||||
|
@ -101,7 +101,7 @@ struct token {
|
|||
void add_char(char const c) {
|
||||
buffer_.push_back(c);
|
||||
is_parsed_ = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** Abstract baseclass for the tokenizer. */
|
||||
|
|
|
@ -255,7 +255,7 @@ bool terrain_filter::match_internal(const map_location& loc, const bool ignore_x
|
|||
if(std::find(vals.begin(),vals.end(),z_lawful) == vals.end()) {
|
||||
return false;
|
||||
}
|
||||
} else if(std::find(vals.begin(),vals.end(),z_neutral) == vals.end()
|
||||
} else if(std::find(vals.begin(),vals.end(),z_neutral) == vals.end()
|
||||
&& std::find(vals.begin(),vals.end(),z_liminal) == vals.end() ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ void terrain_filter::get_locations(t_maploc_set& locs, bool with_border, gamemap
|
|||
t_maploc_set union_hexes;
|
||||
terrain_filter(cond_cfg, *this).get_locations(union_hexes, with_border);
|
||||
//doesn't compile on MSVC
|
||||
//xy_set.insert(union_hexes.begin(), union_hexes.end());
|
||||
//xy_set.insert(union_hexes.begin(), union_hexes.end());
|
||||
t_maploc_set::iterator insert_itor = union_hexes.begin();
|
||||
while(insert_itor != union_hexes.end()) {
|
||||
xy_set.insert(*insert_itor++);
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
//match: returns true if and only if the given location matches this filter
|
||||
bool match(const map_location& loc
|
||||
, gamemap const & game_map = *resources::game_map
|
||||
, t_teams const & teams = *resources::teams
|
||||
, t_teams const & teams = *resources::teams
|
||||
, tod_manager const & tod_manager = *resources::tod_manager) const;
|
||||
virtual bool operator()(const map_location& loc) { return this->match(loc); }
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
config to_config() const;
|
||||
private:
|
||||
bool match_internal(const map_location& loc, const bool ignore_xy
|
||||
, gamemap const & game_map = *resources::game_map
|
||||
, gamemap const & game_map = *resources::game_map
|
||||
, t_teams const & teams = *resources::teams
|
||||
, tod_manager const & tod_manager= *resources::tod_manager ) const ;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
std::string checkR = "check";
|
||||
check_equal_interpolation(checkL, checkR, symbols);
|
||||
|
||||
//Nesting
|
||||
//Nesting
|
||||
std::string nestingL = "ne$second$third|to|dolls";
|
||||
symbols["second"] = "BBB";
|
||||
symbols["secondTTTto"] = "sting_";
|
||||
|
@ -123,7 +123,7 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
std::string stop_embedded_ctrlL = "stop$embed*star";
|
||||
symbols["embed*dollar"] = "_noway";
|
||||
symbols["embed"] = "_parse_at_embedded_";
|
||||
std::string stop_embedded_ctrlR = "stop_parse_at_embedded_*star";
|
||||
std::string stop_embedded_ctrlR = "stop_parse_at_embedded_*star";
|
||||
check_equal_interpolation(stop_embedded_ctrlL, stop_embedded_ctrlR, symbols);
|
||||
|
||||
std::string stop_recursive_embedded_ctrlL = "stop$fly$embed|star";
|
||||
|
@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
check_equal_interpolation(mismatch_string_in_formulaL, mismatch_string_in_formulaR, symbols);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4: */
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -28,7 +28,7 @@ BOOST_AUTO_TEST_SUITE( lru_cache_suite )
|
|||
namespace{
|
||||
static const unsigned int CACHE_SIZE = 10;
|
||||
static const unsigned int STEP_SIZE = 1000;
|
||||
|
||||
|
||||
|
||||
struct t_gen_cache_item {
|
||||
int operator()(int const & in) const {
|
||||
|
@ -80,23 +80,23 @@ static t_cache cache( t_gen_cache_item(), CACHE_SIZE);
|
|||
|
||||
int hit_me(cache.check( 1 ));
|
||||
check_newest(1, cache);
|
||||
|
||||
|
||||
check_oldest(
|
||||
(i<2) ? i :
|
||||
(i<=CACHE_SIZE + 1) ? 2 :
|
||||
( i<=CACHE_SIZE + 2) ? (i - CACHE_SIZE + 1) : (i - CACHE_SIZE + 2)
|
||||
(i<=CACHE_SIZE + 1) ? 2 :
|
||||
( i<=CACHE_SIZE + 2) ? (i - CACHE_SIZE + 1) : (i - CACHE_SIZE + 2)
|
||||
, cache);
|
||||
|
||||
|
||||
cache.invalidate(4);
|
||||
check_not_present(4, cache);
|
||||
|
||||
|
||||
check_equal(1, hit_me);
|
||||
check_equal(i, from_cache);
|
||||
}
|
||||
cache.invalidate();
|
||||
check_empty(cache);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4: */
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
BOOST_AUTO_TEST_SUITE( unit_map_suite )
|
||||
|
||||
namespace{
|
||||
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_1 ) {
|
||||
|
@ -45,16 +45,16 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
orc_config["random_traits"]=false;
|
||||
unit_type orc_type(orc_config);
|
||||
|
||||
unit orc1_side0_real(&orc_type, 0, true);
|
||||
unit orc2_side0_fake(&orc_type, 0, false);
|
||||
unit orc1_side0_real(&orc_type, 0, true);
|
||||
unit orc2_side0_fake(&orc_type, 0, false);
|
||||
|
||||
unit_map unit_map;
|
||||
|
||||
|
||||
typedef std::pair<unit_map::unit_iterator, bool> t_uresult;
|
||||
t_uresult uresult1 = unit_map.add(map_location(1,1), orc1_side0_real);
|
||||
|
||||
BOOST_CHECK_MESSAGE(uresult1.second == true, "Good Add");
|
||||
|
||||
|
||||
unit_map::unit_iterator ui = unit_map.find(map_location(1,1));
|
||||
BOOST_CHECK_MESSAGE(uresult1.first == ui, "Good Add");
|
||||
BOOST_CHECK_MESSAGE(ui->underlying_id() == orc1_side0_real.underlying_id(), "Found Orc1");
|
||||
|
@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
uresult1 = unit_map.add(map_location(-1,1), orc1_side0_real);
|
||||
BOOST_CHECK_MESSAGE(uresult1.second == false, "Didn't Add at invalid location.");
|
||||
BOOST_CHECK_MESSAGE(uresult1.first == unit_map.end(), "Didn't Add at invalid location.");
|
||||
|
||||
|
||||
|
||||
// std::cerr<<"ID real ="<<orc1_side0_real.underlying_id()<<"\n";
|
||||
// std::cerr<<"ID fake ="<<orc2_side0_fake.underlying_id()<<"\n";
|
||||
|
@ -88,11 +88,11 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
//To check that the collisions will cut off change the cutoff in unit_map.cpp from 1e6 to less than the guard value below
|
||||
// unit_map.add(map_location(1,3), orc2_side0_fake);
|
||||
// unit_map.add(map_location(1,3), orc2_side0_fake);
|
||||
|
||||
|
||||
// unsigned long long guard =0;
|
||||
// for(; guard< 2e2;++guard) {
|
||||
// unit_map.add(map_location(2,guard), orc1_side0_real);
|
||||
// };
|
||||
// };
|
||||
|
||||
// n_unit::id_manager::instance().clear();
|
||||
// std::cerr<<"BREAK\n;";
|
||||
|
@ -105,8 +105,8 @@ BOOST_AUTO_TEST_CASE( test_1 ) {
|
|||
// , "One million uid collision exception");
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4: */
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
@ -250,5 +250,5 @@ private:
|
|||
|
||||
tborder border_;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace{
|
|||
static const config::t_token z_sound("sound", false);
|
||||
static const config::t_token z_NULL_TOD("NULL_TOD", false);
|
||||
static const config::t_token z_nulltod("nulltod", false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
time_of_day::time_of_day(const config& cfg):
|
||||
lawful_bonus(cfg[z_lawful_bonus]),
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace n_token {
|
|||
const t_token & t_token::z_empty() {
|
||||
//This is NOTa memory leak
|
||||
//It is static so it is only allocated once and not de-allocated until the program terminates.
|
||||
///If changed to a static reference it may cause a static de-initialization
|
||||
///If changed to a static reference it may cause a static de-initialization
|
||||
//core dump when the destructor for z_empty is called here before its last use in another file.
|
||||
//Do not remove the = new t_token("", false);
|
||||
static t_token *z_empty = new t_token("", false);
|
||||
|
|
|
@ -39,9 +39,9 @@ namespace n_token {
|
|||
A unique copy of the string is available as a const reference.
|
||||
It is typically reference counted unless explicitly requested otherwise upon construction (i.e for static strings)
|
||||
|
||||
The copying of tokens is faster than the creation of tokens, because a reference object isn't created.
|
||||
The copying of tokens is faster than the creation of tokens, because a reference object isn't created.
|
||||
Hence use static tokens as replacements for constant string literals in the code in a local scope, as follows:
|
||||
static const t_token z_some_string("some_string", false);
|
||||
static const t_token z_some_string("some_string", false);
|
||||
@see below on caveats in Static Initialization
|
||||
|
||||
@note It is intentionally inconvenient to convert to std::string. Allowing automatic conversion would allow
|
||||
|
@ -49,25 +49,25 @@ namespace n_token {
|
|||
make a std::string conversion operator.
|
||||
|
||||
@par @b Static Initialization and Deinitializtion @b
|
||||
Static initialization problems can occur when a static file local variable from one compilation unit/file is
|
||||
Static initialization problems can occur when a static file local variable from one compilation unit/file is
|
||||
accessed in a function called from another compilation unit/file during static initialization/de-initialization.
|
||||
The initialization order is not specified in the C++ spec and hence potentially random. There are 3 ways to fix
|
||||
The initialization order is not specified in the C++ spec and hence potentially random. There are 3 ways to fix
|
||||
it for 3 different use cases, outlined below.
|
||||
|
||||
@li 1. Create a non-inlined function that allocates (via new) a static pointer to a t_token and return a reference to it.
|
||||
@li 1. Create a non-inlined function that allocates (via new) a static pointer to a t_token and return a reference to it.
|
||||
This is used in z_empty() and is rock solid and never fails. As long as it is not inlined the static allocation is executed once
|
||||
when control passes over the line. It is never de-allocated so it never faces the static de-initialization problem. The downside
|
||||
is that is always results in the overhead of a function call. It is necessary for creating default parameters in function
|
||||
is that is always results in the overhead of a function call. It is necessary for creating default parameters in function
|
||||
declarations.
|
||||
|
||||
@li 2. Use new to allocate a static pointer in a local scope block. This is also rock solid and works for everything except
|
||||
@li 2. Use new to allocate a static pointer in a local scope block. This is also rock solid and works for everything except
|
||||
creaing default parameters in function declarations. This has the slight drawback of the pointer overhead.
|
||||
static t_token *z_empty = new t_token("", false);
|
||||
|
||||
@li 3. Lastly create a static object in a local scope. This is avoids the pointer dereference, but risks a static de-initalization
|
||||
@li 3. Lastly create a static object in a local scope. This is avoids the pointer dereference, but risks a static de-initalization
|
||||
core dump if z_some_string is deallocated before its last use. If you are sure that this function is never called by destructors
|
||||
outside of the compilation unit/file that it is created in, then this method is correct, but a little risky
|
||||
static const t_token z_some_string("some_string", false);
|
||||
static const t_token z_some_string("some_string", false);
|
||||
|
||||
*/
|
||||
|
||||
|
@ -75,7 +75,7 @@ class t_token : public n_interned::t_interned_token<std::string> {
|
|||
public:
|
||||
typedef n_interned::t_interned_token<std::string> t_base;
|
||||
|
||||
t_token() : t_base(z_empty()){}
|
||||
t_token() : t_base(z_empty()){}
|
||||
explicit t_token(std::string const & a , bool is_ref_counted = true) : t_base(a, is_ref_counted) {}
|
||||
t_token(t_token const & a) : t_base(a) {}
|
||||
t_token & operator=(t_token const & a) { this->t_base::operator=(a); return *this;}
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
///Return a default interned object suitable as a default value which won't cause a static initialization error
|
||||
template <char T_defchar>
|
||||
static t_token const & default_value();
|
||||
|
||||
|
||||
inline bool empty() const {return *this == z_empty() ;}
|
||||
|
||||
char const * c_str() const {return static_cast<std::string const &>(*this).c_str();} /// todo remove this kluge for lua.cpp
|
||||
|
@ -105,7 +105,7 @@ template <char T_defval>
|
|||
t_token const & t_token::default_value() {
|
||||
//This is NOTa memory leak
|
||||
//It is static so it is only allocated once and not de-allocated until the program terminates.
|
||||
//If changed to a static reference it may cause a static de-initialization
|
||||
//If changed to a static reference it may cause a static de-initialization
|
||||
//core dump when the destructor for z_empty is called here before its last use in another file.
|
||||
//Do not remove the = new t_token(std::string(1, T_defval), false); part
|
||||
static t_token *z_defval = new t_token(std::string(1, T_defval), false);
|
||||
|
@ -116,7 +116,7 @@ inline std::string operator+(const n_token::t_token &a, const std::string &b) {
|
|||
inline std::string operator+(const std::string &a, const n_token::t_token &b) { return a + static_cast<std::string const &>(b); }
|
||||
inline std::string operator+(const n_token::t_token &a, const char *b) { return static_cast<std::string const &>(a) + b; }
|
||||
inline std::string operator+(const char *a, const n_token::t_token &b) { return a + static_cast<std::string const &>(b); }
|
||||
inline std::string operator+(const n_token::t_token &a, const n_token::t_token &b) {
|
||||
inline std::string operator+(const n_token::t_token &a, const n_token::t_token &b) {
|
||||
return static_cast<std::string const &>(a) + static_cast<std::string const &>(b); }
|
||||
|
||||
}//end namepace
|
||||
|
|
|
@ -316,7 +316,7 @@ bool class_source_parser::parse_source(){
|
|||
// Item with will be at the end of error list.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
f_.open(input_.c_str(),std::ios::in);
|
||||
if (f_.fail()){
|
||||
errors_.add_simple_error("File "+input_ + " can not be opened\n");
|
||||
|
@ -344,8 +344,8 @@ bool class_source_parser::parse_source(){
|
|||
}
|
||||
|
||||
f_.close();
|
||||
|
||||
// Clear all flags ( eg the eof flag ) after closing the file.
|
||||
|
||||
// Clear all flags ( eg the eof flag ) after closing the file.
|
||||
// This will let us reuse the same fstream variable for different files.
|
||||
f_.clear();
|
||||
|
||||
|
|
|
@ -291,8 +291,8 @@ public:
|
|||
|
||||
#ifdef _MSC_VER
|
||||
// MSVC throws an error if this method is private.
|
||||
// so, define it as public to prevent that. The error is:
|
||||
// error C2248: 'schema_validation::class_tag::find_tag' : cannot
|
||||
// so, define it as public to prevent that. The error is:
|
||||
// error C2248: 'schema_validation::class_tag::find_tag' : cannot
|
||||
// access private member declared in class 'schema_validation::class_tag'
|
||||
|
||||
class_tag * find_tag(const std::string & fullpath,
|
||||
|
|
|
@ -150,7 +150,7 @@ public:
|
|||
t_string(const std::string &str, const std::string &textdomain);
|
||||
|
||||
t_string &operator=(t_token const &);
|
||||
template <typename X> t_string &operator=(X const &o) {
|
||||
template <typename X> t_string &operator=(X const &o) {
|
||||
operator=(static_cast<t_token const &>(o)); return *this; }
|
||||
|
||||
t_string &operator=(std::string const &);
|
||||
|
|
14
src/unit.cpp
14
src/unit.cpp
|
@ -1367,8 +1367,8 @@ void unit::remove_ability_by_id(const std::string &ability)
|
|||
}
|
||||
|
||||
bool unit::matches_filter(const vconfig& cfg, const map_location& loc, bool use_flat_tod
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager) const
|
||||
{
|
||||
bool matches = true;
|
||||
|
@ -1412,8 +1412,8 @@ bool unit::matches_filter(const vconfig& cfg, const map_location& loc, bool use_
|
|||
}
|
||||
|
||||
bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc, bool use_flat_tod
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager) const
|
||||
{
|
||||
config::attribute_value cfg_name = cfg[z_name];
|
||||
|
@ -2446,8 +2446,8 @@ static void mod_mdr_merge(config& dst, const config& mod, bool delta)
|
|||
}
|
||||
|
||||
void unit::add_modification(const config::t_token& type, const config& mod, bool no_add
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
, gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager)
|
||||
{
|
||||
|
||||
|
@ -3229,7 +3229,7 @@ std::string get_checksum(const unit& u) {
|
|||
foreach (const config &c, unit_config.child_range( k )) {
|
||||
wcfg.add_child(k, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
DBG_UT << wcfg;
|
||||
|
||||
return wcfg.hash();
|
||||
|
|
|
@ -202,7 +202,7 @@ public:
|
|||
const std::vector<attack_type>& attacks() const { return attacks_; }
|
||||
std::vector<attack_type>& attacks() { return attacks_; }
|
||||
|
||||
int damage_from(const attack_type& attack,bool attacker,const map_location& loc) const {
|
||||
int damage_from(const attack_type& attack,bool attacker,const map_location& loc) const {
|
||||
return resistance_against(attack,attacker,loc); }
|
||||
|
||||
/** A SDL surface, ready for display for place where we need a still-image of the unit. */
|
||||
|
@ -310,18 +310,18 @@ public:
|
|||
const attack_type* attack=NULL,const attack_type* second_attack = NULL,
|
||||
int swing_num =0) const;
|
||||
|
||||
bool get_ability_bool(const config::t_token& ability, const map_location& loc
|
||||
bool get_ability_bool(const config::t_token& ability, const map_location& loc
|
||||
, gamemap const & game_map = *resources::game_map
|
||||
, unit_map const & units =*resources::units
|
||||
, t_teams const & teams = *resources::teams
|
||||
, LuaKernel & lua_kernel = *resources::lua_kernel
|
||||
, tod_manager const & tod_manager = *resources::tod_manager) const;
|
||||
bool get_ability_bool(const config::t_token& ability
|
||||
bool get_ability_bool(const config::t_token& ability
|
||||
, gamemap const & game_map = *resources::game_map
|
||||
, unit_map const & units =*resources::units
|
||||
, t_teams const & teams = *resources::teams
|
||||
, LuaKernel & lua_kernel = *resources::lua_kernel
|
||||
, tod_manager const & tod_manager = *resources::tod_manager) const {
|
||||
, tod_manager const & tod_manager = *resources::tod_manager) const {
|
||||
return get_ability_bool(ability, loc_, game_map, units, teams, lua_kernel, tod_manager);}
|
||||
inline bool get_ability_bool(const std::string& ability, const map_location& loc ) const {
|
||||
return get_ability_bool(config::t_token(ability), loc); }
|
||||
|
|
|
@ -185,7 +185,7 @@ bool unit::get_ability_bool(const config::t_token& ability, const map_location&
|
|||
if (const config &abilities = cfg_.child(z_abilities))
|
||||
{
|
||||
foreach (const config &i, abilities.child_range(ability)) {
|
||||
if (ability_active(ability, i, loc, game_map, units, teams, lua_kernel, tod_manager)
|
||||
if (ability_active(ability, i, loc, game_map, units, teams, lua_kernel, tod_manager)
|
||||
&& ability_affects_self(ability, i, loc))
|
||||
return true;
|
||||
}
|
||||
|
@ -364,8 +364,8 @@ bool unit::ability_active(const std::string& ability,const config& cfg,const map
|
|||
*
|
||||
*/
|
||||
bool unit::ability_affects_adjacent(const std::string& ability, const config& cfg,int dir,
|
||||
const map_location& loc,
|
||||
gamemap const & game_map, unit_map const & units,
|
||||
const map_location& loc,
|
||||
gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager
|
||||
) const
|
||||
|
@ -402,7 +402,7 @@ bool unit::ability_affects_self(const std::string& ability,const config& cfg,con
|
|||
const config &filter = cfg.child(z_filter_self);
|
||||
bool affect_self = cfg[z_affect_self].to_bool(true);
|
||||
if (!filter || !affect_self) return affect_self;
|
||||
return matches_filter(vconfig(filter),
|
||||
return matches_filter(vconfig(filter),
|
||||
loc, cache_illuminates(illuminates, ability),game_map, units, teams, lua_kernel, tod_manager);
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ return config::t_token( res );
|
|||
* cfg: a weapon special WML structure
|
||||
*
|
||||
*/
|
||||
bool attack_type::special_active(gamemap const & game_map, unit_map const & units,
|
||||
bool attack_type::special_active(gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager,
|
||||
const config& cfg, bool self) const
|
||||
|
|
|
@ -114,7 +114,7 @@ class unit_animation
|
|||
void redraw( const frame_parameters& value,const map_location &src, const map_location &dst);
|
||||
std::set<map_location> get_overlaped_hex(const frame_parameters& value,const map_location &src, const map_location &dst);
|
||||
void start_animation(int start_time);
|
||||
const frame_parameters parameters(const frame_parameters & default_val) const {
|
||||
const frame_parameters parameters(const frame_parameters & default_val) const {
|
||||
return get_current_frame().merge_parameters(get_current_frame_time(), (*parameters_).parameters(get_animation_time()-get_begin_time()),default_val); };
|
||||
void clear_halo();
|
||||
bool accelerate;
|
||||
|
|
|
@ -110,7 +110,7 @@ size_t hash_value(progressive_discrete<T> const & a) {
|
|||
|
||||
|
||||
template <class T>
|
||||
T const & progressive_continuous<T>::default_default_value() {
|
||||
T const & progressive_continuous<T>::default_default_value() {
|
||||
static T * defval= new T();
|
||||
return *defval;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ frame_parsed_parameters::frame_parsed_parameters(const frame_builder & builder,
|
|||
}
|
||||
|
||||
bool frame_parsed_parameters::operator==(frame_parsed_parameters const & b) const {
|
||||
return duration_ == b.duration_
|
||||
return duration_ == b.duration_
|
||||
&& image_ == b.image_
|
||||
&& image_diagonal_ == b.image_diagonal_
|
||||
&& image_mod_ == b.image_mod_
|
||||
|
|
|
@ -57,7 +57,7 @@ class progressive_continuous {
|
|||
|
||||
//Do not inline it fixes static initialization problems
|
||||
static T const & default_default_value();
|
||||
|
||||
|
||||
public:
|
||||
progressive_continuous(const n_token::t_token& data = n_token::t_token::z_empty(), int duration = 0) : data_(), input_(data) {
|
||||
progressive_continuous_core(data, duration); }
|
||||
|
@ -220,7 +220,7 @@ class frame_parsed_parameters {
|
|||
|
||||
/// A token to a frame builder which are 10:1 redundant
|
||||
|
||||
///todo a second index to the frame_parameter_token via the builder so that the toke can be
|
||||
///todo a second index to the frame_parameter_token via the builder so that the toke can be
|
||||
///created without constructing the frame parameters
|
||||
typedef n_interned::t_interned_token<frame_parsed_parameters> t_frame_parameter_token;
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ std::pair<unit_map::unit_iterator, bool> unit_map::insert(unit *p) {
|
|||
int guard(0);
|
||||
while (!uinsert.second && (++guard < 1e6) ) {
|
||||
if(guard % 10 == 9){
|
||||
ERR_NG << "\n\nPlease Report this error to https://gna.org/bugs/index.php?18591 "
|
||||
ERR_NG << "\n\nPlease Report this error to https://gna.org/bugs/index.php?18591 "
|
||||
"\nIn addition to the standard details of operating system and wesnoth version "
|
||||
"and how it happened, please answer the following questions "
|
||||
"\n 1. Were you playing mutli-player?"
|
||||
|
@ -189,7 +189,7 @@ std::pair<unit_map::unit_iterator, bool> unit_map::insert(unit *p) {
|
|||
}
|
||||
p->clone(false);
|
||||
uinsert = umap_.insert(std::make_pair(p->underlying_id(), lit )); }
|
||||
if (!uinsert.second) {
|
||||
if (!uinsert.second) {
|
||||
throw "One million collisions in unit_map"; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ attack_type::attack_type(const config& cfg) :
|
|||
if (id() != n_token::t_token::z_empty())
|
||||
icon_ = config::t_token("attacks/" + static_cast<std::string const &>(id()) + ".png");
|
||||
else {
|
||||
static const config::t_token default_icon("attacks/blank-attack.png", false);
|
||||
static const config::t_token default_icon("attacks/blank-attack.png", false);
|
||||
icon_ = default_icon;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ public:
|
|||
/*
|
||||
* cfg: a weapon special WML structure
|
||||
*/
|
||||
bool special_active(gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
bool special_active(gamemap const & game_map, unit_map const & units,
|
||||
t_teams const & teams, LuaKernel & lua_kernel,
|
||||
tod_manager const & tod_manager,
|
||||
const config& cfg, bool self) const;
|
||||
inline bool special_active(const config& cfg, bool self) const {
|
||||
|
|
|
@ -43,12 +43,12 @@ template <typename T, typename T_hasher = boost::hash<T> > class t_interned_toke
|
|||
|
||||
/**
|
||||
@class t_interned_token
|
||||
@brief t_interned_token stores unique copies of an object of type T and returns a reference to an object of type T
|
||||
@brief t_interned_token stores unique copies of an object of type T and returns a reference to an object of type T
|
||||
that allows fast O(1) equality comparison, copying and hashing.
|
||||
A unique copy of the T is available as a const reference.
|
||||
It is typically reference counted unless explicitly requested otherwise upon construction (i.e for static T)
|
||||
|
||||
The copying of interned_tokens is faster than the creation of interned_tokens, because a reference object isn't created.
|
||||
The copying of interned_tokens is faster than the creation of interned_tokens, because a reference object isn't created.
|
||||
Hence use static interned_tokens as replacements for constants in the code, as follows:
|
||||
static const t_interned_token<T> z_some_T_thing(reference_T_thing, false);
|
||||
*/
|
||||
|
@ -59,9 +59,9 @@ public:
|
|||
|
||||
///default constructor.
|
||||
t_interned_token();
|
||||
|
||||
|
||||
///Create token
|
||||
///@param[in] is_ref_counted determines if all tokens of this value will be ref counted.
|
||||
///@param[in] is_ref_counted determines if all tokens of this value will be ref counted.
|
||||
///Static tokens should not be ref counted.
|
||||
explicit t_interned_token(T const & a, bool is_ref_counted = true);
|
||||
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
///For debugging purposes count the number of identical tokens created by
|
||||
///redundant construction of objects.
|
||||
///If the numbers are large enough that construction and hashing of the reference objects is creating a slowdown
|
||||
///then these should then be changed to static objects/copies of tokens to avoid the
|
||||
///then these should then be changed to static objects/copies of tokens to avoid the
|
||||
///repeated cost of constructing the objects.
|
||||
static const unsigned int is_collect_num_stats_ = 0;
|
||||
|
||||
|
@ -135,10 +135,10 @@ public:
|
|||
private:
|
||||
typedef n_ref_counter::t_ref_counter<signed long> t_interned;
|
||||
typedef boost::unordered_map<T, t_interned, T_hasher > t_stash;
|
||||
///The token table
|
||||
///This forces correct static initialization order.
|
||||
///Do not inline.
|
||||
static t_stash & the_stash();
|
||||
///The token table
|
||||
///This forces correct static initialization order.
|
||||
///Do not inline.
|
||||
static t_stash & the_stash();
|
||||
|
||||
///Initialize first default constructed value. The default value is only constructed once.
|
||||
typename t_stash::value_type * first_default_constructed();
|
||||
|
@ -169,7 +169,7 @@ typename t_interned_token<T, T_hasher>::t_stash::value_type * t_interned_token<T
|
|||
t_stash & the_stash_ = the_stash();
|
||||
t_interned default_value_(0);
|
||||
T a = T();
|
||||
|
||||
|
||||
std::pair<typename t_stash::iterator, bool> maybe_inserted = the_stash_.insert(std::make_pair(a, default_value_));
|
||||
|
||||
return &*(maybe_inserted.first);
|
||||
|
@ -191,15 +191,15 @@ t_interned_token<T, T_hasher>::t_interned_token(T const & a , bool is_ref_counte
|
|||
|
||||
static t_stash & the_stash_ = the_stash();
|
||||
static t_interned default_value_(0);
|
||||
|
||||
|
||||
std::pair<typename t_stash::iterator, bool> maybe_inserted = the_stash_.insert(std::make_pair(a, default_value_));
|
||||
assert( maybe_inserted.first != the_stash_.end() );
|
||||
|
||||
iter_ = &*(maybe_inserted.first);
|
||||
if(!is_ref_counted_){
|
||||
if(!is_ref_counted_){
|
||||
//Mark this token as no longer ref counted
|
||||
iter_->second.disable_count();
|
||||
}
|
||||
}
|
||||
inc_ref();
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -223,7 +223,7 @@ t_interned_token<T, T_hasher>::t_interned_token(T const & a , bool is_ref_counte
|
|||
}
|
||||
|
||||
template <typename T, typename T_hasher >
|
||||
t_interned_token<T, T_hasher>::t_interned_token(t_interned_token<T, T_hasher> const & a)
|
||||
t_interned_token<T, T_hasher>::t_interned_token(t_interned_token<T, T_hasher> const & a)
|
||||
: iter_(a.iter_), is_ref_counted_(a.is_ref_counted_) {
|
||||
inc_ref();
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ t_interned_token<T, T_hasher> & t_interned_token<T, T_hasher>::operator=(t_inter
|
|||
|
||||
iter_ = a.iter_;
|
||||
is_ref_counted_ = a.is_ref_counted_;
|
||||
|
||||
|
||||
inc_ref();
|
||||
|
||||
return *this;
|
||||
|
@ -250,12 +250,12 @@ t_interned_token<T, T_hasher>::~t_interned_token() {
|
|||
|
||||
template <typename T, typename T_hasher >
|
||||
void t_interned_token<T, T_hasher>::inc_ref() {
|
||||
if(is_ref_counted_ && valid() && (++(iter_->second) < 0 )) {
|
||||
is_ref_counted_ = false; }
|
||||
if(is_ref_counted_ && valid() && (++(iter_->second) < 0 )) {
|
||||
is_ref_counted_ = false; }
|
||||
}
|
||||
template <typename T, typename T_hasher >
|
||||
void t_interned_token<T, T_hasher>::dec_ref() {
|
||||
if(is_ref_counted_ && valid() && ( (--(iter_->second)) == 0)) {
|
||||
if(is_ref_counted_ && valid() && ( (--(iter_->second)) == 0)) {
|
||||
static t_stash & the_stash_ = the_stash();
|
||||
///@todo upgrade to quick_erase when boost 1.42 is supported
|
||||
the_stash_.erase(iter_->first); }
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
///@param[in] max_size the maximum size of the cache before items are discarded
|
||||
///@param[in] dummy_value a dummy value used internally to insert fake values into the cache
|
||||
t_lru_cache(t_comp const & c, size_t max_size, t_value const & dummy_value = t_value())
|
||||
: key_to_valpos_(), lru_list_(), comp_(c), max_size_(max_size), dummy_item_(dummy_value)
|
||||
: key_to_valpos_(), lru_list_(), comp_(c), max_size_(max_size), dummy_item_(dummy_value)
|
||||
, stat_hit_(0), stat_miss_(0), stat_erased_(0){}
|
||||
t_lru_cache(t_lru_cache const & a)
|
||||
: key_to_valpos_(a.key_to_valpos_), lru_list_(a.lru_list_), comp_(a.comp_)
|
||||
|
@ -106,7 +106,7 @@ public:
|
|||
if(found){
|
||||
//++stat_hit_;
|
||||
mark_used(kv_it);
|
||||
return kv_it->second.first;
|
||||
return kv_it->second.first;
|
||||
}
|
||||
|
||||
//cache miss
|
||||
|
@ -129,14 +129,14 @@ public:
|
|||
}
|
||||
void invalidate(t_key const & k){
|
||||
kv_iterator found (key_to_valpos_.find(k));
|
||||
if(found != key_to_valpos_.end()){ //Cache hit
|
||||
if(found != key_to_valpos_.end()){ //Cache hit
|
||||
lru_list_.erase(found->second.second);
|
||||
///todo Change to quick_erase when wesnoth supports boost 1.4?6
|
||||
key_to_valpos_.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
///For debugging only. Check for a cache hit.
|
||||
///For debugging only. Check for a cache hit.
|
||||
///@note Don't use this in real code, just call check. It is faster
|
||||
bool debugging_test_cache(t_key const & k) const {
|
||||
typename t_key_to_value::const_iterator found (key_to_valpos_.find(k));
|
||||
|
|
|
@ -383,7 +383,7 @@ struct vconfig_expand_visitor : public config::attribute_value::default_visitor
|
|||
void operator()(config::t_token const & token){
|
||||
config::t_token cp(token);
|
||||
utils::interpolate_variables_into_token(cp, *repos);
|
||||
val = cp;
|
||||
val = cp;
|
||||
}
|
||||
void operator()(const t_string &s){
|
||||
val = utils::interpolate_variables_into_tstring(s, *repos);
|
||||
|
@ -583,17 +583,17 @@ static const config::t_token z_rbracket("]", false);
|
|||
|
||||
|
||||
typedef config::t_token t_token;
|
||||
struct t_parsed {
|
||||
struct t_parsed {
|
||||
enum {NO_INDEX = -1};
|
||||
t_parsed(t_token const & a, int i = NO_INDEX):token(a),index(i){}
|
||||
t_parsed(t_parsed const & a):token(a.token), index(a.index){}
|
||||
t_token token;
|
||||
t_token token;
|
||||
int index; };
|
||||
|
||||
typedef std::vector<t_parsed> t_parsed_tokens;
|
||||
|
||||
class t_parse_token {
|
||||
public:
|
||||
public:
|
||||
t_parsed_tokens operator()(config::t_token const & key) const {
|
||||
//an example varname is "unit_store.modifications.trait[0]"
|
||||
|
||||
|
@ -611,16 +611,16 @@ public:
|
|||
case '.' :
|
||||
case '[':
|
||||
case ']':
|
||||
throw game::wml_syntax_error(skey, i, "the first character of identifier is one of these, .[] invalid characters" );
|
||||
throw game::wml_syntax_error(skey, i, "the first character of identifier is one of these, .[] invalid characters" );
|
||||
}
|
||||
}
|
||||
if(is_lbrack){
|
||||
switch(c){
|
||||
case '.' :
|
||||
case '[':
|
||||
throw game::wml_syntax_error(skey, i, "a dot . or left bracket [ after left bracket [ starting the variable name");
|
||||
case '[':
|
||||
throw game::wml_syntax_error(skey, i, "a dot . or left bracket [ after left bracket [ starting the variable name");
|
||||
break;
|
||||
case ']':
|
||||
case ']':
|
||||
std::string index_str(skey.substr(i_start_of_token, i - i_start_of_token ));
|
||||
std::istringstream is(index_str);
|
||||
size_t index;
|
||||
|
@ -630,7 +630,7 @@ public:
|
|||
index = game_config::max_loop;
|
||||
}
|
||||
parsed_tokens.back().index = index;
|
||||
|
||||
|
||||
//adjust for dot after lbrack as in "unit_store.modifications.trait[0].y"
|
||||
if (i < (iend-1) ) {
|
||||
char next_c = skey[i+1] ;
|
||||
|
@ -658,7 +658,7 @@ public:
|
|||
++i;
|
||||
}
|
||||
if(i_start_of_token != i){
|
||||
parsed_tokens.push_back(t_token(skey.substr(i_start_of_token, i - i_start_of_token )));
|
||||
parsed_tokens.push_back(t_token(skey.substr(i_start_of_token, i - i_start_of_token )));
|
||||
}
|
||||
|
||||
return parsed_tokens;
|
||||
|
@ -679,7 +679,7 @@ void activate_scope_variable(t_parsed_tokens const & tokens)
|
|||
if(recursive_activation){ return; }
|
||||
|
||||
if(! tokens.empty()){
|
||||
|
||||
|
||||
config::t_token const & first((tokens.begin()->token));
|
||||
|
||||
std::vector<scoped_wml_variable*>::reverse_iterator rit;
|
||||
|
@ -765,9 +765,9 @@ void variable_info::init(const config::t_token& varname, bool force_valid) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
vars = &vars->child(i->token, inner_index);
|
||||
vars = &vars->child(i->token, inner_index);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
//Process the last token
|
||||
|
||||
|
@ -830,7 +830,7 @@ void variable_info::init(const config::t_token& varname, bool force_valid) {
|
|||
}
|
||||
}
|
||||
|
||||
variable_info::variable_info(const config::t_token& varname, bool force_valid, TYPE validation_type)
|
||||
variable_info::variable_info(const config::t_token& varname, bool force_valid, TYPE validation_type)
|
||||
: vartype(validation_type), is_valid_(false), explicit_index_(false), key(varname), index(0), vars(NULL) {
|
||||
init( varname, force_valid) ;}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ private:
|
|||
void init(const config::t_token& varname, bool force_valid=true);
|
||||
TYPE vartype; ///default is TYPE_UNSPECIFIED
|
||||
bool is_valid_;
|
||||
bool explicit_index_; ///true if query ended in [...] specifier
|
||||
bool explicit_index_; ///true if query ended in [...] specifier
|
||||
public: ///todo make these private
|
||||
config::t_token key; /// the name of the internal attribute or child
|
||||
size_t index; /// the index of the child
|
||||
|
|
|
@ -58,7 +58,7 @@ recruit::recruit(size_t team_index, bool hidden, const std::string& unit_name, c
|
|||
recruit_hex_(recruit_hex),
|
||||
temp_unit_(create_corresponding_unit()),
|
||||
valid_(true),
|
||||
fake_unit_(create_corresponding_unit()),
|
||||
fake_unit_(create_corresponding_unit()),
|
||||
temp_cost_()
|
||||
{
|
||||
this->init();
|
||||
|
@ -79,7 +79,7 @@ recruit::recruit(config const& cfg, bool hidden)
|
|||
|
||||
// Construct temp_unit_ and fake_unit_
|
||||
temp_unit_ = create_corresponding_unit();
|
||||
fake_unit_.reset(create_corresponding_unit()),
|
||||
fake_unit_.reset(create_corresponding_unit()),
|
||||
|
||||
this->init();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue