Results 1 to 3 of 3

Thread: [OGL] !AddGlobalType Error with TBoxArray

  1. #1
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default [OGL] !AddGlobalType Error with TBoxArray

    Hi I'm trying to create a TBoxArray and store Tboxes into it, but I'm running into an error whenever I try to put a TBox into an index of the array. Here is the code:
    Simba Code:
    procedure tlobby.setupSorts();
    var
      boxTextures : GlTextureArray;
      boxLength, i : Integer;
      boxArray : TBoxArray;
      temp : TBox;
    begin
      boxTextures := ogl.getTextures(11475);
      boxLength := length(boxTextures);
      for i := 0 to boxLength do
        boxArray[i] := TBox(boxTextures[i].bounds);

      self.pingBox := boxArray[boxLength-1];
      if self.compareBoxes(boxArray[boxLength-1], boxArray[boxLength-2]) then
        self.typeBox := boxArray[boxLength-4]
      else if self.compareBoxes(boxArray[boxLength-2], boxArray[boxLength-3]) then
        self.typeBox := boxArray[boxLength-4]
      else
        self.typeBox := boxArray[boxLength-3];


      self.sortByType := (ogl.getTextures(10, self.typeBox).indexes() = 0);
      self.sortByPing := (ogl.getTextures(10, self.pingBox).indexes() = 0);
      writeln(sortByType,  ' ',  sortByPing);
    end;

    function tlobby.compareBoxes(box1, box2 : TBox): boolean;
    begin
      if (box1.x1 = box2.x1) and (box1.x2 = box2.x2) and
         (box1.y1 = box2.y1) and (box1.y2 = box2.y2) then
        result := true
      else
        result := false;
    end;

    And here is the error:
    Simba Code:
    12:29:38 | debugTextureHighlight > setup
    ERROR comes from a non-existing file (!addGlobalType)
    Error: Access violation at line 1
    Execution failed.
    The following bitmaps were not freed: [0]

    Keep in mind I ran it from another file so the access violation is from the first file.

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    It seems that you haven't considered the length of the box array at the start. These sorts of errors are usually caused by accessing array indices that don't exist. I'd throw a quick if length(X) < 5 then Exit into the function so that you aren't getting negative indices.

    E: If that doesn't work then good luck, that's the only way I've ever seen the vague errors like this before.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  3. #3
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    That did it! I didn't have any textures found when I started it, so it was trying to get the bounds of nothing
    EDIT: NEVERMIND @3Garrett3;! I added a check for box length, and that fixed part of it, and I checked that the .bounds returns a tbox, which it does. But it is still giving the error when I try to assign it to the BoxArray[0].
    EDIT2: GOT IT! I had to set the length:
    Simba Code:
    setLength(boxArray, boxLength);


    (sorry arrays I love you still)
    Last edited by Justin; 07-20-2015 at 10:29 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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