Selaa lähdekoodia

part of minimap revealing

mateuszb 18 vuotta sitten
vanhempi
sitoutus
4a6ffa94d0
4 muutettua tiedostoa jossa 27 lisäystä ja 0 poistoa
  1. 17 0
      CAdvmapInterface.cpp
  2. 6 0
      CCallback.cpp
  3. 2 0
      CPlayerInterface.cpp
  4. 2 0
      SDL_Extensions.cpp

+ 17 - 0
CAdvmapInterface.cpp

@@ -777,6 +777,23 @@ void CMinimap::deactivate()
 	ClickableR::deactivate();
 	Hoverable::deactivate();
 }
+void CMinimap::showTile(int3 pos)
+{
+	int mw = map[0]->w, mh = map[0]->h,
+		wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
+	for (int ii=0; ii<wo; ii++)
+	{
+		for (int jj=0; jj<ho; jj++)
+		{
+			if ((pos.x+ii<this->pos.w-1) && (pos.y+jj<this->pos.h-1))
+				CSDL_Ext::SDL_PutPixel(FoW[pos.z],pos.x+ii,pos.y+jj,0,0,0,0,128);
+
+		}
+	}
+}
+void CMinimap::hideTile(int3 pos)
+{
+}
 CTerrainRect::CTerrainRect():currentPath(NULL)
 {
 	tilesw=19;

+ 6 - 0
CCallback.cpp

@@ -151,7 +151,13 @@ bool CCallback::moveHero(int ID, CPath * path, int idtype, int pathType)
 						int deltaX = (hero->getPosition(false).x-xd)*(hero->getPosition(false).x-xd);
 						int deltaY = (hero->getPosition(false).y-yd)*(hero->getPosition(false).y-yd);
 						if(deltaX+deltaY<hero->getSightDistance()*hero->getSightDistance())
+						{
+							if(gs->players[player].fogOfWarMap[xd][yd][hero->getPosition(false).z] == 0)
+							{
+								CGI->playerint[gs->players[player].serial]->tileRevealed(int3(xd, yd, hero->getPosition(false).z));
+							}
 							gs->players[player].fogOfWarMap[xd][yd][hero->getPosition(false).z] = 1;
+						}
 					}
 				}
 

+ 2 - 0
CPlayerInterface.cpp

@@ -1287,7 +1287,9 @@ void CPlayerInterface::removeObjToBlit(IShowable* obj)
 }
 void CPlayerInterface::tileRevealed(int3 pos)
 {
+	adventureInt->minimap.showTile(pos);
 }
 void CPlayerInterface::tileHidden(int3 pos)
 {
+	adventureInt->minimap.hideTile(pos);
 }

+ 2 - 0
SDL_Extensions.cpp

@@ -152,6 +152,8 @@ void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G,
 	p[0] = B;
 	p[1] = G;
 	p[2] = R;
+	if(ekran->format->BytesPerPixel==4)
+		p[3] = A;
 #endif
 	SDL_UpdateRect(ekran, x, y, 1, 1);
 }