Prevent IBRU island update recursion on script reload

This commit is contained in:
WorldBosse committed 2026-11-02 00:53:05 +04:00
1 parent 3e832c8446
commit 5804acfcec
1 file changed
+22 -20
+22 -20
View File
@@ -175,7 +175,7 @@ end
if defined?(Game_Player) if defined?(Game_Player)
class Game_Player class Game_Player
alias ibru_movable_without movable? alias ibru_movable_without movable? unless method_defined?(:ibru_movable_without)
def movable?(*args, &block) def movable?(*args, &block)
return false if MPIslandVoyage.transit? && $game_map && $game_map.map_id == 156 return false if MPIslandVoyage.transit? && $game_map && $game_map.map_id == 156
ibru_movable_without(*args, &block) ibru_movable_without(*args, &block)
@@ -186,7 +186,7 @@ end
if defined?(WebSocket) if defined?(WebSocket)
module WebSocket module WebSocket
class << self class << self
alias ibru_parse_without parse alias ibru_parse_without parse unless method_defined?(:ibru_parse_without)
def parse(message) def parse(message)
# The server uses a distinct room ID for island interiors. Only the # The server uses a distinct room ID for island interiors. Only the
# transport layer sees it; the game loads the original map data. # transport layer sees it; the game loads the original map data.
@@ -226,17 +226,17 @@ if defined?(WebSocket)
ibru_parse_without(message) ibru_parse_without(message)
end end
alias ibru_noclip_without admin_noclip_enabled? alias ibru_noclip_without admin_noclip_enabled? unless method_defined?(:ibru_noclip_without)
def admin_noclip_enabled? def admin_noclip_enabled?
MPIslandVoyage.noclip? || ibru_noclip_without MPIslandVoyage.noclip? || ibru_noclip_without
end end
alias ibru_hidden_without admin_see_hidden_enabled? alias ibru_hidden_without admin_see_hidden_enabled? unless method_defined?(:ibru_hidden_without)
def admin_see_hidden_enabled? def admin_see_hidden_enabled?
(MPIslandVoyage.active? && !!@admin_see_hidden_enabled) || ibru_hidden_without (MPIslandVoyage.active? && !!@admin_see_hidden_enabled) || ibru_hidden_without
end end
alias ibru_ghost_without admin_can_ghost? alias ibru_ghost_without admin_can_ghost? unless method_defined?(:ibru_ghost_without)
def admin_can_ghost? def admin_can_ghost?
MPIslandVoyage.active? || ibru_ghost_without MPIslandVoyage.active? || ibru_ghost_without
end end
@@ -247,12 +247,12 @@ end
if defined?(MPGodMode) if defined?(MPGodMode)
module MPGodMode module MPGodMode
class << self class << self
alias ibru_active_without active? alias ibru_active_without active? unless method_defined?(:ibru_active_without)
def active? def active?
return !!@enabled && MPIslandVoyage.active? && Time.now.to_f < @expires.to_f if MPIslandVoyage.active? return !!@enabled && MPIslandVoyage.active? && Time.now.to_f < @expires.to_f if MPIslandVoyage.active?
ibru_active_without ibru_active_without
end end
alias ibru_toggle_without request_toggle alias ibru_toggle_without request_toggle unless method_defined?(:ibru_toggle_without)
def request_toggle def request_toggle
return ibru_toggle_without unless MPIslandVoyage.active? return ibru_toggle_without unless MPIslandVoyage.active?
return if pending? || !WebSocket.connected? return if pending? || !WebSocket.connected?
@@ -260,7 +260,7 @@ if defined?(MPGodMode)
WebSocket.send_line("god_toggle:#{active? ? 0 : 1}") WebSocket.send_line("god_toggle:#{active? ? 0 : 1}")
refresh_menu refresh_menu
end end
alias ibru_tick_without tick alias ibru_tick_without tick unless method_defined?(:ibru_tick_without)
def tick def tick
ibru_tick_without ibru_tick_without
if MPIslandVoyage.active? && WebSocket.bootstrap_sync_unlocked? && (!@ibru_hello_at || Time.now.to_f - @ibru_hello_at > 10) if MPIslandVoyage.active? && WebSocket.bootstrap_sync_unlocked? && (!@ibru_hello_at || Time.now.to_f - @ibru_hello_at > 10)
@@ -274,7 +274,9 @@ end
if defined?(Scene_Map) if defined?(Scene_Map)
class Scene_Map class Scene_Map
alias ibru_update_without update # A script reload must not alias our own wrapper: that would recurse until
# SystemStackError on this frame's call to ibru_update_without.
alias ibru_update_without update unless method_defined?(:ibru_update_without)
def update(*args, &block) def update(*args, &block)
result = ibru_update_without(*args, &block) result = ibru_update_without(*args, &block)
MPIslandVoyage.tick MPIslandVoyage.tick
@@ -286,20 +288,20 @@ end
# Keep the island tools in the existing VIP overlay, without granting OWNER. # Keep the island tools in the existing VIP overlay, without granting OWNER.
if defined?(Scene_Map) && Scene_Map.method_defined?(:mp_admin_open_root) if defined?(Scene_Map) && Scene_Map.method_defined?(:mp_admin_open_root)
class Scene_Map class Scene_Map
alias ibru_hotkey_without mp_admin_update_hotkey alias ibru_hotkey_without mp_admin_update_hotkey unless method_defined?(:ibru_hotkey_without)
def mp_admin_update_hotkey def mp_admin_update_hotkey
return ibru_hotkey_without unless MPIslandVoyage.active? && WebSocket.admin_role_rank <= 0 return ibru_hotkey_without unless MPIslandVoyage.active? && WebSocket.admin_role_rank <= 0
return if MPAdminMenu.blocked_by_other_ui? || !MPAdminMenu.open_triggered? return if MPAdminMenu.blocked_by_other_ui? || !MPAdminMenu.open_triggered?
mp_admin_menu_active? ? mp_admin_dispose_menu : mp_admin_open_root mp_admin_menu_active? ? mp_admin_dispose_menu : mp_admin_open_root
end end
alias ibru_validate_role_without mp_admin_validate_menu_role alias ibru_validate_role_without mp_admin_validate_menu_role unless method_defined?(:ibru_validate_role_without)
def mp_admin_validate_menu_role def mp_admin_validate_menu_role
return if MPIslandVoyage.active? && WebSocket.connected? return if MPIslandVoyage.active? && WebSocket.connected?
ibru_validate_role_without ibru_validate_role_without
end end
alias ibru_admin_root_without mp_admin_open_root alias ibru_admin_root_without mp_admin_open_root unless method_defined?(:ibru_admin_root_without)
def mp_admin_open_root def mp_admin_open_root
return ibru_admin_root_without unless MPIslandVoyage.active? return ibru_admin_root_without unless MPIslandVoyage.active?
rows = [] rows = []
@@ -321,7 +323,7 @@ if defined?(Scene_Map) && Scene_Map.method_defined?(:mp_admin_open_root)
@mp_admin_window.set_handler(:cancel, method(:mp_admin_dispose_menu)) @mp_admin_window.set_handler(:cancel, method(:mp_admin_dispose_menu))
end end
alias ibru_admin_back_without mp_admin_back alias ibru_admin_back_without mp_admin_back unless method_defined?(:ibru_admin_back_without)
def mp_admin_back def mp_admin_back
return mp_admin_open_root if @mp_admin_state == :ibru_targets return mp_admin_open_root if @mp_admin_state == :ibru_targets
ibru_admin_back_without ibru_admin_back_without
@@ -372,7 +374,7 @@ end
if defined?(MPAdminMenu) if defined?(MPAdminMenu)
module MPAdminMenu module MPAdminMenu
class << self class << self
alias ibru_grid_title_without grid_title alias ibru_grid_title_without grid_title unless method_defined?(:ibru_grid_title_without)
def grid_title(state) def grid_title(state)
return 'Остров IBRU_VIZ' if state == :root && MPIslandVoyage.active? return 'Остров IBRU_VIZ' if state == :root && MPIslandVoyage.active?
ibru_grid_title_without(state) ibru_grid_title_without(state)
@@ -384,12 +386,12 @@ end
# Gray the item entry and block both keyboard and mouse access to its page. # Gray the item entry and block both keyboard and mouse access to its page.
if defined?(Menu_Command) if defined?(Menu_Command)
class Menu_Command class Menu_Command
alias ibru_menu_initialize_without initialize alias ibru_menu_initialize_without initialize unless method_defined?(:ibru_menu_initialize_without)
def initialize(command_names) def initialize(command_names)
@ibru_item_index = command_names.index($game_text['menu:core/items']) rescue nil @ibru_item_index = command_names.index($game_text['menu:core/items']) rescue nil
ibru_menu_initialize_without(command_names) ibru_menu_initialize_without(command_names)
end end
alias ibru_menu_refresh_without refresh alias ibru_menu_refresh_without refresh unless method_defined?(:ibru_menu_refresh_without)
def refresh def refresh
ibru_menu_refresh_without ibru_menu_refresh_without
if MPIslandVoyage.active? && @ibru_item_index && @menu_sprites[@ibru_item_index] if MPIslandVoyage.active? && @ibru_item_index && @menu_sprites[@ibru_item_index]
@@ -401,7 +403,7 @@ end
if defined?(Scene_Menu) if defined?(Scene_Menu)
class Scene_Menu class Scene_Menu
alias ibru_menu_start_without start alias ibru_menu_start_without start unless method_defined?(:ibru_menu_start_without)
def start(*args, &block) def start(*args, &block)
result = ibru_menu_start_without(*args, &block) result = ibru_menu_start_without(*args, &block)
if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items) if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items)
@@ -409,7 +411,7 @@ if defined?(Scene_Menu)
end end
result result
end end
alias ibru_menu_switch_without process_switchMenuIndex alias ibru_menu_switch_without process_switchMenuIndex unless method_defined?(:ibru_menu_switch_without)
def process_switchMenuIndex(index) def process_switchMenuIndex(index)
if MPIslandVoyage.active? && @contents && @contents.contents[index].is_a?(Menu_Items) if MPIslandVoyage.active? && @contents && @contents.contents[index].is_a?(Menu_Items)
direction = index.to_i >= @menu_index.to_i ? 1 : -1 direction = index.to_i >= @menu_index.to_i ? 1 : -1
@@ -419,7 +421,7 @@ if defined?(Scene_Menu)
end end
ibru_menu_switch_without(index) ibru_menu_switch_without(index)
end end
alias ibru_menu_ok_without process_ok alias ibru_menu_ok_without process_ok unless method_defined?(:ibru_menu_ok_without)
def process_ok def process_ok
return SndLib.sys_buzzer if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items) return SndLib.sys_buzzer if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items)
ibru_menu_ok_without ibru_menu_ok_without
@@ -444,7 +446,7 @@ if defined?(Battle_System)
end end
if defined?(Game_SandboxObject) if defined?(Game_SandboxObject)
class Game_SandboxObject class Game_SandboxObject
alias ibru_sandbox_damage_without take_damage alias ibru_sandbox_damage_without take_damage unless method_defined?(:ibru_sandbox_damage_without)
def take_damage(user, *args, &block) def take_damage(user, *args, &block)
return [] if MPIslandVoyage.active? && $game_player && user.equal?($game_player.actor) return [] if MPIslandVoyage.active? && $game_player && user.equal?($game_player.actor)
ibru_sandbox_damage_without(user, *args, &block) ibru_sandbox_damage_without(user, *args, &block)