mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
b3c17d2788
- completely replaced CLodHandler, removed bitmaph and spriteh - replaced CLodStream in favour of CCompressedStream (2 new files) - renamed CResourceLoaderFactory and ResourceIndetifier to shorter names NOTES: - campaign loading is currently broken. Will fix. - I am going to remove several unused files in several days (e.g. LodHandler)
72 lines
1.4 KiB
C++
72 lines
1.4 KiB
C++
#include "StdInc.h"
|
|
#include "CMapInfo.h"
|
|
|
|
#include "StartInfo.h"
|
|
#include "map.h"
|
|
#include "CCampaignHandler.h"
|
|
#include "GameConstants.h"
|
|
|
|
void CMapInfo::countPlayers()
|
|
{
|
|
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 (std::map<int, PlayerSettings>::const_iterator i = scenarioOpts->playerInfos.begin(); i != scenarioOpts->playerInfos.end(); i++)
|
|
if(i->second.human)
|
|
actualHumanPlayers++;
|
|
}
|
|
|
|
CMapInfo::CMapInfo(bool map)
|
|
: mapHeader(NULL), campaignHeader(NULL), scenarioOpts(NULL)
|
|
{
|
|
}
|
|
|
|
void CMapInfo::mapInit(const std::string &fname, const ui8 *map )
|
|
{
|
|
fileURI = fname;
|
|
int i = 0;
|
|
mapHeader = new CMapHeader();
|
|
mapHeader->version = CMapHeader::invalid;
|
|
|
|
try
|
|
{
|
|
mapHeader->initFromMemory(map, i);
|
|
countPlayers();
|
|
}
|
|
catch (const std::exception &e)
|
|
{
|
|
tlog1 << "\t\tWarning: evil map file: " << fname << ": " << e.what() << std::endl;
|
|
delete mapHeader;
|
|
mapHeader = NULL;
|
|
}
|
|
}
|
|
|
|
CMapInfo::~CMapInfo()
|
|
{
|
|
delete mapHeader;
|
|
delete campaignHeader;
|
|
}
|
|
|
|
void CMapInfo::campaignInit()
|
|
{
|
|
campaignHeader = new CCampaignHeader( CCampaignHandler::getHeader(fileURI) );
|
|
}
|
|
|
|
void CMapInfo::setHeader(CMapHeader *header)
|
|
{
|
|
mapHeader = header;
|
|
}
|
|
|