fix net hold/unhold

This commit is contained in:
devsaurus 2018-10-20 22:58:57 +02:00
parent 3fb2c7d402
commit 7ded3960eb
1 changed files with 11 additions and 5 deletions

View File

@ -677,10 +677,13 @@ int net_hold( lua_State *L ) {
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
if (!ud->client.hold && ud->netconn)
{
if (ud->client.hold == 0)
{
ud->client.hold = 1;
ud->client.num_held = 0;
}
}
return 0;
}
@ -690,9 +693,13 @@ int net_unhold( lua_State *L ) {
if (!ud || ud->type != TYPE_TCP_CLIENT)
return luaL_error(L, "invalid user data");
if (ud->client.hold && ud->netconn)
{
if (ud->client.hold != 0)
{
ud->client.hold = 0;
netconn_recved(ud->netconn, ud->client.num_held);
ud->client.num_held = 0;
}
}
return 0;
}
@ -1130,7 +1137,6 @@ static void lrecv_cb (lua_State *L, lnet_userdata *ud) {
if (ud->type == TYPE_TCP_CLIENT) {
if (ud->client.hold) {
netconn_recved(ud->netconn, 0);
ud->client.num_held += len;
} else {
netconn_recved(ud->netconn, len);