HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unknown if-statement Error

01-07-2009, 01:46 AM#1
Thunder_Eye
Can someone explain to me how this can occur? I would assume it's some kind of bug.

This is how it looks like.
Collapse JASS:
code... //this runs

if (conditions) then
  //this doesn't run
  if (conditions) then
    //this doesn't run
  else
    //this runs
  endif
  //this runs
endif

code...//this runs

Real code (yes it is messy)
Hidden information:
Collapse JASS:
if GetItemTypeId(GetManipulatedItem()) == GetStoredInteger(udg_*cache, I2S(12)+","+I2S(thePosition), "whatItem") and some_IsHeroAllowed(someUnit, GetStoredString(udg_somecache, I2S(12)+","+I2S(thePosition), "whatRequirements")) then
    call BJDebugMsg("This does not show")
    if not GetStoredBoolean(udg_somecache, someUnitID, I2S(5)) and not GetStoredBoolean(udg_somecache, someUnitID, I2S(7)) then
        //Mark 2
        call BJDebugMsg("This does not show")
        call UnitRemoveAbility( someUnit, GetStoredInteger(udg_somecache, "disabledAbility", "("+I2S(5)+")") )
        call UnitRemoveAbility( somegUnit, GetStoredInteger(udg_somecache, "disabledAbility", "("+I2S(7)+")") )
        call UnitAddAbility( someUnit, GetStoredInteger(udg_somecache, I2S(12)+","+I2S(thePosition), "whatSpellbook") )
        call UnitAddAbility( someUnit, GetStoredInteger(udg_somecache, I2S(12)+","+I2S(thePosition), "whatSecondSpellbook") )
        call RemoveItem( GetManipulatedItem() )
        call some_ModifyStats(someUnit, true, GetStoredString(udg_somecache, I2S(12)+","+I2S(thePosition), "whatStats"))
        call StoreBoolean(udg_somecache, someUnitID, I2S(12), true)
        call ForceUIKeyBJ( GetOwningPlayer(someUnit), "I" )
    else
        //Mark 3
        call some_SimError(GetOwningPlayer(someUnit), "*")
        call BJDebugMsg("This does show")
    endif
    //Mark 4
    call BJDebugMsg("This does show")
endif


Yes I changed some names, but that shouldn't matter.
01-07-2009, 04:15 AM#2
Ammorth
is * a valid character for names? I wouldn't think it would work (unless that denotes a name change).
01-07-2009, 08:09 AM#3
DioD
Asterics (*) is not valid char for vars and functions.
01-07-2009, 12:56 PM#4
Thunder_Eye
Quote:
Originally Posted by Thunder_Eye
Yes I changed some names, but that shouldn't matter.
But I'll change it if it makes you happy.

There are no syntax errors, only run-time errors.
01-07-2009, 01:03 PM#5
Vestras
The syntax checker can fuckup sometimes.
01-07-2009, 01:08 PM#6
Thunder_Eye
Well what could be wrong then? The code almost runs perfectly fine as long as the first one does not equal to false.
There are 4 scenarios:
Table:
1st if2nd ifRuns Code
truetrueMark 2
truefalseMark 3
falsefalseMark 4
falsetrueMark 4

EDIT:
Okey something is heavily wrong with the code at Mark 3..
Currently it looks like:
Collapse JASS:
    else
        //Mark 3
        call some_SimError(GetOwningPlayer(someUnit), "*")
        call BJDebugMsg("This does show")
    endif
The debugmsg runs, however if I put it like this.
Collapse JASS:
    else
        //Mark 3
        call BJDebugMsg("This does show")
        call some_SimError(GetOwningPlayer(someUnit), "*")
    endif
It does NOT print the text "This does show". I've made sure some_SimError doesn't crash the thread with a DebugMsg at the end of the function.
Why does the first example show, but the second does not?

EDIT2:
Ok the problem seems solved atm, the problem was that if the item "GetManipulatedItem()" was removed before the code the first if statement returned true. The code currently works as supposed to.
However, that does not explain the very odd errors I had before.