Fix IBRU websocket prepend recursion

This commit is contained in:
WorldBosse committed 2026-11-02 01:01:43 +04:00
1 parent 89f0da185b
commit 5123d1bc7e
1 file changed
+24 -26
+24 -26
View File
@@ -174,20 +174,21 @@ module MPIslandVoyage
end end
if defined?(Game_Player) if defined?(Game_Player)
class Game_Player module MPIslandVoyageMovementPatch
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) super
end end
end end
Game_Player.prepend(MPIslandVoyageMovementPatch) unless Game_Player.ancestors.include?(MPIslandVoyageMovementPatch)
end end
if defined?(WebSocket) if defined?(WebSocket)
module WebSocket # PresenceVersionGate and several other mods already prepend WebSocket.
class << self # Aliasing their parse/disconnect methods here makes their super call return
alias ibru_parse_without parse unless method_defined?(:ibru_parse_without) # to this wrapper forever. A final prepend keeps the lookup chain linear.
def parse(message) module MPIslandVoyageWebSocketPatch
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.
if message =~ /\Abootstrap_map:(10\d{3})\z/ if message =~ /\Abootstrap_map:(10\d{3})\z/
@@ -223,31 +224,28 @@ if defined?(WebSocket)
MPIslandVoyage.set_targets(list) MPIslandVoyage.set_targets(list)
return return
end end
ibru_parse_without(message) super(message)
end end
alias ibru_disconnect_without disconnect unless method_defined?(:ibru_disconnect_without) def disconnect(*args, &block)
def disconnect(*args, &block) MPIslandVoyage.set_active(false)
MPIslandVoyage.set_active(false) super
ibru_disconnect_without(*args, &block) end
end
alias ibru_noclip_without admin_noclip_enabled? unless method_defined?(:ibru_noclip_without) def admin_noclip_enabled?
def admin_noclip_enabled? MPIslandVoyage.noclip? || super
MPIslandVoyage.noclip? || ibru_noclip_without end
end
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) || super
(MPIslandVoyage.active? && !!@admin_see_hidden_enabled) || ibru_hidden_without end
end
alias ibru_ghost_without admin_can_ghost? unless method_defined?(:ibru_ghost_without) def admin_can_ghost?
def admin_can_ghost? MPIslandVoyage.active? || super
MPIslandVoyage.active? || ibru_ghost_without
end
end end
end end
sc = WebSocket.singleton_class
sc.prepend(MPIslandVoyageWebSocketPatch) unless sc.ancestors.include?(MPIslandVoyageWebSocketPatch)
end end
if defined?(MPGodMode) if defined?(MPGodMode)