Results 1 to 10 of 20

Thread: Tracking segfaults

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sprite is created IN Tchunk.draw. This is because how they are handled in game - they are created as necessary and destroyed when no longer needed. Because of that memory used by game is about 30... MB and it should in theory run even on old 128mb machines.

  2. #2
    well ok i guess as long as you are not loading resources there. anyways looks like problem lies around* tsprite.create
    Last edited by laggyluk; 24-06-2013 at 12:04 PM.

  3. #3
    I can send you sources, if you want to look into it.

  4. #4

  5. #5
    Quote Originally Posted by Darkhog View Post
    I can send you sources, if you want to look into it.
    ok i can give it a shot

  6. #6
    Pm'ed Laggyluk, will PM imcold in a minute.

    //edit: PM'ed imcold as well.
    Last edited by Darkhog; 24-06-2013 at 04:08 PM. Reason: Because.

  7. #7
    Can you send it to me also. I would also like to try help you out.
    And besides since I'm closely folowing Factorio which also uses allegro game engine it would probably give me better idea of what it is posible to do with allegro and what not. This way I could probably give better suggestion to Factorio developers. And no Factorio is unfortunately not made with pascal.

  8. #8
    You're getting errors due to changing the Chunk.Data in your keyboard handling code. The your keyboard handler is running in another context/thread (read the doc carefully: http://allegro-pas.sourceforge.net/d...install_int_ex). What does this mean? The data modified in the handler can change at any moment, independently of your main loop routine - if it changes when you're in your Draw routine, all hell's gonna break loose due to invalid pointers etc.
    The solution is to just set a flag to signal that a world refresh is needed, and check it in the main loop (and there should be a lock around the flag, to do things 100% properly; but you can probably get away without it in this case).
    Code:
    var
        update_chunks: boolean;
    
      procedure RegenerateChunk;
      begin
        update_chunks := false;
        Chunk.Data:=WorldGenerator.GenerateChunkData(chunkx,0,18);
        Inc(chunkx);
        al_clear_to_color(perlin,al_makecol(255,0,255));
        for x:=0 to 100-1 do
        begin
          for y:=0 to 100-1 do
          begin
            al_putpixel(perlin,x,y,generate_pixel(x,y));
          end;
        end;
      end;
    
      procedure update_keyboard();
      begin
          Dec(lasted);
          dec(chunklasted);
          if (al_keyboard_needs_poll) then al_poll_keyboard;
          if ((al_key[AL_KEY_P]<>0) and (lasted<=0)) then begin pause:=not pause; lasted:=pausedelay; end;
          if not pause then begin
    
            if ((al_key[AL_KEY_SPACE]<>0) and (chunklasted<=0)) then
            begin
              update_chunks := true;
              chunklasted:=pausedelay;
            end;
          end;
      end;
    main routine:
    Code:
          repeat
            draw;
            if update_chunks then
                RegenerateChunk;
          until (al_key[AL_KEY_Q]<>0) or quit;
    Last edited by imcold; 24-06-2013 at 07:40 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
  •