• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] too many "Enters Region" events?

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
Good Evening Ladies and Gentlemen,

Short:
Is there a way to have too many events of type
JASS:
call TriggerRegisterEnterRectSimple( gg_trg_test, bj_mapInitialPlayableArea)
in a map?


Details:
In my current project, I got certain code blocks, which recognize entering units.

After the game started right after the initialization phase, units get displaced randomly and stopp moving randomly, if I select them and order them to move somewhere.
When that happens, core mechanics of the game stopp to work quite randomly, some of them are correctly set up and some are not.

I disabled all code blocks to track the down the problem, which turned out to be:


Description

that I cannot create anymore triggers with the above mentionned event. If I comment out only one arbitrary event register from the map script, the described problems vanish. If I add an empty trigger just with this event, the problems start to re-appear.
If I change mapInitialPlayableArea to some other rect, where also some units enter shortly after map initialization, the problems do not occur.


---------------
Can someone point me towards the problem? Is there some event cap hardcoded?

I am glad for any help and Best regards!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Be aware that the event is a BJ wrapper for the native unit enters region event. It works by filling a region cells using the given rect and using that region for the event.

The result is that the area which triggers the event is not the same as the rect provided because rects can represent areas that are not a whole number of cells and that there is possible a boundary logic error with the cell filling of regions from rects.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Thank you for your comments, guys :)

Have you checked if code is hitting the OP limit? Maybe there is too much stuff going on onInit that some inits will not run.
You may for example also init with a 0-timer timeout. Worth a try.

I don't think there is a (low) limit for this event registration.

I will try to set all my init with a 0-timer, and see if the problem persists.
Anyway, I can add tons of code and there is no OP limit reached, only if I register one more "Enters Region Event". I can add like 20 events of other types and a whole minigame trigger pack that consist of around 5000 lines of code (around 800 lines in init) ...

Edit: It does not help, if I use a 0-timer ..

Upload the code.

I think you are doing something fishy.

I guess, I can't since it is a whole map, which became quite complex lately. Is there a special section, you are interested in? I am not sure if you really want to test the whole map?^^

As I wrote, it does not matter, where the "one more region enters" event appears, it only has to be bj_mapInitialPlayableArea ...

Edit:

Is this too many init triggers in the start? When I delete some, it does not seem to have an impact on the observed problem.

JASS:
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_showbarn(  )
    call InitTrig_test_spiders(  )
    call InitTrig_player_show_barn(  )
    call InitTrig_player_hide_barn(  )
    call InitTrig_gold_init(  )
    call InitTrig_swamp(  )
    call InitTrig_mail(  )
    call InitTrig_thunder(  )
    call InitTrig_firepost(  )
    call InitTrig_walk(  )
    call InitTrig_bookShelf(  )
    call InitTrig_lighthouse_alc(  )
    call InitTrig_lightning(  )
    call InitTrig_player_hp(  )
    call InitTrig_pinesnow(  )
    call InitTrig_visibl(  )
    call InitTrig_sister(  )
    call InitTrig_cattle50(  )
    call InitTrig_honeytest(  )
    call InitTrig_debugtext(  )
    call InitTrig_mystic(  )
    call InitTrig_dummycommands(  )
    call InitTrig_TestTipps(  )
    call InitTrig_time_test(  )
    call InitTrig_setdemoseeds(  )
    call InitTrig_setmarket(  )
    call InitTrig_addabilities(  )
    call InitTrig_wintertest(  )
    call InitTrig_springtest(  )
    call InitTrig_fogtest_Kopieren(  )
    call InitTrig_fogtest(  )
    call InitTrig_enablefog(  )
    call InitTrig_daynight_test(  )
    call InitTrig_camtest(  )
    call InitTrig_visharvest(  )
    call InitTrig_resetharvester(  )
    call InitTrig_rooftest(  )
    call InitTrig_roofenable(  )
    call InitTrig_winter(  )
    call InitTrig_spring(  )
    call InitTrig_fruitday(  )
    call InitTrig_wset(  )
    call InitTrig_wex(  )
    call InitTrig_create_life(  )
    call InitTrig_create_crow(  )
    call InitTrig_animalcare(  )
    call InitTrig_autoupgrade(  )
    call InitTrig_testmilk(  )
    call InitTrig_cmfort(  )
    call InitTrig_farmHarvester(  )
    call InitTrig_cityHarvester(  )
    call InitTrig_immobilienHarvester(  )
    call InitTrig_mountainHarvester(  )
    call InitTrig_deepwoodsHarvester(  )
    call InitTrig_IcyMountainsHarvester(  )
    call InitTrig_FarmlandsHarvester(  )
    call InitTrig_PqAreaHarvester(  )
    call InitTrig_boxingHarvester(  )
    call InitTrig_whatweather(  )
    call InitTrig_zepp(  )
    call InitTrig_cook(  )
    call InitTrig_exhaustedTest(  )
    call InitTrig_GamePlay_Library(  )
    call InitTrig_Knowledge_Library(  )
    call InitTrig_Lightning_library(  )
    call InitTrig_Visibility_Libraries(  )
    call InitTrig_General_Presets(  )
    call InitTrig_Game_Initialization(  )
    call InitTrig_GamePreloadData(  )
    call InitTrig_MiscInit(  )
    call InitTrig_Game_Choose_Mode_INTRO(  )
    call InitTrig_Game_Choose_Mode_SheepDifficulty(  )
    call InitTrig_Game_Choose_Mode_Interactive(  )
    call InitTrig_Game_Choose_Mode_Choose_Heroes(  )
    call InitTrig_Game_Start(  )
    call InitTrig_GameLoadChosenDifficulty(  )
    call InitTrig_Game_Dialogs(  )
    call InitTrig_Effekte(  )
    call InitTrig_PlayerCreateItems(  )
    call InitTrig_Game_Quests(  )
    call InitTrig_Multiboards_Init(  )
    call InitTrig_Delayed_Destruction_and_Reset_Library(  )
    call InitTrig_DestructableHider(  )
    call InitTrig_TriggerRecycling(  )
    call InitTrig_Tree_Reviving_System(  )
    call InitTrig_Player_Leaves(  )
    call InitTrig_PlayerSwitchMultiboard(  )
    call InitTrig_OpenGamePlayOptions(  )
    call InitTrig_InfoWindow_Lib(  )
    call InitTrig_PlayerSetCamRef(  )
    call InitTrig_GameOptionsBoardClicked(  )
    call InitTrig_Camera_BirdEye_Modes(  )
    call InitTrig_StaticCamLinks(  )
    call InitTrig_StaticCamRechts(  )
    call InitTrig_Camera(  )
    call InitTrig_CameraChangeTargets(  )
    call InitTrig_FixedCameraMode(  )
    call InitTrig_FixedCameraModeRecycle(  )
    call InitTrig_InitPlayerItemManipulators(  )
    call InitTrig_Items_Library(  )
    call InitTrig_BuySpecialItems(  )
    call InitTrig_Portals_Library(  )
    call InitTrig_PortalToPlayerPropertiesDecision(  )
    call InitTrig_PortalToPlayerProperties(  )
    call InitTrig_PortalToPlayerPropertiesUnlock(  )
    call InitTrig_PortalToPlayerPropertiesLock(  )
    call InitTrig_RegionManagerEntering(  )
    call InitTrig_RegionManagerLeaving(  )
    call InitTrig_SpecialRects_Scope(  )
    call InitTrig_Game_Control(  )
    call InitTrig_PlayerDeath(  )
    call InitTrig_PER_01_Sec(  )
    call InitTrig_PER_03_Sec(  )
    call InitTrig_PER_1_Sec(  )
    call InitTrig_PER_5_Sec(  )
    call InitTrig_PER_10_Sec(  )
    call InitTrig_PER_30_Sec(  )
    call InitTrig_RapidSound(  )
    call InitTrig_SeasonalChange_Library(  )
    call InitTrig_MusicAndSound_Library(  )
    call InitTrig_Environmental_Library(  )
    call InitTrig_Market_Prices(  )
    call InitTrig_Multiboards_Current(  )
    call InitTrig_Stealing_Library(  )
    call InitTrig_Train_Library(  )
    call InitTrig_KaravaneInRange1(  )
    call InitTrig_KaravaneInRange2(  )
    call InitTrig_KaravaneInRange3(  )
    call InitTrig_KaravaneInRange4(  )
    call InitTrig_Karavane_Start(  )
    call InitTrig_KaravaneControlPath(  )
    call InitTrig_NatureLifeStock(  )
    call InitTrig_Nature_Library(  )
    call InitTrig_crow(  )
    call InitTrig_aa(  )
    call InitTrig_Cut_Wood_Library(  )
    call InitTrig_HammerRemoveStones(  )
    call InitTrig_BankSystem(  )
    call InitTrig_House_Comfort_Lib(  )
    call InitTrig_Buildings_System(  )
    call InitTrig_testdamage(  )
    call InitTrig_building_test(  )
    call InitTrig_Cast_Camp_Bed(  )
    call InitTrig_JumpSystem_Library(  )
    call InitTrig_Z_Movements_Library(  )
    call InitTrig_Upgrades_Library(  )
    call InitTrig_LearnSeedFlowersPlayer1(  )
    call InitTrig_LearnSeedFirewoodPlayer1(  )
    call InitTrig_AcquireSeedingBagPlayer1(  )
    call InitTrig_AcquireSeedingBagPlayer2(  )
    call InitTrig_AcquireSeedingBagPlayer3(  )
    call InitTrig_AcquireSeedingBagPlayer4(  )
    call InitTrig_AcquireDiaryPlayer1(  )
    call InitTrig_AcquireDiaryPlayer2(  )
    call InitTrig_AcquireDiaryPlayer3(  )
    call InitTrig_AcquireDiaryPlayer4(  )
    call InitTrig_CattleCareLvl1Player1(  )
    call InitTrig_CattleCareLvl1Player2(  )
    call InitTrig_CattleCareLvl1Player3(  )
    call InitTrig_CattleCareLvl1Player4(  )
    call InitTrig_PlantsShopBuyPlants(  )
    call InitTrig_PlantShopLibrary(  )
    call InitTrig_Feld_bestellen(  )
    call InitTrig_PlantsHarvest(  )
    call InitTrig_PlantsWeed(  )
    call InitTrig_PlantsFertilize(  )
    call InitTrig_WateringCanFill(  )
    call InitTrig_WateringCanWaterPlants(  )
    call InitTrig_WaterSpray(  )
    call InitTrig_lawnSprinkler_Systems(  )
    call InitTrig_Garden_Fence_Handling(  )
    call InitTrig_PlantFieldCrops(  )
    call InitTrig_PlantGardenPlants(  )
    call InitTrig_PlantTrees(  )
    call InitTrig_PlantFireWoodTrees(  )
    call InitTrig_PlantFlowers(  )
    call InitTrig_PlantMagicBeans(  )
    call InitTrig_plant_knowledge(  )
    call InitTrig_beanTest(  )
    call InitTrig_Plants_Library(  )
    call InitTrig_Fruit_Tree_Library(  )
    call InitTrig_fruit(  )
    call InitTrig_t(  )
    call InitTrig_Packhorse_Library(  )
    call InitTrig_StockShopBuyAnimals(  )
    call InitTrig_PlayerCattle_Library(  )
    call InitTrig_count(  )
    call InitTrig_cattle(  )
    call InitTrig_testa(  )
    call InitTrig_PlayerCareForCattle(  )
    call InitTrig_PlayerCattleBell(  )
    call InitTrig_SlaughterCattle(  )
    call InitTrig_MilkCow(  )
    call InitTrig_PlayerCheeseMaker_Library(  )
    call InitTrig_PlayerEviscerateAnimals(  )
    call InitTrig_DeadAnimalsPlayDecayAnim(  )
    call InitTrig_FishingSystems_Library(  )
    call InitTrig_Pet_System(  )
    call InitTrig_GameInfoSigns(  )
    call InitTrig_IndicateOpenWorldSign(  )
    call InitTrig_IndicateOpenWorldBoundaries(  )
    call InitTrig_LighthouseClimbDown(  )
    call InitTrig_LighthouseShowMapRects(  )
    call InitTrig_Selection_Easter_Eggs(  )
    call InitTrig_PlayerOpenLetterBox(  )
    call InitTrig_Zeppelin_Library(  )
    call InitTrig_Travels_Library(  )
    call InitTrig_trav(  )
    call InitTrig_Cooking(  )
    call InitTrig_TV(  )
    call InitTrig_PlayerWakeUp(  )
    call InitTrig_PlayerCallDozer(  )
    call InitTrig_PlayerLeaveDozer(  )
    call InitTrig_DozerHonk(  )
    call InitTrig_Gameplay_Interaction(  )
    call InitTrig_PlayerCollect(  )
    call InitTrig_NPCDialogMain_SetUp(  )
    call InitTrig_NPCDialogClicked_City(  )
    call InitTrig_NPCDialogClicked_Land(  )
    call InitTrig_Information_Dialogs(  )
    call InitTrig_NPC_String_List(  )
    call InitTrig_NPC_Init_List(  )
    call InitTrig_NPC_Life_Cycles(  )
    call InitTrig_NPC_Events(  )
    call InitTrig_Police_Library(  )
    call InitTrig_test_honor(  )
    call InitTrig_Event_Selection(  )
    call InitTrig_Quest_Furniture_Zombies(  )
    call InitTrig_test_zombie_quest(  )
    call InitTrig_Quest_Chicken_Race(  )
    call InitTrig_test_chicken_quest(  )
    call InitTrig_Quest_Partyquest_Farms(  )
    call InitTrig_test_pq(  )
endfunction


Be aware that the event is a BJ wrapper for the native unit enters region event. It works by filling a region cells using the given rect and using that region for the event.

The result is that the area which triggers the event is not the same as the rect provided because rects can represent areas that are not a whole number of cells and that there is possible a boundary logic error with the cell filling of regions from rects.

Thanks for the explanation, unforunately it was the same problem, when I used the native instead, that recognizes a region ... And the other "EntersRegion" Events work fine. I shall count the number of these events. But i think it is ~ 7 in total.

Edit: It does not help, if I use this instead:
JASS:
local region reg = CreateRegion()
        set tempTrigger = CreateTrigger()
        call RegionAddRect( reg, bj_mapInitialPlayableArea)
        call TriggerRegisterEnterRegion( tempTrigger, reg, null)

--------------------------------------
It looks like there is some infinite loop going on, as soon as I select a unit and order it to move. It gets displaced and stopped randomly and after that, wc3 does not close anymore and I have to use task manager to force it ...

can it be that these events somehow interfere with each other, if there is more than a certain amount? I mean even if there is no cap, as IcemanBo suggested.
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,657
Simple check, write "call BJDebugMsg("Finished Initialization!")" at the end of the "call InitTrig_Bla()" spam.
Then start the map.
If the message does not appear, you either have a "ClearTextMessages()" call somewhere after that, or you have a thread crash.
(The ClearTextMessages() call can be filtered by also creating a unit.
So, you do "call CreateUnit(Player(0), 'hfoo', 0, 0, 0)" as well.)
JASS:
    call InitTrig_test_zombie_quest(  )
    call InitTrig_Quest_Chicken_Race(  )
    call InitTrig_test_chicken_quest(  )
    call InitTrig_Quest_Partyquest_Farms(  )
    call InitTrig_test_pq(  )
    
    call BJDebugMsg("Finished Initialization!")
    call CreateUnit(Player(0), 'hfoo', 0, 0, 0)
endfunction
If the unit is not created, then come back here.
If it does get created, continue on the next part... simply filtering triggers.

I thought you had a shitload of "TriggerRegisterEnterRectSimple()" in one trigger for a system or something.

You could try disabling all triggers, one by one, until all of them are disabled, or until the problem disappears.
Then, when the problem disappears, you re-enable the triggers, one by one, and check each time if the problem comes back.
If the problem comes back, you disable the last enabled trigger again and move on to the next.
Then you upload all triggers that are disabled by this check in JASS/TRIGGER tags, depending on what is appropriate.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
@Wietlol
I honestly have no idea how to insert a debug message into the pre-compiled init script, but for example, the last system is initialized correctly, so it should be not that problem imo?

Also, I isolated the problem, as you suggested, already before I posted the thread.

First I isolated my pet system to be the source of this problem, but after I realized that the corresponding functions could not be the problem, I created a single trigger to test this.

This is the initial problem source (event: unit enters bj_init map area)

JASS:
private function GetEnteringPetHome takes nothing returns boolean
        local integer i = GetUnitTypeId( GetTriggerUnit())
        return false // (i == PET_ID_HOME_BEAR or i == PET_ID_HOME_CAT)
    endfunction
 
    private function PetHomeInitialize takes nothing returns nothing
        // upon pet home entering the map, init data
        local unit petHome     = GetTriggerUnit()
        local player p         = GetOwningPlayer( petHome)
        local integer playerId = GetPlayerId( p)
        call BJDebugMsg("!!!!PET!!!!!!! pet home init")
        set PET_UNITS[playerId+4] = petHome
        call HM_Select( p, udg_KAMERA_TARGET[playerId])
        call SetUnitOwner( petHome, Player(4), false)
        call DELAYED_UNIT_DESTRUCTION( CreateUnit( Player(4), 'e00B', GetUnitX( petHome), GetUnitY( petHome), GetRandomReal( 0., 360.)), 15.)
        call TriggerSleepAction( 16.00) // wait for the build being finished
        call SetUnitOwner( petHome, p, false)
        set udg_GAMEPLAY_STATUS[playerId+16] = true
     
        // Remove Leaks
        set petHome = null
        set p       = null
    endfunction

I disabled the event, and everything works fine, but if I keep the event and disable the actions (return false), the problem persists.


Then I did the following:
Disabled the event, tested the map -> problem dissappeared, all units behaved normally.
Created this new trigger -> problem appeared again!
  • //===========================================================================
  • function InitTrig_test takes nothing returns nothing
    • set gg_trg_test = CreateTrigger( )
    • call TriggerRegisterEnterRectSimple( gg_trg_test, GetPlayableMapRect() )
  • endfunction
If I disable any other "Enter bj initial map area" event somewhere else in the script, I can re-enable the above event, and everything works again. So it does not seem to be restricted to one single code block....?

That honestly makes no sense to me at all, so thats why I created this thread ...

It seems to create an endless loop or something, as wc3 cannot be closed normally after the dislocation of the units begins. I have to force it by task manager.

Also, selected units seem to be ordered to stop randomly every ~0.1 seconds.

@
Dr Super Good:
Thanks! ... I still have no clue at all where I messed something up ... :( It seems like something in my script is interfering, but I dont know what. The displaced units have nothing in common, only that I select and order them somewhere. I checked all triggers, that set unit positions or could be activated by ordering units, but they are all secured by conditions ...

@
AGD: I guess, I did not, because I dont know what that is :)
 
Last edited:
I asked for map size for a reason, because such a big maps may have problems with comparing reals: if you for example checking 2 reals 10.00==10.02 it may return diffrent results (true or false) on big maps. On up to 224 map sizes it will be always 'false'. Solutions is to use Rabs(x1-x2)<=0.02 for example

units get displaced randomly and stopp moving randomly, if I select them and order them to move somewhere.

However I think you should focus on checking triggers with events "unit is issued an order" cause somewhere in those trigger you have a loop

You may overwite globals cause you use 'Waits' which may cause bad results

CreateUnit( Player(4), 'e00B', GetUnitX( petHome)Also check if actions when you create units inside trigger-actions with event 'unit enters playable map area' is save
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
Thanks, but I doubt, that this problem is caused by me, because as I said:

I can reproduce the weird behaviour by simply adding an empty trigger, only with the event!


So, maybe it is something with the map's size ... I can avoid the problem by not using any of these events anymore, but I was simply interested, how I can cause such a problem ...

It indeed looks like some kind of dependency loop or whatever, but it does not seem to be caused by any actions of mine .... (?)

I mean, how could any Orders or whatever functions from completely different code be triggered by this event? It must be something in the source code, that I accidently triggered, Isnt it?
 
Level 11
Joined
Dec 19, 2012
Messages
411
I'm not really sure what is happening to your map, but anywhere, I'm just here to provide some additional suggestions for checking :

1. Delete all actions of the trigger related to TriggerRegisterEnterRectSimple and see if the problem persist
2. Delete/Disable all events other then TriggerRegisterEnterRectSimple and see if the problem persist
3. Count the number of TriggerRegisterEnterRectSimple and try to reproduce it in a new blank map and see if the problem persist.

That's all i can think of, I couldn't provide a detailed solution as I personally never meet such weird behavior before.
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
THanks for your suggestions.

I already tried 1. and 2. Answers: 1. yes. 2. yes (kind of, I did not delete all events but all I found after a quick search.) 3. counted 7.

I tried to reproduce the problem in an empty map, it is nowhere near this "limit" of my map. Around 250 "enter whole map" events and the map crashes eventually, but not always, when I simply create 1 footman in the middle of the map.

It seem like these "enter whole map" events may be merged somehow after being compiled or what...

Well, at this point I would like to thank all of you that suggested things here! :)
 
Status
Not open for further replies.
Top