Sign in to follow this  
rpg gamer 17

Hum... Trouble...

Recommended Posts

Programming Language: C++ Compiler: MV C++ 2008 What is an easy safe way to change a location in a list<bool> from true to false? besides:
		for(list<bool>::iterator OpenS = OpenSurface.begin(); OpenS != OpenSurface.end(); OpenS++) {
			if(Num == Number)
			{
				list<bool> temp;
				temp.push_back(false);
				list<bool>::iterator value = temp.begin();
				iter_swap(value, OpenSurface.begin());
			}
			Num++;
		}


Also: Unhandled exception at 0x00d43a00 in GameEngine.exe: 0xC0000005: Access violation reading location 0x00000000. I get this when I run the debugger. It breaks to line 832 in the list header file. The error only happens when I close the program. If I run the exe by itself it stops responding.
 #if _HAS_ITERATOR_DEBUGGING
		this->_Orphan_ptr(*this, 0);
 #endif /* _HAS_ITERATOR_DEBUGGING */

		_Nodeptr _Pnext;
		_Nodeptr _Pnode = _Nextnode(_Myhead); //<-- here
		_Nextnode(_Myhead) = _Myhead;
		_Prevnode(_Myhead) = _Myhead;
		_Mysize = 0;


I only have one list in my program.
class GraphicEngine
{
private:
	SDL_Surface* ReturnImage; //Returned surface for Images
	Surface* Surfaces;
	list<bool> OpenSurface;
...
GraphicEngine::GraphicEngine(short int TOTAL = 50)
{
	Surfaces = new Surface [TOTAL];
	for(int num = 0; num < TOTAL; num++)
	{
		Surfaces[num].X = -1;
		Surfaces[num].Y = -1;
		Surfaces[num].Layer = 0;
		Surfaces[num].TotalFrames = 0;
		Surfaces[num].StartingFrame = -1;
		Surfaces[num].ColorKeyOn = false;
		Surfaces[num].R = 0;
		Surfaces[num].G = 0;
		Surfaces[num].B = 0;
		Surfaces[num].Alpha = SDL_ALPHA_OPAQUE;
		Surfaces[num].Image = NULL;
		Surfaces[num].Text = NULL;
		Surfaces[num].Started = false;
		OpenSurface.push_back(true);
	}
}


Share this post


Link to post
Share on other sites
Short and simple. I like it. Thanks!
Now for the pesky error I'm getting.
Here are a few details on what I have set in the compiler:

Properties->C/C++->Code Generation->Runtime Library->Multi-Threaded DLL (/MD)
Properties->C/C++->Preprocessor->Preprocessor Definitions: WIN32;_CONSOLE
Properties->Linker->Input->Additional Dependencies->SDL.lib SDLmain.lib SDL_image.lib SDL_ttf.lib SDL_mixer.lib


I'm pretty sure that's all I've changed. I took out _DEBUG; from the preprocessor because it kept throwing errors with list and SDL.

Share this post


Link to post
Share on other sites
Quote:
Original post by rpg gamer 17
I took out _DEBUG; from the preprocessor because it kept throwing errors with list and SDL.


correct me if im wrong but couldnt you put _NDEBUG instead of deleting it? seems safer to me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this