Added function to get the map size, and fixed a stupid material bug.

develop
Japa 2014-12-17 08:40:29 +05:30
parent 6982de88bd
commit cc5a78f848
2 changed files with 22 additions and 2 deletions

@ -188,3 +188,10 @@ message ViewInfo
optional int32 cursor_pos_y = 7; optional int32 cursor_pos_y = 7;
optional int32 cursor_pos_z = 8; optional int32 cursor_pos_z = 8;
} }
message MapInfo
{
optional int32 block_size_x = 1;
optional int32 block_size_y = 2;
optional int32 block_size_z = 3;
}

@ -70,6 +70,8 @@ static command_result GetPlantList(color_ostream &stream, const BlockRequest *in
static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in); static command_result CheckHashes(color_ostream &stream, const EmptyMessage *in);
static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, UnitList *out); static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in, UnitList *out);
static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in, ViewInfo *out); static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in, ViewInfo *out);
static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in, MapInfo *out);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC); void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC);
void FindChangedBlocks(); void FindChangedBlocks();
@ -117,6 +119,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetPlantList", GetPlantList); svc->addFunction("GetPlantList", GetPlantList);
svc->addFunction("GetUnitList", GetUnitList); svc->addFunction("GetUnitList", GetUnitList);
svc->addFunction("GetViewInfo", GetViewInfo); svc->addFunction("GetViewInfo", GetViewInfo);
svc->addFunction("GetMapInfo", GetMapInfo);
return svc; return svc;
} }
@ -564,8 +567,8 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
df::tiletype tile = DfBlock->tiletype[xx][yy]; df::tiletype tile = DfBlock->tiletype[xx][yy];
NetBlock->add_tiles(tile); NetBlock->add_tiles(tile);
RemoteFortressReader::MatPair * material = NetBlock->add_materials(); RemoteFortressReader::MatPair * material = NetBlock->add_materials();
material->set_mat_type(block->baseMaterialAt(df::coord2d(xx, yy)).mat_index); material->set_mat_type(block->baseMaterialAt(df::coord2d(xx, yy)).mat_type);
material->set_mat_index(block->baseMaterialAt(df::coord2d(xx, yy)).mat_type); material->set_mat_index(block->baseMaterialAt(df::coord2d(xx, yy)).mat_index);
} }
} }
} }
@ -690,3 +693,13 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
out->set_cursor_pos_z(z); out->set_cursor_pos_z(z);
return CR_OK; return CR_OK;
} }
static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in, MapInfo *out)
{
uint32_t size_x, size_y, size_z;
Maps::getSize(size_x, size_y, size_z);
out->set_block_size_x(size_x);
out->set_block_size_y(size_y);
out->set_block_size_z(size_z);
return CR_OK;
}