Add ability for remotefortressreader.cpp to accept dig designations.

develop
Japa 2016-10-19 22:21:50 +05:30
parent e3f8d63726
commit 701adc12b3
3 changed files with 54 additions and 1 deletions

@ -124,7 +124,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(prospector prospector.cpp) DFHACK_PLUGIN(prospector prospector.cpp)
DFHACK_PLUGIN(power-meter power-meter.cpp LINK_LIBRARIES lua) DFHACK_PLUGIN(power-meter power-meter.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(regrass regrass.cpp) DFHACK_PLUGIN(regrass regrass.cpp)
DFHACK_PLUGIN(RemoteFortressReader remotefortressreader.cpp PROTOBUFS RemoteFortressReader) DFHACK_PLUGIN(RemoteFortressReader remotefortressreader.cpp proto/RemoteFortressReader.proto PROTOBUFS RemoteFortressReader)
DFHACK_PLUGIN(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename) DFHACK_PLUGIN(rename rename.cpp LINK_LIBRARIES lua PROTOBUFS rename)
add_subdirectory(rendermax) add_subdirectory(rendermax)
DFHACK_PLUGIN(resume resume.cpp) DFHACK_PLUGIN(resume resume.cpp)

@ -117,6 +117,13 @@ enum TileDigDesignation
UP_STAIR_DIG = 6; UP_STAIR_DIG = 6;
} }
message Coord
{
optional int32 x = 1;
optional int32 y = 2;
optional int32 z = 3;
}
message Tiletype message Tiletype
{ {
required int32 id = 1; required int32 id = 1;
@ -726,3 +733,8 @@ message KeyboardEvent
optional uint32 unicode = 7; optional uint32 unicode = 7;
} }
message DigCommand
{
optional TileDigDesignation designation = 1;
repeated Coord locations = 2;
}

@ -140,6 +140,7 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out); static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in, PlantRawList *out);
static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, ScreenCapture *out); static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in, ScreenCapture *out);
static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEvent *in); static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEvent *in);
static command_result SendDigCommand(color_ostream &stream, const DigCommand *in);
void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos); void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC, DFCoord pos);
@ -243,6 +244,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetPlantRaws", GetPlantRaws); svc->addFunction("GetPlantRaws", GetPlantRaws);
svc->addFunction("CopyScreen", CopyScreen); svc->addFunction("CopyScreen", CopyScreen);
svc->addFunction("PassKeyboardEvent", PassKeyboardEvent); svc->addFunction("PassKeyboardEvent", PassKeyboardEvent);
svc->addFunction("SendDigCommand", SendDigCommand);
return svc; return svc;
} }
@ -2856,3 +2858,42 @@ static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEve
SDL_PushEvent(&e); SDL_PushEvent(&e);
return CR_OK; return CR_OK;
} }
static command_result SendDigCommand(color_ostream &stream, const DigCommand *in)
{
MapExtras::MapCache mc;
for (int i = 0; i < in->locations.locations_size(); i++)
{
auto pos = in->locations(i);
auto des = mc.designationAt(DFCoord(pos.x(), pos.y(), pos.z()));
switch (in->designation())
{
case NO_DIG:
des.bits.dig = tile_dig_designation::No;
break;
case DEFAULT_DIG:
des.bits.dig = tile_dig_designation::Default;
break;
case UP_DOWN_STAIR_DIG:
des.bits.dig = tile_dig_designation::UpDownStair;
break;
case CHANNEL_DIG:
des.bits.dig = tile_dig_designation::Channel;
break;
case RAMP_DIG:
des.bits.dig = tile_dig_designation::Ramp;
break;
case DOWN_STAIR_DIG:
des.bits.dig = tile_dig_designation::DownStair;
break;
case UP_STAIR_DIG:
des.bits.dig = tile_dig_designation::UpStair;
break;
default:
break;
}
mc.setDesignationAt(DFCoord(pos.x(), pos.y(), pos.z()), des);
}
return CR_OK;
}