Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6068723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:44:44+00:00 2026-05-23T09:44:44+00:00

This is a bizarre problem. I’ve got a void function that performs a for

  • 0

This is a bizarre problem. I’ve got a void function that performs a for loop and nothing else, but the for loop doesn’t ever start, even though the function is being called. Here is the function:

void Cell::Consolidate()
{
    cout << "Consolidating (outside)...\n";
    for(int i = 0; i < m_Tiles.size(); ++i)
    {
        cout << "Consolidating (inside)...\n";
        int row = m_Tiles[i]->GetRow();
        int col = m_Tiles[i]->GetCol();
        //Check below.
        if((*m_pTileMap)[row + 1][col].pParentCell != this)
        {
            m_EdgeTiles.push_back(m_Tiles[i]);
            m_Tiles[i]->SetColor(sf::Color(100, 100, 100));
            bool newNeighbor = true;
            for(int j = 0; j < m_Neighbors.size(); ++j)
            {
                if(m_Neighbors[j] == (*m_pTileMap)[row + 1][col].pParentCell)
                {
                    newNeighbor = false;
                    break;
                }
            }
            if(newNeighbor)
            {
                m_Neighbors.push_back((*m_pTileMap)[row + 1][col].pParentCell);
            }
        }
        //Check above.
        else if((*m_pTileMap)[row - 1][col].pParentCell != this)
        {
            m_EdgeTiles.push_back(m_Tiles[i]);
            m_Tiles[i]->SetColor(sf::Color(100, 100, 100));
            bool newNeighbor = true;
            for(int j = 0; j < m_Neighbors.size(); ++j)
            {
                if(m_Neighbors[j] == (*m_pTileMap)[row - 1][col].pParentCell)
                {
                    newNeighbor = false;
                    break;
                }
            }
            if(newNeighbor)
            {
                m_Neighbors.push_back((*m_pTileMap)[row - 1][col].pParentCell);
            }
        }
        //Check the right.
        else if((*m_pTileMap)[row][col + 1].pParentCell != this)
        {
            m_EdgeTiles.push_back(m_Tiles[i]);
            m_Tiles[i]->SetColor(sf::Color(100, 100, 100));
            bool newNeighbor = true;
            for(int j = 0; j < m_Neighbors.size(); ++j)
            {
                if(m_Neighbors[j] == (*m_pTileMap)[row][col + 1].pParentCell)
                {
                    newNeighbor = false;
                    break;
                }
            }
            if(newNeighbor)
            {
                m_Neighbors.push_back((*m_pTileMap)[row][col + 1].pParentCell);
            }
        }
        //Check the left.
        else if((*m_pTileMap)[row][col - 1].pParentCell != this)
        {
            m_EdgeTiles.push_back(m_Tiles[i]);
            m_Tiles[i]->SetColor(sf::Color(100, 100, 100));
            bool newNeighbor = true;
            for(int j = 0; j < m_Neighbors.size(); ++j)
            {
                if(m_Neighbors[j] == (*m_pTileMap)[row][col - 1].pParentCell)
                {
                    newNeighbor = false;
                    break;
                }
            }
            if(newNeighbor)
            {
                m_Neighbors.push_back((*m_pTileMap)[row][col - 1].pParentCell);
            }
        }
    }
}

When I run the program, "Consolidating (outside)...\n" gets send to cout, but "Consolidating (inside)...\n" does not. Nothing that is supposed to happen in the loop actually happens, either (for example the SetColor() calls don’t do anything, nor does anything happen if I send things to cout anywhere else in the loop), so I can only assume the loop is not starting at all. Why not? What could cause this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:44:45+00:00Added an answer on May 23, 2026 at 9:44 am
    i < m_Tiles.size()
    

    This loop condition gets checked on entrance to the loop, not only after each iteration. If your m_Tiles vector is empty, well, no loop for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this is downright bizarre. I am building a web application that relies on
I have this bizarre problem. I'm making a checklist program with XCode and I'm
I am facing this bizarre problem in my asp.net mvc application: In one page
Hello I have a bizarre problem with sprintf . Here's my code: void draw_number(int
This is a math problem, but I'm sure this must come up in some
This question is a spin-off/evolution of this question . (That question got marked as
I have a bizarre problem that is doing my head in. I have the
I have a bizarre problem that is causing us problems. We have a simple
I've got a bizarre problem with my menu for a site I'm making. And
This problem is bizarre. I have never encountered anything like it before. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.