READ: error in invalid memory area what does that mean?

Non-platform specific questions.

READ: error in invalid memory area what does that mean?

Postby jimmynewguy » Tue Jul 28, 2009 7:45 pm

I keep getting a run time error on line 28, i've tried everything i know how to but no result..... can anyone help me? the code is here and if you don't know how to fix it can anyone tell me what it means? Thanx. The code is to get the closest enemy1 and set the targetx and targety as their x2 & y2. I marked line 28
Code: Select all
int n;
double mindist = 100;
actors = getAllActorsInCollision("Event Actor", &n);


if(actors)
{
  int i;
  for(i = 0; i < n; i++)
  {
    if(strcmp(actors[i].name, "enemy1") == 0)
    {
       double d = distance(parent.x, parent.y, actors[i].x2, actors[i].y2);
       if(d < mindist)
       {
           closest = (actors + i);
           mindist = d;
       }
    }
  }
}
if(!closest)
{
targetx = -500;
targety = 3000;
}
else if(closest)
{
targetx = closest->x2;//LINE 28 IS THIS ONE
targety = closest->y2;//WHY NO ERROR HERE?
}

targetx = closest->x2; again for anger lol
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: READ: error in invalid memory area what does that mean?

Postby makslane » Tue Jul 28, 2009 8:19 pm

Try put:

Code: Select all
closest = NULL;


before your code
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: READ: error in invalid memory area what does that mean?

Postby jimmynewguy » Tue Jul 28, 2009 8:24 pm

Code: Select all
Actor *actors, *closest = NULL;

i had that in global, but it works in code thanx mak, looks like i own you one....again :) It's kind of ironic that you helped me right that original code....
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest