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 708665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:24:59+00:00 2026-05-14T04:24:59+00:00

EDIT – The code looks strange here, so I suggest viewing the files directly

  • 0
  • EDIT – The code looks strange here, so I suggest viewing the files directly in the link given.

While working on my engine, I came across a issue that I’m unable to resolve. Hoping to fix this without any heavy modification, the code is below.

void Block::DoCollision(GameObject* obj){
 obj->DoCollision(this);
}

That is where the stack overflow occurs. This application works perfectly fine until I create two instances of the class using the new keyword. If I only had 1 instance of the class, it worked fine.

Block* a = new Block(0, 0, 0, 5);
AddGameObject(a);
a = new Block(30, 0, 0, 5);
AddGameObject(a);

Those parameters are just x,y,z and size.

The code is checked before hand. Only a object with a matching Collisonflag and collision type will trigger the DoCollision(); function.

((*list1)->m_collisionFlag & (*list2)->m_type)

Maybe my check is messed up though. I attached the files concerned here http://celestialcoding.com/index.php?topic=1465.msg9913;topicseen#new. You can download them without having to sign up. The main suspects, I also pasted the code for below.

From GameManager.cpp

void GameManager::Update(float dt){
 GameList::iterator list1;

 for(list1=m_gameObjectList.begin(); list1 != m_gameObjectList.end(); ++list1){
  GameObject* temp = *list1;

  // Update logic and positions
  if((*list1)->m_active){
   (*list1)->Update(dt);
 //  Clip((*list1)->m_position); // Modify for bounce affect
  } else continue;

  // Check for collisions
  if((*list1)->m_collisionFlag != GameObject::TYPE_NONE){
   GameList::iterator list2;
   for(list2=m_gameObjectList.begin(); list2 != m_gameObjectList.end(); ++list2){
    if(!(*list2)->m_active)
     continue;
    if(list1 == list2)
     continue;
    if( (*list2)->m_active && 
     ((*list1)->m_collisionFlag & (*list2)->m_type) && 
     (*list1)->IsColliding(*list2)){
      (*list1)->DoCollision((*list2));
    }
   }
  }
  if(list1==m_gameObjectList.end()) break;
 }
 GameList::iterator end    = m_gameObjectList.end();
 GameList::iterator newEnd = remove_if(m_gameObjectList.begin(),m_gameObjectList.end(),RemoveNotActive);
 if(newEnd != end)
        m_gameObjectList.erase(newEnd,end);
}

void GameManager::LoadAllFiles(){
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Top.bmp",   GetNextFreeID());
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Right.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Back.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Left.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Front.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Models/Skybox/Images/Bottom.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Terrain/Textures/Terrain1.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Terrain/Textures/Terrain2.bmp",  GetNextFreeID());
 LoadSkin(m_gameTextureList, "Terrain/Details/TerrainDetails.bmp", GetNextFreeID());
 LoadSkin(m_gameTextureList, "Terrain/Textures/Water1.bmp",   GetNextFreeID());




 Block* a = new Block(0, 0, 0, 5);
 AddGameObject(a);
 a = new Block(30, 0, 0, 5);
 AddGameObject(a);
 Player* d = new Player(0, 100,0);
 AddGameObject(d);
}



void Block::Draw(){

 glPushMatrix();
  glTranslatef(m_position.x(), m_position.y(), m_position.z());
  glRotatef(m_facingAngle, 0, 1, 0);
  glScalef(m_size, m_size, m_size);
  glBegin(GL_LINES);
   glColor3f(255, 255, 255);
   glVertex3f(m_boundingRect.left, m_boundingRect.top, m_position.z());
   glVertex3f(m_boundingRect.right, m_boundingRect.top, m_position.z());
   glVertex3f(m_boundingRect.left, m_boundingRect.bottom, m_position.z());
   glVertex3f(m_boundingRect.right, m_boundingRect.bottom, m_position.z());

   glVertex3f(m_boundingRect.left, m_boundingRect.top, m_position.z());
   glVertex3f(m_boundingRect.left, m_boundingRect.bottom, m_position.z());
   glVertex3f(m_boundingRect.right, m_boundingRect.top, m_position.z());
   glVertex3f(m_boundingRect.right, m_boundingRect.bottom, m_position.z());
  glEnd();
 //  DrawBox(m_position.x(), m_position.y(), m_position.z(), m_size, m_size, m_size, 8);
 glPopMatrix();
}

void Block::DoCollision(GameObject* obj){
 GameObject* t = this;   // I modified this to see for sure that it was causing the mistake.
// obj->DoCollision(NULL); // Just revert it back to 
/*
void Block::DoCollision(GameObject* obj){  
       obj->DoCollision(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-14T04:25:00+00:00Added an answer on May 14, 2026 at 4:25 am

    Stack overflow usually comes from infinite recursion. I’m having trouble parsing your question, but here’s a guess:

    void Block::DoCollision(GameObject* obj){
      if (this != obj) {
        obj->DoCollision(this);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Michael Kaplan has a blog post where he explains how… May 14, 2026 at 9:22 pm
  • Editorial Team
    Editorial Team added an answer You can use this code : CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0,… May 14, 2026 at 9:22 pm
  • Editorial Team
    Editorial Team added an answer You should use setStroke to set a stroke of the… May 14, 2026 at 9:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.