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;
|
2013-03-03 20:06:03 +03:00
|
|
|
for(int i=0; i<PlayerColor::PLAYER_LIMIT_I; i++)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-02 18:23:32 +03:00
|
|
|
#define STEAL(x) x = std::move(tmp.x)
|
2013-07-02 15:08:30 +03:00
|
|
|
|
|
|
|
CMapInfo::CMapInfo(CMapInfo && tmp)
|
2013-07-02 18:23:32 +03:00
|
|
|
{
|
|
|
|
STEAL(mapHeader);
|
|
|
|
STEAL(campaignHeader);
|
|
|
|
STEAL(scenarioOpts);
|
|
|
|
STEAL(fileURI);
|
|
|
|
STEAL(date);
|
|
|
|
STEAL(playerAmnt);
|
|
|
|
STEAL(humanPlayers);
|
|
|
|
STEAL(actualHumanPlayers);
|
|
|
|
STEAL(isRandomMap);
|
|
|
|
}
|
2013-07-02 15:08:30 +03:00
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-07-02 18:23:32 +03:00
|
|
|
CMapInfo & CMapInfo::operator=(CMapInfo &&tmp)
|
|
|
|
{
|
|
|
|
STEAL(mapHeader);
|
|
|
|
STEAL(campaignHeader);
|
|
|
|
STEAL(scenarioOpts);
|
|
|
|
STEAL(fileURI);
|
|
|
|
STEAL(date);
|
|
|
|
STEAL(playerAmnt);
|
|
|
|
STEAL(humanPlayers);
|
|
|
|
STEAL(actualHumanPlayers);
|
|
|
|
STEAL(isRandomMap);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|