HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simple Loops Crashes Wc3

01-25-2009, 01:40 AM#1
ShadowWolf
Trigger:
Level 9
Collapse Events
Time - Every 5.00 seconds of game time
Collapse Conditions
int_LevelNumber Equal to 9
Collapse Actions
Set temp_UnitGroup = (Units of type Tree-Eating Sheep - 9)
Collapse Unit Group - Pick every unit in temp_UnitGroup and do (Actions)
Collapse Loop - Actions
Set temp_Location = (Position of (Picked unit))
Unit - Order (Picked unit) to Attack (Random destructible in (Region centered at temp_Location with size (800.00, 800.00)))
Custom script: call RemoveLocation(udg_temp_Location)
Custom script: call DestroyGroup(udg_temp_UnitGroup)

Seems like a simple enough loop, but it closes wc3 when it fires. It's handling 25 units, which doesn't seem like it should be too much, so why is this crashing?
01-25-2009, 01:53 AM#2
DioD
dont destroy GUI globals, never.
01-25-2009, 02:15 AM#3
TriggerHappy
Quote:
Originally Posted by DioD
dont destroy GUI globals, never.

How do you expect GUI'ers remove leaks.
01-25-2009, 06:17 AM#4
Archmage Owenalacaster
It's a global variable, not a local. Clear the group, don't destoy it.

EDIT: After reading the proceeding posts, I'd like to add that I'm wrong and am an idiot for not remembering that those group functions create groups.
01-25-2009, 07:31 AM#5
ShadowWolf
It still crashes the game, it's not the cause. :/
01-25-2009, 08:40 AM#6
DioD
You destroy global group and leak rect...clean up fail.

Post map, if you destroy group anywhere or attack nothing game may run unstable.
01-25-2009, 09:36 AM#7
the-thingy
Quote:
It's a global variable, not a local. Clear the group, don't destoy it.
Quote:
You destroy global group and leak rect...clean up fail.
All (from what I know) GUI groups create a new group
Code:
Set G = (Units of type Footman)
becomes
Collapse JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction
A group is being created everytime the trigger runs, so the alternative is leaking...


As for the question, do you have any trigger like
Trigger:
Melee Initialization
Collapse Events
Unit - A unit Is issued an order targeting an object
Conditions
Collapse Actions
-------- Some action involving a unit targeting an object like --------
Unit - Order (Triggering unit) to Attack (Last created unit)
01-25-2009, 10:56 AM#8
Captain Griffen
He does need to destroy the group. Don't confuse the need to null locals with the object leak...

Anyway, could be setting off some other trigger that detects orders?
01-25-2009, 12:33 PM#9
Anitarf
The crash could be caused by something like an infinite loop, but it's definitely not caused by this trigger alone.
01-25-2009, 12:38 PM#10
Matarael
How do you get the value for the int_LevelNumber? Did you remember to "close" it?
01-25-2009, 02:00 PM#11
DioD
Captain Griffen
There is MANY BJ functions that linked to global and destruction of such object cause "bug cascade", if you code GUI only, dont destroy anything.

OFC if you able to check every function you using you can destroy\clean what you want, but in this case you dont need GUI...
01-25-2009, 02:56 PM#12
Bobo_The_Kodo
In this case, the destroy group should be at the very start of the trigger.
01-25-2009, 09:49 PM#13
ShadowWolf
Holy shit, every tutorial says to destroy the group when using GUI and you guys just said about 3 different things, all contradicting each other. Which is it?

Anyways, it shouldn't be connected to int_LevelNumber, that is only changed when a countdown timer expires. I don't want to post the entire map, it's a finished product. If you want to take a look at it, post and I might PM it to you. I'm currently running through every trigger that interacts with that one and trying to debug it. I'm starting to think that Griffen is right. I think I have some order functions in here to keep units from getting stuck, I'll play around with them see if that fixes things.
01-25-2009, 09:58 PM#14
Troll-Brain
War3 crash with a box message or without it ?
But i'm agree it can't be this trigger, at least not by itself