Revamped ulx.getVersion()

Changed beta version numbers to be backwards-looking (beta version number is the same as the current release).
This commit is contained in:
Nayruden 2015-11-19 17:22:19 -06:00
parent c1fe532069
commit 28a28a2061
9 changed files with 56 additions and 46 deletions

View File

@ -1,7 +1,7 @@
"AddonInfo"
{
"name" "ULX"
"version" "3.70"
"version" "3.62d"
"up_date" "00/00/00"
"author_name" "Team Ulysses"
"author_email" "teamulysses@ulyssesmod.net"

View File

@ -88,8 +88,8 @@ hook.Add( "PlayerInitialSpawn", "sendAutoCompletes", sendAutocompletes )
-- This will load ULX client side
local function playerInit( ply )
local _, v, r = ulx.getVersion()
ULib.clientRPC( ply, "ulx.clInit", v, r )
local _, _, b, w = ulx.getVersion()
ULib.clientRPC( ply, "ulx.clInit", b, w )
end
hook.Add( "PlayerInitialSpawn", "ULXInitPlayer", playerInit )

View File

@ -18,10 +18,9 @@ if not ulx then
end
end
function ulx.clInit( v, r )
-- Number conversion to ensure we're not getting an incredibly complex floating number
ulx.version = tonumber( string.format( "%.2f", v ) ) -- Yah, I know, we should have the version from shared anyways.... but doesn't make sense to send one and not the other.
ulx.revision = r
function ulx.clInit( b, w )
ulx.build = b
ulx.usingWorkshop = w
Msg( "ULX version " .. ulx.getVersion() .. " loaded.\n" )
end

View File

@ -106,16 +106,21 @@ end
usermessage.Hook( "ulx_vote", rcvVote )
function ulx.getVersion() -- This exists on the server as well, so feel free to use it!
local versionStr
local build = ulx.build
local usingWorkshop = ulx.usingWorkshop
if ulx.release then
version = string.format( "%.02f", ulx.version )
elseif ulx.revision > 0 then -- SVN version?
version = string.format( "<SVN> revision %i", ulx.revision )
else
version = string.format( "<SVN> unknown revision" )
versionStr = string.format( "v%.02f", ulx.version )
elseif usingWorkshop then
versionStr = string.format( "v%.02fw", ulx.version )
elseif build then -- It's not release and it's not workshop
versionStr = string.format( "v%.02fd (%s)", ulx.version, os.date( "%x", build ) )
else -- Not sure what this version is, but it's not a release
versionStr = string.format( "v%.02fd", ulx.version )
end
return version, ulx.version, ulx.revision
return versionStr, ulx.version, build, usingWorkshop
end
function ulx.addToMenu( menuid, label, data ) -- TODO, remove

View File

@ -61,36 +61,41 @@ end
hook.Add( "CanPlayerSuicide", "ULXCheckSuicide", checkSuicide, HOOK_HIGH )
function ulx.getVersion() -- This exists on the client as well, so feel free to use it!
local version
local r = 0
local versionStr
local build = nil
local usingWorkshop = false
if ulx.release then
version = string.format( "%.02f", ulx.version )
else
if ULib.fileExists( "addons/ulx/.svn/wc.db" ) then -- SVN's new format
-- The following code would probably work if garry allowed us to read this file...
--[[local raw = ULib.fileRead( "addons/ulx/.svn/wc.db" )
local highest = 0
for rev in string.gmatch( raw, "/ulx/!svn/ver/%d+/" ) do
if rev > highest then
highest = rev
end
end
r = highest]]
elseif ULib.fileExists( "addons/ulx/lua/ulx/.svn/entries" ) then
-- Garry broke the following around 05/11/2010, then fixed it again around 11/10/2010!
local lines = string.Explode( "\n", ULib.fileRead( "lua/ulx/.svn/entries" ) )
r = tonumber( lines[ 4 ] )
end
if r and r > 0 then
version = string.format( "<SVN> revision %i", r )
else
version = string.format( "<SVN> unknown revision" )
-- Get workshop information, if available
local addons = engine.GetAddons()
for i=1, #addons do
-- Ideally we'd use the "wsid" from this table
-- But, as of 19 Nov 2015, that is broken, so we'll work around it
if addons[i].file:find(tostring(ulx.WORKSHOPID)) then
usingWorkshop = true
end
end
return version, ulx.version, r
-- If we have good build data, set it in "build"
if ULib.fileExists( "ulx.build" ) then
local buildStr = ULib.fileRead( "ulx.build" )
local buildNum = tonumber(buildStr)
-- Make sure the time is something reasonable -- between the year 2014 and 2128
if buildNum and buildNum > 1400000000 and buildNum < 5000000000 then
build = buildNum
end
end
if ulx.release then
versionStr = string.format( "v%.02f", ulx.version )
elseif usingWorkshop then
versionStr = string.format( "v%.02fw", ulx.version )
elseif build then -- It's not release and it's not workshop
versionStr = string.format( "v%.02fd (%s)", ulx.version, os.date( "%x", build ) )
else -- Not sure what this version is, but it's not a release
versionStr = string.format( "v%.02fd", ulx.version )
end
return versionStr, ulx.version, build, usingWorkshop
end
function ulx.addToMenu( menuid, label, data ) -- TODO: Remove

View File

@ -115,8 +115,7 @@ function xgui.init( ply )
xgui.infobar.Paint = function( self, w, h )
draw.RoundedBoxEx( 4, 0, 1, 580, 20, xgui.settings.infoColor, false, false, true, true )
end
local version_type = ulx.revision and ( ulx.revision > 0 and " SVN " .. ulx.revision or " Release") or (" N/A")
xlib.makelabel{ x=5, y=-10, label="\nULX Admin Mod :: XGUI - by Stickly Man! :: v15.11.7 | ULX v" .. string.format("%.2f", ulx.version) .. version_type .. " | ULib v" .. ULib.VERSION, parent=xgui.infobar }:NoClipping( true )
xlib.makelabel{ x=5, y=-10, label="\nULX Admin Mod :: XGUI - by Stickly Man! :: v15.11.7 | ULX " .. ulx.getVersion() .. " | ULib " .. ULib.getVersion(), parent=xgui.infobar }:NoClipping( true )
xgui.thetime = xlib.makelabel{ x=515, y=-10, label="", parent=xgui.infobar }
xgui.thetime:NoClipping( true )
xgui.thetime.check = function()

View File

@ -1,6 +1,6 @@
ulx.LOW_ARGS = "You did not specify enough arguments for this command. Type 'ulx help' in console for help."
ulx.version = 3.70 -- Current release version. Don't access directly, use ulx.getVersion instead. (SVN checks)
ulx.version = 3.62 -- Current release version. Don't access directly, use ulx.getVersion instead. (Git/Workshop checks)
ulx.release = false -- Is this the release?
ulx.ID_ORIGINAL = 1
@ -13,3 +13,5 @@ ulx.ID_MADMIN = 3
ulx.HOOK_ULXDONELOADING = "ULXLoaded"
ulx.HOOK_VETO = "ULXVetoChanged"
ulx.WORKSHOPID = 557962280

View File

@ -1 +1 @@
1447972832
1447975339

View File

@ -1,9 +1,9 @@
Title: ULX Readme
__ULX__
Version 3.70
Version 3.62d
*ULX v3.70 (released 00/00/00)*
*ULX v3.62d (released 00/00/00)*
ULX is an admin mod for GMod (<http://garrysmod.com/>).