mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Check extension hash
This commit is contained in:
parent
e99d6d9381
commit
042404afb4
@ -77,3 +77,26 @@ class ACE_Tests {
|
||||
mapConfigs = QPATHTOF(dev\test_mapConfigs.sqf);
|
||||
cfgPatches = QPATHTOF(dev\test_cfgPatches.sqf);
|
||||
};
|
||||
|
||||
class ACE_ExtensionsHashes {
|
||||
class ace_advanced_ballistics {
|
||||
dll = "bbfbd04bced4e4766298903944ff2d0e3da7586a";
|
||||
dll_x64 = "95bdf812ebb52d4e87c4b1b980dfa785d4f980a7";
|
||||
};
|
||||
class ace_artillerytables {
|
||||
dll = "f6db1088a08e1c98f3718159a653df3ba11df773";
|
||||
dll_x64 = "d3f76b3b95ffe9c6ab6ded137ae41edcab81a9f0";
|
||||
};
|
||||
class ace_break_line {
|
||||
dll = "c1f0b83ced1f36849c8aaf23f27c889d7d7e1344";
|
||||
dll_x64 = "8622873962f4c4d3bbe05891242f21ba69845d11";
|
||||
};
|
||||
class ace_clipboard {
|
||||
dll = "cde2eceb8bac3a119c53a957e332f1a2f9cd8dcb";
|
||||
dll_x64 = "d5e8660018b9c9e870a0d4e6005a65afe48b00d3";
|
||||
};
|
||||
class ace_fcs {
|
||||
dll = "58b36db51209f61f2b63fc2469b1c74efd581012";
|
||||
dll_x64 = "4db527f03bbe71d5004647ad6b12d0263b0c3af9";
|
||||
};
|
||||
};
|
||||
|
@ -145,6 +145,31 @@ if (isArray (configFile >> "ACE_Extensions" >> "extensions")) then {
|
||||
WARNING("extensions[] array no longer supported");
|
||||
};
|
||||
|
||||
|
||||
if (hasInterface && {_platform == "windows"}) then {
|
||||
if (isFilePatchingEnabled) exitWith {};
|
||||
{
|
||||
private _extName = configName _x;
|
||||
private _extensionType = "dll";
|
||||
if (productVersion select 7 == "x64") then { _extensionType = format ["%1_x64", _extensionType]; };
|
||||
private _expectedHash = getText (_x >> _extensionType);
|
||||
|
||||
private _extensionHash = "";
|
||||
{
|
||||
if ((_x getOrDefault ["name", ""]) == _extName) exitWith {
|
||||
_extensionHash = _x getOrDefault ["hash", ""];
|
||||
};
|
||||
} forEach allExtensions;
|
||||
|
||||
if (_extensionHash != _expectedHash) then {
|
||||
private _errorMsg = format ["Extension %1 wrong version [%2 vs %3].", _extName, _extensionHash, _expectedHash];
|
||||
ERROR(_errorMsg);
|
||||
["[ACE] ERROR", _errorMsg] call FUNC(errorMessage);
|
||||
};
|
||||
} forEach ("true" configClasses (configFile >> "ACE_ExtensionsHashes"));
|
||||
};
|
||||
|
||||
|
||||
///////////////
|
||||
// Check server version/addons
|
||||
///////////////
|
||||
|
32
tools/getExtensionHash.py
Normal file
32
tools/getExtensionHash.py
Normal file
@ -0,0 +1,32 @@
|
||||
import pathlib
|
||||
import os
|
||||
import hashlib
|
||||
|
||||
addon_base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
extensions = {}
|
||||
|
||||
for file in os.listdir(addon_base_path):
|
||||
path = pathlib.Path(file)
|
||||
extension_type = "dll"
|
||||
if path.suffix == ".dll":
|
||||
key = path.stem
|
||||
if key.endswith("_x64"):
|
||||
key = key.removesuffix("_x64")
|
||||
extension_type += "_x64"
|
||||
|
||||
with open(file, 'rb') as file_read:
|
||||
sha1 = hashlib.sha1()
|
||||
data = file_read.read()
|
||||
sha1.update(data)
|
||||
arr = extensions.get(key, {})
|
||||
arr[extension_type] = sha1.hexdigest()
|
||||
extensions[key] = arr
|
||||
|
||||
print(f"class ACE_ExtensionsHashes {{")
|
||||
for key, values in extensions.items():
|
||||
print(f" class {key} {{")
|
||||
for type, hash in values.items():
|
||||
print(f" {type} = \"{hash}\";")
|
||||
print(f" }};")
|
||||
print(f"}};")
|
Loading…
Reference in New Issue
Block a user