瀏覽代碼

* capitol bar in town hall is grey (not red) if already one exists
* disabled autosaving on first turn
* bonuses from bonus artifacts
* fixed crash on battle with neutral creatures
* minor improvements

Michał W. Urbańczyk 16 年之前
父節點
當前提交
db2f8c1d7c

+ 2 - 2
client/CCastleInterface.cpp

@@ -1014,11 +1014,11 @@ void CHallInterface::CBuildingBox::show(SDL_Surface * to)
 		pom2 = 2;
 		pom2 = 2;
 		pom = 2;
 		pom = 2;
 		break;
 		break;
-	case 0: case 5: case 8:
+	case 5: case 8:
 		pom2 = 1;
 		pom2 = 1;
 		pom = 2;
 		pom = 2;
 		break;
 		break;
-	case 2: case 1: default:
+	case 0: case 2: case 1: default:
 		pom = 3;
 		pom = 3;
 		break;
 		break;
 	}
 	}

+ 1 - 0
client/CMT.cpp

@@ -144,6 +144,7 @@ int main(int argc, char** argv)
 	std::cout.flags(std::ios::unitbuf);
 	std::cout.flags(std::ios::unitbuf);
 	logfile = new std::ofstream("VCMI_Client_log.txt");
 	logfile = new std::ofstream("VCMI_Client_log.txt");
 	console = new CConsoleHandler;
 	console = new CConsoleHandler;
+	*console->cb = boost::bind(&processCommand, _1, boost::ref(client));
 	console->start();
 	console->start();
 	atexit(dispose);
 	atexit(dispose);
 	tlog0 <<"Creating console and logfile: "<<pomtime.getDif() << std::endl;
 	tlog0 <<"Creating console and logfile: "<<pomtime.getDif() << std::endl;

+ 7 - 1
client/CPlayerInterface.cpp

@@ -132,8 +132,14 @@ void CPlayerInterface::yourTurn()
 		LOCPLINT = this;
 		LOCPLINT = this;
 		makingTurn = true;
 		makingTurn = true;
 
 
+		static bool firstCall = true;
 		static int autosaveCount = 0;
 		static int autosaveCount = 0;
-		LOCPLINT->cb->save("Autosave_" + boost::lexical_cast<std::string>(autosaveCount++ + 1));
+
+		if(firstCall)
+			firstCall = false;
+		else
+			LOCPLINT->cb->save("Autosave_" + boost::lexical_cast<std::string>(autosaveCount++ + 1));
+
 		autosaveCount %= 5;
 		autosaveCount %= 5;
 
 
 		for(std::map<int,SDL_Surface*>::iterator i=graphics->heroWins.begin(); i!=graphics->heroWins.end();i++) //redraw hero infoboxes
 		for(std::map<int,SDL_Surface*>::iterator i=graphics->heroWins.begin(); i!=graphics->heroWins.end();i++) //redraw hero infoboxes

+ 13 - 8
hch/CObjectHandler.cpp

@@ -568,14 +568,7 @@ void CGHeroInstance::initHero()
 	boost::algorithm::replace_first(hoverName,"%s",name);
 	boost::algorithm::replace_first(hoverName,"%s",name);
 	boost::algorithm::replace_first(hoverName,"%s", type->heroClass->name);
 	boost::algorithm::replace_first(hoverName,"%s", type->heroClass->name);
 
 
-	//clear all bonuses from artifacts (if present) and give them again
-	std::remove_if(bonuses.begin(), bonuses.end(), boost::bind(HeroBonus::IsFrom,_1,HeroBonus::ARTIFACT,0xffffff));
-	for (std::map<ui16,ui32>::iterator ari = artifWorn.begin(); ari != artifWorn.end(); ari++)
-	{
-		CArtifact &art = VLC->arth->artifacts[ari->second];
-		for(std::list<HeroBonus>::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++)
-			bonuses.push_back(*i);
-	}
+	recreateArtBonuses();
 }
 }
 
 
 void CGHeroInstance::initHeroDefInfo()
 void CGHeroInstance::initHeroDefInfo()
@@ -903,6 +896,18 @@ si32 CGHeroInstance::getArtPos(int aid) const
 	return -1;
 	return -1;
 }
 }
 
 
+void CGHeroInstance::recreateArtBonuses()
+{
+	//clear all bonuses from artifacts (if present) and give them again
+	std::remove_if(bonuses.begin(), bonuses.end(), boost::bind(HeroBonus::IsFrom,_1,HeroBonus::ARTIFACT,0xffffff));
+	for (std::map<ui16,ui32>::iterator ari = artifWorn.begin(); ari != artifWorn.end(); ari++)
+	{
+		CArtifact &art = VLC->arth->artifacts[ari->second];
+		for(std::list<HeroBonus>::iterator i = art.bonuses.begin(); i != art.bonuses.end(); i++)
+			bonuses.push_back(*i);
+	}
+}
+
 void CGDwelling::initObj()
 void CGDwelling::initObj()
 {
 {
 	switch(ID)
 	switch(ID)

+ 1 - 0
hch/CObjectHandler.h

@@ -273,6 +273,7 @@ public:
 
 
 	void initHero(); 
 	void initHero(); 
 	void initHero(int SUBID); 
 	void initHero(int SUBID); 
+	void recreateArtBonuses();
 	void initHeroDefInfo();
 	void initHeroDefInfo();
 	CGHeroInstance();
 	CGHeroInstance();
 	virtual ~CGHeroInstance();
 	virtual ~CGHeroInstance();

+ 3 - 13
lib/CGameState.cpp

@@ -1219,7 +1219,10 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
 				CGHeroInstance *hero = k->second.heroes[0];
 				CGHeroInstance *hero = k->second.heroes[0];
 				std::vector<ui16>::iterator slot = vstd::findFirstNot(hero->artifWorn,toGive->possibleSlots);
 				std::vector<ui16>::iterator slot = vstd::findFirstNot(hero->artifWorn,toGive->possibleSlots);
 				if(slot!=toGive->possibleSlots.end())
 				if(slot!=toGive->possibleSlots.end())
+				{
 					hero->artifWorn[*slot] = toGive->id;
 					hero->artifWorn[*slot] = toGive->id;
+					hero->recreateArtBonuses();
+				}
 				else
 				else
 					hero->artifacts.push_back(toGive->id);
 					hero->artifacts.push_back(toGive->id);
 			}
 			}
@@ -1296,19 +1299,6 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
 	{
 	{
 		if(k->first==-1 || k->first==255)
 		if(k->first==-1 || k->first==255)
 			continue;
 			continue;
-	//	for(int xd=0; xd<map->width; ++xd) //revealing part of map around towns
-	//	{
-	//		for(int yd=0; yd<map->height; ++yd)
-	//		{
-	//			for(int ch=0; ch<k->second.towns.size(); ++ch)
-	//			{
-	//				int deltaX = (k->second.towns[ch]->pos.x-xd)*(k->second.towns[ch]->pos.x-xd);
-	//				int deltaY = (k->second.towns[ch]->pos.y-yd)*(k->second.towns[ch]->pos.y-yd);
-	//				if(deltaX+deltaY<k->second.towns[ch]->getSightDistance()*k->second.towns[ch]->getSightDistance())
-	//					k->second.fogOfWarMap[xd][yd][k->second.towns[ch]->pos.z] = 1;
-	//			}
-	//		}
-	//	}
 
 
 		//init visiting and garrisoned heroes
 		//init visiting and garrisoned heroes
 		for(unsigned int l=0; l<k->second.heroes.size();l++)
 		for(unsigned int l=0; l<k->second.heroes.size();l++)

+ 12 - 3
server/CGameHandler.cpp

@@ -938,7 +938,8 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, CCreatureSet &army
 	//adding native terrain bonuses
 	//adding native terrain bonuses
 	for(int g=0; g<stacks.size(); ++g)
 	for(int g=0; g<stacks.size(); ++g)
 	{
 	{
-		if( VLC->heroh->nativeTerrains[stacks[g]->creature->faction] == gs->map->terrain[tile.x][tile.y][tile.z].tertype )
+		int faction = stacks[g]->creature->faction;
+		if(faction >= 0 && VLC->heroh->nativeTerrains[faction] == gs->map->terrain[tile.x][tile.y][tile.z].tertype )
 		{
 		{
 			stacks[g]->features.push_back(makeFeature(StackFeature::SPEED_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
 			stacks[g]->features.push_back(makeFeature(StackFeature::SPEED_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
 			stacks[g]->features.push_back(makeFeature(StackFeature::ATTACK_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
 			stacks[g]->features.push_back(makeFeature(StackFeature::ATTACK_BONUS, StackFeature::WHOLE_BATTLE, 0, 1, StackFeature::OTHER_SOURCE));
@@ -995,7 +996,7 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, CCreatureSet &army
 			stacks.back()->luck = hero2->getCurrentLuck(stacks.back()->ID,false);
 			stacks.back()->luck = hero2->getCurrentLuck(stacks.back()->ID,false);
 		}
 		}
 	}
 	}
-	//war machiens added
+	//war machines added
 	std::stable_sort(stacks.begin(),stacks.end(),cmpst);
 	std::stable_sort(stacks.begin(),stacks.end(),cmpst);
 
 
 	//randomize obstacles
 	//randomize obstacles
@@ -1674,13 +1675,21 @@ bool CGameHandler::buildStructure( si32 tid, si32 bid )
 			ns.bid.insert(19);
 			ns.bid.insert(19);
 		else if(t->getHordeLevel(1) == (bid-37))
 		else if(t->getHordeLevel(1) == (bid-37))
 			ns.bid.insert(25);
 			ns.bid.insert(25);
+
+		SetAvailableCreatures ssi;
+		ssi.tid = tid;
+		ssi.creatures = t->creatures;
+		ssi.creatures[bid-37].second.push_back(t->town->upgradedCreatures[bid-37]);
+		sendAndApply(&ssi);
 	}
 	}
 	else if(bid >= 30) //bas. dwelling
 	else if(bid >= 30) //bas. dwelling
 	{
 	{
+		int crid = t->town->basicCreatures[bid-30];
 		SetAvailableCreatures ssi;
 		SetAvailableCreatures ssi;
 		ssi.tid = tid;
 		ssi.tid = tid;
 		ssi.creatures = t->creatures;
 		ssi.creatures = t->creatures;
-		ssi.creatures[bid-30].first = VLC->creh->creatures[t->town->basicCreatures[bid-30]].growth;
+		ssi.creatures[bid-30].first = VLC->creh->creatures[crid].growth;
+		ssi.creatures[bid-30].second.push_back(crid);
 		sendAndApply(&ssi);
 		sendAndApply(&ssi);
 	}
 	}
 
 

+ 2 - 2
server/NetPacksServer.cpp

@@ -25,9 +25,9 @@ CGameState* CPackForServer::GS(CGameHandler *gh)
 
 
 bool SaveGame::applyGh( CGameHandler *gh )
 bool SaveGame::applyGh( CGameHandler *gh )
 {
 {
-	gh->sendMessageTo(*c,"Saving...");
+	//gh->sendMessageTo(*c,"Saving...");
 	gh->save(fname);
 	gh->save(fname);
-	gh->sendMessageTo(*c,"Game has been succesfully saved!");
+	gh->sendMessageTo(*c,"Game has been saved as " + fname);
 	return true;
 	return true;
 }
 }