Преглед изворни кода

A number of fixes. Banks serialization, doubling spell effects, week of plague.

DjWarmonger пре 15 година
родитељ
комит
02d7fa35b7
4 измењених фајлова са 13 додато и 7 уклоњено
  1. 2 2
      client/CCastleInterface.cpp
  2. 1 1
      hch/CObjectHandler.h
  3. 2 1
      lib/CGameState.cpp
  4. 8 3
      server/CGameHandler.cpp

+ 2 - 2
client/CCastleInterface.cpp

@@ -1128,7 +1128,7 @@ int CCastleInterface::CCreaInfo::AddToString(std::string from, std::string & to,
 {
 	if (!numb)
 		return 0;//do not add string if 0
-	boost::algorithm::replace_first(from,"%+d", "+"+boost::lexical_cast<std::string>(numb));
+	boost::algorithm::replace_first(from,"%+d", (numb > 0 ? "+" : "")+boost::lexical_cast<std::string>(numb)); //negative values don't need "+"
 	to+="\n"+from;
 	return numb;
 }
@@ -1157,7 +1157,7 @@ void CCastleInterface::CCreaInfo::clickRight(tribool down, bool previousState)
 			else if ( bld.find(8)!=bld.end())//else if citadel+50% to basic
 				summ+=AddToString(CGI->buildh->buildings[ci->town->subID][8]->Name()+" %+d",descr,summ/2);
 
-			summ+=AddToString(CGI->generaltexth->allTexts[63] + " %+d",descr, //plague
+			summ+=AddToString(CGI->generaltexth->allTexts[63] + " %+d",descr, //double growth or plague
 				summ * CGI->creh->creatures[crid]->valOfBonuses(Bonus::CREATURE_GROWTH_PERCENT)/100);
 
 			summ+=AddToString(CGI->generaltexth->artifNames[133] + " %+d",descr,

+ 1 - 1
hch/CObjectHandler.h

@@ -1052,7 +1052,7 @@ class DLL_EXPORT CBank : public CArmedInstance
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
-		h & static_cast<CGObjectInstance&>(*this);
+		h & static_cast<CArmedInstance&>(*this);
 		h & index & multiplier & artifacts & daycounter & bc;
 	}
 };

+ 2 - 1
lib/CGameState.cpp

@@ -969,7 +969,8 @@ std::vector<si32> CStack::activeSpells() const
 	BonusList spellEffects = getSpellBonuses();
 	for(BonusList::const_iterator it = spellEffects.begin(); it != spellEffects.end(); it++)
 	{
-		ret.push_back(it->id);
+		if (!vstd::contains(ret, it->id)) //do not duplicate spells with multiple effects
+			ret.push_back(it->id);
 	}
 
 	return ret;

+ 8 - 3
server/CGameHandler.cpp

@@ -1220,9 +1220,14 @@ void CGameHandler::newTurn()
 			{
 				if((**j).creatureDwelling(k))//there is dwelling (k-level)
 				{
-					sac.creatures[k].first += (**j).creatureGrowth(k);
-					if(gs->getDate(0) == 1) //first day of game: use only basic growths
-						amin(sac.creatures[k].first, VLC->creh->creatures[(*j)->town->basicCreatures[k]]->growth);
+					if (n.specialWeek == NewTurn::PLAGUE)
+						sac.creatures[k].first = (**j).creatures[k].first / 2; //halve their number, no growth
+					else
+					{
+						sac.creatures[k].first += (**j).creatureGrowth(k);
+						if(gs->getDate(0) == 1) //first day of game: use only basic growths
+							amin(sac.creatures[k].first, VLC->creh->creatures[(*j)->town->basicCreatures[k]]->growth);
+					}
 				}
 			}
 			//creatures from town events