Jump to content
EleTD.com
Sign in to follow this  
Guest DeathMasta

Bad unit handle error

Recommended Posts

Guest DeathMasta

Hi guys. I've been playing a good bit of EleTD lately and I just got a bug in a game. As you can see from the screenshot the game gave me this error and none of my towers would attack the creeps. This happened (I think) when I upgraded 6 or so towers to Geyser towers. This is with beta 16b. It was also near the end of the game when I had 50 lives left, oh well. :o

eletd%20error.JPG

Share this post


Link to post
Guest DeathMasta
If you could post the replay in the game reports forum (in beta section) that would be great...

Ah crap, I never thought to save the replay. I would upload 'lastreplay' but I know I've played a few games since then. Sorry.

Share this post


Link to post
Guest DeathMasta

Experienced the error again. I was afk during the game but a friend of mine explained to me what happened. Apparently it is the Mortar towers causing the bug, just the Mortars wouldn't attack. He simply sold them all and he finished playing. Attached a replay.

LastReplay.w3g

Share this post


Link to post
Guest RiVaL.ChiMeRa

It should also be noted that the units of the round ran back and forth for a long period of time. I'm not sure if it's the result of the same bug or not.

Share this post


Link to post
Guest cohadar

Yes PUI also controls units so it is the result of same error.

This error happens when a spell uses GetUnitIndex on a null unit.

and this can only happen after waits.

So Karawasa post a trigger code for that tower that is making problems.

There is a big chance error is there.

I will be available on MSN at 20:00 GMT+1

Share this post


Link to post
Guest RiVaL.ChiMeRa

Just FYI this bug still exists in the newest private beta.

Share this post


Link to post

pff, and how did you get it?

I can't se anywhere that your a beta tester.

Another question, what is this bad unit handle?

Since it's only you that got it.

Share this post


Link to post

I was thinking the same - you are not in the beta tester list - how do you know it's not in the latest private beta? :P

Share this post


Link to post
Guest cohadar

PUI handle error happens for two reasons:

You call GetUnitIndex(whichUnit) with null unit handle

You call GetUnitIndex(whichUnit) with unit handle of a unit that has been removed from game.

Now theoretically this should be only a warning because GetUnitIndex returns zero for null or invalid handle and the coder can check that:

local integer i = GetUnitIndex(GetTriggerUnit())
if i == 0 then
   // Abort Spell
else
   // Do the spell stuff
endif

But most people don't check it so from warning it becomes an error because you do the spell stuff with invalid handle and that fucks up stuff.

The worst is that it can propagate from one spell to another creating a chain reaction.

(The blizzard is to be blamed for this because they don't have cutoff mechanism for handle factory/recycler)

Examples1:

You want to do 500 damage a random unit in an area of 300 with a custom spell that uses PUI

call GroupEnumUnitsInRange(g, x, y, 300., Filter(function AliveEnemyUnits))
set target = FirstOfGroup(g)
set SpellDamage[GetUnitIndex(target)] = 500.

The poblem with the above code is what if there are no alive enemy units in that area?

FirstOfGroup will return null, than you will call GetUnitIndex on a null unit and bam...

Correct way would be to check the index ofc.

Example2:

You have a DOT spell (damage over time), for example something like custom shadow strike that deals 200 damage to a unit every second for 10 secons.

local integer i = 10
loop
    exitwhen i<0
    set SpellDamage[GetUnitIndex(target)] = 200.
    // execute custom spell effect
    call TriggerSleepAction(1.0)
    set i = i - 1
endloop

But imagine a player that casted that spell leaves a game 5 sec after the cast.

As you all know all his units will be removed from game so the next 5 times that 200. damage will be called on invalid unit handle(removed unit) ....

Nuff said.

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...