1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dismiss Notice
  3. After a long wait, the results for Terraining Contest #18 are finally out! Drop by and congratulate the winners!
    Dismiss Notice
  4. The poll for Concept Art Contest #9 is up! Cast your vote for your favourite entry!
    Dismiss Notice
  5. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  6. Our first StarCraft contest, The Galaxy Terraining Contest #1 - World Wonders has started. Enter to show off your Galaxy Editor skills and win a custom rank icon among other things.
    Dismiss Notice
  7. Ever wanted to get your sets ready for fast texturing while still having fun? Now it is possible with our newest Mini-Texturing Contest.
    The Skeleton Units need your dire help!
    Dismiss Notice
  8. The poll for Techtree Contest #11 is up! Cast your vote for your favorite entry.
    Dismiss Notice
  9. Take part in a Futuristic musical experience with our very own Music Contest. The 5th edition has finally arrived after a long time.
    Dismiss Notice
  10. Dismiss Notice

[System] Mode Manager

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

  1. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,106
    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,022
    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,106
    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,022
    Ok then.
     
    Last edited: Jun 29, 2011
  5. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    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,022
    Update: Fixed a small bug :)
     
  7. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    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

    Code Moderator

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

    sized structs are struct[size] title
     
  9. Magtheridon96

    Magtheridon96
    Joined:
    Dec 12, 2008
    Messages:
    6,022
    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

    Code Moderator

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

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

    Bribe

    Code Moderator

    Joined:
    Sep 26, 2009
    Messages:
    7,339
    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,022
    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,022
    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,022
    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,022
    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