[vJASS] Is this a bugg with the editor or why on earth is this not working?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
Was creating a little job system for an RPG and it stopped working when I was reaching completion, so i fleshed it back down to creation. But it doesn't actually create any units for some reason and never actually shows "Done", which suggests some sort of infinite loop, but I'm not using any loops here...?

The other day a similar thing happend where what i was making just broke and i had to redo it jumping back to a previous version of the map I was editing. Since it has happend twice, I'm starting to think it can be something with the editor and not with the code?

JASS:
scope SetupJobs initializer Init
 

    private function Setup takes nothing returns nothing
        local Job jobb
        local timer t = GetExpiredTimer()
        call PauseTimer(t)
        call DestroyTimer(t)
        set t = null

        call BJDebugMsg("Started...")
        call Job.create(gg_rct_Job1, "Boar hunter", gg_trg_QuitJob1, gg_trg_EmployJob1)
        call Job.create(gg_rct_Job2, "Lizard egg collector", gg_trg_QuitJob2, gg_trg_EmployJob2)
        call BJDebugMsg("Done.")
    endfunction

    private function Init takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t, 0.1, false, function Setup)
        set t = null
    endfunction
endscope

JASS:
library JobManager uses Table, CommandUtils
 
    globals
        private constant integer    PING_TIME_JOBS        = 10        // Time that available jobs will be shown
        private constant string     CMD_JOBS        = "-jobs"        // Command for pining all available jobs
        private constant string     CMD_QUIT        = "-quit"        // Command for quitting current jobs
        private constant integer     CIRCLE_ID         = 'ncop'        // The circle representing the job
        private constant integer     AB_JOB_DESC        = 'A000'
        private constant string     JOB_PREFIX         = "Job: "        // A naming prefix given to the job circle
        private constant player     NEUTRAL         = Player(11)
        private constant integer     DISTANCE         = 40000
    endglobals
 
    struct Job
        real x
        real y
        unit u
        trigger trgQuit
        trigger trgEmploy
 
        static thistype array jobs
        static integer size
        static trigger trgWalkOnCircle
 
 
        private static method onWalkOnCircleEvent takes nothing returns nothing
            call BJDebugMsg("Walking on circle...")
        endmethod
 
        static method onInit takes nothing returns nothing
            set thistype.trgWalkOnCircle = CreateTrigger()
            call TriggerAddAction(thistype.trgWalkOnCircle, function thistype.onWalkOnCircleEvent)
        endmethod
 
        static method create takes rect r, string title, trigger OnQuit, trigger OnEmploy returns thistype
            local thistype this = .allocate()
            call BJDebugMsg("Creating...")
            set thistype.jobs[thistype.size] = this
            set thistype.size = thistype.size + 1
            set this.x = GetRectCenterX(r)
            set this.y = GetRectCenterY(r)
            set this.u = CreateUnit(NEUTRAL, CIRCLE_ID, this.x, this.y, 270)
            set this.trgQuit = OnQuit
            set this.trgEmploy = OnEmploy
            //call TriggerRegisterEnterRectSimple(thistype.trgWalkOnCircle, r)
            // Modify
            call BlzSetUnitName(this.u, JOB_PREFIX + title)
            call BJDebugMsg("Done Creating...")
            return this
        endmethod
    endstruct
endlibrary

It appears that this line was the culprit, but I'm not sure I understand why this is an illegal operation set thistype.jobs[thistype.size] = this... Oh it's because i didn't declare the array size. Right.....
 
Last edited:
Status
Not open for further replies.
Top