Last active
May 12, 2019 11:22
-
-
Save BaerMitUmlaut/dfaccd6f4a7c399a942aec24c618e914 to your computer and use it in GitHub Desktop.
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
numberMapping = []; | |
// 0 - 9 -> 0 - 9 | |
for "_i" from 0 to 9 do { | |
numberMapping pushBack str _i; | |
}; | |
// 10 - 24 -> 33 - 47 | |
for "_i" from 33 to 47 do { | |
numberMapping pushBack (toString [_i]); | |
}; | |
// 24 - 92 -> 58 - 126 | |
for "_i" from 58 to 126 do { | |
numberMapping pushBack (toString [_i]); | |
}; | |
// 93 - 99 -> 224 - 230 | |
for "_i" from 224 to 230 do { | |
numberMapping pushBack (toString [_i]); | |
}; | |
fncCompressNumber = { | |
params ["_number"]; | |
_number = round (_number * 100); | |
private _str = str _number; | |
private _compressed = ""; | |
for "_i" from 0 to ceil (count _str / 2) - 1 do { | |
private _part = _str select [_i * 2, 2]; | |
_compressed = _compressed + (numberMapping select parseNumber _part); | |
}; | |
_compressed | |
}; | |
fncDecompressNumber = { | |
params ["_compressed"]; | |
private _number = ""; | |
{ | |
_number = _number + str (numberMapping find _x); | |
} forEach (_compressed splitString ""); | |
(parseNumber _number) / 100 | |
}; | |
fncCompressUnitCapture = { | |
params ["_captureData"]; | |
private _compressArray = { | |
private _c = ""; | |
{ | |
_c = _c + ([_x] call fncCompressNumber) + " "; | |
} forEach _this; | |
_c | |
}; | |
private _output = ""; | |
private _prevPos = [0, 0, 0]; | |
private _prevVel = [0, 0, 0]; | |
{ | |
_x params ["_time", "_pos", "_dir", "_up", "_vel"]; | |
_output = _output + str _time + " "; | |
_output = _output + str ((_pos vectorDiff _prevPos) call _compressArray); | |
_output = _output + str (_dir call _compressArray); | |
_output = _output + str (_up call _compressArray); | |
_output = _output + str ((_vel vectorDiff _prevVel) call _compressArray); | |
_prevPos = _pos; | |
_prevVel = _vel; | |
} forEach _captureData; | |
_output | |
}; | |
fncDecompressUnitCapture = { | |
params ["_captureData"]; | |
private _decompressArray = { | |
[ | |
[_numbers deleteAt 0] call fncDecompressNumber, | |
[_numbers deleteAt 0] call fncDecompressNumber, | |
[_numbers deleteAt 0] call fncDecompressNumber | |
] | |
}; | |
private _numbers = _captureData splitString " "; | |
private _output = []; | |
private _prevPos = [0, 0, 0]; | |
private _prevVel = [0, 0, 0]; | |
while {!(_numbers isEqualTo [])} do { | |
private _time = [_numbers deleteAt 0]; | |
private _pos = _prevPos vectorAdd (call _decompressArray); | |
private _dir = call _decompressArray; | |
private _up = call _decompressArray; | |
private _vel = _prevVel vectorAdd (call _decompressArray); | |
_prevPos = _pos; | |
_prevVel = _vel; | |
_output pushBack [_time, _pos, _dir, _up, _vel]; | |
}; | |
_output | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment