Revert incorrect logic changes from std::ranges conversion
Commite385ff1c3b
switched various sites to use projection to extract a value and avoid use of a predicate. Two of the converted sites need to use a predicate in order to test for a value being unequal to a constant, rather than testing for equality ase385ff1c3b
did. Fixes:e385ff1c3b
("Use std::ranges::find_if instead of std::find_if")
This commit is contained in:
parent
2dd538eb4d
commit
7981fd1b17
|
@ -3034,7 +3034,7 @@ static unsigned net_udp_send_request(void)
|
|||
// game, non-zero if there is some problem.
|
||||
auto b = Netgame.players.begin();
|
||||
auto e = Netgame.players.end();
|
||||
const auto &&i = std::ranges::find(b, e, player_connection_status::disconnected, &netplayer_info::connected);
|
||||
const auto &&i = std::ranges::find_if(b, e, [](const netplayer_info &ni) { return ni.connected != player_connection_status::disconnected; });
|
||||
if (i == e)
|
||||
{
|
||||
Assert(false);
|
||||
|
|
|
@ -682,13 +682,19 @@ static void newmenu_scroll(newmenu *const menu, const int amount)
|
|||
menu->scroll_offset = nitems - menu->max_on_menu;
|
||||
return;
|
||||
}
|
||||
/* Otherwise, at least one element is not of type text. Find that element.
|
||||
*/
|
||||
const auto &range = menu->items;
|
||||
const auto find_value = nm_type::text;
|
||||
const auto find_projection = &newmenu_item::type;
|
||||
const auto &&first = std::ranges::find(range, find_value, find_projection);
|
||||
const auto predicate = [](const newmenu_item &n) {
|
||||
return n.type != nm_type::text;
|
||||
};
|
||||
const auto &&first = std::ranges::find_if(range, predicate);
|
||||
if (first == range.end())
|
||||
/* This should not happen. If every entry is of type `nm_type::text`,
|
||||
* then `menu->all_text` should have been true.
|
||||
*/
|
||||
return;
|
||||
const auto &&rlast = std::ranges::find(range.rbegin(), std::reverse_iterator<newmenu_item *>(first), find_value, find_projection).base();
|
||||
const auto &&rlast = std::ranges::find_if(std::reverse_iterator(range.end()), std::reverse_iterator(first), predicate).base();
|
||||
/* `first == rlast` should not happen, since that would mean that
|
||||
* there are no elements in `range` for which `predicate` is true.
|
||||
* If there are no such elements, then `first == range.end()` should
|
||||
|
|
Loading…
Reference in a new issue