Removed very dangerous unused parameter from conditional_passed (game_state),

the function gets the game_state directly from a global variable ignoring
completely the passed parameter
This commit is contained in:
Isaac Clerencia Perez 2004-07-27 19:23:13 +00:00
parent 7d537053b2
commit 43e81e3514
3 changed files with 6 additions and 8 deletions

View file

@ -31,8 +31,7 @@
namespace game_events {
bool conditional_passed(game_state& state_of_game,
const std::map<gamemap::location,unit>* units,
bool conditional_passed(const std::map<gamemap::location,unit>* units,
const config& cond)
{
//an 'or' statement means that if the contained statements are true,
@ -40,7 +39,7 @@ bool conditional_passed(game_state& state_of_game,
const config::child_list& or_statements = cond.get_children("or");
for(config::child_list::const_iterator or_it = or_statements.begin();
or_it != or_statements.end(); ++or_it) {
if(conditional_passed(state_of_game,units,**or_it)) {
if(conditional_passed(units,**or_it)) {
return true;
}
}
@ -567,7 +566,7 @@ bool event_handler::handle_event_command(const queued_event& event_info, const s
const std::string fail = (cmd == "if" ? "else" : "");
for(size_t i = 0; i != max_iterations; ++i) {
const std::string type = game_events::conditional_passed(
*state_of_game,units,cfg) ? pass : fail;
units,cfg) ? pass : fail;
if(type == "") {
break;

View file

@ -65,8 +65,7 @@ bool fire(const std::string& event,
const gamemap::location& loc1=gamemap::location::null_location,
const gamemap::location& loc2=gamemap::location::null_location);
bool conditional_passed(game_state& state_of_game,
const std::map<gamemap::location,unit>* units,
bool conditional_passed(const std::map<gamemap::location,unit>* units,
const config& cond);
bool pump();

View file

@ -58,7 +58,7 @@ void show_intro(display& screen, const config& data,
const std::pair<const std::string*, const config*> item = *i;
if (*item.first == "if") {
const std::string type = game_events::conditional_passed(
state_of_game, NULL, *item.second) ? "then":"else";
NULL, *item.second) ? "then":"else";
const config::child_list& thens = (*item.second).get_children(type);
for (config::child_list::const_iterator t = thens.begin();
@ -386,7 +386,7 @@ void show_map_scene(display& screen, config& data, game_state& state_of_game)
if(*item.first == "if") {
const std::string type = game_events::conditional_passed(
state_of_game, NULL, *item.second) ? "then":"else";
NULL, *item.second) ? "then":"else";
const config* const thens = (*item.second).child(type);
if(thens == NULL) {
std::cerr << "no map scene this way...\n";