mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
Merge pull request #3480 from IvanSavenko/rmg_ban_starting_heroes
Ban starting heroes in RMG
This commit is contained in:
commit
19765e0e01
@ -388,6 +388,13 @@ void CMapGenOptions::setStartingTownForPlayer(const PlayerColor & color, Faction
|
|||||||
it->second.setStartingTown(town);
|
it->second.setStartingTown(town);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMapGenOptions::setStartingHeroForPlayer(const PlayerColor & color, HeroTypeID hero)
|
||||||
|
{
|
||||||
|
auto it = players.find(color);
|
||||||
|
assert(it != players.end());
|
||||||
|
it->second.setStartingHero(hero);
|
||||||
|
}
|
||||||
|
|
||||||
void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType)
|
void CMapGenOptions::setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType)
|
||||||
{
|
{
|
||||||
// FIXME: Why actually not set it to COMP_ONLY? Ie. when swapping human to another color?
|
// FIXME: Why actually not set it to COMP_ONLY? Ie. when swapping human to another color?
|
||||||
@ -746,7 +753,7 @@ const CRmgTemplate * CMapGenOptions::getPossibleTemplate(CRandomGenerator & rand
|
|||||||
return *RandomGeneratorUtil::nextItem(templates, rand);
|
return *RandomGeneratorUtil::nextItem(templates, rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMapGenOptions::CPlayerSettings::CPlayerSettings() : color(0), startingTown(FactionID::RANDOM), playerType(EPlayerType::AI), team(TeamID::NO_TEAM)
|
CMapGenOptions::CPlayerSettings::CPlayerSettings() : color(0), startingTown(FactionID::RANDOM), startingHero(HeroTypeID::RANDOM), playerType(EPlayerType::AI), team(TeamID::NO_TEAM)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -778,6 +785,17 @@ void CMapGenOptions::CPlayerSettings::setStartingTown(FactionID value)
|
|||||||
startingTown = value;
|
startingTown = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeroTypeID CMapGenOptions::CPlayerSettings::getStartingHero() const
|
||||||
|
{
|
||||||
|
return startingHero;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapGenOptions::CPlayerSettings::setStartingHero(HeroTypeID value)
|
||||||
|
{
|
||||||
|
assert(value == HeroTypeID::RANDOM || value.toEntity(VLC) != nullptr);
|
||||||
|
startingHero = value;
|
||||||
|
}
|
||||||
|
|
||||||
EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const
|
EPlayerType CMapGenOptions::CPlayerSettings::getPlayerType() const
|
||||||
{
|
{
|
||||||
return playerType;
|
return playerType;
|
||||||
|
@ -45,6 +45,11 @@ public:
|
|||||||
FactionID getStartingTown() const;
|
FactionID getStartingTown() const;
|
||||||
void setStartingTown(FactionID value);
|
void setStartingTown(FactionID value);
|
||||||
|
|
||||||
|
/// The starting hero of the player ranging from 0 to hero max count or RANDOM_HERO.
|
||||||
|
/// The default value is RANDOM_HERO
|
||||||
|
HeroTypeID getStartingHero() const;
|
||||||
|
void setStartingHero(HeroTypeID value);
|
||||||
|
|
||||||
/// The default value is EPlayerType::AI.
|
/// The default value is EPlayerType::AI.
|
||||||
EPlayerType getPlayerType() const;
|
EPlayerType getPlayerType() const;
|
||||||
void setPlayerType(EPlayerType value);
|
void setPlayerType(EPlayerType value);
|
||||||
@ -56,6 +61,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
PlayerColor color;
|
PlayerColor color;
|
||||||
FactionID startingTown;
|
FactionID startingTown;
|
||||||
|
HeroTypeID startingHero;
|
||||||
EPlayerType playerType;
|
EPlayerType playerType;
|
||||||
TeamID team;
|
TeamID team;
|
||||||
|
|
||||||
@ -68,6 +74,10 @@ public:
|
|||||||
h & playerType;
|
h & playerType;
|
||||||
if(version >= 806)
|
if(version >= 806)
|
||||||
h & team;
|
h & team;
|
||||||
|
if (version >= 832)
|
||||||
|
h & startingHero;
|
||||||
|
else
|
||||||
|
startingHero = HeroTypeID::RANDOM;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -120,6 +130,7 @@ public:
|
|||||||
const std::map<PlayerColor, CPlayerSettings> & getPlayersSettings() const;
|
const std::map<PlayerColor, CPlayerSettings> & getPlayersSettings() const;
|
||||||
const std::map<PlayerColor, CPlayerSettings> & getSavedPlayersMap() const;
|
const std::map<PlayerColor, CPlayerSettings> & getSavedPlayersMap() const;
|
||||||
void setStartingTownForPlayer(const PlayerColor & color, FactionID town);
|
void setStartingTownForPlayer(const PlayerColor & color, FactionID town);
|
||||||
|
void setStartingHeroForPlayer(const PlayerColor & color, HeroTypeID hero);
|
||||||
/// Sets a player type for a standard player. A standard player is the opposite of a computer only player. The
|
/// Sets a player type for a standard player. A standard player is the opposite of a computer only player. The
|
||||||
/// values which can be chosen for the player type are EPlayerType::AI or EPlayerType::HUMAN.
|
/// values which can be chosen for the player type are EPlayerType::AI or EPlayerType::HUMAN.
|
||||||
void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType);
|
void setPlayerTypeForStandardPlayer(const PlayerColor & color, EPlayerType playerType);
|
||||||
|
@ -491,14 +491,26 @@ const std::vector<HeroTypeID> CMapGenerator::getAllPossibleHeroes() const
|
|||||||
for (HeroTypeID hero : map->getMap(this).allowedHeroes)
|
for (HeroTypeID hero : map->getMap(this).allowedHeroes)
|
||||||
{
|
{
|
||||||
auto * h = dynamic_cast<const CHero*>(VLC->heroTypes()->getById(hero));
|
auto * h = dynamic_cast<const CHero*>(VLC->heroTypes()->getById(hero));
|
||||||
if ((h->onlyOnWaterMap && !isWaterMap) || (h->onlyOnMapWithoutWater && isWaterMap))
|
if(h->onlyOnWaterMap && !isWaterMap)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
else
|
if(h->onlyOnMapWithoutWater && isWaterMap)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool heroUsedAsStarting = false;
|
||||||
|
for (auto const & player : map->getMapGenOptions().getPlayersSettings())
|
||||||
{
|
{
|
||||||
ret.push_back(hero);
|
if (player.second.getStartingHero() == hero)
|
||||||
|
{
|
||||||
|
heroUsedAsStarting = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (heroUsedAsStarting)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ret.push_back(hero);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
const ui32 SERIALIZATION_VERSION = 831;
|
const ui32 SERIALIZATION_VERSION = 832;
|
||||||
const ui32 MINIMAL_SERIALIZATION_VERSION = 831;
|
const ui32 MINIMAL_SERIALIZATION_VERSION = 831;
|
||||||
const std::string SAVEGAME_MAGIC = "VCMISVG";
|
const std::string SAVEGAME_MAGIC = "VCMISVG";
|
||||||
|
|
||||||
|
@ -762,6 +762,7 @@ void CVCMIServer::updateAndPropagateLobbyState()
|
|||||||
{
|
{
|
||||||
const auto & pset = psetPair.second;
|
const auto & pset = psetPair.second;
|
||||||
si->mapGenOptions->setStartingTownForPlayer(pset.color, pset.castle);
|
si->mapGenOptions->setStartingTownForPlayer(pset.color, pset.castle);
|
||||||
|
si->mapGenOptions->setStartingHeroForPlayer(pset.color, pset.hero);
|
||||||
if(pset.isControlledByHuman())
|
if(pset.isControlledByHuman())
|
||||||
{
|
{
|
||||||
si->mapGenOptions->setPlayerTypeForStandardPlayer(pset.color, EPlayerType::HUMAN);
|
si->mapGenOptions->setPlayerTypeForStandardPlayer(pset.color, EPlayerType::HUMAN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user