Skip to content

Commit

Permalink
Trigger: Empty trigger is always -1
Browse files Browse the repository at this point in the history
That allows save to properly store the removed-status.
Storing nil truncates the table (leading to wrong length of table).
  • Loading branch information
zzam committed Mar 5, 2024
1 parent 2b9ed1d commit 838f82e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/game/trigger.cpp
Expand Up @@ -444,9 +444,9 @@ static int CclAddTrigger(lua_State *l)

const int i = lua_rawlen(l, -1);
if (i / 2 < ActiveTriggers.size() && !ActiveTriggers[i / 2]) {
lua_pushnil(l);
lua_pushnumber(l, -1);
lua_rawseti(l, -2, i + 1);
lua_pushnil(l);
lua_pushnumber(l, -1);
lua_rawseti(l, -2, i + 2);
} else {
lua_pushvalue(l, 1);
Expand Down Expand Up @@ -596,7 +596,7 @@ void SaveTriggers(CFile &file)
if (i) {
file.printf(", ");
}
if (!lua_isnil(Lua, -1)) {
if (!lua_isnumber(Lua, -1)) {
file.printf("true");
} else {
file.printf("false");
Expand Down

0 comments on commit 838f82e

Please sign in to comment.