Trigger causing server splits

Cal1991

New Member
Reaction score
7
Some people server split when this trigger runs. Anyone know why?
JASS:

function Trig_Creep_Spawn_Jass_Func002Func001002002 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Creep_Spawn_Jass_Func002Func002C takes nothing returns boolean
    if ( not ( IsUnitGroupEmptyBJ(udg_Group) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Creep_Spawn_Jass_Actions takes nothing returns nothing
    local integer a = 1
    local integer b = 18
    local integer c = 1
    local integer d = 18
    call AddItemToStockBJ( ChooseRandomItemExBJ(GetRandomInt(4, 8), ITEM_TYPE_ANY), gg_unit_nmrk_0017, 1, 1 )
    loop
        exitwhen a > b
        set udg_Group = GetUnitsInRectMatching(udg_CreepLocs[a], Condition(function Trig_Creep_Spawn_Jass_Func002Func001002002))
        if ( Trig_Creep_Spawn_Jass_Func002Func002C() ) then
            set udg_Point[1] = GetRectCenter(udg_CreepLocs[a])
            set c = udg_CreepAmountMin[a]
            set d = udg_CreepAmountMax[a]
            loop
                exitwhen c > d
                call CreateNUnitsAtLoc( 1, ChooseRandomCreepBJ(GetRandomInt(udg_CreepLevelMin[a], udg_CreepLevelMax[a])), Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Point[1], bj_UNIT_FACING )
                call UnitAddAbilityBJ( 'Asla', GetLastCreatedUnit() )
                call PolledWait( 1 )
                set c = c + 1
            endloop
            set udg_CreepAmountMax[a] = ( udg_CreepAmountMax[a] + 1 )
            set udg_CreepAmountMin[a] = ( udg_CreepAmountMin[a] + 1 )
            set udg_CreepLevelMax[a] = ( udg_CreepLevelMax[a] + 1 )
            call RemoveLocation(udg_Point[1])
        else
            call DoNothing(  )
        endif
        call DestroyGroup(udg_Group)
        set a = a + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Creep_Spawn_Jass takes nothing returns nothing
    set gg_trg_Creep_Spawn_Jass = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Creep_Spawn_Jass, 30.00 )
    call TriggerAddAction( gg_trg_Creep_Spawn_Jass, function Trig_Creep_Spawn_Jass_Actions )
endfunction
 

Builder Bob

Live free or don't
Reaction score
249
It looks as if the time you set the global location variable udg_Point[1] and remove it's location is on each their side of a PolledWait().

I don't know if that can cause the server split, but I do know that if multiple instances of this trigger are run on the same time, then the location can be removed in one trigger after it was set in another, but before it was used. Leading to a situation where you try to use a location that does not exist.

Try using a local location variable instead

Edit: same thing with your group variable
 

Cal1991

New Member
Reaction score
7
It looks as if the time you set the global location variable udg_Point[1] and remove it's location is on each their side of a PolledWait().

I don't know if that can cause the server split, but I do know that if multiple instances of this trigger are run on the same time, then the location can be removed in one trigger after it was set in another, but before it was used. Leading to a situation where you try to use a location that does not exist.

Try using a local location variable instead

Edit: same thing with your group variable

Hmm, that is a good point, but it split before I added the wait, I added the wait in attempt to make it easier on slow comps in case it was splitting for that reason. I'll try locals and see how it goes, though. Thanks.
 

Builder Bob

Live free or don't
Reaction score
249
If the wait isn't causing the splits, then my only other idea is that it can be something in one of the BJ functions that is causing it. They often do stuff that is unneeded.

JASS:
function Trig_Creep_Spawn_Filter takes nothing returns boolean
	return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endfunction

function Trig_Creep_Spawn_Jass_Actions takes nothing returns nothing
	local unit u
	local group g
	local real x
	local real y
	local integer a = 1
	local integer b = 18
	local integer c = 1
	local integer d = 18
	call AddItemToStock(gg_unit_nmrk_0017, ChooseRandomItemEx(ITEM_TYPE_ANY, GetRandomInt(4, 8)), 1, 1)
	loop
		exitwhen a > b
		set g = CreateGroup()
		call GroupEnumUnitsInRect(g, udg_CreepLocs[a], Condition(function Trig_Creep_Spawn_Filter))
		if FirstOfGroup(g) == null then //I don't know if it's the best way to check for an empty group, but at least it works and is short
			set x = GetRectCenterX(udg_CreepLocs[a])
			set y = GetRectCenterY(udg_CreepLocs[a])
			set c = udg_CreepAmountMin[a]
			set d = udg_CreepAmountMax[a]
			loop
				exitwhen c > d
				set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), ChooseRandomCreep(GetRandomInt(udg_CreepLevelMin[a], udg_CreepLevelMax[a])), x, y, bj_UNIT_FACING)
				call UnitAddAbility(u, 'Asla')
				call PolledWait(1) //it's up to you if you want to keep the polled wait or not
				set c = c + 1
			endloop
			set udg_CreepAmountMax[a] = udg_CreepAmountMax[a] + 1
			set udg_CreepAmountMin[a] = udg_CreepAmountMin[a] + 1
			set udg_CreepLevelMax[a] = udg_CreepLevelMax[a] + 1
		endif
		call DestroyGroup(g)
		set a = a + 1
	endloop
	set u = null
	set g = null
endfunction

//===========================================================================
function InitTrig_Creep_Spawn_Jass takes nothing returns nothing
	set gg_trg_Creep_Spawn_Jass = CreateTrigger()
	call TriggerRegisterTimerEvent(gg_trg_Creep_Spawn_Jass, 30.00, true)
	call TriggerAddAction(gg_trg_Creep_Spawn_Jass, function Trig_Creep_Spawn_Jass_Actions)
endfunction


I took the liberty to replace the BJ functions with natives. There might be some mistakes as I weren't able to check the syntax due to lack of variables.
 

Cal1991

New Member
Reaction score
7
If the wait isn't causing the splits, then my only other idea is that it can be something in one of the BJ functions that is causing it. They often do stuff that is unneeded.

I took the liberty to replace the BJ functions with natives. There might be some mistakes as I weren't able to check the syntax due to lack of variables.

Well, thanks for going through the work to change the BJs.

The syntax was fine, but it's still splitting just as badly as before. (I copy+pasted your code so I know I didn't mess it up)

Also, I know it is not my host because I regularly host DotA/ladder/other maps of mine with no splits.

+rep cause I appreciate your attempts to help but it's still not working. Maybe adding an item to marketplace can cause a split? Because thats also in the trigger.
 

Builder Bob

Live free or don't
Reaction score
249
Well, then I have no idea what may be causing it.

Appreciate the rep. I'm sorry, I couldn't help you get to the bottom of the problem.

Maybe someone else want to take a crack at it. It would be interesting to know what the cause it.
 

Technomancer

New Member
Reaction score
14
This could be a hell of a tester :/ best bet is to /w the guys that regularly split and break the code up into parts and have them test, to see what is causing it.

I looked it through, didn't see anything, but can I see the full map?
 

Arkan

Nobody rides for free
Reaction score
92
Does it work as intended if you try it in single player? Try putting up a few debug messages in the code to narrow down the line that causes a split, can't see it now...
 

Builder Bob

Live free or don't
Reaction score
249
hmm... one final thought.

you set these variables right before the unit creating loop.
Code:
set c = udg_CreepAmountMin[a]
set d = udg_CreepAmountMax[a]

right after the loop you add one to both of these variables that later turn into c and d again.
Code:
set udg_CreepAmountMax[a] = udg_CreepAmountMax[a] + 1
set udg_CreepAmountMin[a] = udg_CreepAmountMin[a] + 1

the unit creating loop goes from c to d, so adding 1 to both changes nothing. I was wondering, does these variables get changed in other triggers?

udg_CreepLevelMax[a] also seem to get increased a lot. Could making a too high lvl creep cause any anomalies?

I don't see why any of those things would cause splits however, just thought it didn't make much sense unless some other trigger has something to do with the same variables.

Arkan has a good point by the way, check all the variables with debug messages to see if they are what you want them to be.
 

Cal1991

New Member
Reaction score
7
Does it work as intended if you try it in single player?
Yeah, sometimes it even works fine in multi-player, but usually someone splits.


I looked it through, didn't see anything, but can I see the full map?

Sure, attached is the map.

you set these variables right before the unit creating loop.
Code:
set c = udg_CreepAmountMin[a]
set d = udg_CreepAmountMax[a]

right after the loop you add one to both of these variables that later turn into c and d again.
Code:
set udg_CreepAmountMax[a] = udg_CreepAmountMax[a] + 1
set udg_CreepAmountMin[a] = udg_CreepAmountMin[a] + 1

the unit creating loop goes from c to d, so adding 1 to both changes nothing.
Thanks for pointing that out, originally I was going to make more creeps spawn as the game went along but decided not to. I guess I should just delete that bit now.

I was wondering, does these variables get changed in other triggers?
No.
udg_CreepLevelMax[a] also seem to get increased a lot. Could making a too high lvl creep cause any anomalies?
Unlikely, but it might be possible I guess. But that can't be the cuase of the current problem becuase it splits the first time creeps spawn, and the max creep level is 2 for the first spawn, 3 for the second, ect.
Try putting up a few debug messages in the code to narrow down the line that causes a split, can't see it now...
Arkan has a good point by the way, check all the variables with debug messages to see if they are what you want them to be.
I suppose so. Since the trigger works perfectly with the exception of splitting a few people the first time it runs, I doubt they are anything other than what they ought to be. And I'm not 100% sure it always splits at same place.

But yeah thats just about the only option I have now, so I'll do that.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top