Send Unit inventories with RFR

develop
Japa 2017-08-19 17:48:18 +05:30
parent 737aefefea
commit 8e71cf9def
2 changed files with 49 additions and 0 deletions

@ -128,6 +128,39 @@ enum HairStyle
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;
@ -336,6 +369,12 @@ message UnitAppearance
optional Hair sideburns = 8;
}
message InventoryItem
{
optional InventoryMode mode = 1;
optional Item item = 2;
}
message UnitDefinition
{
required int32 id = 1;
@ -357,6 +396,7 @@ message UnitDefinition
optional int32 profession_id = 17;
repeated string noble_positions = 18;
optional int32 rider_id = 19;
repeated InventoryItem inventory = 20;
}
message UnitList

@ -86,6 +86,7 @@
#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"
@ -1615,6 +1616,14 @@ static command_result GetUnitList(color_ostream &stream, const EmptyMessage *in,
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;
}