mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-20 22:16:57 +00:00
Anonymized GPS (#341)
GPS requests are now sent and received on CHANNEL_GPS by default instead. This means it should not be possible to distinguish computers (and thus locate them) via their GPS requests.
This commit is contained in:
parent
c1c01bef7c
commit
35c1b10224
@ -84,16 +84,16 @@ function locate( _nTimeout, _bDebug )
|
|||||||
print( "Finding position..." )
|
print( "Finding position..." )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open a channel
|
-- Open GPS channel to listen for ping responses
|
||||||
local modem = peripheral.wrap( sModemSide )
|
local modem = peripheral.wrap( sModemSide )
|
||||||
local bCloseChannel = false
|
local bCloseChannel = false
|
||||||
if not modem.isOpen( os.getComputerID() ) then
|
if not modem.isOpen( CHANNEL_GPS ) then
|
||||||
modem.open( os.getComputerID() )
|
modem.open( CHANNEL_GPS )
|
||||||
bCloseChannel = true
|
bCloseChannel = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Send a ping to listening GPS hosts
|
-- Send a ping to listening GPS hosts
|
||||||
modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" )
|
modem.transmit( CHANNEL_GPS, CHANNEL_GPS, "PING" )
|
||||||
|
|
||||||
-- Wait for the responses
|
-- Wait for the responses
|
||||||
local tFixes = {}
|
local tFixes = {}
|
||||||
@ -104,7 +104,7 @@ function locate( _nTimeout, _bDebug )
|
|||||||
if e == "modem_message" then
|
if e == "modem_message" then
|
||||||
-- We received a reply from a modem
|
-- We received a reply from a modem
|
||||||
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
|
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
|
||||||
if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then
|
if sSide == sModemSide and sChannel == CHANNEL_GPS and sReplyChannel == CHANNEL_GPS and nDistance then
|
||||||
-- Received the correct message from the correct modem: use it to determine position
|
-- Received the correct message from the correct modem: use it to determine position
|
||||||
if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
|
if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
|
||||||
local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance }
|
local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance }
|
||||||
@ -141,7 +141,7 @@ function locate( _nTimeout, _bDebug )
|
|||||||
|
|
||||||
-- Close the channel, if we opened one
|
-- Close the channel, if we opened one
|
||||||
if bCloseChannel then
|
if bCloseChannel then
|
||||||
modem.close( os.getComputerID() )
|
modem.close( CHANNEL_GPS )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return the response
|
-- Return the response
|
||||||
|
Loading…
Reference in New Issue
Block a user