Michał W. Urbańczyk 15 лет назад
Родитель
Сommit
3af697b91a
4 измененных файлов с 28 добавлено и 13 удалено
  1. 6 4
      client/mapHandler.cpp
  2. 18 8
      lib/CGameState.cpp
  3. 3 0
      lib/map.cpp
  4. 1 1
      lib/map.h

+ 6 - 4
client/mapHandler.cpp

@@ -325,8 +325,8 @@ static void processDef (CGDefInfo* def)
 			return;
 		}
 
-		def->width = def->handler->ourImages[0].bitmap->w/32;
-		def->height = def->handler->ourImages[0].bitmap->h/32;
+// 		def->width = def->handler->ourImages[0].bitmap->w/32;
+// 		def->height = def->handler->ourImages[0].bitmap->h/32;
 	}
 
 	CGDefInfo* pom = CGI->dobjinfo->gobjs[def->id][def->subid];
@@ -1348,14 +1348,16 @@ void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terN
 	TerrainTile2 &t = ttiles[pos.x][pos.y][pos.z];
 	for(std::vector < std::pair<const CGObjectInstance*,SDL_Rect> >::const_iterator i = t.objects.begin(); i != t.objects.end(); i++)
 	{
-		if(i->first->ID == 124)
+		if(i->first->ID == 124) //Hole
 		{
 			out = i->first->hoverName;
 			return;
 		}
 	}
 
-	if(terName)
+	if(t.tileInfo->siodmyTajemniczyBajt & 128)
+		out = CGI->generaltexth->names[225]; //Favourable Winds
+	else if(terName)
 		out = CGI->generaltexth->terrainNames[t.tileInfo->tertype];
 }
 

+ 18 - 8
lib/CGameState.cpp

@@ -1271,14 +1271,24 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
 	}
 
 	//randomizing objects
-	for(unsigned int no=0; no<map->objects.size(); ++no)
+	BOOST_FOREACH(CGObjectInstance *obj, map->objects)
 	{
-		randomizeObject(map->objects[no]);
-		if(map->objects[no]->ID==EVENTI_TYPE)
+		randomizeObject(obj);
+		if(obj->ID==EVENTI_TYPE)
 		{
-			map->objects[no]->defInfo->handler=NULL;
+			obj->defInfo->handler=NULL;
 		}
-		map->objects[no]->hoverName = VLC->generaltexth->names[map->objects[no]->ID];
+		obj->hoverName = VLC->generaltexth->names[obj->ID];
+
+		//handle Favouring Winds - mark tiles under it
+		if(obj->ID == 225)
+			for (int i = 0; i < obj->getWidth() ; i++)
+				for (int j = 0; j < obj->getHeight() ; j++)
+				{
+					int3 pos = obj->pos - int3(i,j,0);
+					if(map->isInTheMap(pos))
+						map->getTile(pos).siodmyTajemniczyBajt |= 128;
+				}
 	}
 	//std::cout<<"\tRandomizing objects: "<<th.getDif()<<std::endl;
 
@@ -1804,10 +1814,10 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const
 	}
 	else if (d.tertype == TerrainTile::water)
 	{
-		if (!h->boat && h->getBonusesCount(Selector::typeSybtype(Bonus::WATER_WALKING, 1)) > 0)
-		{
+		if(h->boat && s.siodmyTajemniczyBajt & 128 && d.siodmyTajemniczyBajt & 128) //Favourable Winds
+			ret *= 0.666f;
+		else if (!h->boat && h->getBonusesCount(Selector::typeSybtype(Bonus::WATER_WALKING, 1)) > 0)
 			ret *= 1.4f; //40% penalty for water walking
-		}
 	}
 
 	if(src.x != dest.x  &&  src.y != dest.y) //it's diagonal move

+ 3 - 0
lib/map.cpp

@@ -1338,6 +1338,9 @@ void Mapa::readDefInfo( const unsigned char * bufor, int &i)
 		//calculating coverageMap
 		std::string nameCopy = vinya->name;
 		std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" ));
+
+		vinya->width = msk[0];
+		vinya->height = msk[1];
 		for(int i=0; i<6; ++i)
 		{
 			vinya->coverageMap[i] = msk[i+2];

+ 1 - 1
lib/map.h

@@ -77,7 +77,7 @@ struct DLL_EXPORT TerrainTile
 	unsigned char rivDir; // direction of Eriver
 	Eroad malle; // type of Eroad (0 if there is no river)
 	unsigned char roadDir; // direction of Eroad
-	unsigned char siodmyTajemniczyBajt; //bitfield, info whether this tile is coastal and how to rotate tile graphics
+	unsigned char siodmyTajemniczyBajt; //first two bits - how to rotate terrain graphic (next two - river graphic, next two - road); 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favourable Winds effect
 
 	bool visitable; //false = not visitable; true = visitable
 	bool blocked; //false = free; true = blocked;