StartInfo.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __STARTINFO_H__
  2. #define __STARTINFO_H__
  3. #include "global.h"
  4. #include <vector>
  5. /*
  6. * StartInfo.h, part of VCMI engine
  7. *
  8. * Authors: listed in file AUTHORS in main folder
  9. *
  10. * License: GNU General Public License v2.0 or later
  11. * Full text of license available in license.txt file, in main folder
  12. *
  13. */
  14. enum Ebonus {brandom=-1,bartifact, bgold, bresource};
  15. struct PlayerSettings
  16. {
  17. si32 castle, hero, //ID, if -1 then random, if -2 then none
  18. heroPortrait; //-1 if default, else ID
  19. std::string heroName;
  20. si8 bonus; //usees enum type Ebonus
  21. ui8 color; //from 0 -
  22. ui8 serial;
  23. ui8 handicap;//0-no, 1-mild, 2-severe
  24. std::string name;
  25. ui8 human;
  26. template <typename Handler> void serialize(Handler &h, const int version)
  27. {
  28. h & castle;
  29. h & hero;
  30. h & heroPortrait;
  31. h & heroName;
  32. h & bonus;
  33. h & color;
  34. h & serial;
  35. h & handicap;
  36. h & name;
  37. h & human;
  38. }
  39. };
  40. struct StartInfo
  41. {
  42. ui8 mode; //0 - new game; 1 - load game
  43. ui8 difficulty; //0=easy; 4=impossible
  44. std::vector<PlayerSettings> playerInfos;
  45. ui8 turnTime; //in minutes, 0=unlimited
  46. std::string mapname;
  47. PlayerSettings & getIthPlayersSettings(int no)
  48. {
  49. for(unsigned int i=0; i<playerInfos.size(); ++i)
  50. if(playerInfos[i].color == no)
  51. return playerInfos[i];
  52. tlog1 << "Cannot find info about player " << no <<". Throwing...\n";
  53. throw std::string("Cannot find info about player");
  54. }
  55. template <typename Handler> void serialize(Handler &h, const int version)
  56. {
  57. h & mode;
  58. h & difficulty;
  59. h & playerInfos;
  60. h & turnTime;
  61. h & mapname;
  62. }
  63. };
  64. #endif // __STARTINFO_H__