mapHandler.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #ifndef MAPHANDLER_H
  2. #define MAPHANDLER_H
  3. #include "hch\CAmbarCendamo.h"
  4. #include "hch\CSemiDefHandler.h"
  5. #include "CGameInfo.h"
  6. #include "hch\CDefHandler.h"
  7. #include <boost/logic/tribool.hpp>
  8. #include "hch\CObjectHandler.h"
  9. const int Woff = 12; //width of map's frame
  10. const int Hoff = 8;
  11. struct TerrainTile2
  12. {
  13. int3 pos; //this tile's position
  14. EterrainType terType; //type of terrain tile
  15. Eroad malle; //type of road
  16. unsigned char roaddir; //type of road tile
  17. Eriver nuine; //type of river
  18. unsigned char rivdir; //type of river tile
  19. std::vector<SDL_Surface *> terbitmap; //frames of terrain animation
  20. std::vector<SDL_Surface *> rivbitmap; //frames of river animation
  21. std::vector<SDL_Surface *> roadbitmap; //frames of road animation
  22. bool visitable; //false = not visitable; true = visitable
  23. bool blocked; //false = free; true = blocked;
  24. std::vector < std::pair<CObjectInstance*,SDL_Rect> > objects; //poiters to objects being on this tile with rects to be easier to blit this tile on screen
  25. std::vector <CObjectInstance*> visitableObjects; //pointers to objects hero is visiting being on this tile
  26. };
  27. //pathfinder
  28. // map<int,int> iDTerenu=>koszt_pola
  29. // map<int,int> IDdrogi=>koszt_drogi
  30. template <typename T> class PseudoV
  31. {
  32. public:
  33. int offset;
  34. std::vector<T> inver;
  35. inline T & operator[](int n)
  36. {
  37. return inver[n+offset];
  38. }
  39. void resize(int rest,int Offset)
  40. {
  41. inver.resize(Offset*2+rest);
  42. offset=Offset;
  43. }
  44. int size() const
  45. {
  46. return inver.size();
  47. }
  48. };
  49. class CMapHandler
  50. {
  51. public:
  52. PseudoV< PseudoV< PseudoV<TerrainTile2> > > ttiles;
  53. int3 sizes;
  54. CAmbarCendamo * reader;
  55. CDefHandler * fullHide;
  56. CDefHandler * partialHide;
  57. PseudoV< PseudoV< PseudoV<unsigned char> > > visibility; //true means that pointed place is visible
  58. //std::vector< std::vector<char> > undVisibility; //true means that pointed place is visible
  59. std::vector<CDefHandler *> roadDefs;
  60. std::vector<CDefHandler *> staticRiverDefs;
  61. char & visAccess(int x, int y);
  62. char & undVisAccess(int x, int y);
  63. SDL_Surface mirrorImage(SDL_Surface *src); //what is this??
  64. SDL_Surface * getVisBitmap(int x, int y, const PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap, int lvl);
  65. int getCost(int3 & a, int3 & b, const CHeroInstance * hero);
  66. std::vector< std::string > getObjDescriptions(int3 pos); //returns desriptions of objects blocking given position
  67. void init();
  68. SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0, PseudoV< PseudoV< PseudoV<unsigned char> > > & visibilityMap = CGI->mh->visibility);
  69. SDL_Surface * terrBitmap(int x, int y);
  70. SDL_Surface * undTerrBitmap(int x, int y);
  71. };
  72. #endif //MAPHANDLER_H