Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DarkSaint

break point in code

This topic is 5220 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

I''m having a problem where when I try to run this function I get booted to a disassembly screen with the address 6720796D ???. I''m getting an access violation... First-chance exception in Game.exe: 0xC0000005: Access Violation. Can anyone see what might be causing this in this funciton?
void InitSprite (unzFile* ZipFile, SPRITEDATA* thissprite)
{
	BYTE* ImageBuffer;		//image buffer for loading sprite textures.

	BYTE* AniFileBuff;		//animation file buffer.

	char SprSeqName[32];	//sprites animation sequence name.	

	char SprAniFile[32];	//sprites animation file name.


	//a archived zip file info structure one for sequence info and the other for animation file info.

	unz_file_info sequenceinfo;		
	unz_file_info aninfo;

	//add a sprite manager node.

	SPRITEMANAGER* thisspritemanager = AddSpriteManager();

	//get the sprites animation file name.

	sprintf(SprAniFile,"s%s%",thissprite->SprName,".anm");

	//locat the animation file in the zip archive

	unzLocateFile OF((ZipFile, SprAniFile, 2));

	//open the animation file

	if(unzOpenCurrentFile(ZipFile) != UNZ_OK)
	{
					//return E_FAIL;

	}
		
	//get information about the file.

	unzGetCurrentFileInfo OF((ZipFile, &aninfo, NULL, 0, NULL,0,NULL,0));

	//create a buffer for the animation file.

	AniFileBuff = new BYTE [aninfo.uncompressed_size];

	//fill the buffer with the animation file.

	if(unzReadCurrentFile( ZipFile, AniFileBuff, aninfo.uncompressed_size ) != aninfo.uncompressed_size)
	{
		//return E_FAIL;

	}

	//create an input string stream for the file.

	std::istringstream AniSS ((char *)AniFileBuff, std::istringstream::in);

	//get the number of sequences the sprite has from the animation file.

	AniSS >> thisspritemanager->SmngNumSequences;

	thissprite->SprNumSequences = thisspritemanager->SmngNumSequences;

	//allocate some arrays for holding information pertaining to the sprites animation.

	thisspritemanager->SmngSeqCounterMax = new unsigned short [thisspritemanager->SmngNumSequences];
	thisspritemanager->SmngFramesInSequence = new unsigned short [thisspritemanager->SmngNumSequences];
	thisspritemanager->pSmngTextureReference = new LPDIRECT3DTEXTURE9[thisspritemanager->SmngNumSequences];

	thissprite->SprSeqCounterMax = new unsigned short [thissprite->SprNumSequences];
	thissprite->SprFramesInSequence = new unsigned short [thissprite->SprNumSequences];
	thissprite->pSprTexture = new LPDIRECT3DTEXTURE9[thissprite->SprNumSequences];

	//loop through the sprites sequences and fill in the sprites needed data.

	for (int j = 0; j < thissprite->SprNumSequences; j++)
	{
		//get the sprites sequence counter and the number of frames in the current sequence

		AniSS >> thisspritemanager->SmngSeqCounterMax[j] >> thisspritemanager->SmngFramesInSequence[j];

		thissprite->SprSeqCounterMax[j] = thisspritemanager->SmngSeqCounterMax[j];
		thissprite->SprFramesInSequence[j] = thisspritemanager->SmngFramesInSequence[j];

		//get the sprites sequence name.

		sprintf(SprSeqName,"%s%d%s",thissprite->SprName, j,".png");

		//locate the sequence file in the zip file.

		unzLocateFile OF((ZipFile, SprSeqName, 2));

		//open the sequence file.

		if( unzOpenCurrentFile(ZipFile) != UNZ_OK)
		{
			//return E_FAIL;

		}

		//get info aobut the sequence file.

		unzGetCurrentFileInfo OF((ZipFile, &sequenceinfo, NULL, 0, NULL,0,NULL,0));

		//create a buffer for the sequence file.

		ImageBuffer = new BYTE [sequenceinfo.uncompressed_size];

		//fill the sequence file buffer.

		if(unzReadCurrentFile( ZipFile, ImageBuffer, sequenceinfo.uncompressed_size ) != sequenceinfo.uncompressed_size)
		{
			//return E_FAIL;

		}
				
		//create a directx texture from the sequence file buffer.

		D3DXIMAGE_INFO ImageInfo;
		if( FAILED( D3DXCreateTextureFromFileInMemoryEx( g_pd3dDevice, ImageBuffer,
		sequenceinfo.uncompressed_size,0,0,1,0,D3DFMT_UNKNOWN,D3DPOOL_DEFAULT,D3DX_FILTER_NONE,0,0x00FF00FF,&ImageInfo,NULL, &thisspritemanager->pSmngTextureReference[j] ) ) )
		{
			delete [] ImageBuffer;
			//return E_FAIL;

		}

		thissprite->pSprTexture[j] = thisspritemanager->pSmngTextureReference[j];
		unzCloseCurrentFile( ZipFile);

		delete [] ImageBuffer;

	}
	thisspritemanager->SmngSprite_ID = thissprite->Spr_ID;
}

Share this post


Link to post
Share on other sites
Advertisement
That''s an awful lot of code to look through (not to mention lots of pointers). Find out what statement in the code its going wrong before expecting people to look through it.

Zorx (a Puzzle Bobble clone)
Discontinuity (an animation system for POV-Ray)

Share this post


Link to post
Share on other sites
If you get that dialog, it means you''re not running your program through the debugger.

The debugger is your friend.

No, let me re-phrase that: the debugger is your girlfriend.

No, wait, this is better: the debugger is your always ready and willing sex kitten, with a clear bill of health.

If you don''t know how to use your debugger, then drop everything, and learn.

Whenever you write new code, or change old code, set a breakpoint in that code while you''re editing it. Then make sure you hit that code when running your program. Single-step through the new bit, and inspect variable values, to make sure that all the values and control flow are right. More often than not, you''ll find they aren''t, and you would have had a really hard to find bug, if you hadn''t had this habit.

Now close the browser. Your sex kitten is waiting!

Share this post


Link to post
Share on other sites
well, it''s always easier to try and get other people to solve your problems for you but I whent through the debugger and found the problem. Thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by DarkSaint
well, it''s always easier to try and get other people to solve your problems for you but I whent through the debugger and found the problem. Thanks.


It may seem easier in the short term, but in the last year, I must''ve used my debugger at least 50 times. If I came to a forum every time and waited for someone to dissect my code to find the error, I''d have missed a hell of a lot of deadlines.

No offense to you really, I''m just griping because I don''t know how many times it''s happened where I''m sitting in the computer lab, an assignment is due in the next few hours and I have a lineup of people asking me to look at their code and tell them why their code is segfaulting.

I just don''t understand why they didn''t teach how to use GDB or KDebug or something like that in my first-year programming courses. I mean, showing only how to do a backtrace on a program with GDB takes all of five minutes and it can do wonders for a segfaulting program. Yet still at the end of second year, I would have people giving me blank stares when I asked them if they used a debugger to find what''s crashing their code... *sighs*

-Auron

Share this post


Link to post
Share on other sites
quote:
Original post by hplus0603
No, wait, this is better: the debugger is your always ready and willing sex kitten, with a clear bill of health.
...
Now close the browser. Your sex kitten is waiting!

That analogy could lead to many a keyboard replacement

Share this post


Link to post
Share on other sites
quote:
Original post by Auron

It may seem easier in the short term, but in the last year, I must''ve used my debugger at least 50 times. If I came to a forum every time and waited for someone to dissect my code to find the error, I''d have missed a hell of a lot of deadlines.

No offense to you really, I''m just griping because I don''t know how many times it''s happened where I''m sitting in the computer lab, an assignment is due in the next few hours and I have a lineup of people asking me to look at their code and tell them why their code is segfaulting.

I just don''t understand why they didn''t teach how to use GDB or KDebug or something like that in my first-year programming courses. I mean, showing only how to do a backtrace on a program with GDB takes all of five minutes and it can do wonders for a segfaulting program. Yet still at the end of second year, I would have people giving me blank stares when I asked them if they used a debugger to find what''s crashing their code... *sighs*

-Auron


Most professors expect students to learn that kind of thing on their own. In fact, in some schools, the professors will only even talk about the language that they want you to program in for a few weeks, then go straight into complex projects! Ask the kids that go (or went) to Berkeley or MIT about it...from what I''ve heard, they have to use Scheme from the get-go.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!