CBuildingHandler.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "StdInc.h"
  2. #include "CBuildingHandler.h"
  3. /*
  4. * CBuildingHandler.cpp, part of VCMI engine
  5. *
  6. * Authors: listed in file AUTHORS in main folder
  7. *
  8. * License: GNU General Public License v2.0 or later
  9. * Full text of license available in license.txt file, in main folder
  10. *
  11. */
  12. BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
  13. {
  14. using namespace boost::assign;
  15. static const std::vector<BuildingID> campToERMU =
  16. {
  17. BuildingID::TOWN_HALL, BuildingID::CITY_HALL,
  18. BuildingID::CAPITOL, BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::TAVERN,
  19. BuildingID::BLACKSMITH, BuildingID::MARKETPLACE, BuildingID::RESOURCE_SILO, BuildingID::NONE,
  20. BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, BuildingID::MAGES_GUILD_4,
  21. BuildingID::MAGES_GUILD_5,
  22. BuildingID::SHIPYARD, BuildingID::GRAIL,
  23. BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, BuildingID::SPECIAL_4
  24. }; //creature generators with banks - handled separately
  25. if (camp < campToERMU.size())
  26. {
  27. return campToERMU[camp];
  28. }
  29. static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] =
  30. {
  31. {2}, {1}, {1,4}, {0,2}, {0}, {0}, {0}, {0}, {0}
  32. };
  33. int curPos = campToERMU.size();
  34. for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)
  35. {
  36. if(camp == curPos) //non-upgraded
  37. return BuildingID(30 + i);
  38. curPos++;
  39. if(camp == curPos) //upgraded
  40. return BuildingID(37 + i);
  41. curPos++;
  42. if (i < 5) // last two levels don't have reserved horde ID. Yet another H3C weirdeness
  43. {
  44. if (vstd::contains(hordeLvlsPerTType[townType], i))
  45. {
  46. if (camp == curPos)
  47. {
  48. if (hordeLvlsPerTType[townType][0] == i)
  49. {
  50. if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built
  51. return BuildingID::HORDE_1_UPGR;
  52. else //upgraded dwelling not presents
  53. return BuildingID::HORDE_1;
  54. }
  55. else
  56. {
  57. if(hordeLvlsPerTType[townType].size() > 1)
  58. {
  59. if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built
  60. return BuildingID::HORDE_2_UPGR;
  61. else //upgraded dwelling not presents
  62. return BuildingID::HORDE_2;
  63. }
  64. }
  65. }
  66. }
  67. curPos++;
  68. }
  69. }
  70. assert(0);
  71. return BuildingID::NONE; //not found
  72. }