From b0e72f334e9e239aad7dccebee7d306ae8bd2c3a Mon Sep 17 00:00:00 2001 From: mateuszb Date: Mon, 17 Sep 2007 17:36:20 +0000 Subject: [PATCH] small bugfix, move of one file --- CAdvmapInterface.cpp | 1 + CGameInfo.h | 2 ++ CMT.cpp | 55 +++++++++++++++-------------- SDL_Extensions.cpp | 25 +++++++++++++ SDL_Extensions.h | 1 + TERCOSTS.TXT => config/TERCOSTS.TXT | 0 hch/CHeroHandler.cpp | 2 +- 7 files changed, 58 insertions(+), 28 deletions(-) rename TERCOSTS.TXT => config/TERCOSTS.TXT (100%) diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index 0763e522d..141450aeb 100644 --- a/CAdvmapInterface.cpp +++ b/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(35,577)),(std::pair(120,577)),(std::pair(205,577)), diff --git a/CGameInfo.h b/CGameInfo.h index a39481975..ea40b2c7d 100644 --- a/CGameInfo.h +++ b/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 playerint; std::vector playerColors; + std::vector playerColorInfo; //gems from adventure map interface SDL_Color neutralColor; StartInfo scenarioOps; }; diff --git a/CMT.cpp b/CMT.cpp index e155576a5..436c35b10 100644 --- a/CMT.cpp +++ b/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 startres; - std::ifstream tis("config/startres.txt"); - int k; - for (int j=0;jscenarioOps.difficulty;j++) - { - tis >> k; - for (int z=0;z>k; - } - tis >> k; - for (int i=0;i> k; - startres.push_back(k); - } - tis.close(); - for (std::map::iterator i = cgi->state->players.begin(); i!=cgi->state->players.end(); i++) - { - (*i).second.resources.resize(RESOURCE_QUANTITY); - for (int x=0;xheroh->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 startres; + std::ifstream tis("config/startres.txt"); + int k; + for (int j=0;jscenarioOps.difficulty;j++) + { + tis >> k; + for (int z=0;z>k; + } + tis >> k; + for (int i=0;i> k; + startres.push_back(k); + } + tis.close(); + for (std::map::iterator i = cgi->state->players.begin(); i!=cgi->state->players.end(); i++) + { + (*i).second.resources.resize(RESOURCE_QUANTITY); + for (int x=0;x::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; diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index c0c66cc37..2fe05a9d6 100644 --- a/SDL_Extensions.cpp +++ b/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; iformat->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; aformat->palette->ncolors; ++a) + { + for(int s=0; splayerColorInfo[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) diff --git a/SDL_Extensions.h b/SDL_Extensions.h index 21eff6fab..2aa204aa1 100644 --- a/SDL_Extensions.h +++ b/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 & tor); //replaces %s in string }; diff --git a/TERCOSTS.TXT b/config/TERCOSTS.TXT similarity index 100% rename from TERCOSTS.TXT rename to config/TERCOSTS.TXT diff --git a/hch/CHeroHandler.cpp b/hch/CHeroHandler.cpp index ce88ba147..b65e8abc6 100644 --- a/hch/CHeroHandler.cpp +++ b/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)