[0.0-53] misc stability improvements; also updated some docs

This commit is contained in:
Ben Russell (300178622) 2013-06-24 14:35:23 +12:00
parent 808c9fe5ab
commit e073433273
16 changed files with 234 additions and 128 deletions

View File

@ -1,9 +1,12 @@
GUYS GUYS GUYS
FIRST THING YOU NEED TO READ:
Forums: http://iceballga.me
Our IRC channel is #iceball @ irc.quacknet.org (not quaKEnet, but quaCKnet).
docs/READ_THIS_FIRST.txt might work (OK, it's out of date right now. Try running the tutorial.)
If not, there's a tutorial on the forums:
http://iceballga.me
If you have a Windows build, running iceball.exe should give you a tutorial
on how to actually run this thing.
If you've built this for not-Windows, running ./iceball should do the same.
The tutorial files are located in pkg/iceball/halp/.
------------------------------------------------------------------------------

View File

@ -1,2 +1,2 @@
@echo off
iceball-gl -c play.iceballga.me 20737
@echo off
iceball-gl -c play.iceballga.me 20737

View File

@ -1,3 +1,13 @@
Sorry, but the contents of this file are horrendously out of date.
You can either:
1. run iceball.exe without any arguments, and get a tutorial, or
2. read the tutorial in pkg/iceball/halp/texts.lua using something that isn't Notepad.
The building information is a bit out of date
- you need to copy sackit and enet to xlibinc/ or winlibs/ depending on your OS.
Original text follows.
### INCOMPLETE. Hopefully will apply eventually. ###
Congratulations for successfully extracting Iceball from its archive!

51
docs/troubleshooting.txt Normal file
View File

@ -0,0 +1,51 @@
First things first, if you have a Windows build, double-click on iceball.exe.
Things to check if it fails:
*** Is this file in the same folder as iceball.exe? ***
If so, you extraced the .zip wrong.
You *MUST* retain the correct directory structure.
*** Have you tried running it in the command line? ***
Open opencmd.bat, and run it from there.
See if you get any errors.
You don't need to worry about stdout.txt/stderr.txt with the official builds,
however if you built it yourself, you may need to check those files.
*** Does opencmd.bat not work for you? ***
Um, you will need access to a commandline *somehow*.
*** I typed in the iceball-gl -c thing and it doesn't work! ***
Did you hit enter?
If so, and you get an error,
take a screenshot or a copy of the EXACT text in your command prompt,
and we can extend this section.
*** Does it *actually* crash? ***
Give us a screenshot of the commandline window showing how it crashed.
The best idea?
Run it in a debugger such as GDB (available with MinGW32).
If you're using GDB, run it like do this:
handle SIGPIPE nostop noprint pass
run
and then when it crashes, type:
bt full
Note, if you get a SIGPIPE/Broken pipe "crash",
you didn't set up the debugger correctly.
I *think* this might be a non-Windows issue though.
In my case I tend to prepend the commandline with "gdb --args ".
Someone else can elaborate here if necessary.
*** How do I change my name? ***
Did you read the built-in tutorial?
*** Anything else? ***
Join us on IRC: #iceball @ irc.quacknet.org (NOT quaKEnet!).
This really should be on a wiki somewhere.

View File

@ -19,7 +19,7 @@
#define VERSION_X 0
#define VERSION_Y 0
#define VERSION_A 0
#define VERSION_Z 52
#define VERSION_Z 53
// Remember to bump "Z" basically every time you change the engine!
// Remember to bump the version in Lua too!
// Remember to document API changes in a new version!

View File

@ -1,2 +1,4 @@
@echo off
cmd
@echo off
cmd
pause

View File

@ -133,7 +133,7 @@ TOOL_EXPL = 3
-- sounds
if client then
client.wav_cube_size(2)
client.wav_cube_size(1)
wav_rifle_shot = skin_load("wav", "rifle-shot.wav", DIR_PKG_WAV)
wav_rifle_reload = skin_load("wav", "rifle-reload.wav", DIR_PKG_WAV)
wav_whoosh = skin_load("wav", "whoosh.wav", DIR_PKG_WAV)

View File

@ -231,6 +231,11 @@ do
rgb = 85
while true do
obj, csize, usize, amount = common.fetch_poll()
-- TODO: don't do this every time fetch_poll returns - give it a bit of a rest!
if PKT_KEEPALIVE then
print(PKT_KEEPALIVE)
common.net_send(nil, common.net_pack("BB", PKT_KEEPALIVE), true)
end
--print("obj:", obj, csize, usize, amount)
if obj ~= false then break end

View File

@ -32,7 +32,7 @@ dofile("pkg/base/commands.lua")
client_list = {fdlist={}}
server_tick_accum = 0.
function slot_add(sockfd, tidx, wpn, name)
function slot_add(neth, tidx, wpn, name)
local i
for i=1,players.max do
if not players[i] then
@ -53,7 +53,7 @@ function slot_add(sockfd, tidx, wpn, name)
team = tidx, -- 0 == blue, 1 == green
weapon = _wpn,
pid = i,
sockfd = sockfd
neth = neth
})
if permissions["default"] ~= nil then
players[i].add_permission_group(permissions["default"].perms)
@ -69,8 +69,10 @@ function slot_add(sockfd, tidx, wpn, name)
end
function server.hook_file(sockfd, ftype, fname)
print("hook_file:", sockfd, ftype, fname)
function server.hook_file(neth, ftype, fname)
print("hook_file:", neth, ftype, fname)
local cli = client_list[neth]
if cli then cli.lastmsg = sec_current end
if fname:lower():find("svsave") then
return nil
@ -89,50 +91,51 @@ function server.hook_file(sockfd, ftype, fname)
return true
end
function server.hook_connect(sockfd, addrinfo)
function server.hook_connect(neth, addrinfo)
-- TODO: enforce bans
client_list.fdlist[#(client_list.fdlist)+1] = sockfd
client_list[sockfd] = {
client_list.fdlist[#(client_list.fdlist)+1] = neth
client_list[neth] = {
fdidx = #(client_list.fdlist),
addrinfo = addrinfo,
lastmsg = nil,
plrid = nil
}
print("connect:", sockfd, addrinfo.proto,
print("connect:", neth, addrinfo.proto,
addrinfo.addr and addrinfo.addr.sport,
addrinfo.addr and addrinfo.addr.ip,
addrinfo.addr and addrinfo.addr.cport)
local ss = (sockfd == true and "(local)") or sockfd
local ss = (neth == true and "(local)") or neth
--[[net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFF800000,
"Connected: player on sockfd "..ss))]]
print("Connected: player on sockfd "..ss)
"Connected: player on neth "..ss))]]
print("Connected: player on neth "..ss)
end
function server.hook_disconnect(sockfd, server_force, reason)
function server.hook_disconnect(neth, server_force, reason)
-- just in case we get any stray disconnect messages
if not client_list[sockfd] then return end
if not client_list[neth] then return end
local plrid = client_list[sockfd].plrid
local plrid = client_list[neth].plrid
local plr = players[plrid]
local fdidx = client_list[sockfd].fdidx
local fdidx = client_list[neth].fdidx
local cli2 = client_list[client_list.fdlist[#(client_list.fdlist)]]
cli2.fdidx = fdidx
client_list.fdlist[fdidx] = client_list.fdlist[#(client_list.fdlist)]
client_list.fdlist[#(client_list.fdlist)] = nil
client_list[sockfd] = nil
print("disconnect:", sockfd, server_force, reason)
client_list[neth] = nil
print("disconnect:", neth, server_force, reason)
local ss = (sockfd == true and "(local)") or sockfd
local ss = (neth == true and "(local)") or neth
--[[net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFF800000,
"Disconnected: player on sockfd "..ss))]]
print("Disconnected: player on sockfd "..ss)
"Disconnected: player on neth "..ss))]]
print("Disconnected: player on neth "..ss)
if plr then
plr.intel_drop()
net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFF800000,
"* Player "..plr.name.." disconnected"))
net_broadcast(sockfd, common.net_pack("BB",
net_broadcast(neth, common.net_pack("BB",
PKT_PLR_RM, plrid))
-- TODO fix crash bug
@ -159,22 +162,40 @@ function server.hook_tick(sec_current, sec_delta)
lflush = sec_current
end
end
local pkt, sockfd
local pkt, neth, cli
for neth, cli in pairs(client_list) do
if type(neth) == type(0) or neth == true then
--print(neth,cli.lastmsg, sec_current)
if not cli.lastmsg then
cli.lastmsg = sec_current
elseif neth ~= "true" and cli.lastmsg + NET_MAX_LAG < sec_current then
-- don't autokick the local client - it never ACTUALLY "disconnects"
-- otherwise we'll be chewing through this over and over again
print("Autokicking client "..((neth == true and "local") or neth))
server.net_kick(neth, "Connection timed out")
-- net_disconnect should be called by this point
end
end
end
while true do
pkt, sockfd = common.net_recv()
pkt, neth = common.net_recv()
if not pkt then break end
local cli = client_list[sockfd]
local cli = client_list[neth]
local plr = cli and players[cli.plrid]
if cli then cli.lastmsg = sec_current end
local cid
cid, pkt = common.net_unpack("B", pkt)
--print("in",sockfd,cid)
--print("in",neth,cid)
local hdl = network.sys_tab_handlers[cid]
if hdl then
hdl.f(sockfd, cli, plr, sec_current, common.net_unpack(hdl.s, pkt))
hdl.f(neth, cli, plr, sec_current, common.net_unpack(hdl.s, pkt))
else
print(string.format("S: unhandled packet %02X", cid))
end

View File

@ -21,8 +21,8 @@ network.sys_tab_cli = {}
network.sys_tab_throttle = {}
function net_send(sockfd, msg)
network.sys_tab_throttle[#(network.sys_tab_throttle)+1] = {sockfd, msg}
function net_send(neth, msg)
network.sys_tab_throttle[#(network.sys_tab_throttle)+1] = {neth, msg}
end
function net_send_flush()
@ -32,18 +32,24 @@ function net_send_flush()
for i=1,n do
local v = network.sys_tab_throttle[i]
network.sys_tab_throttle[i] = nil
if not common.net_send(v[1], v[2]) then
failures = failures or {}
failures[v[1]] = true
if client or v[1] then
if not common.net_send(v[1], v[2]) then
failures = failures or {}
failures[v[1]] = true
end
else
-- FIXME: this happens too often.
-- It works perfectly fine, though. --GM
--print("ignoring packet with nil neth:", #(v[2]))
end
end
end
if server then
function net_broadcast(sockfd, msg)
function net_broadcast(neth, msg)
local i
for i=1,#(client_list.fdlist) do
if client_list.fdlist[i] ~= sockfd then
if client_list.fdlist[i] ~= neth then
--print("to", client_list.fdlist[i], type(msg))
net_send(client_list.fdlist[i], msg)
end
@ -100,7 +106,7 @@ end
-- base mod packets
do
local pktlist = {
"PING", "PONG",
"PING", "PONG", "KEEPALIVE",
"PLR_POS", "PLR_ORIENT",
"PLR_ADD", "PLR_ID", "PLR_RM",
"BLK_ADD", "BLK_RM1", "BLK_RM3",
@ -128,26 +134,26 @@ do
end
function nwdec_plrset(f, fx)
return (function (sockfd, cli, plr, sec_current, ...)
if plr then return f(sockfd, cli, plr, sec_current, ...)
elseif fx then return fx(sockfd, cli, plr, sec_current, ...) end
return (function (neth, cli, plr, sec_current, ...)
if plr then return f(neth, cli, plr, sec_current, ...)
elseif fx then return fx(neth, cli, plr, sec_current, ...) end
end)
end
function nwdec_plrclear(f)
return (function (sockfd, cli, plr, sec_current, ...)
if not plr then return f(sockfd, cli, plr, sec_current, ...) end
return (function (neth, cli, plr, sec_current, ...)
if not plr then return f(neth, cli, plr, sec_current, ...) end
end)
end
function nwdec_plrsquadset(f)
return (function (sockfd, cli, plr, sec_current, ...)
if plr and plr.squad then return f(sockfd, cli, plr, sec_current, ...) end
return (function (neth, cli, plr, sec_current, ...)
if plr and plr.squad then return f(neth, cli, plr, sec_current, ...) end
end)
end
-- S2C packets
network.sys_handle_s2c(PKT_PLR_POS, "Bhhh", function (sockfd, cli, plr, sec_current, pid, x, y, z, pkt)
network.sys_handle_s2c(PKT_PLR_POS, "Bhhh", function (neth, cli, plr, sec_current, pid, x, y, z, pkt)
x = x/32.0
y = y/32.0
z = z/32.0
@ -158,7 +164,7 @@ network.sys_handle_s2c(PKT_PLR_POS, "Bhhh", function (sockfd, cli, plr, sec_curr
plr.set_pos_recv(x, y, z)
end
end)
network.sys_handle_s2c(PKT_PLR_ORIENT, "BbbB", function (sockfd, cli, plr, sec_current, pid, ya, xa, keys, pkt)
network.sys_handle_s2c(PKT_PLR_ORIENT, "BbbB", function (neth, cli, plr, sec_current, pid, ya, xa, keys, pkt)
ya = ya*math.pi/128
xa = xa*math.pi/256
@ -168,7 +174,7 @@ network.sys_handle_s2c(PKT_PLR_ORIENT, "BbbB", function (sockfd, cli, plr, sec_c
plr.set_orient_recv(ya, xa, keys)
end
end)
network.sys_handle_s2c(PKT_PLR_ADD, "Bbbbhhhzz", function (sockfd, cli, plr, sec_current, pid, tidx, wpn, mode, score, kills, deaths, name, squad, pkt)
network.sys_handle_s2c(PKT_PLR_ADD, "Bbbbhhhzz", function (neth, cli, plr, sec_current, pid, tidx, wpn, mode, score, kills, deaths, name, squad, pkt)
if players[pid] then
-- TODO: update wpn/name
players[pid].squad = (squad ~= "" and squad) or nil
@ -193,7 +199,7 @@ network.sys_handle_s2c(PKT_PLR_ADD, "Bbbbhhhzz", function (sockfd, cli, plr, sec
weapon = wpn,
mode = mode,
pid = pid,
sockfd = sockfd
neth = neth
})
end
@ -201,36 +207,36 @@ network.sys_handle_s2c(PKT_PLR_ADD, "Bbbbhhhzz", function (sockfd, cli, plr, sec
players[pid].kills = kills
players[pid].deaths = deaths
end)
network.sys_handle_s2c(PKT_PLR_ID, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PLR_ID, "B", function (neth, cli, plr, sec_current, pid, pkt)
players.current = pid
end)
network.sys_handle_s2c(PKT_PLR_RM, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PLR_RM, "B", function (neth, cli, plr, sec_current, pid, pkt)
players[pid] = nil
end)
network.sys_handle_s2c(PKT_BLK_ADD, "HHHBBBB", function (sockfd, cli, plr, sec_current, x,y,z,cb,cg,cr,ct, pkt)
network.sys_handle_s2c(PKT_BLK_ADD, "HHHBBBB", function (neth, cli, plr, sec_current, x,y,z,cb,cg,cr,ct, pkt)
bhealth_clear(x,y,z,false)
client.wav_play_global(wav_buld,x+0.5,y+0.5,z+0.5)
map_block_set(x,y,z,ct,cr,cg,cb)
end)
network.sys_handle_s2c(PKT_BLK_RM1, "HHH", function (sockfd, cli, plr, sec_current, x, y, z, pkt)
network.sys_handle_s2c(PKT_BLK_RM1, "HHH", function (neth, cli, plr, sec_current, x, y, z, pkt)
bhealth_clear(x,y,z,false)
map_block_break(x,y,z)
client.wav_play_global(wav_pop, x, y, z)
end)
network.sys_handle_s2c(PKT_CHAT_ADD_TEXT, "Iz", function (sockfd, cli, plr, sec_current, color, msg, pkt)
network.sys_handle_s2c(PKT_CHAT_ADD_TEXT, "Iz", function (neth, cli, plr, sec_current, color, msg, pkt)
chat_add(chat_text, sec_current, msg, color)
end)
network.sys_handle_s2c(PKT_CHAT_ADD_KILLFEED, "Iz", function (sockfd, cli, plr, sec_current, color, msg, pkt)
network.sys_handle_s2c(PKT_CHAT_ADD_KILLFEED, "Iz", function (neth, cli, plr, sec_current, color, msg, pkt)
chat_add(chat_killfeed, sec_current, msg, color)
end)
network.sys_handle_s2c(PKT_PLR_SPAWN, "Bfffbb", function (sockfd, cli, plr, sec_current, pid, x, y, z, xa, ya, pkt)
network.sys_handle_s2c(PKT_PLR_SPAWN, "Bfffbb", function (neth, cli, plr, sec_current, pid, x, y, z, xa, ya, pkt)
local plr = players[pid]
--print("client respawn!", players.current, pid, plr)
if plr then
plr.spawn_at(x,y,z,ya*math.pi/128,xa*math.pi/256)
end
end)
network.sys_handle_s2c(PKT_ITEM_POS, "HhhhB", function (sockfd, cli, plr, sec_current, iid, x,y,z, f, pkt)
network.sys_handle_s2c(PKT_ITEM_POS, "HhhhB", function (neth, cli, plr, sec_current, iid, x,y,z, f, pkt)
if intent[iid] then
--print("intent",iid,x,y,z,f)
if not intent[iid].spawned then
@ -243,20 +249,20 @@ network.sys_handle_s2c(PKT_ITEM_POS, "HhhhB", function (sockfd, cli, plr, sec_cu
--print(intent[iid].spawned, intent[iid].alive, intent[iid].visible)
end
end)
network.sys_handle_s2c(PKT_PLR_DAMAGE, "BB", function (sockfd, cli, plr, sec_current, pid, amt, pkt)
network.sys_handle_s2c(PKT_PLR_DAMAGE, "BB", function (neth, cli, plr, sec_current, pid, amt, pkt)
local plr = players[pid]
--print("hit pkt", pid, amt)
if plr then
plr.set_health_damage(amt, nil, nil, nil)
end
end)
network.sys_handle_s2c(PKT_PLR_RESTOCK, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PLR_RESTOCK, "B", function (neth, cli, plr, sec_current, pid, pkt)
local plr = players[pid]
if plr then
plr.tent_restock()
end
end)
network.sys_handle_s2c(PKT_ITEM_CARRIER, "HB", function (sockfd, cli, plr, sec_current, iid, pid, pkt)
network.sys_handle_s2c(PKT_ITEM_CARRIER, "HB", function (neth, cli, plr, sec_current, iid, pid, pkt)
local plr = (pid ~= 0 and players[pid]) or nil
local item = intent[iid]
--print(">",iid,pid,plr,item)
@ -272,14 +278,14 @@ network.sys_handle_s2c(PKT_ITEM_CARRIER, "HB", function (sockfd, cli, plr, sec_c
end
end
end)
network.sys_handle_s2c(PKT_PLR_TOOL, "BB", function (sockfd, cli, plr, sec_current, pid, tool, pkt)
network.sys_handle_s2c(PKT_PLR_TOOL, "BB", function (neth, cli, plr, sec_current, pid, tool, pkt)
local plr = players[pid]
if plr then
plr.tool_switch(tool)
end
end)
network.sys_handle_s2c(PKT_PLR_BLK_COLOR, "BBBB", function (sockfd, cli, plr, sec_current, pid, cr, cg, cb, pkt)
network.sys_handle_s2c(PKT_PLR_BLK_COLOR, "BBBB", function (neth, cli, plr, sec_current, pid, cr, cg, cb, pkt)
local plr = players[pid]
--print("recol",cr,cg,cb)
@ -289,7 +295,7 @@ network.sys_handle_s2c(PKT_PLR_BLK_COLOR, "BBBB", function (sockfd, cli, plr, se
plr.block_recolor()
end
end)
network.sys_handle_s2c(PKT_PLR_BLK_COUNT, "BB", function (sockfd, cli, plr, sec_current, pid, blocks, pkt)
network.sys_handle_s2c(PKT_PLR_BLK_COUNT, "BB", function (neth, cli, plr, sec_current, pid, blocks, pkt)
local plr = players[pid]
--print("19",pid,blocks)
@ -298,7 +304,7 @@ network.sys_handle_s2c(PKT_PLR_BLK_COUNT, "BB", function (sockfd, cli, plr, sec_
plr.blocks = blocks
end
end)
network.sys_handle_s2c(PKT_PLR_GUN_TRACER, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PLR_GUN_TRACER, "B", function (neth, cli, plr, sec_current, pid, pkt)
local plr = players[pid]
if plr then
@ -321,7 +327,7 @@ network.sys_handle_s2c(PKT_PLR_GUN_TRACER, "B", function (sockfd, cli, plr, sec_
})
end
end)
network.sys_handle_s2c(PKT_NADE_THROW, "BhhhhhhH", function (sockfd, cli, plr, sec_current, pid,x,y,z,vx,vy,vz,fuse, pkt)
network.sys_handle_s2c(PKT_NADE_THROW, "BhhhhhhH", function (neth, cli, plr, sec_current, pid,x,y,z,vx,vy,vz,fuse, pkt)
local n = new_nade({
x = x/32,
y = y/32,
@ -335,23 +341,23 @@ network.sys_handle_s2c(PKT_NADE_THROW, "BhhhhhhH", function (sockfd, cli, plr, s
client.wav_play_global(wav_whoosh, x, y, z)
nade_add(n)
end)
network.sys_handle_s2c(PKT_MAP_RCIRC, "", function (sockfd, cli, plr, sec_current, pkt)
network.sys_handle_s2c(PKT_MAP_RCIRC, "", function (neth, cli, plr, sec_current, pkt)
local plr = players[players.current]
if plr then
plr.t_rcirc = sec_current + MODE_RCIRC_LINGER
end
end)
network.sys_handle_s2c(PKT_PLR_GUN_RELOAD, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PLR_GUN_RELOAD, "B", function (neth, cli, plr, sec_current, pid, pkt)
local plr = players[pid]
if plr then
client.wav_play_global(wav_rifle_reload, plr.x, plr.y, plr.z)
end
end)
network.sys_handle_s2c(PKT_TEAM_SCORE, "bh", function (sockfd, cli, plr, sec_current, tidx, score, pkt)
network.sys_handle_s2c(PKT_TEAM_SCORE, "bh", function (neth, cli, plr, sec_current, tidx, score, pkt)
teams[tidx].score = score
end)
network.sys_handle_s2c(PKT_BLK_DAMAGE, "HHHH", function (sockfd, cli, plr, sec_current, x, y, z, amt, pkt)
network.sys_handle_s2c(PKT_BLK_DAMAGE, "HHHH", function (neth, cli, plr, sec_current, x, y, z, amt, pkt)
if map_block_get(x, y, z) then
client.wav_play_global(wav_hammer, x, y, z)
bhealth_damage(x, y, z, amt)
@ -359,13 +365,13 @@ network.sys_handle_s2c(PKT_BLK_DAMAGE, "HHHH", function (sockfd, cli, plr, sec_c
client.wav_play_global(wav_swish, x, y, z)
end
end)
network.sys_handle_s2c(PKT_PIANO, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_PIANO, "B", function (neth, cli, plr, sec_current, pid, pkt)
local plr = players[pid]
if plr then
plr.drop_piano()
end
end)
network.sys_handle_s2c(PKT_NADE_PIN, "B", function (sockfd, cli, plr, sec_current, pid, pkt)
network.sys_handle_s2c(PKT_NADE_PIN, "B", function (neth, cli, plr, sec_current, pid, pkt)
local plr = players[pid]
if plr then
client.wav_play_global(wav_pin, plr.x, plr.y, plr.z)
@ -373,24 +379,26 @@ network.sys_handle_s2c(PKT_NADE_PIN, "B", function (sockfd, cli, plr, sec_curren
end)
-- C2S packets
network.sys_handle_c2s(PKT_PLR_POS, "Bhhh", nwdec_plrset(function (sockfd, cli, plr, sec_current, pid, x2, y2, z2, pkt)
network.sys_handle_c2s(PKT_KEEPALIVE, "B", function () end)
network.sys_handle_c2s(PKT_PLR_POS, "Bhhh", nwdec_plrset(function (neth, cli, plr, sec_current, pid, x2, y2, z2, pkt)
local x = x2/32.0
local y = y2/32.0
local z = z2/32.0
plr.set_pos_recv(x, y, z)
net_broadcast(sockfd, common.net_pack("BBhhh",
net_broadcast(neth, common.net_pack("BBhhh",
PKT_PLR_POS, cli.plrid, x2, y2, z2))
end))
network.sys_handle_c2s(PKT_PLR_ORIENT, "BbbB", nwdec_plrset(function (sockfd, cli, plr, sec_current, pid, ya2, xa2, keys, pkt)
network.sys_handle_c2s(PKT_PLR_ORIENT, "BbbB", nwdec_plrset(function (neth, cli, plr, sec_current, pid, ya2, xa2, keys, pkt)
local ya = ya2*math.pi/128
local xa = xa2*math.pi/256
plr.set_orient_recv(ya, xa, keys)
net_broadcast(sockfd, common.net_pack("BBbbB",
net_broadcast(neth, common.net_pack("BBbbB",
PKT_PLR_ORIENT, cli.plrid, ya2, xa2, keys))
end))
network.sys_handle_c2s(PKT_BLK_ADD, "HHHBBBB", nwdec_plrset(function (sockfd, cli, plr, sec_current, x,y,z,cb,cg,cr,ct,pkt)
network.sys_handle_c2s(PKT_BLK_ADD, "HHHBBBB", nwdec_plrset(function (neth, cli, plr, sec_current, x,y,z,cb,cg,cr,ct,pkt)
local xlen,ylen,zlen
xlen,ylen,zlen = common.map_get_dims()
@ -411,7 +419,7 @@ network.sys_handle_c2s(PKT_BLK_ADD, "HHHBBBB", nwdec_plrset(function (sockfd, cl
end
end
end))
network.sys_handle_c2s(PKT_BLK_RM1, "HHH", nwdec_plrset(function (sockfd, cli, plr, sec_current, x,y,z, pkt)
network.sys_handle_c2s(PKT_BLK_RM1, "HHH", nwdec_plrset(function (neth, cli, plr, sec_current, x,y,z, pkt)
local xlen,ylen,zlen
xlen,ylen,zlen = common.map_get_dims()
@ -434,7 +442,7 @@ network.sys_handle_c2s(PKT_BLK_RM1, "HHH", nwdec_plrset(function (sockfd, cli, p
end
end
end))
network.sys_handle_c2s(PKT_BLK_RM3, "HHH", nwdec_plrset(function (sockfd, cli, plr, sec_current, x,y,z, pkt)
network.sys_handle_c2s(PKT_BLK_RM3, "HHH", nwdec_plrset(function (neth, cli, plr, sec_current, x,y,z, pkt)
local xlen,ylen,zlen
xlen,ylen,zlen = common.map_get_dims()
@ -449,13 +457,13 @@ network.sys_handle_c2s(PKT_BLK_RM3, "HHH", nwdec_plrset(function (sockfd, cli, p
end
end
end))
network.sys_handle_c2s(PKT_CHAT_SEND, "z", nwdec_plrset(function (sockfd, cli, plr, sec_current, msg, pkt)
network.sys_handle_c2s(PKT_CHAT_SEND, "z", nwdec_plrset(function (neth, cli, plr, sec_current, msg, pkt)
local s = nil
local usage_colour = 0xFFDDDDFF
if string.sub(msg,1,1) == "/" then
--TODO: Better parameter parsing (param1 "param two" "param \"three\"")
local params = string.split(string.sub(msg,2), " ")
command_handle(plr, cli.plrid, sockfd, params, msg)
command_handle(plr, cli.plrid, neth, params, msg)
else
s = plr.name.." ("..teams[plr.team].name.."): "..msg
-- TODO: use a user-configurable table for these
@ -477,7 +485,7 @@ network.sys_handle_c2s(PKT_CHAT_SEND, "z", nwdec_plrset(function (sockfd, cli, p
net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFFFFFFFF, s))
end
end))
network.sys_handle_c2s(PKT_CHAT_SEND_TEAM, "z", nwdec_plrset(function (sockfd, cli, plr, sec_current, msg, pkt)
network.sys_handle_c2s(PKT_CHAT_SEND_TEAM, "z", nwdec_plrset(function (neth, cli, plr, sec_current, msg, pkt)
local s = nil
if string.sub(msg,1,4) == "/me " then
s = "* "..plr.name.." "..string.sub(msg,5)
@ -491,7 +499,7 @@ network.sys_handle_c2s(PKT_CHAT_SEND_TEAM, "z", nwdec_plrset(function (sockfd, c
net_broadcast_team(plr.team, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, c, s))
end
end))
network.sys_handle_c2s(PKT_CHAT_SEND_SQUAD, "z", nwdec_plrset(function (sockfd, cli, plr, sec_current, msg, pkt)
network.sys_handle_c2s(PKT_CHAT_SEND_SQUAD, "z", nwdec_plrset(function (neth, cli, plr, sec_current, msg, pkt)
if plr.squad then
local s = nil
if string.sub(msg,1,4) == "/me " then
@ -505,7 +513,7 @@ network.sys_handle_c2s(PKT_CHAT_SEND_SQUAD, "z", nwdec_plrset(function (sockfd,
end
end
end))
network.sys_handle_c2s(PKT_PLR_OFFER, "bbz", nwdec_plrset(function (sockfd, cli, plr, sec_current, tidx, wpn, name, pkt)
network.sys_handle_c2s(PKT_PLR_OFFER, "bbz", nwdec_plrset(function (neth, cli, plr, sec_current, tidx, wpn, name, pkt)
name = (name ~= "" and name) or name_generate()
plr.wpn = weapons[wpn](plr)
if plr.team ~= tidx then
@ -524,9 +532,9 @@ network.sys_handle_c2s(PKT_PLR_OFFER, "bbz", nwdec_plrset(function (sockfd, cli,
plr.team, plr.weapon, plr.mode,
plr.score, plr.kills, plr.deaths,
plr.name, plr.squad))
end, function (sockfd, cli, plr, sec_current, tidx, wpn, name, pkt)
end, function (neth, cli, plr, sec_current, tidx, wpn, name, pkt)
name = (name ~= "" and name) or name_generate()
cli.plrid = slot_add(sockfd, tidx, wpn, name)
cli.plrid = slot_add(neth, tidx, wpn, name)
if not cli.plrid then
print("* server full")
-- TODO: kick somehow!
@ -539,18 +547,18 @@ end, function (sockfd, cli, plr, sec_current, tidx, wpn, name, pkt)
for i=1,players.max do
local plr = players[i]
if plr then
net_send(sockfd, common.net_pack("BBBBBhhhzz",
net_send(neth, common.net_pack("BBBBBhhhzz",
PKT_PLR_ADD, i,
plr.team, plr.weapon, plr.mode,
plr.score, plr.kills, plr.deaths,
plr.name, plr.squad))
net_send(sockfd, common.net_pack("BBfffBB",
net_send(neth, common.net_pack("BBfffBB",
PKT_PLR_SPAWN, i,
plr.x, plr.y, plr.z,
plr.angy*128/math.pi, plr.angx*256/math.pi))
net_send(sockfd, common.net_pack("BBB",
net_send(neth, common.net_pack("BBB",
PKT_PLR_TOOL, i, plr.tool))
net_send(sockfd, common.net_pack("BBBBB",
net_send(neth, common.net_pack("BBBBB",
PKT_PLR_BLK_COLOR, i,
plr.blk_color[1],plr.blk_color[2],plr.blk_color[3]))
end
@ -561,18 +569,18 @@ end, function (sockfd, cli, plr, sec_current, tidx, wpn, name, pkt)
local f,x,y,z
x,y,z = intent[i].get_pos()
f = intent[i].get_flags()
net_send(sockfd, common.net_pack("BHhhhB",
net_send(neth, common.net_pack("BHhhhB",
PKT_ITEM_POS, i, x, y, z, f))
local plr = intent[i].player
if plr then
net_send(sockfd, common.net_pack("BHB",
net_send(neth, common.net_pack("BHB",
PKT_ITEM_CARRIER, i, plr.pid))
end
end
-- relay score to this player
for i=0,teams.max do
net_send(sockfd, common.net_pack("Bbh", PKT_TEAM_SCORE, i, teams[i].score))
net_send(neth, common.net_pack("Bbh", PKT_TEAM_SCORE, i, teams[i].score))
end
-- relay this player to everyone
@ -587,14 +595,14 @@ end, function (sockfd, cli, plr, sec_current, tidx, wpn, name, pkt)
plr.angy*128/math.pi, plr.angx*256/math.pi))
-- set player ID
net_send(sockfd, common.net_pack("BB",
net_send(neth, common.net_pack("BB",
PKT_PLR_ID, cli.plrid))
net_broadcast(nil, common.net_pack("BIz", PKT_CHAT_ADD_TEXT, 0xFF800000,
"* Player "..name.." has joined the "..teams[plr.team].name.." team"))
end
end))
network.sys_handle_c2s(PKT_PLR_GUN_HIT, "BB", nwdec_plrset(function (sockfd, cli, plr, sec_current, tpid, styp)
network.sys_handle_c2s(PKT_PLR_GUN_HIT, "BB", nwdec_plrset(function (neth, cli, plr, sec_current, tpid, styp)
local tplr = players[tpid]
if tplr then
if plr.tool == TOOL_GUN and plr.wpn and styp >= 1 and styp <= 3 then
@ -610,24 +618,24 @@ network.sys_handle_c2s(PKT_PLR_GUN_HIT, "BB", nwdec_plrset(function (sockfd, cli
if plr.tool == TOOL_GUN then
-- we don't want the spade spewing tracers!
net_broadcast(sockfd, common.net_pack("BB", PKT_PLR_GUN_TRACER, cli.plrid))
net_broadcast(neth, common.net_pack("BB", PKT_PLR_GUN_TRACER, cli.plrid))
end
end))
network.sys_handle_c2s(PKT_PLR_TOOL, "BB", nwdec_plrset(function (sockfd, cli, plr, sec_current, tpid, tool, pkt)
network.sys_handle_c2s(PKT_PLR_TOOL, "BB", nwdec_plrset(function (neth, cli, plr, sec_current, tpid, tool, pkt)
if plr and tool >= 0 and tool <= 3 then
plr.tool = tool
net_broadcast(sockfd, common.net_pack("BBB"
net_broadcast(neth, common.net_pack("BBB"
, PKT_PLR_TOOL, cli.plrid, tool))
end
end))
network.sys_handle_c2s(PKT_PLR_BLK_COLOR, "BBBB", nwdec_plrset(function (sockfd, cli, plr, sec_current, tpid, cr, cg, cb, pkt)
network.sys_handle_c2s(PKT_PLR_BLK_COLOR, "BBBB", nwdec_plrset(function (neth, cli, plr, sec_current, tpid, cr, cg, cb, pkt)
if plr then
plr.blk_color = {cr,cg,cb}
net_broadcast(sockfd, common.net_pack("BBBBB"
net_broadcast(neth, common.net_pack("BBBBB"
, PKT_PLR_BLK_COLOR, cli.plrid, cr, cg, cb))
end
end))
network.sys_handle_c2s(PKT_NADE_THROW, "hhhhhhH", nwdec_plrset(function (sockfd, cli, plr, sec_current, x, y, z, vx, vy, vz, fuse, pkt)
network.sys_handle_c2s(PKT_NADE_THROW, "hhhhhhH", nwdec_plrset(function (neth, cli, plr, sec_current, x, y, z, vx, vy, vz, fuse, pkt)
if plr.expl.ammo > 0 then
if plr.mode == PLM_NORMAL then
plr.expl.ammo = plr.expl.ammo - 1
@ -643,19 +651,19 @@ network.sys_handle_c2s(PKT_NADE_THROW, "hhhhhhH", nwdec_plrset(function (sockfd,
pid = cli.plrid
})
nade_add(n)
net_broadcast(sockfd, common.net_pack("BBhhhhhhH",
net_broadcast(neth, common.net_pack("BBhhhhhhH",
PKT_NADE_THROW,cli.plrid,x,y,z,vx,vy,vz,fuse))
end
end))
network.sys_handle_c2s(PKT_PLR_GUN_RELOAD, "", nwdec_plrset(function (sockfd, cli, plr, sec_current, pkt)
network.sys_handle_c2s(PKT_PLR_GUN_RELOAD, "", nwdec_plrset(function (neth, cli, plr, sec_current, pkt)
-- TODO: actually reload with serverside counts
net_broadcast(sockfd, common.net_pack("BB", PKT_PLR_GUN_RELOAD, cli.plrid))
net_broadcast(neth, common.net_pack("BB", PKT_PLR_GUN_RELOAD, cli.plrid))
end))
network.sys_handle_c2s(PKT_BLK_DAMAGE, "HHHH", nwdec_plrset(function (sockfd, cli, plr, sec_current, x, y, z, amt, pkt)
network.sys_handle_c2s(PKT_BLK_DAMAGE, "HHHH", nwdec_plrset(function (neth, cli, plr, sec_current, x, y, z, amt, pkt)
net_broadcast(nil, common.net_pack("BHHHH", PKT_BLK_DAMAGE, x, y, z, amt))
bhealth_damage(x, y, z, amt, plr)
end))
network.sys_handle_c2s(PKT_NADE_PIN, "", nwdec_plrset(function (sockfd, cli, plr, sec_current, pkt)
net_broadcast(sockfd, common.net_pack("BB", PKT_NADE_PIN, cli.plrid))
network.sys_handle_c2s(PKT_NADE_PIN, "", nwdec_plrset(function (neth, cli, plr, sec_current, pkt)
net_broadcast(neth, common.net_pack("BB", PKT_NADE_PIN, cli.plrid))
end))

View File

@ -31,6 +31,7 @@ end
-- network throttling
NET_FLUSH_C2S = 0.05
NET_FLUSH_S2C = 0.1
NET_MAX_LAG = 15.0
-- base dir stuff
DIR_PKG_ROOT = DIR_PKG_ROOT or "pkg/base"

View File

@ -16,9 +16,9 @@
]]
VERSION_ENGINE = {
cmp={0,0,0,0,52},
num=52,
str="0.0-52",
cmp={0,0,0,0,53},
num=53,
str="0.0-53",
}
VERSION_BUGS = {
@ -79,5 +79,8 @@ VERSION_BUGS = {
{intro=nil, fix=50, msg="Network handle architecture changed. If it breaks, upgrade. If your mods break, FIX THEM."},
{intro=nil, fix=51, msg="ENet protocol not supported"},
{intro=51, fix=52, msg="Server tends to crash when a TCP connection loads and there's at least one other client still connected"},
{intro=51, fix=53, msg="Local mode (-s) broken and causes a crash"},
{intro=nil, fix=53, msg="Timing accuracy somewhat bad (uses a float instead of a double, mostly an issue for sec_current)"},
{intro=nil, fix=53, msg="There are some weird network stability issues"},
}

View File

@ -346,7 +346,7 @@ int icelua_fn_common_net_recv(lua_State *L)
{
if(to_server.head != NULL && (to_server.head->data[0] < 0x40 || (unsigned char)(to_server.head->data[0]) > 0x7F))
{
fprintf(stderr, "BUG EVASION: system packet hit common.net_recv. Returning nil.\n");
//fprintf(stderr, "BUG EVASION: system packet hit common.net_recv. Returning nil.\n");
return 0;
}

View File

@ -173,10 +173,10 @@ int64_t frame_prev = 0;
int64_t frame_now = 0;
int fps = 0;
float sec_curtime = 0.0f;
float sec_lasttime = 0.0f;
float sec_wait = 0.0f;
float sec_serv_wait = 0.0f;
double sec_curtime = 0.0;
double sec_lasttime = 0.0;
double sec_wait = 0.0;
double sec_serv_wait = 0.0;
float ompx = -M_PI, ompy = -M_PI, ompz = -M_PI;
@ -487,7 +487,7 @@ int run_game_cont1(void)
// update time
sec_lasttime = sec_curtime;
int64_t usec_curtime = platform_get_time_usec() - usec_basetime;
sec_curtime = ((float)usec_curtime)/1000000.0f;
sec_curtime = ((double)usec_curtime)/1000000.0;
// update client/server
quitflag = quitflag || update_client_contpre1();
@ -505,7 +505,7 @@ int run_game_cont2(void)
// update time
sec_lasttime = sec_curtime;
int64_t usec_curtime = platform_get_time_usec() - usec_basetime;
sec_curtime = ((float)usec_curtime)/1000000.0f;
sec_curtime = ((double)usec_curtime)/1000000.0;
return quitflag;
}
@ -541,7 +541,7 @@ void run_game(void)
// update time
sec_lasttime = sec_curtime;
int64_t usec_curtime = platform_get_time_usec() - usec_basetime;
sec_curtime = ((float)usec_curtime)/1000000.0f;
sec_curtime = ((double)usec_curtime)/1000000.0;
// update client/server
#ifndef DEDI

View File

@ -159,9 +159,10 @@ int net_packet_push(int len, const char *data, int neth, packet_t **head, packet
if(cli == NULL)
{
fprintf(stderr, "PANIC: NULL client in packet pusher!\n");
fflush(stderr);
abort();
fprintf(stderr, "Note: NULL client in packet pusher, ignoring\n");
return 0;
//fflush(stderr);
//abort();
}
if(cli->sockfd == SOCKFD_ENET)
@ -1467,6 +1468,7 @@ void net_flush(void)
net_flush_accept();
// parse ENet crap
if(server_host != NULL)
for(;;)
{
err = enet_host_service(server_host, &ev, 0);

View File

@ -1,6 +1,6 @@
#!/bin/sh
export ZIPNAME=nubdist/iceballfornoobs-0.0-51.zip
export ZIPNAME=nubdist/iceballfornoobs-0.0-53.zip
#zip -r $ZIPNAME *.dll *.exe *.txt *.bat docs/ \
# pkg/base/*.lua \