Browse Source

* working minimap's FoW
* properly displayed neutral buildings' flags

mateuszb 17 years ago
parent
commit
92971e0df0
3 changed files with 37 additions and 39 deletions
  1. 36 11
      CAdvmapInterface.cpp
  2. 0 27
      CMT.cpp
  3. 1 1
      client/Graphics.cpp

+ 36 - 11
CAdvmapInterface.cpp

@@ -93,6 +93,7 @@ CMinimap::CMinimap(bool draw)
 		colorsBlocked.insert(vinya2);
 		colorsBlocked.insert(vinya2);
 	}
 	}
 	is.close();
 	is.close();
+
 	if (draw)
 	if (draw)
 		redraw();
 		redraw();
 }
 }
@@ -121,7 +122,7 @@ void CMinimap::draw()
 			}
 			}
 		}
 		}
 	}
 	}
-	//blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
+	blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
 
 
 	//draw radar
 	//draw radar
 	int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
 	int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)CGI->mh->sizes.x)))*pos.w,
@@ -155,6 +156,30 @@ void CMinimap::redraw(int level)// (level==-1) => redraw all levels
 		map.push_back(pom);
 		map.push_back(pom);
 
 
 	}
 	}
+
+	//FoW
+	int mw = map[0]->w, mh = map[0]->h,
+		wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
+	for(int d=0; d<CGI->mh->map->twoLevel+1; ++d)
+	{
+		if(level>=0 && d!=level)
+			continue;
+		SDL_Surface * pt = CSDL_Ext::newSurface(pos.w, pos.h, CSDL_Ext::std32bppSurface);
+		for (int i=0; i<mw; i++)
+		{
+			for (int j=0; j<mh; j++)
+			{
+				int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
+				if ( !LOCPLINT->cb->isVisible(pp) )
+				{
+					CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
+				}
+			}
+		}
+		CSDL_Ext::update(pt);
+		FoW.push_back(pt);
+	}
+	//FoW end
 }
 }
 void CMinimap::updateRadar()
 void CMinimap::updateRadar()
 {}
 {}
@@ -217,17 +242,17 @@ void CMinimap::deactivate()
 }
 }
 void CMinimap::showTile(int3 pos)
 void CMinimap::showTile(int3 pos)
 {
 {
-	//int mw = map[0]->w, mh = map[0]->h;
-	//double wo = ((double)mw)/CGI->mh->sizes.x, ho = ((double)mh)/CGI->mh->sizes.y;
-	//for (int ii=0; ii<wo; ii++)
-	//{
-	//	for (int jj=0; jj<ho; jj++)
-	//	{
-	//		if ((pos.x*wo+ii<this->pos.w) && (pos.y*ho+jj<this->pos.h))
-	//			CSDL_Ext::SDL_PutPixel(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0,0,0);
+	int mw = map[0]->w, mh = map[0]->h;
+	double wo = ((double)mw)/CGI->mh->sizes.x, ho = ((double)mh)/CGI->mh->sizes.y;
+	for (int ii=0; ii<wo; ii++)
+	{
+		for (int jj=0; jj<ho; jj++)
+		{
+			if ((pos.x*wo+ii<this->pos.w) && (pos.y*ho+jj<this->pos.h))
+				CSDL_Ext::SDL_PutPixel(FoW[pos.z],pos.x*wo+ii,pos.y*ho+jj,0,0,0,0,0);
 
 
-	//	}
-	//}
+		}
+	}
 }
 }
 void CMinimap::hideTile(int3 pos)
 void CMinimap::hideTile(int3 pos)
 {
 {

+ 0 - 27
CMT.cpp

@@ -167,33 +167,6 @@ int main(int argc, _TCHAR* argv[])
 			events.push(ev);
 			events.push(ev);
 			eventsM.unlock();
 			eventsM.unlock();
 		}
 		}
-		///claculating FoWs for minimap
-		/****************************Minimaps' FoW******************************************/
-		//for(int g=0; g<cgi->playerint.size(); ++g)
-		//{
-		//	if(!cgi->playerint[g]->human)
-		//		continue;
-		//	CMinimap & mm = ((CPlayerInterface*)cgi->playerint[g])->adventureInt->minimap;
-		//	int mw = mm.map[0]->w, mh = mm.map[0]->h,
-		//		wo = mw/CGI->mh->sizes.x, ho = mh/CGI->mh->sizes.y;
-		//	for(int d=0; d<cgi->mh->map->twoLevel+1; ++d)
-		//	{
-		//		SDL_Surface * pt = CSDL_Ext::newSurface(mm.pos.w, mm.pos.h, CSDL_Ext::std32bppSurface);
-		//		for (int i=0; i<mw; i++)
-		//		{
-		//			for (int j=0; j<mh; j++)
-		//			{
-		//				int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
-		//				if ( !((CPlayerInterface*)cgi->playerint[g])->cb->isVisible(pp) )
-		//				{
-		//					CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
-		//				}
-		//			}
-		//		}
-		//		CSDL_Ext::update(pt);
-		//		mm.FoW.push_back(pt);
-		//	}
-		//}
 	}
 	}
 	else
 	else
 	{
 	{

+ 1 - 1
client/Graphics.cpp

@@ -115,7 +115,7 @@ void Graphics::loadPaletteAndColors()
 		playerColors[i].b = kolory[i].z;
 		playerColors[i].b = kolory[i].z;
 		playerColors[i].unused = 0;
 		playerColors[i].unused = 0;
 	}
 	}
-	neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84;//gray
+	neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 0x0;//gray
 }	
 }	
 void Graphics::initializeBattleGraphics()
 void Graphics::initializeBattleGraphics()
 {
 {