mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Not very nice fix for campaigns.
This commit is contained in:
@@ -70,7 +70,7 @@ extern SystemOptions GDefaultOptions;
|
|||||||
CGPreGame * CGP;
|
CGPreGame * CGP;
|
||||||
ISelectionScreenInfo *SEL;
|
ISelectionScreenInfo *SEL;
|
||||||
|
|
||||||
static int playerColor; //if more than one player - applies to the first -------- BROKEN BROKEN BROKEN
|
static int playerColor; //if more than one player - applies to the first
|
||||||
|
|
||||||
static std::string selectedName; //set when game is started/loaded
|
static std::string selectedName; //set when game is started/loaded
|
||||||
|
|
||||||
@@ -127,6 +127,59 @@ static void swapPlayers(PlayerSettings &a, PlayerSettings &b)
|
|||||||
playerColor = b.color;
|
playerColor = b.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPlayer(PlayerSettings &pset, unsigned player, const std::map<ui32, std::string> &playerNames)
|
||||||
|
{
|
||||||
|
if(vstd::contains(playerNames, player))
|
||||||
|
pset.name = playerNames.find(player)->second;
|
||||||
|
else
|
||||||
|
pset.name = CGI->generaltexth->allTexts[468];//Computer
|
||||||
|
|
||||||
|
pset.human = player;
|
||||||
|
if(player == playerNames.begin()->first)
|
||||||
|
playerColor = pset.color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateStartInfo(std::string filename, StartInfo & sInfo, const CMapHeader * mapHeader, const std::map<ui32, std::string> &playerNames)
|
||||||
|
{
|
||||||
|
sInfo.playerInfos.clear();
|
||||||
|
if(!filename.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*sInfo.playerInfos.resize(to->playerAmnt);*/
|
||||||
|
sInfo.mapname = filename;
|
||||||
|
playerColor = -1;
|
||||||
|
|
||||||
|
std::map<ui32, std::string>::const_iterator namesIt = playerNames.begin();
|
||||||
|
|
||||||
|
for (int i = 0; i < PLAYER_LIMIT; i++)
|
||||||
|
{
|
||||||
|
const PlayerInfo &pinfo = mapHeader->players[i];
|
||||||
|
|
||||||
|
//neither computer nor human can play - no player
|
||||||
|
if (!(pinfo.canComputerPlay || pinfo.canComputerPlay))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PlayerSettings &pset = sInfo.playerInfos[i];
|
||||||
|
pset.color = i;
|
||||||
|
if(pinfo.canHumanPlay && namesIt != playerNames.end())
|
||||||
|
setPlayer(pset, namesIt++->first, playerNames);
|
||||||
|
else
|
||||||
|
setPlayer(pset, 0, playerNames);
|
||||||
|
|
||||||
|
pset.castle = pinfo.defaultCastle();
|
||||||
|
pset.hero = pinfo.defaultHero(mapHeader->version==CMapHeader::RoE);
|
||||||
|
|
||||||
|
|
||||||
|
if(pinfo.mainHeroName.length())
|
||||||
|
{
|
||||||
|
pset.heroName = pinfo.mainHeroName;
|
||||||
|
if((pset.heroPortrait = pinfo.mainHeroPortrait) == 255)
|
||||||
|
pset.heroPortrait = pinfo.p9;
|
||||||
|
}
|
||||||
|
pset.handicap = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T> class CApplyOnPG;
|
template <typename T> class CApplyOnPG;
|
||||||
|
|
||||||
class CBaseForPGApply
|
class CBaseForPGApply
|
||||||
@@ -2696,7 +2749,9 @@ void CBonusSelection::selectMap( int whichOne )
|
|||||||
ourHeader = new CMapHeader();
|
ourHeader = new CMapHeader();
|
||||||
ourHeader->initFromMemory((const unsigned char*)ourCampaign->camp->mapPieces.find(whichOne)->second.c_str(), i);
|
ourHeader->initFromMemory((const unsigned char*)ourCampaign->camp->mapPieces.find(whichOne)->second.c_str(), i);
|
||||||
|
|
||||||
SEL->updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader);
|
std::map<ui32, std::string> names;
|
||||||
|
names[1] = GDefaultOptions.playerName;
|
||||||
|
updateStartInfo(ourCampaign->camp->header.filename, sInfo, ourHeader, names);
|
||||||
sInfo.turnTime = 0;
|
sInfo.turnTime = 0;
|
||||||
sInfo.whichMapInCampaign = whichOne;
|
sInfo.whichMapInCampaign = whichOne;
|
||||||
sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty;
|
sInfo.difficulty = ourCampaign->camp->scenarios[whichOne].difficulty;
|
||||||
@@ -3123,55 +3178,12 @@ ISelectionScreenInfo::~ISelectionScreenInfo()
|
|||||||
|
|
||||||
void ISelectionScreenInfo::updateStartInfo(std::string filename, StartInfo & sInfo, const CMapHeader * mapHeader)
|
void ISelectionScreenInfo::updateStartInfo(std::string filename, StartInfo & sInfo, const CMapHeader * mapHeader)
|
||||||
{
|
{
|
||||||
sInfo.playerInfos.clear();
|
::updateStartInfo(filename, sInfo, mapHeader, playerNames);
|
||||||
if(!filename.size())
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*sInfo.playerInfos.resize(to->playerAmnt);*/
|
|
||||||
sInfo.mapname = filename;
|
|
||||||
playerColor = -1;
|
|
||||||
|
|
||||||
std::map<ui32, std::string>::const_iterator namesIt = playerNames.begin();
|
|
||||||
|
|
||||||
for (int i = 0; i < PLAYER_LIMIT; i++)
|
|
||||||
{
|
|
||||||
const PlayerInfo &pinfo = mapHeader->players[i];
|
|
||||||
|
|
||||||
//neither computer nor human can play - no player
|
|
||||||
if (!(pinfo.canComputerPlay || pinfo.canComputerPlay))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
PlayerSettings &pset = sInfo.playerInfos[i];
|
|
||||||
pset.color = i;
|
|
||||||
if(pinfo.canHumanPlay && namesIt != playerNames.end())
|
|
||||||
setPlayer(pset, namesIt++->first);
|
|
||||||
else
|
|
||||||
setPlayer(pset, 0);
|
|
||||||
|
|
||||||
pset.castle = pinfo.defaultCastle();
|
|
||||||
pset.hero = pinfo.defaultHero(mapHeader->version==CMapHeader::RoE);
|
|
||||||
|
|
||||||
|
|
||||||
if(pinfo.mainHeroName.length())
|
|
||||||
{
|
|
||||||
pset.heroName = pinfo.mainHeroName;
|
|
||||||
if((pset.heroPortrait = pinfo.mainHeroPortrait) == 255)
|
|
||||||
pset.heroPortrait = pinfo.p9;
|
|
||||||
}
|
|
||||||
pset.handicap = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISelectionScreenInfo::setPlayer(PlayerSettings &pset, unsigned player)
|
void ISelectionScreenInfo::setPlayer(PlayerSettings &pset, unsigned player)
|
||||||
{
|
{
|
||||||
if(vstd::contains(playerNames, player))
|
::setPlayer(pset, player, playerNames);
|
||||||
pset.name = playerNames[player];
|
|
||||||
else
|
|
||||||
pset.name = CGI->generaltexth->allTexts[468];//Computer
|
|
||||||
|
|
||||||
pset.human = player;
|
|
||||||
if(player == playerNames.begin()->first)
|
|
||||||
playerColor = pset.color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ISelectionScreenInfo::getIdOfFirstUnallocatedPlayer()
|
int ISelectionScreenInfo::getIdOfFirstUnallocatedPlayer()
|
||||||
|
2
global.h
2
global.h
@@ -25,7 +25,7 @@ typedef ui16 spelltype;
|
|||||||
#define THC
|
#define THC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NAME_VER ("VCMI 0.82b")
|
#define NAME_VER ("VCMI 0.82c")
|
||||||
extern std::string NAME; //full name
|
extern std::string NAME; //full name
|
||||||
extern std::string NAME_AFFIX; //client / server
|
extern std::string NAME_AFFIX; //client / server
|
||||||
#define CONSOLE_LOGGING_LEVEL 5
|
#define CONSOLE_LOGGING_LEVEL 5
|
||||||
|
Reference in New Issue
Block a user