mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* displaying flags
* significant speed-ups and warningfixing
This commit is contained in:
parent
21f8684cdd
commit
b07b1ec7dc
@ -212,6 +212,7 @@ int CCallback::getDate(int mode)
|
||||
return ((gs->day-1)/28)+1;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
bool CCallback::verifyPath(CPath * path, bool blockSea)
|
||||
{
|
||||
|
@ -269,14 +269,20 @@ inline void subRect(const int & x, const int & y, const int & z, SDL_Rect & r, c
|
||||
{
|
||||
for(int h=0; h<CGI->mh->ttiles[x][y][z].objects.size(); ++h)
|
||||
if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid)
|
||||
{
|
||||
CGI->mh->ttiles[x][y][z].objects[h].second.first = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void delObjRect(const int & x, const int & y, const int & z, const int & hid)
|
||||
{
|
||||
for(int h=0; h<CGI->mh->ttiles[x][y][z].objects.size(); ++h)
|
||||
if(CGI->mh->ttiles[x][y][z].objects[h].first->id==hid)
|
||||
{
|
||||
CGI->mh->ttiles[x][y][z].objects.erase(CGI->mh->ttiles[x][y][z].objects.begin()+h);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
@ -559,7 +565,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 33+i, 33+i), ho->id);
|
||||
subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65+i, 33+i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -572,7 +578,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y+1 == details.src.y) //t
|
||||
{
|
||||
@ -588,7 +594,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 32, 33+i), ho->id);
|
||||
subRect(hp.x, hp.y, hp.z, genRect(32, 32, 64, 33+i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
|
||||
@ -598,7 +604,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y+1 == details.src.y) //tr
|
||||
{
|
||||
@ -617,7 +623,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 33+i), ho->id);
|
||||
subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 33+i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-2][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-2][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -630,7 +636,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y == details.src.y) //r
|
||||
{
|
||||
@ -644,7 +650,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x, hp.y, hp.z, genRect(32, 32, 63-i, 32), ho->id);
|
||||
subRect(hp.x+1, hp.y, hp.z, genRect(32, 32, 95-i, 32), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -652,7 +658,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x-1 == details.src.x && details.dst.y-1 == details.src.y) //br
|
||||
{
|
||||
@ -671,7 +677,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 63-i, 63-i), ho->id);
|
||||
subRect(hp.x+1, hp.y+1, hp.z, genRect(32, 32, 95-i, 63-i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -684,7 +690,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x+1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x == details.src.x && details.dst.y-1 == details.src.y) //b
|
||||
{
|
||||
@ -700,7 +706,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 32, 63-i), ho->id);
|
||||
subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 64, 63-i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
|
||||
@ -710,7 +716,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y-1 == details.src.y) //bl
|
||||
{
|
||||
@ -729,7 +735,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x-1, hp.y+1, hp.z, genRect(32, 32, 33+i, 63-i), ho->id);
|
||||
subRect(hp.x, hp.y+1, hp.z, genRect(32, 32, 65+i, 63-i), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -742,7 +748,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y+1][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
else if(details.dst.x+1 == details.src.x && details.dst.y == details.src.y) //l
|
||||
{
|
||||
@ -756,7 +762,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
subRect(hp.x-1, hp.y, hp.z, genRect(32, 32, 33+i, 32), ho->id);
|
||||
subRect(hp.x, hp.y, hp.z, genRect(32, 32, 65+i, 32), ho->id);
|
||||
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
/*std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y-1][hp.z].objects.end(), ocmptwo_cgin);
|
||||
@ -764,7 +770,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-3][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-2][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x-1][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);
|
||||
std::stable_sort(CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.begin(), CGI->mh->ttiles[hp.x][hp.y][hp.z].objects.end(), ocmptwo_cgin);*/
|
||||
}
|
||||
LOCPLINT->adventureInt->update(); //updating screen
|
||||
CGI->screenh->updateScreen();
|
||||
|
BIN
CPreGame.cpp
BIN
CPreGame.cpp
Binary file not shown.
@ -159,6 +159,23 @@ void CSDL_Ext::SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G,
|
||||
SDL_UpdateRect(ekran, x, y, 1, 1);
|
||||
}
|
||||
|
||||
void CSDL_Ext::SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC, Uint8 A)
|
||||
{
|
||||
Uint8 *p = (Uint8 *)ekran->pixels + y * ekran->pitch + x * ekran->format->BytesPerPixel-myC;
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = B;
|
||||
p[1] = G;
|
||||
p[2] = R;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = R;
|
||||
p[1] = G;
|
||||
p[2] = B;
|
||||
}
|
||||
}
|
||||
|
||||
///**************/
|
||||
///Reverses the toRot surface by the vertical axis
|
||||
///**************/
|
||||
|
@ -15,6 +15,7 @@ SDL_Rect genRect(int hh, int ww, int xx, int yy);
|
||||
namespace CSDL_Ext
|
||||
{
|
||||
void SDL_PutPixel(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels
|
||||
void SDL_PutPixelWithoutRefresh(SDL_Surface *ekran, int x, int y, Uint8 R, Uint8 G, Uint8 B, int myC=0, Uint8 A = 255); //myC influences the start of reading pixels ; without refreshing
|
||||
SDL_Surface * rotate01(SDL_Surface * toRot, int myC = 2); //vertical flip
|
||||
SDL_Surface * hFlip(SDL_Surface * toRot); //horizontal flip
|
||||
SDL_Surface * rotate02(SDL_Surface * toRot); //rotate 90 degrees left
|
||||
|
@ -54,3 +54,13 @@ void CDefObjInfoHandler::load()
|
||||
objs.push_back(nobj);
|
||||
}
|
||||
}
|
||||
|
||||
bool DefObjInfo::isVisitable() const
|
||||
{
|
||||
for(int g=0; g<6; ++g)
|
||||
{
|
||||
if(visitMap[g]!=0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ struct DefObjInfo
|
||||
unsigned char visitMap[6];
|
||||
unsigned char blockMap[6];
|
||||
bool operator==(const std::string & por) const;
|
||||
bool isVisitable() const;
|
||||
};
|
||||
|
||||
class CDefObjInfoHandler
|
||||
|
@ -57,6 +57,7 @@ std::string CSemiDefHandler::nameFromType (EterrainType typ)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
void CSemiDefHandler::openDef(std::string name, std::string lodName, int dist)
|
||||
{
|
||||
|
@ -416,20 +416,29 @@ void CMapHandler::init()
|
||||
cr.y = fy*32;
|
||||
std::pair<CObjectInstance*,std::pair<SDL_Rect, std::vector<std::list<int3>>>> toAdd = std::make_pair(CGI->objh->objInstances[f], std::make_pair(cr, std::vector<std::list<int3>>()));
|
||||
///initializing places that will be coloured by blitting (flag colour / player colour positions)
|
||||
toAdd.second.second.resize(CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size());
|
||||
for(int no = 0; no<CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size(); ++no)
|
||||
if(toAdd.first->defObjInfoNumber>=0 && CGI->dobjinfo->objs[toAdd.first->defObjInfoNumber].isVisitable())
|
||||
{
|
||||
for(int dx=0; dx<32; ++dx)
|
||||
toAdd.second.second.resize(CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size());
|
||||
for(int no = 0; no<CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages.size(); ++no)
|
||||
{
|
||||
for(int dy=0; dy<32; ++dy)
|
||||
bool breakNow = true;
|
||||
for(int dx=0; dx<32; ++dx)
|
||||
{
|
||||
SDL_Surface * curs = CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages[no].bitmap;
|
||||
Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx));
|
||||
Uint8* r = new Uint8, *g = new Uint8, *b = new Uint8, *a = new Uint8;
|
||||
SDL_GetRGBA(*point, curs->format, r, g, b, a);
|
||||
if(*r==255 && *g==255 && *b==0)
|
||||
toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0));
|
||||
for(int dy=0; dy<32; ++dy)
|
||||
{
|
||||
SDL_Surface * curs = CGI->mh->reader->map.defy[toAdd.first->defNumber].handler->ourImages[no].bitmap;
|
||||
Uint32* point = (Uint32*)( (Uint8*)curs->pixels + curs->pitch * (fy*32+dy) + curs->format->BytesPerPixel*(fx*32+dx));
|
||||
Uint8 r, g, b, a;
|
||||
SDL_GetRGBA(*point, curs->format, &r, &g, &b, &a);
|
||||
if(r==255 && g==255 && b==0)
|
||||
{
|
||||
toAdd.second.second[no].push_back(int3((fx*32+dx), (fy*32+dy), 0));
|
||||
breakNow = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(breakNow)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)>=0 && (CGI->objh->objInstances[f]->pos.x + fx - curd->ourImages[0].bitmap->w/32+1)<ttiles.size()-Woff && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)>=0 && (CGI->objh->objInstances[f]->pos.y + fy - curd->ourImages[0].bitmap->h/32+1)<ttiles[0].size()-Hoff)
|
||||
@ -938,7 +947,22 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
|
||||
int imgVal = CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages.size();
|
||||
SDL_BlitSurface(CGI->ac->map.defy[ttiles[x+bx][y+by][level].objects[h].first->defNumber].handler->ourImages[anim%imgVal].bitmap,&pp,su,&sr);
|
||||
}
|
||||
//printing appropriate flag colour (TODO)
|
||||
//printing appropriate flag colour
|
||||
if(ttiles[x+bx][y+by][level].objects[h].second.second.size())
|
||||
{
|
||||
std::list<int3> & curl = ttiles[x+bx][y+by][level].objects[h].second.second[anim%ttiles[x+bx][y+by][level].objects[h].second.second.size()];
|
||||
for(std::list<int3>::iterator g=curl.begin(); g!=curl.end(); ++g)
|
||||
{
|
||||
SDL_Color ourC;
|
||||
int own = ttiles[x+bx][y+by][level].objects[h].first->owner;
|
||||
if(ttiles[x+bx][y+by][level].objects[h].first->owner!=255 && ttiles[x+bx][y+by][level].objects[h].first->owner!=254)
|
||||
ourC = CGI->playerColors[ttiles[x+bx][y+by][level].objects[h].first->owner];
|
||||
else if(ttiles[x+bx][y+by][level].objects[h].first->owner==255)
|
||||
ourC = CGI->neutralColor;
|
||||
else continue;
|
||||
CSDL_Ext::SDL_PutPixelWithoutRefresh(su, bx*32 + g->x%32 , by*32 + g->y%32, ourC.r , ourC.g, ourC.b, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user