global.h 3.9 KB

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