diff --git a/CAdvmapInterface.cpp b/CAdvmapInterface.cpp index b0230b28b..fdd64a2f2 100644 --- a/CAdvmapInterface.cpp +++ b/CAdvmapInterface.cpp @@ -1252,7 +1252,8 @@ void CAdvMapInt::update() } } if(updateScreen) - { + { + CGI->mh->updateWater(); terrain.show(); for(int i=0;i<4;i++) blitAt(gems[i]->ourImages[LOCPLINT->playerID].bitmap,ADVOPT.gemX[i],ADVOPT.gemY[i]); diff --git a/CGameState.cpp b/CGameState.cpp index ab73e366d..5c97c28b4 100644 --- a/CGameState.cpp +++ b/CGameState.cpp @@ -1392,13 +1392,13 @@ int CGameState::battleGetStack(int pos) return -1; for(int g=0; gstacks.size(); ++g) { - if(curB->stacks[g]->position == pos || - ( curB->stacks[g]->creature->isDoubleWide() && - ( (curB->stacks[g]->attackerOwned && curB->stacks[g]->position-1 == pos) || - (!curB->stacks[g]->attackerOwned && curB->stacks[g]->position+1 == pos) - ) - ) - ) + if((curB->stacks[g]->position == pos + || (curB->stacks[g]->creature->isDoubleWide() + &&( (curB->stacks[g]->attackerOwned && curB->stacks[g]->position-1 == pos) + || (!curB->stacks[g]->attackerOwned && curB->stacks[g]->position+1 == pos) ) + )) + && curB->stacks[g]->alive() + ) return curB->stacks[g]->ID; } return -1; diff --git a/CHeroWindow.cpp b/CHeroWindow.cpp index 68f12936b..5d65f182e 100644 --- a/CHeroWindow.cpp +++ b/CHeroWindow.cpp @@ -269,7 +269,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero) artWorn[g] = new CArtPlace(hero->getArt(g)); artWorn[g]->pos = slotPos[g]; if(hero->getArt(g)) - artWorn[g]->text = hero->getArt(g)->description; + artWorn[g]->text = hero->getArt(g)->Description(); artWorn[g]->ourWindow = this; } @@ -278,7 +278,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero) artWorn[g]->slotID = g; if(artWorn[g]->ourArt) { - sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), artWorn[g]->ourArt->name.c_str()); + sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), artWorn[g]->ourArt->Name().c_str()); artWorn[g]->hoverText = std::string(bufor); } else @@ -293,7 +293,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero) if( s < curHero->artifacts.size() ) { add = new CArtPlace(&CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]]); - sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), add->ourArt->name.c_str()); + sprintf(bufor, CGI->generaltexth->heroscrn[1].c_str(), add->ourArt->Name().c_str()); add->hoverText = bufor; } else @@ -305,7 +305,7 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero) add->pos.y = pos.y + 365; add->pos.h = add->pos.w = 44; if(sartifacts.size() && hero->artifacts[s]) - add->text = hero->getArt(19+s)->description; + add->text = hero->getArt(19+s)->Description(); else add->text = std::string(); add->ourWindow = this; @@ -468,7 +468,7 @@ void CHeroWindow::leftArtRoller() { backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ]]; if(backpack[s]->ourArt) - backpack[s]->text = backpack[s]->ourArt->description; + backpack[s]->text = backpack[s]->ourArt->Description(); else backpack[s]->text = std::string(); } @@ -485,7 +485,7 @@ void CHeroWindow::rightArtRoller() { backpack[s]->ourArt = &CGI->arth->artifacts[curHero->artifacts[(s+backpackPos) % curHero->artifacts.size() ] ]; if(backpack[s]->ourArt) - backpack[s]->text = backpack[s]->ourArt->description; + backpack[s]->text = backpack[s]->ourArt->Description(); else backpack[s]->text = std::string(); } @@ -719,11 +719,11 @@ void CArtPlace::clickLeft(boost::logic::tribool down) //set texts if(pmh) - ourWindow->activeArtPlace->text = pmh->description; + ourWindow->activeArtPlace->text = pmh->Description(); else ourWindow->activeArtPlace->text = std::string(); if(ourArt) - text = ourArt->description; + text = ourArt->Description(); else text = std::string(); diff --git a/CMT.cpp b/CMT.cpp index a23e9e06d..beb562850 100644 --- a/CMT.cpp +++ b/CMT.cpp @@ -114,6 +114,7 @@ int main(int argc, char** argv) cgi->bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data"); tlog0<<"Loading .lod files: "<bitmaph,::console,logfile); + CGI->generaltexth = VLC->generaltexth; CGI->arth = VLC->arth; CGI->creh = VLC->creh; CGI->townh = VLC->townh; @@ -122,7 +123,6 @@ int main(int argc, char** argv) CGI->spellh = VLC->spellh; CGI->dobjinfo = VLC->dobjinfo; CGI->buildh = VLC->buildh; - CGI->generaltexth = VLC->generaltexth; tlog0<<"Initializing VCMI_Lib: "<curh = new CCursorHandler; diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index fd1aea758..149555c15 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -626,8 +626,8 @@ void SComponent::init(Etype Type, int Subtype, int Val) switch (Type) { case artifact: - description = CGI->arth->artifacts[Subtype].description; - subtitle = CGI->arth->artifacts[Subtype].name; + description = CGI->arth->artifacts[Subtype].Description(); + subtitle = CGI->arth->artifacts[Subtype].Name(); break; case primskill: description = CGI->generaltexth->arraytxt[2+Subtype]; @@ -2255,36 +2255,7 @@ void CPlayerInterface::heroArtifactSetChanged(const CGHeroInstance*hero) void CPlayerInterface::updateWater() { - //updating water tiles - //int wnumber = -1; - //for(int s=0; smh->reader->defs.size(); ++s) - //{ - // if(CGI->mh->reader->defs[s]->defName==std::string("WATRTL.DEF")) - // { - // wnumber = s; - // break; - // } - //} - //if(wnumber>=0) - //{ - // for(int g=0; gmh->reader->defs[wnumber]->ourImages.size(); ++g) - // { - // SDL_Color tab[32]; - // for(int i=0; i<32; ++i) - // { - // tab[i] = CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + (i+1)%32]; - // } - // //SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t1.bmp"); - // for(int i=0; i<32; ++i) - // { - // CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap->format->palette->colors[160 + i] = tab[i]; - // } - // //SDL_SaveBMP(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap,"t2.bmp"); - // CSDL_Ext::update(CGI->mh->reader->defs[wnumber]->ourImages[g].bitmap); - // } - //} - //water tiles updated - //CGI->screenh->updateScreen(); + } void CPlayerInterface::availableCreaturesChanged( const CGTownInstance *town ) @@ -2643,7 +2614,8 @@ CTownList::CTownList(int Size, int x, int y, std::string arrupg, std::string arr arrdo = CDefHandler::giveDef(arrdog); pos.x = x; pos.y = y; - pos.w = std::max(arrdo->width, arrup->height); + pos.w = std::max(arrdo->width, arrup->width); + pos.h = arrdo->height + arrup->height + Size*32; arrupp.x=x; arrupp.y=y; diff --git a/ChangeLog b/ChangeLog index e05eea5e4..39310a0f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,19 @@ -0.64 -> 0.next (???) [as for r639] +0.64 -> 0.next (???) [as for r651] GENERAL: * move some settings to the config/settings.txt file * partial support for new screen resolutions * /Data and /Sprites subfolders can be used for adding files not present in .lod archives * fixed crashbug occuring when hero levelled above 15 level +ADVENTURE INTERFACE: +* added water animation + +TOWN INTERFACE: +* the scroll tab won't remain hanged to our mouse position if we move the mouse away from the scroll bar +* fixed cloning creatures bug in garrisons (and related issues) + BATTLES +* support for the Wait command * magic arrow *really* works * war machines support partially added * queue of stacks narrowed @@ -17,6 +25,10 @@ BATTLES c) ice bolt d) slow e) implosion + f) forgetfulness + +AI: +* Genius AI (first VCMI AI) will control computer creatures during the combat. GENERAL: * started making external settings file (will be used for support for non 800x600 screen resolutions) diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index a536a21ea..3b7ee7c2b 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -272,14 +272,7 @@ SDL_Surface * CSDL_Ext::rotate01(SDL_Surface * toRot) { { Uint8 *p = (Uint8 *)toRot->pixels + j * toRot->pitch + (ret->w - i - 1) * toRot->format->BytesPerPixel; -/* - -#if(SDL_BYTEORDER == SDL_BIG_ENDIAN) - CSDL_Ext::SDL_PutPixelWithoutRefresh(ret, i, j, p[0], p[1], p[2]); -#else -*/ - CSDL_Ext::SDL_PutPixelWithoutRefresh(ret, i, j, p[2], p[1], p[0]); -//#endif + CSDL_Ext::SDL_PutPixelWithoutRefresh(ret, i, j, p[2], p[1], p[0]); } } } @@ -493,6 +486,54 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src) } return src; } +// <=> +void CSDL_Ext::blitWithRotate1(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect)//srcRect is not used, works with 8bpp sources and 24bpp dests +{ + Uint8 *dp, *sp = (Uint8 *)src->pixels; + for(int i=0; ih; i++) + { + dp = (Uint8 *)dst->pixels + (i+dstRect->y)*dst->pitch + (dstRect->x+dstRect->w)*dst->format->BytesPerPixel; + for(int j=0; jw; j++, sp++) + { + const SDL_Color * const color = src->format->palette->colors+(*sp); + *(--dp) = color->r; + *(--dp) = color->g; + *(--dp) = color->b; + } + } +} + +void CSDL_Ext::blitWithRotate2(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect)//srcRect is not used, works with 8bpp sources and 24bpp dests +{ + Uint8 *dp, *sp = (Uint8 *)src->pixels; + for(int i=0; ih; i++) + { + dp = (Uint8 *)dst->pixels + (dstRect->y + dstRect->h - 1 - i)*dst->pitch + dstRect->x*dst->format->BytesPerPixel; + for(int j=0; jw; j++, sp++) + { + const SDL_Color * const color = src->format->palette->colors+(*sp); + *(dp++) = color->b; + *(dp++) = color->g; + *(dp++) = color->r; + } + } +} + +void CSDL_Ext::blitWithRotate3(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect)//srcRect is not used, works with 8bpp sources and 24bpp dests +{ + Uint8 *dp, *sp = (Uint8 *)src->pixels; + for(int i=0; ih; i++) + { + dp = (Uint8 *)dst->pixels + (dstRect->y + dstRect->h - 1 - i)*dst->pitch + (dstRect->x+dstRect->w)*dst->format->BytesPerPixel; + for(int j=0; jw; j++, sp++) + { + const SDL_Color * const color = src->format->palette->colors+(*sp); + *(--dp) = color->r; + *(--dp) = color->g; + *(--dp) = color->b; + } + } +} int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect) { @@ -518,8 +559,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su } /* clip the source rectangle to the source surface */ - if(srcRect) { - int maxw, maxh; + if(srcRect) + { + int maxw, maxh; srcx = srcRect->x; w = srcRect->w; @@ -543,7 +585,9 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su if(maxh < h) h = maxh; - } else { + } + else + { srcx = srcy = 0; w = src->w; h = src->h; diff --git a/SDL_Extensions.h b/SDL_Extensions.h index 3c2a310c7..7390eb3f5 100644 --- a/SDL_Extensions.h +++ b/SDL_Extensions.h @@ -34,6 +34,9 @@ namespace CSDL_Ext Uint32 SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y, bool colorByte = false); SDL_Color SDL_GetPixelColor(SDL_Surface *surface, int x, int y); SDL_Surface * alphaTransform(SDL_Surface * src); //adds transparency and shadows (partial handling only; see examples of using for details) + void blitWithRotate1(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect);//srcRect is not used, works with 8bpp sources and 24bpp dests + void blitWithRotate2(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect);//srcRect is not used, works with 8bpp sources and 24bpp dests + void blitWithRotate3(SDL_Surface *src,SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect);//srcRect is not used, works with 8bpp sources and 24bpp dests int blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Surface * dst, SDL_Rect * dstRect); //blits 8 bpp surface with alpha channel to 24 bpp surface Uint32 colorToUint32(const SDL_Color * color); //little endian only void printTo(const std::string & text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=screen, unsigned char quality = 2);// quality: 0 - lowest, 1 - medium, 2 - highest; prints at right bottom corner of specific area. position of corner indicated by (x, y) diff --git a/client/Client.cpp b/client/Client.cpp index 4bc0ee43d..b87306c1a 100644 --- a/client/Client.cpp +++ b/client/Client.cpp @@ -36,7 +36,7 @@ std::string toString(MetaString &ms) ser = ms.texts[-ms.message[i]-1].second; if(type == 5) { - ret += CGI->arth->artifacts[ser].name; + ret += CGI->arth->artifacts[ser].Name(); continue; } else if(type == 7) diff --git a/hch/CArtHandler.cpp b/hch/CArtHandler.cpp index ab5dfe07c..c793ea41d 100644 --- a/hch/CArtHandler.cpp +++ b/hch/CArtHandler.cpp @@ -2,6 +2,7 @@ #include "../stdafx.h" #include "CArtHandler.h" #include "CLodHandler.h" +#include "CGeneralTextHandler.h" #include #include #include "../lib/VCMI_Lib.h" @@ -23,10 +24,12 @@ void CArtHandler::loadArtifacts() { loadToIt(dump,buf,it,3); } + VLC->generaltexth->artifNames.resize(ARTIFACTS_QUANTITY); + VLC->generaltexth->artifDescriptions.resize(ARTIFACTS_QUANTITY); for (int i=0; igeneraltexth->artifNames[i],buf,it,4); loadToIt(pom,buf,it,4); nart.price=atoi(pom.c_str()); for(int j=0;jgeneraltexth->artifDescriptions[i],buf,it,3); nart.id=i; artifacts.push_back(nart); } @@ -95,4 +98,20 @@ void CArtHandler::sortArts() break; } } +} + +const std::string & CArtifact::Name() const +{ + if(name.size()) + return name; + else + return VLC->generaltexth->artifNames[id]; +} + +const std::string & CArtifact::Description() const +{ + if(description.size()) + return description; + else + return VLC->generaltexth->artifDescriptions[id]; } \ No newline at end of file diff --git a/hch/CArtHandler.h b/hch/CArtHandler.h index 7db2e3311..8896e021d 100644 --- a/hch/CArtHandler.h +++ b/hch/CArtHandler.h @@ -9,10 +9,11 @@ class CDefHandler; class DLL_EXPORT CArtifact //container for artifacts { + std::string name, description; //set if custom public: + const std::string &Name() const; + const std::string &Description() const; bool isAllowed; //true if we can use this artifact (map information) - std::string name; - std::string description; //std::string desc2; unsigned int price; std::vector possibleSlots; //ids of slots where artifact can be placed diff --git a/hch/CGeneralTextHandler.h b/hch/CGeneralTextHandler.h index e99d8a434..c5313a8b8 100644 --- a/hch/CGeneralTextHandler.h +++ b/hch/CGeneralTextHandler.h @@ -22,6 +22,8 @@ public: std::vector jktexts; std::vector heroscrn; std::vector artifEvents; + std::vector artifNames; + std::vector artifDescriptions; std::vector > zelp; std::string lossCondtions[4]; diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 026b1d461..4e04a0685 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -29,6 +29,11 @@ DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream * bitmaph=b; VLC = new LibClasses; + VLC->generaltexth = new CGeneralTextHandler; + VLC->generaltexth->loadTexts(); + VLC->generaltexth->load(); + tlog0<<"\tGeneral text handler: "<loadHeroes(); VLC->heroh = heroh; @@ -65,11 +70,6 @@ DLL_EXPORT void initDLL(CLodHandler *b, CConsoleHandler *Console, std::ostream * spellh->loadSpells(); VLC->spellh = spellh; tlog0<<"\tSpell handler: "<generaltexth = new CGeneralTextHandler; - VLC->generaltexth->loadTexts(); - VLC->generaltexth->load(); - tlog0<<"\tGeneral text handler: "<ourImages[i].bitmap); } - //visibility.resize(map->width+2*Woff); - //for(int gg=0; ggwidth+2*Woff; ++gg) - //{ - // visibility[gg].resize(map->height+2*Hoff); - // for(int jj=0; jjheight+2*Hoff; ++jj) - // visibility[gg][jj] = true; - //} - - //visibility.resize(CGI->mh->map->width, Woff); - //for (int i=0-Woff;imh->map->height,Hoff); - //} - //for (int i=0-Woff; imh->map->height+Hoff; ++j) - // { - // visibility[i][j].resize(CGI->mh->map->twoLevel+1,0); - // for(int k=0; kmh->map->twoLevel+1; ++k) - // visibility[i][j][k]=true; - // } - //} hideBitmap.resize(CGI->mh->map->width); for (int i=0;inotFreeImgs = true; + terrainGraphics.resize(10); + for (int i = 0; i < 10 ; i++) + { + CDefHandler *hlp = CDefHandler::giveDef(nameFromType(i)); + terrainGraphics[i].resize(hlp->ourImages.size()); + hlp->notFreeImgs = true; + for(int j=0; jourImages.size();j++) + terrainGraphics[i][j] = hlp->ourImages[j].bitmap; + delete hlp; + } + for (int i=0-Woff; iwidth+Woff; i++) //jest po szerokości { for (int j=0-Hoff; jheight+Hoff;j++) //po wysokości @@ -307,99 +296,47 @@ void CMapHandler::borderAndTerrainBitmapInit() { if(i==-1 && j==-1) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[16].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[16].bitmap; continue; } else if(i==-1 && j==(map->height)) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[19].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[19].bitmap; continue; } else if(i==(map->width) && j==-1) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[17].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[17].bitmap; continue; } else if(i==(map->width) && j==(map->height)) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[18].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[18].bitmap; continue; } else if(j == -1 && i > -1 && i < map->height) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[22+rand()%2].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[22+rand()%2].bitmap; continue; } else if(i == -1 && j > -1 && j < map->height) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[33+rand()%2].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[33+rand()%2].bitmap; continue; } else if(j == map->height && i >-1 && i < map->width) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[29+rand()%2].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[29+rand()%2].bitmap; continue; } else if(i == map->width && j > -1 && j < map->height) { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[25+rand()%2].bitmap); + ttiles[i][j][k].terbitmap = bord->ourImages[25+rand()%2].bitmap; continue; } else { - ttiles[i][j][k].terbitmap.push_back(bord->ourImages[rand()%16].bitmap); - continue; - } - } - //TerrainTile zz = map->terrain[i-Woff][j-Hoff]; - std::string name; - if (k>0) - name = nameFromType(map->terrain[i][j][1].tertype); - else - name = nameFromType(map->terrain[i][j][0].tertype); - for (unsigned int m=0; mdefName != name) - continue; - else - { - int ktora; - if (k==0) - ktora = map->terrain[i][j][0].terview; - else - ktora = map->terrain[i][j][1].terview; - ttiles[i][j][k].terbitmap.push_back(defs[m]->ourImages[ktora].bitmap); - int zz; - if (k==0) - zz = (map->terrain[i][j][0].siodmyTajemniczyBajt)%4; - else - zz = (map->terrain[i][j][1].siodmyTajemniczyBajt)%4; - switch (zz) - { - case 1: - { - ttiles[i][j][k].terbitmap[0] = CSDL_Ext::rotate01(ttiles[i][j][k].terbitmap[0]); - break; - } - case 2: - { - ttiles[i][j][k].terbitmap[0] = CSDL_Ext::hFlip(ttiles[i][j][k].terbitmap[0]); - break; - } - case 3: - { - ttiles[i][j][k].terbitmap[0] = CSDL_Ext::rotate03(ttiles[i][j][k].terbitmap[0]); - break; - } - } - - break; - } - } - catch (...) - { + ttiles[i][j][k].terbitmap = bord->ourImages[rand()%16].bitmap; continue; } } @@ -491,8 +428,6 @@ void CMapHandler::init() { timeHandler th; th.getDif(); - loadDefs(); //loading castles' defs - tlog0<<"Reading terrain defs: "<siodmyTajemniczyBajt%4) + { + case 0: + SDL_BlitSurface(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview], + &genRect(sr.h, sr.w, 0, 0),su,&sr); + break; + case 1: + CSDL_Ext::blitWithRotate1(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview], + &genRect(sr.h, sr.w, 0, 0),su,&sr); + break; + case 2: + CSDL_Ext::blitWithRotate2(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview], + &genRect(sr.h, sr.w, 0, 0),su,&sr); + break; + default: + CSDL_Ext::blitWithRotate3(terrainGraphics[tile.tileInfo->tertype][tile.tileInfo->terview], + &genRect(sr.h, sr.w, 0, 0),su,&sr); + break; + } + } } } ////terrain printed @@ -736,8 +696,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, sr.x=bx*32; sr.h=sr.w=32; validateRectTerr(&sr, extRect); - - SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr); + SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap,&genRect(sr.h, sr.w, 0, 0),su,&sr); } else { @@ -1286,26 +1245,24 @@ unsigned char CMapHandler::getDir(const int3 &a, const int3 &b) return -2; //shouldn't happen } - -void CMapHandler::loadDefs() +void CMapHandler::updateWater() //shift colors in palettes of water tiles { - std::set loadedTypes; - for (int i=0; iwidth; i++) + SDL_Color palette[14]; + for(int j=0; jwidth; j++) + for(int i=0; i<12; ++i) { - if (loadedTypes.find(map->terrain[i][j][0].tertype)==loadedTypes.end()) - { - CDefHandler *sdh = CDefHandler::giveDef(nameFromType(map->terrain[i][j][0].tertype).c_str()); - loadedTypes.insert(map->terrain[i][j][0].tertype); - defs.push_back(sdh); - } - if (map->twoLevel && loadedTypes.find(map->terrain[i][j][1].tertype)==loadedTypes.end()) - { - CDefHandler *sdh = CDefHandler::giveDef(nameFromType(map->terrain[i][j][1].tertype).c_str()); - loadedTypes.insert(map->terrain[i][j][1].tertype); - defs.push_back(sdh); - } + palette[(i+1)%12] = terrainGraphics[8][j]->format->palette->colors[229 + i]; } + SDL_SetColors(terrainGraphics[8][j],palette,229,12); + for(int i=0; i<14; ++i) + { + palette[(i+1)%14] = terrainGraphics[8][j]->format->palette->colors[242 + i]; + } + SDL_SetColors(terrainGraphics[8][j],palette,242,14); } } + +TerrainTile2::TerrainTile2() +:terbitmap(0),tileInfo(0) +{} \ No newline at end of file diff --git a/mapHandler.h b/mapHandler.h index 815f35a77..82bbc96a7 100644 --- a/mapHandler.h +++ b/mapHandler.h @@ -20,11 +20,12 @@ struct TerrainTile2 { int3 pos; const TerrainTile *tileInfo; - std::vector terbitmap; //frames of terrain animation + SDL_Surface * terbitmap; //frames of terrain animation std::vector rivbitmap; //frames of river animation std::vector roadbitmap; //frames of road animation std::vector < std::pair > objects; //poiters to objects being on this tile with rects to be easier to blit this tile on screen + TerrainTile2(); }; //pathfinder @@ -75,6 +76,7 @@ public: CDefHandler * fullHide; CDefHandler * partialHide; + std::vector > terrainGraphics; // [terrain id] [view type] [rotation type] std::vector roadDefs; std::vector staticRiverDefs; std::vector defs; @@ -103,6 +105,7 @@ public: void prepareFOWDefs(); SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, std::vector< std::vector< std::vector > > * visibilityMap = NULL, bool otherHeroAnim = false, unsigned char heroAnim = 0, SDL_Surface * extSurf = NULL, SDL_Rect * extRect = NULL); //if extSurf is specified, blit to it + void updateWater(); unsigned char getHeroFrameNum(const unsigned char & dir, const bool & isMoving) const; //terrainRect helper function void validateRectTerr(SDL_Rect * val, const SDL_Rect * ext); //terrainRect helper static unsigned char getDir(const int3 & a, const int3 & b); //returns direction number in range 0 - 7 (0 is left top, clockwise) [direction: form a to b]