mapHandler.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 = 4; //width of map's frame
  10. const int Hoff = 4;
  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()
  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. std::vector< std::vector<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, std::vector< std::vector<char> > & visibility);
  65. int getCost(int3 & a, int3 & b, CHeroInstance * hero);
  66. void init();
  67. SDL_Surface * terrainRect(int x, int y, int dx, int dy, int level=0, unsigned char anim=0);
  68. SDL_Surface * terrBitmap(int x, int y);
  69. SDL_Surface * undTerrBitmap(int x, int y);
  70. };
  71. #endif //MAPHANDLER_H