mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +00:00
Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
parent
104be6c8ac
commit
8a48246ed1
168 changed files with 1280 additions and 1280 deletions
|
@ -172,7 +172,7 @@ void Game::setup(Mode mode)
|
|||
on_game_end(GameOverReason::NewGame, m_score);
|
||||
|
||||
for (auto& stack : stacks())
|
||||
stack.clear();
|
||||
stack->clear();
|
||||
|
||||
m_new_deck.clear();
|
||||
m_new_game_animation_pile = 0;
|
||||
|
@ -256,14 +256,14 @@ void Game::mousedown_event(GUI::MouseEvent& event)
|
|||
|
||||
auto click_location = event.position();
|
||||
for (auto& to_check : stacks()) {
|
||||
if (to_check.type() == CardStack::Type::Waste)
|
||||
if (to_check->type() == CardStack::Type::Waste)
|
||||
continue;
|
||||
|
||||
if (to_check.bounding_box().contains(click_location)) {
|
||||
if (to_check.type() == CardStack::Type::Stock) {
|
||||
if (to_check->bounding_box().contains(click_location)) {
|
||||
if (to_check->type() == CardStack::Type::Stock) {
|
||||
draw_cards();
|
||||
} else if (!to_check.is_empty()) {
|
||||
auto& top_card = to_check.peek();
|
||||
} else if (!to_check->is_empty()) {
|
||||
auto& top_card = to_check->peek();
|
||||
|
||||
if (top_card.is_upside_down()) {
|
||||
if (top_card.rect().contains(click_location)) {
|
||||
|
@ -356,8 +356,8 @@ void Game::mousemove_event(GUI::MouseEvent& event)
|
|||
|
||||
for (auto& to_intersect : moving_cards()) {
|
||||
mark_intersecting_stacks_dirty(to_intersect);
|
||||
to_intersect.rect().translate_by(dx, dy);
|
||||
update(to_intersect.rect());
|
||||
to_intersect->rect().translate_by(dx, dy);
|
||||
update(to_intersect->rect());
|
||||
}
|
||||
|
||||
m_mouse_down_location = click_location;
|
||||
|
@ -380,11 +380,11 @@ void Game::doubleclick_event(GUI::MouseEvent& event)
|
|||
|
||||
auto click_location = event.position();
|
||||
for (auto& to_check : stacks()) {
|
||||
if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
|
||||
if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
|
||||
continue;
|
||||
|
||||
if (to_check.bounding_box().contains(click_location) && !to_check.is_empty()) {
|
||||
auto& top_card = to_check.peek();
|
||||
if (to_check->bounding_box().contains(click_location) && !to_check->is_empty()) {
|
||||
auto& top_card = to_check->peek();
|
||||
if (!top_card.is_upside_down() && top_card.rect().contains(click_location))
|
||||
attempt_to_move_card_to_foundations(to_check);
|
||||
|
||||
|
@ -418,7 +418,7 @@ void Game::draw_cards()
|
|||
update(waste.bounding_box());
|
||||
update(play.bounding_box());
|
||||
|
||||
NonnullRefPtrVector<Card> moved_cards;
|
||||
Vector<NonnullRefPtr<Card>> moved_cards;
|
||||
while (!play.is_empty()) {
|
||||
auto card = play.pop();
|
||||
stock.push(card).release_value_but_fixme_should_propagate_errors();
|
||||
|
@ -458,7 +458,7 @@ void Game::draw_cards()
|
|||
|
||||
update(stock.bounding_box());
|
||||
|
||||
NonnullRefPtrVector<Card> cards_drawn;
|
||||
Vector<NonnullRefPtr<Card>> cards_drawn;
|
||||
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
|
||||
auto card = stock.pop();
|
||||
cards_drawn.prepend(card);
|
||||
|
@ -509,7 +509,7 @@ bool Game::attempt_to_move_card_to_foundations(CardStack& from)
|
|||
mark_intersecting_stacks_dirty(card);
|
||||
foundation.push(card).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
NonnullRefPtrVector<Card> moved_card;
|
||||
Vector<NonnullRefPtr<Card>> moved_card;
|
||||
moved_card.append(card);
|
||||
remember_move_for_undo(from, foundation, moved_card);
|
||||
|
||||
|
@ -538,7 +538,7 @@ void Game::auto_move_eligible_cards_to_foundations()
|
|||
while (true) {
|
||||
bool card_was_moved = false;
|
||||
for (auto& to_check : stacks()) {
|
||||
if (to_check.type() != CardStack::Type::Normal && to_check.type() != CardStack::Type::Play)
|
||||
if (to_check->type() != CardStack::Type::Normal && to_check->type() != CardStack::Type::Play)
|
||||
continue;
|
||||
|
||||
if (attempt_to_move_card_to_foundations(to_check))
|
||||
|
@ -567,17 +567,17 @@ void Game::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
if (is_moving_cards()) {
|
||||
for (auto& card : moving_cards())
|
||||
card.clear(painter, background_color);
|
||||
card->clear(painter, background_color);
|
||||
}
|
||||
|
||||
for (auto& stack : stacks()) {
|
||||
stack.paint(painter, background_color);
|
||||
stack->paint(painter, background_color);
|
||||
}
|
||||
|
||||
if (is_moving_cards()) {
|
||||
for (auto& card : moving_cards()) {
|
||||
card.paint(painter);
|
||||
card.save_old_position();
|
||||
card->paint(painter);
|
||||
card->save_old_position();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,14 +585,14 @@ void Game::paint_event(GUI::PaintEvent& event)
|
|||
if (is_moving_cards()) {
|
||||
check_for_game_over();
|
||||
for (auto& card : moving_cards())
|
||||
card.set_moving(false);
|
||||
card->set_moving(false);
|
||||
}
|
||||
|
||||
clear_moving_cards();
|
||||
}
|
||||
}
|
||||
|
||||
void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards)
|
||||
void Game::remember_move_for_undo(CardStack& from, CardStack& to, Vector<NonnullRefPtr<Card>> moved_cards)
|
||||
{
|
||||
m_last_move.type = LastMove::Type::MoveCards;
|
||||
m_last_move.from = &from;
|
||||
|
@ -604,7 +604,7 @@ void Game::remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrV
|
|||
|
||||
void Game::remember_flip_for_undo(Card& card)
|
||||
{
|
||||
NonnullRefPtrVector<Card> cards;
|
||||
Vector<NonnullRefPtr<Card>> cards;
|
||||
cards.append(card);
|
||||
m_last_move.type = LastMove::Type::FlipCard;
|
||||
m_last_move.cards = cards;
|
||||
|
@ -618,7 +618,7 @@ void Game::perform_undo()
|
|||
return;
|
||||
|
||||
if (m_last_move.type == LastMove::Type::FlipCard) {
|
||||
m_last_move.cards.at(0).set_upside_down(true);
|
||||
m_last_move.cards[0]->set_upside_down(true);
|
||||
if (on_undo_availability_change)
|
||||
on_undo_availability_change(false);
|
||||
invalidate_layout();
|
||||
|
@ -641,7 +641,7 @@ void Game::perform_undo()
|
|||
if (m_last_move.from->type() == CardStack::Type::Stock) {
|
||||
auto& waste = stack_at_location(Waste);
|
||||
auto& play = stack_at_location(Play);
|
||||
NonnullRefPtrVector<Card> cards_popped;
|
||||
Vector<NonnullRefPtr<Card>> cards_popped;
|
||||
for (size_t i = 0; i < m_last_move.cards.size(); i++) {
|
||||
if (!waste.is_empty()) {
|
||||
auto card = waste.pop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue