global.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. #pragma once
  2. #ifndef __GLOBAL_H__
  3. #define __GLOBAL_H__
  4. #include <iostream>
  5. #include <algorithm> //std::find
  6. #include <string> //std::find
  7. #include <boost/logic/tribool.hpp>
  8. #include <boost/unordered_set.hpp>
  9. using boost::logic::tribool;
  10. #include <boost/cstdint.hpp>
  11. #include <assert.h>
  12. typedef boost::uint64_t ui64; //unsigned int 64 bits (8 bytes)
  13. typedef boost::uint32_t ui32; //unsigned int 32 bits (4 bytes)
  14. typedef boost::uint16_t ui16; //unsigned int 16 bits (2 bytes)
  15. typedef boost::uint8_t ui8; //unsigned int 8 bits (1 byte)
  16. typedef boost::int64_t si64; //signed int 64 bits (8 bytes)
  17. typedef boost::int32_t si32; //signed int 32 bits (4 bytes)
  18. typedef boost::int16_t si16; //signed int 16 bits (2 bytes)
  19. typedef boost::int8_t si8; //signed int 8 bits (1 byte)
  20. typedef si64 expType;
  21. typedef ui16 spelltype;
  22. typedef std::pair<ui32, ui32> TDmgRange;
  23. #include "int3.h"
  24. #include <map>
  25. #include <vector>
  26. #define CHECKTIME 1
  27. #if CHECKTIME
  28. #include "timeHandler.h"
  29. #define THC
  30. #endif
  31. #define NAME_VER ("VCMI 0.83b")
  32. extern std::string NAME; //full name
  33. extern std::string NAME_AFFIX; //client / server
  34. #define CONSOLE_LOGGING_LEVEL 5
  35. #define FILE_LOGGING_LEVEL 6
  36. /*
  37. * DATA_DIR contains the game data (Data/, MP3/, ...).
  38. * USER_DIR is where to save games (Games/) and the config.
  39. * BIN_DIR is where the vcmiclient/vcmiserver binaries reside
  40. * LIB_DIR is where the AI libraries reside (linux only)
  41. */
  42. #ifdef _WIN32
  43. #define DATA_DIR "."
  44. #define USER_DIR "."
  45. #define BIN_DIR "."
  46. #define LIB_DIR "AI"
  47. #define SERVER_NAME "VCMI_server.exe"
  48. #else
  49. #ifndef DATA_DIR
  50. #error DATA_DIR undefined.
  51. #endif
  52. #ifndef BIN_DIR
  53. #error BIN_DIR undefined.
  54. #endif
  55. #ifndef LIB_DIR
  56. #error LIB_DIR undefined.
  57. #endif
  58. #define SERVER_NAME "vcmiserver"
  59. #endif
  60. #ifdef _WIN32
  61. #define PATH_SEPARATOR "\\"
  62. #else
  63. #define PATH_SEPARATOR "/"
  64. #endif
  65. /*
  66. * global.h, part of VCMI engine
  67. *
  68. * Authors: listed in file AUTHORS in main folder
  69. *
  70. * License: GNU General Public License v2.0 or later
  71. * Full text of license available in license.txt file, in main folder
  72. *
  73. */
  74. enum Ecolor {RED, BLUE, TAN, GREEN, ORANGE, PURPLE, TEAL, PINK}; //player's colors
  75. enum EvictoryConditions {artifact, gatherTroop, gatherResource, buildCity, buildGrail, beatHero,
  76. captureCity, beatMonster, takeDwellings, takeMines, transportItem, winStandard=255};
  77. enum ElossCon {lossCastle, lossHero, timeExpires, lossStandard=255};
  78. enum ECombatInfo{ALIVE = 180, SUMMONED, CLONED, HAD_MORALE, WAITING, MOVED, DEFENDING};
  79. class CGameInfo;
  80. extern const CGameInfo* CGI; //game info for general use
  81. class CClientState;
  82. extern CClientState * CCS;
  83. //a few typedefs for CCreatureSet
  84. typedef si32 TSlot;
  85. typedef si32 TQuantity;
  86. typedef ui32 TCreature; //creature id
  87. const int ARMY_SIZE = 7;
  88. const int HEROI_TYPE = 34,
  89. TOWNI_TYPE = 98,
  90. CREI_TYPE = 54,
  91. EVENTI_TYPE = 26;
  92. const int CRE_LEVELS = 10;
  93. const int F_NUMBER = 9; //factions (town types) quantity
  94. const int PLAYER_LIMIT = 8; //player limit per map
  95. const int ALL_PLAYERS = 255; //bitfield
  96. const int HEROES_PER_TYPE=8; //amount of heroes of each type
  97. const int SKILL_QUANTITY=28;
  98. const int SKILL_PER_HERO=8;
  99. const int ARTIFACTS_QUANTITY=171;
  100. const int HEROES_QUANTITY=156;
  101. const int SPELLS_QUANTITY=70;
  102. const int RESOURCE_QUANTITY=8;
  103. const int TERRAIN_TYPES=10;
  104. const int PRIMARY_SKILLS=4;
  105. const int NEUTRAL_PLAYER=255;
  106. const int NAMES_PER_TOWN=16;
  107. const int CREATURES_PER_TOWN = 7; //without upgrades
  108. const int MAX_BUILDING_PER_TURN = 1;
  109. const int SPELL_LEVELS = 5;
  110. //const int CREEP_SIZE = 4000; // neutral stacks won't grow beyon this number
  111. const int CREEP_SIZE = 2000000000;
  112. const int WEEKLY_GROWTH = 10; //percent
  113. const int AVAILABLE_HEROES_PER_PLAYER = 2;
  114. const bool DWELLINGS_ACCUMULATE_CREATURES = true;
  115. const int BFIELD_WIDTH = 17;
  116. const int BFIELD_HEIGHT = 11;
  117. const int BFIELD_SIZE = BFIELD_WIDTH * BFIELD_HEIGHT;
  118. const int SPELLBOOK_GOLD_COST = 500;
  119. //for battle stacks' positions
  120. struct THex
  121. {
  122. static const si16 INVALID = -1;
  123. enum EDir{RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT, LEFT, TOP_LEFT, TOP_RIGHT};
  124. si16 hex;
  125. THex() : hex(INVALID) {}
  126. THex(si16 _hex) : hex(_hex)
  127. {
  128. //assert(isValid());
  129. }
  130. operator si16() const
  131. {
  132. return hex;
  133. }
  134. bool isValid() const
  135. {
  136. return hex >= 0 && hex < BFIELD_SIZE;
  137. }
  138. template<typename inttype>
  139. THex(inttype x, inttype y)
  140. {
  141. setXY(x, y);
  142. }
  143. template<typename inttype>
  144. THex(std::pair<inttype, inttype> xy)
  145. {
  146. setXY(xy);
  147. }
  148. template<typename inttype>
  149. void setX(inttype x)
  150. {
  151. setXY(x, getY());
  152. }
  153. template<typename inttype>
  154. void setY(inttype y)
  155. {
  156. setXY(getX(), y);
  157. }
  158. void setXY(si16 x, si16 y)
  159. {
  160. assert(x >= 0 && x < BFIELD_WIDTH && y >= 0 && y < BFIELD_HEIGHT);
  161. hex = x + y * BFIELD_WIDTH;
  162. }
  163. template<typename inttype>
  164. void setXY(std::pair<inttype, inttype> xy)
  165. {
  166. setXY(xy.first, xy.second);
  167. }
  168. si16 getY() const
  169. {
  170. return hex/BFIELD_WIDTH;
  171. }
  172. si16 getX() const
  173. {
  174. int pos = hex - getY() * BFIELD_WIDTH;
  175. return pos;
  176. }
  177. std::pair<si16, si16> getXY() const
  178. {
  179. return std::make_pair(getX(), getY());
  180. }
  181. //moving to direction
  182. void operator+=(EDir dir)
  183. {
  184. si16 x = getX(),
  185. y = getY();
  186. switch(dir)
  187. {
  188. case TOP_LEFT:
  189. setXY(y%2 ? x-1 : x, y-1);
  190. break;
  191. case TOP_RIGHT:
  192. setXY(y%2 ? x : x+1, y-1);
  193. break;
  194. case RIGHT:
  195. setXY(x+1, y);
  196. break;
  197. case BOTTOM_RIGHT:
  198. setXY(y%2 ? x : x+1, y+1);
  199. break;
  200. case BOTTOM_LEFT:
  201. setXY(y%2 ? x-1 : x, y+1);
  202. break;
  203. case LEFT:
  204. setXY(x-1, y);
  205. break;
  206. default:
  207. throw std::string("Disaster: wrong direction in THex::operator+=!\n");
  208. break;
  209. }
  210. }
  211. //generates new THex moved by given dir
  212. THex operator+(EDir dir) const
  213. {
  214. THex ret(*this);
  215. ret += dir;
  216. return ret;
  217. }
  218. std::vector<THex> neighbouringTiles() const
  219. {
  220. std::vector<THex> ret;
  221. const int WN = BFIELD_WIDTH;
  222. checkAndPush(hex - ( (hex/WN)%2 ? WN+1 : WN ), ret);
  223. checkAndPush(hex - ( (hex/WN)%2 ? WN : WN-1 ), ret);
  224. checkAndPush(hex - 1, ret);
  225. checkAndPush(hex + 1, ret);
  226. checkAndPush(hex + ( (hex/WN)%2 ? WN-1 : WN ), ret);
  227. checkAndPush(hex + ( (hex/WN)%2 ? WN : WN+1 ), ret);
  228. return ret;
  229. }
  230. //returns info about mutual position of given hexes (-1 - they're distant, 0 - left top, 1 - right top, 2 - right, 3 - right bottom, 4 - left bottom, 5 - left)
  231. static signed char mutualPosition(THex hex1, THex hex2)
  232. {
  233. if(hex2 == hex1 - ( (hex1/17)%2 ? 18 : 17 )) //top left
  234. return 0;
  235. if(hex2 == hex1 - ( (hex1/17)%2 ? 17 : 16 )) //top right
  236. return 1;
  237. if(hex2 == hex1 - 1 && hex1%17 != 0) //left
  238. return 5;
  239. if(hex2 == hex1 + 1 && hex1%17 != 16) //right
  240. return 2;
  241. if(hex2 == hex1 + ( (hex1/17)%2 ? 16 : 17 )) //bottom left
  242. return 4;
  243. if(hex2 == hex1 + ( (hex1/17)%2 ? 17 : 18 )) //bottom right
  244. return 3;
  245. return -1;
  246. }
  247. //returns distance between given hexes
  248. static si8 getDistance(THex hex1, THex hex2)
  249. {
  250. int xDst = std::abs(hex1 % BFIELD_WIDTH - hex2 % BFIELD_WIDTH),
  251. yDst = std::abs(hex1 / BFIELD_WIDTH - hex2 / BFIELD_WIDTH);
  252. return std::max(xDst, yDst) + std::min(xDst, yDst) - (yDst + 1)/2;
  253. }
  254. template <typename Handler> void serialize(Handler &h, const int version)
  255. {
  256. h & hex;
  257. }
  258. private:
  259. static void checkAndPush(int tile, std::vector<THex> & ret)
  260. {
  261. if( tile>=0 && tile<BFIELD_SIZE && (tile%BFIELD_WIDTH != (BFIELD_WIDTH - 1)) && (tile%BFIELD_WIDTH != 0) )
  262. ret.push_back(THex(tile));
  263. }
  264. };
  265. enum EMarketMode
  266. {
  267. RESOURCE_RESOURCE, RESOURCE_PLAYER, CREATURE_RESOURCE, RESOURCE_ARTIFACT,
  268. ARTIFACT_RESOURCE, ARTIFACT_EXP, CREATURE_EXP, CREATURE_UNDEAD, RESOURCE_SKILL,
  269. MARTKET_AFTER_LAST_PLACEHOLDER
  270. };
  271. namespace Res
  272. {
  273. enum ERes
  274. {
  275. WOOD = 0, MERCURY, ORE, SULFUR, CRYSTAL, GEMS, GOLD, MITHRIL
  276. };
  277. }
  278. namespace Arts
  279. {
  280. enum EPos
  281. {
  282. PRE_FIRST = -1,
  283. HEAD, SHOULDERS, NECK, RIGHT_HAND, LEFT_HAND, TORSO, RIGHT_RING, LEFT_RING, FEET, MISC1, MISC2, MISC3, MISC4,
  284. MACH1, MACH2, MACH3, MACH4, SPELLBOOK, MISC5,
  285. AFTER_LAST
  286. };
  287. const ui16 BACKPACK_START = 19;
  288. const int ID_CATAPULT = 3, ID_LOCK = 145;
  289. }
  290. enum EAlignment
  291. {
  292. GOOD, EVIL, NEUTRAL
  293. };
  294. //uncomment to make it work
  295. //#define MARK_BLOCKED_POSITIONS
  296. //#define MARK_VISITABLE_POSITIONS
  297. #define DEFBYPASS
  298. #ifdef _WIN32
  299. #define DLL_F_EXPORT __declspec(dllexport)
  300. #else
  301. #if defined(__GNUC__) && __GNUC__ >= 4
  302. #define DLL_F_EXPORT __attribute__ ((visibility("default")))
  303. #else
  304. #define DLL_F_EXPORT
  305. #endif
  306. #endif
  307. #ifdef _WIN32
  308. #define DLL_F_IMPORT __declspec(dllimport)
  309. #else
  310. #if defined(__GNUC__) && __GNUC__ >= 4
  311. #define DLL_F_IMPORT __attribute__ ((visibility("default")))
  312. #else
  313. #define DLL_F_IMPORT
  314. #endif
  315. #endif
  316. #ifdef VCMI_DLL
  317. #define DLL_EXPORT DLL_F_EXPORT
  318. #else
  319. #define DLL_EXPORT DLL_F_IMPORT
  320. #endif
  321. template<typename T, size_t N> char (&_ArrayCountObj(const T (&)[N]))[N];
  322. #define ARRAY_COUNT(arr) (sizeof(_ArrayCountObj(arr)))
  323. //a normal std::map with consted operator[] for sanity
  324. template<typename KeyT, typename ValT>
  325. class bmap : public std::map<KeyT, ValT>
  326. {
  327. public:
  328. const ValT & operator[](KeyT key) const
  329. {
  330. const_iterator it = find(key);
  331. return it->second;
  332. }
  333. ValT & operator[](KeyT key)
  334. {
  335. return static_cast<std::map<KeyT, ValT> &>(*this)[key];
  336. }
  337. template <typename Handler> void serialize(Handler &h, const int version)
  338. {
  339. h & static_cast<std::map<KeyT, ValT> &>(*this);
  340. }
  341. };
  342. namespace vstd
  343. {
  344. template <typename Container, typename Item>
  345. bool contains(const Container & c, const Item &i) //returns true if container c contains item i
  346. {
  347. return std::find(c.begin(),c.end(),i) != c.end();
  348. }
  349. template <typename V, typename Item, typename Item2>
  350. bool contains(const std::map<Item,V> & c, const Item2 &i) //returns true if map c contains item i
  351. {
  352. return c.find(i)!=c.end();
  353. }
  354. template <typename V, typename Item, typename Item2>
  355. bool contains(const bmap<Item,V> & c, const Item2 &i) //returns true if bmap c contains item i
  356. {
  357. return c.find(i)!=c.end();
  358. }
  359. template <typename Item>
  360. bool contains(const boost::unordered_set<Item> & c, const Item &i) //returns true if unordered set c contains item i
  361. {
  362. return c.find(i)!=c.end();
  363. }
  364. template <typename Container1, typename Container2>
  365. typename Container2::iterator findFirstNot(Container1 &c1, Container2 &c2)//returns first element of c2 not present in c1
  366. {
  367. typename Container2::iterator itr = c2.begin();
  368. while(itr != c2.end())
  369. if(!contains(c1,*itr))
  370. return itr;
  371. else
  372. ++itr;
  373. return c2.end();
  374. }
  375. template <typename Container1, typename Container2>
  376. typename Container2::const_iterator findFirstNot(const Container1 &c1, const Container2 &c2)//returns const first element of c2 not present in c1
  377. {
  378. typename Container2::const_iterator itr = c2.begin();
  379. while(itr != c2.end())
  380. if(!contains(c1,*itr))
  381. return itr;
  382. else
  383. ++itr;
  384. return c2.end();
  385. }
  386. template <typename Container, typename Item>
  387. typename Container::iterator find(const Container & c, const Item &i)
  388. {
  389. return std::find(c.begin(),c.end(),i);
  390. }
  391. template <typename T1, typename T2>
  392. int findPos(const std::vector<T1> & c, const T2 &s) //returns position of first element in vector c equal to s, if there is no such element, -1 is returned
  393. {
  394. for(size_t i=0; i < c.size(); ++i)
  395. if(c[i] == s)
  396. return i;
  397. return -1;
  398. }
  399. template <typename T1, typename T2, typename Func>
  400. int findPos(const std::vector<T1> & c, const T2 &s, const Func &f) //Func(T1,T2) must say if these elements matches
  401. {
  402. for(size_t i=0; i < c.size(); ++i)
  403. if(f(c[i],s))
  404. return i;
  405. return -1;
  406. }
  407. template <typename Container, typename Item>
  408. typename Container::iterator find(Container & c, const Item &i) //returns iterator to the given element if present in container, end() if not
  409. {
  410. return std::find(c.begin(),c.end(),i);
  411. }
  412. template <typename Container, typename Item>
  413. typename Container::const_iterator find(const Container & c, const Item &i)//returns const iterator to the given element if present in container, end() if not
  414. {
  415. return std::find(c.begin(),c.end(),i);
  416. }
  417. template <typename Container, typename Item>
  418. typename Container::size_type operator-=(Container &c, const Item &i) //removes element i from container c, returns false if c does not contain i
  419. {
  420. typename Container::iterator itr = find(c,i);
  421. if(itr == c.end())
  422. return false;
  423. c.erase(itr);
  424. return true;
  425. }
  426. template <typename t1>
  427. void delObj(t1 *a1)
  428. {
  429. delete a1;
  430. }
  431. template <typename t1, typename t2>
  432. void assign(t1 &a1, const t2 &a2)
  433. {
  434. a1 = a2;
  435. }
  436. template <typename t1, typename t2>
  437. struct assigner
  438. {
  439. public:
  440. t1 &op1;
  441. t2 op2;
  442. assigner(t1 &a1, const t2 & a2)
  443. :op1(a1), op2(a2)
  444. {}
  445. void operator()()
  446. {
  447. op1 = op2;
  448. }
  449. };
  450. template <typename t1, typename t2>
  451. assigner<t1,t2> assigno(t1 &a1, const t2 &a2)
  452. {
  453. return assigner<t1,t2>(a1,a2);
  454. }
  455. template <typename t1, typename t2, typename t3>
  456. bool equal(const t1 &a1, const t3 t1::* point, const t2 &a2)
  457. {
  458. return a1.*point == a2;
  459. }
  460. template <typename t1, typename t2>
  461. bool equal(const t1 &a1, const t2 &a2)
  462. {
  463. return a1 == a2;
  464. }
  465. }
  466. using vstd::operator-=;
  467. template <typename t1, typename t2>
  468. t1 & amax(t1 &a, const t2 &b) //assigns greater of (a, b) to a and returns maximum of (a, b)
  469. {
  470. if(a >= b)
  471. return a;
  472. else
  473. {
  474. a = b;
  475. return a;
  476. }
  477. }
  478. template <typename t1, typename t2>
  479. t1 & amin(t1 &a, const t2 &b) //assigns smaller of (a, b) to a and returns minimum of (a, b)
  480. {
  481. if(a <= b)
  482. return a;
  483. else
  484. {
  485. a = b;
  486. return a;
  487. }
  488. }
  489. template <typename t1, typename t2, typename t3>
  490. t1 & abetw(t1 &a, const t2 &b, const t3 &c) //makes a to fit the range <b, c>
  491. {
  492. amax(a,b);
  493. amin(a,c);
  494. return a;
  495. }
  496. template <typename T>
  497. void delNull(T* &ptr) //deleted pointer and sets it to NULL
  498. {
  499. delete ptr;
  500. ptr = NULL;
  501. }
  502. #include "CConsoleHandler.h"
  503. extern DLL_EXPORT std::ostream *logfile;
  504. extern DLL_EXPORT CConsoleHandler *console;
  505. class CLogger //logger, prints log info to console and saves in file
  506. {
  507. const int lvl;
  508. public:
  509. CLogger& operator<<(std::ostream& (*fun)(std::ostream&))
  510. {
  511. if(lvl < CONSOLE_LOGGING_LEVEL)
  512. std::cout << fun;
  513. if((lvl < FILE_LOGGING_LEVEL) && logfile)
  514. *logfile << fun;
  515. return *this;
  516. }
  517. template<typename T>
  518. CLogger & operator<<(const T & data)
  519. {
  520. if(lvl < CONSOLE_LOGGING_LEVEL)
  521. {
  522. if(console)
  523. console->print(data,lvl);
  524. else
  525. std::cout << data << std::flush;
  526. }
  527. if((lvl < FILE_LOGGING_LEVEL) && logfile)
  528. *logfile << data << std::flush;
  529. return *this;
  530. }
  531. CLogger(const int Lvl) : lvl(Lvl) {}
  532. };
  533. extern DLL_EXPORT CLogger tlog0; //green - standard progress info
  534. extern DLL_EXPORT CLogger tlog1; //red - big errors
  535. extern DLL_EXPORT CLogger tlog2; //magenta - major warnings
  536. extern DLL_EXPORT CLogger tlog3; //yellow - minor warnings
  537. extern DLL_EXPORT CLogger tlog4; //white - detailed log info
  538. extern DLL_EXPORT CLogger tlog5; //gray - minor log info
  539. extern DLL_EXPORT CLogger tlog6; //teal - AI info
  540. //XXX pls dont - 'debug macros' are usually more trouble than it's worth
  541. #define HANDLE_EXCEPTION \
  542. catch (const std::exception& e) { \
  543. tlog1 << e.what() << std::endl; \
  544. throw; \
  545. } \
  546. catch (const std::exception * e) \
  547. { \
  548. tlog1 << e->what()<< std::endl; \
  549. throw; \
  550. } \
  551. catch (const std::string& e) { \
  552. tlog1 << e << std::endl; \
  553. throw; \
  554. }
  555. #define HANDLE_EXCEPTIONC(COMMAND) \
  556. catch (const std::exception& e) { \
  557. COMMAND; \
  558. tlog1 << e.what() << std::endl; \
  559. throw; \
  560. } \
  561. catch (const std::string &e) \
  562. { \
  563. COMMAND; \
  564. tlog1 << e << std::endl; \
  565. throw; \
  566. }
  567. #if defined(linux) && defined(sparc)
  568. /* SPARC does not support unaligned memory access. Let gcc know when
  569. * to emit the right code. */
  570. struct unaligned_Uint16 { ui16 val __attribute__(( packed )); };
  571. struct unaligned_Uint32 { ui32 val __attribute__(( packed )); };
  572. static inline ui16 read_unaligned_u16(const void *p)
  573. {
  574. const struct unaligned_Uint16 *v = (const struct unaligned_Uint16 *)p;
  575. return v->val;
  576. }
  577. static inline ui32 read_unaligned_u32(const void *p)
  578. {
  579. const struct unaligned_Uint32 *v = (const struct unaligned_Uint32 *)p;
  580. return v->val;
  581. }
  582. #else
  583. #define read_unaligned_u16(p) (* reinterpret_cast<const Uint16 *>(p))
  584. #define read_unaligned_u32(p) (* reinterpret_cast<const Uint32 *>(p))
  585. #endif
  586. //for explicit overrides
  587. #ifdef _MSC_VER
  588. #define OVERRIDE override
  589. #else
  590. #define OVERRIDE //is there any working counterpart?
  591. #endif
  592. #endif // __GLOBAL_H__