Send world buildings through remotefortressreader.cpp

develop
Japa 2016-08-02 10:30:17 +05:30
parent 98230e9078
commit 9189e3dc7e
3 changed files with 88 additions and 1 deletions

@ -1 +1 @@
Subproject commit 7d312334c320022cd6275cddcdb8a64d4ed8d722
Subproject commit 84f5de34c1a269420204c81f3244a70843bb9c5c

@ -411,6 +411,44 @@ message WorldMap
repeated RegionTile region_tiles = 25;
}
enum SiteRealizationBuildingType
{
cottage_plot = 0;
castle_wall = 1;
castle_tower = 2;
castle_courtyard = 3;
house = 4;
temple = 5;
tomb = 6;
shop_house = 7;
warehouse = 8;
market_square = 9;
pasture = 10;
waste = 11;
courtyard = 12;
well = 13;
vault = 14;
great_tower = 15;
trenches = 16;
tree_house = 17;
hillock_house = 18;
mead_hall = 19;
fortress_entrance = 20;
library = 21;
tavern = 22;
}
message SiteRealizationBuilding
{
optional int32 id = 1;
optional SiteRealizationBuildingType type = 2;
optional int32 min_x = 3;
optional int32 min_y = 4;
optional int32 max_x = 5;
optional int32 max_y = 6;
optional MatPair material = 7;
}
message RegionTile
{
optional int32 elevation = 1;
@ -426,6 +464,7 @@ message RegionTile
optional int32 water_elevation = 11;
optional MatPair surface_material = 12;
repeated MatPair plant_materials = 13;
repeated SiteRealizationBuilding buildings = 14;
}
message RegionMap

@ -61,6 +61,9 @@
#include "df/world_geo_biome.h"
#include "df/world_geo_layer.h"
#include "df/world_population.h"
#include "df/world_site.h"
#include "df/world_site_realization.h"
#include "df/site_realization_building.h"
#include "df/unit.h"
#include "df/creature_raw.h"
@ -2251,10 +2254,13 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
south = region;
}
RegionTile* outputTiles[17][17];
for (int yy = 0; yy < 17; yy++)
for (int xx = 0; xx < 17; xx++)
{
auto tile = out->add_tiles();
outputTiles[xx][yy] = tile;
//This is because the bottom row doesn't line up.
if (xx == 16 && yy == 16 && southEast != NULL)
{
@ -2303,6 +2309,48 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
east->set_min_pos(worldRegionDetails->rivers_horizontal.y_min[xx + 1][yy]);
east->set_max_pos(worldRegionDetails->rivers_horizontal.y_max[xx + 1][yy]);
}
auto regionMap = worldData->region_map[pos_x][pos_y];
for (int i = 0; i < regionMap.sites.size(); i++)
{
df::world_site* site = regionMap.sites[i];
if (site->realization == NULL)
continue;
int region_min_x = pos_x * 16;
int region_min_y = pos_y * 16;
auto realization = site->realization;
for (int site_x = 0; site_x < 17; site_x++)
for (int site_y = 0; site_y < 17; site_y++)
{
int region_x = site->global_min_x - region_min_x + site_x;
int region_y = site->global_min_y - region_min_y + site_y;
if (region_x < 0 || region_y < 0 || region_x >= 16 || region_y >= 16)
continue;
for (int j = 0; j < realization->building_map[site_x][site_y].buildings.size(); j++)
{
auto in_building = realization->building_map[site_x][site_y].buildings[j];
auto out_building = outputTiles[region_x][region_y]->add_buildings();
out_building->set_id(in_building->id);
out_building->set_type((SiteRealizationBuildingType)in_building->type);
out_building->set_min_x(in_building->min_x - (site_x * 48));
out_building->set_min_y(in_building->min_y - (site_y * 48));
out_building->set_max_x(in_building->max_x - (site_x * 48));
out_building->set_max_y(in_building->max_y - (site_y * 48));
auto mat = out_building->mutable_material();
mat->set_mat_type(in_building->item.mat_type);
mat->set_mat_index(in_building->item.mat_index);
}
}
}
}
static command_result GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out)