diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-20 15:49:28 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-05-20 15:49:28 +0200 |
commit | 9a0781e52fd0f9eac8ac75c18d7f58936fb6c981 (patch) | |
tree | b0766998fe71a89e4f968dac1e669684d7cb7d88 /src/keeper.cpp | |
parent | 5e5f08558010890206e1d2d11045870c35eb23cf (diff) | |
download | lanes-9a0781e52fd0f9eac8ac75c18d7f58936fb6c981.tar.gz lanes-9a0781e52fd0f9eac8ac75c18d7f58936fb6c981.tar.bz2 lanes-9a0781e52fd0f9eac8ac75c18d7f58936fb6c981.zip |
linda:limit uses nil instead of -1 to unblock
Diffstat (limited to 'src/keeper.cpp')
-rw-r--r-- | src/keeper.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp index 2f8817c..9bde2d5 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp | |||
@@ -359,14 +359,14 @@ int keepercall_receive_batched(lua_State* L_) | |||
359 | 359 | ||
360 | // ################################################################################################# | 360 | // ################################################################################################# |
361 | 361 | ||
362 | // in: linda_ud key n | 362 | // in: linda_ud key [n|nil] |
363 | // out: true or nil | 363 | // out: true or nil |
364 | int keepercall_limit(lua_State* L_) | 364 | int keepercall_limit(lua_State* L_) |
365 | { | 365 | { |
366 | int const _limit{ static_cast<int>(lua_tointeger(L_, 3)) }; | 366 | int const _limit{ static_cast<int>(luaL_optinteger(L_, 3, -1)) }; // -1 if we read nil because the argument is absent |
367 | push_table(L_, 1); // L_: ud key n fifos | 367 | push_table(L_, 1); // L_: ud key n? fifos |
368 | lua_replace(L_, 1); // L_: fifos key n | 368 | lua_replace(L_, 1); // L_: fifos key n? |
369 | lua_pop(L_, 1); // L_: fifos key | 369 | lua_settop(L_, 2); // L_: fifos key |
370 | lua_pushvalue(L_, -1); // L_: fifos key key | 370 | lua_pushvalue(L_, -1); // L_: fifos key key |
371 | lua_rawget(L_, -3); // L_: fifos key fifo|nil | 371 | lua_rawget(L_, -3); // L_: fifos key fifo|nil |
372 | keeper_fifo* _fifo{ keeper_fifo::getPtr(L_, -1) }; | 372 | keeper_fifo* _fifo{ keeper_fifo::getPtr(L_, -1) }; |