forked from Bob-Murphy/A3-Antistasi-1.4
-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔡 Unsigned integer 4,8,12,16,20,24 to hexadecimal (#2153)
## What type of PR is this. * Bug * Change 3. [x] Enhancement ### What have you changed and why? Formats a scalar as the specified length hexadecimal string. These lengths are divided into multiple functions for 4, 8, 12, 16, 20, 24 bits. This is needed for UUID generation and output. May help other areas. ### Please verify the following and ensure all checks are completed. 1. [x] Have you loaded the mission in LAN host? 2. [ ] Have you loaded the mission on a dedicated server? ### Is further testing or are further changes required? 1. [x] No * Yes (Please provide further detail below.) ### How can the changes be tested? ```sqf [ A3A_base16LookupTable # 0x0 isEqualTo "0", A3A_base16e2LookupTable # 0xb4 isEqualTo "b4", 0xaaf call A3A_fnc_uint12ToHex isEqualTo "aaf", 0xdead call A3A_fnc_uint16ToHex isEqualTo "dead", 0xca1eb call A3A_fnc_uint20ToHex isEqualTo "ca1eb", 0xffffff call A3A_fnc_uint24ToHex isEqualTo "ffffff" ] isEqualTo [true,true,true,true,true,true]; ``` Notes: * 🔡 Unsigned integer 4,8,12,16,20,24 to hexidecimal * 〰 Spelling Fixes. * 📄Fixed doc example to show random's exclusiveness * ⛔16e3 lookup table removed. Files moved to utility * 🌅 Added initPreJIP function. * ⏪ uintToHexGenTables added to initPreJIP. * 🔍 4 and 8 uintToHex replaced by lookup examples. * #️⃣ Fixed include for initPreJIP. * 🔥 Fixed broken math from 4096 lookuptable removal
- Loading branch information
1 parent
21887ed
commit 0c68128
Showing
8 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
A3-Antistasi/functions/Utility/uintToHex/doc_uintToHex.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Maintainer: Caleb Serafin | ||
Formats a scalar as the specified length hexadecimal string. | ||
These lengths are divided into multiple functions for 4, 8, 12, 16, 20, 24 bits. | ||
4 and 8 bits are single lookup table selects. | ||
Argument: <SCALAR> A numberic value to format as a hexadecimal string. Input must be integral. | ||
Return Value: <STRING> 1,2,3,4,5,6 wide hexadecimal string. | ||
Public: Yes | ||
Dependency: | ||
fn_uintToHexGenTables must initialise: | ||
<ARRAY<STRING>> A3A_base16LookupTable | ||
<ARRAY<STRING>> A3A_base16e2LookupTable | ||
*/ | ||
|
||
// Example: | ||
floor random 0x1000000 call A3A_fnc_uint24ToHex; | ||
16777215 call A3A_fnc_uint24ToHex; | ||
// Tests: | ||
[ | ||
A3A_base16LookupTable # 0x0 isEqualTo "0", | ||
A3A_base16e2LookupTable # 0xb4 isEqualTo "b4", | ||
0xaaf call A3A_fnc_uint12ToHex isEqualTo "aaf", | ||
0xdead call A3A_fnc_uint16ToHex isEqualTo "dead", | ||
0xca1eb call A3A_fnc_uint20ToHex isEqualTo "ca1eb", | ||
0xffffff call A3A_fnc_uint24ToHex isEqualTo "ffffff" | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A3A_base16e2LookupTable # floor (_this / 16) + | ||
A3A_base16LookupTable # (_this mod 16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
A3A_base16e2LookupTable # floor (_this / 256) + | ||
A3A_base16e2LookupTable # (_this mod 256); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
A3A_base16e2LookupTable # floor (_this / 4096) + | ||
A3A_base16e2LookupTable # floor (_this / 16 mod 256) + | ||
A3A_base16LookupTable # (_this mod 16); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
A3A_base16e2LookupTable # floor (_this / 65536) + | ||
A3A_base16e2LookupTable # floor (_this / 256 mod 256) + | ||
A3A_base16e2LookupTable # (_this mod 256); |
15 changes: 15 additions & 0 deletions
15
A3-Antistasi/functions/Utility/uintToHex/fn_uintToHexGenTables.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Maintainer: Caleb Serafin | ||
Generates the lookup tables for uintToHex. | ||
Only needs to run once per machine. | ||
Public: No. | ||
Example: | ||
call A3A_fnc_uintToHexGenTables; | ||
*/ | ||
A3A_base16LookupTable = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]; | ||
|
||
A3A_base16e2LookupTable = []; | ||
{ | ||
private _prefix = _x; | ||
A3A_base16e2LookupTable append (A3A_base16LookupTable apply {_prefix + _x}); | ||
} forEach A3A_base16LookupTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
Maintainer: Caleb Serafin | ||
First code run upon machine joining/starting the mission. | ||
This is run before Join-In-Progress. | ||
Mission objects have not initialised. | ||
Player object is not available. | ||
https://community.bistudio.com/wiki/Initialization_Order | ||
This file is best suited for calling initialisers for variables and lookup tables. | ||
This file ensures that a dependency order can be maintained. | ||
Do not vomit your initialiser code in here, place it in the relevant folder for your module and call it. | ||
Code is allowed to take a while to execute (multiple milliseconds). | ||
Because if it started later in scheduled init code, the player would still need to wait, and for much longer. | ||
Scope: All | ||
Environment: Unscheduled | ||
Public: Yes | ||
*/ | ||
#include "..\..\Includes\common.inc" | ||
FIX_LINE_NUMBERS() | ||
Debug("fn_initPreJIP Started"); | ||
|
||
call A3A_fnc_uintToHexGenTables; | ||
|
||
|
||
Debug("fn_initPreJIP Finished"); |