Pārlūkot izejas kodu

Minor tweaks for hiding tiles, now it belongs to CGObjectInstance class.

DjWarmonger 15 gadi atpakaļ
vecāks
revīzija
a53be2d382
3 mainītis faili ar 18 papildinājumiem un 23 dzēšanām
  1. 15 11
      hch/CObjectHandler.cpp
  2. 1 0
      hch/CObjectHandler.h
  3. 2 12
      server/CGameHandler.cpp

+ 15 - 11
hch/CObjectHandler.cpp

@@ -422,6 +422,20 @@ void CGObjectInstance::getSightTiles(std::set<int3> &tiles) const //returns refe
 {
 	cb->getTilesInRange(tiles, getSightCenter(), getSightRadious(), tempOwner, 1);
 }
+void CGObjectInstance::hideTiles(int ourplayer, int radius) const
+{
+	for (std::map<ui8, PlayerState>::iterator i = cb->gameState()->players.begin(); i != cb->gameState()->players.end(); i++)
+	{
+		if (ourplayer != i->first && i->second.status == PlayerState::INGAME) //TODO: team support
+		{
+			FoWChange fw;
+			fw.mode = 0;
+			fw.player = i->first;
+			cb->getTilesInRange (fw.tiles, pos, radius, i->first, -1);
+			cb->sendAndApply (&fw);
+		}
+	}
+}
 int3 CGObjectInstance::getVisitableOffset() const
 {
 	for(int y = 0; y < 6; y++)
@@ -4470,17 +4484,7 @@ void CGObservatory::onHeroVisit( const CGHeroInstance * h ) const
 		case 15://cover of darkness
 		{
 			iw.text.addTxt (MetaString::ADVOB_TXT, 31);
-			for (std::map<ui8, PlayerState>::iterator i = cb->gameState()->players.begin(); i != cb->gameState()->players.end(); i++)
-			{
-				if (h->tempOwner != i->first && i->second.status == PlayerState::INGAME) //TODO: team support
-				{
-					FoWChange fw;
-				    fw.mode = 0;
-					fw.player = i->first;
-					cb->getTilesInRange (fw.tiles, pos, 20, i->first, -1);
-					cb->sendAndApply (&fw);
-				}
-			}
+			hideTiles(h->tempOwner, 20);
 			break;
 		}
 	}

+ 1 - 0
hch/CObjectHandler.h

@@ -190,6 +190,7 @@ public:
 	bool hasShadowAt(int x, int y) const;//returns true if object covers with shadow location (x, y) form left top tile of maximal possible image (8 x 6 tiles) (x, y in tiles)
 	std::set<int3> getBlockedPos() const; //returns set of positions blocked by this object
 	bool operator<(const CGObjectInstance & cmp) const;  //screen printing priority comparing
+	void hideTiles(int ourplayer, int radius) const;
 	CGObjectInstance();
 	virtual ~CGObjectInstance();
 	//CGObjectInstance(const CGObjectInstance & right);

+ 2 - 12
server/CGameHandler.cpp

@@ -1037,19 +1037,9 @@ void CGameHandler::newTurn()
 		}
 		if ((**j).hasBonusOfType (Bonus::DARKNESS))
 		{
-			for (std::map<ui8, PlayerState>::iterator i = gs->players.begin(); i != gs->players.end(); i++)
-			{
-				if (player != i->first && i->second.status == PlayerState::INGAME) //TODO: team support
-				{
-					FoWChange fw;
-				    fw.mode = 0;
-					fw.player = i->first;
-					getTilesInRange (fw.tiles, (**j).getSightCenter(), (**j).getBonus(Selector::type(Bonus::DARKNESS))->val, i->first, -1);
-					sendAndApply (&fw);
-				}
-			}
+			(**j).hideTiles((**j).getOwner(), (**j).getBonus(Selector::type(Bonus::DARKNESS))->val);
 		}
-		//unhiding what shouldn't be hidden?
+		//unhiding what shouldn't be hidden? //that's handled in netpacks client
 	}
 
 	sendAndApply(&n);