-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose client version information in non-debug builds (#15708)
Co-authored-by: SmallJoker <SmallJoker@users.noreply.github.com> Co-authored-by: Lars Mueller <appgurulars@gmx.de> Co-authored-by: sfan5 <sfan5@live.de>
- Loading branch information
1 parent
e6cf081
commit dd0070a
Showing
8 changed files
with
95 additions
and
24 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
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
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
This file was deleted.
Oops, something went wrong.
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
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,40 @@ | ||
unittests.register("test_get_version", function() | ||
local version = core.get_version() | ||
assert(type(version) == "table") | ||
assert(type(version.project) == "string") | ||
assert(type(version.string) == "string") | ||
assert(type(version.proto_min) == "number") | ||
assert(type(version.proto_max) == "number") | ||
assert(version.proto_max >= version.proto_min) | ||
assert(type(version.is_dev) == "boolean") | ||
if version.is_dev then | ||
assert(type(version.hash) == "string") | ||
else | ||
assert(version.hash == nil) | ||
end | ||
end) | ||
|
||
unittests.register("test_protocol_version", function(player) | ||
local info = core.get_player_information(player:get_player_name()) | ||
|
||
local maxver = 0 | ||
for _, v in pairs(core.protocol_versions) do | ||
maxver = math.max(maxver, v) | ||
end | ||
assert(maxver > 0) -- table must contain something valid | ||
|
||
-- If the client is older than a known version then it's pointless. | ||
if info.protocol_version < maxver then | ||
core.log("warning", "test_protocol_version: client is outdated, skipping test!") | ||
return | ||
end | ||
local info_server = core.get_version() | ||
if info.version_string ~= (info_server.hash or info_server.string) then | ||
core.log("warning", "test_protocol_version: client is not the same version. False-positive possible.") | ||
end | ||
|
||
-- The protocol version the client and server agreed on must exist in the table. | ||
local match = table.key_value_swap(core.protocol_versions)[info.protocol_version] | ||
assert(match ~= nil) | ||
print(string.format("client proto matched: %s sent: %s", match, info.version_string)) | ||
end, {player = true}) |
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
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
dd0070a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows CI builds:
luanti-5.11.0-rc1-win32.zip
luanti-5.11.0-rc1-win64.zip