• Advertisement
Sign in to follow this  

("this-_Mycont != NULL", 0)

This topic is 3343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I compile my game and everything is fine until I try shooting, whenever I try it an error window pops up with the message '("this->_Mycont != NULL", 0)' I placed a comment over the line which I think causes the problem(removing it makes the problem go away)... Any idea why this is happening? Thanks
void update(Application &application,
			Input &input, 
			std::vector<Object> &game_objects)
{
	std::vector<Object>::iterator it = game_objects.begin();

	if(input.move_forward)
	{
		it->move(get_displacement());	
	}    
	if(input.move_backward)
	{
		it->move(-get_displacement());
	}
	if(input.turn_right)
	{
		it->rotate(get_theta());
	}
	if(input.turn_left)
	{
		it->rotate(-get_theta());
	}

	//Attack
	DWORD time = timeGetTime();
	if(input.shooting == true)
	{
		if((time - it->get_time_since_last_shot()) > get_cooldown())
		{
			SpriteInstance sprite_instance(application.get_sprite("missile"));
			Object object(it->get_position(),
						  it->get_rotation(),
						  0,
						  sprite_instance);
			object.move(get_displacement());

			//This line of code is what causes the problem
			game_objects.push_back(object);
		}
	}

	it++;
	for(; it != game_objects.end(); it++)
	{
		it->move(10);
	}
}

Share this post


Link to post
Share on other sites
Advertisement
Well everything looks fine on the surface and since you do not have any message box commands my best guess is that yoru problem actualy lies in the game objects vector. You may want to try and debug the code and make sure that your object is being constrcuted properly and its fully valid when you pass it into the game object list. Without seeing abit more code i cannot see and problems as it is. ("this->_Mycont != NULL", 0) <-- this partuclar error from what i can tell is saying that the objects list Count aka the number of objects or data stored in the list / vector is not valid so my guess would be make sur eyou are passing a valid object list as well.

Remmeber the debugger is your friend.

Regards Joue.

Share this post


Link to post
Share on other sites
When you call push_back, changing the size of the vector, it invalidates any current iterators. Options are: recreate the iterator with game_objects.begin() + offset, iterate the old-fashioned way (by int index), or use a std::list.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement