mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-17 20:58:07 +02:00
* animation of water tiles
* minor changes
This commit is contained in:
parent
447e5babda
commit
c6bcd61aba
@ -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]);
|
||||
|
@ -1392,13 +1392,13 @@ int CGameState::battleGetStack(int pos)
|
||||
return -1;
|
||||
for(int g=0; g<curB->stacks.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;
|
||||
|
@ -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(s<hero->artifacts.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();
|
||||
|
||||
|
2
CMT.cpp
2
CMT.cpp
@ -114,6 +114,7 @@ int main(int argc, char** argv)
|
||||
cgi->bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
|
||||
tlog0<<"Loading .lod files: "<<tmh.getDif()<<std::endl;
|
||||
initDLL(cgi->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: "<<tmh.getDif()<<std::endl;
|
||||
pomtime.getDif();
|
||||
cgi->curh = new CCursorHandler;
|
||||
|
@ -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; s<CGI->mh->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; g<CGI->mh->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;
|
||||
|
14
ChangeLog
14
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)
|
||||
|
@ -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; i<dstRect->h; i++)
|
||||
{
|
||||
dp = (Uint8 *)dst->pixels + (i+dstRect->y)*dst->pitch + (dstRect->x+dstRect->w)*dst->format->BytesPerPixel;
|
||||
for(int j=0; j<dstRect->w; 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; i<dstRect->h; i++)
|
||||
{
|
||||
dp = (Uint8 *)dst->pixels + (dstRect->y + dstRect->h - 1 - i)*dst->pitch + dstRect->x*dst->format->BytesPerPixel;
|
||||
for(int j=0; j<dstRect->w; 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; i<dstRect->h; i++)
|
||||
{
|
||||
dp = (Uint8 *)dst->pixels + (dstRect->y + dstRect->h - 1 - i)*dst->pitch + (dstRect->x+dstRect->w)*dst->format->BytesPerPixel;
|
||||
for(int j=0; j<dstRect->w; 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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "../stdafx.h"
|
||||
#include "CArtHandler.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "CGeneralTextHandler.h"
|
||||
#include <boost/assign/std/vector.hpp>
|
||||
#include <boost/assign/list_of.hpp>
|
||||
#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; i<ARTIFACTS_QUANTITY; i++)
|
||||
{
|
||||
CArtifact nart;
|
||||
loadToIt(nart.name,buf,it,4);
|
||||
loadToIt(VLC->generaltexth->artifNames[i],buf,it,4);
|
||||
loadToIt(pom,buf,it,4);
|
||||
nart.price=atoi(pom.c_str());
|
||||
for(int j=0;j<slots.size();j++)
|
||||
@ -37,7 +40,7 @@ void CArtHandler::loadArtifacts()
|
||||
}
|
||||
loadToIt(pom,buf,it,4);
|
||||
nart.aClass = classes[pom[0]];
|
||||
loadToIt(nart.description,buf,it,3);
|
||||
loadToIt(VLC->generaltexth->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];
|
||||
}
|
@ -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<ui16> possibleSlots; //ids of slots where artifact can be placed
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
std::vector<std::string> jktexts;
|
||||
std::vector<std::string> heroscrn;
|
||||
std::vector<std::string> artifEvents;
|
||||
std::vector<std::string> artifNames;
|
||||
std::vector<std::string> artifDescriptions;
|
||||
|
||||
std::vector<std::pair<std::string,std::string> > zelp;
|
||||
std::string lossCondtions[4];
|
||||
|
@ -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: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
CHeroHandler * heroh = new CHeroHandler;
|
||||
heroh->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: "<<pomtime.getDif()<<std::endl;
|
||||
|
||||
VLC->generaltexth = new CGeneralTextHandler;
|
||||
VLC->generaltexth->loadTexts();
|
||||
VLC->generaltexth->load();
|
||||
tlog0<<"\tGeneral text handler: "<<pomtime.getDif()<<std::endl;
|
||||
}
|
||||
|
||||
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)
|
||||
|
173
mapHandler.cpp
173
mapHandler.cpp
@ -16,9 +16,9 @@
|
||||
#include "map.h"
|
||||
#include "hch/CDefHandler.h"
|
||||
extern SDL_Surface * screen;
|
||||
std::string nameFromType (EterrainType typ)
|
||||
std::string nameFromType (int typ)
|
||||
{
|
||||
switch(typ)
|
||||
switch((EterrainType)typ)
|
||||
{
|
||||
case dirt:
|
||||
{
|
||||
@ -139,28 +139,6 @@ void CMapHandler::prepareFOWDefs()
|
||||
{
|
||||
CSDL_Ext::alphaTransform(partialHide->ourImages[i].bitmap);
|
||||
}
|
||||
//visibility.resize(map->width+2*Woff);
|
||||
//for(int gg=0; gg<map->width+2*Woff; ++gg)
|
||||
//{
|
||||
// visibility[gg].resize(map->height+2*Hoff);
|
||||
// for(int jj=0; jj<map->height+2*Hoff; ++jj)
|
||||
// visibility[gg][jj] = true;
|
||||
//}
|
||||
|
||||
//visibility.resize(CGI->mh->map->width, Woff);
|
||||
//for (int i=0-Woff;i<visibility.size()-Woff;i++)
|
||||
//{
|
||||
// visibility[i].resize(CGI->mh->map->height,Hoff);
|
||||
//}
|
||||
//for (int i=0-Woff; i<visibility.size()-Woff; ++i)
|
||||
//{
|
||||
// for (int j=0-Hoff; j<CGI->mh->map->height+Hoff; ++j)
|
||||
// {
|
||||
// visibility[i][j].resize(CGI->mh->map->twoLevel+1,0);
|
||||
// for(int k=0; k<CGI->mh->map->twoLevel+1; ++k)
|
||||
// visibility[i][j][k]=true;
|
||||
// }
|
||||
//}
|
||||
|
||||
hideBitmap.resize(CGI->mh->map->width);
|
||||
for (int i=0;i<hideBitmap.size();i++)
|
||||
@ -297,6 +275,17 @@ void CMapHandler::borderAndTerrainBitmapInit()
|
||||
{
|
||||
CDefHandler * bord = CDefHandler::giveDef("EDG.DEF");
|
||||
bord->notFreeImgs = 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; j<hlp->ourImages.size();j++)
|
||||
terrainGraphics[i][j] = hlp->ourImages[j].bitmap;
|
||||
delete hlp;
|
||||
}
|
||||
|
||||
for (int i=0-Woff; i<map->width+Woff; i++) //jest po szerokoœci
|
||||
{
|
||||
for (int j=0-Hoff; j<map->height+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; m<defs.size(); m++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (defs[m]->defName != 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: "<<th.getDif()<<std::endl;
|
||||
|
||||
std::ifstream ifs("config/townsDefs.txt");
|
||||
int ccc;
|
||||
@ -553,7 +488,6 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
{
|
||||
if(!otherHeroAnim)
|
||||
heroAnim = anim; //the same, as it should be
|
||||
|
||||
//setting surface to blit at
|
||||
SDL_Surface * su = NULL; //blitting surface CSDL_Ext::newSurface(dx*32, dy*32, CSDL_Ext::std32bppSurface);
|
||||
if(extSurf)
|
||||
@ -572,12 +506,38 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
{
|
||||
for (int by=0; by<dy; by++)
|
||||
{
|
||||
const TerrainTile2 & tile = ttiles[x+bx][y+by][level];
|
||||
SDL_Rect sr;
|
||||
sr.y=by*32;
|
||||
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);
|
||||
if(tile.terbitmap)
|
||||
{
|
||||
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap, &genRect(sr.h, sr.w, 0, 0), su, &sr);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(tile.tileInfo->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<int> loadedTypes;
|
||||
for (int i=0; i<map->width; i++)
|
||||
SDL_Color palette[14];
|
||||
for(int j=0; j<terrainGraphics[8].size(); j++)
|
||||
{
|
||||
for (int j=0; j<map->width; 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)
|
||||
{}
|
@ -20,11 +20,12 @@ struct TerrainTile2
|
||||
{
|
||||
int3 pos;
|
||||
const TerrainTile *tileInfo;
|
||||
std::vector<SDL_Surface *> terbitmap; //frames of terrain animation
|
||||
SDL_Surface * terbitmap; //frames of terrain animation
|
||||
std::vector<SDL_Surface *> rivbitmap; //frames of river animation
|
||||
std::vector<SDL_Surface *> roadbitmap; //frames of road animation
|
||||
|
||||
std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > 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<std::vector<SDL_Surface *> > terrainGraphics; // [terrain id] [view type] [rotation type]
|
||||
std::vector<CDefHandler *> roadDefs;
|
||||
std::vector<CDefHandler *> staticRiverDefs;
|
||||
std::vector<CDefHandler*> 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<unsigned char> > > * 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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user