• Advertisement
Sign in to follow this  

SDL Parachute deployed...WHY?

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

Hi all...Okay, I have two rooms in my game. When the player enters the first room, everything works fine. When he enters the second room, (which is set up EXACTLY like the first one) the prog crashes and I get the SDL parachute deployed message. I've scanned the forum for other postings of this, and all I can devise is that 1) there may be a problem using SDL_rect(which I use in the first room and it works fine) or there may be a problem using the same names for the rect and it's pointers in both rooms. Any thoughtS?

Share this post


Link to post
Share on other sites
Advertisement
Run the debugger. Usually, it catches a segmentation fault (you might be reading outside of an array, through a null pointer, or there is some memory corruption).

Once you figure out where it crashes, you can figure out why it crashes.

Share this post


Link to post
Share on other sites
Well I can't read the debugger too well. It lists 'frames invalid' about 20 times in a row, and there is a 'segmentation fault' right below where it receives a signal SIGSEGV.

also I see frame-address-end in frame-function-name drawString(...)
does that mean it's memory corruption?

Share this post


Link to post
Share on other sites
Run through the debugger and post some code from the area where it crashes.

Share this post


Link to post
Share on other sites
how do I know if the debugger found the crash? I can't understand the thing at all. But I will post the section of code where the crash occurs:

#ifndef FONTROOM_CPP
#define FONTROOM_CPP

#include "function_protos.h"
#include "font.h"

void FontRoom()
{
Uint8* keys;
SDL_Rect panel = {0, 520, 800, 80};
SDL_Rect *ppanel = &panel;

SDLFont *amertype = initFont("data/fonts/amertype_512",0,0,0);
SDLFont *arial = initFont("data/fonts/arial_512",0,0,0);
SDLFont *benguiat = initFont("data/fonts/benguiat_512",0,0,0);
SDLFont *hattenschweiler = initFont("data/fonts/hattenschweiler_512",0,0,0);
SDLFont *goudy = initFont("data/fonts/goudy_512",0,0,0);

SDLFont *franklin = initFont("data/fonts/franklin_512",1,1,1);
SDLFont *kabel = initFont("data/fonts/kabel_512",1,1,1);

SDL_FillRect(screen,NULL,0xFFFFFF);
SDL_FillRect(screen,ppanel,0x000000);

drawString(screen,amertype,1,1,"AmerType 512");
drawString(screen,arial,1,21,"Arial 512");
drawString(screen,benguiat,1,41,"Benguiat 512");
drawString(screen,hattenschweiler,1,81,"Hattenschweiler 512");
drawString(screen,goudy,1,101,"Goudy 512");

drawString(screen,franklin,1,521,"Franklin 256");
drawString(screen,kabel,1,541,"Kabel 256");

SDL_Flip(screen);

while(done == 0)
{
SDL_Event event;
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT ) { done = 1; }
if ( event.type == SDL_KEYDOWN )
{
if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
}
}
keys = SDL_GetKeyState(NULL);
if ( keys[SDLK_DOWN] ) { Street(130, 400);}
}
freeFont(amertype);
freeFont(benguiat);
freeFont(arial);
freeFont(hattenschweiler);
freeFont(goudy);
freeFont(franklin);
freeFont(kabel);
}
#endif



All I want to do is test out some fonts for later development here. There's no player, no action, just pressing 'down' to exit the room. Like I said before, this same system works in another room.

Share this post


Link to post
Share on other sites
my sincere apologies...I am a goofus. I had included two bad directories for the fonts and now it's all cleared up. But I do have another question I've been meaning to post...how to I lower the sensitivity of the keys, so that when I push the left arrow it doesn't register like 3 or 4 key presses?
for instance, I want to push the letter 'm' to increase money by 100. but when I press it, the money rolls up to about 500 or 600. How to fix this, and sorry if I should have started a new thread for this...

Share this post


Link to post
Share on other sites
keys = SDL_GetKeyState(NULL);
if ( keys[SDLK_DOWN] ) { Street(130, 400);}

This type of code should be in the while ( SDL_PollEvent(&event) ) loop, if its outside, then it will trigger for every frame that you have your finger on the button. And since your program is probably running 100's of frames a second, you'd have to be extremely quick to register only 1 keypress..

Bascially you should be checking like for the key like you check for the ESC

I hope that helps

Share this post


Link to post
Share on other sites
Quote:
Original post by mattor
how do I know if the debugger found the crash?


Place breakpoints in your code then step through the program. When it crashes, look at the line of code that the debugger was on.

Share this post


Link to post
Share on other sites
is it possible to make an array of functions, like Func[20] or whatever so you can call a certain function based on a collision?
i want to check collision with a lot of doors, and then call whatever function is behind the door I hit.

Share this post


Link to post
Share on other sites
An SDL Parachute deploy usually happens when you attempt to point to data that does not exist. Make sure you check if your pointers are NULL before you actually use them.

Share this post


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

  • Advertisement