Skip to content

Commit

Permalink
Send Unit inventories with RFR
Browse files Browse the repository at this point in the history
  • Loading branch information
RosaryMala committed Aug 19, 2017
1 parent 737aefe commit 8e71cf9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
40 changes: 40 additions & 0 deletions plugins/proto/RemoteFortressReader.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions plugins/remotefortressreader/remotefortressreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 8e71cf9

Please sign in to comment.