| 02-20-2007, 03:33 PM | #1 |
| 02-21-2007, 04:02 AM | #2 |
huh? When I save it there are no errors: - If you don't need the passive ability event, comment out that line and possibly the other lines in that code that use an integer array p - Look out for global variables or structs named 'p'. If nothing works, send me the darn map? |
| 02-22-2007, 04:29 PM | #3 |
Aight, I've found both 'p' and 's', but they are not globals (at least not before compilation). Is it so that all structs count, even the local ones?? This is the list-code which PipeDream provided me with JASS://! library List struct pair integer value pair next static method cons takes integer value, pair next returns pair local pair p = pair.create() set p.value = value set p.next = next return p endmethod method copy takes nothing returns pair if this.next == 0 then return pair.cons(this.value,0) else return pair.cons(this.value,this.next.copy()) endif endmethod //remove recursion static method Destroy takes pair p returns nothing local pair next = p.next call pair.destroy(p) if p.next != 0 then call pair.Destroy(next) endif endmethod endstruct struct list pair l static method Create takes nothing returns list local list s = list.create() set s.l = 0 return s endmethod method push takes integer value returns nothing set this.l = pair.cons(value,this.l) endmethod method pop takes nothing returns nothing if this.l != 0 then set this.l = this.l.next endif endmethod method peek takes nothing returns integer return this.l.value endmethod method isempty takes nothing returns boolean return this.l == 0 endmethod method shuffle takes nothing returns nothing local pair array lst local integer n = 0 local pair p = this.l local integer i = 0 local integer swapwith loop exitwhen p == 0 set lst[n] = p set n = n + 1 set p = p.next endloop loop exitwhen i >= n set swapwith = GetRandomInt(i,n-1) //swap ith with n-1th //need to include i so that every element can end up in every position set p = lst[swapwith] set lst[swapwith] = lst[i] set lst[i] = p set i = i + 1 endloop set i = 0 loop exitwhen i >= n-1 set lst[i].next = lst[i+1] set i = i + 1 endloop set lst[i].next = 0 set this.l = lst[0] endmethod //fine for acyclic method copy takes nothing returns list return this.l.copy() endmethod static method Destroy takes list l returns nothing call pair.Destroy(l.l) call list.destroy(l) endmethod endstruct //! endlibrary I solved this problem by adding needs CasterSystem to the library definition. Feels like a workaround to me, but at least... it works :P |
