| 09-20-2006, 11:58 AM | #1 | |
I've built a "little" Fireballspell, it works perfectly, but WC3 crashs after 100+ Runs without a warning. How to fix that Problem? Here's the Code:
|
| 09-20-2006, 12:34 PM | #2 |
Try removing the array. I do not know why but I have a hunch that the problem may be with their allocation. Tell me if the error does not occur again and maybe then a new bug has been discovered. I found a problem though in the timer. When the timer ends, if you simply use "return" without nulling or removing anything, all leaks remain. Also you use too much GetExpiredTimer(). I suggest you try to avoid the timer bug by using the timer as a parameter in timer's function. Replace that function with one which simply calls it, using the timer as a parameter. ~Daelin |
| 09-20-2006, 01:22 PM | #3 |
I rebuild everything as you told, but WC3 still crashs. Needs a bit longer till crash, but it still crashs, damn it, i still can't find the proplem. |
| 09-20-2006, 01:35 PM | #4 |
You have a leak in the fireball function. If you return, "target" will leak. Use natives instead of those non-natives. These are not stuff that should cause a crash though. I don't get this: set s = I2S(H2I(t)). I also suspect this: call TimerStart(t,FireballPeriod(),true,function Fireball_callback) set fireball = null. I'm not sure if this cannot cause the timer bug too. And no, callback is not like this. JASS:function FireballCore takes timer t returns nothing //blah blah, no nullification for t needed endfunction function Fireball_callback takes nothing returns nothing call FireballCore(GetExpiredTimer()) endfunction exitwhen u == null or n >=8192. Does crash occur after a savegame? You know the maximum array size limit which is 8191 after a savegame. u, in first function, is never nullified. The code is still really messy. Modify it, especially replace the non-natives, and then we'll see. ~Daelin |
| 09-20-2006, 02:23 PM | #5 |
Got the exact number when WC3 crashs, it crashs after 202 runs. I'm not using: JASS:function Fireball_callback takes nothing returns nothing call FireballCore(GetExpiredTimer()) endfunction I use JASS:function Fireball_callback takes nothing returns nothing call ExecuteFunc("FireballCore") endfunction H2I is just this JASS:function H2I takes handle h returns integer return h return 0 endfunction And this JASS:call TimerStart(t,FireballPeriod(),true,function Fireball_callback) Also i don't think that JASS:set fireball = null And no the crash doesn't occour after a loaded save game and i nullify u always. JASS:
loop
set u = FirstOfGroup(g)
exitwhen u == null or n >=8192
if(FireballIsUnitAllowed(u,fireball)) then
if (u==target) then
call UnitDamageTargetBJ( fireball, u, ( 100.00 * I2R(level) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
else
call UnitDamageTargetBJ( fireball, u, ( 50.00 * I2R(level) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endif
endif
set n = n + 1
call GroupRemoveUnit(g,u)
set u = null
endloop
I also tried the natives but the game still crashs. |
| 09-20-2006, 04:04 PM | #6 |
Mno, I meant use Fireball_callback how I said, sorry for the misunderstanding. There's no point in executing a function from timer's function. It's the same thing. Call a function with the timer as a parameter and avoid using GetExpiredTimer() loads of times, just because you are afraid of nullifying timer pointer. ~Daelin |
