- Joined
- Jul 30, 2012
- Messages
- 156
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:
[CmdMove]
Art=CommandMove
Buttonpos=0,-11
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.
Attachments
Last edited: