Archived

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

strange crash.

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

why does my program crash when it tries to execute this line: dCollide.start->x = dWeapon[xLoop].x; here is some info:
  
typedef struct
{
  PR_POINT *start,
            end,
            sphere;
  PR_RAY    ray;
} COLLISIONTYPE;

typedef struct
{
  float x,
        y,
        z,
        xvel,
        yvel,
        angle;
  int   type;
} WEAPONTYPE;

COLLISIONTYPE dCollide;
WEAPONTYPE    dWeapon[500];
  
The loop goes from 0 to 499, so its not an out of array bounds issue. What could be the problem? -Rich

Share this post


Link to post
Share on other sites
dCollide.start->x = dWeapon[xLoop].x could easily crash if you never allocated the "start" variable.

In your code it''s listed as a pointer, so if you never allocated it memory equal to the sizeof PR_POINT it would crash.



Gary

Share this post


Link to post
Share on other sites
You didn''t give much info to go on, but here''s a couple of shots in the dark.

Does xLoop go greater than 499 or less than zero?

Do you create a new "start" member before assigning the value? (Perhaps you don''t really want start to be a pointer to a PR_POINT?)

Share this post


Link to post
Share on other sites