From a9fd7b806cc7e4a1c87772392836a58fd449dde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Wed, 27 Feb 2013 03:11:45 +0000 Subject: [PATCH] Fixed crash on the new month when there are no creatures that can get double growth. (#1219, possibly #1217) The list of double growth creatures will be serialized. Bumped format. MSVC: silenced that stupid C4275 warning. (senseless when using STL) --- VCMI_global.props | 3 +++ lib/CCreatureHandler.h | 2 +- lib/Connection.h | 2 +- server/CGameHandler.cpp | 7 ++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/VCMI_global.props b/VCMI_global.props index 8197ea294..40df06ece 100644 --- a/VCMI_global.props +++ b/VCMI_global.props @@ -12,6 +12,9 @@ Console + + 4275 + \ No newline at end of file diff --git a/lib/CCreatureHandler.h b/lib/CCreatureHandler.h index 686f9257b..c82aaa9c4 100644 --- a/lib/CCreatureHandler.h +++ b/lib/CCreatureHandler.h @@ -176,7 +176,7 @@ public: template void serialize(Handler &h, const int version) { //TODO: should be optimized, not all these informations needs to be serialized (same for ccreature) - h & notUsedMonsters & creatures; + h & notUsedMonsters & doubledCreatures & creatures; h & stackBonuses & expRanks & maxExpPerBattle & expAfterUpgrade; h & skillLevels & skillRequirements & commanderLevelPremy; h & allCreatures; diff --git a/lib/Connection.h b/lib/Connection.h index 547c8d553..d4ae9707c 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -26,7 +26,7 @@ #include "CObjectHandler.h" //for CArmedInstance #include "Mapping/CCampaignHandler.h" //for CCampaignState -const ui32 version = 738; +const ui32 version = 739; class CConnection; class CGObjectInstance; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 8688a07b2..c397de950 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -1209,12 +1209,17 @@ void CGameHandler::newTurn() std::pair newMonster(54, VLC->creh->pickRandomMonster(boost::ref(rand))); n.creatureid = newMonster.second; } - else + else if(VLC->creh->doubledCreatures.size()) { auto it = VLC->creh->doubledCreatures.cbegin(); std::advance (it, rand() % VLC->creh->doubledCreatures.size()); //picking random element of set is tiring n.creatureid = *it; } + else + { + complain("Cannot find creature that can be spawned!"); + n.specialWeek = NewTurn::NORMAL; + } } else if (monthType < 50) n.specialWeek = NewTurn::PLAGUE;