Browse Source

minimap completety fixed (never use float for precise int calculations!)

mateuszb 18 years ago
parent
commit
56ed228cb1
4 changed files with 12 additions and 19 deletions
  1. 6 4
      CAdvmapInterface.cpp
  2. 3 13
      CMT.cpp
  3. 3 2
      CPlayerInterface.cpp
  4. BIN
      CPreGame.cpp

+ 6 - 4
CAdvmapInterface.cpp

@@ -650,8 +650,10 @@ void CMinimap::draw()
 	for (int i=0; i<hh.size();i++)
 	{
 		int3 hpos = hh[i]->getPosition(false);
-		float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
-		int3 maplgp ( zawx*mw, zawy*mh, hpos.z );
+		if(hpos.z!=LOCPLINT->adventureInt->position.z)
+			continue;
+		//float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
+		int3 maplgp ( (hpos.x*mw)/CGI->mh->sizes.x, (hpos.y*mh)/CGI->mh->sizes.y, hpos.z );
 		for (int ii=0; ii<wo; ii++)
 		{
 			for (int jj=0; jj<ho; jj++)
@@ -786,7 +788,7 @@ void CMinimap::showTile(int3 pos)
 	{
 		for (int jj=0; jj<ho; jj++)
 		{
-			if ((pos.x*wo+ii<this->pos.w-1) && (pos.y*ho+jj<this->pos.h-1))
+			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);
 
 		}
@@ -1336,7 +1338,7 @@ void CAdvMapInt::show()
 
 	infoBar.draw();
 
-	SDL_Flip(ekran);
+	CSDL_Ext::update(ekran);
 }
 void CAdvMapInt::hide()
 {

+ 3 - 13
CMT.cpp

@@ -768,21 +768,11 @@ int _tmain(int argc, _TCHAR* argv[])
 				{
 					for (int j=0; j<mh; j++)
 					{
-						int3 pp((((float)i/mw)*CGI->mh->sizes.x), (((float)j/mh)*CGI->mh->sizes.y), d);
-						/*pp.x = (((float)i/mw)*CGI->mh->sizes.x);
-						pp.y = (((float)j/mh)*CGI->mh->sizes.y);
-						pp.z = LOCPLINT->adventureInt->position.z;*/
+						int3 pp( ((i*CGI->mh->sizes.x)/mw), ((j*CGI->mh->sizes.y)/mh), d );
+
 						if ( !((CPlayerInterface*)cgi->playerint[g])->cb->isVisible(pp) )
 						{
-							for (int ii=0; ii<wo; ii++)
-							{
-								for (int jj=0; jj<ho; jj++)
-								{
-									if ((i+ii<mm.pos.w-1) && (j+jj<mm.pos.h-1))
-										CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i+ii,j+jj,0,0,0);
-
-								}
-							}
+							CSDL_Ext::SDL_PutPixelWithoutRefresh(pt,i,j,0,0,0);
 						}
 					}
 				}

+ 3 - 2
CPlayerInterface.cpp

@@ -371,7 +371,8 @@ void CPlayerInterface::yourTurn()
 		}
 		for(int i=0;i<objsToBlit.size();i++)
 			objsToBlit[i]->show();
-		SDL_Flip(ekran);
+		//SDL_Flip(ekran);
+		CSDL_Ext::update(ekran);
 		SDL_Delay(5); //give time for other apps
 		SDL_framerateDelay(mainFPSmng);
 	}
@@ -935,7 +936,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
 			std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
 		}
 		LOCPLINT->adventureInt->update(); //updating screen
-		SDL_Flip(ekran);
+		CSDL_Ext::update(ekran);
 		CGI->screenh->updateScreen();
 		LOCPLINT->adventureInt->anim++;
 		SDL_framerateDelay(mainFPSmng); //for animation purposes

BIN
CPreGame.cpp