14 #include "../bscript/berror.h" 15 #include "../bscript/impstr.h" 16 #include "../clib/cfgelem.h" 17 #include "../clib/cfgfile.h" 18 #include "../clib/fileutil.h" 19 #include "../clib/stlutil.h" 32 : name_( elem.rest() ), regionid_( id ), proplist_( Core::
CPropProfiler::Type::REGION )
50 std::string propvalue;
67 unsigned int gridwidth = realm->width() /
ZONE_SIZE;
68 unsigned int gridheight = realm->height() /
ZONE_SIZE;
72 for (
unsigned int i = 0; i < gridwidth; i++ )
75 for (
unsigned int j = 0; j < gridheight; j++ )
87 unsigned int gridwidth = realm.first->width() /
ZONE_SIZE;
93 for (
unsigned int i = 0; i < gridwidth; i++ )
94 delete[] realm.second[i];
95 delete[] realm.second;
108 std::string zonestr, strrealm;
116 unsigned short xwest, ynorth, xeast, ysouth;
118 if ( is >> xwest >> ynorth >> xeast >> ysouth )
120 if ( xeast >= realm->
width() || ysouth >= realm->
height() )
122 elem.
throw_error(
"Zone range is out of bounds for realm" );
124 unsigned zone_xwest, zone_ynorth, zone_xeast, zone_ysouth;
125 std::tie( zone_xwest, zone_ynorth ) =
XyToZone( xwest, ynorth );
126 std::tie( zone_xeast, zone_ysouth ) =
XyToZone( xeast, ysouth );
128 for ( zx = zone_xwest; zx <= zone_xeast; ++zx )
130 for ( zy = zone_ynorth; zy <= zone_ysouth; ++zy )
144 elem.
throw_error(
"Poorly formed zone range: " + zonestr );
152 std::tie( zx, zy ) =
XyToZone( x, y );
158 return regiongrp[zx][zy];
167 return ( *itr ).second;
175 std::vector<Region*>::iterator itr =
regions_.begin();
176 if ( ( itr += ridx ) >=
regions_.end() )
197 regions_byname_.insert( RegionsByName::value_type(
"_background_", rgn ) );
204 for (
const auto& region :
regions_ )
206 size += region->estimateSize();
210 if ( realm.first !=
nullptr )
212 unsigned int gridwidth = realm.first->width() /
ZONE_SIZE;
214 (
sizeof(
void* ) * 3 + 1 ) / 2;
217 size +=
name_.capacity();
220 size += realm.first.capacity() +
sizeof(
Region* ) + (
sizeof(
void* ) * 3 + 1 ) / 2;
226 const char* other_filename,
const char* tags_expected )
228 const char* filename;
230 filename = preferred_filename;
232 filename = other_filename;
241 while ( cf.
read( elem ) )
void read_region_data(RegionGroupBase &grp, const char *preferred_filename, const char *other_filename, const char *tags_expected)
Region * getregion_byloc(xcoord x, ycoord y, Realms::Realm *realm)
std::string remove_string(const char *propname)
RegionsByName regions_byname_
Bscript::BObjectImp * get_region_string(const std::string &propname)
std::vector< Region * > regions_
void read_custom_config(Clib::ConfigElem &elem)
virtual Region * create_region(Clib::ConfigElem &elem, RegionId id) const =0
size_t estimatedSize() const
std::pair< unsigned, unsigned > XyToZone(xcoord x, ycoord y)
RegionId getregionid(xcoord x, ycoord y, Realms::Realm *realm)
const char * rest() const
void readRemainingPropertiesAsStrings(Clib::ConfigElem &elem)
virtual size_t estimateSize() const
POL_NORETURN void throw_error(const std::string &errmsg) const
std::vector< Realms::Realm * > Realms
virtual size_t estimateSize() const
unsigned short height() const
RegionRealms regionrealms
Region * getregion_byname(const std::string ®ionname)
bool remove_prop(const char *propname, std::string *value)
unsigned short width() const
bool getprop(const std::string &propname, std::string &propvalue) const
Realms::Realm * find_realm(const std::string &name)
virtual ~RegionGroupBase()
const std::string & name() const
RegionGroupBase(const char *name)
bool FileExists(const char *filename)
void paint_zones(Clib::ConfigElem &elem, RegionId ridx)
bool read(ConfigElem &elem)
void create_bgnd_region(Clib::ConfigElem &elem)
void read_region(Clib::ConfigElem &elem)
Region(Clib::ConfigElem &elem, RegionId id)