Fixed crash upon soft resetting

This commit is contained in:
Maruno17
2023-07-31 23:40:02 +01:00
parent bd70166dbb
commit ea7b5d56d2
2 changed files with 12 additions and 27 deletions

View File

@@ -340,32 +340,20 @@ module RPG
end
#===============================================================================
# A modification to class Sprite that allows its coordinates to be floats rather
# than integers.
# A version of class Sprite that allows its coordinates to be floats rather than
# integers.
#===============================================================================
class Sprite
attr_accessor :float
alias :__float__x :x
alias :__float__y :y
alias :__float__x_equals :x=
alias :__float__y_equals :y=
def x
return (@float) ? @real_x : __float__x
end
def y
return (@float) ? @real_y : __float__y
end
class FloatSprite < Sprite
def x; return @float_x; end
def y; return @float_y; end
def x=(value)
@real_x = value if @float
__float__x_equals(value)
@float_x = value
super
end
def y=(value)
@real_y = value if @float
__float__y_equals(value)
@float_y = value
super
end
end

View File

@@ -164,8 +164,7 @@ module RPG
if @sprites.length < MAX_SPRITES && @weatherTypes[@type] && @weatherTypes[@type][1].length > 0
MAX_SPRITES.times do |i|
if !@sprites[i]
sprite = Sprite.new(@origViewport)
sprite.float = true
sprite = FloatSprite.new(@origViewport)
sprite.z = 1000
sprite.ox = @ox + @ox_offset
sprite.oy = @oy + @oy_offset
@@ -180,8 +179,7 @@ module RPG
@weatherTypes[@target_type][1].length > 0
MAX_SPRITES.times do |i|
if !@new_sprites[i]
sprite = Sprite.new(@origViewport)
sprite.float = true
sprite = FloatSprite.new(@origViewport)
sprite.z = 1000
sprite.ox = @ox + @ox_offset
sprite.oy = @oy + @oy_offset
@@ -198,8 +196,7 @@ module RPG
return if @tiles.length >= @tiles_wide * @tiles_tall
(@tiles_wide * @tiles_tall).times do |i|
if !@tiles[i]
sprite = Sprite.new(@origViewport)
sprite.float = true
sprite = FloatSprite.new(@origViewport)
sprite.z = 1000
sprite.ox = @ox + @ox_offset
sprite.oy = @oy + @oy_offset