Skip to content

Commit 4d7f296

Browse files
linewriter1024sfan5
authored andcommittedAug 7, 2019
Do not add group values of zero to group lists. (#8751)
This fixes an issue where when the engine looked up groups (for example, in ABM node names), NodeDefManager's m_group_to_items would contain nodes with a group value of zero, resulting in nodes with flammable = 0 being burned by a fire mod with a group:flammable checking ABM. It brings consistency to the behaviour described in the api documentation, where zero and nil groups should be the same.
1 parent 233cb86 commit 4d7f296

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎src/script/common/c_content.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -1529,13 +1529,15 @@ void read_groups(lua_State *L, int index, ItemGroupList &result)
15291529
return;
15301530
result.clear();
15311531
lua_pushnil(L);
1532-
if(index < 0)
1532+
if (index < 0)
15331533
index -= 1;
1534-
while(lua_next(L, index) != 0){
1534+
while (lua_next(L, index) != 0) {
15351535
// key at index -2 and value at index -1
15361536
std::string name = luaL_checkstring(L, -2);
15371537
int rating = luaL_checkinteger(L, -1);
1538-
result[name] = rating;
1538+
// zero rating indicates not in the group
1539+
if (rating != 0)
1540+
result[name] = rating;
15391541
// removes value, keeps key for next iteration
15401542
lua_pop(L, 1);
15411543
}

0 commit comments

Comments
 (0)
Please sign in to comment.