|
From: | Alex Olivas |
Subject: | Re: [Swarm-Support] Segmentation Violation |
Date: | Mon, 25 Oct 2004 18:54:08 -0600 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 |
Steve Railsback wrote:
That actually turned out to be the problem. I thought it odd that if the position were off the grid [world getObjectAtX: xPos+deltaX Y: yPos+deltaY] would return a non-nil value.Alex Olivas wrote:I modified bug slightly to "interact" with nearest neighbor bugs. I would like for an individual bug's step to depend on the state of the bugs around it. I defined a simple method called getRole, - (int)getRole; { return role; } My code compiles just fine, but when I run it crashes in the bug's step method at the line...int neighborRole = [[world getObjectAtX: xPos+deltaX Y: yPos+deltaY] getRole];One thing to check very carefully is whether (xPos+deltaX) or (yPos+deltaY) could ever exceed the size of world. If they do, I think you'll get a segmentation fault.Steve R.
The line just before the one above checks this... if([world getObjectAtX: xPos+deltaX Y: yPos+deltaY]!= nil){ //printf("x: %d y: %d\n",xPos+deltaX,yPos+deltaY); //xprint([world getObjectAtX: xPos+deltaX Y: yPos+deltaY]);int neighborRole = [[world getObjectAtX: xPos+deltaX Y: yPos+deltaY] getRole];
Thanks, Alex.
[Prev in Thread] | Current Thread | [Next in Thread] |