diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-26 17:40:37 +0100 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-03-26 17:40:37 +0100 |
| commit | 2eeb245b98bd702379aa92d888f7b7d21d1193b8 (patch) | |
| tree | c61a4bee6bec9b7b3c88b8e422e32d710da09ac8 /src | |
| parent | be2f2b4314799d38901c9e80dd35dee63f541c90 (diff) | |
| download | lanes-2eeb245b98bd702379aa92d888f7b7d21d1193b8.tar.gz lanes-2eeb245b98bd702379aa92d888f7b7d21d1193b8.tar.bz2 lanes-2eeb245b98bd702379aa92d888f7b7d21d1193b8.zip | |
C++ migration: Fix metatable caching bug introduced when converting the index to std::atomic
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools.cpp | 2 | ||||
| -rw-r--r-- | src/universe.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/tools.cpp b/src/tools.cpp index 89e5499..52c70bc 100644 --- a/src/tools.cpp +++ b/src/tools.cpp | |||
| @@ -632,7 +632,7 @@ static lua_Integer get_mt_id( Universe* U, lua_State* L, int i) | |||
| 632 | 632 | ||
| 633 | if( id == 0) | 633 | if( id == 0) |
| 634 | { | 634 | { |
| 635 | id = U->last_mt_id.fetch_add(1, std::memory_order_relaxed); | 635 | id = U->next_mt_id.fetch_add(1, std::memory_order_relaxed); |
| 636 | 636 | ||
| 637 | /* Create two-way references: id_uint <-> table | 637 | /* Create two-way references: id_uint <-> table |
| 638 | */ | 638 | */ |
diff --git a/src/universe.h b/src/universe.h index 3aac20d..bb3ebdd 100644 --- a/src/universe.h +++ b/src/universe.h | |||
| @@ -154,7 +154,7 @@ struct Universe | |||
| 154 | // require() serialization | 154 | // require() serialization |
| 155 | std::recursive_mutex require_cs; | 155 | std::recursive_mutex require_cs; |
| 156 | 156 | ||
| 157 | std::atomic<lua_Integer> last_mt_id{ 0 }; | 157 | std::atomic<lua_Integer> next_mt_id{ 1 }; |
| 158 | 158 | ||
| 159 | #if USE_DEBUG_SPEW() | 159 | #if USE_DEBUG_SPEW() |
| 160 | int debugspew_indent_depth{ 0 }; | 160 | int debugspew_indent_depth{ 0 }; |
