2
0
Эх сурвалжийг харах

small bugfix, move of one file

mateuszb 18 жил өмнө
parent
commit
b0e72f334e

+ 1 - 0
CAdvmapInterface.cpp

@@ -754,6 +754,7 @@ CResDataBar::CResDataBar()
 	bg = CGI->bitmaph->loadBitmap("ZRESBAR.bmp");
 	SDL_SetColorKey(bg,SDL_SRCCOLORKEY,SDL_MapRGB(bg->format,0,255,255));
 	blueToPlayersAdv(bg,LOCPLINT->playerID);
+	//blueToPlayersNice(bg,LOCPLINT->playerID);
 	pos = genRect(bg->h,bg->w,3,575);
 
 	txtpos  +=  (std::pair<int,int>(35,577)),(std::pair<int,int>(120,577)),(std::pair<int,int>(205,577)),

+ 2 - 0
CGameInfo.h

@@ -31,6 +31,7 @@ class CGameState;
 class CMapHandler;
 class CGameInterface;
 class CPreGame;
+class CDefHandler;
 /*
 	CGameInfo class
 	for allowing different functions for modifying game informations
@@ -64,6 +65,7 @@ public:
 	int localPlayer;
 	std::vector<CGameInterface *> playerint;
 	std::vector<SDL_Color> playerColors;
+	std::vector<CDefHandler *> playerColorInfo; //gems from adventure map interface
 	SDL_Color neutralColor;
 	StartInfo scenarioOps;
 };

+ 28 - 27
CMT.cpp

@@ -85,36 +85,10 @@ TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX, *GEORM;
 
 void initGameState(CGameInfo * cgi)
 {
-	/******************RESOURCES****************************************************/
-	//TODO: zeby komputer dostawal inaczej niz gracz
-	std::vector<int> startres;
-	std::ifstream tis("config/startres.txt");
-	int k;
-	for (int j=0;j<cgi->scenarioOps.difficulty;j++)
-	{
-		tis >> k;
-		for (int z=0;z<RESOURCE_QUANTITY;z++)
-			tis>>k;
-	}
-	tis >> k;
-	for (int i=0;i<RESOURCE_QUANTITY;i++)
-	{
-		tis >> k;
-		startres.push_back(k);
-	}
-	tis.close();
-	for (std::map<int,PlayerState>::iterator i = cgi->state->players.begin(); i!=cgi->state->players.end(); i++)
-	{
-		(*i).second.resources.resize(RESOURCE_QUANTITY);
-		for (int x=0;x<RESOURCE_QUANTITY;x++)
-			(*i).second.resources[x] = startres[x];
-
-	}
-
 	/*************************HEROES************************************************/
 	for (int i=0; i<cgi->heroh->heroInstances.size();i++) //heroes instances
 	{
-		if (!cgi->heroh->heroInstances[i]->type || cgi->heroh->heroInstances[i]->owner<0)
+		if (!cgi->heroh->heroInstances[i]->type || cgi->heroh->heroInstances[i]->owner<0 || cgi->heroh->heroInstances[i]->owner==255)
 			continue;
 		CHeroInstance * vhi = new CHeroInstance();
 		*vhi=*(cgi->heroh->heroInstances[i]);
@@ -147,6 +121,31 @@ void initGameState(CGameInfo * cgi)
 
 		cgi->state->players[vhi->owner].heroes.push_back(vhi);
 
+	}
+	/******************RESOURCES****************************************************/
+	//TODO: zeby komputer dostawal inaczej niz gracz
+	std::vector<int> startres;
+	std::ifstream tis("config/startres.txt");
+	int k;
+	for (int j=0;j<cgi->scenarioOps.difficulty;j++)
+	{
+		tis >> k;
+		for (int z=0;z<RESOURCE_QUANTITY;z++)
+			tis>>k;
+	}
+	tis >> k;
+	for (int i=0;i<RESOURCE_QUANTITY;i++)
+	{
+		tis >> k;
+		startres.push_back(k);
+	}
+	tis.close();
+	for (std::map<int,PlayerState>::iterator i = cgi->state->players.begin(); i!=cgi->state->players.end(); i++)
+	{
+		(*i).second.resources.resize(RESOURCE_QUANTITY);
+		for (int x=0;x<RESOURCE_QUANTITY;x++)
+			(*i).second.resources[x] = startres[x];
+
 	}
 	/*************************FOG**OF**WAR******************************************/		
 	for(std::map<int, PlayerState>::iterator k=cgi->state->players.begin(); k!=cgi->state->players.end(); ++k)
@@ -288,6 +287,8 @@ int _tmain(int argc, _TCHAR* argv[])
 		cgi->playerColors.push_back(p);//pink
 		p.r = 0x84; p.g = 0x84; p.b = 0x84;//gray
 		cgi->neutralColor = p;//gray
+
+		cgi->playerColorInfo.push_back(cgi->spriteh->giveDef("agemLL.def")); //todo: finish
 		//colors initialized
 
 		cgi->townh = new CTownHandler;

+ 25 - 0
SDL_Extensions.cpp

@@ -530,6 +530,8 @@ void CSDL_Ext::blueToPlayers(SDL_Surface * sur, int player)
 
 void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player)
 {
+	if(player==1) //it is actually blue...
+		return;
 	if(sur->format->BitsPerPixel == 8)
 	{
 		for(int i=0; i<sur->format->palette->ncolors; ++i)
@@ -621,6 +623,29 @@ void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player)
 	}
 }
 
+void CSDL_Ext::blueToPlayersNice(SDL_Surface * sur, int player) //incomplete, TODO: finish
+{
+	if(sur->format->BitsPerPixel==8)
+	{
+		for(int a=0; a<sur->format->palette->ncolors; ++a)
+		{
+			for(int s=0; s<CGI->playerColorInfo[0]->ourImages[1].bitmap->format->palette->ncolors; ++s)
+			{
+				if(abs((sur->format->palette->colors+a)->b - (CGI->playerColorInfo[0]->ourImages[1].bitmap->format->palette->colors+s)->b) < 5
+					&& abs((sur->format->palette->colors+a)->g - (CGI->playerColorInfo[0]->ourImages[1].bitmap->format->palette->colors+s)->g) < 5
+					&& abs((sur->format->palette->colors+a)->r - (CGI->playerColorInfo[0]->ourImages[1].bitmap->format->palette->colors+s)->r) < 5
+					)
+				{
+					(sur->format->palette->colors+a)->b = (CGI->playerColorInfo[0]->ourImages[player].bitmap->format->palette->colors+s)->b;
+					(sur->format->palette->colors+a)->r = (CGI->playerColorInfo[0]->ourImages[player].bitmap->format->palette->colors+s)->g;
+					(sur->format->palette->colors+a)->g = (CGI->playerColorInfo[0]->ourImages[player].bitmap->format->palette->colors+s)->r;
+					break;
+				}
+			}
+		}
+	}
+}
+
 void CSDL_Ext::setPlayerColor(SDL_Surface * sur, int player)
 {
 	if(sur->format->BitsPerPixel==8)

+ 1 - 0
SDL_Extensions.h

@@ -31,6 +31,7 @@ namespace CSDL_Ext
 	void update(SDL_Surface * what = ekran); //updates whole surface (default - main screen)
 	void blueToPlayers(SDL_Surface * sur, int player); //simple color substitution
 	void blueToPlayersAdv(SDL_Surface * sur, int player); //substitute blue color by another one, makes it nicer keeping nuances
+	void blueToPlayersNice(SDL_Surface * sur, int player); //uses interface gems to substitute colours
 	void setPlayerColor(SDL_Surface * sur, int player); //sets correct color of flags; -1 for neutral
 	std::string processStr(std::string str, std::vector<std::string> & tor); //replaces %s in string
 };

+ 0 - 0
TERCOSTS.TXT → config/TERCOSTS.TXT


+ 1 - 1
hch/CHeroHandler.cpp

@@ -442,7 +442,7 @@ unsigned int CHeroInstance::getLowestCreatureSpeed()
 void CHeroHandler::initTerrainCosts()
 {
 	std::ifstream inp;
-	inp.open("TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
+	inp.open("config\\TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
 	int tynum;
 	inp>>tynum;
 	for(int i=0; i<2*tynum; i+=2)