Merge branch 'develop' of dfhack/dfhack into develop

develop
lethosor 2017-03-30 23:55:45 -04:00
commit 155084f32f
5 changed files with 590 additions and 530 deletions

@ -150,6 +150,12 @@ message BuildingExtents
repeated int32 extents = 5;
}
message BuildingItem
{
optional Item item = 1;
optional int32 mode = 2;
}
message BuildingInstance
{
required int32 index = 1;
@ -165,6 +171,7 @@ message BuildingInstance
optional bool is_room = 11;
optional BuildingExtents room = 12;
optional BuildingDirection direction = 13; //Doesn't mean anything for most buildings
repeated BuildingItem items = 14;
}
message RiverEdge
@ -757,3 +764,10 @@ message SingleBool
{
optional bool Value = 1;
}
message VersionInfo
{
optional string dwarf_fortress_version = 1;
optional string dfhack_version = 2;
optional string remote_fortress_reader_version = 3;
}

@ -2,10 +2,11 @@ PROJECT (remotefortressreader)
# A list of source files
SET(PROJECT_SRCS
remotefortressreader.cpp
building_reader.cpp
)
# A list of headers
SET(PROJECT_HDRS
building_reader.h
)
#proto files to include.
SET(PROJECT_PROTO

@ -0,0 +1,529 @@
#include "building_reader.h"
#include "DataDefs.h"
#include "df/building_axle_horizontalst.h"
#include "df/building_bridgest.h"
#include "df/building_def_furnacest.h"
#include "df/building_def_workshopst.h"
#include "df/building_rollersst.h"
#include "df/building_screw_pumpst.h"
#include "df/building_siegeenginest.h"
#include "df/building_water_wheelst.h"
#include "df/building_wellst.h"
#include "df/building_windmillst.h"
#include "df/world.h"
#include "modules/Buildings.h"
using namespace DFHack;
using namespace df::enums;
using namespace RemoteFortressReader;
using namespace std;
DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const DFHack::EmptyMessage *in, RemoteFortressReader::BuildingList *out)
{
FOR_ENUM_ITEMS(building_type, bt)
{
BuildingDefinition * bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(-1);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt));
switch (bt)
{
case df::enums::building_type::NONE:
break;
case df::enums::building_type::Chair:
break;
case df::enums::building_type::Bed:
break;
case df::enums::building_type::Table:
break;
case df::enums::building_type::Coffin:
break;
case df::enums::building_type::FarmPlot:
break;
case df::enums::building_type::Furnace:
FOR_ENUM_ITEMS(furnace_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(furnace_type, st));
if (st == furnace_type::Custom)
{
for (int i = 0; i < df::global::world->raws.buildings.furnaces.size(); i++)
{
auto cust = df::global::world->raws.buildings.furnaces[i];
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(cust->id);
bld->set_id(cust->code);
bld->set_name(cust->name);
}
}
}
break;
case df::enums::building_type::TradeDepot:
break;
case df::enums::building_type::Shop:
FOR_ENUM_ITEMS(shop_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(shop_type, st));
}
break;
case df::enums::building_type::Door:
break;
case df::enums::building_type::Floodgate:
break;
case df::enums::building_type::Box:
break;
case df::enums::building_type::Weaponrack:
break;
case df::enums::building_type::Armorstand:
break;
case df::enums::building_type::Workshop:
FOR_ENUM_ITEMS(workshop_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(workshop_type, st));
if (st == workshop_type::Custom)
{
for (int i = 0; i < df::global::world->raws.buildings.workshops.size(); i++)
{
auto cust = df::global::world->raws.buildings.workshops[i];
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(cust->id);
bld->set_id(cust->code);
bld->set_name(cust->name);
}
}
}
break;
case df::enums::building_type::Cabinet:
break;
case df::enums::building_type::Statue:
break;
case df::enums::building_type::WindowGlass:
break;
case df::enums::building_type::WindowGem:
break;
case df::enums::building_type::Well:
break;
case df::enums::building_type::Bridge:
break;
case df::enums::building_type::RoadDirt:
break;
case df::enums::building_type::RoadPaved:
break;
case df::enums::building_type::SiegeEngine:
FOR_ENUM_ITEMS(siegeengine_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(siegeengine_type, st));
}
break;
case df::enums::building_type::Trap:
FOR_ENUM_ITEMS(trap_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(trap_type, st));
}
break;
case df::enums::building_type::AnimalTrap:
break;
case df::enums::building_type::Support:
break;
case df::enums::building_type::ArcheryTarget:
break;
case df::enums::building_type::Chain:
break;
case df::enums::building_type::Cage:
break;
case df::enums::building_type::Stockpile:
break;
case df::enums::building_type::Civzone:
FOR_ENUM_ITEMS(civzone_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(civzone_type, st));
}
break;
case df::enums::building_type::Weapon:
break;
case df::enums::building_type::Wagon:
break;
case df::enums::building_type::ScrewPump:
break;
case df::enums::building_type::Construction:
FOR_ENUM_ITEMS(construction_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(construction_type, st));
}
break;
case df::enums::building_type::Hatch:
break;
case df::enums::building_type::GrateWall:
break;
case df::enums::building_type::GrateFloor:
break;
case df::enums::building_type::BarsVertical:
break;
case df::enums::building_type::BarsFloor:
break;
case df::enums::building_type::GearAssembly:
break;
case df::enums::building_type::AxleHorizontal:
break;
case df::enums::building_type::AxleVertical:
break;
case df::enums::building_type::WaterWheel:
break;
case df::enums::building_type::Windmill:
break;
case df::enums::building_type::TractionBench:
break;
case df::enums::building_type::Slab:
break;
case df::enums::building_type::Nest:
break;
case df::enums::building_type::NestBox:
break;
case df::enums::building_type::Hive:
break;
case df::enums::building_type::Rollers:
break;
default:
break;
}
}
return CR_OK;
}
void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * remote_build)
{
df::building * local_build = df::global::world->buildings.all[buildingIndex];
remote_build->set_index(buildingIndex);
int minZ = local_build->z;
if (local_build->getType() == df::enums::building_type::Well)
{
df::building_wellst * well_building = virtual_cast<df::building_wellst>(local_build);
if (well_building)
minZ = well_building->bucket_z;
}
remote_build->set_pos_x_min(local_build->x1);
remote_build->set_pos_y_min(local_build->y1);
remote_build->set_pos_z_min(minZ);
remote_build->set_pos_x_max(local_build->x2);
remote_build->set_pos_y_max(local_build->y2);
remote_build->set_pos_z_max(local_build->z);
auto buildingType = remote_build->mutable_building_type();
auto type = local_build->getType();
buildingType->set_building_type(type);
buildingType->set_building_subtype(local_build->getSubtype());
buildingType->set_building_custom(local_build->getCustomType());
auto material = remote_build->mutable_material();
material->set_mat_type(local_build->mat_type);
material->set_mat_index(local_build->mat_index);
remote_build->set_building_flags(local_build->flags.whole);
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)
{
auto room = remote_build->mutable_room();
room->set_pos_x(local_build->room.x);
room->set_pos_y(local_build->room.y);
room->set_width(local_build->room.width);
room->set_height(local_build->room.height);
for (int i = 0; i < (local_build->room.width * local_build->room.height); i++)
{
room->add_extents(local_build->room.extents[i]);
}
}
switch (type)
{
case df::enums::building_type::NONE:
break;
case df::enums::building_type::Chair:
break;
case df::enums::building_type::Bed:
break;
case df::enums::building_type::Table:
break;
case df::enums::building_type::Coffin:
break;
case df::enums::building_type::FarmPlot:
break;
case df::enums::building_type::Furnace:
break;
case df::enums::building_type::TradeDepot:
break;
case df::enums::building_type::Shop:
break;
case df::enums::building_type::Door:
break;
case df::enums::building_type::Floodgate:
break;
case df::enums::building_type::Box:
break;
case df::enums::building_type::Weaponrack:
break;
case df::enums::building_type::Armorstand:
break;
case df::enums::building_type::Workshop:
break;
case df::enums::building_type::Cabinet:
break;
case df::enums::building_type::Statue:
break;
case df::enums::building_type::WindowGlass:
break;
case df::enums::building_type::WindowGem:
break;
case df::enums::building_type::Well:
break;
case df::enums::building_type::Bridge:
{
auto actual = strict_virtual_cast<df::building_bridgest>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::building_bridgest::Retracting:
break;
case df::building_bridgest::Left:
remote_build->set_direction(WEST);
break;
case df::building_bridgest::Right:
remote_build->set_direction(EAST);
break;
case df::building_bridgest::Up:
remote_build->set_direction(NORTH);
break;
case df::building_bridgest::Down:
remote_build->set_direction(SOUTH);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::RoadDirt:
break;
case df::enums::building_type::RoadPaved:
break;
case df::enums::building_type::SiegeEngine:
{
auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build);
if (actual)
{
auto facing = actual->facing;
switch (facing)
{
case df::building_siegeenginest::Left:
remote_build->set_direction(WEST);
break;
case df::building_siegeenginest::Up:
remote_build->set_direction(NORTH);
break;
case df::building_siegeenginest::Right:
remote_build->set_direction(EAST);
break;
case df::building_siegeenginest::Down:
remote_build->set_direction(SOUTH);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::Trap:
break;
case df::enums::building_type::AnimalTrap:
break;
case df::enums::building_type::Support:
break;
case df::enums::building_type::ArcheryTarget:
break;
case df::enums::building_type::Chain:
break;
case df::enums::building_type::Cage:
break;
case df::enums::building_type::Stockpile:
break;
case df::enums::building_type::Civzone:
break;
case df::enums::building_type::Weapon:
break;
case df::enums::building_type::Wagon:
break;
case df::enums::building_type::ScrewPump:
{
auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::Construction:
break;
case df::enums::building_type::Hatch:
break;
case df::enums::building_type::GrateWall:
break;
case df::enums::building_type::GrateFloor:
break;
case df::enums::building_type::BarsVertical:
break;
case df::enums::building_type::BarsFloor:
break;
case df::enums::building_type::GearAssembly:
break;
case df::enums::building_type::AxleHorizontal:
{
auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build);
if (actual)
{
if (actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
}
break;
case df::enums::building_type::AxleVertical:
break;
case df::enums::building_type::WaterWheel:
{
auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build);
if (actual)
{
if (actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
}
break;
case df::enums::building_type::Windmill:
{
auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
if (actual)
{
if (actual->orient_x < 0)
remote_build->set_direction(WEST);
else if (actual->orient_x > 0)
remote_build->set_direction(EAST);
else if (actual->orient_y < 0)
remote_build->set_direction(NORTH);
else if (actual->orient_y > 0)
remote_build->set_direction(SOUTH);
else
remote_build->set_direction(WEST);
}
}
break;
case df::enums::building_type::TractionBench:
break;
case df::enums::building_type::Slab:
break;
case df::enums::building_type::Nest:
break;
case df::enums::building_type::NestBox:
break;
case df::enums::building_type::Hive:
break;
case df::enums::building_type::Rollers:
{
auto actual = strict_virtual_cast<df::building_rollersst>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
}
break;
default:
break;
}
}

@ -0,0 +1,9 @@
#ifndef BUILDING_READER_H
#define BUILDING_READER_H
#include "RemoteClient.h"
#include "RemoteFortressReader.pb.h"
DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const DFHack::EmptyMessage *in, RemoteFortressReader::BuildingList *out);
void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * remote_build);
#endif

@ -1,4 +1,5 @@
#define DF_VERSION 42004
#define DF_VERSION_INT 42004
#define RFR_VERSION "0.16.1"
#include <cstdio>
#include <time.h>
@ -16,8 +17,8 @@
#include "SDL_events.h"
#include "SDL_keyboard.h"
#include "TileTypes.h"
#include "DFHackVersion.h"
#include "modules/Buildings.h"
#include "modules/Gui.h"
#include "modules/Items.h"
#include "modules/MapCache.h"
@ -35,17 +36,9 @@
#include "df/body_part_layer_raw.h"
#include "df/body_part_raw.h"
#include "df/bp_appearance_modifier.h"
#include "df/building_axle_horizontalst.h"
#include "df/building_bridgest.h"
#include "df/building_def_furnacest.h"
#include "df/building_def_workshopst.h"
#include "df/building_rollersst.h"
#include "df/building_screw_pumpst.h"
#include "df/building_siegeenginest.h"
#include "df/building_water_wheelst.h"
#include "df/building_wellst.h"
#include "df/building_windmillst.h"
#include "df/builtin_mats.h"
#include "df/building_wellst.h"
#include "df/caste_raw.h"
#include "df/caste_raw.h"
#include "df/color_modifier_raw.h"
@ -98,13 +91,15 @@
#include "df/world_site_realization.h"
#include "df/entity_position.h"
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
#include "df/plant_growth.h"
#include "df/plant_growth_print.h"
#include "df/plant_tree_info.h"
#include "df/plant_tree_tile.h"
#endif
#include "building_reader.h"
using namespace DFHack;
using namespace df::enums;
using namespace RemoteFortressReader;
@ -135,7 +130,6 @@ static command_result GetViewInfo(color_ostream &stream, const EmptyMessage *in,
static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in, MapInfo *out);
static command_result ResetMapHashes(color_ostream &stream, const EmptyMessage *in);
static command_result GetItemList(color_ostream &stream, const EmptyMessage *in, MaterialList *out);
static command_result GetBuildingDefList(color_ostream &stream, const EmptyMessage *in, BuildingList *out);
static command_result GetWorldMap(color_ostream &stream, const EmptyMessage *in, WorldMap *out);
static command_result GetWorldMapNew(color_ostream &stream, const EmptyMessage *in, WorldMap *out);
static command_result GetWorldMapCenter(color_ostream &stream, const EmptyMessage *in, WorldMap *out);
@ -148,6 +142,7 @@ static command_result PassKeyboardEvent(color_ostream &stream, const KeyboardEve
static command_result SendDigCommand(color_ostream &stream, const DigCommand *in);
static command_result SetPauseState(color_ostream & stream, const SingleBool * in);
static command_result GetPauseState(color_ostream & stream, const EmptyMessage * in, SingleBool * out);
static command_result GetVersionInfo(color_ostream & stream, const EmptyMessage * in, RemoteFortressReader::VersionInfo * out);
void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem);
@ -255,6 +250,7 @@ DFhackCExport RPCService *plugin_rpcconnect(color_ostream &)
svc->addFunction("SendDigCommand", SendDigCommand);
svc->addFunction("SetPauseState", SetPauseState);
svc->addFunction("GetPauseState", GetPauseState);
svc->addFunction("GetVersionInfo", GetVersionInfo);
return svc;
}
@ -312,296 +308,6 @@ void ConvertDFColorDescriptor(int16_t index, RemoteFortressReader::ColorDefiniti
out->set_blue(color->blue * 255);
}
void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * remote_build)
{
df::building * local_build = df::global::world->buildings.all[buildingIndex];
remote_build->set_index(buildingIndex);
int minZ = local_build->z;
if (local_build->getType() == df::enums::building_type::Well)
{
df::building_wellst * well_building = virtual_cast<df::building_wellst>(local_build);
if (well_building)
minZ = well_building->bucket_z;
}
remote_build->set_pos_x_min(local_build->x1);
remote_build->set_pos_y_min(local_build->y1);
remote_build->set_pos_z_min(minZ);
remote_build->set_pos_x_max(local_build->x2);
remote_build->set_pos_y_max(local_build->y2);
remote_build->set_pos_z_max(local_build->z);
auto buildingType = remote_build->mutable_building_type();
auto type = local_build->getType();
buildingType->set_building_type(type);
buildingType->set_building_subtype(local_build->getSubtype());
buildingType->set_building_custom(local_build->getCustomType());
auto material = remote_build->mutable_material();
material->set_mat_type(local_build->mat_type);
material->set_mat_index(local_build->mat_index);
remote_build->set_building_flags(local_build->flags.whole);
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)
{
auto room = remote_build->mutable_room();
room->set_pos_x(local_build->room.x);
room->set_pos_y(local_build->room.y);
room->set_width(local_build->room.width);
room->set_height(local_build->room.height);
for (int i = 0; i < (local_build->room.width * local_build->room.height); i++)
{
room->add_extents(local_build->room.extents[i]);
}
}
switch (type)
{
case df::enums::building_type::NONE:
break;
case df::enums::building_type::Chair:
break;
case df::enums::building_type::Bed:
break;
case df::enums::building_type::Table:
break;
case df::enums::building_type::Coffin:
break;
case df::enums::building_type::FarmPlot:
break;
case df::enums::building_type::Furnace:
break;
case df::enums::building_type::TradeDepot:
break;
case df::enums::building_type::Shop:
break;
case df::enums::building_type::Door:
break;
case df::enums::building_type::Floodgate:
break;
case df::enums::building_type::Box:
break;
case df::enums::building_type::Weaponrack:
break;
case df::enums::building_type::Armorstand:
break;
case df::enums::building_type::Workshop:
break;
case df::enums::building_type::Cabinet:
break;
case df::enums::building_type::Statue:
break;
case df::enums::building_type::WindowGlass:
break;
case df::enums::building_type::WindowGem:
break;
case df::enums::building_type::Well:
break;
case df::enums::building_type::Bridge:
{
auto actual = strict_virtual_cast<df::building_bridgest>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::building_bridgest::Retracting:
break;
case df::building_bridgest::Left:
remote_build->set_direction(WEST);
break;
case df::building_bridgest::Right:
remote_build->set_direction(EAST);
break;
case df::building_bridgest::Up:
remote_build->set_direction(NORTH);
break;
case df::building_bridgest::Down:
remote_build->set_direction(SOUTH);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::RoadDirt:
break;
case df::enums::building_type::RoadPaved:
break;
case df::enums::building_type::SiegeEngine:
{
auto actual = strict_virtual_cast<df::building_siegeenginest>(local_build);
if (actual)
{
auto facing = actual->facing;
switch (facing)
{
case df::building_siegeenginest::Left:
remote_build->set_direction(WEST);
break;
case df::building_siegeenginest::Up:
remote_build->set_direction(NORTH);
break;
case df::building_siegeenginest::Right:
remote_build->set_direction(EAST);
break;
case df::building_siegeenginest::Down:
remote_build->set_direction(SOUTH);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::Trap:
break;
case df::enums::building_type::AnimalTrap:
break;
case df::enums::building_type::Support:
break;
case df::enums::building_type::ArcheryTarget:
break;
case df::enums::building_type::Chain:
break;
case df::enums::building_type::Cage:
break;
case df::enums::building_type::Stockpile:
break;
case df::enums::building_type::Civzone:
break;
case df::enums::building_type::Weapon:
break;
case df::enums::building_type::Wagon:
break;
case df::enums::building_type::ScrewPump:
{
auto actual = strict_virtual_cast<df::building_screw_pumpst>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
}
break;
case df::enums::building_type::Construction:
break;
case df::enums::building_type::Hatch:
break;
case df::enums::building_type::GrateWall:
break;
case df::enums::building_type::GrateFloor:
break;
case df::enums::building_type::BarsVertical:
break;
case df::enums::building_type::BarsFloor:
break;
case df::enums::building_type::GearAssembly:
break;
case df::enums::building_type::AxleHorizontal:
{
auto actual = strict_virtual_cast<df::building_axle_horizontalst>(local_build);
if (actual)
{
if(actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
}
break;
case df::enums::building_type::AxleVertical:
break;
case df::enums::building_type::WaterWheel:
{
auto actual = strict_virtual_cast<df::building_water_wheelst>(local_build);
if (actual)
{
if (actual->is_vertical)
remote_build->set_direction(NORTH);
else
remote_build->set_direction(EAST);
}
}
break;
case df::enums::building_type::Windmill:
{
auto actual = strict_virtual_cast<df::building_windmillst>(local_build);
if (actual)
{
if (actual->orient_x < 0)
remote_build->set_direction(WEST);
else if (actual->orient_x > 0)
remote_build->set_direction(EAST);
else if (actual->orient_y < 0)
remote_build->set_direction(NORTH);
else if (actual->orient_y > 0)
remote_build->set_direction(SOUTH);
else
remote_build->set_direction(WEST);
}
}
break;
case df::enums::building_type::TractionBench:
break;
case df::enums::building_type::Slab:
break;
case df::enums::building_type::Nest:
break;
case df::enums::building_type::NestBox:
break;
case df::enums::building_type::Hive:
break;
case df::enums::building_type::Rollers:
{
auto actual = strict_virtual_cast<df::building_rollersst>(local_build);
if (actual)
{
auto direction = actual->direction;
switch (direction)
{
case df::enums::screw_pump_direction::FromNorth:
remote_build->set_direction(NORTH);
break;
case df::enums::screw_pump_direction::FromEast:
remote_build->set_direction(EAST);
break;
case df::enums::screw_pump_direction::FromSouth:
remote_build->set_direction(SOUTH);
break;
case df::enums::screw_pump_direction::FromWest:
remote_build->set_direction(WEST);
break;
default:
break;
}
}
}
break;
default:
break;
}
}
RemoteFortressReader::TiletypeMaterial TranslateMaterial(df::tiletype_material material)
{
switch (material)
@ -675,7 +381,7 @@ RemoteFortressReader::TiletypeMaterial TranslateMaterial(df::tiletype_material m
case df::enums::tiletype_material::RIVER:
return RemoteFortressReader::RIVER;
break;
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
case df::enums::tiletype_material::ROOT:
return RemoteFortressReader::ROOT;
break;
@ -736,7 +442,7 @@ RemoteFortressReader::TiletypeSpecial TranslateSpecial(df::tiletype_special spec
case df::enums::tiletype_special::TRACK:
return RemoteFortressReader::TRACK;
break;
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
case df::enums::tiletype_special::SMOOTH_DEAD:
return RemoteFortressReader::SMOOTH_DEAD;
break;
@ -794,17 +500,17 @@ RemoteFortressReader::TiletypeShape TranslateShape(df::tiletype_shape shape)
case df::enums::tiletype_shape::BROOK_TOP:
return RemoteFortressReader::BROOK_TOP;
break;
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
case df::enums::tiletype_shape::BRANCH:
return RemoteFortressReader::BRANCH;
break;
#endif
#if DF_VERSION < 40001
#if DF_VERSION_INT < 40001
case df::enums::tiletype_shape::TREE:
return RemoteFortressReader::TREE_SHAPE;
break;
#endif
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
case df::enums::tiletype_shape::TRUNK_BRANCH:
return RemoteFortressReader::TRUNK_BRANCH;
@ -1196,7 +902,7 @@ static command_result GetGrowthList(color_ostream &stream, const EmptyMessage *i
basePlant->set_name(pp->name);
basePlant->mutable_mat_pair()->set_mat_type(-1);
basePlant->mutable_mat_pair()->set_mat_index(i);
#if DF_VERSION > 40001
#if DF_VERSION_INT > 40001
for (int g = 0; g < pp->growths.size(); g++)
{
df::plant_growth* growth = pp->growths[g];
@ -1464,14 +1170,21 @@ void CopyBuildings(df::map_block * DfBlock, RemoteFortressReader::MapBlock * Net
continue;
auto out_bld = NetBlock->add_buildings();
CopyBuilding(i, out_bld);
df::building_actual* actualBuilding = strict_virtual_cast<df::building_actual>(bld);
df::building_actual* actualBuilding = virtual_cast<df::building_actual>(bld);
if (actualBuilding)
{
for (int i = 0; i < actualBuilding->contained_items.size(); i++)
{
if (isItemChanged(actualBuilding->contained_items[i]->item->id))
if (actualBuilding->contained_items[i]->use_mode == 0)
{
CopyItem(NetBlock->add_items(), actualBuilding->contained_items[i]->item);
if (isItemChanged(actualBuilding->contained_items[i]->item->id))
CopyItem(NetBlock->add_items(), actualBuilding->contained_items[i]->item);
}
else
{
auto buildingItem = out_bld->add_items();
buildingItem->set_mode(actualBuilding->contained_items[i]->use_mode);
CopyItem(buildingItem->mutable_item(), actualBuilding->contained_items[i]->item);
}
}
}
@ -1722,7 +1435,7 @@ static command_result GetPlantList(color_ostream &stream, const BlockRequest *in
int max_y = in->max_y() / 3;
int max_z = in->max_z();
#if DF_VERSION < 40001
#if DF_VERSION_INT < 40001
//plants are gotten differently here
#else
for (int xx = min_x; xx < max_x; xx++)
@ -1869,220 +1582,6 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in,
return CR_OK;
}
static command_result GetBuildingDefList(color_ostream &stream, const EmptyMessage *in, BuildingList *out)
{
FOR_ENUM_ITEMS(building_type, bt)
{
BuildingDefinition * bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(-1);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt));
switch (bt)
{
case df::enums::building_type::NONE:
break;
case df::enums::building_type::Chair:
break;
case df::enums::building_type::Bed:
break;
case df::enums::building_type::Table:
break;
case df::enums::building_type::Coffin:
break;
case df::enums::building_type::FarmPlot:
break;
case df::enums::building_type::Furnace:
FOR_ENUM_ITEMS(furnace_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(furnace_type, st));
if (st == furnace_type::Custom)
{
for (int i = 0; i < world->raws.buildings.furnaces.size(); i++)
{
auto cust = world->raws.buildings.furnaces[i];
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(cust->id);
bld->set_id(cust->code);
bld->set_name(cust->name);
}
}
}
break;
case df::enums::building_type::TradeDepot:
break;
case df::enums::building_type::Shop:
FOR_ENUM_ITEMS(shop_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(shop_type, st));
}
break;
case df::enums::building_type::Door:
break;
case df::enums::building_type::Floodgate:
break;
case df::enums::building_type::Box:
break;
case df::enums::building_type::Weaponrack:
break;
case df::enums::building_type::Armorstand:
break;
case df::enums::building_type::Workshop:
FOR_ENUM_ITEMS(workshop_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(workshop_type, st));
if (st == workshop_type::Custom)
{
for (int i = 0; i < world->raws.buildings.workshops.size(); i++)
{
auto cust = world->raws.buildings.workshops[i];
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(cust->id);
bld->set_id(cust->code);
bld->set_name(cust->name);
}
}
}
break;
case df::enums::building_type::Cabinet:
break;
case df::enums::building_type::Statue:
break;
case df::enums::building_type::WindowGlass:
break;
case df::enums::building_type::WindowGem:
break;
case df::enums::building_type::Well:
break;
case df::enums::building_type::Bridge:
break;
case df::enums::building_type::RoadDirt:
break;
case df::enums::building_type::RoadPaved:
break;
case df::enums::building_type::SiegeEngine:
FOR_ENUM_ITEMS(siegeengine_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(siegeengine_type, st));
}
break;
case df::enums::building_type::Trap:
FOR_ENUM_ITEMS(trap_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(trap_type, st));
}
break;
case df::enums::building_type::AnimalTrap:
break;
case df::enums::building_type::Support:
break;
case df::enums::building_type::ArcheryTarget:
break;
case df::enums::building_type::Chain:
break;
case df::enums::building_type::Cage:
break;
case df::enums::building_type::Stockpile:
break;
case df::enums::building_type::Civzone:
FOR_ENUM_ITEMS(civzone_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(civzone_type, st));
}
break;
case df::enums::building_type::Weapon:
break;
case df::enums::building_type::Wagon:
break;
case df::enums::building_type::ScrewPump:
break;
case df::enums::building_type::Construction:
FOR_ENUM_ITEMS(construction_type, st)
{
bld = out->add_building_list();
bld->mutable_building_type()->set_building_type(bt);
bld->mutable_building_type()->set_building_subtype(st);
bld->mutable_building_type()->set_building_custom(-1);
bld->set_id(ENUM_KEY_STR(building_type, bt) + "_" + ENUM_KEY_STR(construction_type, st));
}
break;
case df::enums::building_type::Hatch:
break;
case df::enums::building_type::GrateWall:
break;
case df::enums::building_type::GrateFloor:
break;
case df::enums::building_type::BarsVertical:
break;
case df::enums::building_type::BarsFloor:
break;
case df::enums::building_type::GearAssembly:
break;
case df::enums::building_type::AxleHorizontal:
break;
case df::enums::building_type::AxleVertical:
break;
case df::enums::building_type::WaterWheel:
break;
case df::enums::building_type::Windmill:
break;
case df::enums::building_type::TractionBench:
break;
case df::enums::building_type::Slab:
break;
case df::enums::building_type::Nest:
break;
case df::enums::building_type::NestBox:
break;
case df::enums::building_type::Hive:
break;
case df::enums::building_type::Rollers:
break;
default:
break;
}
}
return CR_OK;
}
DFCoord GetMapCenter()
{
DFCoord output;
@ -3077,4 +2576,12 @@ static command_result GetPauseState(color_ostream &stream, const EmptyMessage *i
{
out->set_value(World::ReadPauseState());
return CR_OK;
}
}
command_result GetVersionInfo(color_ostream & stream, const EmptyMessage * in, RemoteFortressReader::VersionInfo * out)
{
out->set_dfhack_version(DFHACK_VERSION);
out->set_dwarf_fortress_version(DF_VERSION);
out->set_remote_fortress_reader_version(RFR_VERSION);
return command_result();
}