mapHandler.h 2.4 KB

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