Results 1 to 10 of 30

Thread: Yet another segfault (a.k.a. Darkhog is a total noob)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    No, function that is used is TGameObject.isColliding(GO:TGameObject). But thanks for suggestion, will try to check that.

  2. #2
    Nope, checked if it is in range and still segfaults.

  3. #3
    Are you sure CurrentSprite is a valid index?

    You should not do this, , but try this, it will avoid anything wrong :

    Code:
    function TGameObject.isColliding(Sprite: TSprite): Boolean;
    begin
      Result:=false; //setting result, just in case
    
      if (not Assigned(self)) or (not Assigned(Sprite)) then Exit;
    
      case ObjectMode of
        omAnim:   begin
                    if (CurrentAnim>0) and (CurrentAnim<=Animations.Items.Count-1) then
                    if Assigned(Animations.Items[CurrentAnim]) then //safety check so we won't get segfault
                      //setting result
                      Result:=Animations.Items[CurrentAnim].IsColliding(Sprite);
                    end;
        omSprite: begin
                    if (CurrentSprite>0) and (CurrentSprite<=Animations.Items.Count-1) then
                    if Sprites.Items[CurrentSprite]<>nil then //safety check so we won't get segfault
                      //setting result
                      Result:=Sprites.Items[CurrentSprite].IsColliding(Sprite);
                  end;
      end;
    end;

  4. #4
    I'm telling you this is not the right function, you're looking at! It
    Quote Originally Posted by Darkhog View Post
    is TGameObject.isColliding(GO:TGameObject).
    But I've used this code and it still crashes.

  5. #5
    Had another quick look on the github. Are you calling right constructor for TAnimatedSprite?
    Code:
    constructor TGameObject.Create(mode: TObjectMode);
    begin
      if mode=omAnim then Animations:=TAnimatedSpriteList.create;
    the .Create is TObject.Create, it seems. The .Create without parameters is not written to either TAnimatedSprite or TSprite.
    Last edited by User137; 18-07-2013 at 03:49 PM.

  6. #6
    *TAnimatedSpriteList. And for a while I've thought you're right, but TAnimatedSpriteList.create is defined on line 186 of Sprites.pas.

    Anyway, it then would crash as soon as I'd enter TDebugState since collision is checked constantly and thus Animations is accessed constantly and it only crashes if I make both game objects touch each other.

    It may be something with TAnimatedSprite class though.

  7. #7
    Any help? I can't pinpoint the issue at all!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •