Browse Source

Merge branch 'develop' of https://github.com/vcmi/vcmi into RMG

DjWarmonger 11 years ago
parent
commit
7dbe2f5c40

+ 4 - 4
config/objects/creatureBanks.json

@@ -526,7 +526,7 @@
 						"combat_value": 154,
 						"reward" : {
 							"value": 3200,
-							"creatures": [ { "amount": 4, "type": "vyvern" } ]
+							"creatures": [ { "amount": 4, "type": "wyvern" } ]
 						}
 					},
 					{
@@ -541,7 +541,7 @@
 						"combat_value": 230,
 						"reward" : {
 							"value": 4800,
-							"creatures": [ { "amount": 6, "type": "vyvern" } ]
+							"creatures": [ { "amount": 6, "type": "wyvern" } ]
 						}
 					},
 					{
@@ -556,7 +556,7 @@
 						"combat_value": 307,
 						"reward" : {
 							"value": 6400,
-							"creatures": [ { "amount": 8, "type": "vyvern" } ]
+							"creatures": [ { "amount": 8, "type": "wyvern" } ]
 						}
 					},
 					{
@@ -571,7 +571,7 @@
 						"combat_value": 461,
 						"reward" : {
 							"value": 9600,
-							"creatures": [ { "amount": 12, "type": "vyvern" } ]
+							"creatures": [ { "amount": 12, "type": "wyvern" } ]
 						}
 					}
 				]

+ 2 - 2
lib/CGameState.cpp

@@ -256,7 +256,7 @@ DLL_LINKAGE void MetaString::toString(std::string &dst) const
 			boost::replace_first(dst, "%+d", '+' + boost::lexical_cast<std::string>(numbers[nums++]));
 			break;
 		default:
-            logGlobal->errorStream() << "MetaString processing error!";
+			logGlobal->errorStream() << "MetaString processing error! Received message of type " << int(elem);
 			break;
 		}
 	}
@@ -313,7 +313,7 @@ DLL_LINKAGE std::string MetaString::buildList () const
 				lista.replace (lista.find("%d"), 2, boost::lexical_cast<std::string>(numbers[nums++]));
 				break;
 			default:
-                logGlobal->errorStream() << "MetaString processing error!";
+				logGlobal->errorStream() << "MetaString processing error! Received message of type " << int(message[i]);
 		}
 
 	}

+ 6 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -473,9 +473,12 @@ void CGHeroInstance::initObj()
 	skillsInfo.resetMagicSchoolCounter();
 	skillsInfo.resetWisdomCounter();
 
-	auto customApp = VLC->objtypeh->getHandlerFor(ID, type->heroClass->id)->getOverride(cb->gameState()->getTile(visitablePos())->terType, this);
-	if (customApp)
-		appearance = customApp.get();
+	if (ID != Obj::PRISON)
+	{
+		auto customApp = VLC->objtypeh->getHandlerFor(ID, type->heroClass->id)->getOverride(cb->gameState()->getTile(visitablePos())->terType, this);
+		if (customApp)
+			appearance = customApp.get();
+	}
 
 	for(const auto &spec : type->spec) //TODO: unfity with bonus system
 	{

+ 6 - 1
lib/mapObjects/CRewardableObject.cpp

@@ -78,6 +78,7 @@ std::vector<ui32> CRewardableObject::getAvailableRewards(const CGHeroInstance *
 
 		if (visit.numOfGrants < visit.limiter.numOfGrants && visit.limiter.heroAllowed(hero))
 		{
+			logGlobal->debugStream() << "Reward " << i << " is allowed";
 			ret.push_back(i);
 		}
 	}
@@ -88,7 +89,7 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
 {
 	auto grantRewardWithMessage = [&](int index) -> void
 	{
-		grantReward(index, h);
+		logGlobal->debugStream() << "Granting reward " << index << ". Message says: " << info[index].message.toString();
 		// show message only if it is not empty
 		if (!info[index].message.toString().empty())
 		{
@@ -99,6 +100,8 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
 			info[index].reward.loadComponents(iw.components);
 			cb->showInfoDialog(&iw);
 		}
+		// grant reward afterwards. Note that it may remove object
+		grantReward(index, h);
 	};
 	auto selectRewardsMessage = [&](std::vector<ui32> rewards) -> void
 	{
@@ -114,6 +117,7 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
 	if (!wasVisited(h))
 	{
 		auto rewards = getAvailableRewards(h);
+		logGlobal->debugStream() << "Visiting object with " << rewards.size() << " possible rewards";
 		switch (rewards.size())
 		{
 			case 0: // no available rewards, e.g. empty flotsam
@@ -155,6 +159,7 @@ void CRewardableObject::onHeroVisit(const CGHeroInstance *h) const
 	}
 	else
 	{
+		logGlobal->debugStream() << "Revisiting already visited object";
 		InfoWindow iw;
 		iw.player = h->tempOwner;
 		iw.soundID = soundID;

+ 2 - 0
lib/registerTypes/RegisterTypes.h

@@ -97,6 +97,7 @@ void registerTypesMapObjectTypes(Serializer &s)
 	REGISTER_GENERIC_HANDLER(CGBorderGuard);
 	REGISTER_GENERIC_HANDLER(CGCreature);
 	REGISTER_GENERIC_HANDLER(CGDenOfthieves);
+	REGISTER_GENERIC_HANDLER(CGDwelling);
 	REGISTER_GENERIC_HANDLER(CGEvent);
 	REGISTER_GENERIC_HANDLER(CGGarrison);
 	REGISTER_GENERIC_HANDLER(CGHeroPlaceholder);
@@ -122,6 +123,7 @@ void registerTypesMapObjectTypes(Serializer &s)
 	REGISTER_GENERIC_HANDLER(CGSignBottle);
 	REGISTER_GENERIC_HANDLER(CGSirens);
 	REGISTER_GENERIC_HANDLER(CGTeleport);
+	REGISTER_GENERIC_HANDLER(CGTownInstance);
 	REGISTER_GENERIC_HANDLER(CGUniversity);
 	REGISTER_GENERIC_HANDLER(CGVisitableOPH);
 	REGISTER_GENERIC_HANDLER(CGVisitableOPW);