Hackfix for garrysmod-issues#5134

This commit is contained in:
William Venner 2022-01-04 21:56:23 +00:00
parent 09cded3b38
commit 2d8e53b0f9
1 changed files with 5 additions and 0 deletions

View File

@ -239,7 +239,12 @@ impl LuaState {
}
pub unsafe fn lua_type_name(&self, lua_type_id: i32) -> Cow<'_, str> {
let hackfix = self.get_top(); // https://github.com/Facepunch/garrysmod-issues/issues/5134
let type_str_ptr = (LUA_SHARED.lua_typename)(*self, lua_type_id);
self.pop_n((self.get_top() - hackfix).max(0));
let type_str = std::ffi::CStr::from_ptr(type_str_ptr);
type_str.to_string_lossy()
}