StartInfo.h 1.3 KB

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