mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-02-03 20:25:58 +00:00
Fix negative zero network_send() edgecase (#1024)
Lua mods in very rare scenarios would send a value of -0 over the network, and receive MIN_U64 due to an incorrect guess at the variable type in an LNT. --------- Co-authored-by: MysterD <myster@d>
This commit is contained in:
parent
6be70deecc
commit
a164caa412
1 changed files with 5 additions and 10 deletions
|
|
@ -241,19 +241,14 @@ struct LSTNetworkType smlua_to_lnt(lua_State* L, int index) {
|
|||
int valueType = lua_type(L, index);
|
||||
|
||||
if (valueType == LUA_TNUMBER) {
|
||||
lnt.type = LST_NETWORK_TYPE_INTEGER;
|
||||
lnt.value.integer = lua_tointeger(L, index);
|
||||
lnt.size = sizeof(u8) + sizeof(long long);
|
||||
|
||||
if (lnt.value.integer == 0) {
|
||||
if (lua_isinteger(L, index)) {
|
||||
lnt.type = LST_NETWORK_TYPE_INTEGER;
|
||||
lnt.value.integer = lua_tointeger(L, index);
|
||||
lnt.size = sizeof(u8) + sizeof(long long);
|
||||
} else {
|
||||
lnt.type = LST_NETWORK_TYPE_NUMBER;
|
||||
lnt.value.number = lua_tonumber(L, index);
|
||||
lnt.size = sizeof(u8) + sizeof(double);
|
||||
|
||||
if (lnt.value.number == 0) {
|
||||
lnt.type = LST_NETWORK_TYPE_INTEGER;
|
||||
lnt.size = sizeof(u8) + sizeof(long long);
|
||||
}
|
||||
}
|
||||
gSmLuaConvertSuccess = true;
|
||||
return lnt;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue