[JASS] Unusual wc3err message

Status
Not open for further replies.
Level 8
Joined
Jul 23, 2005
Messages
329
The error "Uninitialized variable 'Struct method generated initializers/callers: ***************** cape to select." used in IceMoveNow()" appears whenever IceMoveNow() is called. What's strange about the entire thing is that in no case do I ever use a struct, only globals.
JASS:
function IceMoveNow takes nothing returns nothing
    local rect RawrRect
    local group RawrGroup = CreateGroup()
    local unit RawrUnit
    call SetUnitPosition(MovedUnit, GetUnitX(MovedUnit), GetUnitY(MovedUnit) + 50)
    
    
    set RawrRect = Rect(GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 128, GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) + 128)
    call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
    set RawrUnit = FirstOfGroup(RawrGroup)
    
    //First: The hit unit
    if RawrUnit != null then
        call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
        call UnitAddAbility(RawrUnit, 'A208')
        
        //Second: The unit behind
        if GetUnitAbilityLevel(udg_P1Unit, 'A118') >= 2 then
            set RawrRect = Rect(GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 256, GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) + 512)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
        endif
        
        //Third: The unit to the sides
        if GetUnitAbilityLevel(udg_P1Unit, 'A118') == 3 then
            //Unit to the left
            set RawrRect = Rect(GetUnitX(MovedUnit) - 384, GetUnitY(MovedUnit) - 128, GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 128)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
            
            //Unit to the right
            set RawrRect = Rect(GetUnitX(MovedUnit) + 128, GetUnitY(MovedUnit) - 128, GetUnitX(MovedUnit) - 128, GetUnitY(MovedUnit) + 384)
            call GroupEnumUnitsInRect(RawrGroup, RawrRect, Filter(function boolexprclosest))
            set RawrUnit = FirstOfGroup(RawrGroup)
            if RawrUnit != null then
                call SetUnitState(RawrUnit, UNIT_STATE_LIFE, 10.0)
                call UnitAddAbility(RawrUnit, 'A208')
            endif
        endif
        call KillUnit(MovedUnit)
        call DestroyTimer(GetExpiredTimer())
    endif
    
    //Detect if the bullet's gone out of range.
    if GetUnitY(MovedUnit) >= GetRectMinY(gg_rct_TopBoundry) then
        call KillUnit(MovedUnit)
        call DestroyTimer(GetExpiredTimer())
    endif
    
    set RawrRect = null
    set RawrGroup = null
    set RawrUnit = null
endfunction

That's the code... Can someone explain to me what wc3err is trying to say?
 
Fixed it... MovedUnit IS a global, but in the version of this code I was running, I accidently also declared a local with the same name in this function. Oddly enough, the compiler didn't crash, but gave me that strange error message.

I'll rep you both...
 
Fixed it... MovedUnit IS a global, but in the version of this code I was running, I accidently also declared a local with the same name in this function. Oddly enough, the compiler didn't crash, but gave me that strange error message.
Globals and locals having the same name is a well-known bug, and is actually the source of "locals" in GUI, in a sense - if you make a global with the same name as a local, whenever the global is attempted to be used inside that function, it will reference the local instead. From what I know, this also works with locals vs arguments, and only works for one variable per function.
 
Status
Not open for further replies.
Back
Top