RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VXA]Picture Bug Fix

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 85
I am the wood of my broom
2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
Picture Bug Fix
Authors: Raizen884, Johnbolton, Gab!
Version: 1.0
Type: Bug Fix

Introduction

While I was beta testing for VXAce, I noticed that after a specific amount of picture disposal the game will start lagging. This is more obvious when you disposed 4 1280x1280 pictures and a few smaller amounts. The sad thing is that the lag is permanent. Trying Cache.clear with GC.start didn't help me with this problem. Luckily, a few guys from CentroRPGmaker found out about this and has created a fix. They also shared it with the English community and I figured I'll post it in here as well.

Note: This has already been reported to Eb! And we're not sure yet if this fix will be applied, but just in case :)



Features

  • Clears Pictures that you already disposed to avoid permanent lag.

Screenshots

N/A

Demo

No demo.

Script

Spoiler for:
Code: [Select]
#==============================================================================
#                           Picture Bug Fix
#------------------------------------------------------------------------------
# Author : Raizen884
# Credits : JohnBolton, Gab!
# Community : www.centrorpgmaker.com
# This script corrects a bug in the default scripts in which pictures continued
# to be updated even after they were erased, which caused lag.
#------------------------------------------------------------------------------
# Place this script above all other scripts in the Materials section.
#==============================================================================
class Sprite_Picture < Sprite
    def update
        super
        if @picture.name != ""
            update_bitmap
            update_origin
            update_position
            update_zoom
            update_other
        else
            self.bitmap.dispose if self.bitmap != nil
        end
    end
end


    Instructions

    In the script.

    Compatibility

    Should work with anything.

    Credits and Thanks

    • Raizen884
    • Johnbolton
    • Gab!
    • Touchfuzzy - for the proper script formatting.



    Author's Notes
    There were 2 members which were trying to fix this, me and JohnBolton, it took some time because there was no error log, but JohnBolton, which has some scripts here found where was the problem. Also special thanks for Gab! which helped us out also, even though it is a very small script, it took some time to find where was the problem.
    Enjoy! :)
    « Last Edit: March 08, 2012, 10:18:10 PM by Nessiah »


    *
    Rep:
    Level 85
    I am the wood of my broom
    2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
    Picture Bug Fix
    Author: Mithran
    Version: 1.0
    Type: Bug Fix

    Introduction

    The problem is caused when a picture is erased it holds an assoicated "picture" object in memory as long as you stay on the same scene. Every time that picture object comes up, it creates a NEW blank bitmap, every frame, basically if you want it to lag, create a lot of blank pictures when they get garbage collected, it lags. Each erased picture creates a single 32x32 blank bitmap to associate itself with, every frame, same with any picture shown as (none). Since the lag is caused by garbage collection, which is basically uncontrollabe with Ruby.

    The reason why it constantly creates new blank pictures is because the base scripts check for the picture name. And if it's "" (aka no picture name), it keeps creating. When a picture is erased, it sets to ""


    Features

    • Clears Pictures that you already disposed to avoid permanent lag.

    Screenshots

    N/A

    Demo

    No demo.

    Script

    Spoiler for:
    Code: [Select]
    #==============================================================================
    # ? Mithran Picture Bug Fix
    # -- Created: 3/12/2012
    #==============================================================================
    # The problem is caused when a picture is erased it holds an assoicated "picture"
    # object in memory as long as you stay on the same scene. Every time that picture
    # object comes up, it creates a NEW blank bitmap, every frame, basically if you
    # want it to lag, create a lot of blank pictures when they get garbage collected,
    # it lags.

    # Each erased picture creates a single 32x32 blank bitmap to associate
    # itself with, every frame, same with any picture shown as (none). Since the lag
    # is caused by garbage collection, which is basically uncontrollabe with Ruby.
    #
    # The reason why it constantly creates new blank pictures is because the base
    # scripts check for the picture name. And if it's "" (aka no picture name),
    # it keeps creating. When a picture is erased, it sets to ""
    #
    # This script fixes that.
    #==============================================================================

    class Sprite_Picture
      def update_bitmap
        if @picture.name != @pic_name
          self.bitmap = Cache.picture(@picture.name)
        end
        @pic_name = @picture.name
      end
     
    end


    class Spriteset_Map
     
      def update_pictures
        $game_map.screen.pictures.each do |pic|
          @picture_sprites[pic.number] ||= Sprite_Picture.new(@viewport2, pic)
          @picture_sprites[pic.number].update
          if pic.name == ""
            $game_map.screen.pictures.remove(pic.number)
            @picture_sprites[pic.number].dispose
            @picture_sprites[pic.number] = nil
          end
        end
      end

    end

    class Game_Pictures
     
      def remove(index)
        @data[index] = nil
      end
     
    end

      Instructions

      In the script.

      Compatibility

      Should work with anything.

      Credits and Thanks

      • Mithran


      Author's Notes
      The difference with this one and the previous one is that it doesn't remove the stored picture data. It's still a stored empty image.

      [/list]
      « Last Edit: March 13, 2012, 04:52:34 PM by Nessiah »


      **
      Rep:
      Level 86
      Deviant Designer
      I'm kind of confused, do I get both or just the second one? I read the descriptions of both and still not sure if I need them both.

      *
      Rep:
      Level 85
      I am the wood of my broom
      2010 Project of the YearProject of the Month winner for January 2009Project of the Month winner for January 2010Project of the Month winner for April 2010
      Just get the 2nd one if you're using the Japanese version :3


      **
      Rep:
      Level 86
      Deviant Designer
      I am using English version.