1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Solved] (Player group((Player(TriggeringPlayer)))) Solved: It leaks

Discussion in 'Triggers & Scripts' started by Veronnis, Jul 25, 2019.

  1. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    150
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    • Inventory Slot Tooltip
      • Events
      • Conditions
      • Actions
        • For each (Integer GenericLoopCount) from 1 to MaxAllSlotTypes, do (Actions)
          • Loop - Actions
            • Set SlotOfPlayer = ((TriggeringPlayer x MaxAllSlotTypes) + GenericLoopCount)
            • Set RandomLocation[1] = (Mouse Position for Triggered Mouse Event)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (BackpackRegion[GenericLoopCount] contains RandomLocation[1]) Equal to True
              • Then - Actions
                • Custom script: call RemoveLocation(udg_RandomLocation[1])
                • Special Effect - Play Special Effect: xxxTheTestEffect, Animation: Stand
                • Set RandomLocation[1] = (Center of BackpackRegion[GenericLoopCount])
                • Special Effect - Set Position of xxxTheTestEffect to x: (X of RandomLocation[1]), y: (Y of RandomLocation[1]), z: 11.00
                • Custom script: call RemoveLocation(udg_RandomLocation[1])
                • If (LocalPlayerN Equal to TriggeringPlayer) then do (Floating Text - Change text of TooltipText to (InvItemName[SlotOfPlayer] + (|n + InvObjDescriptor[SlotOfPlayer])) using font size 7.00) else do (Do nothing)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Hero[TriggeringPlayer] has buff Merchant Buff ) Equal to True
                    • InvItemValue[SlotOfPlayer] Not equal to 0
                  • Then - Actions
                    • -------- THIS AREA STILL NEEDS LOCAL PLAYER --------
                    • Floating Text - Change text of TooltipValue to ((|c00E1E100 + (String((Integer(((Real((Max(InvItemValue[SlotOfPlayer], (InvItemValue[SlotOfPlayer] x InvItemQuantity[SlotOfPlayer]))))) x PlayerSellRatio[TriggeringPlayer])))))) + g|r) using font size 7.00
                  • Else - Actions
                    • Floating Text - Change text of TooltipValue to using font size 7.00
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • InvItemQuantity[SlotOfPlayer] Less than or equal to 0
                  • Then - Actions
                    • If (LocalPlayerN Equal to TriggeringPlayer) then do (Floating Text - Change text of TooltipText to (InvItemName[SlotOfPlayer] + (|n + InvObjDescriptor[SlotOfPlayer])) using font size 7.00) else do (Do nothing)
                  • Else - Actions
                    • If (LocalPlayerN Equal to TriggeringPlayer) then do (Floating Text - Change text of TooltipText to (InvItemName[SlotOfPlayer] + (( ( + ((String(InvItemQuantity[SlotOfPlayer])) + )|n)) + InvObjDescriptor[SlotOfPlayer])) using font size 7.00) else do (Do nothing)
                • Floating Text - Show TooltipText for (Player group((Player(TriggeringPlayer))))
                • Floating Text - Show TooltipValue for (Player group((Player(TriggeringPlayer))))
                • Set GenericLoopCount = MaxAllSlotTypes
              • Else - Actions
                • Custom script: call RemoveLocation(udg_RandomLocation[1])
                • Special Effect - Play Special Effect: xxxTheTestEffect, Animation: Death
                • Floating Text - Hide TooltipText for (Player group((Player(TriggeringPlayer))))
                • Floating Text - Hide TooltipValue for (Player group((Player(TriggeringPlayer))))


    So this is obviously kind of a chunky trigger. But if someone could please help me understand where it leaks I would love you. This trigger, while not on very frequently will run for every mouse movement of the player. It is imperative this one is leak free.
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,596
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I do not see any leaks other than possibly some unique strings which could be considered a leak when using JASS2.
     
  3. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,085
    Resources:
    0
    Resources:
    0
    Doesn't (Player group((Player(TriggeringPlayer)))) create a new force everytime?
     
  4. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    3,065
    Resources:
    1
    Spells:
    1
    Resources:
    1
  5. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,596
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Ops... I did not notice that. Stupid unreadable GUI...

    Solution is to cache the player groups in a player group array. One can then use the player slot index as an index in the array to get the player group. This recycles the same player groups and hence no leak.
     
  6. Veronnis

    Veronnis

    Joined:
    Jul 19, 2010
    Messages:
    150
    Resources:
    6
    Models:
    2
    Icons:
    1
    Maps:
    3
    Resources:
    6
    Ahhh! Thank you, I never would have guessed that! It runs soo much smoother now.