Skip to content

Commit 5b7e774

Browse files
committed
Fix some off-by-one errors in Item config.
1 parent b9fc288 commit 5b7e774

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ItemConfiguration.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ bool parseItemElement( TiXmlElement* elemRoot, int basefile)
104104

105105
void flushItemConfig(vector<std::unique_ptr<ItemConfiguration>> &config)
106106
{
107-
uint32_t currentsize = (uint32_t)config.size();
108-
if (currentsize < ENUM_LAST_ITEM(item_type)) {
109-
currentsize = ENUM_LAST_ITEM(item_type);
110-
}
107+
if (config.size() != (ENUM_LAST_ITEM(item_type) + 1))
108+
config.resize(ENUM_LAST_ITEM(item_type) + 1);
111109

112-
config.clear();
113-
while (currentsize < config.size()) {
114-
config.push_back(nullptr);
110+
for (size_t i = 0; i < config.size(); i++)
111+
{
112+
config[i] = nullptr;
115113
}
116114
}

0 commit comments

Comments
 (0)