1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.

Pages

Saturday, May 16, 2020

Command Args Parser Update

Made a small update to the GitHub repository for the console command variables and functions library I've been working on.  Now both functions and variables can use functions with pre-computed hash values.

Variables Before:
CommandArgVariable g_testInteger("g_testInteger", CommandArgVariableType::Integer, 0);

Variables After:
CommandArgVariable g_testInteger(HASH_COMMAND_VARIABLE("g_testInteger", 0xf681f79d), CommandArgVariableType::Integer, 0);

Functions Before:
CONSOLE_COMMAND_FUNCTION_HASH(SetPlayerPosition)(CommandArgsParser & args) {

Functions After:
CONSOLE_COMMAND_FUNCTION_HASH(SetPlayerPosition, 0x13748f32)(CommandArgsParser & args) {

This has numerous benefits related to code size, initialization time, and perhaps most importantly security.  Unfortunately the trade off is that programmers need to calculate the hash value themselves.  To ease with this I've added 2 defines that allow you to compile an executable that makes this pretty easy.  By defining _HASH_COMMAND_VARIABLE and compiling you can create a simple command line utility that formats the HASH_COMMAND_VARIABLE macro for you.  By adding the folder this executable lives in to your system variables you can open up the command prompt and copy paste the values fairly easily.  Another _HASH_COMMAND_FUNCTION define has also been added to do the equivalent for the CONSOLE_COMMAND_FUNCTION_HASH macro.