1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Choose a model and craft your spell in Zephyr Contest #15!
    Dismiss Notice
  3. Compete in Concept Art Contest - Bounty Hunter . May the best artist's bounty hunter execute!
    Dismiss Notice
  4. The Modeling Mini-Contest #5 - Familiar is up! Compete to design a pet companion to a lonely WC3 Hero of your preference.
    Dismiss Notice
  5. The 6th installment of our Music Contest just got fired up! Now with an Apocalyptic taste. Get started and compete in this musical battle!
    Dismiss Notice
  6. Looking to expand an altered melee race of yours? Join the Advanced Techtree Contest - Recycle, Revise, Reinvent contest!
    Dismiss Notice

[System] Mode Manager

Discussion in 'JASS Resources' started by Magtheridon96, Jun 24, 2011.

  1. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,141
    Why is the run thingie public??


    Also, I already mentioned that this is slower than a hashtable- boolean auth[12];
     
  2. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    Because then it won't compile? (See how mean I am when I ask rhetorical questions? :ogre_datass: =P)

    Yeah, I'll fix that..
     
  3. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,141
    Anything that shouldn't be accessed outside of the library should be private and shouldn't be documented in the header >.>
     
  4. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    Ok then.
     
    Last edited: Jun 29, 2011
  5. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    Updated to Mode Manager 3.0.0.0!

    Changelog:
    - New API (Making it a requirement to go to 3.0.0.0)
    - Fixed a huge bug
    - Added debug messages everywhere :p
    - Fixed Mode/Command collisions.


    There are still some potential bugs that allow a player to ruin a game, but that can be easily fixed (via the 'flag' boolean).
    For example, a player could ruin the game if he enters a mode string like -apar (All Pick and All Random).
    If you want to fix that, this is how:

    Your functions should look like this:

    Code (vJASS):
    function Ap takes nothing returns boolean
        if not AR.flag then
            set AP.flag = true
            // your code here
        endif
        return false
    endfunction

    function Ar takes nothing returns boolean
        if not AP.flag then
            set AR.flag = true
            // your code here
        endif
        return false
    endfunction


    I told you the 'flag' is useful ;)

    edit
    Updated to 3.0.1.0
    - You may now completely lock players to render them unable to use any commands/modes.
     
    Last edited: Jun 30, 2011
  6. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    Update: Fixed a small bug :)
     
  7. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    Update:

    Huge optimization.

    Bribe, could you change the title to "[System] ModeManager" cause I rewrote the system in vJASS because I was too lazy to lookup how to make a struct extend an array in Zinc =P
     
  8. Bribe

    Bribe
    Joined:
    Sep 26, 2009
    Messages:
    7,358
    struct title[]

    sized structs are struct[size] title
     
  9. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    I'll keep that in mind next time I upload a Zinc resource xD
    Thanks :)

    edit
    Not so silent update:
    - Fixed a huge bug that didn't allow the system to function at all :p
     
  10. Bribe

    Bribe
    Joined:
    Sep 26, 2009
    Messages:
    7,358
    How did that happen to both scripts?
     
  11. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    I forgot to initialize integers ic (instance count) and ir (instance recycler) :p
     
  12. Bribe

    Bribe
    Joined:
    Sep 26, 2009
    Messages:
    7,358
    The names are a bit generic. "Mode" would be better as "GameMode",
    if you think about it "Mode" could mean anything.
     
  13. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    You're probably right :)
    Since I'd have to change the API (even though it's only one word), I'm going to have to update to 5.0.0.0 :p (Way too fast xD)

    edit
    Updated! :D
    I also updated the demo code to show you how you could stop players from f***ing up the game with 2 modes that shouldnt go together xD
     
  14. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    thanks this should be working
     
  15. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    It better ;)
    I'm already using it in an AoS =D
     
  16. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    i can't let it work :/ doesn't init anyways

    here's my init code
    Code (vJASS):

        private function ND takes nothing returns boolean
            set udg_EnablePvP_On = false
            set PvP_ModeAllowed = false
            call BJDebugMsg("Init ND")
            return false
        endfunction
        private function Init takes nothing returns nothing
            set nd = GameMode.create("nd",true, Condition(function ND))
            call nd.authorize(GetPlayerId(PLAYERS_HOST))
            set nd.enabled = true
        endfunction
     
     
  17. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    You shouldn't touch the boolean enabled unless you want to disable the system.
    Plus, it's static. Using it would disable/enable the entire system.
     
  18. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    ohh but also without the enabled/authorize thing, it doesn't work for me D:
     
  19. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,019
    The authorize thing is needed...
     
  20. jim7777

    jim7777
    Joined:
    May 27, 2009
    Messages:
    481
    ohh even though i used it
    since players_host is player 1(blue)
    still nothing happens.. D: dunno whyyyy

    this is really awesome