mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Missing files.
This commit is contained in:
		
							
								
								
									
										70
									
								
								lib/CMapInfo.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								lib/CMapInfo.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| #define VCMI_DLL | ||||
|  | ||||
| #include "CMapInfo.h" | ||||
| #include "..\StartInfo.h" | ||||
| #include "map.h" | ||||
| #include "..\hch\CCampaignHandler.h" | ||||
|  | ||||
| void CMapInfo::countPlayers() | ||||
| { | ||||
| 	actualHumanPlayers = playerAmnt = humenPlayers = 0; | ||||
| 	for(int i=0;i<PLAYER_LIMIT;i++) | ||||
| 	{ | ||||
| 		if(mapHeader->players[i].canHumanPlay) | ||||
| 		{ | ||||
| 			playerAmnt++; | ||||
| 			humenPlayers++; | ||||
| 		} | ||||
| 		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 unsigned char *map ) | ||||
| { | ||||
| 	filename = fname; | ||||
| 	int i = 0; | ||||
| 	mapHeader = new CMapHeader(); | ||||
| 	mapHeader->version = CMapHeader::invalid; | ||||
|  | ||||
| 	try | ||||
| 	{ | ||||
| 		mapHeader->initFromMemory(map, i); | ||||
| 		countPlayers(); | ||||
| 	} | ||||
| 	catch (const std::string &e) | ||||
| 	{ | ||||
| 		tlog1 << "\t\tWarning: evil map file: " << fname << ": " << e << std::endl;  | ||||
| 		delete mapHeader; | ||||
| 		mapHeader = NULL; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| CMapInfo::~CMapInfo() | ||||
| { | ||||
| 	delete mapHeader; | ||||
| 	delete campaignHeader; | ||||
| } | ||||
|  | ||||
| void CMapInfo::campaignInit() | ||||
| { | ||||
| 	campaignHeader = new CCampaignHeader( CCampaignHandler::getHeader(filename, lodCmpgn) ); | ||||
| } | ||||
|  | ||||
| void CMapInfo::setHeader(CMapHeader *header) | ||||
| { | ||||
| 	mapHeader = header; | ||||
| } | ||||
|  | ||||
							
								
								
									
										35
									
								
								lib/CMapInfo.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								lib/CMapInfo.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "../global.h" | ||||
|  | ||||
| class CMapHeader; | ||||
| class CCampaignHeader; | ||||
| class StartInfo; | ||||
|  | ||||
|  | ||||
| class DLL_EXPORT CMapInfo | ||||
| { | ||||
| public: | ||||
| 	CMapHeader * mapHeader; //may be NULL if campaign | ||||
| 	CCampaignHeader * campaignHeader; //may be NULL if scenario | ||||
| 	StartInfo *scenarioOpts; //options with which scenario has been started (used only with saved games) | ||||
| 	std::string filename; | ||||
| 	bool lodCmpgn; //tells if this campaign is located in Lod file | ||||
| 	std::string date; | ||||
| 	int playerAmnt, //players in map | ||||
| 		humenPlayers; //players ALLOWED to be controlled by human | ||||
| 	int actualHumanPlayers; // >1 if multiplayer game | ||||
| 	CMapInfo(bool map = true); | ||||
| 	~CMapInfo(); | ||||
| 	//CMapInfo(const std::string &fname, const unsigned char *map); | ||||
| 	void setHeader(CMapHeader *header); | ||||
| 	void mapInit(const std::string &fname, const unsigned char *map); | ||||
| 	void campaignInit(); | ||||
| 	void countPlayers(); | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int Version) | ||||
| 	{ | ||||
| 		h & mapHeader & campaignHeader & scenarioOpts & filename & lodCmpgn & date & playerAmnt & humenPlayers; | ||||
| 		h & actualHumanPlayers; | ||||
| 	} | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user