Results 1 to 10 of 23

Thread: PGDmC: Knight Fever

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #20
    function grabCollisionArrayPixel(xz,yz:integer;xx,yy:intege r) : byte;
    begin
    if ((yz mod 512) = 0) then inc(yz);
    if ((xz mod 512) = 0) then inc(xz);
    if(yy < 1) then yy := 1;
    if(xx < 1) then xx := 1;
    try
    result := arrayCollisionPixels[yy,xx]^[ (512 * (yz mod 512)) + (xz mod 512) ];
    except
    raise exception.create('Bad memory access');
    writeln('SIGSEGV noted');
    result := 255;
    end;
    end;

    If anybody could help me with stopping this from crashing I would majorly appreciate it. It's certainly not xx and yy being out of bound, and the second value can range from 0 to 262144. By my calculations, (512 * (yz mod 512)) + (xz mod 512) should never be larget than 262143, even if yz and xz are both 511. So any ideas?
    What about if yz or xz are negative?
    eg
    xz = -10;

    xz mod 512 gives a result -10 (!!)
    Last edited by Jimmy Valavanis; 30-03-2012 at 04:08 PM.

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
  •