@ -1,5 +1,5 @@
# define DF_VERSION_INT 42004
# define RFR_VERSION "0.1 6.1 "
# include "df_version_int.h"
# define RFR_VERSION "0.1 7.0 "
# include <cstdio>
# include <time.h>
@ -17,10 +17,12 @@
# include "SDL_events.h"
# include "SDL_keyboard.h"
# include "TileTypes.h"
# if DF_VERSION_INT > 34011
# include "DFHackVersion.h"
# endif
# include "modules/Gui.h"
# include "modules/Items.h"
# include "modules/Job.h"
# include "modules/MapCache.h"
# include "modules/Maps.h"
# include "modules/Materials.h"
@ -28,9 +30,11 @@
# include "modules/Units.h"
# include "modules/World.h"
# if DF_VERSION_INT > 34011
# include "df/army.h"
# include "df/army_flags.h"
# include "df/block_square_event_item_spatterst.h"
# endif
# include "df/block_square_event_material_spatterst.h"
# include "df/body_appearance_modifier.h"
# include "df/body_part_layer_raw.h"
@ -74,7 +78,9 @@
# include "df/site_realization_building.h"
# include "df/site_realization_building_info_castle_towerst.h"
# include "df/site_realization_building_info_castle_wallst.h"
# if DF_VERSION_INT > 34011
# include "df/site_realization_building_info_trenchesst.h"
# endif
# include "df/tissue.h"
# include "df/ui.h"
# include "df/unit.h"
@ -136,7 +142,9 @@ static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessag
static command_result GetRegionMaps ( color_ostream & stream , const EmptyMessage * in , RegionMaps * out ) ;
static command_result GetRegionMapsNew ( color_ostream & stream , const EmptyMessage * in , RegionMaps * out ) ;
static command_result GetCreatureRaws ( color_ostream & stream , const EmptyMessage * in , CreatureRawList * out ) ;
static command_result GetPartialCreatureRaws ( color_ostream & stream , const ListRequest * in , CreatureRawList * out ) ;
static command_result GetPlantRaws ( color_ostream & stream , const EmptyMessage * in , PlantRawList * out ) ;
static command_result GetPartialPlantRaws ( color_ostream & stream , const ListRequest * in , PlantRawList * 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 SendDigCommand ( color_ostream & stream , const DigCommand * in ) ;
@ -188,11 +196,13 @@ command_result dump_bp_mods(color_ostream &out, vector <string> & parameters)
output < < casteRaw - > body_info . body_parts [ casteRaw - > bp_appearance . part_idx [ partIndex ] ] - > layers [ layer ] - > layer_name < < " ; " ;
output < < ENUM_KEY_STR ( appearance_modifier_type , casteRaw - > bp_appearance . modifiers [ casteRaw - > bp_appearance . modifier_idx [ partIndex ] ] - > type ) < < " ; " ;
auto appMod = casteRaw - > bp_appearance . modifiers [ casteRaw - > bp_appearance . modifier_idx [ partIndex ] ] ;
if ( appMod - > growth_rate > 0 )
# if DF_VERSION_INT > 34011
if ( appMod - > growth_rate > 0 )
{
output < < appMod - > growth_min < < " - " < < appMod - > growth_max < < " \n " ;
}
else
# endif
{
output < < casteRaw - > bp_appearance . modifiers [ casteRaw - > bp_appearance . modifier_idx [ partIndex ] ] - > ranges [ 0 ] < < " - " ;
output < < casteRaw - > bp_appearance . modifiers [ casteRaw - > bp_appearance . modifier_idx [ partIndex ] ] - > ranges [ 6 ] < < " \n " ;
@ -206,6 +216,11 @@ command_result dump_bp_mods(color_ostream &out, vector <string> & parameters)
return CR_OK ;
}
command_result RemoteFortressReader_version ( color_ostream & out , vector < string > & parameters )
{
out . print ( RFR_VERSION ) ;
return CR_OK ;
}
// Mandatory init function. If you have some global state, create it here.
DFhackCExport command_result plugin_init ( color_ostream & out , std : : vector < PluginCommand > & commands )
@ -220,6 +235,7 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector <Plugin
" isoworldremote \n "
" Does nothing. \n "
) ) ;
commands . push_back ( PluginCommand ( " RemoteFortressReader_version " , " List the loaded RemoteFortressReader version " , RemoteFortressReader_version , false , " This is used for plugin version checking. " ) ) ;
return CR_OK ;
}
@ -243,8 +259,10 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc - > addFunction ( " GetRegionMaps " , GetRegionMaps ) ;
svc - > addFunction ( " GetRegionMapsNew " , GetRegionMapsNew ) ;
svc - > addFunction ( " GetCreatureRaws " , GetCreatureRaws ) ;
svc - > addFunction ( " GetPartialCreatureRaws " , GetPartialCreatureRaws ) ;
svc - > addFunction ( " GetWorldMapCenter " , GetWorldMapCenter ) ;
svc - > addFunction ( " GetPlantRaws " , GetPlantRaws ) ;
svc - > addFunction ( " GetPartialPlantRaws " , GetPartialPlantRaws ) ;
svc - > addFunction ( " CopyScreen " , CopyScreen ) ;
svc - > addFunction ( " PassKeyboardEvent " , PassKeyboardEvent ) ;
svc - > addFunction ( " SendDigCommand " , SendDigCommand ) ;
@ -654,9 +672,14 @@ bool IsspatterChanged(DFCoord pos)
df : : map_block * block = Maps : : getBlock ( pos ) ;
bool changed = false ;
std : : vector < df : : block_square_event_material_spatterst * > materials ;
# if DF_VERSION_INT > 34011
std : : vector < df : : block_square_event_item_spatterst * > items ;
if ( ! Maps : : SortBlockEvents ( block , NULL , NULL , & materials , NULL , NULL , NULL , & items ) )
return false ;
# else
if ( ! Maps : : SortBlockEvents ( block , NULL , NULL , & materials , NULL , NULL ) )
return false ;
# endif
uint16_t hash = 0 ;
@ -665,12 +688,14 @@ bool IsspatterChanged(DFCoord pos)
auto mat = materials [ i ] ;
hash ^ = fletcher16 ( ( uint8_t * ) mat , sizeof ( df : : block_square_event_material_spatterst ) ) ;
}
# if DF_VERSION_INT > 34011
for ( int i = 0 ; i < items . size ( ) ; i + + )
{
auto item = items [ i ] ;
hash ^ = fletcher16 ( ( uint8_t * ) item , sizeof ( df : : block_square_event_item_spatterst ) ) ;
}
if ( spatterHashes [ pos ] ! = hash )
# endif
if ( spatterHashes [ pos ] ! = hash )
{
spatterHashes [ pos ] = hash ;
return true ;
@ -939,6 +964,7 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
tree_z [ xx ] [ yy ] = - 3000 ;
}
# if DF_VERSION_INT > 34011
df : : map_block_column * column = df : : global : : world - > map . column_index [ ( DfBlock - > map_pos . x / 48 ) * 3 ] [ ( DfBlock - > map_pos . y / 48 ) * 3 ] ;
for ( int i = 0 ; i < column - > plants . size ( ) ; i + + )
{
@ -987,7 +1013,8 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
tree_z [ xxx ] [ yyy ] = localPos . z ;
}
}
for ( int yy = 0 ; yy < 16 ; yy + + )
# endif
for ( int yy = 0 ; yy < 16 ; yy + + )
for ( int xx = 0 ; xx < 16 ; xx + + )
{
df : : tiletype tile = DfBlock - > tiletype [ xx ] [ yy ] ;
@ -1035,6 +1062,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
for ( int xx = 0 ; xx < 16 ; xx + + )
{
df : : tile_designation designation = DfBlock - > designation [ xx ] [ yy ] ;
df : : tile_occupancy occupancy = DfBlock - > occupancy [ xx ] [ yy ] ;
int lava = 0 ;
int water = 0 ;
if ( designation . bits . liquid_type = = df : : enums : : tile_liquid : : Magma )
@ -1054,11 +1082,17 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
auto fog_of_war = DfBlock - > fog_of_war [ xx ] [ yy ] ;
NetBlock - > add_hidden ( designation . bits . dig = = TileDigDesignation : : NO_DIG | | designation . bits . hidden ) ;
NetBlock - > add_tile_dig_designation ( TileDigDesignation : : NO_DIG ) ;
NetBlock - > add_tile_dig_designation_marker ( false ) ;
NetBlock - > add_tile_dig_designation_auto ( false ) ;
}
else
{
NetBlock - > add_hidden ( designation . bits . hidden ) ;
switch ( designation . bits . dig )
# if DF_VERSION_INT > 34011
NetBlock - > add_tile_dig_designation_marker ( occupancy . bits . dig_marked ) ;
NetBlock - > add_tile_dig_designation_auto ( occupancy . bits . dig_auto ) ;
# endif
switch ( designation . bits . dig )
{
case df : : enums : : tile_dig_designation : : No :
NetBlock - > add_tile_dig_designation ( TileDigDesignation : : NO_DIG ) ;
@ -1087,6 +1121,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
}
}
}
# if DF_VERSION_INT > 34011
for ( int i = 0 ; i < world - > job_postings . size ( ) ; i + + )
{
auto job = world - > job_postings [ i ] - > job ;
@ -1134,7 +1169,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
break ;
}
}
# endif
}
void CopyBuildings ( DFCoord min , DFCoord max , RemoteFortressReader : : MapBlock * NetBlock , MapExtras : : MapCache * MC )
@ -1179,10 +1214,14 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
NetBlock - > set_map_y ( DfBlock - > map_pos . y ) ;
NetBlock - > set_map_z ( DfBlock - > map_pos . z ) ;
std : : vector < df : : block_square_event_material_spatterst * > materials ;
# if DF_VERSION_INT > 34011
std : : vector < df : : block_square_event_item_spatterst * > items ;
if ( ! Maps : : SortBlockEvents ( DfBlock , NULL , NULL , & materials , NULL , NULL , NULL , & items ) )
return ;
# else
if ( ! Maps : : SortBlockEvents ( DfBlock , NULL , NULL , & materials , NULL , NULL ) )
return ;
# endif
for ( int yy = 0 ; yy < 16 ; yy + + )
for ( int xx = 0 ; xx < 16 ; xx + + )
{
@ -1197,6 +1236,7 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
CopyMat ( send_spat - > mutable_material ( ) , mat - > mat_type , mat - > mat_index ) ;
send_spat - > set_amount ( mat - > amount [ xx ] [ yy ] ) ;
}
# if DF_VERSION_INT > 34011
for ( int i = 0 ; i < items . size ( ) ; i + + )
{
auto item = items [ i ] ;
@ -1209,6 +1249,7 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
send_item - > set_mat_type ( item - > item_type ) ;
send_item - > set_mat_index ( item - > item_subtype ) ;
}
# endif
}
}
@ -1355,7 +1396,7 @@ static command_result GetBlockList(color_ostream &stream, const BlockRequest *in
CopyDesignation ( block , net_block , & MC , pos ) ;
if ( buildingChanged )
{
CopyBuildings ( DFCoord ( min_x , min_y , min_z ) , DFCoord ( max_x , max_y , max_z ) , net_block , & MC ) ;
CopyBuildings ( DFCoord ( min_x * 16 , min_y * 16 , min_z ) , DFCoord ( max_x * 16 , max_y * 16 , max_z ) , net_block , & MC ) ;
sentBuildings = true ;
}
if ( spatterChanged )
@ -1526,6 +1567,7 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
Gui : : getViewCoords ( x , y , z ) ;
Gui : : getCursorCoords ( cx , cy , cz ) ;
# if DF_VERSION_INT > 34011
auto embark = Gui : : getViewscreenByType < df : : viewscreen_choose_start_sitest > ( 0 ) ;
if ( embark )
{
@ -1536,6 +1578,7 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
z = data - > region_map [ location . region_pos . x ] [ location . region_pos . y ] . elevation ;
}
}
# endif
out - > set_view_pos_x ( x ) ;
out - > set_view_pos_y ( y ) ;
@ -1573,6 +1616,7 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in,
DFCoord GetMapCenter ( )
{
DFCoord output ;
# if DF_VERSION_INT > 34011
auto embark = Gui : : getViewscreenByType < df : : viewscreen_choose_start_sitest > ( 0 ) ;
if ( embark )
{
@ -1586,12 +1630,15 @@ DFCoord GetMapCenter()
output . z = data - > region_map [ location . region_pos . x ] [ location . region_pos . y ] . elevation ;
}
}
else if ( Maps : : IsValid ( ) )
else
# endif
if ( Maps : : IsValid ( ) )
{
int x , y , z ;
Maps : : getPosition ( x , y , z ) ;
output = DFCoord ( x , y , z ) ;
}
# if DF_VERSION_INT > 34011
else
for ( int i = 0 ; i < df : : global : : world - > armies . all . size ( ) ; i + + )
{
@ -1603,6 +1650,7 @@ DFCoord GetMapCenter()
output . z = thisArmy - > pos . z ;
}
}
# endif
return output ;
}
@ -1652,6 +1700,7 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
out - > set_name ( Translation : : TranslateName ( & ( data - > name ) , false ) ) ;
out - > set_name_english ( Translation : : TranslateName ( & ( data - > name ) , true ) ) ;
auto poles = data - > flip_latitude ;
# if DF_VERSION_INT > 34011
switch ( poles )
{
case df : : world_data : : None :
@ -1663,12 +1712,15 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
case df : : world_data : : South :
out - > set_world_poles ( WorldPoles : : SOUTH_POLE ) ;
break ;
case df : : world_data : : Both :
out - > set_world_poles ( WorldPoles : : BOTH_POLES ) ;
break ;
default :
break ;
}
case df : : world_data : : Both :
out - > set_world_poles ( WorldPoles : : BOTH_POLES ) ;
break ;
default :
break ;
}
# else
out - > set_world_poles ( WorldPoles : : NO_POLES ) ;
# endif
for ( int yy = 0 ; yy < height ; yy + + )
for ( int xx = 0 ; xx < width ; xx + + )
{
@ -1684,11 +1736,18 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
out - > add_savagery ( map_entry - > savagery ) ;
out - > add_salinity ( map_entry - > salinity ) ;
auto clouds = out - > add_clouds ( ) ;
# if DF_VERSION_INT > 34011
clouds - > set_cirrus ( map_entry - > clouds . bits . cirrus ) ;
clouds - > set_cumulus ( ( RemoteFortressReader : : CumulusType ) map_entry - > clouds . bits . cumulus ) ;
clouds - > set_fog ( ( RemoteFortressReader : : FogType ) map_entry - > clouds . bits . fog ) ;
clouds - > set_front ( ( RemoteFortressReader : : FrontType ) map_entry - > clouds . bits . front ) ;
clouds - > set_stratus ( ( RemoteFortressReader : : StratusType ) map_entry - > clouds . bits . stratus ) ;
# else
clouds - > set_cirrus ( map_entry - > clouds . bits . striped ) ;
clouds - > set_cumulus ( ( RemoteFortressReader : : CumulusType ) map_entry - > clouds . bits . density ) ;
clouds - > set_fog ( ( RemoteFortressReader : : FogType ) map_entry - > clouds . bits . fog ) ;
clouds - > set_stratus ( ( RemoteFortressReader : : StratusType ) map_entry - > clouds . bits . darkness ) ;
# endif
if ( region - > type = = world_region_type : : Lake )
{
out - > add_water_elevation ( region - > lake_surface ) ;
@ -1763,7 +1822,9 @@ static void SetRegionTile(RegionTile * out, df::region_map_entry * e1)
plantMat - > set_mat_type ( 419 ) ;
}
}
# if DF_VERSION_INT >= 43005
out - > set_snow ( e1 - > snowfall ) ;
# endif
}
static command_result GetWorldMapNew ( color_ostream & stream , const EmptyMessage * in , WorldMap * out )
@ -1787,6 +1848,7 @@ static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *
out - > set_world_height ( height ) ;
out - > set_name ( Translation : : TranslateName ( & ( data - > name ) , false ) ) ;
out - > set_name_english ( Translation : : TranslateName ( & ( data - > name ) , true ) ) ;
# if DF_VERSION_INT > 34011
auto poles = data - > flip_latitude ;
switch ( poles )
{
@ -1805,6 +1867,9 @@ static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *
default :
break ;
}
# else
out - > set_world_poles ( WorldPoles : : NO_POLES ) ;
# endif
for ( int yy = 0 ; yy < height ; yy + + )
for ( int xx = 0 ; xx < width ; xx + + )
{
@ -1815,11 +1880,18 @@ static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *
regionTile - > set_elevation ( map_entry - > elevation ) ;
SetRegionTile ( regionTile , map_entry ) ;
auto clouds = out - > add_clouds ( ) ;
# if DF_VERSION_INT > 34011
clouds - > set_cirrus ( map_entry - > clouds . bits . cirrus ) ;
clouds - > set_cumulus ( ( RemoteFortressReader : : CumulusType ) map_entry - > clouds . bits . cumulus ) ;
clouds - > set_fog ( ( RemoteFortressReader : : FogType ) map_entry - > clouds . bits . fog ) ;
clouds - > set_front ( ( RemoteFortressReader : : FrontType ) map_entry - > clouds . bits . front ) ;
clouds - > set_stratus ( ( RemoteFortressReader : : StratusType ) map_entry - > clouds . bits . stratus ) ;
# else
clouds - > set_cirrus ( map_entry - > clouds . bits . striped ) ;
clouds - > set_cumulus ( ( RemoteFortressReader : : CumulusType ) map_entry - > clouds . bits . density ) ;
clouds - > set_fog ( ( RemoteFortressReader : : FogType ) map_entry - > clouds . bits . fog ) ;
clouds - > set_stratus ( ( RemoteFortressReader : : StratusType ) map_entry - > clouds . bits . darkness ) ;
# endif
}
DFCoord pos = GetMapCenter ( ) ;
out - > set_center_x ( pos . x ) ;
@ -1915,6 +1987,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
sprintf ( name , " Region %d, %d " , pos_x , pos_y ) ;
out - > set_name_english ( name ) ;
out - > set_name ( name ) ;
# if DF_VERSION_INT > 34011
auto poles = worldData - > flip_latitude ;
switch ( poles )
{
@ -1933,6 +2006,9 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
default :
break ;
}
# else
out - > set_world_poles ( WorldPoles : : NO_POLES ) ;
# endif
df : : world_region_details * south = NULL ;
df : : world_region_details * east = NULL ;
@ -2168,7 +2244,9 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
auto out_building = outputTiles [ region_x ] [ region_y ] - > add_buildings ( ) ;
out_building - > set_id ( in_building - > id ) ;
# if DF_VERSION_INT > 34011
out_building - > set_type ( ( SiteRealizationBuildingType ) in_building - > type ) ;
# endif
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 ) ) ;
@ -2176,6 +2254,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
CopyMat ( out_building - > mutable_material ( ) , in_building - > item . mat_type , in_building - > item . mat_index ) ;
# if DF_VERSION_INT >= 43005
STRICT_VIRTUAL_CAST_VAR ( tower_info , df : : site_realization_building_info_castle_towerst , in_building - > building_info ) ;
if ( tower_info )
{
@ -2200,6 +2279,7 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
out_wall - > set_end_y ( wall_info - > end_y - ( site_y * 48 ) ) ;
out_wall - > set_end_z ( wall_info - > end_z ) ;
}
# endif
}
}
@ -2243,13 +2323,28 @@ static command_result GetRegionMapsNew(color_ostream &stream, const EmptyMessage
}
static command_result GetCreatureRaws ( color_ostream & stream , const EmptyMessage * in , CreatureRawList * out )
{
return GetPartialCreatureRaws ( stream , NULL , out ) ;
}
static command_result GetPartialCreatureRaws ( color_ostream & stream , const ListRequest * in , CreatureRawList * out )
{
if ( ! df : : global : : world )
return CR_FAILURE ;
df : : world * world = df : : global : : world ;
for ( int i = 0 ; i < world - > raws . creatures . all . size ( ) ; i + + )
int list_start = 0 ;
int list_end = world - > raws . creatures . all . size ( ) ;
if ( in ! = nullptr )
{
list_start = in - > list_start ( ) ;
if ( in - > list_end ( ) < list_end )
list_end = in - > list_end ( ) ;
}
for ( int i = list_start ; i < list_end ; i + + )
{
df : : creature_raw * orig_creature = world - > raws . creatures . all [ i ] ;
@ -2339,12 +2434,14 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
auto orig_mod = orig_caste - > bp_appearance . modifiers [ k ] ;
send_mod - > set_type ( ENUM_KEY_STR ( appearance_modifier_type , orig_mod - > type ) ) ;
# if DF_VERSION_INT > 34011
if ( orig_mod - > growth_rate > 0 )
{
send_mod - > set_mod_min ( orig_mod - > growth_min ) ;
send_mod - > set_mod_max ( orig_mod - > growth_max ) ;
}
else
# endif
{
send_mod - > set_mod_min ( orig_mod - > ranges [ 0 ] ) ;
send_mod - > set_mod_max ( orig_mod - > ranges [ 6 ] ) ;
@ -2364,12 +2461,14 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
send_mod - > set_type ( ENUM_KEY_STR ( appearance_modifier_type , orig_mod - > type ) ) ;
# if DF_VERSION_INT > 34011
if ( orig_mod - > growth_rate > 0 )
{
send_mod - > set_mod_min ( orig_mod - > growth_min ) ;
send_mod - > set_mod_max ( orig_mod - > growth_max ) ;
}
else
# endif
{
send_mod - > set_mod_min ( orig_mod - > ranges [ 0 ] ) ;
send_mod - > set_mod_max ( orig_mod - > ranges [ 6 ] ) ;
@ -2429,12 +2528,28 @@ static command_result GetCreatureRaws(color_ostream &stream, const EmptyMessage
}
static command_result GetPlantRaws ( color_ostream & stream , const EmptyMessage * in , PlantRawList * out )
{
GetPartialPlantRaws ( stream , nullptr , out ) ;
return CR_OK ;
}
static command_result GetPartialPlantRaws ( color_ostream & stream , const ListRequest * in , PlantRawList * out )
{
if ( ! df : : global : : world )
return CR_FAILURE ;
df : : world * world = df : : global : : world ;
int list_start = 0 ;
int list_end = world - > raws . plants . all . size ( ) ;
if ( in ! = nullptr )
{
list_start = in - > list_start ( ) ;
if ( in - > list_end ( ) < list_end )
list_end = in - > list_end ( ) ;
}
for ( int i = 0 ; i < world - > raws . plants . all . size ( ) ; i + + )
{
df : : plant_raw * plant_local = world - > raws . plants . all [ i ] ;
@ -2447,6 +2562,7 @@ static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in
plant_remote - > set_tile ( plant_local - > tiles . shrub_tile ) ;
else
plant_remote - > set_tile ( plant_local - > tiles . tree_tile ) ;
# if DF_VERSION_INT > 34011
for ( int j = 0 ; j < plant_local - > growths . size ( ) ; j + + )
{
df : : plant_growth * growth_local = plant_local - > growths [ j ] ;
@ -2479,6 +2595,7 @@ static command_result GetPlantRaws(color_ostream &stream, const EmptyMessage *in
growth_remote - > set_trunk_height_end ( growth_local - > trunk_height_perc_2 ) ;
CopyMat ( growth_remote - > mutable_mat ( ) , growth_local - > mat_type , growth_local - > mat_index ) ;
}
# endif
}
return CR_OK ;
}
@ -2502,6 +2619,7 @@ static command_result CopyScreen(color_ostream &stream, const EmptyMessage *in,
static command_result PassKeyboardEvent ( color_ostream & stream , const KeyboardEvent * in )
{
# if DF_VERSION_INT > 34011
SDL : : Event e ;
e . key . type = in - > type ( ) ;
e . key . state = in - > state ( ) ;
@ -2510,6 +2628,7 @@ static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEve
e . key . ksym . sym = ( SDL : : Key ) in - > sym ( ) ;
e . key . ksym . unicode = in - > unicode ( ) ;
SDL_PushEvent ( & e ) ;
# endif
return CR_OK ;
}
@ -2546,8 +2665,46 @@ static command_result SendDigCommand(color_ostream &stream, const DigCommand *in
break ;
default :
break ;
}
mc . setDesignationAt ( DFCoord ( pos . x ( ) , pos . y ( ) , pos . z ( ) ) , des ) ;
# if DF_VERSION_INT >= 43005
//remove and job postings related.
for ( df : : job_list_link * listing = & ( world - > job_list ) ; listing ! = NULL ; listing = listing - > next )
{
if ( listing - > item = = NULL )
continue ;
auto type = listing - > item - > job_type ;
switch ( type )
{
case df : : enums : : job_type : : CarveFortification :
case df : : enums : : job_type : : DetailWall :
case df : : enums : : job_type : : DetailFloor :
case df : : enums : : job_type : : Dig :
case df : : enums : : job_type : : CarveUpwardStaircase :
case df : : enums : : job_type : : CarveDownwardStaircase :
case df : : enums : : job_type : : CarveUpDownStaircase :
case df : : enums : : job_type : : CarveRamp :
case df : : enums : : job_type : : DigChannel :
case df : : enums : : job_type : : FellTree :
case df : : enums : : job_type : : GatherPlants :
case df : : enums : : job_type : : RemoveConstruction :
case df : : enums : : job_type : : CarveTrack :
{
if ( listing - > item - > pos = = DFCoord ( pos . x ( ) , pos . y ( ) , pos . z ( ) ) )
{
Job : : removeJob ( listing - > item ) ;
goto JOB_FOUND ;
}
break ;
}
default :
continue ;
}
}
mc . setDesignationAt ( DFCoord ( pos . x ( ) , pos . y ( ) , pos . z ( ) ) , des ) ;
JOB_FOUND :
continue ;
# endif
}
mc . WriteAll ( ) ;
@ -2569,7 +2726,11 @@ static command_result GetPauseState(color_ostream &stream, const EmptyMessage *i
command_result GetVersionInfo ( color_ostream & stream , const EmptyMessage * in , RemoteFortressReader : : VersionInfo * out )
{
out - > set_dfhack_version ( DFHACK_VERSION ) ;
# if DF_VERSION_INT == 34011
out - > set_dwarf_fortress_version ( " 0.34.11 " ) ;
# else
out - > set_dwarf_fortress_version ( DF_VERSION ) ;
# endif
out - > set_remote_fortress_reader_version ( RFR_VERSION ) ;
return command_result ( ) ;
}