[0.0-49] kicks are handled gracefully now; server can kick from the lua side; framework starting to be laid for ENet support

This commit is contained in:
Ben Russell (300178622) 2013-06-23 15:50:29 +12:00
parent d03c7bb51a
commit 087cfd1cea
16 changed files with 203 additions and 46 deletions

View File

@ -12,11 +12,12 @@ HEADERS_Lua = #-I /usr/include/lua5.1
LDFLAGS = -pg -g $(LDFLAGS_EXTRA) -fopenmp LDFLAGS = -pg -g $(LDFLAGS_EXTRA) -fopenmp
LIBS_SDL = `sdl-config --libs` LIBS_SDL = `sdl-config --libs`
LIBS_ENet = xlibinc/libenet.a
LIBS_Lua = -llua LIBS_Lua = -llua
# Lua is not an acronym. Get used to typing it with lower case u/a. # Lua is not an acronym. Get used to typing it with lower case u/a.
LIBS_zlib = -lz LIBS_zlib = -lz
LIBS_sackit = -lsackit LIBS_sackit = -lsackit
LIBS = -Lxlibinc -lm $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_sackit) LIBS = -Lxlibinc -lm $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_sackit) $(LIBS_ENet)
BINNAME = iceball BINNAME = iceball

View File

@ -10,11 +10,12 @@ CFLAGS = -DDEDI -pg -O2 -fno-strict-aliasing -g -Wall -Wextra \
HEADERS_Lua = HEADERS_Lua =
LDFLAGS = -pg -g -fopenmp $(LDFLAGS_EXTRA) LDFLAGS = -pg -g -fopenmp $(LDFLAGS_EXTRA)
LIBS_ENet = xlibinc/libenet.a
LIBS_Lua = -llua LIBS_Lua = -llua
# Lua is not an acronym. Get used to typing it with lower case u/a. # Lua is not an acronym. Get used to typing it with lower case u/a.
LIBS_zlib = -lz LIBS_zlib = -lz
LIBS_sackit = -lsackit LIBS_sackit = -lsackit
LIBS = -Lxlibinc/ -lm $(LIBS_Lua) $(LIBS_zlib) $(LIBS_sackit) LIBS = -Lxlibinc/ -lm $(LIBS_Lua) $(LIBS_zlib) $(LIBS_sackit) $(LIBS_ENet)
BINNAME = dedi_iceball BINNAME = dedi_iceball
OBJDIR = build/dedi OBJDIR = build/dedi

View File

@ -7,6 +7,8 @@
# - Stash Lua includes in winlibs/*.h. # - Stash Lua includes in winlibs/*.h.
# - lua.h, lualib.h, lauxlib.h, luaconf.h # - lua.h, lualib.h, lauxlib.h, luaconf.h
# - Stash sackit.h and libsackit.a in winlibs/. # - Stash sackit.h and libsackit.a in winlibs/.
# - Stash libenet.a in winlibs/.
# - Stash ENet includes from enet/*.h in winlibs/enet/*.h.
# #
CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \ CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \
@ -20,12 +22,13 @@ CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \
LDFLAGS = -g $(LDFLAGS_EXTRA) LDFLAGS = -g $(LDFLAGS_EXTRA)
LIBS_SDL = -lSDLmain -lSDL LIBS_SDL = -lSDLmain -lSDL
LIBS_ENet = winlibs/libenet.a
LIBS_Lua = -llua LIBS_Lua = -llua
LIBS_Winsuck = -lws2_32 LIBS_Winsuck = -lws2_32
# Lua is not an acronym. Get used to typing it with lower case u/a. # Lua is not an acronym. Get used to typing it with lower case u/a.
LIBS_zlib = -lz LIBS_zlib = -lz
LIBS_sackit = -lsackit LIBS_sackit = -lsackit
LIBS = -Lwinlibs -lm -lmingw32 $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_Winsuck) $(LIBS_sackit) ./glew32.dll -lopengl32 LIBS = -Lwinlibs -lm -lmingw32 $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_Winsuck) $(LIBS_sackit) ./glew32.dll -lopengl32 $(LIBS_ENet)
BINNAME = iceball-gl.exe BINNAME = iceball-gl.exe
RENDERER = gl RENDERER = gl

View File

@ -7,6 +7,8 @@
# - Stash Lua includes in winlibs/*.h. # - Stash Lua includes in winlibs/*.h.
# - lua.h, lualib.h, lauxlib.h, luaconf.h # - lua.h, lualib.h, lauxlib.h, luaconf.h
# - Stash sackit.h and libsackit.a in winlibs/. # - Stash sackit.h and libsackit.a in winlibs/.
# - Stash libenet.a in winlibs/.
# - Stash ENet includes from enet/*.h in winlibs/enet/*.h.
# #
CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \ CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \
@ -20,12 +22,13 @@ CFLAGS = -O2 -fno-strict-aliasing -g -Wall -Wextra \
LDFLAGS = -g -fopenmp $(LDFLAGS_EXTRA) LDFLAGS = -g -fopenmp $(LDFLAGS_EXTRA)
LIBS_SDL = -lSDLmain -lSDL LIBS_SDL = -lSDLmain -lSDL
LIBS_ENet = winlibs/libenet.a
LIBS_Lua = -llua LIBS_Lua = -llua
LIBS_Winsuck = -lws2_32 LIBS_Winsuck = -lws2_32
# Lua is not an acronym. Get used to typing it with lower case u/a. # Lua is not an acronym. Get used to typing it with lower case u/a.
LIBS_zlib = -lz LIBS_zlib = -lz
LIBS_sackit = -lsackit LIBS_sackit = -lsackit
LIBS = -Lwinlibs -lm -lmingw32 $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_Winsuck) $(LIBS_sackit) LIBS = -Lwinlibs -lm -lmingw32 $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_Winsuck) $(LIBS_sackit) $(LIBS_ENet)
BINNAME = iceball.exe BINNAME = iceball.exe
OBJDIR = build/mingw32 OBJDIR = build/mingw32

View File

@ -12,11 +12,12 @@ HEADERS_Lua = #-I /usr/include/lua5.1
LDFLAGS = -pg -g $(LDFLAGS_EXTRA) LDFLAGS = -pg -g $(LDFLAGS_EXTRA)
LIBS_SDL = `sdl-config --libs` LIBS_SDL = `sdl-config --libs`
LIBS_ENet = xlibinc/libenet.a
LIBS_Lua = -llua LIBS_Lua = -llua
# Lua is not an acronym. Get used to typing it with lower case u/a. # Lua is not an acronym. Get used to typing it with lower case u/a.
LIBS_zlib = -lz LIBS_zlib = -lz
LIBS_sackit = -lsackit LIBS_sackit = -lsackit
LIBS = -Lxlibinc -lm $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_sackit) -lGL -lGLEW LIBS = -Lxlibinc -lm $(LIBS_Lua) $(LIBS_SDL) $(LIBS_zlib) $(LIBS_sackit) -lGL -lGLEW $(LIBS_ENet)
BINNAME = iceball-gl BINNAME = iceball-gl
RENDERER = gl RENDERER = gl

View File

@ -1,19 +1,12 @@
GUYS GUYS GUYS GUYS GUYS GUYS
FIRST THING YOU NEED TO READ: FIRST THING YOU NEED TO READ:
docs/READ_THIS_FIRST.txt might work. 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: If not, there's a tutorial on the forums:
http://iceballga.me http://iceballga.me
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
This is FINALLY a game, BUT is not ready to be released yet.
NOTE:
By Stack's request, this project is now known as "Iceball".
mesa.vxl is by Triplefox, and is currently being used to test load/render.
LICENSING NOTES: LICENSING NOTES:
Iceball is licensed under the regular GNU GPL version 3. Iceball is licensed under the regular GNU GPL version 3.
Ice Lua Components is licensed under the LGPL version 3. Ice Lua Components is licensed under the LGPL version 3.
@ -42,6 +35,7 @@ REQUIREMENTS:
- zlib - http://zlib.net/ - zlib - http://zlib.net/
- sackit - https://github.com/iamgreaser/sackit/ - sackit - https://github.com/iamgreaser/sackit/
- you should copy libsackit.a and sackit.h to xlibinc. - you should copy libsackit.a and sackit.h to xlibinc.
- enet 1.3 - http://enet.bespin.org/
- GNU make - GNU make
- if someone has BSD make, please tell us :) - if someone has BSD make, please tell us :)
@ -52,10 +46,10 @@ STUFF TO DO BEFORE 0.1 CAN BE RELEASED:
- make kicking not suck - make kicking not suck
MSVC readme (wip): MSVC readme (wip):
- create a folder 'winlibs' in the buldenthesnip dir - create a folder 'winlibs' in the iceball dir
dump all dll's + lib's in this folder (opengl,lua,zlib, sdl, glew) dump all dll's + lib's in this folder (opengl,lua,zlib, sdl, glew)
dump all includes in submaps (glew in glew submap, and so on) dump all includes in submaps (glew in glew submap, and so on)
/buldenthesnip/ /iceball/
/winlibs/ /winlibs/
/glew/ /glew/
/lua/ /lua/
@ -79,7 +73,7 @@ for the git starters:
- git update-index --assume-unchanged clsave\pub\user.json - git update-index --assume-unchanged clsave\pub\user.json
and to get updates from the main repo: and to get updates from the main repo:
- git remote add upstream git://github.com/iamgreaser/buldthensnip.git - git remote add upstream git://github.com/iamgreaser/iceball.git
- git pull --rebase upstream master - git pull --rebase upstream master
- git push origin master - git push origin master

View File

@ -520,22 +520,36 @@ success = common.net_send(sockfd, str) @
"sockfd" is ignored C->S and should be nil "sockfd" is ignored C->S and should be nil
S->C local multiplayer should set "sockfd" to "true" S->C local multiplayer should set "sockfd" to "true"
COMPATIBILITY WARNING:
[ writing this before I actually do it --GM ]
before 0.0-50, sockfd pertains to an ACTUAL sockfd.
from 0.0-50 onwards, sockfd pertains to a CLIENT HANDLE.
this should not be of any concern to you unless you do Really Stupid Stuff.
having said that, DO NOT EXPECT THIS TO BE A ONE-TO-ONE MAPPING TO CLIENT INDICES.
oh, and as expected, same applies to common.net_recv and every other case you see a sockfd.
str, sockfd = common.net_recv() @ str, sockfd = common.net_recv() @
receives a packet receives a packet
for C->S "sockfd" is nil for C->S "sockfd" is nil
S->C local multiplayer will result in "sockfd" being "true" S->C local multiplayer will result in "sockfd" being "true"
returns nil if nothing is there returns nil, nil if nothing is there
returns false, nil on the client if the connection was terminated
server.net_kick(sockfd, reason) server.net_kick(sockfd, reason) @
kicks a client from the server kicks a client from the server
fails silently if sockfd is invalid, fails silently if sockfd is invalid (but still a plausible parameter),
or sockfd is closed / errors out or sockfd is closed / errors out
throws a lua error for other weird errors. throws a lua error for other weird errors.
client.hook_kick = fn(reason) @
sets a hook called when the player gets kicked
wav = common.wav_load(fname) @ wav = common.wav_load(fname) @
loads a sound with filename "fname" loads a sound with filename "fname"
remember to free it when you're done remember to free it when you're done

View File

@ -19,7 +19,7 @@
#define VERSION_X 0 #define VERSION_X 0
#define VERSION_Y 0 #define VERSION_Y 0
#define VERSION_A 0 #define VERSION_A 0
#define VERSION_Z 48 #define VERSION_Z 49
// Remember to bump "Z" basically every time you change the engine! // Remember to bump "Z" basically every time you change the engine!
// Remember to bump the version in Lua too! // Remember to bump the version in Lua too!
// Remember to document API changes in a new version! // Remember to document API changes in a new version!
@ -76,6 +76,8 @@ typedef unsigned __int64 uint64_t;
#include <math.h> #include <math.h>
#include <enet/enet.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -108,6 +110,9 @@ extern "C" {
// just so we can get getaddrinfo // just so we can get getaddrinfo
// you will need Windows 2000 at least! // you will need Windows 2000 at least!
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
#include <windows.h> #include <windows.h>
#include <winsock2.h> #include <winsock2.h>
@ -355,10 +360,14 @@ struct packet
typedef struct client typedef struct client
{ {
// legacy proto only
packet_t *head, *tail; packet_t *head, *tail;
packet_t *send_head, *send_tail; packet_t *send_head, *send_tail;
int sockfd; int sockfd;
int isfull; int isfull;
// enet proto only
ENetPeer *peer;
// client only // client only
char *cfetch_ubuf; char *cfetch_ubuf;
@ -374,7 +383,7 @@ typedef struct client
int sfetch_cpos; int sfetch_cpos;
int sfetch_udtype; int sfetch_udtype;
// serialisation // serialisation - legacy proto only
char rpkt_buf[PACKET_LEN_MAX*2]; char rpkt_buf[PACKET_LEN_MAX*2];
int rpkt_len; int rpkt_len;
char spkt_buf[PACKET_LEN_MAX*2]; char spkt_buf[PACKET_LEN_MAX*2];
@ -384,6 +393,7 @@ typedef struct client
#define SOCKFD_NONE -1 #define SOCKFD_NONE -1
#define SOCKFD_LOCAL -2 #define SOCKFD_LOCAL -2
#define SOCKFD_ENET -3
enum enum
{ {
@ -498,6 +508,8 @@ int net_packet_push(int len, const char *data, int sockfd, packet_t **head, pack
int net_packet_push_lua(int len, const char *data, int sockfd, packet_t **head, packet_t **tail); int net_packet_push_lua(int len, const char *data, int sockfd, packet_t **head, packet_t **tail);
packet_t *net_packet_pop(packet_t **head, packet_t **tail); packet_t *net_packet_pop(packet_t **head, packet_t **tail);
void net_packet_free(packet_t *pkt, packet_t **head, packet_t **tail); void net_packet_free(packet_t *pkt, packet_t **head, packet_t **tail);
void net_kick_sockfd_immediate(int sockfd, const char *msg);
void net_kick_client_immediate(client_t *cli, const char *msg);
void net_flush(void); void net_flush(void);
int net_connect(void); int net_connect(void);
void net_disconnect(void); void net_disconnect(void);

View File

@ -858,6 +858,27 @@ client.hook_mouse_button = h_mouse_button
client.hook_mouse_motion = h_mouse_motion client.hook_mouse_motion = h_mouse_motion
client.hook_window_activate = h_window_activate client.hook_window_activate = h_window_activate
function client.hook_kick(reason)
print("Kicked - "..reason)
function client.hook_tick()
client.mouse_lock_set(false)
client.mouse_visible_set(true)
return 0.01
end
local old_render = client.hook_render
local new_render = nil
function new_render_fn(...)
client.hook_render = old_render
local ret = client.hook_render(...)
old_render = client.hook_render
client.hook_render = new_render
font_large.print(30, 30, 0xFFAA0000, "KICKED")
font_mini.print(30, 65, 0xFFAA0000, reason)
end
new_render = new_render_fn
client.hook_render = new_render
end
print("pkg/base/client_start.lua loaded.") print("pkg/base/client_start.lua loaded.")
--dofile("pkg/base/plug_snow.lua") --dofile("pkg/base/plug_snow.lua")

View File

@ -82,6 +82,16 @@ command_register({
end end
}) })
-- for testing. not like it can be abused. well, i hope it can't be abused. --GM
command_register({
command = "kickme",
permission = nil,
usage = "/kickme",
func = function(plr, plrid, sockfd, prms, msg)
server.net_kick(sockfd, "requested!")
end
})
command_register({ command_register({
command = "me", command = "me",
permission = "me", permission = "me",

View File

@ -15,6 +15,16 @@
along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>. along with Ice Lua Components. If not, see <http://www.gnu.org/licenses/>.
]] ]]
function client.hook_kick(reason)
print("Kicked - "..reason)
function client.hook_tick()
error("Kicked - "..reason)
end
function client.hook_render()
error("Kicked - "..reason)
end
end
dofile("pkg/base/preconf.lua") dofile("pkg/base/preconf.lua")
-- if you don't want music, set FILE_MUSIC to "true". -- if you don't want music, set FILE_MUSIC to "true".

View File

@ -16,9 +16,9 @@
]] ]]
VERSION_ENGINE = { VERSION_ENGINE = {
cmp={0,0,0,0,48}, cmp={0,0,0,0,49},
num=48, num=49,
str="0.0-48", str="0.0-49",
} }
VERSION_BUGS = { VERSION_BUGS = {
@ -74,5 +74,7 @@ VERSION_BUGS = {
{renderer="gl", intro=nil, fix=48, msg="[OpenGL] Chunk count is static and does not adapt to different fog values"}, {renderer="gl", intro=nil, fix=48, msg="[OpenGL] Chunk count is static and does not adapt to different fog values"},
{intro=nil, fix=48, msg="No way to determine from the Lua end what renderer a client is using"}, {intro=nil, fix=48, msg="No way to determine from the Lua end what renderer a client is using"},
{renderer="gl", intro=nil, fix=48, msg="[OpenGL] Chunk generation pattern kinda sucks"}, {renderer="gl", intro=nil, fix=48, msg="[OpenGL] Chunk generation pattern kinda sucks"},
{intro=nil, fix=49, msg="Kick not handled gracefully"},
{intro=49, fix=nil, msg="Kick message isn't communicated properly"},
} }

View File

@ -166,6 +166,7 @@ struct icelua_entry icelua_common_client[] = {
#endif #endif
struct icelua_entry icelua_common_server[] = { struct icelua_entry icelua_common_server[] = {
{icelua_fn_server_net_kick, "net_kick"},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -370,7 +370,14 @@ int icelua_fn_common_net_recv(lua_State *L)
} else { } else {
packet_t *pkt = net_packet_pop(&(to_client_local.head), &(to_client_local.tail)); packet_t *pkt = net_packet_pop(&(to_client_local.head), &(to_client_local.tail));
if(pkt == NULL) if(pkt == NULL)
{
if(to_client_local.sockfd == SOCKFD_NONE)
{
lua_pushboolean(L, 0);
return 1;
}
return 0; return 0;
}
if(pkt->data[0] >= 0x40 && pkt->data[0] <= 0x7E) if(pkt->data[0] >= 0x40 && pkt->data[0] <= 0x7E)
lua_pushlstring(L, &pkt->data[1], pkt->len-1); lua_pushlstring(L, &pkt->data[1], pkt->len-1);
@ -386,3 +393,30 @@ int icelua_fn_common_net_recv(lua_State *L)
return 2; return 2;
} }
} }
int icelua_fn_server_net_kick(lua_State *L)
{
int top = icelua_assert_stack(L, 2, 2);
const char *msg = lua_tostring(L, 2);
if(msg == NULL)
return luaL_error(L, "not a string");
if(lua_isboolean(L, 1) && lua_toboolean(L, 1))
{
// local player kick
net_kick_sockfd_immediate(SOCKFD_LOCAL, msg);
} else if(lua_isnumber(L, 1)) {
// remote player kick
int sockfd = lua_tointeger(L, 1);
if(sockfd >= 0)
net_kick_sockfd_immediate(sockfd, msg);
else
return luaL_error(L, "invalid sockfd");
} else {
return luaL_error(L, "invalid sockfd");
}
return 0;
}

View File

@ -33,8 +33,10 @@ int setsockopt( SOCKET s, int level, int optname, void* optval, int optlen )
#endif #endif
#endif #endif
int server_sockfd_ipv4 = -1; int server_sockfd_ipv4 = SOCKFD_NONE;
int server_sockfd_ipv6 = -1; int server_sockfd_ipv6 = SOCKFD_NONE;
ENetPeer *server_peer;
ENetPeer *client_peer;
client_t to_server; client_t to_server;
client_t to_client_local; client_t to_client_local;
@ -238,15 +240,20 @@ void net_packet_free(packet_t *pkt, packet_t **head, packet_t **tail)
void net_deinit_client(client_t *cli) void net_deinit_client(client_t *cli)
{ {
while(cli->head != NULL) if(cli->sockfd == SOCKFD_ENET)
net_packet_free(cli->head, &(cli->head), &(cli->tail)); {
while(cli->send_head != NULL) // TODO: disconnect properly
net_packet_free(cli->send_head, &(cli->send_head), &(cli->send_tail)); } else {
while(cli->head != NULL)
net_packet_free(cli->head, &(cli->head), &(cli->tail));
while(cli->send_head != NULL)
net_packet_free(cli->send_head, &(cli->send_head), &(cli->send_tail));
}
cli->sockfd = -1; cli->sockfd = SOCKFD_NONE;
} }
void net_kick_sockfd_immediate(int sockfd, char *msg) void net_kick_sockfd_immediate(int sockfd, const char *msg)
{ {
char buf[260]; char buf[260];
buf[0] = 0x17; buf[0] = 0x17;
@ -283,27 +290,54 @@ void net_kick_sockfd_immediate(int sockfd, char *msg)
lua_pop(lstate_server, 1); lua_pop(lstate_server, 1);
} }
} }
// nuke it // if sockfd is local, then send the kick message to the local client
close(sockfd); if(sockfd == SOCKFD_LOCAL)
{
net_kick_client_immediate(&to_client_local, msg);
} else {
// otherwise, nuke it
close(sockfd);
}
} }
void net_kick_client_immediate(client_t *cli, char *msg) void net_kick_client_immediate(client_t *cli, const char *msg)
{ {
if(cli == &to_client_local) if(cli == &to_client_local)
{ {
fprintf(stderr, "KICK: local \"%s\"\n", msg); fprintf(stderr, "KICK: local \"%s\"\n", msg);
fprintf(stderr, "PANIC: I don't know how to handle a local client kick yet!\n"); if(cli->sockfd == SOCKFD_NONE)
fflush(stderr); // we shouldn't reach here, but we might as well fail silently for now
abort(); // we might as well find out why people's comps are breaking if this ever DOES occur
return;
lua_getglobal(lstate_client, "client");
lua_getfield(lstate_client, -1, "hook_kick");
lua_remove(lstate_client, -2);
if(lua_isnil(lstate_client, -1))
{
lua_pop(lstate_client, 1);
} else {
lua_pushstring(lstate_client, msg);
if(lua_pcall(lstate_client, 1, 0, 0) != 0)
{
fprintf(stderr, "ERROR running client Lua (hook_kick): %s\n"
, lua_tostring(lstate_client, -1));
lua_pop(lstate_client, 1);
}
}
} }
if(cli == NULL) if(cli == NULL)
return; return;
net_kick_sockfd_immediate(cli->sockfd, msg); cli->sockfd = SOCKFD_NONE;
cli->sockfd = -1; if(cli != &to_client_local)
net_deinit_client(cli); {
net_kick_sockfd_immediate(cli->sockfd, msg);
net_deinit_client(cli);
}
} }
const char *net_aux_gettype_str(int ftype) const char *net_aux_gettype_str(int ftype)
@ -631,6 +665,16 @@ void net_eat_s2c(client_t *cli)
net_packet_free(pkt, &(cli->head), &(cli->tail)); net_packet_free(pkt, &(cli->head), &(cli->tail));
} break; } break;
case 0x17: {
if(pkt->data[pkt->len-1] != '\x00')
{
fprintf(stderr, "ERROR: string not zero-terminated!\n");
} else {
net_kick_client_immediate(&to_client_local, &(pkt->data[2]));
}
net_packet_free(pkt, &(cli->head), &(cli->tail));
} break;
case 0x31: { case 0x31: {
// 0x31 clen.u32 ulen.u32: // 0x31 clen.u32 ulen.u32:
// file transfer initiation // file transfer initiation
@ -1109,6 +1153,9 @@ void net_flush_accept(void)
void net_flush_snr(client_t *cli) void net_flush_snr(client_t *cli)
{ {
if(cli->sockfd == SOCKFD_NONE)
return;
if(cli == &to_client_local) if(cli == &to_client_local)
{ {
if(boot_mode & 2) if(boot_mode & 2)
@ -1537,16 +1584,19 @@ int net_init(void)
for(i = 0; i < CLIENT_MAX; i++) for(i = 0; i < CLIENT_MAX; i++)
{ {
to_clients[i].sockfd = -1; to_clients[i].sockfd = SOCKFD_NONE;
to_clients[i].peer = NULL;
to_clients[i].head = to_clients[i].tail = NULL; to_clients[i].head = to_clients[i].tail = NULL;
to_clients[i].send_head = to_clients[i].send_tail = NULL; to_clients[i].send_head = to_clients[i].send_tail = NULL;
} }
to_server.sockfd = -1; to_server.sockfd = SOCKFD_NONE;
to_server.peer = NULL;
to_server.head = to_server.tail = NULL; to_server.head = to_server.tail = NULL;
to_server.send_head = to_server.send_tail = NULL; to_server.send_head = to_server.send_tail = NULL;
to_client_local.sockfd = -1; to_client_local.sockfd = SOCKFD_NONE;
to_client_local.peer = NULL;
to_client_local.head = to_client_local.tail = NULL; to_client_local.head = to_client_local.tail = NULL;
to_client_local.send_head = to_client_local.send_tail = NULL; to_client_local.send_head = to_client_local.send_tail = NULL;

View File

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