mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
* working pathfinder
* drawing paths * new command "P X1 Y1 Z1 X2 Y2 Z2" - draws path between given points * borders handling rewritten * minor stuff
This commit is contained in:
parent
d708669a75
commit
7d704c7f02
@ -156,6 +156,18 @@ void CStatusBar::show()
|
||||
blitAtWR(bg,pos.x,pos.y);
|
||||
printAtMiddle(current,middlex,middley,GEOR13,zwykly);
|
||||
}
|
||||
CTerrainRect::CTerrainRect():currentPath(NULL)
|
||||
{
|
||||
pos.x=7;
|
||||
pos.y=6;
|
||||
pos.w=594;
|
||||
pos.h=547;
|
||||
arrows = CGI->spriteh->giveDef("ADAG.DEF");
|
||||
for(int y=0; y<arrows->ourImages.size(); ++y)
|
||||
{
|
||||
CSDL_Ext::fullAlphaTransform(arrows->ourImages[y].bitmap);
|
||||
}
|
||||
}
|
||||
void CTerrainRect::activate()
|
||||
{
|
||||
ClickableL::activate();
|
||||
@ -181,6 +193,203 @@ void CTerrainRect::show()
|
||||
19,18,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim);
|
||||
SDL_BlitSurface(teren,&genRect(547,594,0,0),ekran,&genRect(547,594,7,6));
|
||||
SDL_FreeSurface(teren);
|
||||
if (currentPath)
|
||||
{
|
||||
for (int i=0;i<currentPath->nodes.size()-1;i++)
|
||||
{
|
||||
int pn=-1;//number of picture
|
||||
if (i==0) //last tile
|
||||
{
|
||||
int x = 32*(currentPath->nodes[i].x-LOCPLINT->adventureInt->position.x)+7,
|
||||
y = 32*(currentPath->nodes[i].y-LOCPLINT->adventureInt->position.y)+6;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
pn=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<CPathNode> & cv = currentPath->nodes;
|
||||
if (cv[i+1].x == cv[i].x-1 && cv[i+1].y == cv[i].y-1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 3;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 12;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 21;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 22;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 2;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x && cv[i+1].y == cv[i].y-1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 4;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 13;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 22;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x+1 && cv[i+1].y == cv[i].y-1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 5;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 14;
|
||||
}
|
||||
else if(cv[i-1].x-1 == cv[i].x && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 23;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 24;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 4;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x+1 && cv[i+1].y == cv[i].y)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 6;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 15;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 24;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x+1 && cv[i+1].y == cv[i].y+1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 7;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 16;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 17;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 6;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 18;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x && cv[i+1].y == cv[i].y+1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 8;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 9;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 18;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x-1 && cv[i+1].y == cv[i].y+1)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 1;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 10;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 19;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x-1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 8;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 20;
|
||||
}
|
||||
}
|
||||
else if (cv[i+1].x == cv[i].x-1 && cv[i+1].y == cv[i].y)
|
||||
{
|
||||
if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y-1)
|
||||
{
|
||||
pn = 2;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y)
|
||||
{
|
||||
pn = 11;
|
||||
}
|
||||
else if(cv[i-1].x == cv[i].x+1 && cv[i-1].y == cv[i].y+1)
|
||||
{
|
||||
pn = 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pn>=0)
|
||||
{
|
||||
int x = 32*(currentPath->nodes[i].x-LOCPLINT->adventureInt->position.x)+7,
|
||||
y = 32*(currentPath->nodes[i].y-LOCPLINT->adventureInt->position.y)+6;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
int hvx = (x+arrows->ourImages[pn].bitmap->w)-(pos.x+pos.w),
|
||||
hvy = (y+arrows->ourImages[pn].bitmap->h)-(pos.y+pos.h);
|
||||
if (hvx<0 && hvy<0)
|
||||
blitAtWR(arrows->ourImages[pn].bitmap,x,y);
|
||||
else if(hvx<0)
|
||||
SDL_BlitSurface
|
||||
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,0,0),
|
||||
ekran,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w,x,y));
|
||||
else if (hvy<0)
|
||||
{
|
||||
SDL_BlitSurface
|
||||
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,0,0),
|
||||
ekran,&genRect(arrows->ourImages[pn].bitmap->h,arrows->ourImages[pn].bitmap->w-hvx,x,y));
|
||||
}
|
||||
else
|
||||
SDL_BlitSurface
|
||||
(arrows->ourImages[pn].bitmap,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,0,0),
|
||||
ekran,&genRect(arrows->ourImages[pn].bitmap->h-hvy,arrows->ourImages[pn].bitmap->w-hvx,x,y));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CAdvMapInt::CAdvMapInt(int Player)
|
||||
|
@ -97,9 +97,12 @@ public:
|
||||
|
||||
};
|
||||
class CTerrainRect
|
||||
: public ClickableL, public ClickableR, public Hoverable, public CIntObject, public KeyInterested
|
||||
: public ClickableL, public ClickableR, public Hoverable, public virtual CIntObject, public KeyInterested
|
||||
{
|
||||
public:
|
||||
CDefHandler * arrows;
|
||||
CTerrainRect();
|
||||
CPath * currentPath;
|
||||
void activate();
|
||||
void deactivate();
|
||||
void clickLeft(tribool down);
|
||||
|
@ -1,7 +1,11 @@
|
||||
#include "CConsoleHandler.h"
|
||||
#include "stdafx.h"
|
||||
#include "CConsoleHandler.h"
|
||||
#include "CAdvmapInterface.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "CGameInfo.h"
|
||||
#include "global.h"
|
||||
#include <sstream>
|
||||
|
||||
int internalFunc(void * nothingUsed)
|
||||
{
|
||||
@ -10,7 +14,21 @@ int internalFunc(void * nothingUsed)
|
||||
while(true)
|
||||
{
|
||||
std::cin.getline(usersMessage, 500);
|
||||
readed = std::string(usersMessage);
|
||||
std::istringstream readed;
|
||||
std::string pom(usersMessage);
|
||||
readed.str(pom);
|
||||
std::string cn; //command name
|
||||
readed >> cn;
|
||||
switch (*cn.c_str())
|
||||
{
|
||||
case 'P':
|
||||
std::cout<<"Policzyc sciezke."<<std::endl;
|
||||
int3 src, dst;
|
||||
readed>>src>>dst;
|
||||
LOCPLINT->adventureInt->terrain.currentPath = CGI->pathf->getPath(src,dst,CGI->heroh->heroInstances[0]);
|
||||
break;
|
||||
}
|
||||
//SDL_Delay(100);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#ifndef CCONSOLEHANDLER_H
|
||||
#define CCONSOLEHANDLER_H
|
||||
|
||||
class CConsoleHandler
|
||||
{
|
||||
public:
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "CGameState.h"
|
||||
#include "mapHandler.h"
|
||||
#include "CConsoleHandler.h"
|
||||
#include "CPathfinder.h"
|
||||
#include "SDL.h"
|
||||
|
||||
#include <vector>
|
||||
@ -53,6 +54,7 @@ public:
|
||||
CLodHandler * bitmaph;
|
||||
CGeneralTextHandler * generaltexth;
|
||||
CConsoleHandler * consoleh;
|
||||
CPathfinder * pathf;
|
||||
int localPlayer;
|
||||
std::vector<CGameInterface *> playerint;
|
||||
std::vector<SDL_Color> playerColors;
|
||||
|
@ -109,7 +109,7 @@ void CPlayerInterface::yourTurn()
|
||||
}
|
||||
if(LOCPLINT->adventureInt->scrollingLeft)
|
||||
{
|
||||
if(LOCPLINT->adventureInt->position.x>0)
|
||||
if(LOCPLINT->adventureInt->position.x>-Woff)
|
||||
{
|
||||
LOCPLINT->adventureInt->position.x--;
|
||||
LOCPLINT->adventureInt->updateScreen = true;
|
||||
@ -117,7 +117,7 @@ void CPlayerInterface::yourTurn()
|
||||
}
|
||||
if(LOCPLINT->adventureInt->scrollingRight)
|
||||
{
|
||||
if(LOCPLINT->adventureInt->position.x<CGI->ac->map.width-19+8)
|
||||
if(LOCPLINT->adventureInt->position.x<CGI->ac->map.width-19+4)
|
||||
{
|
||||
LOCPLINT->adventureInt->position.x++;
|
||||
LOCPLINT->adventureInt->updateScreen = true;
|
||||
@ -125,7 +125,7 @@ void CPlayerInterface::yourTurn()
|
||||
}
|
||||
if(LOCPLINT->adventureInt->scrollingUp)
|
||||
{
|
||||
if(LOCPLINT->adventureInt->position.y>0)
|
||||
if(LOCPLINT->adventureInt->position.y>-Hoff)
|
||||
{
|
||||
LOCPLINT->adventureInt->position.y--;
|
||||
LOCPLINT->adventureInt->updateScreen = true;
|
||||
@ -133,7 +133,7 @@ void CPlayerInterface::yourTurn()
|
||||
}
|
||||
if(LOCPLINT->adventureInt->scrollingDown)
|
||||
{
|
||||
if(LOCPLINT->adventureInt->position.y<CGI->ac->map.height-18+8)
|
||||
if(LOCPLINT->adventureInt->position.y<CGI->ac->map.height-18+4)
|
||||
{
|
||||
LOCPLINT->adventureInt->position.y++;
|
||||
LOCPLINT->adventureInt->updateScreen = true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "CLodHandler.h"
|
||||
#include "SDL_Extensions.h"
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
16
CMT.cpp
16
CMT.cpp
@ -61,6 +61,10 @@ TTF_Font * TNRB16, *TNR, *GEOR13, *GEORXX;
|
||||
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
{
|
||||
|
||||
//CBIKHandler cb;
|
||||
//cb.open("CSECRET.BIK");
|
||||
|
||||
THC timeHandler tmh;
|
||||
THC tmh.getDif();
|
||||
int xx=0, yy=0, zz=0;
|
||||
@ -81,17 +85,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
GEOR13 = TTF_OpenFont("Fonts\\georgia.ttf",13);
|
||||
GEORXX = TTF_OpenFont("Fonts\\tnrb.ttf",22);
|
||||
|
||||
|
||||
|
||||
|
||||
//CBIKHandler cb;
|
||||
//cb.open("CSECRET.BIK");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//initializing audio
|
||||
CMusicHandler * mush = new CMusicHandler;
|
||||
mush->initMusics();
|
||||
@ -185,6 +178,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
||||
cgi->dobjinfo = new CDefObjInfoHandler;
|
||||
cgi->dobjinfo->load();
|
||||
cgi->state = new CGameState();
|
||||
cgi->pathf = new CPathfinder();
|
||||
THC std::cout<<"Handlers initailization: "<<tmh.getDif()<<std::endl;
|
||||
|
||||
std::string mapname;
|
||||
|
123
CPathfinder.cpp
123
CPathfinder.cpp
@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "global.h"
|
||||
#include "CPathfinder.h"
|
||||
|
||||
#include "CGameInfo.h"
|
||||
CPath * CPathfinder::getPath(int3 &src, int3 &dest, CHeroInstance * hero) //TODO: test it (seems to be finished, but relies on unwritten functions :()
|
||||
{
|
||||
if(src.z!=dest.z) //first check
|
||||
@ -30,119 +30,101 @@ CPath * CPathfinder::getPath(int3 &src, int3 &dest, CHeroInstance * hero) //TODO
|
||||
|
||||
std::queue<CPathNode *> mq;
|
||||
mq.push(graph[src.x][src.y]);
|
||||
|
||||
unsigned int curDist = 4000000000;
|
||||
|
||||
while(!mq.empty())
|
||||
{
|
||||
CPathNode * cp = mq.front();
|
||||
mq.pop();
|
||||
if ((cp->x == dest.x) && (cp->y==dest.y))
|
||||
{
|
||||
if (cp->dist < curDist)
|
||||
curDist=cp->dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cp->dist > curDist)
|
||||
continue;
|
||||
}
|
||||
if(cp->x>0)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x-1][cp->y];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->y>0)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x][cp->y-1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y-1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y-1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->x>0 && cp->y>0)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x-1][cp->y-1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y-1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y-1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y-1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y-1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->x<graph.size()-1)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x+1][cp->y];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->y<graph[0].size()-1)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x][cp->y+1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y+1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y+1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->x<graph.size() && cp->y<graph[0].size())
|
||||
if(cp->x<graph.size()-1 && cp->y<graph[0].size()-1)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x+1][cp->y+1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y+1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y+1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->x>0 && cp->y<graph[0].size())
|
||||
if(cp->x>0 && cp->y<graph[0].size()-1)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x-1][cp->y+1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y+1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y+1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x-1, cp->y+1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
if(cp->x<graph.size() && cp->y>0)
|
||||
if(cp->x<graph.size()-1 && cp->y>0)
|
||||
{
|
||||
CPathNode * dp = graph[cp->x+1][cp->y-1];
|
||||
if(!dp->visited)
|
||||
if((dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y-1, src.z), hero))) && dp->accesible)
|
||||
{
|
||||
if(dp->dist==-1 || (dp->dist > cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y-1, src.z), hero)))
|
||||
{
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y-1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
dp->visited = true;
|
||||
}
|
||||
dp->dist = cp->dist + CGI->mh->getCost(int3(cp->x, cp->y, src.z), int3(cp->x+1, cp->y-1, src.z), hero);
|
||||
dp->theNodeBefore = cp;
|
||||
mq.push(dp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,15 +134,16 @@ CPath * CPathfinder::getPath(int3 &src, int3 &dest, CHeroInstance * hero) //TODO
|
||||
|
||||
while(curNode!=graph[src.x][src.y] && curNode != NULL)
|
||||
{
|
||||
ret->nodes.push(*curNode);
|
||||
ret->nodes.push_back(*curNode);
|
||||
curNode = curNode->theNodeBefore;
|
||||
}
|
||||
|
||||
ret->nodes.push_back(*graph[src.x][src.y]);
|
||||
|
||||
for(int i=0; i<graph.size(); ++i)
|
||||
{
|
||||
for(int j=0; j<graph[0].size(); ++i)
|
||||
for(int j=0; j<graph[0].size(); ++j)
|
||||
delete graph[i][j];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef CPATHFINDER_H
|
||||
#define CPATHFINDER_H
|
||||
#include "CGameInfo.h"
|
||||
#include "int3.h"
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
class CHeroInstance;
|
||||
struct CPathNode
|
||||
{
|
||||
bool accesible; //true if a hero can be on this node
|
||||
@ -16,7 +15,7 @@ struct CPathNode
|
||||
|
||||
struct CPath
|
||||
{
|
||||
std::queue<CPathNode> nodes; //just get node by node
|
||||
std::vector<CPathNode> nodes; //just get node by node
|
||||
};
|
||||
|
||||
/**
|
||||
@ -28,7 +27,7 @@ private:
|
||||
std::vector< std::vector<CPathNode *> > graph;
|
||||
public:
|
||||
CPath * getPath(int3 & src, int3 & dest, CHeroInstance * hero); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists
|
||||
CPath * getPath(int3 & src, int3 & dest, CHeroInstance * hero, int (*getDist)(int3 & a, int3 b)); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance
|
||||
CPath * getPath(int3 & src, int3 & dest, CHeroInstance * hero, int (*getDist)(int3 & a, int3 & b)); //calculates path between src and dest; returns pointer to CPath or NULL if path does not exists; uses getDist to calculate distance
|
||||
};
|
||||
|
||||
#endif //CPATHFINDER_H
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include "CVideoHandler.h"
|
||||
|
||||
#include "SDL.h"
|
||||
void DLLHandler::Instantiate(const char *filename)
|
||||
{
|
||||
dll = LoadLibraryA(filename);
|
||||
@ -15,8 +16,14 @@ const char *DLLHandler::GetLibExtension()
|
||||
return "so";
|
||||
#endif
|
||||
}
|
||||
void *DLLHandler::FindAddress(const char *symbol)
|
||||
|
||||
|
||||
|
||||
void *DLLHandler::FindAddress234(const char *symbol)
|
||||
{
|
||||
if ((int)symbol == 0x00001758)
|
||||
return NULL;
|
||||
std::cout<<"co ja tu robie"<<std::endl;
|
||||
return (void*) GetProcAddress(dll,symbol);
|
||||
}
|
||||
DLLHandler::~DLLHandler()
|
||||
@ -29,6 +36,7 @@ CBIKHandler::CBIKHandler()
|
||||
{
|
||||
ourLib.Instantiate("BINKW32.DLL");
|
||||
newmode=-1;
|
||||
waveOutOpen=0;
|
||||
///waveOutOpen = ourLib.FindAddress("_BinkOpenWaveOut@4");
|
||||
}
|
||||
int readNormalNr2 (unsigned char* bufor, int &iter, int bytCon)
|
||||
@ -43,45 +51,134 @@ int readNormalNr2 (unsigned char* bufor, int &iter, int bytCon)
|
||||
iter+=bytCon;
|
||||
return ret;
|
||||
}
|
||||
void RaiseLastOSErrorAt(char * offset)
|
||||
{
|
||||
int * lastError = new int;
|
||||
std::exception * error;
|
||||
*lastError = GetLastError();
|
||||
if (*lastError)
|
||||
throw lastError;
|
||||
|
||||
|
||||
}
|
||||
//var
|
||||
// LastError: Integer;
|
||||
// Error: EOSError;
|
||||
//begin
|
||||
// LastError := GetLastError;
|
||||
// if LastError <> 0 then
|
||||
// Error := EOSError.CreateResFmt(@SOSError, [LastError,
|
||||
// SysErrorMessage(LastError)])
|
||||
// else
|
||||
// Error := EOSError.CreateRes(@SUnkOSError);
|
||||
// Error.ErrorCode := LastError;
|
||||
// raise Error at Offset;
|
||||
//end;
|
||||
//void RSRaiseLastOSError()
|
||||
//{
|
||||
// __asm
|
||||
// {
|
||||
// mov eax, [esp]
|
||||
// sub eax, 5
|
||||
// jmp RaiseLastOSErrorAt
|
||||
// }
|
||||
//}
|
||||
//int RSWin32Check(int CheckForZero)
|
||||
//{
|
||||
// __asm
|
||||
// {
|
||||
// test eax, eax
|
||||
// jz RSRaiseLastOSError
|
||||
// }
|
||||
//}
|
||||
void CBIKHandler::open(std::string name)
|
||||
{
|
||||
unsigned char * fdata = new unsigned char[400];
|
||||
unsigned char * fdata2 = new unsigned char[400];
|
||||
for (int i=0;i<400;i++) fdata[i]=0;
|
||||
|
||||
//str.open(name.c_str(),std::ios::binary);
|
||||
BinkGetError = ourLib.FindAddress("_BinkGetError@0");
|
||||
BinkOpen = ourLib.FindAddress("_BinkOpen@8");
|
||||
BinkSetSoundSystem = ourLib.FindAddress("_BinkSetSoundSystem@8");
|
||||
|
||||
//((void(*)(void*,void*)) BinkSetSoundSystem)(waveOutOpen,NULL);
|
||||
|
||||
while (!fdata)
|
||||
fdata = ((unsigned char *(*)(const char *)) BinkOpen)("CSECRET.BIK");
|
||||
|
||||
|
||||
fdata2 = ((unsigned char *(*)()) BinkGetError)();
|
||||
|
||||
|
||||
int it = 0;
|
||||
data.width = readNormalNr2(fdata,it,4);
|
||||
data.height = readNormalNr2(fdata,it,4);
|
||||
data.frameCount = readNormalNr2(fdata,it,4);
|
||||
data.currentFrame = readNormalNr2(fdata,it,4);
|
||||
data.lastFrame = readNormalNr2(fdata,it,4);
|
||||
|
||||
//FData:= BinkOpen(FileHandle);
|
||||
//if FData = nil then
|
||||
// raise ERSRADException.Create(BinkGetError);
|
||||
//Width:= @FData^.Width;
|
||||
//Height:= @FData^.Height;
|
||||
|
||||
hBinkFile = CreateFile
|
||||
(
|
||||
L"CSECRET.BIK", // file name
|
||||
GENERIC_READ, // access mode
|
||||
FILE_SHARE_READ, // share mode
|
||||
NULL, // Security Descriptor
|
||||
OPEN_EXISTING, // how to create
|
||||
FILE_ATTRIBUTE_NORMAL,//FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
|
||||
0 // handle to template file
|
||||
);
|
||||
//RSWin32Check(hBinkFile!=INVALID_HANDLE_VALUE);
|
||||
if(hBinkFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("failed to open \"%s\"\n", name.c_str());
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
BinkGetError = ourLib.FindAddress234("_BinkGetError@0");
|
||||
BinkOpen = ourLib.FindAddress234("_BinkOpen@8");
|
||||
if (!waveOutOpen)
|
||||
{
|
||||
BinkSetSoundSystem = ourLib.FindAddress234("_BinkSetSoundSystem@8");
|
||||
((void(*)(void*,void*))BinkSetSoundSystem)(waveOutOpen,NULL);
|
||||
}
|
||||
std::cout<<"punkt kulminacyjny... "<<std::flush;
|
||||
hBink = ((HBINK(*)(HANDLE)) BinkOpen)(hBinkFile);
|
||||
width = hBink->width;
|
||||
height = hBink->height;
|
||||
BITMAP gg;
|
||||
gg.bmWidth=width;
|
||||
gg.bmHeight=height;
|
||||
gg.bmBitsPixel=24;
|
||||
gg.bmPlanes=1;
|
||||
gg.bmWidthBytes=3*width;
|
||||
gg.bmBits = new unsigned char[width*height*(gg.bmBitsPixel/8)];
|
||||
|
||||
//HBITMAP bitmapa = CreateBitmap(width, height,1,24,NULL);
|
||||
std::cout<<"przeszlo!"<<std::endl;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
printf("cos nie tak");
|
||||
}
|
||||
}
|
||||
void CBIKHandler::close()
|
||||
{
|
||||
str.close();
|
||||
void *binkClose;
|
||||
binkClose = ourLib.FindAddress("_BinkClose@4");
|
||||
(( void(*)() ) binkClose )();
|
||||
|
||||
}
|
||||
//void CBIKHandler::close()
|
||||
//{
|
||||
// void *binkClose;
|
||||
// binkClose = ourLib.FindAddress234("_BinkClose@4");
|
||||
// (( void(*)() ) binkClose )();
|
||||
//
|
||||
//}
|
||||
//void CBIKHandler::preparePic()
|
||||
//procedure TRSBinkPlayer.PreparePic(b: TBitmap);
|
||||
//var j:int; Pal:array[0..256] of int;
|
||||
//begin
|
||||
// inherited;
|
||||
// case RSGetPixelFormat(b) of
|
||||
// pf24bit, pf32bit, pf15bit, pf16bit:;
|
||||
//
|
||||
// pf8bit:
|
||||
// begin
|
||||
// if @BinkGetPalette=nil then
|
||||
// @BinkGetPalette:=GetProcAddress(FLib, '_BinkGetPalette@4');
|
||||
// if @BinkGetPalette<>nil then
|
||||
// begin
|
||||
// with PLogPalette(@Pal)^ do
|
||||
// begin
|
||||
// palVersion:=$300;
|
||||
// palNumEntries:=BinkGetPalette(@palPalEntry);
|
||||
// for j:=0 to palNumEntries-1 do
|
||||
// int(palPalEntry[j]):=RSSwapColor(int(palPalEntry[j]));
|
||||
// end;
|
||||
// b.Palette:=CreatePalette(PLogPalette(@Pal)^);
|
||||
// end else
|
||||
// b.PixelFormat:=pf24bit;
|
||||
// end;
|
||||
//
|
||||
// else
|
||||
// b.PixelFormat:=pf24bit;
|
||||
// end
|
||||
//
|
||||
//end;
|
@ -1,8 +1,10 @@
|
||||
#ifndef CVIDEOHANDLEER_H
|
||||
#define CVIDEOHANDLEER_H
|
||||
|
||||
#include "windows.h"
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
//
|
||||
#define BINKNOTHREADEDIO 0x00800000
|
||||
//
|
||||
// protected
|
||||
// FLib: HINST;
|
||||
@ -71,16 +73,29 @@
|
||||
// UVPlaneWidth: int;
|
||||
// UVPlaneHeight: int;
|
||||
//end;
|
||||
struct BINKStruct
|
||||
typedef struct
|
||||
{
|
||||
int width, height, frameCount, lastFrame, currentFrame,
|
||||
FPSMul, // frames/second multiplier
|
||||
FPSDiv, // frames/second divisor
|
||||
unk1, flags, YPlaneWidth, YPlaneHeight, UVPlaneWidth, UVPlaneHeight;
|
||||
unsigned char unk2[260];
|
||||
int unk3[2];
|
||||
void *plane1, *plane2;
|
||||
};
|
||||
int width;
|
||||
int height;
|
||||
int frameCount;
|
||||
int currentFrame;
|
||||
int lastFrame;
|
||||
int FPSMul;
|
||||
int FPSDiv;
|
||||
int unknown0;
|
||||
unsigned char flags;
|
||||
unsigned char unknown1[260];
|
||||
int CurPlane; // current plane
|
||||
void *plane0; // pointer to plane 0
|
||||
void *plane1; // pointer to plane 1
|
||||
int unknown2;
|
||||
int unknown3;
|
||||
int yWidth; // Y plane width
|
||||
int yHeight; // Y plane height
|
||||
int uvWidth; // U&V plane width
|
||||
int uvHeight; // U&V plane height
|
||||
int d,e,f,g,h,i;
|
||||
} BINK_STRUCT, *HBINK;
|
||||
|
||||
struct SMKStruct
|
||||
{
|
||||
@ -98,7 +113,7 @@ public:
|
||||
|
||||
void Instantiate(const char *filename);
|
||||
const char *GetLibExtension();
|
||||
void *FindAddress(const char *symbol);
|
||||
void *FindAddress234(const char *symbol);
|
||||
|
||||
virtual ~DLLHandler();
|
||||
};
|
||||
@ -107,12 +122,15 @@ class CBIKHandler
|
||||
{
|
||||
public:
|
||||
DLLHandler ourLib;
|
||||
std::ifstream str;
|
||||
int newmode;
|
||||
BINKStruct data;
|
||||
HANDLE hBinkFile;
|
||||
HBINK hBink;
|
||||
BINK_STRUCT data;
|
||||
unsigned char * buffer;
|
||||
void * waveOutOpen, * BinkGetError, *BinkOpen, *BinkSetSoundSystem ;
|
||||
|
||||
int width, height;
|
||||
|
||||
CBIKHandler();
|
||||
void open(std::string name);
|
||||
void close();
|
||||
|
@ -618,3 +618,26 @@ int readNormalNr (std::istream &in, int bytCon)
|
||||
else return -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CSDL_Ext::fullAlphaTransform(SDL_Surface *& src)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
int rmask = 0xff000000;
|
||||
int gmask = 0x00ff0000;
|
||||
int bmask = 0x0000ff00;
|
||||
int amask = 0x000000ff;
|
||||
#else
|
||||
int rmask = 0x000000ff;
|
||||
int gmask = 0x0000ff00;
|
||||
int bmask = 0x00ff0000;
|
||||
int amask = 0xff000000;
|
||||
#endif
|
||||
src = alphaTransform(src);
|
||||
SDL_Surface * hlp1, * hlp2;
|
||||
hlp1 = SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32, rmask, gmask, bmask, amask);
|
||||
hlp2 = secondAlphaTransform(src, hlp1);
|
||||
SDL_FreeSurface(src);
|
||||
SDL_FreeSurface(hlp1);
|
||||
src = hlp2;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ namespace CSDL_Ext
|
||||
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)
|
||||
SDL_Surface * secondAlphaTransform(SDL_Surface * src, SDL_Surface * alpha); //alpha is a surface we want to blit src to
|
||||
void fullAlphaTransform(SDL_Surface *& src); //performs first and second alpha transform
|
||||
Uint32 colorToUint32(const SDL_Color * color); //little endian only
|
||||
void printAtMiddle(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2); // quality: 0 - lowest, 1 - medium, 2 - highest
|
||||
void printAt(std::string text, int x, int y, TTF_Font * font, SDL_Color kolor=tytulowy, SDL_Surface * dst=ekran, unsigned char quality = 2); // quality: 0 - lowest, 1 - medium, 2 - highest
|
||||
|
1
global.h
1
global.h
@ -3,6 +3,7 @@
|
||||
#define CHECKTIME 1
|
||||
#if CHECKTIME
|
||||
#include "timeHandler.h"
|
||||
#include "int3.h"
|
||||
#include <iostream>
|
||||
#define THC
|
||||
#else
|
||||
|
6
int3.h
6
int3.h
@ -63,5 +63,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::istream & operator>>(std::istream & str, int3 & dest)
|
||||
{
|
||||
str>>dest.x>>dest.y>>dest.z;
|
||||
return str;
|
||||
}
|
||||
#endif //INT3_H
|
223
mapHandler.cpp
223
mapHandler.cpp
@ -84,73 +84,70 @@ void CMapHandler::init()
|
||||
//for (int ii=0;ii<reader->map.width+2*Woff;ii++)
|
||||
// roadBitmaps[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory
|
||||
|
||||
ttiles.resize(CGI->ac->map.width+2*Woff);
|
||||
for (int i=0;i<ttiles.size();i++)
|
||||
ttiles.resize(CGI->ac->map.width,Woff);
|
||||
for (int i=0-Woff;i<ttiles.size()-Woff;i++)
|
||||
{
|
||||
ttiles[i].resize(CGI->ac->map.height+2*Hoff);
|
||||
ttiles[i].resize(CGI->ac->map.height,Hoff);
|
||||
}
|
||||
for (int i=0;i<ttiles.size();i++)
|
||||
for (int i=0-Woff;i<ttiles.size()-Woff;i++)
|
||||
{
|
||||
for (int j=0;j<CGI->ac->map.height+2*Hoff;j++)
|
||||
ttiles[i][j].resize(CGI->ac->map.twoLevel+1);
|
||||
for (int j=0-Hoff;j<CGI->ac->map.height+Hoff;j++)
|
||||
ttiles[i][j].resize(CGI->ac->map.twoLevel+1,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szerokoœci
|
||||
for (int i=0; i<reader->map.width; i++) //jest po szerokoœci
|
||||
{
|
||||
for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysokoœci
|
||||
for (int j=0; j<reader->map.height;j++) //po wysokoœci
|
||||
{
|
||||
if(!(i<Woff || i>reader->map.width+Woff-1 || j<Woff || j>reader->map.height+Hoff-1))
|
||||
for (int k=0; k<=reader->map.twoLevel; ++k)
|
||||
{
|
||||
for (int k=0; k<=reader->map.twoLevel; ++k)
|
||||
TerrainTile** pomm = reader->map.terrain; ;
|
||||
if (k==0)
|
||||
pomm = reader->map.terrain;
|
||||
else
|
||||
pomm = reader->map.undergroungTerrain;
|
||||
if(pomm[i][j].malle)
|
||||
{
|
||||
TerrainTile** pomm = reader->map.terrain; ;
|
||||
if (k==0)
|
||||
pomm = reader->map.terrain;
|
||||
else
|
||||
pomm = reader->map.undergroungTerrain;
|
||||
if(pomm[i-Woff][j-Hoff].malle)
|
||||
int cDir;
|
||||
bool rotV, rotH;
|
||||
if(k==0)
|
||||
{
|
||||
int cDir;
|
||||
bool rotV, rotH;
|
||||
if(k==0)
|
||||
{
|
||||
int roadpom = reader->map.terrain[i-Woff][j-Hoff].malle-1,
|
||||
impom = reader->map.terrain[i-Woff][j-Hoff].roadDir;
|
||||
SDL_Surface *pom1 = roadDefs[roadpom]->ourImages[impom].bitmap;
|
||||
ttiles[i][j][k].roadbitmap.push_back(pom1);
|
||||
cDir = reader->map.terrain[i-Woff][j-Hoff].roadDir;
|
||||
|
||||
rotH = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 5) & 1;
|
||||
rotV = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 4) & 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int pom111 = reader->map.undergroungTerrain[i-Woff][j-Hoff].malle-1,
|
||||
pom777 = reader->map.undergroungTerrain[i-Woff][j-Hoff].roadDir;
|
||||
SDL_Surface *pom1 = roadDefs[pom111]->ourImages[pom777].bitmap;
|
||||
ttiles[i][j][k].roadbitmap.push_back(pom1);
|
||||
cDir = reader->map.undergroungTerrain[i-Woff][j-Hoff].roadDir;
|
||||
int roadpom = reader->map.terrain[i][j].malle-1,
|
||||
impom = reader->map.terrain[i][j].roadDir;
|
||||
SDL_Surface *pom1 = roadDefs[roadpom]->ourImages[impom].bitmap;
|
||||
ttiles[i][j][k].roadbitmap.push_back(pom1);
|
||||
cDir = reader->map.terrain[i][j].roadDir;
|
||||
|
||||
rotH = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 5) & 1;
|
||||
rotV = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 4) & 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int pom111 = reader->map.undergroungTerrain[i][j].malle-1,
|
||||
pom777 = reader->map.undergroungTerrain[i][j].roadDir;
|
||||
SDL_Surface *pom1 = roadDefs[pom111]->ourImages[pom777].bitmap;
|
||||
ttiles[i][j][k].roadbitmap.push_back(pom1);
|
||||
cDir = reader->map.undergroungTerrain[i][j].roadDir;
|
||||
|
||||
rotH = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 5) & 1;
|
||||
rotV = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 4) & 1;
|
||||
}
|
||||
if(rotH)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::hFlip(ttiles[i][j][k].roadbitmap[0]);
|
||||
}
|
||||
if(rotV)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::rotate01(ttiles[i][j][k].roadbitmap[0]);
|
||||
}
|
||||
if(rotH || rotV)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::alphaTransform(ttiles[i][j][k].roadbitmap[0]);
|
||||
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].roadbitmap[0], su);
|
||||
SDL_FreeSurface(ttiles[i][j][k].roadbitmap[0]);
|
||||
ttiles[i][j][k].roadbitmap[0] = buf;
|
||||
}
|
||||
rotH = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 5) & 1;
|
||||
rotV = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 4) & 1;
|
||||
}
|
||||
if(rotH)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::hFlip(ttiles[i][j][k].roadbitmap[0]);
|
||||
}
|
||||
if(rotV)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::rotate01(ttiles[i][j][k].roadbitmap[0]);
|
||||
}
|
||||
if(rotH || rotV)
|
||||
{
|
||||
ttiles[i][j][k].roadbitmap[0] = CSDL_Ext::alphaTransform(ttiles[i][j][k].roadbitmap[0]);
|
||||
SDL_Surface * buf = CSDL_Ext::secondAlphaTransform(ttiles[i][j][k].roadbitmap[0], su);
|
||||
SDL_FreeSurface(ttiles[i][j][k].roadbitmap[0]);
|
||||
ttiles[i][j][k].roadbitmap[0] = buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,39 +155,37 @@ void CMapHandler::init()
|
||||
}
|
||||
|
||||
//initializing simple values
|
||||
for (int i=0; i<ttiles.size(); i++) //jest po szerokoœci
|
||||
for (int i=0; i<CGI->ac->map.width; i++) //jest po szerokoœci
|
||||
{
|
||||
for (int j=0; j<ttiles[0].size();j++) //po wysokoœci
|
||||
for (int j=0; j<CGI->ac->map.height;j++) //po wysokoœci
|
||||
{
|
||||
for(int k=0; k<ttiles[0][0].size(); ++k)
|
||||
{
|
||||
ttiles[i][j][k].pos = int3(i, j, k);
|
||||
ttiles[i][j][k].blocked = false;
|
||||
ttiles[i][j][k].visitable = false;
|
||||
if(i<Woff || j<Hoff || i>=CGI->ac->map.width+Woff || j>=CGI->ac->map.height+Hoff)
|
||||
if(i<0 || j<0 || i>=CGI->ac->map.width || j>=CGI->ac->map.height)
|
||||
{
|
||||
ttiles[i][j][k].blocked = true;
|
||||
continue;
|
||||
}
|
||||
ttiles[i][j][k].terType = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].tertype : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].tertype);
|
||||
ttiles[i][j][k].malle = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].malle : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].malle);
|
||||
ttiles[i][j][k].nuine = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].nuine : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].nuine);
|
||||
ttiles[i][j][k].rivdir = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].rivDir : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].rivDir);
|
||||
ttiles[i][j][k].roaddir = (k==0 ? CGI->ac->map.terrain[i-Woff][j-Hoff].roadDir : CGI->ac->map.undergroungTerrain[i-Woff][j-Hoff].roadDir);
|
||||
ttiles[i][j][k].terType = (k==0 ? CGI->ac->map.terrain[i][j].tertype : CGI->ac->map.undergroungTerrain[i][j].tertype);
|
||||
ttiles[i][j][k].malle = (k==0 ? CGI->ac->map.terrain[i][j].malle : CGI->ac->map.undergroungTerrain[i][j].malle);
|
||||
ttiles[i][j][k].nuine = (k==0 ? CGI->ac->map.terrain[i][j].nuine : CGI->ac->map.undergroungTerrain[i][j].nuine);
|
||||
ttiles[i][j][k].rivdir = (k==0 ? CGI->ac->map.terrain[i][j].rivDir : CGI->ac->map.undergroungTerrain[i][j].rivDir);
|
||||
ttiles[i][j][k].roaddir = (k==0 ? CGI->ac->map.terrain[i][j].roadDir : CGI->ac->map.undergroungTerrain[i][j].roadDir);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//simple values initialized
|
||||
|
||||
for (int i=0; i<reader->map.width+Woff; i++) //jest po szerokoœci
|
||||
for (int i=0; i<reader->map.width; i++) //jest po szerokoœci
|
||||
{
|
||||
for (int j=0; j<reader->map.height+Hoff;j++) //po wysokoœci
|
||||
for (int j=0; j<reader->map.height;j++) //po wysokoœci
|
||||
{
|
||||
for(int k=0; k<=reader->map.twoLevel; ++k)
|
||||
{
|
||||
if(i<4 || j<4)
|
||||
continue;
|
||||
TerrainTile** pomm = reader->map.terrain;
|
||||
if(k==0)
|
||||
{
|
||||
@ -200,23 +195,23 @@ void CMapHandler::init()
|
||||
{
|
||||
pomm = reader->map.undergroungTerrain;
|
||||
}
|
||||
if(pomm[i-Woff][j-Hoff].nuine)
|
||||
if(pomm[i][j].nuine)
|
||||
{
|
||||
int cDir;
|
||||
bool rotH, rotV;
|
||||
if(k==0)
|
||||
{
|
||||
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.terrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.terrain[i-Woff][j-Hoff].rivDir].bitmap);
|
||||
cDir = reader->map.terrain[i-Woff][j-Hoff].rivDir;
|
||||
rotH = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 3) & 1;
|
||||
rotV = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 2) & 1;
|
||||
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.terrain[i][j].nuine-1]->ourImages[reader->map.terrain[i][j].rivDir].bitmap);
|
||||
cDir = reader->map.terrain[i][j].rivDir;
|
||||
rotH = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 3) & 1;
|
||||
rotV = (reader->map.terrain[i][j].siodmyTajemniczyBajt >> 2) & 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.undergroungTerrain[i-Woff][j-Hoff].nuine-1]->ourImages[reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir].bitmap);
|
||||
cDir = reader->map.undergroungTerrain[i-Woff][j-Hoff].rivDir;
|
||||
rotH = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 3) & 1;
|
||||
rotV = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt >> 2) & 1;
|
||||
ttiles[i][j][k].rivbitmap.push_back(staticRiverDefs[reader->map.undergroungTerrain[i][j].nuine-1]->ourImages[reader->map.undergroungTerrain[i][j].rivDir].bitmap);
|
||||
cDir = reader->map.undergroungTerrain[i][j].rivDir;
|
||||
rotH = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 3) & 1;
|
||||
rotV = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt >> 2) & 1;
|
||||
}
|
||||
if(rotH)
|
||||
{
|
||||
@ -247,50 +242,50 @@ void CMapHandler::init()
|
||||
// terrainBitmap[ii] = new SDL_Surface*[reader->map.height+2*Hoff]; // allocate memory
|
||||
|
||||
CDefHandler * bord = CGameInfo::mainObj->spriteh->giveDef("EDG.DEF");
|
||||
for (int i=0; i<reader->map.width+2*Woff; i++) //jest po szerokoœci
|
||||
for (int i=0-Woff; i<reader->map.width+Woff; i++) //jest po szerokoœci
|
||||
{
|
||||
for (int j=0; j<reader->map.height+2*Hoff;j++) //po wysokoœci
|
||||
for (int j=0-Hoff; j<reader->map.height+Hoff;j++) //po wysokoœci
|
||||
{
|
||||
for(int k=0; k<=reader->map.twoLevel; ++k)
|
||||
{
|
||||
if(i < Woff || i > (reader->map.width+Woff-1) || j < Hoff || j > (reader->map.height+Hoff-1))
|
||||
if(i < 0 || i > (reader->map.width-1) || j < 0 || j > (reader->map.height-1))
|
||||
{
|
||||
if(i==Woff-1 && j==Hoff-1)
|
||||
if(i==-1 && j==-1)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[16].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(i==Woff-1 && j==(reader->map.height+Hoff))
|
||||
else if(i==-1 && j==(reader->map.height))
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[19].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(i==(reader->map.width+Woff) && j==Hoff-1)
|
||||
else if(i==(reader->map.width) && j==-1)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[17].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(i==(reader->map.width+Woff) && j==(reader->map.height+Hoff))
|
||||
else if(i==(reader->map.width) && j==(reader->map.height))
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[18].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(j == Hoff-1 && i > Woff-1 && i < reader->map.height+Woff)
|
||||
else if(j == -1 && i > -1 && i < reader->map.height)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[22+rand()%2].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(i == Woff-1 && j > Hoff-1 && j < reader->map.height+Hoff)
|
||||
else if(i == -1 && j > -1 && j < reader->map.height)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[33+rand()%2].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(j == reader->map.height+Hoff && i > Woff-1 && i < reader->map.width+Woff)
|
||||
else if(j == reader->map.height && i >-1 && i < reader->map.width)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[29+rand()%2].bitmap);
|
||||
continue;
|
||||
}
|
||||
else if(i == reader->map.width+Woff && j > Hoff-1 && j < reader->map.height+Hoff)
|
||||
else if(i == reader->map.width && j > -1 && j < reader->map.height)
|
||||
{
|
||||
ttiles[i][j][k].terbitmap.push_back(bord->ourImages[25+rand()%2].bitmap);
|
||||
continue;
|
||||
@ -304,9 +299,9 @@ void CMapHandler::init()
|
||||
//TerrainTile zz = reader->map.terrain[i-Woff][j-Hoff];
|
||||
std::string name;
|
||||
if (k>0)
|
||||
name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i-Woff][j-Hoff].tertype);
|
||||
name = CSemiDefHandler::nameFromType(reader->map.undergroungTerrain[i][j].tertype);
|
||||
else
|
||||
name = CSemiDefHandler::nameFromType(reader->map.terrain[i-Woff][j-Hoff].tertype);
|
||||
name = CSemiDefHandler::nameFromType(reader->map.terrain[i][j].tertype);
|
||||
for (unsigned int m=0; m<reader->defs.size(); m++)
|
||||
{
|
||||
try
|
||||
@ -317,15 +312,15 @@ void CMapHandler::init()
|
||||
{
|
||||
int ktora;
|
||||
if (k==0)
|
||||
ktora = reader->map.terrain[i-Woff][j-Hoff].terview;
|
||||
ktora = reader->map.terrain[i][j].terview;
|
||||
else
|
||||
ktora = reader->map.undergroungTerrain[i-Woff][j-Hoff].terview;
|
||||
ktora = reader->map.undergroungTerrain[i][j].terview;
|
||||
ttiles[i][j][k].terbitmap.push_back(reader->defs[m]->ourImages[ktora].bitmap);
|
||||
int zz;
|
||||
if (k==0)
|
||||
zz = (reader->map.terrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4;
|
||||
zz = (reader->map.terrain[i][j].siodmyTajemniczyBajt)%4;
|
||||
else
|
||||
zz = (reader->map.undergroungTerrain[i-Woff][j-Hoff].siodmyTajemniczyBajt)%4;
|
||||
zz = (reader->map.undergroungTerrain[i][j].siodmyTajemniczyBajt)%4;
|
||||
switch (zz)
|
||||
{
|
||||
case 1:
|
||||
@ -359,6 +354,8 @@ void CMapHandler::init()
|
||||
//initializing objects / rects
|
||||
for(int f=0; f<CGI->objh->objInstances.size(); ++f)
|
||||
{
|
||||
CGI->objh->objInstances[f]->pos.x+=1;
|
||||
CGI->objh->objInstances[f]->pos.y+=1;
|
||||
CDefHandler * curd = CGI->ac->map.defy[CGI->objh->objInstances[f]->defNumber].handler;
|
||||
for(int fx=0; fx<curd->ourImages[0].bitmap->w/32; ++fx)
|
||||
{
|
||||
@ -370,10 +367,16 @@ void CMapHandler::init()
|
||||
cr.x = fx*32;
|
||||
cr.y = fy*32;
|
||||
std::pair<CObjectInstance *, SDL_Rect> toAdd = std::make_pair(CGI->objh->objInstances[f], cr);
|
||||
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff)<=ttiles.size() && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff)<=ttiles[0].size())
|
||||
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32)<=ttiles.size() && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32)<=ttiles[0].size())
|
||||
{
|
||||
TerrainTile2 & curt = ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff][CGI->objh->objInstances[f]->pos.z];
|
||||
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+Woff][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+Hoff][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
|
||||
TerrainTile2 & curt =
|
||||
ttiles
|
||||
[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32]
|
||||
[CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32]
|
||||
[CGI->objh->objInstances[f]->pos.z];
|
||||
|
||||
|
||||
ttiles[CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32][CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32][CGI->objh->objInstances[f]->pos.z].objects.push_back(toAdd);
|
||||
}
|
||||
|
||||
} // for(int fy=0; fy<curd->ourImages[0].bitmap->h/32; ++fy)
|
||||
@ -388,10 +391,10 @@ void CMapHandler::init()
|
||||
{
|
||||
for(int fy=0; fy<6; ++fy)
|
||||
{
|
||||
int xVal = CGI->objh->objInstances[f]->pos.x + Woff + fx - 7;
|
||||
int yVal = CGI->objh->objInstances[f]->pos.y + Hoff + fy - 5;
|
||||
int xVal = CGI->objh->objInstances[f]->pos.x + fx - 8;
|
||||
int yVal = CGI->objh->objInstances[f]->pos.y + fy - 6;
|
||||
int zVal = CGI->objh->objInstances[f]->pos.z;
|
||||
if(xVal>=0 && xVal<ttiles.size() && yVal>=0 && yVal<ttiles[0].size())
|
||||
if(xVal>=0 && xVal<ttiles.size()-Woff && yVal>=0 && yVal<ttiles[0].size()-Hoff)
|
||||
{
|
||||
TerrainTile2 & curt = ttiles[xVal][yVal][zVal];
|
||||
if(((CGI->dobjinfo->objs[CGI->objh->objInstances[f]->defObjInfoNumber].visitMap[fy] >> (7 - fx)) & 1))
|
||||
@ -402,9 +405,9 @@ void CMapHandler::init()
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int ix=0; ix<ttiles.size(); ++ix)
|
||||
for(int ix=0; ix<ttiles.size()-Woff; ++ix)
|
||||
{
|
||||
for(int iy=0; iy<ttiles[0].size(); ++iy)
|
||||
for(int iy=0; iy<ttiles[0].size()-Hoff; ++iy)
|
||||
{
|
||||
for(int iz=0; iz<ttiles[0][0].size(); ++iz)
|
||||
{
|
||||
@ -430,7 +433,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
|
||||
SDL_Surface * su = SDL_CreateRGBSurface(SDL_SWSURFACE, dx*32, dy*32, 32,
|
||||
rmask, gmask, bmask, amask);
|
||||
if (((dx+x)>((reader->map.width+8)) || (dy+y)>((reader->map.height+8))) || ((x<0)||(y<0) ) )
|
||||
if (((dx+x)>((reader->map.width+Woff)) || (dy+y)>((reader->map.height+Hoff))) || ((x<-Woff)||(y<-Hoff) ) )
|
||||
throw new std::string("terrainRect: out of range");
|
||||
////printing terrain
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
@ -478,9 +481,9 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
////roads printed
|
||||
////printing objects
|
||||
|
||||
for (int bx=(x==0 ? 0 : -1); bx<dx; bx++)
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
{
|
||||
for (int by=( y==0 ? 0 : -1); by<dy; by++)
|
||||
for (int by=0; by<dy; by++)
|
||||
{
|
||||
if(true)
|
||||
{
|
||||
@ -489,8 +492,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
SDL_Rect * sr = new SDL_Rect;
|
||||
sr->w = 32;
|
||||
sr->h = 32;
|
||||
sr->x = (bx+1)*32;
|
||||
sr->y = (by+1)*32;
|
||||
sr->x = (bx)*32;
|
||||
sr->y = (by)*32;
|
||||
|
||||
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
|
||||
int imgVal = CGI->ac->map.defy[
|
||||
@ -518,7 +521,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
if (!level)
|
||||
{
|
||||
|
||||
if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<visibility.size()-(Woff-1) && by+y<visibility[0].size()-(Hoff-1) && !visibility[bx+x][by+y])
|
||||
if( bx+x>-1 && by+y>-1 && bx+x<visibility.size()-(-1) && by+y<visibility[0].size()-(-1) && !visibility[bx+x][by+y])
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibility);
|
||||
SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
|
||||
@ -528,7 +531,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
else
|
||||
{
|
||||
if( bx+x>Woff-1 && by+y>Hoff-1 && bx+x<undVisibility.size()-(Woff-1) && by+y<undVisibility[0].size()-(Hoff-1) && !undVisibility[bx+x][by+y])
|
||||
if( bx+x>-1 && by+y>-1 && bx+x<undVisibility.size()-(-1) && by+y<undVisibility[0].size()-(-1) && !undVisibility[bx+x][by+y])
|
||||
{
|
||||
SDL_Surface * hide = getVisBitmap(bx+x, by+y, undVisibility);
|
||||
SDL_Surface * hide2 = CSDL_Ext::secondAlphaTransform(hide, su);
|
||||
@ -541,11 +544,11 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
}
|
||||
////shadow printed
|
||||
//printing borders
|
||||
for (int bx=(x==0 ? 0 : -1); bx<dx; bx++)
|
||||
for (int bx=0; bx<dx; bx++)
|
||||
{
|
||||
for (int by=(y==0 ? 0 : -1); by<dy; by++)
|
||||
for (int by=0; by<dy; by++)
|
||||
{
|
||||
if(bx+x<Woff || by+y<Hoff || bx+x>reader->map.width+(Woff-1) || by+y>reader->map.height+(Hoff-1))
|
||||
if(bx+x<0 || by+y<0 || bx+x>reader->map.width+(-1) || by+y>reader->map.height+(-1))
|
||||
{
|
||||
SDL_Rect * sr = new SDL_Rect;
|
||||
sr->y=by*32;
|
||||
|
22
mapHandler.h
22
mapHandler.h
@ -35,11 +35,29 @@ struct TerrainTile2
|
||||
//pathfinder
|
||||
// map<int,int> iDTerenu=>koszt_pola
|
||||
// map<int,int> IDdrogi=>koszt_drogi
|
||||
|
||||
template <typename T> class PseudoV
|
||||
{
|
||||
public:
|
||||
int offset;
|
||||
std::vector<T> inver;
|
||||
inline T & operator[](int n)
|
||||
{
|
||||
return inver[n+offset];
|
||||
}
|
||||
void resize(int rest,int Offset)
|
||||
{
|
||||
inver.resize(Offset*2+rest);
|
||||
offset=Offset;
|
||||
}
|
||||
int size()
|
||||
{
|
||||
return inver.size();
|
||||
}
|
||||
};
|
||||
class CMapHandler
|
||||
{
|
||||
public:
|
||||
std::vector< std::vector< std::vector<TerrainTile2> > > ttiles;
|
||||
PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles;
|
||||
CAmbarCendamo * reader;
|
||||
SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0);
|
||||
SDL_Surface * terrBitmap(int x, int y);
|
||||
|
Loading…
Reference in New Issue
Block a user