re-add love-gltf for now; use local IPs for now.
This commit is contained in:
parent
6d623dec28
commit
42aa39423f
|
@ -0,0 +1,3 @@
|
|||
[submodule "love-gltf"]
|
||||
path = love-gltf
|
||||
url = https://gitlab.com/Alloyed/love-gltf.git
|
|
@ -0,0 +1 @@
|
|||
Subproject commit b9084c4dd27057d0e72b569c2da806cabc1a84f7
|
|
@ -18,12 +18,18 @@ local tick = 0
|
|||
local handlers = setmetatable({
|
||||
|
||||
serverInfo = function( svInfo, ip, port )
|
||||
print( "Received server info from:", ip, port )
|
||||
if ip ~= tostring( svInfo.ip ) then return print("Server IP mismatch:", ip, svInfo.ip) end
|
||||
print( "Server:", ip, port )
|
||||
local t = socket.gettime()
|
||||
if not servers[ip] then servers[ip] = { ip = ip, port = port, info = svInfo } end
|
||||
servers[ip].time = t
|
||||
packet.advertised{ time = t }
|
||||
if not servers[ip..port] then
|
||||
servers[ip..port] = { ip = ip, port = port, info = svInfo }
|
||||
--NAT punch: the server doesn't know its own external IP
|
||||
--so it contacts a third party (the metaserver) to discover it.
|
||||
--This external IP gets advertised to prospective clients.
|
||||
svInfo.ip = shared.ip.fromString( ip )
|
||||
svInfo.port = port
|
||||
end
|
||||
servers[ip..port].time = t
|
||||
packet.advertised{ time = t, ip = svInfo.ip, port = svInfo.port }
|
||||
return udp:sendto( packet.get(), ip, port )
|
||||
end,
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ package.path = "..\\?.lua;..\\lualib\\?.lua;"..package.path
|
|||
local shared = assert( require 'shared.shared' )
|
||||
local packet = shared.packet
|
||||
local socket = assert( require 'socket' )
|
||||
local ms = shared.metaserver
|
||||
local mscxn = assert( socket.udp() )
|
||||
mscxn:settimeout( 0 )
|
||||
assert( mscxn:setpeername( shared.metaserver.ip, shared.metaserver.port ), "Could not connect to metaserver!" )
|
||||
local udp
|
||||
local io = assert( io )
|
||||
|
||||
|
@ -36,7 +38,7 @@ function server.Advertise()
|
|||
packet.get()
|
||||
packet.metaServer()
|
||||
packet.serverInfo( svInfo )
|
||||
udp:sendto( packet.get() , ms.ip, ms.port )
|
||||
mscxn:send( packet.get() )
|
||||
end
|
||||
|
||||
function server.serverInfo( serverInfo )
|
||||
|
@ -106,7 +108,7 @@ server.Start()
|
|||
function love.update( dt )
|
||||
server.Parse( udp:receivefrom() )
|
||||
server.Advance()
|
||||
if server.tick % 50 == 0 then
|
||||
if server.tick % 250 == 0 then
|
||||
server.Advertise()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
return { ip = '142.162.167.92', port = 42069 }
|
||||
return { ip = '192.168.2.15', port = 42069 }
|
|
@ -1,13 +1,13 @@
|
|||
print( "Loading Shared." )
|
||||
local shared = {}
|
||||
|
||||
do
|
||||
--[[do
|
||||
local rq = require
|
||||
require = function( ... )
|
||||
print( "Require:", ... )
|
||||
return rq( ... )
|
||||
end
|
||||
end
|
||||
end]]
|
||||
shared.ip = assert( require 'shared.ipstring' )
|
||||
shared.packet = assert( require 'shared.packet' )
|
||||
shared.print = assert( require 'shared.print' )
|
||||
|
|
Loading…
Reference in New Issue