Feedback on AoS Spawn system

Bribe

vJass errors are legion
Reaction score
67
I don't hate function interfaces because of how bad the performance is, I hate them because they duplicate your functions! Function interfaces and stub/interface methods in general should be discouraged.

This:

JASS:
library FunctionInterface initializer Init
    
    private function interface FI takes integer arg returns nothing
    
    globals
        private FI array fiStack
        private integer fiCount = 0
    endglobals
    
    function RegisterFI takes FI fi returns nothing
        set fiStack[fiCount] = fi
        set fiCount = fiCount + 1
    endfunction
    
    private function Fire takes nothing returns nothing
        local integer i = fiCount
        loop
            set i = i - 1
            call fiStack[fiCount].execute(GetRandomInt(1, 10))
            exitwhen i == 0
        endloop
    endfunction
    
    private function WallOfText takes integer arg returns nothing
        local integer i = 5
        loop
            set i = i - 1
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            exitwhen i == 0
        endloop
    endfunction
    
    private function Init takes nothing returns nothing
        call RegisterFI(WallOfText)
    endfunction
    
endlibrary


Outputs this:

JASS:
globals
constant boolean LIBRARY_FunctionInterface=true
integer array FunctionInterface___fiStack
        integer FunctionInterface___fiCount = 0
trigger array st___prototype1
integer f__arg_integer1
endglobals

function sc___prototype1_execute takes integer i,integer a1 returns nothing
    set f__arg_integer1=a1

    call TriggerExecute(st___prototype1<i>)
endfunction
function sc___prototype1_evaluate takes integer i,integer a1 returns nothing
    set f__arg_integer1=a1

    call TriggerEvaluate(st___prototype1<i>)

endfunction
    
    function RegisterFI takes integer fi returns nothing
        set FunctionInterface___fiStack[FunctionInterface___fiCount]=fi
        set FunctionInterface___fiCount=FunctionInterface___fiCount + 1
    endfunction
    
    function FunctionInterface___Fire takes nothing returns nothing
        local integer i= FunctionInterface___fiCount
        loop
            set i=i - 1
            call sc___prototype1_execute(FunctionInterface___fiStack[FunctionInterface___fiCount],GetRandomInt(1, 10))
            exitwhen i == 0
        endloop
    endfunction
    
    function FunctionInterface___WallOfText takes integer arg returns nothing
        local integer i= 5
        loop
            set i=i - 1
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            exitwhen i == 0
        endloop
    endfunction
    
    function FunctionInterface___Init takes nothing returns nothing
        call RegisterFI((1))
    endfunction
    
function sa___prototype1_FunctionInterface___WallOfText takes nothing returns boolean
 local integer arg=f__arg_integer1

        local integer i= 5
        loop
            set i=i - 1
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            exitwhen i == 0
        endloop
    return true
endfunction

function jasshelper__initstructs2334779884 takes nothing returns nothing
    set st___prototype1[1]=CreateTrigger()
    call TriggerAddAction(st___prototype1[1],function sa___prototype1_FunctionInterface___WallOfText)
    call TriggerAddCondition(st___prototype1[1],Condition(function sa___prototype1_FunctionInterface___WallOfText))
endfunction</i></i>


Instead of this:

JASS:
library FunctionInterface initializer Init
    
    globals
        private trigger codeTrigger = CreateTrigger()
        private integer eventVar
    endglobals
    
    function RegisterCode takes code c returns nothing
        call TriggerAddAction(codeTrigger, c)
    endfunction
    
    function GetEventVar takes nothing returns integer
        return eventVar
    endfunction
    
    private function Fire takes nothing returns nothing
        set eventVar = GetRandomInt(1, 10)
        call TriggerExecute(codeTrigger)
    endfunction
    
    private function WallOfText takes nothing returns nothing
        local integer arg = GetEventVar()
        local integer i = 5
        loop
            set i = i - 1
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            call DoNothing()
            exitwhen i == 0
        endloop
    endfunction
    
    private function Init takes nothing returns nothing
        call RegisterCode(function WallOfText)
    endfunction
    
endlibrary


Which outputs no "ghost code" or senselessly duplicated code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top