Add ListJobSkills.

develop
Will Rogers 2012-04-03 14:03:06 -04:00
parent 467f4108ae
commit 59d7b6faab
4 changed files with 42 additions and 0 deletions

@ -338,6 +338,21 @@ void DFHack::describeUnit(BasicUnitInfo *info, df::unit *unit,
info->add_burrows(unit->burrows[i]);
}
void DFHack::describeJobSkills(RepeatedPtrField<JobSkillInfo> *pf)
{
FOR_ENUM_ITEMS(job_skill, skill)
{
auto item = pf->Add();
item->set_id(skill);
item->set_caption(ENUM_ATTR_STR(job_skill, caption, skill));
item->set_caption_noun(ENUM_ATTR_STR(job_skill, caption_noun, skill));
item->set_profession(ENUM_ATTR(job_skill, profession, skill));
item->set_labor(ENUM_ATTR(job_skill, labor, skill));
item->set_type(ENUM_ATTR(job_skill, type, skill));
}
}
static command_result GetVersion(color_ostream &stream,
const EmptyMessage *, StringMessage *out)
{
@ -445,6 +460,12 @@ static command_result ListEnums(color_ostream &stream,
#undef BITFIELD
}
static command_result ListJobSkills(color_ostream &stream, const EmptyMessage *, ListJobSkillsOut *out)
{
describeJobSkills(out->mutable_value());
return CR_OK;
}
static void listMaterial(ListMaterialsOut *out, int type, int index, const BasicMaterialInfoMask *mask)
{
MaterialInfo info(type, index);
@ -590,6 +611,7 @@ CoreService::CoreService() {
addFunction("GetWorldInfo", GetWorldInfo);
addFunction("ListEnums", ListEnums, SF_CALLED_ONCE | SF_DONT_SUSPEND);
addFunction("ListJobSkills", ListJobSkills, SF_CALLED_ONCE | SF_DONT_SUSPEND);
addFunction("ListMaterials", ListMaterials, SF_CALLED_ONCE);
addFunction("ListUnits", ListUnits);

@ -127,6 +127,10 @@ namespace DFHack
DFHACK_EXPORT void describeUnit(BasicUnitInfo *info, df::unit *unit,
const BasicUnitInfoMask *mask = NULL);
using dfproto::JobSkillInfo;
DFHACK_EXPORT void describeJobSkills(RepeatedPtrField<JobSkillInfo> *pf);
/////
class CoreService : public RPCService {

@ -69,6 +69,17 @@ message BasicMaterialInfoMask {
optional bool reaction = 3 [default = false];
};
message JobSkillInfo {
required int32 id = 1;
optional string caption = 2;
optional string caption_noun = 3;
optional int32 profession = 4;
optional int32 labor = 5;
optional int32 type = 6;
};
message NameInfo {
optional string first_name = 1;
optional string nickname = 2;

@ -51,6 +51,11 @@ message ListEnumsOut {
repeated EnumItemName profession = 11;
};
// RPC ListJobSkills : EmptyMessage -> ListJobSkillsOut
message ListJobSkillsOut {
repeated JobSkillInfo value = 1;
};
// RPC ListMaterials : ListMaterialsIn -> ListMaterialsOut
message ListMaterialsIn {
optional BasicMaterialInfoMask mask = 1;