1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-04 09:42:40 +02:00
vcmi/lib/mapping/CMapInfo.cpp
Arseniy Shestakov 452e28d183 Remove some useless includes found by cppclean
This of course was tested and shouldn't break anything
2016-08-26 04:42:16 +03:00

78 lines
1.6 KiB
C++

#include "StdInc.h"
#include "CMapInfo.h"
#include "../StartInfo.h"
#include "../GameConstants.h"
#include "CMapService.h"
void CMapInfo::countPlayers()
{
actualHumanPlayers = playerAmnt = humanPlayers = 0;
for(int i=0; i<PlayerColor::PLAYER_LIMIT_I; 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++)
if(i->second.playerID != PlayerSettings::PLAYER_AI)
actualHumanPlayers++;
}
CMapInfo::CMapInfo() : scenarioOpts(nullptr), playerAmnt(0), humanPlayers(0),
actualHumanPlayers(0), isRandomMap(false)
{
}
#define STEAL(x) x = std::move(tmp.x)
CMapInfo::CMapInfo(CMapInfo && tmp)
{
STEAL(mapHeader);
STEAL(campaignHeader);
STEAL(scenarioOpts);
STEAL(fileURI);
STEAL(date);
STEAL(playerAmnt);
STEAL(humanPlayers);
STEAL(actualHumanPlayers);
STEAL(isRandomMap);
}
void CMapInfo::mapInit(const std::string & fname)
{
fileURI = fname;
mapHeader = CMapService::loadMapHeader(fname);
countPlayers();
}
void CMapInfo::campaignInit()
{
campaignHeader = std::unique_ptr<CCampaignHeader>(new CCampaignHeader(CCampaignHandler::getHeader(fileURI)));
}
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;
}