mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #645 from Adriankhl/develop-khl
Fix mingw build and Random Map Generator Option
This commit is contained in:
@@ -160,7 +160,7 @@ if(WIN32)
|
|||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp)
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} ole32 oleaut32 ws2_32 mswsock dbghelp bcrypt)
|
||||||
|
|
||||||
# Check for iconv (may be needed for Boost.Locale)
|
# Check for iconv (may be needed for Boost.Locale)
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
|
@@ -80,7 +80,10 @@ RandomMapTab::RandomMapTab()
|
|||||||
{
|
{
|
||||||
mapGenOptions->setPlayerCount(btnId);
|
mapGenOptions->setPlayerCount(btnId);
|
||||||
deactivateButtonsFrom(groupMaxTeams.get(), btnId);
|
deactivateButtonsFrom(groupMaxTeams.get(), btnId);
|
||||||
deactivateButtonsFrom(groupCompOnlyPlayers.get(), btnId);
|
|
||||||
|
// deactive some CompOnlyPlayers buttons to prevent total number of players exceeds PlayerColor::PLAYER_LIMIT_I
|
||||||
|
deactivateButtonsFrom(groupCompOnlyPlayers.get(), PlayerColor::PLAYER_LIMIT_I - btnId + 1);
|
||||||
|
|
||||||
validatePlayersCnt(btnId);
|
validatePlayersCnt(btnId);
|
||||||
updateMapInfoByHost();
|
updateMapInfoByHost();
|
||||||
});
|
});
|
||||||
@@ -175,7 +178,14 @@ void RandomMapTab::updateMapInfoByHost()
|
|||||||
mapInfo->mapHeader->players.clear();
|
mapInfo->mapHeader->players.clear();
|
||||||
int playersToGen = PlayerColor::PLAYER_LIMIT_I;
|
int playersToGen = PlayerColor::PLAYER_LIMIT_I;
|
||||||
if(mapGenOptions->getPlayerCount() != CMapGenOptions::RANDOM_SIZE)
|
if(mapGenOptions->getPlayerCount() != CMapGenOptions::RANDOM_SIZE)
|
||||||
playersToGen = mapGenOptions->getPlayerCount();
|
{
|
||||||
|
if(mapGenOptions->getCompOnlyPlayerCount() != CMapGenOptions::RANDOM_SIZE)
|
||||||
|
playersToGen = mapGenOptions->getPlayerCount() + mapGenOptions->getCompOnlyPlayerCount();
|
||||||
|
else
|
||||||
|
playersToGen = mapGenOptions->getPlayerCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mapInfo->mapHeader->howManyTeams = playersToGen;
|
mapInfo->mapHeader->howManyTeams = playersToGen;
|
||||||
|
|
||||||
for(int i = 0; i < playersToGen; ++i)
|
for(int i = 0; i < playersToGen; ++i)
|
||||||
@@ -183,7 +193,7 @@ void RandomMapTab::updateMapInfoByHost()
|
|||||||
PlayerInfo player;
|
PlayerInfo player;
|
||||||
player.isFactionRandom = true;
|
player.isFactionRandom = true;
|
||||||
player.canComputerPlay = true;
|
player.canComputerPlay = true;
|
||||||
if(mapGenOptions->getCompOnlyPlayerCount() != CMapGenOptions::RANDOM_SIZE && i >= mapGenOptions->getHumanOnlyPlayerCount())
|
if(mapGenOptions->getCompOnlyPlayerCount() != CMapGenOptions::RANDOM_SIZE && i >= mapGenOptions->getPlayerCount())
|
||||||
{
|
{
|
||||||
player.canHumanPlay = false;
|
player.canHumanPlay = false;
|
||||||
}
|
}
|
||||||
@@ -268,9 +278,10 @@ void RandomMapTab::validatePlayersCnt(int playersCnt)
|
|||||||
mapGenOptions->setTeamCount(playersCnt - 1);
|
mapGenOptions->setTeamCount(playersCnt - 1);
|
||||||
groupMaxTeams->setSelected(mapGenOptions->getTeamCount());
|
groupMaxTeams->setSelected(mapGenOptions->getTeamCount());
|
||||||
}
|
}
|
||||||
if(mapGenOptions->getCompOnlyPlayerCount() >= playersCnt)
|
// total players should not exceed PlayerColor::PLAYER_LIMIT_I (8 in homm3)
|
||||||
|
if(mapGenOptions->getCompOnlyPlayerCount() + playersCnt > PlayerColor::PLAYER_LIMIT_I)
|
||||||
{
|
{
|
||||||
mapGenOptions->setCompOnlyPlayerCount(playersCnt - 1);
|
mapGenOptions->setCompOnlyPlayerCount(PlayerColor::PLAYER_LIMIT_I - playersCnt);
|
||||||
groupCompOnlyPlayers->setSelected(mapGenOptions->getCompOnlyPlayerCount());
|
groupCompOnlyPlayers->setSelected(mapGenOptions->getCompOnlyPlayerCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "CSelectionBase.h"
|
#include "CSelectionBase.h"
|
||||||
|
|
||||||
#include "../../lib/FunctionList.h"
|
#include "../../lib/FunctionList.h"
|
||||||
|
#include "../../lib/GameConstants.h"
|
||||||
|
|
||||||
class CMapGenOptions;
|
class CMapGenOptions;
|
||||||
class CToggleButton;
|
class CToggleButton;
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "../gui/CGuiHandler.h"
|
#include "../gui/CGuiHandler.h"
|
||||||
#include "../gui/SDL_Pixels.h"
|
#include "../gui/SDL_Pixels.h"
|
||||||
|
#include "../gui/SDL_Compat.h"
|
||||||
|
|
||||||
#include "../widgets/Images.h"
|
#include "../widgets/Images.h"
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
CMapGenOptions::CMapGenOptions()
|
CMapGenOptions::CMapGenOptions()
|
||||||
: width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true),
|
: width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true),
|
||||||
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE), humanPlayersCount(0),
|
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE),
|
||||||
waterContent(EWaterContent::RANDOM), monsterStrength(EMonsterStrength::RANDOM), mapTemplate(nullptr)
|
waterContent(EWaterContent::RANDOM), monsterStrength(EMonsterStrength::RANDOM), mapTemplate(nullptr)
|
||||||
{
|
{
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
@@ -71,22 +71,9 @@ void CMapGenOptions::setPlayerCount(si8 value)
|
|||||||
if (compOnlyPlayerCount > possibleCompPlayersCount)
|
if (compOnlyPlayerCount > possibleCompPlayersCount)
|
||||||
setCompOnlyPlayerCount(possibleCompPlayersCount);
|
setCompOnlyPlayerCount(possibleCompPlayersCount);
|
||||||
|
|
||||||
if (getPlayerCount() != RANDOM_SIZE)
|
|
||||||
{
|
|
||||||
if (getCompOnlyPlayerCount() != RANDOM_SIZE)
|
|
||||||
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
|
|
||||||
else
|
|
||||||
humanPlayersCount = getPlayerCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
si8 CMapGenOptions::getHumanOnlyPlayerCount() const
|
|
||||||
{
|
|
||||||
return humanPlayersCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
si8 CMapGenOptions::getTeamCount() const
|
si8 CMapGenOptions::getTeamCount() const
|
||||||
{
|
{
|
||||||
return teamCount;
|
return teamCount;
|
||||||
@@ -105,12 +92,9 @@ si8 CMapGenOptions::getCompOnlyPlayerCount() const
|
|||||||
|
|
||||||
void CMapGenOptions::setCompOnlyPlayerCount(si8 value)
|
void CMapGenOptions::setCompOnlyPlayerCount(si8 value)
|
||||||
{
|
{
|
||||||
assert(value == RANDOM_SIZE || (getPlayerCount() == RANDOM_SIZE || (value >= 0 && value <= getPlayerCount())));
|
assert(value == RANDOM_SIZE || (getPlayerCount() == RANDOM_SIZE || (value >= 0 && value <= PlayerColor::PLAYER_LIMIT_I - getPlayerCount())));
|
||||||
compOnlyPlayerCount = value;
|
compOnlyPlayerCount = value;
|
||||||
|
|
||||||
if (getPlayerCount() != RANDOM_SIZE && getCompOnlyPlayerCount() != RANDOM_SIZE)
|
|
||||||
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
|
|
||||||
|
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +143,7 @@ void CMapGenOptions::resetPlayersMap()
|
|||||||
|
|
||||||
|
|
||||||
players.clear();
|
players.clear();
|
||||||
int realPlayersCnt = humanPlayersCount;
|
int realPlayersCnt = playerCount;
|
||||||
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
|
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
|
||||||
int totalPlayersLimit = realPlayersCnt + realCompOnlyPlayersCnt;
|
int totalPlayersLimit = realPlayersCnt + realCompOnlyPlayersCnt;
|
||||||
if (getPlayerCount() == RANDOM_SIZE || compOnlyPlayerCount == RANDOM_SIZE)
|
if (getPlayerCount() == RANDOM_SIZE || compOnlyPlayerCount == RANDOM_SIZE)
|
||||||
|
@@ -109,8 +109,6 @@ public:
|
|||||||
si8 getPlayerCount() const;
|
si8 getPlayerCount() const;
|
||||||
void setPlayerCount(si8 value);
|
void setPlayerCount(si8 value);
|
||||||
|
|
||||||
si8 getHumanOnlyPlayerCount() const;
|
|
||||||
|
|
||||||
/// The count of the teams ranging from 0 to <players count - 1> or RANDOM_SIZE for random.
|
/// The count of the teams ranging from 0 to <players count - 1> or RANDOM_SIZE for random.
|
||||||
si8 getTeamCount() const;
|
si8 getTeamCount() const;
|
||||||
void setTeamCount(si8 value);
|
void setTeamCount(si8 value);
|
||||||
@@ -166,7 +164,7 @@ private:
|
|||||||
|
|
||||||
si32 width, height;
|
si32 width, height;
|
||||||
bool hasTwoLevels;
|
bool hasTwoLevels;
|
||||||
si8 playerCount, teamCount, humanPlayersCount, compOnlyPlayerCount, compOnlyTeamCount;
|
si8 playerCount, teamCount, compOnlyPlayerCount, compOnlyTeamCount;
|
||||||
EWaterContent::EWaterContent waterContent;
|
EWaterContent::EWaterContent waterContent;
|
||||||
EMonsterStrength::EMonsterStrength monsterStrength;
|
EMonsterStrength::EMonsterStrength monsterStrength;
|
||||||
std::map<PlayerColor, CPlayerSettings> players;
|
std::map<PlayerColor, CPlayerSettings> players;
|
||||||
@@ -186,7 +184,6 @@ public:
|
|||||||
h & waterContent;
|
h & waterContent;
|
||||||
h & monsterStrength;
|
h & monsterStrength;
|
||||||
h & players;
|
h & players;
|
||||||
h & humanPlayersCount;
|
|
||||||
//TODO add name of template to class, enables selection of a template by a user
|
//TODO add name of template to class, enables selection of a template by a user
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user