diff --git a/CvGameCoreDLL/CvInitCore.cpp b/CvGameCoreDLL/CvInitCore.cpp index 3e93987f8..ddf89b758 100644 --- a/CvGameCoreDLL/CvInitCore.cpp +++ b/CvGameCoreDLL/CvInitCore.cpp @@ -587,6 +587,7 @@ void CvInitCore::resetPlayer(PlayerTypes eID, m_aszCivPassword[eID].clear(); m_aszEmail[eID].clear(); m_aszSmtpHost[eID].clear(); + m_uiTotalNameLength = 0; // advc.003k m_abWhiteFlag.resetVal(eID); m_aszFlagDecal[eID].clear(); @@ -1006,6 +1007,7 @@ void CvInitCore::setForceControl(ForceControlTypes eIndex, bool bOption) void CvInitCore::setActivePlayer(PlayerTypes eActivePlayer) { + m_uiTotalNameLength = 0; // advc.003k (tidier to reset this asap) // if (m_eActivePlayer == eActivePlayer) return; // @@ -1121,6 +1123,7 @@ void CvInitCore::setLeaderName(PlayerTypes eID, CvWString const& szLeaderName) CvWString szName = szLeaderName; gDLL->stripSpecialCharacters(szName); m_aszLeaderName[eID] = szName; + countNameLength(szName); // advc.003k } else FAssertBounds(0, MAX_PLAYERS, eID); gDLL->UI().setDirty(Score_DIRTY_BIT, true); // advc.001m @@ -1157,6 +1160,7 @@ void CvInitCore::setCivDescription(PlayerTypes eID, CvWString const& szCivDescri CvWString szName = szCivDescription; gDLL->stripSpecialCharacters(szName); m_aszCivDescription[eID] = szName; + countNameLength(szName); // advc.003k } CvWString const& CvInitCore::getCivDescriptionKey(PlayerTypes eID) const @@ -1291,6 +1295,19 @@ void CvInitCore::setSmtpHost(PlayerTypes eID, CvString const& szHost) m_aszSmtpHost[eID] = szHost; } +// advc.003k: +void CvInitCore::countNameLength(CvWString const& kName) +{ + #ifdef FASSERT_ENABLE + if (getActivePlayer() == NO_PLAYER && getScenario()) + { + m_uiTotalNameLength += kName.length(); + FAssertMsg(m_uiTotalNameLength < 1240, "Total length of LeaderName" + " and CivDesc strings might crash civ selection screen."); + } + #endif +} + void CvInitCore::setWhiteFlag(PlayerTypes eID, bool bWhiteFlag) { m_abWhiteFlag.set(eID, bWhiteFlag); diff --git a/CvGameCoreDLL/CvInitCore.h b/CvGameCoreDLL/CvInitCore.h index 2d2b9d4f4..b6c5e198c 100644 --- a/CvGameCoreDLL/CvInitCore.h +++ b/CvGameCoreDLL/CvInitCore.h @@ -357,6 +357,7 @@ class CvInitCore /* advc.003e */ : boost::noncopyable CvWString* m_aszCivPassword; CvString* m_aszEmail; CvString* m_aszSmtpHost; + size_t m_uiTotalNameLength; // advc.003k CvWString* m_aszFlagDecal; ArrayEnumMap m_abWhiteFlag; @@ -394,6 +395,7 @@ class CvInitCore /* advc.003e */ : boost::noncopyable void clearCustomMapOptions(); void refreshCustomMapOptions(); void updatePangaea(); // advc + void countNameLength(CvWString const& kName); /*void clearVictories(); void refreshVictories();*/ // advc: Easier to understand w/o these @@ -402,7 +404,7 @@ class CvInitCore /* advc.003e */ : boost::noncopyable /* advc.003k: OK to increase the size of CvInitCore (and to update or remove this assertion). Just make sure that new data members are added in the right place. */ BOOST_STATIC_ASSERT(sizeof(CvInitCore) == - (sizeof(ArrayEnumMap) > 4 ? 444 : 420)); + (sizeof(ArrayEnumMap) > 4 ? 448 : 424)); // advc: Custom Game screen probably relies on this BOOST_STATIC_ASSERT(GAMEOPTION_LEAD_ANY_CIV == 7 && GAMEOPTION_ADVANCED_START == 0);