From b2ddedbce1857d150359c17c137d9081ca7c7540 Mon Sep 17 00:00:00 2001 From: Maruno17 Date: Sun, 7 Aug 2022 16:29:29 +0100 Subject: [PATCH] Reduced the work done when updating the sprites of events without a graphic --- Data/Scripts/005_Sprites/003_Sprite_Character.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Data/Scripts/005_Sprites/003_Sprite_Character.rb b/Data/Scripts/005_Sprites/003_Sprite_Character.rb index 00796a278..a617c89a9 100644 --- a/Data/Scripts/005_Sprites/003_Sprite_Character.rb +++ b/Data/Scripts/005_Sprites/003_Sprite_Character.rb @@ -105,33 +105,37 @@ class Sprite_Character < RPG::Sprite @character_hue = @character.character_hue @oldbushdepth = @character.bush_depth @charbitmap&.dispose + @charbitmap = nil + @bushbitmap&.dispose + @bushbitmap = nil if @tile_id >= 384 @charbitmap = pbGetTileBitmap(@character.map.tileset_name, @tile_id, @character_hue, @character.width, @character.height) @charbitmapAnimated = false - @bushbitmap&.dispose - @bushbitmap = nil @spriteoffset = false @cw = Game_Map::TILE_WIDTH * @character.width @ch = Game_Map::TILE_HEIGHT * @character.height self.src_rect.set(0, 0, @cw, @ch) self.ox = @cw / 2 self.oy = @ch - else + elsif @character_name != "" @charbitmap = AnimatedBitmap.new( "Graphics/Characters/" + @character_name, @character_hue ) RPG::Cache.retain("Graphics/Characters/", @character_name, @character_hue) if @character == $game_player @charbitmapAnimated = true - @bushbitmap&.dispose - @bushbitmap = nil @spriteoffset = @character_name[/offset/i] @cw = @charbitmap.width / 4 @ch = @charbitmap.height / 4 self.ox = @cw / 2 + else + self.bitmap = nil + @cw = 0 + @ch = 0 end @character.sprite_size = [@cw, @ch] end + return if !@charbitmap @charbitmap.update if @charbitmapAnimated bushdepth = @character.bush_depth if bushdepth == 0