Skip to content

Commit

Permalink
C'est fou >_<
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Nov 28, 2017
1 parent 3230d11 commit 60793c7
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/game_events/manager.cpp
Expand Up @@ -145,6 +145,8 @@ static handler_ptr lock_ptr(const handler_list& list, handler_list::iterator ite
if(iter != list.end()) {
if(handler_ptr ptr = iter->lock()) {
return ptr;
} else {
std::cerr << "We're not supposed to be here...";
}
}

Expand All @@ -159,22 +161,25 @@ handler_ptr manager::iteration::operator*()
{
// Get the candidate for the current element from the main list.
handler_ptr main_ptr = lock_ptr(main_list_, main_it_);
handler_vec::size_type main_index = ptr_index(main_ptr);
//handler_vec::size_type main_index = ptr_index(main_ptr);

// Get the candidate for the current element from the var list.
handler_ptr var_ptr = lock_ptr(var_list_, var_it_);

// (Loop while var_ptr would be chosen over main_ptr, but the name does not match.)
while(var_ptr && var_ptr->index() < main_index && !var_ptr->matches_name(event_name_, gamedata_)) {
// If we have a variable-name event but the name doesn't match, keep iterating
// until we find a match. If we reach var_list_ end, var_ptr will be nullptr.
while(var_ptr /*&& var_ptr->index() < main_index*/ && !var_ptr->matches_name(event_name_, gamedata_)) {
var_ptr = lock_ptr(var_list_, ++var_it_);
}

handler_vec::size_type var_index = ptr_index(var_ptr);
//handler_vec::size_type var_index = ptr_index(var_ptr);

// Which list? (Index ties go to the main list.)
current_is_known_ = main_index < end_ || var_index < end_;
//current_is_known_ = main_ptr != nullptr || var_ptr != nullptr;
main_is_current_ = main_index <= var_index;
//current_is_known_ = main_index < end_ || var_index < end_;
//main_is_current_ = main_index <= var_index;

current_is_known_ = main_ptr != nullptr || var_ptr != nullptr;
main_is_current_ = var_ptr == nullptr;

if(!current_is_known_) {
return nullptr; // End of list; return a null pointer.
Expand Down

0 comments on commit 60793c7

Please sign in to comment.