mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 09:59:44 +00:00
fix potential fatal errors
This commit is contained in:
parent
6f466d52f2
commit
f246619c6b
3 changed files with 10 additions and 2 deletions
|
|
@ -266,8 +266,10 @@ static int l_peek(lua::State* L, network::Network& network) {
|
|||
static int l_available(lua::State* L, network::Network& network) {
|
||||
u64id_t id = lua::tointeger(L, 1);
|
||||
|
||||
if (auto connection = network.getConnection(id, false)) {
|
||||
return lua::pushinteger(L, dynamic_cast<network::TcpConnection*>(connection)->available());
|
||||
if (auto connection = dynamic_cast<network::ReadableConnection*>(
|
||||
network.getConnection(id, false)
|
||||
)) {
|
||||
return lua::pushinteger(L, connection->available());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue