Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace UniqueID with SteamID64 where applicable #226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/ulx/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ end
local function echoToAdmins( txt )
local players = player.GetAll()
for _, ply in ipairs( players ) do
if ULib.ucl.authed[ ply:UniqueID() ] and ULib.ucl.query( ply, spawnechoAccess ) then
if ULib.ucl.authed[ ply:SteamID64() ] and ULib.ucl.query( ply, spawnechoAccess ) then
ULib.console( ply, txt )
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/ulx/modules/cl/xgui_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function xgui.show( tabname )
return
end

if not game.SinglePlayer() and not ULib.ucl.authed[LocalPlayer():UniqueID()] then
if not game.SinglePlayer() and not ULib.ucl.authed[LocalPlayer():SteamID64()] then
local unauthedWarning = xlib.makeframe{ label="XGUI Error!", w=250, h=90, showclose=true, skin=xgui.settings.skin }
xlib.makelabel{ label="Your ULX player has not been Authed!", x=10, y=30, parent=unauthedWarning }
xlib.makelabel{ label="Please wait a couple seconds and try again.", x=10, y=45, parent=unauthedWarning }
Expand Down
20 changes: 10 additions & 10 deletions lua/ulx/modules/sh/user.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ local function checkForValidId( calling_ply, id )
ULib.tsayError( calling_ply, "Invalid steamid.", true )
return false
end
elseif not tonumber( id ) then -- Assume uniqueid and check
ULib.tsayError( calling_ply, "Invalid Unique ID", true )
elseif not tonumber( id ) then -- Assume UniqueID/SteamID64 and check
ULib.tsayError( calling_ply, "Invalid UniqueID/SteamID64", true )
return false
end

Expand Down Expand Up @@ -49,7 +49,7 @@ usermanagementhelp:defaultAccess( ULib.ACCESS_ALL )
usermanagementhelp:help( "See the user management help." )

function ulx.adduser( calling_ply, target_ply, group_name )
local userInfo = ULib.ucl.authed[ target_ply:UniqueID() ]
local userInfo = ULib.ucl.authed[ target_ply:SteamID64() ]

local id = ULib.ucl.getUserRegisteredID( target_ply )
if not id then id = target_ply:SteamID() end
Expand Down Expand Up @@ -81,13 +81,13 @@ function ulx.adduserid( calling_ply, id, group_name )
end
end
local adduserid = ulx.command( CATEGORY_NAME, "ulx adduserid", ulx.adduserid, nil, false, false, true )
adduserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
adduserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, SteamID64, IP, or UniqueID" }
adduserid:addParam{ type=ULib.cmds.StringArg, completes=ulx.group_names_no_user, hint="group", error="invalid group \"%s\" specified", ULib.cmds.restrictToCompletes }
adduserid:defaultAccess( ULib.ACCESS_SUPERADMIN )
adduserid:help( "Add a user by ID to specified group." )

function ulx.removeuser( calling_ply, target_ply )
ULib.ucl.removeUser( target_ply:UniqueID() )
ULib.ucl.removeUser( target_ply:SteamID64() )

ulx.fancyLogAdmin( calling_ply, "#A removed all access rights from #T", target_ply )
end
Expand Down Expand Up @@ -118,7 +118,7 @@ function ulx.removeuserid( calling_ply, id )
end
end
local removeuserid = ulx.command( CATEGORY_NAME, "ulx removeuserid", ulx.removeuserid, nil, false, false, true )
removeuserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
removeuserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, SteamID64, IP, or UniqueID" }
removeuserid:defaultAccess( ULib.ACCESS_SUPERADMIN )
removeuserid:help( "Permanently removes a user's access by ID." )

Expand Down Expand Up @@ -185,16 +185,16 @@ function ulx.userallowid( calling_ply, id, access_string, access_tag )
end
end
local userallowid = ulx.command( CATEGORY_NAME, "ulx userallowid", ulx.userallowid, nil, false, false, true )
userallowid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
userallowid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, SteamID64, IP, or UniqueID" }
userallowid:addParam{ type=ULib.cmds.StringArg, hint="command" } -- TODO, add completes for this
userallowid:addParam{ type=ULib.cmds.StringArg, hint="access tag", ULib.cmds.optional }
userallowid:defaultAccess( ULib.ACCESS_SUPERADMIN )
userallowid:help( "Add to a user's access." )

function ulx.userdeny( calling_ply, target_ply, access_string, should_use_neutral )
local success = ULib.ucl.userAllow( target_ply:UniqueID(), access_string, should_use_neutral, true )
local success = ULib.ucl.userAllow( target_ply:SteamID64(), access_string, should_use_neutral, true )
if should_use_neutral then
success = success or ULib.ucl.userAllow( target_ply:UniqueID(), access_string, should_use_neutral, false ) -- Remove from both lists
success = success or ULib.ucl.userAllow( target_ply:SteamID64(), access_string, should_use_neutral, false ) -- Remove from both lists
end

if should_use_neutral then
Expand Down Expand Up @@ -250,7 +250,7 @@ function ulx.userdenyid( calling_ply, id, access_string, should_use_neutral )
end
end
local userdenyid = ulx.command( CATEGORY_NAME, "ulx userdenyid", ulx.userdenyid, nil, false, false, true )
userdenyid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
userdenyid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, SteamID64, IP, or UniqueID" }
userdenyid:addParam{ type=ULib.cmds.StringArg, hint="command" } -- TODO, add completes for this
userdenyid:addParam{ type=ULib.cmds.BoolArg, hint="remove explicit allow or deny instead of outright denying", ULib.cmds.optional }
userdenyid:defaultAccess( ULib.ACCESS_SUPERADMIN )
Expand Down
6 changes: 3 additions & 3 deletions lua/ulx/modules/sh/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,16 @@ function ulx.debuginfo( calling_ply )
str = str .. "Dedicated server: " .. tostring( game.IsDedicated() ) .. "\n\n"

local players = player.GetAll()
str = str .. string.format( "Currently connected players:\nNick%s steamid%s uid%s id lsh\n", str.rep( " ", 27 ), str.rep( " ", 12 ), str.rep( " ", 7 ) )
str = str .. string.format( "Currently connected players:\nNick%s steamid%s steamid64%s id lsh\n", str.rep( " ", 27 ), str.rep( " ", 12 ), str.rep( " ", 7 ) )
for _, ply in ipairs( players ) do
local id = string.format( "%i", ply:EntIndex() )
local steamid = ply:SteamID()
local uid = tostring( ply:UniqueID() )
local steamid64 = tostring( ply:SteamID64() )
local name = utf8.force( ply:Nick() )

local plyline = name .. str.rep( " ", 32 - utf8.len( name ) ) -- Name
plyline = plyline .. steamid .. str.rep( " ", 20 - steamid:len() ) -- Steamid
plyline = plyline .. uid .. str.rep( " ", 11 - uid:len() ) -- Steamid
plyline = plyline .. steamid64 .. str.rep( " ", 11 - steamid64:len() ) -- Steamid
plyline = plyline .. id .. str.rep( " ", 3 - id:len() ) -- id
if ply:IsListenServerHost() then
plyline = plyline .. "y "
Expand Down
2 changes: 1 addition & 1 deletion lua/ulx/modules/slots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function calcSlots( disconnect )

local players = player.GetAll()
for _, player in ipairs( players ) do
if player:IsConnected() and ULib.ucl.authed[ player:UniqueID() ] and player:query( access ) then
if player:IsConnected() and ULib.ucl.authed[ player:SteamID64() ] and player:query( access ) then
admins = admins + 1
end
end
Expand Down
48 changes: 24 additions & 24 deletions lua/ulx/modules/xgui_server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ function xgui.init()
--Let the server know when players are/aren't ready to receive data.
function xgui.getInstalled( ply )
ULib.clientRPC( ply, "xgui.getInstalled" )
xgui.readyPlayers[ply:UniqueID()] = 1
xgui.readyPlayers[ply:SteamID64()] = 1
end
xgui.addCmd( "getInstalled", xgui.getInstalled )

function xgui.onDisconnect( ply )
xgui.activeUsers[ply:UniqueID()] = nil
xgui.readyPlayers[ply:UniqueID()] = nil
xgui.activeUsers[ply:SteamID64()] = nil
xgui.readyPlayers[ply:SteamID64()] = nil
end
hook.Add( "PlayerDisconnected", "xgui_ply_disconnect", xgui.onDisconnect )

Expand Down Expand Up @@ -159,25 +159,25 @@ function xgui.init()
plys = plyToTable( plys )

for k, ply in pairs( plys ) do
if not xgui.readyPlayers[ply:UniqueID()] then return end --Ignore requests to players who are not ready, they'll get the data as soon as they can.
if not xgui.readyPlayers[ply:SteamID64()] then return end --Ignore requests to players who are not ready, they'll get the data as soon as they can.

-- print("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
-- print("sendDataTable attempt. Will defer?", xgui.activeUsers[ply:UniqueID()] and not forceSend)
-- print("sendDataTable attempt. Will defer?", xgui.activeUsers[ply:SteamID64()] and not forceSend)
-- PrintTable(datatypes)
-- print(debug.traceback())
-- print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")

if xgui.activeUsers[ply:UniqueID()] and not forceSend then --If data is currently being sent to the client
if xgui.activeUsers[ply:SteamID64()] and not forceSend then --If data is currently being sent to the client
for _, dtype in ipairs( datatypes ) do
local exists = false
for _,existingArg in ipairs(xgui.activeUsers[ply:UniqueID()].tables) do
for _,existingArg in ipairs(xgui.activeUsers[ply:SteamID64()].tables) do
if dtype == existingArg then exists=true break end
end
if not exists then table.insert( xgui.activeUsers[ply:UniqueID()].tables, dtype ) end
if not exists then table.insert( xgui.activeUsers[ply:SteamID64()].tables, dtype ) end
--Clear any events relating to this data type, since those changes will be reflected whenever the new table is sent.
for i=#xgui.activeUsers[ply:UniqueID()].events,1,-1 do
if xgui.activeUsers[ply:UniqueID()].events[i][2] == dtype then
table.remove( xgui.activeUsers[ply:UniqueID()].events, i )
for i=#xgui.activeUsers[ply:SteamID64()].events,1,-1 do
if xgui.activeUsers[ply:SteamID64()].events[i][2] == dtype then
table.remove( xgui.activeUsers[ply:SteamID64()].events, i )
end
end
end
Expand Down Expand Up @@ -246,13 +246,13 @@ function xgui.init()
for k, ply in pairs( plys ) do

-- print("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
-- print("sendDataEvent attempt. Will defer?", xgui.activeUsers[ply:UniqueID()])
-- print("sendDataEvent attempt. Will defer?", xgui.activeUsers[ply:SteamID64()])
-- print(evtype, dtype, entry)
-- print(debug.traceback())
-- print("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")

if xgui.activeUsers[ply:UniqueID()] then
table.insert( xgui.activeUsers[ply:UniqueID()].events, { evtype, dtype, entry } )
if xgui.activeUsers[ply:SteamID64()] then
table.insert( xgui.activeUsers[ply:SteamID64()].events, { evtype, dtype, entry } )
return
end

Expand All @@ -264,26 +264,26 @@ function xgui.init()

function xgui.sendChunks( ply, chunks )
ULib.clientRPC( ply, "xgui.expectChunks", #chunks )
if not xgui.activeUsers[ply:UniqueID()] then xgui.activeUsers[ply:UniqueID()] = { tables={}, events={} } end
if not xgui.activeUsers[ply:SteamID64()] then xgui.activeUsers[ply:SteamID64()] = { tables={}, events={} } end
for _, chunk in ipairs( chunks ) do
ULib.queueFunctionCall( ULib.clientRPC, ply, "xgui.getChunk", chunk[1], chunk[2], chunk[3] )
end
end

function xgui.chunksFinished( ply )
if xgui.activeUsers[ply:UniqueID()] then
if #xgui.activeUsers[ply:UniqueID()].tables > 0 then --Data tables have been requested while the player was transferring data
xgui.sendDataTable( ply, xgui.activeUsers[ply:UniqueID()].tables, true )
xgui.activeUsers[ply:UniqueID()].tables = {}
elseif #xgui.activeUsers[ply:UniqueID()].events > 0 then --No data tables are needed, and events have occurred while the player was transferring data
if xgui.activeUsers[ply:SteamID64()] then
if #xgui.activeUsers[ply:SteamID64()].tables > 0 then --Data tables have been requested while the player was transferring data
xgui.sendDataTable( ply, xgui.activeUsers[ply:SteamID64()].tables, true )
xgui.activeUsers[ply:SteamID64()].tables = {}
elseif #xgui.activeUsers[ply:SteamID64()].events > 0 then --No data tables are needed, and events have occurred while the player was transferring data
local chunks = {}
for _,v in ipairs( xgui.activeUsers[ply:UniqueID()].events ) do
for _,v in ipairs( xgui.activeUsers[ply:SteamID64()].events ) do
table.insert( chunks, v )
end
xgui.sendChunks( ply, chunks )
xgui.activeUsers[ply:UniqueID()].events = {}
xgui.activeUsers[ply:SteamID64()].events = {}
else --Client is up-to-date!
xgui.activeUsers[ply:UniqueID()] = nil
xgui.activeUsers[ply:SteamID64()] = nil
end
end
end
Expand Down Expand Up @@ -326,7 +326,7 @@ function xgui.postInit()
--Fix any users who requested data before the server was ready
for _, ply in pairs( player.GetAll() ) do
for UID, data in pairs( xgui.activeUsers ) do
if ply:UniqueID() == UID then
if ply:SteamID64() == UID then
ULib.clientRPC( ply, "xgui.getChunk", -1, "Initializing..." )
end
end
Expand Down
2 changes: 1 addition & 1 deletion lua/ulx/xgui/server/sv_groups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function groups.init()

function xgui.playerExistsByID( id )
for k, v in ipairs( player.GetAll() ) do
if v:SteamID() == id or v:UniqueID() == id or ULib.splitPort( v:IPAddress() ) == id then
if v:SteamID() == id or v:SteamID64() == id or v:UniqueID() == id or ULib.splitPort( v:IPAddress() ) == id then
return v
end
end
Expand Down