Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: State machine - requesting advice

  1. #21
    Figured it out, you need to have virtual; at the end of the TState methods. If you also add them abstract; , then you don't need to make them implementation code at all. But that is only useful tip if you never plan to add them any code, and also if they're abstract, then they must be defined in all inheriting classes.

    Can't see the source for segfault if you did also what SilverWarior said.

    1 other tip that i could give, is making new unit for TState alone. Then you can use the same state-machine in all your projects. You could move the CurrentState variable there, and also make a universal procedure like
    Code:
    procedure RunStatesApp;
    begin
          repeat
            CurrentState.BeforeDraw;
            CurrentState.Draw;
            CurrentState.Main;
          until quit;
    end;
    that you would call from main program unit.
    (Make sure there are no uses-list's in the universal state-unit)
    Last edited by User137; 29-06-2013 at 11:28 AM.

  2. #22
    Hm, thanks. May I send you project files so you can help me debugging this segfault (will try to check callstack before that)?

    //edit: Callstack isn't helpful. It shows only that function I mentioned before (ntdll!LdrWx86FormatVirtualImage (1584)) and since it seems to be Windows function, I can't really do anything about it...

    Question: Do modern operating systems (Windows/Linux/Mac) free up memory that was used of program even if it was leaked? If they are I could probably get away with not freeing states up at end of program without any damage for players. Of course best would be to fix underlying issue, but if you won't be able to help I'll need some sort of last resort.
    Last edited by Darkhog; 29-06-2013 at 11:37 AM.

  3. #23
    Quote Originally Posted by Darkhog View Post
    Hm, thanks. May I send you project files so you can help me debugging this segfault
    Sure. You could also consider using some webservice to temporarily upload files. Speaking of which, i guess i'll have to try Dropbox myself. Are there better ones? Google drive sharing is not very anonymous i think, doesn't everyone see your email?
    edit2: Seems i was wrong about the email thing. You only see yourself logged in google account, and possibly other accounts viewing them, but just their names.

    edit:
    Quote Originally Posted by Darkhog View Post
    Question: Do modern operating systems (Windows/Linux/Mac) free up memory that was used of program even if it was leaked?
    Yes, they free it. But i'm not sure if attached debugger like used for Delphi or Lazarus handles that well.
    Last edited by User137; 29-06-2013 at 11:49 AM.

  4. #24
    Well, I'm only worried about players when they will want to play SHL several times in a row and they'll fill memory by accident. I'm not worried about me as developer, as I know what I'm getting into and in worst case, I can restart PC. Though I don't want players to need to restart their PCs.

    Anyway, as I've said, this is last resort. I want to figure out how to actually fix that.

  5. #25
    Normaly on Windows when you close the application all of its memory is released. There are exceptions when a program is using two or more seperate memory managers but this is quite unlikely in your case.

    Now you can send me the source code and I'll take a look at it to see what might be causing theese segfaults.

  6. #26
    I've had some look on the source code, and found some things which i PM'd. But i didn't find the crash on exit cause. It came down to al_destroy_bitmap(MaskBitmap); line. Are there some commands to issue for Allegro when application is quitting? I noticed it's sort of threaded, by linking a update procedure in it. But crash when destroying bitmap, which isn't nil, is very odd. That linked update thread wasn't responsible of drawing things. Main loop was already stopped at that time.

Page 3 of 3 FirstFirst 123

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
  •  
Comodo SSL