Skip to content

Commit a067d40

Browse files
Rogier-5sfan5
authored andcommittedAug 12, 2019
Handle multiple deserialization of a block's entities
This fix consists of two parts: - Clear the list of stored entities. This has no side-effects. - Catch the case where active entities exist and print a message. Clearing the active entitiy list has side-effects that should be handled. (those entities are known to the environment and to clients). As avoiding those side-effects is more complex, and as this problem is not expected to occur (with PR #4847 merged), there is no real incentive to implement this ATM. This issue was a contributing factor to bug #4217. With the other contributing factor removed (PR #4847), this commit makes sure this factor does not go unnoticed if it ever happens again.
1 parent 33fdd48 commit a067d40

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

Diff for: ‎src/staticobject.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ void StaticObjectList::serialize(std::ostream &os)
7777
}
7878
void StaticObjectList::deSerialize(std::istream &is)
7979
{
80+
if (m_active.size()) {
81+
errorstream << "StaticObjectList::deSerialize(): "
82+
<< "deserializing objects while " << m_active.size()
83+
<< " active objects already exist (not cleared). "
84+
<< m_stored.size() << " stored objects _were_ cleared"
85+
<< std::endl;
86+
}
87+
m_stored.clear();
88+
8089
// version
8190
u8 version = readU8(is);
8291
// count

0 commit comments

Comments
 (0)