2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* CBuildingHandler.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#include "StdInc.h"
|
|
|
|
#include "CBuildingHandler.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2013-02-11 22:11:34 +03:00
|
|
|
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
2014-10-02 18:43:46 +03:00
|
|
|
static const std::vector<BuildingID> campToERMU =
|
|
|
|
{
|
|
|
|
BuildingID::TOWN_HALL, BuildingID::CITY_HALL,
|
|
|
|
BuildingID::CAPITOL, BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::TAVERN,
|
|
|
|
BuildingID::BLACKSMITH, BuildingID::MARKETPLACE, BuildingID::RESOURCE_SILO, BuildingID::NONE,
|
|
|
|
BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, BuildingID::MAGES_GUILD_4,
|
|
|
|
BuildingID::MAGES_GUILD_5,
|
|
|
|
BuildingID::SHIPYARD, BuildingID::GRAIL,
|
|
|
|
BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, BuildingID::SPECIAL_4
|
|
|
|
}; //creature generators with banks - handled separately
|
|
|
|
|
2010-08-02 17:29:30 +03:00
|
|
|
if (camp < campToERMU.size())
|
|
|
|
{
|
2013-02-13 17:21:11 +03:00
|
|
|
return campToERMU[camp];
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
|
2014-10-02 18:43:46 +03:00
|
|
|
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] =
|
|
|
|
{
|
|
|
|
{2}, {1}, {1,4}, {0,2}, {0}, {0}, {0}, {0}, {0}
|
|
|
|
};
|
2010-08-02 17:29:30 +03:00
|
|
|
|
2020-10-01 10:38:06 +02:00
|
|
|
int curPos = static_cast<int>(campToERMU.size());
|
2014-02-26 20:32:42 +03:00
|
|
|
for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
|
|
|
if(camp == curPos) //non-upgraded
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID(30 + i);
|
2010-08-02 17:29:30 +03:00
|
|
|
curPos++;
|
|
|
|
if(camp == curPos) //upgraded
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID(37 + i);
|
2010-08-02 17:29:30 +03:00
|
|
|
curPos++;
|
2014-02-26 20:32:42 +03:00
|
|
|
|
|
|
|
if (i < 5) // last two levels don't have reserved horde ID. Yet another H3C weirdeness
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
2014-02-26 20:32:42 +03:00
|
|
|
if (vstd::contains(hordeLvlsPerTType[townType], i))
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
2014-02-26 20:32:42 +03:00
|
|
|
if (camp == curPos)
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
2014-02-26 20:32:42 +03:00
|
|
|
if (hordeLvlsPerTType[townType][0] == i)
|
2010-08-03 14:36:52 +03:00
|
|
|
{
|
2014-02-26 20:32:42 +03:00
|
|
|
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built
|
|
|
|
return BuildingID::HORDE_1_UPGR;
|
2010-08-03 14:36:52 +03:00
|
|
|
else //upgraded dwelling not presents
|
2014-02-26 20:32:42 +03:00
|
|
|
return BuildingID::HORDE_1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(hordeLvlsPerTType[townType].size() > 1)
|
|
|
|
{
|
|
|
|
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built
|
|
|
|
return BuildingID::HORDE_2_UPGR;
|
|
|
|
else //upgraded dwelling not presents
|
|
|
|
return BuildingID::HORDE_2;
|
|
|
|
}
|
2010-08-03 14:36:52 +03:00
|
|
|
}
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
}
|
2014-02-26 20:32:42 +03:00
|
|
|
curPos++;
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(0);
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::NONE; //not found
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|