2012-11-21 12:13:33 +03:00
|
|
|
#include "StdInc.h"
|
2012-11-03 16:30:47 +03:00
|
|
|
#include "CMapInfo.h"
|
|
|
|
|
|
|
|
#include "../StartInfo.h"
|
|
|
|
#include "CMap.h"
|
|
|
|
#include "CCampaignHandler.h"
|
|
|
|
#include "../GameConstants.h"
|
|
|
|
#include "CMapService.h"
|
|
|
|
|
|
|
|
void CMapInfo::countPlayers()
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
actualHumanPlayers = playerAmnt = humanPlayers = 0;
|
|
|
|
for(int i=0;i<GameConstants::PLAYER_LIMIT;i++)
|
|
|
|
{
|
|
|
|
if(mapHeader->players[i].canHumanPlay)
|
|
|
|
{
|
|
|
|
playerAmnt++;
|
|
|
|
humanPlayers++;
|
|
|
|
}
|
|
|
|
else if(mapHeader->players[i].canComputerPlay)
|
|
|
|
{
|
|
|
|
playerAmnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(scenarioOpts)
|
|
|
|
for (auto i = scenarioOpts->playerInfos.cbegin(); i != scenarioOpts->playerInfos.cend(); i++)
|
2012-12-02 15:21:44 +03:00
|
|
|
if(i->second.playerID != PlayerSettings::PLAYER_AI)
|
2012-11-11 15:23:31 +03:00
|
|
|
actualHumanPlayers++;
|
2012-11-03 16:30:47 +03:00
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
CMapInfo::CMapInfo() : scenarioOpts(nullptr), playerAmnt(0), humanPlayers(0),
|
|
|
|
actualHumanPlayers(0), isRandomMap(false)
|
2012-11-03 16:30:47 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMapInfo::mapInit(const std::string & fname)
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
fileURI = fname;
|
|
|
|
mapHeader = CMapService::loadMapHeader(fname);
|
|
|
|
countPlayers();
|
2012-11-03 16:30:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMapInfo::campaignInit()
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
campaignHeader = std::unique_ptr<CCampaignHeader>(new CCampaignHeader(CCampaignHandler::getHeader(fileURI)));
|
2012-11-03 16:30:47 +03:00
|
|
|
}
|
|
|
|
|