Skip to content

Commit 409fed2

Browse files
authored
bugfix(thingfactory): Reset next ThingTemplate ID after clearing custom map template overrides to avoid CRC mismatch in the next multiplayer game session (#2034)
1 parent 13de427 commit 409fed2

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Generals/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,14 @@ void ThingFactory::reset( void )
236236
m_templateHashMap.erase(templateName);
237237
}
238238

239+
DEBUG_ASSERTCRASH(!nextT || t->getTemplateID() == nextT->getTemplateID() + 1, ("Next template ID is unexpected"));
240+
239241
t = nextT;
240242
}
243+
244+
// TheSuperHackers @bugfix Caball009 25/12/2025 Avoid mismatches by making m_nextTemplateID unique for a single match instead of unique since game launch.
245+
DEBUG_ASSERTCRASH(m_firstTemplate && m_firstTemplate->getTemplateID() == m_templateHashMap.size(), ("Template ID is unexpected after deleting overrides"));
246+
m_nextTemplateID = static_cast<UnsignedShort>(m_firstTemplate->getTemplateID() + 1);
241247
}
242248

243249
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingFactory.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,14 @@ void ThingFactory::reset( void )
236236
m_templateHashMap.erase(templateName);
237237
}
238238

239+
DEBUG_ASSERTCRASH(!nextT || t->getTemplateID() == nextT->getTemplateID() + 1, ("Next template ID is unexpected"));
240+
239241
t = nextT;
240242
}
243+
244+
// TheSuperHackers @bugfix Caball009 25/12/2025 Avoid mismatches by making m_nextTemplateID unique for a single match instead of unique since game launch.
245+
DEBUG_ASSERTCRASH(m_firstTemplate && m_firstTemplate->getTemplateID() == m_templateHashMap.size(), ("Template ID is unexpected after deleting overrides"));
246+
m_nextTemplateID = static_cast<UnsignedShort>(m_firstTemplate->getTemplateID() + 1);
241247
}
242248

243249
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)