Skip to content

Commit

Permalink
Merge pull request #3642 from randombk/remotefortressreader-reload
Browse files Browse the repository at this point in the history
Add option to force-fetch world blocks in RemoteFortressReader
  • Loading branch information
myk002 authored Aug 8, 2023
2 parents 970babe + 031191a commit cd2d408
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Template for new versions:
## Documentation

## API
- `RemoteFortressReader`: add a ``force_reload`` option to the GetBlockList RPC API to return blocks regardless of whether they have changed since the last request

## Internals

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ message BlockRequest
optional int32 max_y = 5;
optional int32 min_z = 6;
optional int32 max_z = 7;
optional bool force_reload = 8;
}

message BlockList
Expand Down
9 changes: 5 additions & 4 deletions plugins/remotefortressreader/remotefortressreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
int max_y = in->max_y();
int min_z = in->min_z();
int max_z = in->max_z();
bool forceReload = in->force_reload();
bool firstBlock = true; //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());
for (int zz = max_z - 1; zz >= min_z; zz--)
Expand Down Expand Up @@ -1440,27 +1441,27 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
bool itemsChanged = block->items.size() > 0;
bool flows = block->flows.size() > 0;
RemoteFortressReader::MapBlock *net_block = nullptr;
if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows)
if (tileChanged || desChanged || spatterChanged || firstBlock || itemsChanged || flows || forceReload)
{
net_block = out->add_map_blocks();
net_block->set_map_x(block->map_pos.x);
net_block->set_map_y(block->map_pos.y);
net_block->set_map_z(block->map_pos.z);
}
if (tileChanged)
if (tileChanged || forceReload)
{
CopyBlock(block, net_block, &MC, pos);
blocks_sent++;
}
if (desChanged)
if (desChanged || forceReload)
CopyDesignation(block, net_block, &MC, pos);
if (firstBlock)
{
CopyBuildings(DFCoord(min_x * 16, min_y * 16, min_z), DFCoord(max_x * 16, max_y * 16, max_z), net_block, &MC);
CopyProjectiles(net_block);
firstBlock = false;
}
if (spatterChanged)
if (spatterChanged || forceReload)
Copyspatters(block, net_block, &MC, pos);
if (itemsChanged)
CopyItems(block, net_block, &MC, pos);
Expand Down

0 comments on commit cd2d408

Please sign in to comment.