1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
vcmi/lib/CTownHandler.h

79 lines
1.8 KiB
C
Raw Normal View History

#pragma once
#include "int3.h"
/*
* CTownHandler.h, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
class CBuilding;
class CSpell;
class CHero;
class CGTownInstance;
class DLL_LINKAGE CTown
{
std::string name; //name of type
public:
std::vector<std::string> names; //names of the town instances
std::vector<std::vector<int> > creatures; //level (from 0) -> list of creatures on this tier
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
ui32 mageLevel; //max available mage guild level
int bonus; //pic number
ui16 primaryRes, warMachine;
ui8 typeID;
const std::vector<std::string> & Names() const;
const std::string & Name() const;
void Name(const std::string & val) { name = val; }
template <typename Handler> void serialize(Handler &h, const int version)
{
h & names & creatures & hordeLvl & mageLevel & bonus
& primaryRes & warMachine & typeID;
}
};
struct DLL_LINKAGE Structure
{
int ID;
int3 pos;
std::string defName, borderName, areaName, name;
int townID, group;
bool operator<(const Structure & p2) const
{
if(pos.z != p2.pos.z)
return (pos.z) < (p2.pos.z);
else
return (ID) < (p2.ID);
}
};
class DLL_LINKAGE CTownHandler
{
public:
std::vector<CTown> towns;
std::vector<std::map<int, Structure*> > structures; // <town ID, <structure ID, structure>>
CTownHandler(); //c-tor
~CTownHandler(); //d-tor
void loadStructures();
template <typename Handler> void serialize(Handler &h, const int version)
{
h & towns;
if(!h.saving)
loadStructures();
}
};