mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 22:29:15 +00:00
Append private variables with an underscore.
This commit is contained in:
parent
c26c750d49
commit
b304723c5b
@ -161,9 +161,9 @@ game_state::game_state() :
|
|||||||
snapshot(),
|
snapshot(),
|
||||||
last_selected(map_location::null_location),
|
last_selected(map_location::null_location),
|
||||||
rng_(),
|
rng_(),
|
||||||
variables(),
|
variables_(),
|
||||||
temporaries(),
|
temporaries_(),
|
||||||
generator_setter(&recorder),
|
generator_setter_(&recorder),
|
||||||
classification_(),
|
classification_(),
|
||||||
mp_settings_(),
|
mp_settings_(),
|
||||||
phase_(INITIAL),
|
phase_(INITIAL),
|
||||||
@ -260,9 +260,9 @@ game_state::game_state(const config& cfg, bool show_replay) :
|
|||||||
snapshot(),
|
snapshot(),
|
||||||
last_selected(map_location::null_location),
|
last_selected(map_location::null_location),
|
||||||
rng_(cfg),
|
rng_(cfg),
|
||||||
variables(),
|
variables_(),
|
||||||
temporaries(),
|
temporaries_(),
|
||||||
generator_setter(&recorder),
|
generator_setter_(&recorder),
|
||||||
classification_(cfg),
|
classification_(cfg),
|
||||||
mp_settings_(cfg),
|
mp_settings_(cfg),
|
||||||
phase_(INITIAL),
|
phase_(INITIAL),
|
||||||
@ -360,7 +360,7 @@ void game_state::write_snapshot(config& cfg) const
|
|||||||
cfg["end_text"] = classification_.end_text;
|
cfg["end_text"] = classification_.end_text;
|
||||||
cfg["end_text_duration"] = str_cast<unsigned int>(classification_.end_text_duration);
|
cfg["end_text_duration"] = str_cast<unsigned int>(classification_.end_text_duration);
|
||||||
|
|
||||||
cfg.add_child("variables", variables);
|
cfg.add_child("variables", variables_);
|
||||||
|
|
||||||
for(std::map<std::string, wml_menu_item *>::const_iterator j=wml_menu_items.begin();
|
for(std::map<std::string, wml_menu_item *>::const_iterator j=wml_menu_items.begin();
|
||||||
j!=wml_menu_items.end(); ++j) {
|
j!=wml_menu_items.end(); ++j) {
|
||||||
@ -482,7 +482,7 @@ config::attribute_value game_state::get_variable_const(const std::string &key) c
|
|||||||
variable_info to_get(key, false, variable_info::TYPE_SCALAR);
|
variable_info to_get(key, false, variable_info::TYPE_SCALAR);
|
||||||
if (!to_get.is_valid)
|
if (!to_get.is_valid)
|
||||||
{
|
{
|
||||||
config::attribute_value &to_return = temporaries[key];
|
config::attribute_value &to_return = temporaries_[key];
|
||||||
if (key.size() > 7 && key.substr(key.size() - 7) == ".length") {
|
if (key.size() > 7 && key.substr(key.size() - 7) == ".length") {
|
||||||
// length is a special attribute, so guarantee its correctness
|
// length is a special attribute, so guarantee its correctness
|
||||||
to_return = 0;
|
to_return = 0;
|
||||||
@ -551,9 +551,9 @@ game_state::game_state(const game_state& state) :
|
|||||||
snapshot(),
|
snapshot(),
|
||||||
last_selected(),
|
last_selected(),
|
||||||
rng_(),
|
rng_(),
|
||||||
variables(),
|
variables_(),
|
||||||
temporaries(),
|
temporaries_(),
|
||||||
generator_setter(&recorder),
|
generator_setter_(&recorder),
|
||||||
classification_(),
|
classification_(),
|
||||||
mp_settings_(),
|
mp_settings_(),
|
||||||
phase_(INITIAL),
|
phase_(INITIAL),
|
||||||
@ -585,7 +585,7 @@ game_state& game_state::operator=(const game_state& state)
|
|||||||
starting_pos = state.starting_pos;
|
starting_pos = state.starting_pos;
|
||||||
snapshot = state.snapshot;
|
snapshot = state.snapshot;
|
||||||
last_selected = state.last_selected;
|
last_selected = state.last_selected;
|
||||||
variables = state.variables;
|
variables_ = state.variables_;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -595,7 +595,7 @@ game_state::~game_state() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void game_state::set_variables(const config& vars) {
|
void game_state::set_variables(const config& vars) {
|
||||||
variables = vars;
|
variables_ = vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -999,7 +999,7 @@ void game_state::write_config(config_writer& out, bool write_variables) const
|
|||||||
out.write_key_val("random_seed", lexical_cast<std::string>(rng_.get_random_seed()));
|
out.write_key_val("random_seed", lexical_cast<std::string>(rng_.get_random_seed()));
|
||||||
out.write_key_val("random_calls", lexical_cast<std::string>(rng_.get_random_calls()));
|
out.write_key_val("random_calls", lexical_cast<std::string>(rng_.get_random_calls()));
|
||||||
if (write_variables) {
|
if (write_variables) {
|
||||||
out.write_child("variables", variables);
|
out.write_child("variables", variables_);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<std::string, wml_menu_item *>::const_iterator j = wml_menu_items.begin();
|
for(std::map<std::string, wml_menu_item *>::const_iterator j = wml_menu_items.begin();
|
||||||
|
@ -90,7 +90,7 @@ public:
|
|||||||
std::vector<scoped_wml_variable*> scoped_variables;
|
std::vector<scoped_wml_variable*> scoped_variables;
|
||||||
std::map<std::string, wml_menu_item*> wml_menu_items;
|
std::map<std::string, wml_menu_item*> wml_menu_items;
|
||||||
|
|
||||||
const config& get_variables() const { return variables; }
|
const config& get_variables() const { return variables_; }
|
||||||
void set_variables(const config& vars);
|
void set_variables(const config& vars);
|
||||||
|
|
||||||
void set_menu_items(const config::const_child_itors &menu_items);
|
void set_menu_items(const config::const_child_itors &menu_items);
|
||||||
@ -172,10 +172,10 @@ public:
|
|||||||
map_location last_selected;
|
map_location last_selected;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rand_rng::simple_rng rng_ ;
|
rand_rng::simple_rng rng_;
|
||||||
config variables;
|
config variables_;
|
||||||
mutable config temporaries; // lengths of arrays, etc.
|
mutable config temporaries_; // lengths of arrays, etc.
|
||||||
const rand_rng::set_random_generator generator_setter; /**< Make sure that rng is initialized first */
|
const rand_rng::set_random_generator generator_setter_; /**< Make sure that rng is initialized first */
|
||||||
friend struct variable_info;
|
friend struct variable_info;
|
||||||
game_classification classification_;
|
game_classification classification_;
|
||||||
mp_game_settings mp_settings_;
|
mp_game_settings mp_settings_;
|
||||||
|
@ -585,7 +585,7 @@ variable_info::variable_info(const std::string& varname,
|
|||||||
assert(repos != NULL);
|
assert(repos != NULL);
|
||||||
activate_scope_variable(varname);
|
activate_scope_variable(varname);
|
||||||
|
|
||||||
vars = &repos->variables;
|
vars = &repos->variables_;
|
||||||
key = varname;
|
key = varname;
|
||||||
std::string::const_iterator itor = std::find(key.begin(),key.end(),'.');
|
std::string::const_iterator itor = std::find(key.begin(),key.end(),'.');
|
||||||
int dot_index = key.find('.');
|
int dot_index = key.find('.');
|
||||||
@ -634,17 +634,17 @@ variable_info::variable_info(const std::string& varname,
|
|||||||
case variable_info::TYPE_CONTAINER:
|
case variable_info::TYPE_CONTAINER:
|
||||||
WRN_NG << "variable_info: using reserved WML variable as wrong type, "
|
WRN_NG << "variable_info: using reserved WML variable as wrong type, "
|
||||||
<< varname << std::endl;
|
<< varname << std::endl;
|
||||||
is_valid = force_valid || repos->temporaries.child(varname);
|
is_valid = force_valid || repos->temporaries_.child(varname);
|
||||||
break;
|
break;
|
||||||
case variable_info::TYPE_SCALAR:
|
case variable_info::TYPE_SCALAR:
|
||||||
default:
|
default:
|
||||||
// Store the length of the array as a temporary variable
|
// Store the length of the array as a temporary variable
|
||||||
repos->temporaries[varname] = int(size);
|
repos->temporaries_[varname] = int(size);
|
||||||
is_valid = true;
|
is_valid = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
key = varname;
|
key = varname;
|
||||||
vars = &repos->temporaries;
|
vars = &repos->temporaries_;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user