1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Music Contest #8 - Hive Soundtrack is up! Create the soundtrack for the upcoming videos of Hive Workshop's YouTube Channel.
    Dismiss Notice
  3. Check out the entries of the latest Mini-Mapping Contest: Stealth! Cast your vote for here!
    Dismiss Notice

[System] Mode Manager

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

  1. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,143
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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,143
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    Ok then.
     
    Last edited: Jun 29, 2011
  5. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    Update: Fixed a small bug :)
     
  7. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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,470
    Resources:
    13
    Maps:
    3
    Spells:
    10
    Resources:
    13
    struct title[]

    sized structs are struct[size] title
     
  9. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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,470
    Resources:
    13
    Maps:
    3
    Spells:
    10
    Resources:
    13
    How did that happen to both scripts?
     
  11. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    I forgot to initialize integers ic (instance count) and ir (instance recycler) :p
     
  12. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    7,470
    Resources:
    13
    Maps:
    3
    Spells:
    10
    Resources:
    13
    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,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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
    Resources:
    7
    Maps:
    2
    Spells:
    5
    Resources:
    7
    thanks this should be working
     
  15. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    It better ;)
    I'm already using it in an AoS =D
     
  16. jim7777

    jim7777

    Joined:
    May 27, 2009
    Messages:
    481
    Resources:
    7
    Maps:
    2
    Spells:
    5
    Resources:
    7
    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,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    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
    Resources:
    7
    Maps:
    2
    Spells:
    5
    Resources:
    7
    ohh but also without the enabled/authorize thing, it doesn't work for me D:
     
  19. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,017
    Resources:
    9
    Maps:
    1
    Spells:
    8
    Resources:
    9
    The authorize thing is needed...
     
  20. jim7777

    jim7777

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

    this is really awesome