| 01-01-2007, 01:33 AM | #1 |
some might think that it is a joke to call natives on already removed handles, probably because most of the times it is harmless. But it is a terrible idea. Always make sure the handle exists. There are few natives that I would know that work one of them is GetUnitState which I extensively used to recognize if a unit is removed. On the other hand, some natives can pretty much screw the map big time. Just call SetUnitX/Y on an already removed unit multiple times and you will screw up CreateTrigger() Have fun, if your map is Jass enhanced and got a lot of dynamic triggers, paste this code and press escape in game. It is fun to see everything fail. JASS:function eH2I takes handle h returns integer return h return 0 endfunction function dI2U takes integer i returns unit return i return null endfunction function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing local unit u=CreateUnit(Player(0),'hfoo',0,0,0) local integer k=eH2I(u) call RemoveUnit(u) // set u=null call TriggerSleepAction(0.) loop set u=dI2U(k) call SetUnitX(u,1) call TriggerSleepAction(0.0) set u=null endloop call BJDebugMsg("screwed?") endfunction //=========================================================================== function InitTrig_Untitled_Trigger_001 takes nothing returns nothing set gg_trg_Untitled_Trigger_001 = CreateTrigger( ) call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_001, Player(0) ) call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions ) endfunction |
| 01-01-2007, 05:19 AM | #2 |
yup... I'm one of the unlucky guy who experienced this... for no reason my whole map failed due to calling SetUnitX on an removed unit @@ been seaching for the reason for 2 days end up vex pointed that it was all thanks to this bug xP~ |
| 01-01-2007, 05:58 AM | #3 |
This is hardly a bug. |
| 01-01-2007, 09:12 AM | #4 |
How is it not a bug? |
| 01-01-2007, 09:37 AM | #5 |
It IS a bug, as the native functions should not screw things up if having as a parameter non-existing objects. Blizzard should've added a special case for non-existant objects. We cannot control the native functions, it is a problem of the programming language from development, and therefore, we can call it a bug. ~Daelin |
| 01-01-2007, 11:08 AM | #6 |
Once you remove a handle, the expectation is that it gets filled in by something else. Every handle you don't know exists is in limbo between existence and non existence. What you thought was unit X is now unit Y or heaven forbid special effect Z. Any operation on that handle is invalid and undefined. Blizzard could have defensively programmed to prevent things from going horribly wrong, and then you could rely on that defined behavior, although it would still be bad style. |
| 01-01-2007, 09:28 PM | #7 |
Or you could just be smart and put in a safeguard like normal, smart programmers? |
| 01-02-2007, 11:25 AM | #8 |
I know what things like this, crush thread. the other effect i havent see and ofcourse crushed thread don't free used memory =) A ! you convert the handle of not existing object =) but in some case it == bad coding... |
| 01-03-2007, 12:57 AM | #9 |
Wait a second... Would this sort of thing cause say... Natives to start failing, TriggerSleeps to not work at all, massive lag, etc? Because I've always wondered what causes natives and TriggerSleeps to just... Not work in some games of AotZ. I might have something else to scour the code for if that is indeed the case. |
| 01-03-2007, 01:13 AM | #10 |
You've seen the triggersleeps thing not working? Neat-that makes two maps! Could be, but the map I saw it in was pure GUIese-I don't think they destroyed/removed anything and certainly set nothing to null. |
| 01-03-2007, 03:05 AM | #11 |
I just cannot explain what happens to AotZ in like 1 out of 12 games. It's as if the game says "Screw this" and stops working at all. I wish I could explain it any better. I've been trying for months to weed out the issues to no avail. I'm almost sure that if I could ever figure it out, it would benefit a lot of people, but that is yet to be seen. Oh well, I'll delve back into the code and hope something jumps out at me. |
| 01-03-2007, 04:03 AM | #12 |
Give it a shot, call something on a removed native or just use Vex's code, play for a little while to make sure everything is working this game, then hit escape. If everything screws up the way you see once every 12 games, there's your bug. |
| 01-11-2007, 02:13 PM | #13 |
This has to be the bug that is happening in AotZ. I just need to find it. I think in my case it's probably calling natives on destroyed effects though. Although to be honest, I am not sure. I need to mention though, when I CnP'd the code and hit escape, the game bugged out incredibly... Almost identical to what happens online when the game bugs. |
| 01-11-2007, 11:09 PM | #14 |
setunitX\Y is crappy unsafe function its known long ago |
| 01-12-2007, 01:26 AM | #15 |
Don't dare to call it crappy, SetUnitX/Y are probably the best natives ever. It is the user's fault anyways. |
