diff --git a/res/scripts/stdlib.lua b/res/scripts/stdlib.lua index c9f38835..71ba2f4f 100644 --- a/res/scripts/stdlib.lua +++ b/res/scripts/stdlib.lua @@ -413,15 +413,9 @@ end local __vc_coroutines = {} local __vc_named_coroutines = {} local __vc_next_coroutine = 1 -local __vc_coroutine_error = nil function __vc_start_coroutine(chunk) - local co = coroutine.create(function() - local status, err = pcall(chunk) - if not status then - __vc_coroutine_error = err - end - end) + local co = coroutine.create(chunk) local id = __vc_next_coroutine __vc_next_coroutine = __vc_next_coroutine + 1 __vc_coroutines[id] = co @@ -431,10 +425,10 @@ end function __vc_resume_coroutine(id) local co = __vc_coroutines[id] if co then - coroutine.resume(co) - if __vc_coroutine_error then - debug.error(__vc_coroutine_error) - error(__vc_coroutine_error) + local success, err = coroutine.resume(co) + if not success then + debug.error(err) + error(err) end return coroutine.status(co) ~= "dead" end diff --git a/res/shaders/main.glslf b/res/shaders/main.glslf index 4992c36b..12e96eab 100644 --- a/res/shaders/main.glslf +++ b/res/shaders/main.glslf @@ -20,6 +20,9 @@ void main() { if (alpha < 0.2f) discard; alpha = 1.0; + } else { + if (alpha < 0.002f) + discard; } f_color = mix(a_color * tex_color, vec4(fogColor,1.0), min(1.0, pow(depth*u_fogFactor, u_fogCurve))); diff --git a/src/coders/lua_parsing.cpp b/src/coders/lua_parsing.cpp index f30aab37..3c0d3a53 100644 --- a/src/coders/lua_parsing.cpp +++ b/src/coders/lua_parsing.cpp @@ -113,8 +113,9 @@ public: auto start = currentLocation(); if (is_lua_identifier_start(c)) { auto name = parseLuaName(); + TokenTag tag = (is_lua_keyword(name) ? TokenTag::KEYWORD : TokenTag::NAME); emitToken( - is_lua_keyword(name) ? TokenTag::KEYWORD : TokenTag::NAME, + tag, std::move(name), start ); diff --git a/src/logic/scripting/lua/libs/libnetwork.cpp b/src/logic/scripting/lua/libs/libnetwork.cpp index d1edf185..304cf5c8 100644 --- a/src/logic/scripting/lua/libs/libnetwork.cpp +++ b/src/logic/scripting/lua/libs/libnetwork.cpp @@ -89,7 +89,8 @@ static int l_closeserver(lua::State* L) { static int l_send(lua::State* L) { u64id_t id = lua::tointeger(L, 1); auto connection = engine->getNetwork().getConnection(id); - if (connection == nullptr) { + if (connection == nullptr || + connection->getState() == network::ConnectionState::CLOSED) { return 0; } if (lua::istable(L, 2)) { @@ -167,7 +168,9 @@ static int l_is_alive(lua::State* L) { u64id_t id = lua::tointeger(L, 1); if (auto connection = engine->getNetwork().getConnection(id)) { return lua::pushboolean( - L, connection->getState() != network::ConnectionState::CLOSED + L, + connection->getState() != network::ConnectionState::CLOSED || + connection->available() > 0 ); } return lua::pushboolean(L, false); diff --git a/src/logic/scripting/lua/lua_util.cpp b/src/logic/scripting/lua/lua_util.cpp index 842c7859..d008cf45 100644 --- a/src/logic/scripting/lua/lua_util.cpp +++ b/src/logic/scripting/lua/lua_util.cpp @@ -270,12 +270,13 @@ scripting::common_func lua::create_lambda(State* L) { return [=](const std::vector& args) -> dv::value { if (!get_from(L, LAMBDAS_TABLE, *funcptr, false)) return nullptr; - int top = gettop(L) + 1; + int top = gettop(L) - 1; for (const auto& arg : args) { pushvalue(L, arg); } if (call(L, args.size(), 1)) { int nres = gettop(L) - top; + assert(nres >= 0); if (nres) { auto result = tovalue(L, -1); pop(L, 1 + nres);