Merge pull request #1154 from JapaMala/master

RemoteFortressReader updates.
develop
Lethosor 2017-08-22 10:48:47 -04:00 committed by GitHub
commit 54b0d2fcb6
3 changed files with 133 additions and 3 deletions

@ -118,6 +118,49 @@ enum TileDigDesignation
UP_STAIR_DIG = 6;
}
enum HairStyle
{
UNKEMPT = -1;
NEATLY_COMBED = 0;
BRAIDED = 1;
DOUBLE_BRAID = 2;
PONY_TAILS = 3;
CLEAN_SHAVEN = 4;
}
enum InventoryMode
{
Hauled = 0;
/**
* also shield, crutch
*/
Weapon = 1;
/**
* quiver
*/
Worn = 2;
Piercing = 3;
/**
* attached to clothing
*/
Flask = 4;
/**
* e.g. bandage
*/
WrappedAround = 5;
StuckIn = 6;
/**
* string descr like Worn
*/
InMouth = 7;
/**
* Left shoulder, right shoulder, or head, selected randomly using pet_seed
*/
Pet = 8;
SewnInto = 9;
Strapped = 10;
}
message Coord
{
optional int32 x = 1;
@ -256,6 +299,7 @@ message MapBlock
repeated Item items = 26;
repeated bool tile_dig_designation_marker = 27;
repeated bool tile_dig_designation_auto = 28;
repeated int32 grass_percent = 29;
}
message MatPair {
@ -297,6 +341,12 @@ message MaterialList{
repeated MaterialDefinition material_list = 1;
}
message Hair
{
optional int32 length = 1;
optional HairStyle style = 2;
}
message BodySizeInfo
{
optional int32 size_cur = 1;
@ -313,6 +363,16 @@ message UnitAppearance
repeated int32 bp_modifiers = 2;
optional int32 size_modifier = 3;
repeated int32 colors = 4;
optional Hair hair = 5;
optional Hair beard = 6;
optional Hair moustache = 7;
optional Hair sideburns = 8;
}
message InventoryItem
{
optional InventoryMode mode = 1;
optional Item item = 2;
}
message UnitDefinition
@ -335,6 +395,8 @@ message UnitDefinition
optional UnitAppearance appearance = 16;
optional int32 profession_id = 17;
repeated string noble_positions = 18;
optional int32 rider_id = 19;
repeated InventoryItem inventory = 20;
}
message UnitList

@ -287,7 +287,7 @@ DFHack::command_result GetBuildingDefList(DFHack::color_ostream &stream, const D
void CopyBuilding(int buildingIndex, RemoteFortressReader::BuildingInstance * remote_build)
{
df::building * local_build = df::global::world->buildings.all[buildingIndex];
remote_build->set_index(buildingIndex);
remote_build->set_index(local_build->id);
int minZ = local_build->z;
if (local_build->getType() == df::enums::building_type::Well)
{

@ -1,5 +1,5 @@
#include "df_version_int.h"
#define RFR_VERSION "0.17.0"
#define RFR_VERSION "0.18.0"
#include <cstdio>
#include <time.h>
@ -34,6 +34,7 @@
#include "df/army.h"
#include "df/army_flags.h"
#include "df/block_square_event_item_spatterst.h"
#include "df/block_square_event_grassst.h"
#endif
#include "df/block_square_event_material_spatterst.h"
#include "df/body_appearance_modifier.h"
@ -82,8 +83,10 @@
#include "df/site_realization_building_info_trenchesst.h"
#endif
#include "df/tissue.h"
#include "df/tissue_style_raw.h"
#include "df/ui.h"
#include "df/unit.h"
#include "df/unit_inventory_item.h"
#include "df/viewscreen_choose_start_sitest.h"
#include "df/world.h"
#include "df/world_data.h"
@ -104,6 +107,8 @@
#include "df/plant_tree_tile.h"
#endif
#include "df/unit_relationship_type.h"
#include "building_reader.h"
using namespace DFHack;
@ -1179,7 +1184,11 @@ void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * Ne
{
df::building * bld = df::global::world->buildings.all[i];
if (bld->x1 >= max.x || bld->y1 >= max.y || bld->x2 < min.x || bld->y2 < min.y)
{
auto out_bld = NetBlock->add_buildings();
out_bld->set_index(bld->id);
continue;
}
int z2 = bld->z;
@ -1192,7 +1201,11 @@ void CopyBuildings(DFCoord min, DFCoord max, RemoteFortressReader::MapBlock * Ne
}
}
if (bld->z < min.z || z2 >= max.z)
{
auto out_bld = NetBlock->add_buildings();
out_bld->set_index(bld->id);
continue;
}
auto out_bld = NetBlock->add_buildings();
CopyBuilding(i, out_bld);
df::building_actual* actualBuilding = virtual_cast<df::building_actual>(bld);
@ -1216,7 +1229,8 @@ void Copyspatters(df::map_block * DfBlock, RemoteFortressReader::MapBlock * NetB
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))
std::vector<df::block_square_event_grassst *> grasses;
if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, &grasses, NULL, NULL, &items))
return;
#else
if (!Maps::SortBlockEvents(DfBlock, NULL, NULL, &materials, NULL, NULL))
@ -1249,6 +1263,14 @@ 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);
}
int grassPercent = 0;
for (int i = 0; i < grasses.size(); i++)
{
auto grass = grasses[i];
if (grass->amount[xx][yy] > grassPercent)
grassPercent = grass->amount[xx][yy];
}
NetBlock->add_grass_percent(grassPercent);
#endif
}
}
@ -1556,6 +1578,52 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in,
send_unit->add_noble_positions(noble_positon.position->code);
}
}
send_unit->set_rider_id(unit->relationship_ids[df::unit_relationship_type::RiderMount]);
auto creatureRaw = world->raws.creatures.all[unit->race];
auto casteRaw = creatureRaw->caste[unit->caste];
for (int j = 0; j < unit->appearance.tissue_style_type.size(); j++)
{
auto type = unit->appearance.tissue_style_type[j];
if (type < 0)
continue;
int style_raw_index = binsearch_index(casteRaw->tissue_styles, &df::tissue_style_raw::id, type);
auto styleRaw = casteRaw->tissue_styles[style_raw_index];
if (styleRaw->token == "HAIR")
{
auto send_style = appearance->mutable_hair();
send_style->set_length(unit->appearance.tissue_length[j]);
send_style->set_style((HairStyle)unit->appearance.tissue_style[j]);
}
else if (styleRaw->token == "BEARD")
{
auto send_style = appearance->mutable_beard();
send_style->set_length(unit->appearance.tissue_length[j]);
send_style->set_style((HairStyle)unit->appearance.tissue_style[j]);
}
else if (styleRaw->token == "MOUSTACHE")
{
auto send_style = appearance->mutable_moustache();
send_style->set_length(unit->appearance.tissue_length[j]);
send_style->set_style((HairStyle)unit->appearance.tissue_style[j]);
}
else if (styleRaw->token == "SIDEBURNS")
{
auto send_style = appearance->mutable_sideburns();
send_style->set_length(unit->appearance.tissue_length[j]);
send_style->set_style((HairStyle)unit->appearance.tissue_style[j]);
}
}
for (int j = 0; j < unit->inventory.size(); j++)
{
auto inventory_item = unit->inventory[j];
auto sent_item = send_unit->add_inventory();
sent_item->set_mode((InventoryMode)inventory_item->mode);
CopyItem(sent_item->mutable_item(), inventory_item->item);
}
}
return CR_OK;
}