wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 05-20-2009, 07:12 PM   #46
Tyrande_ma3x
User
 
Tyrande_ma3x's Avatar
 
Join Date: Feb 2009
Posts: 185

Submissions (1)

Tyrande_ma3x is on a distinguished road (12)

Default

> But it needs heavy duty public testing to make sure no one finds a way to break it.
Since I really like this system and wanted to use it from the beginning, I'll continue testing different situations and see if it's really stable. Eh, not that I'm testing it as running some test in mind - I just do stuff on my map and bugs suddenly come out. :P Will report you as usual if I find something wrong.
Tyrande_ma3x is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 05-20-2009, 09:35 PM   #47
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

An other thing, for many reasons i plan to recycle all my units.
So creating/destroying trigger periodically is useless for me.

Could you plz make a constant boolean to control that, with a warning of the potential leak ?

Also i didn't made serious test about this sort of leaks, but my few ones tends to show that some events can leak and some others not.
And when an event can leak if you add only ONE to a trigger, it won't leak when you destroy the trigger .
So if i'm not wrong, the dynamic trigger is useless anyway, unless there is an other good effect.
Troll-Brain is offline   Reply With Quote
Old 05-21-2009, 04:58 AM   #48
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Forget it, I hate this dynamic trigger stuff and relying on this strange method that might break at any time. I found a way to fix the ReviveHero bug without using triggers at all. So next version: no triggers, but RemoveUnitEx will come back. Nothing will break it unless you forget to replace RemoveUnit with RemoveUnitEx. Then it will stay that way until Vex implements //! define and I can force all RemoveUnits in a map to become RemoveUnitEx automatically.
grim001 is offline   Reply With Quote
Old 05-21-2009, 12:41 PM   #49
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
Then it will stay that way until Vex implements //! define and I can force all RemoveUnits in a map to become RemoveUnitEx automatically.
I don't really think that would be so easy even with //! define. In fact, it might need a different construct. It would need to be a magical thing that changes even calls on libraries not requiring auto index to that.

You could ... like have a periodic timer that detects removal... I think that even in maps with tons of units the delay between the removal and the dection wouldn't be much bigger than 30 seconds without hitting performance.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-21-2009, 01:46 PM   #50
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

It would have to scan the text of the entire map script and replace all instances of x with y. For example...

Collapse JASS:
//! define " RemoveUnit(" " RemoveUnitEx("

It would be pretty limited and could definitely be abused, however it would work for this particular problem.

For now, instead of a cleanup timer, after each undefend order I will run a 0 second timer and check if the unit's typeID became 0. If it did, then yell at the user for not using RemoveUnitEx.

Yes, I feel good about the new version now.

Last edited by grim001 : 05-21-2009 at 02:24 PM.
grim001 is offline   Reply With Quote
Old 05-21-2009, 02:31 PM   #51
rain9441
User
 
Join Date: Jan 2007
Posts: 195

rain9441 will become famous soon enough (61)rain9441 will become famous soon enough (61)rain9441 will become famous soon enough (61)

Default

Quote:
Originally Posted by Vexorian
You could ... like have a periodic timer that detects removal... I think that even in maps with tons of units the delay between the removal and the dection wouldn't be much bigger than 30 seconds without hitting performance.

As long as you don't have events that fire on removal of a unit, this works great IMO. I have a simple garbage collector that runs through MAX(12,total*0.02) of all the "unit indexes" every couple of seconds and cleans up everything real nicely.

And to keep it consistent, i made a removal function that removes the unit and tosses the unit index into a "trash can" which is then recycled some time (probably 0.0 seconds) after.

The downside is you can't inline GetUnitIndex to be "GetUnitUserData" and end it there, you always have to check if GetUnitTypeId returns 0. Which is good practice anyway...
__________________
My latest project -- Still in development: Experience TD
rain9441 is offline   Reply With Quote
Old 05-21-2009, 03:19 PM   #52
Alevice
It feels good
 
Alevice's Avatar
 
Join Date: Mar 2006
Posts: 1,305

Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)Alevice is a jewel in the rough (190)

Default

gah lack of ternary operator for the lose.
__________________
_-|-_

Alevice.jones is SC2 Beta, losers.

Check out my never updated deviantart gallery!!

Kalimdor Raiders (Race Contest #1) Pastebin Page
Cavern Crawlers (Race Contest #2) Pastebin Page
Airship Race Motherfuckers!
Quote:
Originally Posted by http://ajaxian.com/archives/would-you-like-a-_-with-that-new-library-gives-js-what-it-should-have#comment-276203
- Dont solve problems that dont exist.
- Improve the wheel, dont reinvent it.
- Port the wheel if it doesnt exist in your environment.
- Integrate the wheel into your project.
- Make sure you can replace your wooden wheel for a rubber one if someone else invents it.
Alevice is offline   Reply With Quote
Old 05-21-2009, 03:35 PM   #53
Vexorian
Free Software Terrorist
 
Vexorian's Avatar


Technical Director
 
Join Date: Apr 2003
Posts: 14,898

Submissions (37)

Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)Vexorian has a reputation beyond repute (1062)

Hero Contest #3 - 2nd Place

Default

Quote:
[10:23] <grim001> why would //! define " RemoveUnit(" " RemoveUnitEx(" not work properly?
[10:25] <Vexorian> grim001, if you compile that so that RemoveUnit is only replaced bellow the define, then it will not hook RemoveUnit calls declared above the library.
[10:25] <grim001> yeah, //! define could work on the entire map script. But then you couldn't make it private.
[10:25] <grim001> But textmacros have the same issue.
[10:25] <Vexorian> If //! define worked on the whole script, you couldn't ever call RemoveUnit
[10:26] <Vexorian> chicken and egg.
[10:26] <grim001> Hmm... I would need one exception to that
[10:27] <grim001> so I would actually want it to be for everything but the library.
[10:27] <grim001> which is kind of crazy.
[10:27] <Vexorian> and not a define.
__________________
Zoom (requires log in)Wc3 map optimizer 5.0
Someone should fix .wav sound in this thing.
Zoom (requires log in)JassHelper 0.A.2.A
Turns your simple code into something that is complicated enough to work.
Faster != more useful
Vexorian is offline   Reply With Quote
Old 05-21-2009, 03:35 PM   #54
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Quote:
Originally Posted by rain9441
As long as you don't have events that fire on removal of a unit, this works great IMO.
Part of the idea behind this system is avoiding the cleanup timer, I really don't want to add one just in case someone accidentally used RemoveUnit when the documentation tells them not to.

It looks like vex will add a way to intercept natives soon, that will be great, then there will be no compromises at all with this system.
grim001 is offline   Reply With Quote
Old 05-21-2009, 08:34 PM   #55
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

Quote:
[10:23] <grim001> why would //! define " RemoveUnit(" " RemoveUnitEx(" not work properly?
[10:25] <Vexorian> grim001, if you compile that so that RemoveUnit is only replaced bellow the define, then it will not hook RemoveUnit calls declared above the library.
[10:25] <grim001> yeah, //! define could work on the entire map script. But then you couldn't make it private.
[10:25] <grim001> But textmacros have the same issue.
[10:25] <Vexorian> If //! define worked on the whole script, you couldn't ever call RemoveUnit
[10:26] <Vexorian> chicken and egg.
[10:26] <grim001> Hmm... I would need one exception to that
[10:27] <grim001> so I would actually want it to be for everything but the library.
[10:27] <grim001> which is kind of crazy.
[10:27] <Vexorian> and not a define.
What about this:?
Collapse JASS:
//! define "RemoveUnit(" "RemoveUnitEx("

...

//! novjass
call RemoveUnit( u )
//! endnovjass
Bobo_The_Kodo is offline   Reply With Quote
Old 05-21-2009, 09:17 PM   #56
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Good solution, too bad it won't be needed anymore with native hooking.
grim001 is offline   Reply With Quote
Old 05-23-2009, 03:33 PM   #57
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

Could you please add something like this?

Collapse JASS:
module AutoIndex
    static thistype array Data
    
    method operator[] takes unit u returns integer
        return Data[GetUnitIndex(u)]
    endmethod
    
    method operator[]= takes unit u, thistype toAdd returns nothing
        set Data[GetUnitIndex(u)] = toAdd
    endmethod
endmodule

and this:

Collapse JASS:
function GetUnitId takes unit u returns integer
    debug local integer UserData = GetUnitUserData(u)
    debug if UserData == 0 then
    debug    call BJDebugMsg("AutoIndex: Called OnEnter/OnLeave function not properly")
    debug endif
    debug return UserData
    return GetUnitUserData(u)
endfunction

Last edited by Mr.Malte : 05-23-2009 at 03:39 PM.
Mr.Malte is offline   Reply With Quote
Old 05-23-2009, 03:56 PM   #58
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

Yeah I was planning on both for the next version.
grim001 is offline   Reply With Quote
Old 05-24-2009, 06:44 PM   #59
Mr.Malte
User
 
Mr.Malte's Avatar
 
Join Date: Apr 2008
Posts: 286

Submissions (2)

Mr.Malte is on a distinguished road (11)

Default

Great.
And may I try to submit something like this, or can you use it?
Collapse JASS:
// This library is a doctor for AutoIndex. If AutoIndex doesn't work propely,
// this doctor will find the reason and fix it.
library AutoIndexDoctor initializer Init requires AutoIndex
    globals
        // If this is true, the system itself can't be broken by wrong indexes.
        // Actually this is senseless, if this is false.
        private constant boolean SAFETY = true
        // If the UserData of a units were changed, the change will be made retrogressive.
        private constant boolean HEAL_SICK_INDEXES = true
        // If this is true, it colors units with wrong indexes red and pings their position.
        private constant boolean DISPLAY_SICK_UNITS = false
        // If this is true, the doctor will tell you, whats going on, for example whether he found wrong indexes.
        private constant boolean DISPLAY_TEXT = true
        // The Indexes are checked every CHECK_FREQUENCY_NO_SPREAD seconds if they're correct. 
        // If this is 0, this won't be done periodically.
        private constant real CHECK_FREQUENCY_NO_SPREAD = 150.
        // If there are many wrong Indexes, the frequency of checks is increased to this value.
        private constant real CHECK_FREQUENCY_SMALL_SPREAD = 60.
        // If there are really a lot wrong Indexes, the frequency is increase to this value.
        private constant real CHECK_FREQUENCY_BIG_SPREAD = 8.
    endglobals
    
    globals
        private integer UnitCount = 0
        private integer array InitIndexes
        private unit array IndexedUnits
        
        private integer Cured = 0
        
        private integer array DiagnosePosition
        private boolean array Sick
    endglobals
    
    function DiagnoseDisease takes nothing returns nothing
        local integer i = 0
        loop
            exitwhen i > UnitCount
            if InitIndexes[i] != GetUnitId(IndexedUnits[i]) then
                if DISPLAY_TEXT then
                    call DisplayTextToPlayer(GetLocalPlayer(),0,0,"AutoIndex Doctor found ill UnitUserData.")
                endif
                
                if HEAL_SICK_INDEXES then
                    call SetUnitUserData(IndexedUnits[i],InitIndexes[i])
                    
                    if Cured < 40 and DISPLAY_TEXT then
                        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"AutoIndex Doctor's medicin could cure the index.")
                   endif
                   
                    set Cured = Cured + 1
                    
                    if Cured > 10 and Cured < 12 then
                        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"AutoIndex Doctor gives alarm: A virus seems to spread. He'll do testst automatically now.")
                        call PauseTimer(GetExpiredTimer())
                        call DestroyTimer(GetExpiredTimer())
                        call TimerStart(CreateTimer(),CHECK_FREQUENCY_SMALL_SPREAD,true,function DiagnoseDisease)
                    endif
                    
                    if Cured > 50 and Cured < 52 then
                        call DisplayTextToPlayer(GetLocalPlayer(),0,0,"The virus is getting dangerous. More test will be done.")
                        call PauseTimer(GetExpiredTimer())
                        call DestroyTimer(GetExpiredTimer())
                        call TimerStart(CreateTimer(),CHECK_FREQUENCY_BIG_SPREAD,true,function DiagnoseDisease)
                    endif
                else
                    set InitIndexes[i] = InitIndexes[UnitCount]
                    set IndexedUnits[i] = IndexedUnits[UnitCount]
                    set UnitCount = UnitCount - 1
                endif
            endif
            
            if DISPLAY_SICK_UNITS then
                call PingMinimap(GetUnitX(IndexedUnits[i]),GetUnitY(IndexedUnits[i]),3.)
                call SetUnitVertexColor(IndexedUnits[i],100,0,0,500)
            endif
            set i = i + 1
        endloop
    endfunction
    
    private function RegisterData takes unit u returns nothing
        set InitIndexes[UnitCount] = GetUnitId(u)
        set IndexedUnits[UnitCount] = u
        set DiagnosePosition[InitIndexes[UnitCount]] = UnitCount
        set UnitCount = UnitCount + 1
    endfunction
    
    private function UnregisterData takes unit u returns nothing
        local integer position
        if SAFETY then
            call DiagnoseDisease()
        endif
        set position = DiagnosePosition[GetUnitId(u)]
        set InitIndexes[position] = InitIndexes[UnitCount]
        set IndexedUnits[position] = IndexedUnits[UnitCount]
        set UnitCount = UnitCount - 1
    endfunction

private function Init takes nothing returns nothing 
    call RegisterUnitIndexed(RegisterData)
    call RegisterUnitDeindexed(UnregisterData)
    
    if CHECK_FREQUENCY_NO_SPREAD != 0. then
        call TimerStart(CreateTimer(),CHECK_FREQUENCY_NO_SPREAD,true,function DiagnoseDisease)
    endif
endfunction

endlibrary

Well, actually it could be made a bit better, but I like it like that. It is a doctor that prehends getting Indexes corrupt.

Last edited by Mr.Malte : 05-24-2009 at 06:44 PM.
Mr.Malte is offline   Reply With Quote
Old 05-24-2009, 10:35 PM   #60
grim001
requires vJass
 
grim001's Avatar


Code Moderator
 
Join Date: Nov 2006
Posts: 1,540

Submissions (10)

grim001 is just really nice (277)grim001 is just really nice (277)

Send a message via AIM to grim001
Default

You sure make some weird stuff...

Anyway, there will be a better way to do this soon using native hooks. I can intercept if anyone outside of AutoIndex tries to use SetUnitUserData on a unit that AutoIndex has indexed.
grim001 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 07:02 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services