Compare commits

..

No commits in common. "a6e14499bf7aa3264e49ade3510ee7940b4a802a" and "7396f974330bf094e24c86021eb3dc4b994ebfed" have entirely different histories.

7 changed files with 22 additions and 96 deletions

1
lib/love-gltf Submodule

@ -0,0 +1 @@
Subproject commit b9084c4dd27057d0e72b569c2da806cabc1a84f7

1
lib/lua54 Submodule

@ -0,0 +1 @@
Subproject commit 88246d621abf7b6fba9332f49229d507f020e450

1
lib/luasocket Submodule

@ -0,0 +1 @@
Subproject commit 8c2ff7217e2a205eb107a6f48b04ff1b2b3090a1

View File

@ -20,8 +20,7 @@ function connecting.update(dt)
end end
function connecting:onLoad( params ) function connecting:onLoad( params )
params = params or { ip = "127.0.0.0", port = 8 } local ip, port = assert( params, "No IP address specified!" ).ip, params.port
local ip, port = params.ip, params.port
return server.connect( ip, port ) return server.connect( ip, port )
end end

View File

@ -2,93 +2,21 @@ local lg = assert( love.graphics )
local scene = assert( require 'client.scene' ) local scene = assert( require 'client.scene' )
local textInput = assert( require 'client.ui.textinput' ) local textInput = assert( require 'client.ui.textinput' )
local button = assert( require 'client.ui.button' ) local button = assert( require 'client.ui.button' )
local packet = assert( require 'shared.packet' )
local ipString = assert( require 'shared.ipstring' )
local browser = {} local browser = {}
local font = lg.newFont( "client/assets/fonts/Montserrat-Bold.ttf", 20 ) local serverList = {
selected = false,
local function populateTestServers() x = 25,
packet.get() y = 160,
packet.serverInfo{ h = 24,
players = 24, { name = "test", ip = "192.168.2.150", port = 51312, players = 1, capacity = 64, map = "testMap" },
capacity = 255, { name = "best", ip = "142.154.3.212", port = 21345, players = 2, capacity = 64, map = "nestMap" },
ip = ipString.new{ 123, 456, 789, 101 }, { name = "aest", ip = "123.45.67.89", port = 21253, players = 3, capacity = 32, map = "aestMap" },
port = 51312,
version = 25,
svname = "test server",
map = "testMap_01",
} }
packet.serverInfo{
players = 24,
capacity = 255,
ip = ipString.new{ 123, 456, 789, 101 },
port = 51312,
version = 25,
svname = "test server",
map = "testMap_02",
}
packet.serverInfo{
players = 24,
capacity = 255,
ip = ipString.new{ 150, 645, 151, 67 },
port = 51312,
version = 25,
svname = "test server",
map = "testMap_03",
}
packet.serverInfo{
players = 24,
capacity = 255,
ip = ipString.new{ 123, 456, 789, 101 },
port = 51312,
version = 25,
svname = "test server",
map = "testMap_01",
}
return packet.deserialise( packet.get() )
end
local serverList = {}
serverList.servers = populateTestServers()
serverList.offsets = {
15,
50,
150,
100,
100,
50,
50
}
serverList.selected = false
serverList.x = 25
serverList.y = 220
serverList.h = 36
function serverList.draw() function serverList.draw()
local gs = packet.getString
local x, y, h = serverList.x, serverList.y, serverList.h
local oldFont = lg.getFont()
lg.setFont( font )
for i, svInfo in ipairs( serverList.servers ) do
lg.setColor( 0.7, 0.7, 0.7, 0.7 )
lg.rectangle( "fill", x, y, 800, h, 5, 5 )
x = x + 15
y = y + 9
lg.setColor( 0, 0, 0, 0.7 )
lg.print( svInfo.version, x, y )
lg.print( gs( svInfo.svname ), 50 + x, y )
lg.print( tostring( svInfo.ip ), 200 + x, y )
lg.print( svInfo.port, 300 + x, y )
lg.print( svInfo.players, 400 + x, y )
lg.print( svInfo.capacity, 450 + x, y )
lg.print( gs( svInfo.map ), 500 + x, y )
y = y - 12
x = x - 15
y = y + h + 5
end
lg.setFont( oldFont )
end end
function serverList.select() function serverList.select()
@ -114,7 +42,6 @@ function browser.draw()
lg.setColor( 1, 1, 1, 1 ) lg.setColor( 1, 1, 1, 1 )
lg.print( "Server Browser", 15, 115 ) lg.print( "Server Browser", 15, 115 )
ti:draw() ti:draw()
serverList.draw()
end end
function browser.update( dt ) function browser.update( dt )

View File

@ -1,20 +1,16 @@
package.path = package.path .. ";lib/"
package.cpath = package.path .. ";lib/"
local shared = assert( require 'shared' ) local shared = assert( require 'shared' )
local packet = shared.packet local packet = shared.packet
local socket = assert( require 'socket' ) local socket = assert( require 'socket' )
local udp local udp
local io = assert( io ) local io = assert( io )
local svInfo = packet.serverInfo{ version = 13, local svInfo = { version = 13,
players = 0, players = 0,
capacity = 255, capacity = 255,
ip = shared.ip.fromString( socket.dns.toip(socket.dns.gethostname()) ), ip = shared.ip.fromString( socket.dns.toip(socket.dns.gethostname()) ),
port = 51312, port = 51312,
svname = "New Server", svname = "New Server",
map = "Test Map" map = "Test Map"}
}
local server = { tick = 0 } local server = { tick = 0 }
@ -40,7 +36,7 @@ end
function server.Advertise() function server.Advertise()
print( socket.gettime(), "Advertise." ) print( socket.gettime(), "Advertise." )
packet.metaServer() packet.metaServer{ padding = "" }
packet.serverInfo( svInfo ) packet.serverInfo( svInfo )
udp:sendto( packet.get() , msIP, msPort ) udp:sendto( packet.get() , msIP, msPort )
end end

View File

@ -44,6 +44,7 @@ newStruct{
newStruct{ newStruct{
name = "heartbeat", name = "heartbeat",
netname = 69, netname = 69,
"uint16_t protocol",
"uint32_t tick", "uint32_t tick",
"uint32_t hash", "uint32_t hash",
} }
@ -132,7 +133,7 @@ function packet.add( struct, data )
local str = ffi.new( struct.ct, data or 0 ) local str = ffi.new( struct.ct, data or 0 )
str.netname = assert( struct.netname ) str.netname = assert( struct.netname )
writeBuffer:putcdata( str, struct.size ) writeBuffer:putcdata( str, struct.size )
return str return writeBuffer
end end
function packet.get() function packet.get()