|
3 | 3 | -- This file defines advisor messages related to the NAM DLL. |
4 | 4 |
|
5 | 5 | -- Note that this Lua file is not intended for distribution with the DLL itself, but for distribution with the NAM DBPF files to ensure compatibility between NAM and DLL. |
6 | | -nam_dll_version_expected = "1.2.0" -- needs to be updated whenever a new DLL version is released |
| 6 | +nam_dll_version_expected = "1.3.0" -- needs to be updated whenever a new DLL version is released |
7 | 7 |
|
8 | | --- (When this script is first executed, the `nam_dll_version` is still `nil`, but it gets defined before the trigger conditions are evaluated.) |
| 8 | +local _cached_result = nil |
9 | 9 | function is_nam_dll_correct() |
| 10 | + -- (When this script is first executed, the `nam_dll_version` is still `nil`, but it gets defined before the trigger conditions are evaluated.) |
10 | 11 | local version = rawget(globals(), "nam_dll_version") |
11 | | - return version ~= nil and version == nam_dll_version_expected |
| 12 | + if (version == nil) then |
| 13 | + return false |
| 14 | + elseif (_cached_result ~= nil) then |
| 15 | + return _cached_result |
| 16 | + else |
| 17 | + if (version == nam_dll_version_expected) then |
| 18 | + _cached_result = true |
| 19 | + else |
| 20 | + -- check semantic versions to allow a patch level higher than expected by this Lua script |
| 21 | + local semver_pattern = "^(%d+%.%d+)%.(%d+)" |
| 22 | + local i, _, v12, v3 = string.find(version, semver_pattern) |
| 23 | + local j, _, e12, e3 = string.find(nam_dll_version_expected, semver_pattern) |
| 24 | + if (i == nil or j == nil) then |
| 25 | + _cached_result = false |
| 26 | + else |
| 27 | + _cached_result = (v12 == e12 and tonumber(v3) >= tonumber(e3)) |
| 28 | + end |
| 29 | + end |
| 30 | + return _cached_result |
| 31 | + end |
12 | 32 | end |
13 | 33 |
|
14 | 34 | ------------ Advice record ---- |
|
0 commit comments