Weird Bug

Executor

I see you
Reaction score
57
JASS:
    
private struct Pawn extends Figure
        static constant integer UNIT_ID = PAWN_ID
        method isMoveValid takes Chess__FieldStruct dest returns boolean
            if .white then
                return ( (FieldStruct(dest).y - FieldStruct(.pos).y) == 1) and (IAbsBJ( FieldStruct(dest).x - FieldStruct(.pos).x ) == 1)
            else
                return (dest.y-.pos.y == -1) and (IAbsBJ(dest.x-.pos.x) == 1) // <-
            endif
        endmethod
        static method create takes real x, real y, boolean white returns thistype
            return .createFigure(x,y,white,UNIT_ID)        
        endmethod
    endstruct


the marked line makes problems.
There are 2 error texts, which occur:
- dest is not of a type that allows . syntax
- pos[this] is not of a type that allows .syntax

The weird thing is that both vars are "FieldStruct" vars, but only a typecast prevents the error line.
 

Nexor

...
Reaction score
74
I don't think functions/methods can take structs as arguments

But you could add a return false line after the if/then/else
 

Executor

I see you
Reaction score
57
Well I now replaced all "dest" with "FieldStruct(dest)" etc. (even if that shouldn't be necessary :/ )

Now, it seems to work. BUT every 3rd time I save the compiler gives me several errors. The weird thing is, that saving again solves the problem.. sometimes?!
 
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