| 03-05-2009, 05:48 AM | #1 |
Can't figure out why. I've isolated the problem but there's no obvious problem... Also; any comments on the system? It avoids dynamic triggers at least; =p. The problem is DeleteEnterRect at least that causes the crash. It's something to do with H2I, I can't figure it out =x. JASS:library OER initializer init uses Callbacks globals private trigger OnEnter private Table cbs endglobals private function interface Oni takes nothing returns nothing private function H2I takes handle h returns integer return h return 0 endfunction struct OERS rect rct region r Oni callback boolean enter endstruct private function OnEnterFunc takes nothing returns nothing local region r = GetTriggeringRegion() local unit u = GetEnteringUnit() local OERS oz = cbs[H2I(r)] local Oni i = oz.callback set CALLBACK_RESPONDER = u set CALLBACK_STRUCT = oz call i.execute() endfunction function RegisterEnterRect takes rect rct, boolean enter, boolexpr cond, Oni i returns nothing local region r = CreateRegion() local OERS oz = OERS.create() local integer I call RegionAddRect(r, rct) set oz.rct = rct set oz.r = r set oz.callback = i set oz.enter = enter set I = H2I(r) set cbs[i] = oz set cbs[H2I(rct)+I] = oz if(enter)then call TriggerRegisterEnterRegion(OnEnter, r, cond) else call TriggerRegisterLeaveRegion(OnEnter, r, cond) endif endfunction function DeleteEnterRect takes OERS s, boolean removerect returns nothing if(s == 0)then return endif set cbs[H2I(s.r)] = 0 set cbs[H2I(s.r) + H2I(s.rct)] = 0 if(removerect)then call RemoveRect(s.rct) set s.rct = null endif call RemoveRegion(s.r) set s.r = null call s.destroy() endfunction private function init takes nothing returns nothing set OnEnter = CreateTrigger() call TriggerAddAction(OnEnter, function OnEnterFunc) set cbs = Table.create() endfunction endlibrary |
| 03-05-2009, 09:59 AM | #2 | |
Quote:
How come you are adding these values? Should you be doing that? I'm not super familiar with Tables but that doesn't seem right. ...and I don't see DeleteEnterRect ever being called or used in this script... |
