StartInfo.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef STARTINFO_H
  2. #define STARTINFO_H
  3. #include "global.h"
  4. #include <vector>
  5. enum Ebonus {brandom=-1,bartifact, bgold, bresource};
  6. struct StartInfo
  7. {
  8. struct PlayerSettings
  9. {
  10. si32 castle, hero, //ID, if -1 then random, if -2 then none
  11. heroPortrait; //-1 if default, else ID
  12. std::string heroName;
  13. si8 bonus; //usees enum type Ebonus
  14. ui8 color; //from 0 -
  15. ui8 serial;
  16. ui8 handicap;//0-no, 1-mild, 2-severe
  17. std::string name;
  18. bool human;
  19. template <typename Handler> void serialize(Handler &h, const int version)
  20. {
  21. h & castle;
  22. h & hero;
  23. h & heroPortrait;
  24. h & heroName;
  25. h & bonus;
  26. h & color;
  27. h & serial;
  28. h & handicap;
  29. h & name;
  30. h & human;
  31. }
  32. };
  33. si32 difficulty; //0=easy; 4=impossible
  34. std::vector<PlayerSettings> playerInfos;
  35. ui8 turnTime; //in minutes, 0=unlimited
  36. std::string mapname;
  37. PlayerSettings & getIthPlayersSettings(int no)
  38. {
  39. for(unsigned int i=0; i<playerInfos.size(); ++i)
  40. if(playerInfos[i].color == no)
  41. return playerInfos[i];
  42. #ifndef __GNUC__
  43. throw new std::exception("Cannot find info about player");
  44. #else
  45. throw new std::exception();
  46. #endif
  47. }
  48. template <typename Handler> void serialize(Handler &h, const int version)
  49. {
  50. h & difficulty;
  51. h & playerInfos;
  52. h & turnTime;
  53. h & mapname;
  54. }
  55. };
  56. #endif