Results 1 to 5 of 5

Thread: Design

  1. #1
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Design

    Was just wondering from a design and standrads point of view is it ok to Free a bitmap in a loop like in the example, so it saves me having to free every bitmap on its own line.

    Simba Code:
    for i := 0 to GetArrayLength(Rune) do
      begin
        if FindBitmapToleranceIn(Rune[i].BMP, x, y, MSX1, MSY1, MSX2, MSY2, 15) then
        begin
          Mouse(x, y, 7, 7, true);
          Wait(RandomRange(150, 250));
          ClickMouse2(true)
          if IsUpTextMultiCustom([Rune[1].Uptext + Rune[3].Uptext]) then
            ClickMouse2(true);
          FreeBitmap(Rune[i].BMP);
          Break;
        end;
      end;

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yes that is okay and preferred.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  3. #3
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, just figured if u free one bitmap and break the loop, then every other bitmap wont be freed.

  4. #4
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah, you are correct. Yeah, this would introduce some leaks.
    Do something like this (declare b as a boolean):
    Simba Code:
    for i := 0 to GetArrayLength(Rune) do
      begin
        b := FindBitmapToleranceIn(Rune[i].BMP, x, y, MSX1, MSY1, MSX2, MSY2, 15);
        FreeBitmap(Rune[i].BMP);
        if b then
        begin
          Mouse(x, y, 7, 7, true);
          Wait(RandomRange(150, 250));
          ClickMouse2(true)
          if IsUpTextMultiCustom([Rune[1].Uptext + Rune[3].Uptext]) then
            ClickMouse2(true);
          Break;
        end;
      end;
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  5. #5
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Load all of your bitmaps at the beginning, and free them all at the very end of your script (if you don't, Simba will). Much less hassle this way, and preferable
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

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
  •