mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
* partial handling of advmap objects changing battle background (like clover field) (their existence should change the background but nothing else)
* map should be drawn faster because empty tiles are no more blitted (according to info from .msk files) - I hope it will work correctly, if not please report or turn it off if too hard to make it work
This commit is contained in:
parent
824061e185
commit
50a49460bf
@ -55,6 +55,7 @@ void CDefObjInfoHandler::load()
|
|||||||
{
|
{
|
||||||
nobj->blockMap[o] = 0xff;
|
nobj->blockMap[o] = 0xff;
|
||||||
nobj->visitMap[o] = 0x00;
|
nobj->visitMap[o] = 0x00;
|
||||||
|
nobj->coverageMap[0] = 0x00;
|
||||||
}
|
}
|
||||||
inp>>mapStr;
|
inp>>mapStr;
|
||||||
std::reverse(mapStr.begin(), mapStr.end());
|
std::reverse(mapStr.begin(), mapStr.end());
|
||||||
@ -100,6 +101,16 @@ void CDefObjInfoHandler::load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
inp >> nobj->printPriority;
|
inp >> nobj->printPriority;
|
||||||
|
|
||||||
|
//coverageMap calculating
|
||||||
|
std::string nameCopy = nobj->name;
|
||||||
|
std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" ));
|
||||||
|
for(int i=0; i<6; ++i)
|
||||||
|
{
|
||||||
|
nobj->coverageMap[i] = msk[i+2];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gobjs[nobj->id][nobj->subid] = nobj;
|
gobjs[nobj->id][nobj->subid] = nobj;
|
||||||
if(nobj->id==TOWNI_TYPE)
|
if(nobj->id==TOWNI_TYPE)
|
||||||
castles[nobj->subid]=nobj;
|
castles[nobj->subid]=nobj;
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
|
|
||||||
ui8 visitMap[6];
|
ui8 visitMap[6];
|
||||||
ui8 blockMap[6];
|
ui8 blockMap[6];
|
||||||
|
ui8 coverageMap[6]; //to determine which tiles are covered by picture of this object
|
||||||
ui8 visitDir; //directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
|
ui8 visitDir; //directions from which object can be entered, format same as for moveDir in CGHeroInstance(but 0 - 7)
|
||||||
si32 id, subid; //of object described by this defInfo
|
si32 id, subid; //of object described by this defInfo
|
||||||
si32 serial;
|
si32 serial;
|
||||||
@ -43,7 +44,7 @@ public:
|
|||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & name & serial & visitMap & blockMap & visitDir & id & subid &terrainAllowed
|
h & name & serial & visitMap & blockMap & visitDir & id & subid &terrainAllowed
|
||||||
& terrainMenu & width & height & type & printPriority;
|
& terrainMenu & width & height & type & printPriority & coverageMap;
|
||||||
}
|
}
|
||||||
CGDefInfo();
|
CGDefInfo();
|
||||||
};
|
};
|
||||||
|
@ -186,6 +186,14 @@ bool CGObjectInstance::blockingAt(int x, int y) const
|
|||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CGObjectInstance::coveringAt(int x, int y) const
|
||||||
|
{
|
||||||
|
if((defInfo->coverageMap[y] >> (7-(x) )) & 1)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen printing priority comparing
|
bool CGObjectInstance::operator<(const CGObjectInstance & cmp) const //screen printing priority comparing
|
||||||
{
|
{
|
||||||
if(defInfo->printPriority==1 && cmp.defInfo->printPriority==0)
|
if(defInfo->printPriority==1 && cmp.defInfo->printPriority==0)
|
||||||
|
@ -126,6 +126,7 @@ public:
|
|||||||
int getHeight() const; //returns height of object graphic in tiles
|
int getHeight() const; //returns height of object graphic in tiles
|
||||||
bool visitableAt(int x, int y) const; //returns true if object is visitable at location (x, y) form left top tile of image (x, y in tiles)
|
bool visitableAt(int x, int y) const; //returns true if object is visitable at location (x, y) form left top tile of image (x, y in tiles)
|
||||||
bool blockingAt(int x, int y) const; //returns true if object is blocking location (x, y) form left top tile of image (x, y in tiles)
|
bool blockingAt(int x, int y) const; //returns true if object is blocking location (x, y) form left top tile of image (x, y in tiles)
|
||||||
|
bool coveringAt(int x, int y) const; //returns true if object covers with picture location (x, y) form left top tile of maximal possible image (8 x 6 tiles) (x, y in tiles)
|
||||||
bool operator<(const CGObjectInstance & cmp) const; //screen printing priority comparing
|
bool operator<(const CGObjectInstance & cmp) const; //screen printing priority comparing
|
||||||
CGObjectInstance();
|
CGObjectInstance();
|
||||||
virtual ~CGObjectInstance();
|
virtual ~CGObjectInstance();
|
||||||
|
@ -1343,33 +1343,37 @@ int CGameState::battleGetBattlefieldType(int3 tile)
|
|||||||
else if(tile==int3() && !curB)
|
else if(tile==int3() && !curB)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > & objs = CGI->mh->ttiles[tile.x][tile.y][tile.z].objects;
|
std::vector <CGObjectInstance*> & objs = map->objects;
|
||||||
//for(int g=0; g<objs.size(); ++g)
|
for(int g=0; g<objs.size(); ++g)
|
||||||
//{
|
{
|
||||||
// switch(objs[g].first->ID)
|
if( objs[g]->pos.x - tile.x < 0 || objs[g]->pos.x - tile.x >= 8 || tile.y - objs[g]->pos.y + 5 < 0 || tile.y - objs[g]->pos.y + 5 >=6 ||
|
||||||
// {
|
!objs[g]->coveringAt(objs[g]->pos.x - tile.x, tile.y - objs[g]->pos.y + 5)
|
||||||
// case 222: //clover field
|
) //look only for objects covering given tile
|
||||||
// return 19;
|
continue;
|
||||||
// case 223: //cursed ground
|
switch(objs[g]->ID)
|
||||||
// return 22;
|
{
|
||||||
// case 224: //evil fog
|
case 222: //clover field
|
||||||
// return 20;
|
return 19;
|
||||||
// case 225: //favourable winds
|
case 223: //cursed ground
|
||||||
// return 21;
|
return 22;
|
||||||
// case 226: //fiery fields
|
case 224: //evil fog
|
||||||
// return 14;
|
return 20;
|
||||||
// case 227: //holy ground
|
case 225: //favourable winds
|
||||||
// return 18;
|
return 21;
|
||||||
// case 228: //lucid pools
|
case 226: //fiery fields
|
||||||
// return 17;
|
return 14;
|
||||||
// case 229: //magic clouds
|
case 227: //holy ground
|
||||||
// return 16;
|
return 18;
|
||||||
// case 230: //magic plains
|
case 228: //lucid pools
|
||||||
// return 9;
|
return 17;
|
||||||
// case 231: //rocklands
|
case 229: //magic clouds
|
||||||
// return 15;
|
return 16;
|
||||||
// }
|
case 230: //magic plains
|
||||||
//}
|
return 9;
|
||||||
|
case 231: //rocklands
|
||||||
|
return 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(map->terrain[tile.x][tile.y][tile.z].tertype)
|
switch(map->terrain[tile.x][tile.y][tile.z].tertype)
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "VCMI_Lib.h"
|
#include "VCMI_Lib.h"
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
|
#include "../hch/CLodHandler.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map.cpp, part of VCMI engine
|
* map.cpp, part of VCMI engine
|
||||||
@ -1358,6 +1359,14 @@ void Mapa::readDefInfo( unsigned char * bufor, int &i)
|
|||||||
if(vinya->id == 26)
|
if(vinya->id == 26)
|
||||||
std::memset(vinya->blockMap,255,6);
|
std::memset(vinya->blockMap,255,6);
|
||||||
|
|
||||||
|
//calculating coverageMap
|
||||||
|
std::string nameCopy = vinya->name;
|
||||||
|
std::string msk = spriteh->getTextFile(nameCopy.replace( nameCopy.size()-4, 4, ".MSK" ));
|
||||||
|
for(int i=0; i<6; ++i)
|
||||||
|
{
|
||||||
|
vinya->coverageMap[i] = msk[i+2];
|
||||||
|
}
|
||||||
|
|
||||||
defy.push_back(vinya); // add this def to the vector
|
defy.push_back(vinya); // add this def to the vector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,6 +762,8 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, std::vector< st
|
|||||||
|
|
||||||
for(int h=0; h < objects.size(); ++h)
|
for(int h=0; h < objects.size(); ++h)
|
||||||
{
|
{
|
||||||
|
if(!objects[h].first->coveringAt(objects[h].first->pos.x - (top_tile.x + bx), top_tile.y + by - objects[h].first->pos.y + 5))
|
||||||
|
continue;
|
||||||
SDL_Rect sr;
|
SDL_Rect sr;
|
||||||
|
|
||||||
sr.x = srx;
|
sr.x = srx;
|
||||||
|
Loading…
Reference in New Issue
Block a user