global.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef GLOBAL_H
  2. #define GLOBAL_H
  3. #include <iostream>
  4. #include <boost/logic/tribool.hpp>
  5. #include <boost/cstdint.hpp>
  6. typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes)
  7. typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes)
  8. typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte)
  9. typedef boost::int32_t si32; //signed int 32 bits (4 bytes)
  10. typedef boost::int16_t si16; //signed int 16 bits (2 bytes)
  11. typedef boost::int8_t si8; //signed int 8 bits (1 byte)
  12. #include "int3.h"
  13. #define CHECKTIME 1
  14. #if CHECKTIME
  15. #include "timeHandler.h"
  16. #define THC
  17. #endif
  18. #define NAME_VER ("VCMI 0.62")
  19. #ifdef _WIN32
  20. #define PATHSEPARATOR "\\"
  21. #define DATA_DIR ""
  22. #else
  23. #define PATHSEPARATOR "/"
  24. #define DATA_DIR "/progdir/"
  25. #endif
  26. enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
  27. enum EterrainType {border=-1, dirt, sand, grass, snow, swamp, rough, subterranean, lava, water, rock};
  28. enum Eriver {noRiver=0, clearRiver, icyRiver, muddyRiver, lavaRiver};
  29. enum Eroad {dirtRoad=1, grazvelRoad, cobblestoneRoad};
  30. enum Eformat { WoG=0x33, AB=0x15, RoE=0x0e, SoD=0x1c};
  31. enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
  32. captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
  33. enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
  34. enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HERO_ALCHEMIST, HERO_WIZARD,
  35. HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD,
  36. HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
  37. class CGameInfo;
  38. extern CGameInfo* CGI;
  39. #define HEROI_TYPE (0)
  40. #define TOWNI_TYPE (1)
  41. const int F_NUMBER = 9; //factions (town types) quantity
  42. const int PLAYER_LIMIT = 8; //player limit per map
  43. const int HEROES_PER_TYPE=8; //amount of heroes of each type
  44. const int SKILL_QUANTITY=28;
  45. const int SKILL_PER_HERO=8;
  46. const int ARTIFACTS_QUANTITY=171;
  47. const int HEROES_QUANTITY=156;
  48. const int SPELLS_QUANTITY=70;
  49. const int RESOURCE_QUANTITY=8;
  50. const int TERRAIN_TYPES=10;
  51. const int PRIMARY_SKILLS=4;
  52. const int NEUTRAL_PLAYER=255;
  53. const int NAMES_PER_TOWN=16;
  54. const int CREATURES_PER_TOWN = 7; //without upgrades
  55. const int MAX_BUILDING_PER_TURN = 1;
  56. #define MARK_BLOCKED_POSITIONS false
  57. #define MARK_VISITABLE_POSITIONS false
  58. #define DEFBYPASS
  59. #ifdef _WIN32
  60. #ifdef VCMI_DLL
  61. #define DLL_EXPORT __declspec(dllexport)
  62. #else
  63. #define DLL_EXPORT __declspec(dllimport)
  64. #endif
  65. #else
  66. #if defined(__GNUC__) && __GNUC__ >= 4
  67. #define DLL_EXPORT __attribute__ ((visibility("default")))
  68. #else
  69. #define DLL_EXPORT
  70. #endif
  71. #endif
  72. #define HANDLE_EXCEPTION \
  73. catch (const std::exception& e) { \
  74. std::cerr << e.what() << std::endl; \
  75. } \
  76. catch (const std::exception * e) \
  77. { \
  78. std::cerr << e->what()<< std::endl; \
  79. delete e; \
  80. }
  81. namespace vstd
  82. {
  83. template <typename Container, typename Item>
  84. bool contains(const Container & c, const Item &i)
  85. {
  86. return std::find(c.begin(),c.end(),i) != c.end();
  87. }
  88. template <typename V, typename Item>
  89. bool contains(const std::map<Item,V> & c, const Item &i)
  90. {
  91. return c.find(i)!=c.end();
  92. }
  93. template <typename Container, typename Item>
  94. typename Container::iterator find(const Container & c, const Item &i)
  95. {
  96. return std::find(c.begin(),c.end(),i);
  97. }
  98. template <typename Container, typename Item>
  99. typename Container::iterator find(Container & c, const Item &i)
  100. {
  101. return std::find(c.begin(),c.end(),i);
  102. }
  103. template <typename Container, typename Item>
  104. bool operator-=(Container &c, const Item &i)
  105. {
  106. Container::iterator itr = find(c,i);
  107. if(itr == c.end())
  108. return false;
  109. c.erase(itr);
  110. return true;
  111. }
  112. }
  113. using vstd::operator-=;
  114. #endif //GLOBAL_H