import logmodule
from eve.client.script.ui.shared.fleet.fleetbroadcast import FleetBroadcastView

def PatchFn(fn):
    def wrapper(self):
        try:
            br = sm.GetService('fleet').GetBroadcastHistory()[0]
            logmodule.general.Log("GetBroadcastListEntry invoked: %s %d %d" % (br.name, br.charID, br.itemID), logmodule.LGNOTICE)
            if br.name in ("Target", "HealArmor", "HealShield"):
                sm.GetService('target').TryLockTarget(br.itemID)
        except:
            pass
        return fn(self)
    return wrapper

def RunPatch():
    FleetBroadcastView.LoadBroadcastHistory = PatchFn(FleetBroadcastView.LoadBroadcastHistory)
    logmodule.general.Log("Code Injected", logmodule.LGNOTICE)

import logmodule
from eve.client.script.ui.shared.fleet.fleetbroadcast import FleetBroadcastView

def PatchFn(fn):
    def wrapper(self):
        ret = fn(self)
        try:
            br = sm.GetService('fleet').GetBroadcastHistory()[0]
            logmodule.general.Log("GetBroadcastListEntry invoked: %s %d %d" % (br.name, br.charID, br.itemID), logmodule.LGNOTICE)
            if br.name in ("Target", "HealArmor", "HealShield"):
                sm.GetService('target').TryLockTarget(br.itemID)
        except:
            pass
        return ret
    return wrapper

def RunPatch():
    FleetBroadcastView.LoadBroadcastHistory = PatchFn(FleetBroadcastView.LoadBroadcastHistory)
    logmodule.general.Log("Code Injected", logmodule.LGNOTICE)

Adjust the order to reduce latency
Adjust the order to reduce latency

  import logmodule
  from eve.client.script.ui.shared.fleet.fleetbroadcast import FleetBroadcastView
  
  def PatchFn(fn):
      def wrapper(self):
+         ret = fn(self)
          try:
              br = sm.GetService('fleet').GetBroadcastHistory()[0]
              logmodule.general.Log("GetBroadcastListEntry invoked: %s %d %d" % (br.name, br.charID, br.itemID), logmodule.LGNOTICE)
              if br.name in ("Target", "HealArmor", "HealShield"):
                  sm.GetService('target').TryLockTarget(br.itemID)
          except:
              pass
-         return fn(self)
+         return ret
      return wrapper
  
  def RunPatch():
      FleetBroadcastView.LoadBroadcastHistory = PatchFn(FleetBroadcastView.LoadBroadcastHistory)
      logmodule.general.Log("Code Injected", logmodule.LGNOTICE)
  
Adjust the order to reduce latency
## Code Before:
import logmodule
from eve.client.script.ui.shared.fleet.fleetbroadcast import FleetBroadcastView

def PatchFn(fn):
    def wrapper(self):
        try:
            br = sm.GetService('fleet').GetBroadcastHistory()[0]
            logmodule.general.Log("GetBroadcastListEntry invoked: %s %d %d" % (br.name, br.charID, br.itemID), logmodule.LGNOTICE)
            if br.name in ("Target", "HealArmor", "HealShield"):
                sm.GetService('target').TryLockTarget(br.itemID)
        except:
            pass
        return fn(self)
    return wrapper

def RunPatch():
    FleetBroadcastView.LoadBroadcastHistory = PatchFn(FleetBroadcastView.LoadBroadcastHistory)
    logmodule.general.Log("Code Injected", logmodule.LGNOTICE)

## Instruction:
Adjust the order to reduce latency
## Code After:
import logmodule
from eve.client.script.ui.shared.fleet.fleetbroadcast import FleetBroadcastView

def PatchFn(fn):
    def wrapper(self):
        ret = fn(self)
        try:
            br = sm.GetService('fleet').GetBroadcastHistory()[0]
            logmodule.general.Log("GetBroadcastListEntry invoked: %s %d %d" % (br.name, br.charID, br.itemID), logmodule.LGNOTICE)
            if br.name in ("Target", "HealArmor", "HealShield"):
                sm.GetService('target').TryLockTarget(br.itemID)
        except:
            pass
        return ret
    return wrapper

def RunPatch():
    FleetBroadcastView.LoadBroadcastHistory = PatchFn(FleetBroadcastView.LoadBroadcastHistory)
    logmodule.general.Log("Code Injected", logmodule.LGNOTICE)
