mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Players will be always able to see their owned heroes and other objects. Fixes #1959.
This commit is contained in:
		| @@ -479,7 +479,7 @@ void CMinimapInstance::showAll(SDL_Surface *to) | ||||
| 	blitAtLoc(minimap, 0, 0, to); | ||||
|  | ||||
| 	//draw heroes | ||||
| 	std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); | ||||
| 	std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false); //TODO: do we really need separate function for drawing heroes?  | ||||
| 	for(auto & hero : heroes) | ||||
| 	{ | ||||
| 		int3 position = hero->getPosition(false); | ||||
|   | ||||
| @@ -108,7 +108,7 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v | ||||
| 		return nullptr; | ||||
| 	} | ||||
|  | ||||
| 	if(!isVisible(ret, player)) | ||||
| 	if(!isVisible(ret, player) && ret->tempOwner != player) | ||||
| 	{ | ||||
| 		if(verbose) | ||||
|             logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object is not visible."; | ||||
| @@ -525,7 +525,8 @@ std::vector < const CGHeroInstance *> CPlayerSpecificInfoCallback::getHeroesInfo | ||||
| 	std::vector < const CGHeroInstance *> ret; | ||||
| 	for(auto hero : gs->map->heroesOnMap) | ||||
| 	{ | ||||
| 		if( !player || (hero->tempOwner == *player) || | ||||
| 		// !player || // - why would we even get access to hero not owned by any player? | ||||
| 		if((hero->tempOwner == *player) || | ||||
| 			(isVisible(hero->getPosition(false), player) && !onlyOur)	) | ||||
| 		{ | ||||
| 			ret.push_back(hero); | ||||
|   | ||||
| @@ -2240,6 +2240,10 @@ bool CGameState::isVisible( const CGObjectInstance *obj, boost::optional<PlayerC | ||||
| 	if(!player) | ||||
| 		return true; | ||||
|  | ||||
| 	//we should always see our own heroes - but sometimes not visible heroes cause crash :? | ||||
| 	if (player == obj->tempOwner) | ||||
| 		return true; | ||||
|  | ||||
| 	if(*player == PlayerColor::NEUTRAL) //-> TODO ??? needed? | ||||
| 		return false; | ||||
| 	//object is visible when at least one blocked tile is visible | ||||
|   | ||||
| @@ -2887,7 +2887,7 @@ bool CGameHandler::buyArtifact( ObjectInstanceID hid, ArtifactID aid ) | ||||
| 			return false; | ||||
|  | ||||
| 		giveResource(hero->getOwner(),Res::GOLD,-GameConstants::SPELLBOOK_GOLD_COST); | ||||
| 		giveHeroNewArtifact(hero, VLC->arth->artifacts[0], ArtifactPosition::SPELLBOOK); | ||||
| 		giveHeroNewArtifact(hero, VLC->arth->artifacts[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK); | ||||
| 		assert(hero->getArt(ArtifactPosition::SPELLBOOK)); | ||||
| 		giveSpells(town,hero); | ||||
| 		return true; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user