|
|
@ -1137,19 +1137,13 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CopyBuildings(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
|
|
|
|
void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int minX = DfBlock->map_pos.x;
|
|
|
|
|
|
|
|
int minY = DfBlock->map_pos.y;
|
|
|
|
|
|
|
|
int Z = DfBlock->map_pos.z;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int maxX = minX + 15;
|
|
|
|
|
|
|
|
int maxY = minY + 15;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < df::global::world->buildings.all.size(); i++)
|
|
|
|
for (int i = 0; i < df::global::world->buildings.all.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
df::building * bld = df::global::world->buildings.all[i];
|
|
|
|
df::building * bld = df::global::world->buildings.all[i];
|
|
|
|
if (bld->x1 > maxX || bld->y1 > maxY || bld->x2 < minX || bld->y2 < minY)
|
|
|
|
if (bld->x1 >= max.x || bld->y1 >= max.y || bld->x2 < min.x || bld->y2 < min.y)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
int z2 = bld->z;
|
|
|
|
int z2 = bld->z;
|
|
|
@ -1162,7 +1156,7 @@ void CopyBuildings(df::map_block * DfBlock, RemoteFortressReader::MapBlock * Net
|
|
|
|
z2 = well_building->bucket_z;
|
|
|
|
z2 = well_building->bucket_z;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bld->z < Z || z2 > Z)
|
|
|
|
if (bld->z < min.z || z2 >= max.z)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
auto out_bld = NetBlock->add_buildings();
|
|
|
|
auto out_bld = NetBlock->add_buildings();
|
|
|
|
CopyBuilding(i, out_bld);
|
|
|
|
CopyBuilding(i, out_bld);
|
|
|
@ -1170,13 +1164,6 @@ void CopyBuildings(df::map_block * DfBlock, RemoteFortressReader::MapBlock * Net
|
|
|
|
if (actualBuilding)
|
|
|
|
if (actualBuilding)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int i = 0; i < actualBuilding->contained_items.size(); i++)
|
|
|
|
for (int i = 0; i < actualBuilding->contained_items.size(); i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (actualBuilding->contained_items[i]->use_mode == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isItemChanged(actualBuilding->contained_items[i]->item->id))
|
|
|
|
|
|
|
|
CopyItem(NetBlock->add_items(), actualBuilding->contained_items[i]->item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto buildingItem = out_bld->add_items();
|
|
|
|
auto buildingItem = out_bld->add_items();
|
|
|
|
buildingItem->set_mode(actualBuilding->contained_items[i]->use_mode);
|
|
|
|
buildingItem->set_mode(actualBuilding->contained_items[i]->use_mode);
|
|
|
@ -1184,7 +1171,6 @@ void CopyBuildings(df::map_block * DfBlock, RemoteFortressReader::MapBlock * Net
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
|
|
|
|
void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos)
|
|
|
@ -1314,8 +1300,11 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
|
|
|
|
int min_y = in->min_y();
|
|
|
|
int min_y = in->min_y();
|
|
|
|
int max_x = in->max_x();
|
|
|
|
int max_x = in->max_x();
|
|
|
|
int max_y = in->max_y();
|
|
|
|
int max_y = in->max_y();
|
|
|
|
|
|
|
|
int min_z = in->min_z();
|
|
|
|
|
|
|
|
int max_z = in->max_z();
|
|
|
|
|
|
|
|
bool sentBuildings = false; //Always send all the buildings needed on the first block, and none on the rest.
|
|
|
|
//stream.print("Got request for blocks from (%d, %d, %d) to (%d, %d, %d).\n", in->min_x(), in->min_y(), in->min_z(), in->max_x(), in->max_y(), in->max_z());
|
|
|
|
//stream.print("Got request for blocks from (%d, %d, %d) to (%d, %d, %d).\n", in->min_x(), in->min_y(), in->min_z(), in->max_x(), in->max_y(), in->max_z());
|
|
|
|
for (int zz = in->max_z() - 1; zz >= in->min_z(); zz--)
|
|
|
|
for (int zz = max_z - 1; zz >= min_z; zz--)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// (di, dj) is a vector - direction in which we move right now
|
|
|
|
// (di, dj) is a vector - direction in which we move right now
|
|
|
|
int di = 1;
|
|
|
|
int di = 1;
|
|
|
@ -1346,12 +1335,12 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
|
|
|
|
|| block->occupancy[xxx][yyy].bits.building > 0)
|
|
|
|
|| block->occupancy[xxx][yyy].bits.building > 0)
|
|
|
|
nonAir++;
|
|
|
|
nonAir++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nonAir > 0)
|
|
|
|
if (nonAir > 0 || !sentBuildings)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool tileChanged = IsTiletypeChanged(pos);
|
|
|
|
bool tileChanged = IsTiletypeChanged(pos);
|
|
|
|
bool desChanged = IsDesignationChanged(pos);
|
|
|
|
bool desChanged = IsDesignationChanged(pos);
|
|
|
|
bool spatterChanged = IsspatterChanged(pos);
|
|
|
|
bool spatterChanged = IsspatterChanged(pos);
|
|
|
|
bool buildingChanged = IsBuildingChanged(pos);
|
|
|
|
bool buildingChanged = !sentBuildings;
|
|
|
|
bool itemsChanged = areItemsChanged(&block->items);
|
|
|
|
bool itemsChanged = areItemsChanged(&block->items);
|
|
|
|
//bool bldChanged = IsBuildingChanged(pos);
|
|
|
|
//bool bldChanged = IsBuildingChanged(pos);
|
|
|
|
RemoteFortressReader::MapBlock *net_block;
|
|
|
|
RemoteFortressReader::MapBlock *net_block;
|
|
|
@ -1365,7 +1354,10 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
|
|
|
|
if (desChanged)
|
|
|
|
if (desChanged)
|
|
|
|
CopyDesignation(block, net_block, &MC, pos);
|
|
|
|
CopyDesignation(block, net_block, &MC, pos);
|
|
|
|
if (buildingChanged)
|
|
|
|
if (buildingChanged)
|
|
|
|
CopyBuildings(block, net_block, &MC, pos);
|
|
|
|
{
|
|
|
|
|
|
|
|
CopyBuildings(DFCoord(min_x, min_y, min_z), DFCoord(max_x, max_y, max_z), net_block, &MC);
|
|
|
|
|
|
|
|
sentBuildings = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (spatterChanged)
|
|
|
|
if (spatterChanged)
|
|
|
|
Copyspatters(block, net_block, &MC, pos);
|
|
|
|
Copyspatters(block, net_block, &MC, pos);
|
|
|
|
if (itemsChanged)
|
|
|
|
if (itemsChanged)
|
|
|
|