From 778c7e63b9a6644acf7ccbf84c702092accd34a0 Mon Sep 17 00:00:00 2001 From: Wayward Heart <91356680+WaywardHeart@users.noreply.github.com> Date: Tue, 17 Oct 2023 07:40:58 -0500 Subject: [PATCH] Replace the ruby18_wrap.rb preload script with ruby_classic_wrap.rb --- scripts/preload/ruby18_wrap.rb | 17 ----------- scripts/preload/ruby_classic_wrap.rb | 43 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 17 deletions(-) delete mode 100644 scripts/preload/ruby18_wrap.rb create mode 100644 scripts/preload/ruby_classic_wrap.rb diff --git a/scripts/preload/ruby18_wrap.rb b/scripts/preload/ruby18_wrap.rb deleted file mode 100644 index 82f8a29c..00000000 --- a/scripts/preload/ruby18_wrap.rb +++ /dev/null @@ -1,17 +0,0 @@ -# ruby18_wrap.rb -# Author: Splendide Imaginarius (2022) - -# Creative Commons CC0: To the extent possible under law, Splendide Imaginarius -# has waived all copyright and related or neighboring rights to ruby18_wrap.rb. -# https://creativecommons.org/publicdomain/zero/1.0/ - -# This preload script provides functions that existed in RPG Maker's Ruby v1.8, -# but were renamed in the current Ruby version used in mkxp-z, so that games -# (or other preload scripts) that expect Ruby v1.8's function names can find -# them. - -class Hash - def index(*args) - key(*args) - end -end diff --git a/scripts/preload/ruby_classic_wrap.rb b/scripts/preload/ruby_classic_wrap.rb new file mode 100644 index 00000000..35fe4416 --- /dev/null +++ b/scripts/preload/ruby_classic_wrap.rb @@ -0,0 +1,43 @@ +# ruby_classic_wrap.rb + +# Creative Commons CC0: To the extent possible under law, the author(s) have +# dedicated all copyright and related and neighboring rights to this script +# to the public domain worldwide. +# https://creativecommons.org/publicdomain/zero/1.0/ + +# This preload script provides functions that existed in RPG Maker's versions of Ruby, +# but were renamed or changed in the current Ruby version used in mkxp-z, so that games +# (or other preload scripts) that expect the older Ruby behavior can function. + +class Hash + alias_method :index, :key unless method_defined?(:index) +end + +class Object + TRUE = true unless const_defined?("TRUE") + FALSE = false unless const_defined?("FALSE") + NIL = nil unless const_defined?("NIL") + + alias_method :id, :object_id unless method_defined?(:id) + alias_method :type, :class unless method_defined?(:type) +end + +class NilClass + def id + 4 # Starting with Ruby2, 64-bit builds of ruby make this 8 + end +end + +class TrueClass + def id + 2 # Starting with Ruby2, 64-bit builds of ruby make this 20 + end +end + +if defined?(BasicObject) && BasicObject.instance_method(:initialize).arity == 0 + # In ruby 1.9.2, and only ruby 1.9.2, BasicObject.initialize accepted any number of arguments + class BasicObject + def initialize(*args) + end + end +end