2011-12-14 00:23:17 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "int3.h"
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*
|
2009-04-16 14:14:13 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
class CBuilding;
|
|
|
|
class CSpell;
|
|
|
|
class CHero;
|
|
|
|
class CGTownInstance;
|
2011-12-14 00:23:17 +03:00
|
|
|
class DLL_LINKAGE CTown
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
std::string name; //name of type
|
|
|
|
public:
|
|
|
|
|
|
|
|
std::vector<std::string> names; //names of the town instances
|
2012-08-08 00:46:24 +03:00
|
|
|
std::vector<std::vector<int> > creatures; //level (from 0) -> list of creatures on this tier
|
2009-04-16 14:14:13 +03:00
|
|
|
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)
|
|
|
|
{
|
2012-08-08 00:46:24 +03:00
|
|
|
h & names & creatures & hordeLvl & mageLevel & bonus
|
2009-04-16 14:14:13 +03:00
|
|
|
& primaryRes & warMachine & typeID;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE Structure
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
class DLL_LINKAGE CTownHandler
|
2009-04-16 14:14:13 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::vector<CTown> towns;
|
2010-08-16 12:54:09 +03:00
|
|
|
std::vector<std::map<int, Structure*> > structures; // <town ID, <structure ID, structure>>
|
2009-04-16 14:14:13 +03:00
|
|
|
|
2009-05-07 20:20:41 +03:00
|
|
|
CTownHandler(); //c-tor
|
|
|
|
~CTownHandler(); //d-tor
|
2009-04-16 14:14:13 +03:00
|
|
|
void loadStructures();
|
|
|
|
|
|
|
|
template <typename Handler> void serialize(Handler &h, const int version)
|
|
|
|
{
|
2012-08-09 13:32:50 +03:00
|
|
|
h & towns;
|
2009-04-16 14:14:13 +03:00
|
|
|
if(!h.saving)
|
|
|
|
loadStructures();
|
|
|
|
}
|
|
|
|
};
|