StartInfo.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. PlayerSettings()
  40. {
  41. bonus = brandom;
  42. castle = -2;
  43. heroPortrait = -1;
  44. }
  45. };
  46. struct StartInfo
  47. {
  48. ui8 mode; //0 - new game; 1 - load game
  49. ui8 difficulty; //0=easy; 4=impossible
  50. std::vector<PlayerSettings> playerInfos;
  51. ui8 turnTime; //in minutes, 0=unlimited
  52. std::string mapname;
  53. PlayerSettings & getIthPlayersSettings(int no)
  54. {
  55. for(unsigned int i=0; i<playerInfos.size(); ++i)
  56. if(playerInfos[i].color == no)
  57. return playerInfos[i];
  58. tlog1 << "Cannot find info about player " << no <<". Throwing...\n";
  59. throw std::string("Cannot find info about player");
  60. }
  61. template <typename Handler> void serialize(Handler &h, const int version)
  62. {
  63. h & mode;
  64. h & difficulty;
  65. h & playerInfos;
  66. h & turnTime;
  67. h & mapname;
  68. }
  69. };
  70. #endif // __STARTINFO_H__