1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Hiding any button!!! New method, please help me test it!!!

Discussion in 'The Lab' started by leandrotp, Jun 10, 2015.

  1. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1

    This method crashes on Macs. Until I solve it, you should use [thread=261633]this[/thread] instead







    Hello Guys!

    Please forgive me for the title in caps, but I REALLY think this deserves some attention.

    I JUST FOUND A NEW METHOD TO HIDE ANY BUTTON FROM THE COMMAND CARD!!!

    That means ANY button, even the ones that we know to be "impossible" to remove.

    MOVE, PATROL, STOP, ATTACK, HERO ABILITIES, BUILD, RALLY, EVEN THE CANCEL BUTTON CAN BE HIDDEN!

    Any other ability can be hidden as well. No more need for disabled spellbooks!

    The Concept

    I got the original idea from this thread: http://www.hiveworkshop.com/forums/lab-715/removing-standart-command-buttons-commandfunc-txt-261559/
    Credits go to ALEXz407 for his initial discovery. In his experiments he has found a way to hide anything from command card, by setting the Buttonpos to a big integer.

    However, he reported that he was getting crashes randomly, and that this method was unsafe. Also, because it needed big integers, you couldn't use it inside World Editor because it does not allow you to input such integers.

    So, I decided to track down the cause of the crashes in a debugger, and see if I could make that method more stable.

    The crashes are caused because the values you put in Buttonpos are used directly in pointer arithmetic, with no safety checks. If you set it to a big integer, it will point to a random location in memory, which sometimes gives the desired effect, but may cause crashes as well.

    Then I started to mess with the values to see if I could make it point to a stable location, and it seems that I got it!

    How to hide ANY button from Command Card

    You just need to set its position to 0,-11
    (Only this specific value will work, that's what makes it point to a safe location in memory, anything else may cause crashes.)

    Code (Text):
    [CmdMove]
    Art=CommandMove
    Buttonpos=0,-11
    That will hide the Move button. You can also do it with any other ability in the World Editor, just set the X position to 0 and Y to -11. (You need to use Shift+Enter to input these values)

    I have tested it many times and it never caused problems. The value -11 causes the game to reference a location in the begginning of a memory region, which seems to be safe.

    I have attached a small test map. It's just the Bandit Ridge map with a modified CommandFunc.txt. All standard buttons of the UI (Move, Stop, Patrol, Hold Position and Attack) will be hidden. Cancel button is hidden as well, just for demonstration purposes,

    Please help me test it, just to make sure it's safe.
     

    Attached Files:

    Last edited: Jun 18, 2015
  2. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,114
    Resources:
    0
    Resources:
    0
    I just tested it and tried to add a hidden endurance aura to a unit without spellbook and it seems to be working, maybe rip disabled spellbooks, nice find.
     
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,549
    Resources:
    23
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    5
    JASS:
    3
    Resources:
    23
    Really interesting. It's nice. ^_°
     
  4. Ezekiel12

    Ezekiel12

    Joined:
    Mar 13, 2012
    Messages:
    1,061
    Resources:
    0
    Resources:
    0
    Cool stuff indeed. Now the only thing even better would be to be able to dynamically show/hide buttons.
     
  5. Chaosium

    Chaosium

    Joined:
    Aug 29, 2012
    Messages:
    417
    Resources:
    2
    Models:
    2
    Resources:
    2
    Wow, this is a fantastic find!
     
  6. Eagle XI

    Eagle XI

    Joined:
    Mar 9, 2012
    Messages:
    1,359
    Resources:
    117
    Models:
    2
    Icons:
    109
    Packs:
    4
    Skins:
    2
    Resources:
    117
    You mean i can have 12. building in the build card inplace of goddamn cancel ?
     
  7. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Hmm, I didn't test this possibility, but probably it will work. I will experiment with this when I get home.

    EDIT: Confirmed that it works
    [​IMG]
     

    Attached Files:

    Last edited: Jun 11, 2015
  8. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    7,014
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Nice find, though the number of practical applications outside of the "big five" (move, attack, patrol, stop, hold) is limited since you can not show/hide them dynamically.
     
  9. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Well, it can actually be achieved, depending on what you want to do. Abilities can be hidden in a per-unit basis by using this: http://www.hiveworkshop.com/forums/...78/disable-ability-specific-hero-unit-225879/

    And if you want to hide/unhide the "big five" dynamically, there's also a way to do it: just hide them in CommandFunc.txt, and make 5 dummy abilities based on channel to replace them. Change the order ids of those abilities to move, stop, holdposition, patrol and attack, and change icons accordingly. Then if you want to hide any of them, just remove the dummy ability.
     
  10. Eagle XI

    Eagle XI

    Joined:
    Mar 9, 2012
    Messages:
    1,359
    Resources:
    117
    Models:
    2
    Icons:
    109
    Packs:
    4
    Skins:
    2
    Resources:
    117
    Aww, yeah. Now can add the shipyard without removing buildable shops.
     
  11. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    7,014
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    The problem with that is that this will never correctly mimic the visual behaviour of said buttons.
    For example, when a unit is standing still, the "stop" button has a green frame. Hold position will be framed when this action is used aswell. And patrol will get a frame while the unit is patrolling.

    However, I do see a cool use for this: as you can hide the cancel button aswell, you can use this to unlock a 12th spell slot in spellbooks.
     
  12. ALEXz407

    ALEXz407

    Joined:
    Aug 23, 2014
    Messages:
    206
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Congratulations

    You made a brilliant from the raw idea, nice research!

    Well, button stacking tutorial can be reduced to a single row now :)

    Don't forget about usability. With hidden cancel you can not cancel things with ESC button aswell.
    However, looks like Blizzard made different ways for cancelling things, so it will not ruin gameplay things like cancelling training/building/upgrading/casting/etc.
     
  13. msongyboi

    msongyboi

    Joined:
    Feb 3, 2013
    Messages:
    271
    Resources:
    4
    Spells:
    4
    Resources:
    4
    I just tried twice on my mac, crashes when I try to select builder units.
     
  14. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Hmm... That was exactly what I was afraid of. Thanks for reporting, I really wanted someone to test it in a mac, as the memory layout is different there. Does it happen only when you select a peasant, or with any unit? Try to select your town hall as soon as the game starts and tell me what happens.

    Also, could you please send me a copy of the game.bin and storm.bin libraries from the War3 folder? I'd like to analyze them and fix this problem.
     
  15. TKF

    TKF

    Joined:
    Nov 29, 2006
    Messages:
    1,237
    Resources:
    5
    Maps:
    5
    Resources:
    5
    This is interesting, but if it makes mac players unable to play with lacking compatibility with setting the icons in a "unused" slot which apparently doesn't work for mac version I feel less tempted to use this. Perhaps there is a solution for that.
     
  16. msongyboi

    msongyboi

    Joined:
    Feb 3, 2013
    Messages:
    271
    Resources:
    4
    Spells:
    4
    Resources:
    4
    I will test it later, but uh.. I just realized that the buttons aren't functional if you hide them via this method - that's really limiting.. lol
     
  17. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    7,014
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Yeah it was the same thing with the old method.

    Hotkeys don't work anymore. So hiding the attack button basicly removes the possibility to A-move.

    Hiding 'move' or 'patrol' probably won't hurt anyone, though.

    Btw, does the old method (setting icon position to insanely high numbers) also crash for macs or is that limited to the negative number approach?
     
  18. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    No, the old method is 100% safe. I have examined the code and there is no possible way to crash with a big negative (NOT positive) number. Unless the code from mac version is somehow different from the windows version.

    Anyway, I'm downloading the mac version of warcraft right now. I'll try to debug it in a VM and find a way to make it work there.
     
  19. WaterKnight

    WaterKnight

    Joined:
    Aug 18, 2009
    Messages:
    4,035
    Resources:
    5
    Maps:
    1
    Tutorials:
    4
    Resources:
    5
    Mac may be big endian.

    What happens when you stack a lot of abilities on that invalid slot? Maybe if you have enough they get pushed back into the actual command card or in dangerous areas.
     
  20. leandrotp

    leandrotp

    Joined:
    Jul 30, 2012
    Messages:
    153
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    PowerPC Mac is big endian. Intel Mac is not.

    But this doesn't make a difference. And the buttons don't really get "pushed" at all. See here for a detailed description of how the game UI works.

    My method works by making the game read from some strange memory location. If the offset 0x94 at this memory location is set to 0, then the game will try to create the button in an invalid location and crash. If the value is different from 0 the button will not be created at all.

    Unfornately I still didn't find a value that works both for windows and mac. Endianess does not matter, but the memory allocation schemes are different. Maybe it's not possible at all, I can't be for sure for now.