Merge remote-tracking branch 'JapaMala/master' into develop

develop
lethosor 2017-07-12 16:52:30 -04:00
commit 018f3be70a
6 changed files with 568 additions and 31 deletions

@ -98,6 +98,7 @@ enum BuildingDirection
EAST = 1; EAST = 1;
SOUTH = 2; SOUTH = 2;
WEST = 3; WEST = 3;
NONE = 4;
} }
enum TileDigDesignation enum TileDigDesignation
@ -172,6 +173,7 @@ message BuildingInstance
optional BuildingExtents room = 12; optional BuildingExtents room = 12;
optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings
repeated BuildingItem items = 14; repeated BuildingItem items = 14;
optional int32 active = 15;
} }
message RiverEdge message RiverEdge
@ -252,6 +254,8 @@ message MapBlock
repeated TileDigDesignation tile_dig_designation = 24; repeated TileDigDesignation tile_dig_designation = 24;
repeated SpatterPile spatterPile = 25; repeated SpatterPile spatterPile = 25;
repeated Item items = 26; repeated Item items = 26;
repeated bool tile_dig_designation_marker = 27;
repeated bool tile_dig_designation_auto = 28;
} }
message MatPair { message MatPair {
@ -771,3 +775,9 @@ message VersionInfo
optional string dfhack_version = 2; optional string dfhack_version = 2;
optional string remote_fortress_reader_version = 3; optional string remote_fortress_reader_version = 3;
} }
message ListRequest
{
optional int32 list_start = 1;
optional int32 list_end = 2;
}

@ -7,6 +7,7 @@ SET(PROJECT_SRCS
# A list of headers # A list of headers
SET(PROJECT_HDRS SET(PROJECT_HDRS
building_reader.h building_reader.h
df_version_int.h
) )
#proto files to include. #proto files to include.
SET(PROJECT_PROTO SET(PROJECT_PROTO

@ -1,18 +1,64 @@
#include "building_reader.h" #include "building_reader.h"
#include "DataDefs.h" #include "DataDefs.h"
#include "df/building_archerytargetst.h" //building types
#include "df/building_axle_horizontalst.h" #include "df/building_actual.h"
#include "df/building_chairst.h"
#include "df/building_bedst.h"
#include "df/building_tablest.h"
#include "df/building_coffinst.h"
#include "df/building_farmplotst.h"
#include "df/building_furnacest.h"
#include "df/building_tradedepotst.h"
#include "df/building_shopst.h"
#include "df/building_doorst.h"
#include "df/building_floodgatest.h"
#include "df/building_boxst.h"
#include "df/building_weaponrackst.h"
#include "df/building_armorstandst.h"
#include "df/building_workshopst.h"
#include "df/building_cabinetst.h"
#include "df/building_statuest.h"
#include "df/building_window_glassst.h"
#include "df/building_window_gemst.h"
#include "df/building_wellst.h"
#include "df/building_bridgest.h" #include "df/building_bridgest.h"
#include "df/building_def_furnacest.h" #include "df/building_road_dirtst.h"
#include "df/building_def_workshopst.h" #include "df/building_road_pavedst.h"
#include "df/building_rollersst.h"
#include "df/building_screw_pumpst.h"
#include "df/building_siegeenginest.h" #include "df/building_siegeenginest.h"
#include "df/building_trapst.h"
#include "df/building_animaltrapst.h"
#include "df/building_supportst.h"
#include "df/building_archerytargetst.h"
#include "df/building_chainst.h"
#include "df/building_cagest.h"
#include "df/building_stockpilest.h"
#include "df/building_civzonest.h"
#include "df/building_weaponst.h"
#include "df/building_wagonst.h"
#include "df/building_screw_pumpst.h"
#include "df/building_constructionst.h"
#include "df/building_hatchst.h"
#include "df/building_grate_wallst.h"
#include "df/building_grate_floorst.h"
#include "df/building_bars_verticalst.h"
#include "df/building_bars_floorst.h"
#include "df/building_gear_assemblyst.h"
#include "df/building_axle_horizontalst.h"
#include "df/building_axle_verticalst.h"
#include "df/building_water_wheelst.h" #include "df/building_water_wheelst.h"
#include "df/building_wellst.h"
#include "df/building_windmillst.h" #include "df/building_windmillst.h"
#include "df/building_traction_benchst.h"
#include "df/building_slabst.h"
#include "df/building_nestst.h"
#include "df/building_nest_boxst.h"
#include "df/building_hivest.h"
#include "df/building_rollersst.h"
#include "df/building_def_furnacest.h"
#include "df/building_def_workshopst.h"
#include "df/world.h" #include "df/world.h"
#include "df/machine.h"
#include "modules/Buildings.h" #include "modules/Buildings.h"
@ -269,7 +315,7 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
remote_build->set_building_flags(local_build->flags.whole); remote_build->set_building_flags(local_build->flags.whole);
remote_build->set_is_room(local_build->is_room); remote_build->set_is_room(local_build->is_room);
if (local_build->is_room || local_build->getType() == df::enums::building_type::Civzone || local_build->getType() == df::enums::building_type::Stockpile) if (local_build->room.width > 0 && local_build->room.height > 0 && local_build->room.extents != nullptr)
{ {
auto room = remote_build->mutable_room(); auto room = remote_build->mutable_room();
room->set_pos_x(local_build->room.x); room->set_pos_x(local_build->room.x);
@ -282,49 +328,180 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
} }
} }
//Add building-specific info
switch (type) switch (type)
{ {
case df::enums::building_type::NONE: case df::enums::building_type::NONE:
{
auto actual = virtual_cast<df::building_actual>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Chair: case df::enums::building_type::Chair:
{
auto actual = strict_virtual_cast<df::building_chairst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Bed: case df::enums::building_type::Bed:
{
auto actual = strict_virtual_cast<df::building_bedst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Table: case df::enums::building_type::Table:
{
auto actual = strict_virtual_cast<df::building_tablest>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Coffin: case df::enums::building_type::Coffin:
{
auto actual = strict_virtual_cast<df::building_coffinst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::FarmPlot: case df::enums::building_type::FarmPlot:
{
auto actual = strict_virtual_cast<df::building_farmplotst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Furnace: case df::enums::building_type::Furnace:
{
auto actual = strict_virtual_cast<df::building_furnacest>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::TradeDepot: case df::enums::building_type::TradeDepot:
{
auto actual = strict_virtual_cast<df::building_tradedepotst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Shop: case df::enums::building_type::Shop:
{
auto actual = strict_virtual_cast<df::building_shopst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Door: case df::enums::building_type::Door:
{
auto actual = strict_virtual_cast<df::building_doorst>(local_build);
if (actual)
{
if (actual->door_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::Floodgate: case df::enums::building_type::Floodgate:
{
auto actual = strict_virtual_cast<df::building_floodgatest>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::Box: case df::enums::building_type::Box:
{
auto actual = strict_virtual_cast<df::building_boxst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Weaponrack: case df::enums::building_type::Weaponrack:
{
auto actual = strict_virtual_cast<df::building_weaponrackst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Armorstand: case df::enums::building_type::Armorstand:
{
auto actual = strict_virtual_cast<df::building_armorstandst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Workshop: case df::enums::building_type::Workshop:
{
auto actual = strict_virtual_cast<df::building_workshopst>(local_build);
if (actual && actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
break; break;
}
case df::enums::building_type::Cabinet: case df::enums::building_type::Cabinet:
{
auto actual = strict_virtual_cast<df::building_cabinetst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Statue: case df::enums::building_type::Statue:
{
auto actual = strict_virtual_cast<df::building_statuest>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::WindowGlass: case df::enums::building_type::WindowGlass:
{
auto actual = strict_virtual_cast<df::building_window_glassst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::WindowGem: case df::enums::building_type::WindowGem:
{
auto actual = strict_virtual_cast<df::building_window_gemst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Well: case df::enums::building_type::Well:
{
auto actual = strict_virtual_cast<df::building_wellst>(local_build);
if (actual)
{
remote_build->set_active(actual->bucket_z);
}
break; break;
}
case df::enums::building_type::Bridge: case df::enums::building_type::Bridge:
{ {
auto actual = strict_virtual_cast<df::building_bridgest>(local_build); auto actual = strict_virtual_cast<df::building_bridgest>(local_build);
@ -334,6 +511,7 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
switch (direction) switch (direction)
{ {
case df::building_bridgest::Retracting: case df::building_bridgest::Retracting:
remote_build->set_direction(NONE);
break; break;
case df::building_bridgest::Left: case df::building_bridgest::Left:
remote_build->set_direction(WEST); remote_build->set_direction(WEST);
@ -350,13 +528,29 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
default: default:
break; break;
} }
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
} }
break;
} }
break;
case df::enums::building_type::RoadDirt: case df::enums::building_type::RoadDirt:
{
auto actual = strict_virtual_cast<df::building_road_dirtst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::RoadPaved: case df::enums::building_type::RoadPaved:
{
auto actual = strict_virtual_cast<df::building_road_pavedst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::SiegeEngine: case df::enums::building_type::SiegeEngine:
{ {
auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build); auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build);
@ -381,14 +575,34 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
break; break;
} }
} }
break;
} }
break;
case df::enums::building_type::Trap: case df::enums::building_type::Trap:
{
auto actual = strict_virtual_cast<df::building_trapst>(local_build);
if (actual)
{
remote_build->set_active(actual->state);
}
break; break;
}
case df::enums::building_type::AnimalTrap: case df::enums::building_type::AnimalTrap:
{
auto actual = strict_virtual_cast<df::building_animaltrapst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Support: case df::enums::building_type::Support:
{
auto actual = strict_virtual_cast<df::building_supportst>(local_build);
if (actual)
{
remote_build->set_active(actual->support_flags.bits.triggered);
}
break; break;
}
case df::enums::building_type::ArcheryTarget: case df::enums::building_type::ArcheryTarget:
{ {
auto actual = strict_virtual_cast<df::building_archerytargetst>(local_build); auto actual = strict_virtual_cast<df::building_archerytargetst>(local_build);
@ -413,20 +627,62 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
break; break;
} }
} }
}
break; break;
}
case df::enums::building_type::Chain: case df::enums::building_type::Chain:
{
auto actual = strict_virtual_cast<df::building_chainst>(local_build);
if (actual)
{
remote_build->set_active(actual->chain_flags.bits.triggered);
}
break; break;
}
case df::enums::building_type::Cage: case df::enums::building_type::Cage:
{
auto actual = strict_virtual_cast<df::building_cagest>(local_build);
if (actual)
{
remote_build->set_active(actual->cage_flags.bits.triggered);
}
break; break;
}
case df::enums::building_type::Stockpile: case df::enums::building_type::Stockpile:
{
auto actual = strict_virtual_cast<df::building_stockpilest>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Civzone: case df::enums::building_type::Civzone:
{
auto actual = strict_virtual_cast<df::building_civzonest>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Weapon: case df::enums::building_type::Weapon:
{
auto actual = strict_virtual_cast<df::building_weaponst>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::Wagon: case df::enums::building_type::Wagon:
{
auto actual = strict_virtual_cast<df::building_wagonst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::ScrewPump: case df::enums::building_type::ScrewPump:
{ {
auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build); auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build);
@ -450,23 +706,95 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
default: default:
break; break;
} }
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
} }
} }
break; break;
case df::enums::building_type::Construction: case df::enums::building_type::Construction:
{
auto actual = strict_virtual_cast<df::building_constructionst>(local_build);
if (actual)
{
}
break; break;
}
case df::enums::building_type::Hatch: case df::enums::building_type::Hatch:
{
auto actual = strict_virtual_cast<df::building_hatchst>(local_build);
if (actual)
{
if (actual->door_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::GrateWall: case df::enums::building_type::GrateWall:
{
auto actual = strict_virtual_cast<df::building_grate_wallst>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::GrateFloor: case df::enums::building_type::GrateFloor:
{
auto actual = strict_virtual_cast<df::building_grate_floorst>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::BarsVertical: case df::enums::building_type::BarsVertical:
{
auto actual = strict_virtual_cast<df::building_bars_verticalst>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::BarsFloor: case df::enums::building_type::BarsFloor:
{
auto actual = strict_virtual_cast<df::building_bars_floorst>(local_build);
if (actual)
{
if (actual->gate_flags.bits.closed)
remote_build->set_active(1);
else
remote_build->set_active(0);
}
break; break;
}
case df::enums::building_type::GearAssembly: case df::enums::building_type::GearAssembly:
{
auto actual = strict_virtual_cast<df::building_gear_assemblyst>(local_build);
if (actual)
{
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
}
break; break;
}
case df::enums::building_type::AxleHorizontal: case df::enums::building_type::AxleHorizontal:
{ {
auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build); auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build);
@ -476,11 +804,27 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
remote_build->set_direction(NORTH); remote_build->set_direction(NORTH);
else else
remote_build->set_direction(EAST); remote_build->set_direction(EAST);
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
} }
} }
break; break;
case df::enums::building_type::AxleVertical: case df::enums::building_type::AxleVertical:
{
auto actual = strict_virtual_cast<df::building_axle_verticalst>(local_build);
if (actual)
{
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
}
break; break;
}
case df::enums::building_type::WaterWheel: case df::enums::building_type::WaterWheel:
{ {
auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build); auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build);
@ -490,6 +834,11 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
remote_build->set_direction(NORTH); remote_build->set_direction(NORTH);
else else
remote_build->set_direction(EAST); remote_build->set_direction(EAST);
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
} }
} }
break; break;
@ -498,6 +847,7 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
auto actual = strict_virtual_cast<df::building_windmillst>(local_build); auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
if (actual) if (actual)
{ {
#if DF_VERSION_INT > 34011
if (actual->orient_x < 0) if (actual->orient_x < 0)
remote_build->set_direction(WEST); remote_build->set_direction(WEST);
else if (actual->orient_x > 0) else if (actual->orient_x > 0)
@ -507,7 +857,13 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
else if (actual->orient_y > 0) else if (actual->orient_y > 0)
remote_build->set_direction(SOUTH); remote_build->set_direction(SOUTH);
else else
#endif
remote_build->set_direction(WEST); remote_build->set_direction(WEST);
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
} }
} }
break; break;
@ -544,6 +900,11 @@ void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * re
default: default:
break; break;
} }
if (actual->machine.machine_id >= 0)
{
auto mach = df::machine::find(actual->machine.machine_id);
remote_build->set_active(mach->flags.bits.active);
}
} }
} }
break; break;

@ -1,5 +1,6 @@
#ifndef BUILDING_READER_H #ifndef BUILDING_READER_H
#define BUILDING_READER_H #define BUILDING_READER_H
#include <stdint.h>
#include "RemoteClient.h" #include "RemoteClient.h"
#include "RemoteFortressReader.pb.h" #include "RemoteFortressReader.pb.h"

@ -0,0 +1,3 @@
#ifndef DF_VERSION_INT_H
#define DF_VERSION_INT 43005
#endif // !DF_VERSION_INT_H

@ -1,5 +1,5 @@
#define DF_VERSION_INT 42004 #include "df_version_int.h"
#define RFR_VERSION "0.16.1" #define RFR_VERSION "0.17.0"
#include <cstdio> #include <cstdio>
#include <time.h> #include <time.h>
@ -17,10 +17,12 @@
#include "SDL_events.h" #include "SDL_events.h"
#include "SDL_keyboard.h" #include "SDL_keyboard.h"
#include "TileTypes.h" #include "TileTypes.h"
#if DF_VERSION_INT > 34011
#include "DFHackVersion.h" #include "DFHackVersion.h"
#endif
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "modules/Job.h"
#include "modules/MapCache.h" #include "modules/MapCache.h"
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/Materials.h" #include "modules/Materials.h"
@ -28,9 +30,11 @@
#include "modules/Units.h" #include "modules/Units.h"
#include "modules/World.h" #include "modules/World.h"
#if DF_VERSION_INT > 34011
#include "df/army.h" #include "df/army.h"
#include "df/army_flags.h" #include "df/army_flags.h"
#include "df/block_square_event_item_spatterst.h" #include "df/block_square_event_item_spatterst.h"
#endif
#include "df/block_square_event_material_spatterst.h" #include "df/block_square_event_material_spatterst.h"
#include "df/body_appearance_modifier.h" #include "df/body_appearance_modifier.h"
#include "df/body_part_layer_raw.h" #include "df/body_part_layer_raw.h"
@ -74,7 +78,9 @@
#include "df/site_realization_building.h" #include "df/site_realization_building.h"
#include "df/site_realization_building_info_castle_towerst.h" #include "df/site_realization_building_info_castle_towerst.h"
#include "df/site_realization_building_info_castle_wallst.h" #include "df/site_realization_building_info_castle_wallst.h"
#if DF_VERSION_INT > 34011
#include "df/site_realization_building_info_trenchesst.h" #include "df/site_realization_building_info_trenchesst.h"
#endif
#include "df/tissue.h" #include "df/tissue.h"
#include "df/ui.h" #include "df/ui.h"
#include "df/unit.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 GetRegionMaps(color_ostream &stream, const EmptyMessage *in, RegionMaps *out);
static command_result GetRegionMapsNew(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 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 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 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); 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 << 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) << ";"; 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]]; 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"; output << appMod->growth_min << " - " << appMod->growth_max << "\n";
} }
else 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[0] << " - ";
output << casteRaw->bp_appearance.modifiers[casteRaw->bp_appearance.modifier_idx[partIndex]]->ranges[6] << "\n"; 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; 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. // Mandatory init function. If you have some global state, create it here.
DFhackCExport command_result plugin_init(color_ostream &out, std::vector <PluginCommand> &commands) 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" " isoworldremote\n"
" Does nothing.\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; return CR_OK;
} }
@ -243,8 +259,10 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("GetRegionMaps", GetRegionMaps); svc->addFunction("GetRegionMaps", GetRegionMaps);
svc->addFunction("GetRegionMapsNew", GetRegionMapsNew); svc->addFunction("GetRegionMapsNew", GetRegionMapsNew);
svc->addFunction("GetCreatureRaws", GetCreatureRaws); svc->addFunction("GetCreatureRaws", GetCreatureRaws);
svc->addFunction("GetPartialCreatureRaws", GetPartialCreatureRaws);
svc->addFunction("GetWorldMapCenter", GetWorldMapCenter); svc->addFunction("GetWorldMapCenter", GetWorldMapCenter);
svc->addFunction("GetPlantRaws", GetPlantRaws); svc->addFunction("GetPlantRaws", GetPlantRaws);
svc->addFunction("GetPartialPlantRaws", GetPartialPlantRaws);
svc->addFunction("CopyScreen", CopyScreen); svc->addFunction("CopyScreen", CopyScreen);
svc->addFunction("PassKeyboardEvent", PassKeyboardEvent); svc->addFunction("PassKeyboardEvent", PassKeyboardEvent);
svc->addFunction("SendDigCommand", SendDigCommand); svc->addFunction("SendDigCommand", SendDigCommand);
@ -654,9 +672,14 @@ bool IsspatterChanged(DFCoord pos)
df::map_block * block = Maps::getBlock(pos); df::map_block * block = Maps::getBlock(pos);
bool changed = false; bool changed = false;
std::vector<df::block_square_event_material_spatterst *> materials; std::vector<df::block_square_event_material_spatterst *> materials;
#if DF_VERSION_INT > 34011
std::vector<df::block_square_event_item_spatterst *> items; std::vector<df::block_square_event_item_spatterst *> items;
if (!Maps::SortBlockEvents(block, NULL, NULL, &materials, NULL, NULL, NULL, &items)) if (!Maps::SortBlockEvents(block, NULL, NULL, &materials, NULL, NULL, NULL, &items))
return false; return false;
#else
if (!Maps::SortBlockEvents(block, NULL, NULL, &materials, NULL, NULL))
return false;
#endif
uint16_t hash = 0; uint16_t hash = 0;
@ -665,12 +688,14 @@ bool IsspatterChanged(DFCoord pos)
auto mat = materials[i]; auto mat = materials[i];
hash ^= fletcher16((uint8_t*)mat, sizeof(df::block_square_event_material_spatterst)); 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++) for (int i = 0; i < items.size(); i++)
{ {
auto item = items[i]; auto item = items[i];
hash ^= fletcher16((uint8_t*)item, sizeof(df::block_square_event_item_spatterst)); hash ^= fletcher16((uint8_t*)item, sizeof(df::block_square_event_item_spatterst));
} }
if (spatterHashes[pos] != hash) #endif
if (spatterHashes[pos] != hash)
{ {
spatterHashes[pos] = hash; spatterHashes[pos] = hash;
return true; return true;
@ -939,6 +964,7 @@ void CopyBlock(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetBloc
tree_z[xx][yy] = -3000; 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]; 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++) 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; 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++) for (int xx = 0; xx < 16; xx++)
{ {
df::tiletype tile = DfBlock->tiletype[xx][yy]; 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++) for (int xx = 0; xx < 16; xx++)
{ {
df::tile_designation designation = DfBlock->designation[xx][yy]; df::tile_designation designation = DfBlock->designation[xx][yy];
df::tile_occupancy occupancy = DfBlock->occupancy[xx][yy];
int lava = 0; int lava = 0;
int water = 0; int water = 0;
if (designation.bits.liquid_type == df::enums::tile_liquid::Magma) 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]; auto fog_of_war = DfBlock->fog_of_war[xx][yy];
NetBlock->add_hidden(designation.bits.dig == TileDigDesignation::NO_DIG || designation.bits.hidden); 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(TileDigDesignation::NO_DIG);
NetBlock->add_tile_dig_designation_marker(false);
NetBlock->add_tile_dig_designation_auto(false);
} }
else else
{ {
NetBlock->add_hidden(designation.bits.hidden); 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: case df::enums::tile_dig_designation::No:
NetBlock->add_tile_dig_designation(TileDigDesignation::NO_DIG); 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++) for (int i = 0; i < world->job_postings.size(); i++)
{ {
auto job = world->job_postings[i]->job; auto job = world->job_postings[i]->job;
@ -1134,7 +1169,7 @@ void CopyDesignation(df::map_block * DfBlock, RemoteFortressReader::MapBlock * N
break; break;
} }
} }
#endif
} }
void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * NetBlock, MapExtras::MapCache * MC) 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_y(DfBlock->map_pos.y);
NetBlock->set_map_z(DfBlock->map_pos.z); NetBlock->set_map_z(DfBlock->map_pos.z);
std::vector<df::block_square_event_material_spatterst *> materials; std::vector<df::block_square_event_material_spatterst *> materials;
#if DF_VERSION_INT > 34011
std::vector<df::block_square_event_item_spatterst *> items; std::vector<df::block_square_event_item_spatterst *> items;
if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, NULL, NULL, NULL, &items)) if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, NULL, NULL, NULL, &items))
return; return;
#else
if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, NULL, NULL))
return;
#endif
for (int yy = 0; yy < 16; yy++) for (int yy = 0; yy < 16; yy++)
for (int xx = 0; xx < 16; xx++) 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); CopyMat(send_spat->mutable_material(), mat->mat_type, mat->mat_index);
send_spat->set_amount(mat->amount[xx][yy]); send_spat->set_amount(mat->amount[xx][yy]);
} }
#if DF_VERSION_INT > 34011
for (int i = 0; i < items.size(); i++) for (int i = 0; i < items.size(); i++)
{ {
auto item = items[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_type(item->item_type);
send_item->set_mat_index(item->item_subtype); 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); CopyDesignation(block, net_block, &MC, pos);
if (buildingChanged) 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; sentBuildings = true;
} }
if (spatterChanged) if (spatterChanged)
@ -1526,6 +1567,7 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
Gui::getViewCoords(x, y, z); Gui::getViewCoords(x, y, z);
Gui::getCursorCoords(cx, cy, cz); Gui::getCursorCoords(cx, cy, cz);
#if DF_VERSION_INT > 34011
auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
if (embark) 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; z = data->region_map[location.region_pos.x][location.region_pos.y].elevation;
} }
} }
#endif
out->set_view_pos_x(x); out->set_view_pos_x(x);
out->set_view_pos_y(y); out->set_view_pos_y(y);
@ -1573,6 +1616,7 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in,
DFCoord GetMapCenter() DFCoord GetMapCenter()
{ {
DFCoord output; DFCoord output;
#if DF_VERSION_INT > 34011
auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0); auto embark = Gui::getViewscreenByType<df::viewscreen_choose_start_sitest>(0);
if (embark) if (embark)
{ {
@ -1586,12 +1630,15 @@ DFCoord GetMapCenter()
output.z = data->region_map[location.region_pos.x][location.region_pos.y].elevation; 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; int x, y, z;
Maps::getPosition(x,y,z); Maps::getPosition(x,y,z);
output = DFCoord(x, y, z); output = DFCoord(x, y, z);
} }
#if DF_VERSION_INT > 34011
else else
for (int i = 0; i < df::global::world->armies.all.size(); i++) for (int i = 0; i < df::global::world->armies.all.size(); i++)
{ {
@ -1603,6 +1650,7 @@ DFCoord GetMapCenter()
output.z = thisArmy->pos.z; output.z = thisArmy->pos.z;
} }
} }
#endif
return output; 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(Translation::TranslateName(&(data->name), false));
out->set_name_english(Translation::TranslateName(&(data->name), true)); out->set_name_english(Translation::TranslateName(&(data->name), true));
auto poles = data->flip_latitude; auto poles = data->flip_latitude;
#if DF_VERSION_INT > 34011
switch (poles) switch (poles)
{ {
case df::world_data::None: case df::world_data::None:
@ -1663,12 +1712,15 @@ static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in,
case df::world_data::South: case df::world_data::South:
out->set_world_poles(WorldPoles::SOUTH_POLE); out->set_world_poles(WorldPoles::SOUTH_POLE);
break; break;
case df::world_data::Both: case df::world_data::Both:
out->set_world_poles(WorldPoles::BOTH_POLES); out->set_world_poles(WorldPoles::BOTH_POLES);
break; break;
default: default:
break; break;
} }
#else
out->set_world_poles(WorldPoles::NO_POLES);
#endif
for (int yy = 0; yy < height; yy++) for (int yy = 0; yy < height; yy++)
for (int xx = 0; xx < width; xx++) 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_savagery(map_entry->savagery);
out->add_salinity(map_entry->salinity); out->add_salinity(map_entry->salinity);
auto clouds = out->add_clouds(); auto clouds = out->add_clouds();
#if DF_VERSION_INT > 34011
clouds->set_cirrus(map_entry->clouds.bits.cirrus); clouds->set_cirrus(map_entry->clouds.bits.cirrus);
clouds->set_cumulus((RemoteFortressReader::CumulusType)map_entry->clouds.bits.cumulus); clouds->set_cumulus((RemoteFortressReader::CumulusType)map_entry->clouds.bits.cumulus);
clouds->set_fog((RemoteFortressReader::FogType)map_entry->clouds.bits.fog); clouds->set_fog((RemoteFortressReader::FogType)map_entry->clouds.bits.fog);
clouds->set_front((RemoteFortressReader::FrontType)map_entry->clouds.bits.front); clouds->set_front((RemoteFortressReader::FrontType)map_entry->clouds.bits.front);
clouds->set_stratus((RemoteFortressReader::StratusType)map_entry->clouds.bits.stratus); 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) if (region->type == world_region_type::Lake)
{ {
out->add_water_elevation(region->lake_surface); 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); plantMat->set_mat_type(419);
} }
} }
#if DF_VERSION_INT >= 43005
out->set_snow(e1->snowfall); out->set_snow(e1->snowfall);
#endif
} }
static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *in, WorldMap *out) 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_world_height(height);
out->set_name(Translation::TranslateName(&(data->name), false)); out->set_name(Translation::TranslateName(&(data->name), false));
out->set_name_english(Translation::TranslateName(&(data->name), true)); out->set_name_english(Translation::TranslateName(&(data->name), true));
#if DF_VERSION_INT > 34011
auto poles = data->flip_latitude; auto poles = data->flip_latitude;
switch (poles) switch (poles)
{ {
@ -1805,6 +1867,9 @@ static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *
default: default:
break; break;
} }
#else
out->set_world_poles(WorldPoles::NO_POLES);
#endif
for (int yy = 0; yy < height; yy++) for (int yy = 0; yy < height; yy++)
for (int xx = 0; xx < width; xx++) 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); regionTile->set_elevation(map_entry->elevation);
SetRegionTile(regionTile, map_entry); SetRegionTile(regionTile, map_entry);
auto clouds = out->add_clouds(); auto clouds = out->add_clouds();
#if DF_VERSION_INT > 34011
clouds->set_cirrus(map_entry->clouds.bits.cirrus); clouds->set_cirrus(map_entry->clouds.bits.cirrus);
clouds->set_cumulus((RemoteFortressReader::CumulusType)map_entry->clouds.bits.cumulus); clouds->set_cumulus((RemoteFortressReader::CumulusType)map_entry->clouds.bits.cumulus);
clouds->set_fog((RemoteFortressReader::FogType)map_entry->clouds.bits.fog); clouds->set_fog((RemoteFortressReader::FogType)map_entry->clouds.bits.fog);
clouds->set_front((RemoteFortressReader::FrontType)map_entry->clouds.bits.front); clouds->set_front((RemoteFortressReader::FrontType)map_entry->clouds.bits.front);
clouds->set_stratus((RemoteFortressReader::StratusType)map_entry->clouds.bits.stratus); 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(); DFCoord pos = GetMapCenter();
out->set_center_x(pos.x); 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); sprintf(name, "Region %d, %d", pos_x, pos_y);
out->set_name_english(name); out->set_name_english(name);
out->set_name(name); out->set_name(name);
#if DF_VERSION_INT > 34011
auto poles = worldData->flip_latitude; auto poles = worldData->flip_latitude;
switch (poles) switch (poles)
{ {
@ -1933,6 +2006,9 @@ static void CopyLocalMap(df::world_data * worldData, df::world_region_details* w
default: default:
break; break;
} }
#else
out->set_world_poles(WorldPoles::NO_POLES);
#endif
df::world_region_details * south = NULL; df::world_region_details * south = NULL;
df::world_region_details * east = 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(); auto out_building = outputTiles[region_x][region_y]->add_buildings();
out_building->set_id(in_building->id); out_building->set_id(in_building->id);
#if DF_VERSION_INT > 34011
out_building->set_type((SiteRealizationBuildingType)in_building->type); 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_x(in_building->min_x - (site_x * 48));
out_building->set_min_y(in_building->min_y - (site_y * 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)); 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); 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); STRICT_VIRTUAL_CAST_VAR(tower_info, df::site_realization_building_info_castle_towerst, in_building->building_info);
if (tower_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_y(wall_info->end_y - (site_y * 48));
out_wall->set_end_z(wall_info->end_z); 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) 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) if (!df::global::world)
return CR_FAILURE; return CR_FAILURE;
df::world * world = df::global::world; 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]; 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]; auto orig_mod = orig_caste->bp_appearance.modifiers[k];
send_mod->set_type(ENUM_KEY_STR(appearance_modifier_type, orig_mod->type)); send_mod->set_type(ENUM_KEY_STR(appearance_modifier_type, orig_mod->type));
#if DF_VERSION_INT > 34011
if (orig_mod->growth_rate > 0) if (orig_mod->growth_rate > 0)
{ {
send_mod->set_mod_min(orig_mod->growth_min); send_mod->set_mod_min(orig_mod->growth_min);
send_mod->set_mod_max(orig_mod->growth_max); send_mod->set_mod_max(orig_mod->growth_max);
} }
else else
#endif
{ {
send_mod->set_mod_min(orig_mod->ranges[0]); send_mod->set_mod_min(orig_mod->ranges[0]);
send_mod->set_mod_max(orig_mod->ranges[6]); 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)); send_mod->set_type(ENUM_KEY_STR(appearance_modifier_type, orig_mod->type));
#if DF_VERSION_INT > 34011
if (orig_mod->growth_rate > 0) if (orig_mod->growth_rate > 0)
{ {
send_mod->set_mod_min(orig_mod->growth_min); send_mod->set_mod_min(orig_mod->growth_min);
send_mod->set_mod_max(orig_mod->growth_max); send_mod->set_mod_max(orig_mod->growth_max);
} }
else else
#endif
{ {
send_mod->set_mod_min(orig_mod->ranges[0]); send_mod->set_mod_min(orig_mod->ranges[0]);
send_mod->set_mod_max(orig_mod->ranges[6]); 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) 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) if (!df::global::world)
return CR_FAILURE; return CR_FAILURE;
df::world * world = df::global::world; 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++) for (int i = 0; i < world->raws.plants.all.size(); i++)
{ {
df::plant_raw* plant_local = world->raws.plants.all[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); plant_remote->set_tile(plant_local->tiles.shrub_tile);
else else
plant_remote->set_tile(plant_local->tiles.tree_tile); plant_remote->set_tile(plant_local->tiles.tree_tile);
#if DF_VERSION_INT > 34011
for (int j = 0; j < plant_local->growths.size(); j++) for (int j = 0; j < plant_local->growths.size(); j++)
{ {
df::plant_growth* growth_local = plant_local->growths[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); 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); CopyMat(growth_remote->mutable_mat(), growth_local->mat_type, growth_local->mat_index);
} }
#endif
} }
return CR_OK; 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) static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEvent *in)
{ {
#if DF_VERSION_INT > 34011
SDL::Event e; SDL::Event e;
e.key.type = in->type(); e.key.type = in->type();
e.key.state = in->state(); 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.sym = (SDL::Key)in->sym();
e.key.ksym.unicode = in->unicode(); e.key.ksym.unicode = in->unicode();
SDL_PushEvent(&e); SDL_PushEvent(&e);
#endif
return CR_OK; return CR_OK;
} }
@ -2546,8 +2665,46 @@ static command_result SendDigCommand(color_ostream &stream, const DigCommand *in
break; break;
default: default:
break; 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(); 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) command_result GetVersionInfo(color_ostream & stream, const EmptyMessage * in, RemoteFortressReader::VersionInfo * out)
{ {
out->set_dfhack_version(DFHACK_VERSION); 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); out->set_dwarf_fortress_version(DF_VERSION);
#endif
out->set_remote_fortress_reader_version(RFR_VERSION); out->set_remote_fortress_reader_version(RFR_VERSION);
return command_result(); return command_result();
} }