CBuildingHandler.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "StdInc.h"
  2. #include "CBuildingHandler.h"
  3. #include "GameConstants.h"
  4. /*
  5. * CBuildingHandler.cpp, part of VCMI engine
  6. *
  7. * Authors: listed in file AUTHORS in main folder
  8. *
  9. * License: GNU General Public License v2.0 or later
  10. * Full text of license available in license.txt file, in main folder
  11. *
  12. */
  13. int CBuildingHandler::campToERMU( int camp, int townType, std::set<si32> builtBuildings )
  14. {
  15. using namespace boost::assign;
  16. static const std::vector<int> campToERMU = list_of(11)(12)(13)(7)(8)(9)(5)(16)(14)(15)(-1)(0)(1)(2)(3)(4)
  17. (6)(26)(17)(21)(22)(23)
  18. ; //creature generators with banks - handled separately
  19. if (camp < campToERMU.size())
  20. {
  21. return campToERMU[camp];
  22. }
  23. static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2),
  24. list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)};
  25. int curPos = campToERMU.size();
  26. for (int i=0; i<7; ++i)
  27. {
  28. if(camp == curPos) //non-upgraded
  29. return 30 + i;
  30. curPos++;
  31. if(camp == curPos) //upgraded
  32. return 37 + i;
  33. curPos++;
  34. //horde building
  35. if (vstd::contains(hordeLvlsPerTType[townType], i))
  36. {
  37. if (camp == curPos)
  38. {
  39. if (hordeLvlsPerTType[townType][0] == i)
  40. {
  41. if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built
  42. return 19;
  43. else //upgraded dwelling not presents
  44. return 18;
  45. }
  46. else
  47. {
  48. if(hordeLvlsPerTType[townType].size() > 1)
  49. {
  50. if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built
  51. return 25;
  52. else //upgraded dwelling not presents
  53. return 24;
  54. }
  55. }
  56. }
  57. curPos++;
  58. }
  59. }
  60. assert(0);
  61. return -1; //not found
  62. }