HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Crash when these triggers are run

04-21-2005, 04:10 AM#1
aaero
EDIT: Thanks Mods.

Hi all,

My map crashes when I play with multiple players on Battle.Net when I reach a certain point in the map. I may know why, but I 'd like it confirmed. I'm not positive which trigger it is, but I have a pretty good guess. I'll post 4 possible problem triggers.

#1
Code:
Master Summoner Summon Phoenix
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Unit-type of (Summoned unit)) Equal to Phoenix (Round 7)
    Actions
        Set uSummoner7 = (Summoning unit)
        Set uPhoenix7 = (Summoned unit)
        Lightning - Create a lightning effect Magic Leash (Position of uSummoner7) (Position of uPhoenix7)
        Lightning - Change (Last created lightning effect) color to 0.20 1.00 1.00 1.00
        Set ltPhoenix = (Last created lightning effect)
        Trigger - Turn on Master Summoner Lightning Effect <gen>

#2
Code:
Master Summoner Summon Eredar
    Events
        Unit - A unit Spawns a summoned unit
    Conditions
        (Unit-type of (Summoned unit)) Equal to Eredar Diabolist
    Actions
        Set uSummoner7 = (Summoning unit)
        Set uEredar7 = (Summoned unit)
        Lightning - Create a lightning effect Magic Leash (Position of uSummoner7) (Position of uEredar7)
        Lightning - Change (Last created lightning effect) color to 0.20 1.00 1.00 1.00
        Set ltEredar = (Last created lightning effect)
        Trigger - Turn on Master Summoner Lightning Effect <gen>

#3 (this is probably the problem trigger, and the problem is probably that I'm setting my point variables to null and then reusing them)
Code:
Master Summoner Lightning Effect
    Events
        Time - Every 0.08 seconds of game time
    Conditions
    Actions
        Set p_TempPoint = (Position of uSummoner7)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (uEredar7 is alive) Equal to True
            Then - Actions
                Set pntTemp2 = (Position of uEredar7)
                Lightning - Move ltEredar p_TempPoint pntTemp2
            Else - Actions
                Lightning - Destroy ltEredar
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (uPhoenix7 is alive) Equal to True
            Then - Actions
                Set pntTemp2 = (Position of uPhoenix7)
                Lightning - Move ltPhoenix p_TempPoint pntTemp2
            Else - Actions
                Lightning - Destroy ltPhoenix
        Custom script:   set udg_p_TempPoint = null
        Custom script:   set udg_pntTemp2 = null
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (uEredar7 is alive) Equal to False
                (uPhoenix7 is alive) Equal to False
            Then - Actions
                Trigger - Turn off (This trigger)
            Else - Actions

#4: The Event for this is added elsewhere, when the unit is created. Doubtful that this is the problem anyway.
Code:
Master Summoner Dies
    Events
    Conditions
    Actions
        Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) of type Phoenix (Round 7)) and do (Actions)
            Loop - Actions
                Unit - Kill (Picked unit)
        Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) of type Eredar Diabolist) and do (Actions)
            Loop - Actions
                Unit - Kill (Picked unit)


Basically what I'm doing here is when a particular unit is summoned, I'm tying a lightning effect that is periodically moved between the caster and the summoned unit. It works perfectly (I think)in single player, but causes problems in multiplayer. It's obviously not multi-instanceable at all, it's just thrown together as a couple spells one of my boss monsters uses. Any ideas?
04-21-2005, 07:19 AM#2
Raptor--
i'm a bit tired, sorry, so i'm not gonna look through it to find the problem, but i'll tell you setting a variable to null will not crash it, although, its completely useless to do almost, since the pointer will be overwritten when it runs it again
04-21-2005, 07:34 AM#3
aaero
The reason I thought it might be the problem was because I'm pretty sure this causes errors:

Code:
local location pntTemp
set pntTemp = null
set pntTemp = SomeLocation

Because once you set a variable to null it loses it's type. But I could be wrong, and that certainly wouldn't explain why it only crashes with multiple players.
04-21-2005, 08:12 AM#4
Anitarf
Well, if you are seting them to null to remove memory leaks, that won't help anyway. You should use the custom script RemoveLocation( udg_pntTemp2 ) to eliminate the leak. However, I do not see how this would solve your current problem, I don't know what could be the problem. Maybe you can just experiment a bit by deactivating some triggers or their parts and see when it works...
04-21-2005, 05:51 PM#5
Raptor--
Quote:
Originally Posted by aaero
The reason I thought it might be the problem was because I'm pretty sure this causes errors:

Code:
local location pntTemp
set pntTemp = null
set pntTemp = SomeLocation

Because once you set a variable to null it loses it's type. But I could be wrong, and that certainly wouldn't explain why it only crashes with multiple players.

yeah, thats wrong, you cannot 'detype' a variable... setting it to null simply removes the contents of that pointer
04-21-2005, 06:36 PM#6
aaero
Alright, good to know. The reason I thought that is because you can't perform some operations on variables once they are set to null. for example, you can't set a unit group to null and then use "Unit - Add LastCreatedUnit to someUnitGroup" without getting an error. You have to do a "set someUnitGroup = CreateGroup()" to be able to work with it in that sense (but you probably already know this).

That said, I'm still not sure what's causing the memory fault. It's difficult to test because it only happens with more than two ppl (it didn't happen when I ran the test with two people) and it happens at a strange point in the map. Guess I just need to make some more friends to narrow down the problem.

Edit: Just saw Anitarf's post. I thought that setting a variable to null and calling RemoveLocation were both necessary to remove leaks? I thought I remembered Lord Vexorian saying that in a thread..I'll see if I can find it.

Edit2: Not the thread I was thinking of, but some smart guys saying the same thing:
A Thread
04-21-2005, 10:32 PM#7
Vexorian
When it is a global variable, you don't have to set it to null.

When it is a local handle-derived type variable you have to set it to null.

And in both cases you have to remove the created objects you won't use later.

I seriously doubt the cause is any of these triggers. Try disabling them and play the map again without this fancy useless feature that is not needed in gameplay anyways. If it crashes then it is not the fault of the triggers.
04-21-2005, 11:02 PM#8
aaero
Thanks for clearing that up Lord Vexorian.

I also think that's what I'm going to have to do - disable these triggers and see if the map crashes. I can understand where everyone's coming from when they mention that there's nothing here that could crash the map, but the fact is it worked before I added these triggers.

Regardless, I'll give it a try tonight and post the results. I wanted to avoid doing this without working out the cause but it'll be alright. I guess if the map still crashes I'll know it's unrelated to any of this :)

EDIT: Yeah, it works if I disable each of the three starting triggers. I'm starting to wonder if the map was just somehow corrupted when I prepared it for public release because a lot of talented minds have looked at these simple triggers and seen nothing wrong. I'll switch some of it around and take out the useless Set Global = null and see if I get anywhere.