Merge branch 'master' of git://github.com/warmist/dfhack into rendermax

develop
jj 2013-06-24 00:42:33 +02:00
commit e388dac794
74 changed files with 5135 additions and 9 deletions

@ -0,0 +1,968 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from: Basic.proto
namespace dfproto
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EnumItemName")]
public partial class EnumItemName : global::ProtoBuf.IExtensible
{
public EnumItemName() {}
private int _value;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int value
{
get { return _value; }
set { _value = value; }
}
private string _name = "";
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string name
{
get { return _name; }
set { _name = value; }
}
private int _bit_size = (int)1;
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"bit_size", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)1)]
public int bit_size
{
get { return _bit_size; }
set { _bit_size = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicMaterialId")]
public partial class BasicMaterialId : global::ProtoBuf.IExtensible
{
public BasicMaterialId() {}
private int _type;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int type
{
get { return _type; }
set { _type = value; }
}
private int _index;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"index", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
public int index
{
get { return _index; }
set { _index = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicMaterialInfo")]
public partial class BasicMaterialInfo : global::ProtoBuf.IExtensible
{
public BasicMaterialInfo() {}
private int _type;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int type
{
get { return _type; }
set { _type = value; }
}
private int _index;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"index", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
public int index
{
get { return _index; }
set { _index = value; }
}
private string _token;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"token", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string token
{
get { return _token; }
set { _token = value; }
}
private readonly global::System.Collections.Generic.List<int> _flags = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(4, Name=@"flags", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> flags
{
get { return _flags; }
}
private int _subtype = (int)-1;
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"subtype", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int subtype
{
get { return _subtype; }
set { _subtype = value; }
}
private int _creature_id = (int)-1;
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"creature_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int creature_id
{
get { return _creature_id; }
set { _creature_id = value; }
}
private int _plant_id = (int)-1;
[global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"plant_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int plant_id
{
get { return _plant_id; }
set { _plant_id = value; }
}
private int _histfig_id = (int)-1;
[global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"histfig_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int histfig_id
{
get { return _histfig_id; }
set { _histfig_id = value; }
}
private string _name_prefix = "";
[global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"name_prefix", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string name_prefix
{
get { return _name_prefix; }
set { _name_prefix = value; }
}
private readonly global::System.Collections.Generic.List<uint> _state_color = new global::System.Collections.Generic.List<uint>();
[global::ProtoBuf.ProtoMember(10, Name=@"state_color", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public global::System.Collections.Generic.List<uint> state_color
{
get { return _state_color; }
}
private readonly global::System.Collections.Generic.List<string> _state_name = new global::System.Collections.Generic.List<string>();
[global::ProtoBuf.ProtoMember(11, Name=@"state_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<string> state_name
{
get { return _state_name; }
}
private readonly global::System.Collections.Generic.List<string> _state_adj = new global::System.Collections.Generic.List<string>();
[global::ProtoBuf.ProtoMember(12, Name=@"state_adj", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<string> state_adj
{
get { return _state_adj; }
}
private readonly global::System.Collections.Generic.List<string> _reaction_class = new global::System.Collections.Generic.List<string>();
[global::ProtoBuf.ProtoMember(13, Name=@"reaction_class", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<string> reaction_class
{
get { return _reaction_class; }
}
private readonly global::System.Collections.Generic.List<dfproto.BasicMaterialInfo.Product> _reaction_product = new global::System.Collections.Generic.List<dfproto.BasicMaterialInfo.Product>();
[global::ProtoBuf.ProtoMember(14, Name=@"reaction_product", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.BasicMaterialInfo.Product> reaction_product
{
get { return _reaction_product; }
}
private readonly global::System.Collections.Generic.List<int> _inorganic_flags = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(15, Name=@"inorganic_flags", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> inorganic_flags
{
get { return _inorganic_flags; }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"Product")]
public partial class Product : global::ProtoBuf.IExtensible
{
public Product() {}
private string _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string id
{
get { return _id; }
set { _id = value; }
}
private int _type;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int type
{
get { return _type; }
set { _type = value; }
}
private int _index;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"index", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
public int index
{
get { return _index; }
set { _index = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicMaterialInfoMask")]
public partial class BasicMaterialInfoMask : global::ProtoBuf.IExtensible
{
public BasicMaterialInfoMask() {}
private readonly global::System.Collections.Generic.List<dfproto.BasicMaterialInfoMask.StateType> _states = new global::System.Collections.Generic.List<dfproto.BasicMaterialInfoMask.StateType>();
[global::ProtoBuf.ProtoMember(1, Name=@"states", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<dfproto.BasicMaterialInfoMask.StateType> states
{
get { return _states; }
}
private int _temperature = (int)10015;
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"temperature", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)10015)]
public int temperature
{
get { return _temperature; }
set { _temperature = value; }
}
private bool _flags = (bool)false;
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"flags", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool flags
{
get { return _flags; }
set { _flags = value; }
}
private bool _reaction = (bool)false;
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"reaction", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool reaction
{
get { return _reaction; }
set { _reaction = value; }
}
[global::ProtoBuf.ProtoContract(Name=@"StateType")]
public enum StateType
{
[global::ProtoBuf.ProtoEnum(Name=@"Solid", Value=0)]
Solid = 0,
[global::ProtoBuf.ProtoEnum(Name=@"Liquid", Value=1)]
Liquid = 1,
[global::ProtoBuf.ProtoEnum(Name=@"Gas", Value=2)]
Gas = 2,
[global::ProtoBuf.ProtoEnum(Name=@"Powder", Value=3)]
Powder = 3,
[global::ProtoBuf.ProtoEnum(Name=@"Paste", Value=4)]
Paste = 4,
[global::ProtoBuf.ProtoEnum(Name=@"Pressed", Value=5)]
Pressed = 5
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"JobSkillAttr")]
public partial class JobSkillAttr : global::ProtoBuf.IExtensible
{
public JobSkillAttr() {}
private int _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int id
{
get { return _id; }
set { _id = value; }
}
private string _key;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"key", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string key
{
get { return _key; }
set { _key = value; }
}
private string _caption = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"caption", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string caption
{
get { return _caption; }
set { _caption = value; }
}
private string _caption_noun = "";
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"caption_noun", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string caption_noun
{
get { return _caption_noun; }
set { _caption_noun = value; }
}
private int _profession = default(int);
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"profession", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int profession
{
get { return _profession; }
set { _profession = value; }
}
private int _labor = default(int);
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"labor", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int labor
{
get { return _labor; }
set { _labor = value; }
}
private string _type = "";
[global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"type", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string type
{
get { return _type; }
set { _type = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ProfessionAttr")]
public partial class ProfessionAttr : global::ProtoBuf.IExtensible
{
public ProfessionAttr() {}
private int _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int id
{
get { return _id; }
set { _id = value; }
}
private string _key;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"key", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string key
{
get { return _key; }
set { _key = value; }
}
private string _caption = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"caption", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string caption
{
get { return _caption; }
set { _caption = value; }
}
private bool _military = default(bool);
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"military", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool military
{
get { return _military; }
set { _military = value; }
}
private bool _can_assign_labor = default(bool);
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"can_assign_labor", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool can_assign_labor
{
get { return _can_assign_labor; }
set { _can_assign_labor = value; }
}
private int _parent = default(int);
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"parent", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int parent
{
get { return _parent; }
set { _parent = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UnitLaborAttr")]
public partial class UnitLaborAttr : global::ProtoBuf.IExtensible
{
public UnitLaborAttr() {}
private int _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int id
{
get { return _id; }
set { _id = value; }
}
private string _key;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"key", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string key
{
get { return _key; }
set { _key = value; }
}
private string _caption = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"caption", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string caption
{
get { return _caption; }
set { _caption = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NameInfo")]
public partial class NameInfo : global::ProtoBuf.IExtensible
{
public NameInfo() {}
private string _first_name = "";
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"first_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string first_name
{
get { return _first_name; }
set { _first_name = value; }
}
private string _nickname = "";
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"nickname", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string nickname
{
get { return _nickname; }
set { _nickname = value; }
}
private int _language_id = (int)-1;
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"language_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int language_id
{
get { return _language_id; }
set { _language_id = value; }
}
private string _last_name = "";
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"last_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string last_name
{
get { return _last_name; }
set { _last_name = value; }
}
private string _english_name = "";
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"english_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string english_name
{
get { return _english_name; }
set { _english_name = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"NameTriple")]
public partial class NameTriple : global::ProtoBuf.IExtensible
{
public NameTriple() {}
private string _normal;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"normal", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string normal
{
get { return _normal; }
set { _normal = value; }
}
private string _plural = "";
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"plural", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string plural
{
get { return _plural; }
set { _plural = value; }
}
private string _adjective = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"adjective", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string adjective
{
get { return _adjective; }
set { _adjective = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UnitCurseInfo")]
public partial class UnitCurseInfo : global::ProtoBuf.IExtensible
{
public UnitCurseInfo() {}
private uint _add_tags1;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"add_tags1", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint add_tags1
{
get { return _add_tags1; }
set { _add_tags1 = value; }
}
private uint _rem_tags1;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"rem_tags1", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint rem_tags1
{
get { return _rem_tags1; }
set { _rem_tags1 = value; }
}
private uint _add_tags2;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"add_tags2", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint add_tags2
{
get { return _add_tags2; }
set { _add_tags2 = value; }
}
private uint _rem_tags2;
[global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"rem_tags2", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint rem_tags2
{
get { return _rem_tags2; }
set { _rem_tags2 = value; }
}
private dfproto.NameTriple _name = null;
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.NameTriple name
{
get { return _name; }
set { _name = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"SkillInfo")]
public partial class SkillInfo : global::ProtoBuf.IExtensible
{
public SkillInfo() {}
private int _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int id
{
get { return _id; }
set { _id = value; }
}
private int _level;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"level", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int level
{
get { return _level; }
set { _level = value; }
}
private int _experience;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"experience", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int experience
{
get { return _experience; }
set { _experience = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UnitMiscTrait")]
public partial class UnitMiscTrait : global::ProtoBuf.IExtensible
{
public UnitMiscTrait() {}
private int _id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int id
{
get { return _id; }
set { _id = value; }
}
private int _value;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int value
{
get { return _value; }
set { _value = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicUnitInfo")]
public partial class BasicUnitInfo : global::ProtoBuf.IExtensible
{
public BasicUnitInfo() {}
private int _unit_id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"unit_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int unit_id
{
get { return _unit_id; }
set { _unit_id = value; }
}
private int _pos_x;
[global::ProtoBuf.ProtoMember(13, IsRequired = true, Name=@"pos_x", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int pos_x
{
get { return _pos_x; }
set { _pos_x = value; }
}
private int _pos_y;
[global::ProtoBuf.ProtoMember(14, IsRequired = true, Name=@"pos_y", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int pos_y
{
get { return _pos_y; }
set { _pos_y = value; }
}
private int _pos_z;
[global::ProtoBuf.ProtoMember(15, IsRequired = true, Name=@"pos_z", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int pos_z
{
get { return _pos_z; }
set { _pos_z = value; }
}
private dfproto.NameInfo _name = null;
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.NameInfo name
{
get { return _name; }
set { _name = value; }
}
private uint _flags1;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"flags1", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint flags1
{
get { return _flags1; }
set { _flags1 = value; }
}
private uint _flags2;
[global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"flags2", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint flags2
{
get { return _flags2; }
set { _flags2 = value; }
}
private uint _flags3;
[global::ProtoBuf.ProtoMember(5, IsRequired = true, Name=@"flags3", DataFormat = global::ProtoBuf.DataFormat.FixedSize)]
public uint flags3
{
get { return _flags3; }
set { _flags3 = value; }
}
private int _race;
[global::ProtoBuf.ProtoMember(6, IsRequired = true, Name=@"race", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int race
{
get { return _race; }
set { _race = value; }
}
private int _caste;
[global::ProtoBuf.ProtoMember(7, IsRequired = true, Name=@"caste", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int caste
{
get { return _caste; }
set { _caste = value; }
}
private int _gender = (int)-1;
[global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"gender", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int gender
{
get { return _gender; }
set { _gender = value; }
}
private int _civ_id = (int)-1;
[global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"civ_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int civ_id
{
get { return _civ_id; }
set { _civ_id = value; }
}
private int _histfig_id = (int)-1;
[global::ProtoBuf.ProtoMember(10, IsRequired = false, Name=@"histfig_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int histfig_id
{
get { return _histfig_id; }
set { _histfig_id = value; }
}
private int _death_id = (int)-1;
[global::ProtoBuf.ProtoMember(17, IsRequired = false, Name=@"death_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int death_id
{
get { return _death_id; }
set { _death_id = value; }
}
private uint _death_flags = default(uint);
[global::ProtoBuf.ProtoMember(18, IsRequired = false, Name=@"death_flags", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(uint))]
public uint death_flags
{
get { return _death_flags; }
set { _death_flags = value; }
}
private int _squad_id = (int)-1;
[global::ProtoBuf.ProtoMember(19, IsRequired = false, Name=@"squad_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int squad_id
{
get { return _squad_id; }
set { _squad_id = value; }
}
private int _squad_position = (int)-1;
[global::ProtoBuf.ProtoMember(20, IsRequired = false, Name=@"squad_position", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int squad_position
{
get { return _squad_position; }
set { _squad_position = value; }
}
private int _profession = (int)-1;
[global::ProtoBuf.ProtoMember(22, IsRequired = false, Name=@"profession", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue((int)-1)]
public int profession
{
get { return _profession; }
set { _profession = value; }
}
private string _custom_profession = "";
[global::ProtoBuf.ProtoMember(23, IsRequired = false, Name=@"custom_profession", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string custom_profession
{
get { return _custom_profession; }
set { _custom_profession = value; }
}
private readonly global::System.Collections.Generic.List<int> _labors = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(11, Name=@"labors", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> labors
{
get { return _labors; }
}
private readonly global::System.Collections.Generic.List<dfproto.SkillInfo> _skills = new global::System.Collections.Generic.List<dfproto.SkillInfo>();
[global::ProtoBuf.ProtoMember(12, Name=@"skills", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.SkillInfo> skills
{
get { return _skills; }
}
private readonly global::System.Collections.Generic.List<dfproto.UnitMiscTrait> _misc_traits = new global::System.Collections.Generic.List<dfproto.UnitMiscTrait>();
[global::ProtoBuf.ProtoMember(24, Name=@"misc_traits", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.UnitMiscTrait> misc_traits
{
get { return _misc_traits; }
}
private dfproto.UnitCurseInfo _curse = null;
[global::ProtoBuf.ProtoMember(16, IsRequired = false, Name=@"curse", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.UnitCurseInfo curse
{
get { return _curse; }
set { _curse = value; }
}
private readonly global::System.Collections.Generic.List<int> _burrows = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(21, Name=@"burrows", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> burrows
{
get { return _burrows; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicUnitInfoMask")]
public partial class BasicUnitInfoMask : global::ProtoBuf.IExtensible
{
public BasicUnitInfoMask() {}
private bool _labors = (bool)false;
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"labors", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool labors
{
get { return _labors; }
set { _labors = value; }
}
private bool _skills = (bool)false;
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"skills", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool skills
{
get { return _skills; }
set { _skills = value; }
}
private bool _profession = (bool)false;
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"profession", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool profession
{
get { return _profession; }
set { _profession = value; }
}
private bool _misc_traits = (bool)false;
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"misc_traits", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue((bool)false)]
public bool misc_traits
{
get { return _misc_traits; }
set { _misc_traits = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"BasicSquadInfo")]
public partial class BasicSquadInfo : global::ProtoBuf.IExtensible
{
public BasicSquadInfo() {}
private int _squad_id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"squad_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int squad_id
{
get { return _squad_id; }
set { _squad_id = value; }
}
private dfproto.NameInfo _name = null;
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.NameInfo name
{
get { return _name; }
set { _name = value; }
}
private string _alias = "";
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"alias", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string alias
{
get { return _alias; }
set { _alias = value; }
}
private readonly global::System.Collections.Generic.List<int> _members = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(4, Name=@"members", DataFormat = global::ProtoBuf.DataFormat.ZigZag)]
public global::System.Collections.Generic.List<int> members
{
get { return _members; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"UnitLaborState")]
public partial class UnitLaborState : global::ProtoBuf.IExtensible
{
public UnitLaborState() {}
private int _unit_id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"unit_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int unit_id
{
get { return _unit_id; }
set { _unit_id = value; }
}
private int _labor;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"labor", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int labor
{
get { return _labor; }
set { _labor = value; }
}
private bool _value;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public bool value
{
get { return _value; }
set { _value = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
}

@ -0,0 +1,460 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from: BasicApi.proto
// Note: requires additional types generated from: Basic.proto
namespace dfproto
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"GetWorldInfoOut")]
public partial class GetWorldInfoOut : global::ProtoBuf.IExtensible
{
public GetWorldInfoOut() {}
private dfproto.GetWorldInfoOut.Mode _mode;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"mode", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public dfproto.GetWorldInfoOut.Mode mode
{
get { return _mode; }
set { _mode = value; }
}
private string _save_dir;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"save_dir", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string save_dir
{
get { return _save_dir; }
set { _save_dir = value; }
}
private dfproto.NameInfo _world_name = null;
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"world_name", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.NameInfo world_name
{
get { return _world_name; }
set { _world_name = value; }
}
private int _civ_id = default(int);
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"civ_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int civ_id
{
get { return _civ_id; }
set { _civ_id = value; }
}
private int _site_id = default(int);
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"site_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int site_id
{
get { return _site_id; }
set { _site_id = value; }
}
private int _group_id = default(int);
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"group_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int group_id
{
get { return _group_id; }
set { _group_id = value; }
}
private int _race_id = default(int);
[global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"race_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int race_id
{
get { return _race_id; }
set { _race_id = value; }
}
private int _player_unit_id = default(int);
[global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"player_unit_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int player_unit_id
{
get { return _player_unit_id; }
set { _player_unit_id = value; }
}
private int _player_histfig_id = default(int);
[global::ProtoBuf.ProtoMember(9, IsRequired = false, Name=@"player_histfig_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int player_histfig_id
{
get { return _player_histfig_id; }
set { _player_histfig_id = value; }
}
private readonly global::System.Collections.Generic.List<int> _companion_histfig_ids = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(10, Name=@"companion_histfig_ids", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> companion_histfig_ids
{
get { return _companion_histfig_ids; }
}
[global::ProtoBuf.ProtoContract(Name=@"Mode")]
public enum Mode
{
[global::ProtoBuf.ProtoEnum(Name=@"MODE_DWARF", Value=1)]
MODE_DWARF = 1,
[global::ProtoBuf.ProtoEnum(Name=@"MODE_ADVENTURE", Value=2)]
MODE_ADVENTURE = 2,
[global::ProtoBuf.ProtoEnum(Name=@"MODE_LEGENDS", Value=3)]
MODE_LEGENDS = 3
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListEnumsOut")]
public partial class ListEnumsOut : global::ProtoBuf.IExtensible
{
public ListEnumsOut() {}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _material_flags = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(1, Name=@"material_flags", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> material_flags
{
get { return _material_flags; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _inorganic_flags = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(2, Name=@"inorganic_flags", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> inorganic_flags
{
get { return _inorganic_flags; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _unit_flags1 = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(3, Name=@"unit_flags1", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> unit_flags1
{
get { return _unit_flags1; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _unit_flags2 = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(4, Name=@"unit_flags2", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> unit_flags2
{
get { return _unit_flags2; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _unit_flags3 = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(5, Name=@"unit_flags3", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> unit_flags3
{
get { return _unit_flags3; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _unit_labor = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(6, Name=@"unit_labor", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> unit_labor
{
get { return _unit_labor; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _job_skill = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(7, Name=@"job_skill", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> job_skill
{
get { return _job_skill; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _cie_add_tag_mask1 = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(8, Name=@"cie_add_tag_mask1", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> cie_add_tag_mask1
{
get { return _cie_add_tag_mask1; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _cie_add_tag_mask2 = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(9, Name=@"cie_add_tag_mask2", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> cie_add_tag_mask2
{
get { return _cie_add_tag_mask2; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _death_info_flags = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(10, Name=@"death_info_flags", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> death_info_flags
{
get { return _death_info_flags; }
}
private readonly global::System.Collections.Generic.List<dfproto.EnumItemName> _profession = new global::System.Collections.Generic.List<dfproto.EnumItemName>();
[global::ProtoBuf.ProtoMember(11, Name=@"profession", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.EnumItemName> profession
{
get { return _profession; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListJobSkillsOut")]
public partial class ListJobSkillsOut : global::ProtoBuf.IExtensible
{
public ListJobSkillsOut() {}
private readonly global::System.Collections.Generic.List<dfproto.JobSkillAttr> _skill = new global::System.Collections.Generic.List<dfproto.JobSkillAttr>();
[global::ProtoBuf.ProtoMember(1, Name=@"skill", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.JobSkillAttr> skill
{
get { return _skill; }
}
private readonly global::System.Collections.Generic.List<dfproto.ProfessionAttr> _profession = new global::System.Collections.Generic.List<dfproto.ProfessionAttr>();
[global::ProtoBuf.ProtoMember(2, Name=@"profession", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.ProfessionAttr> profession
{
get { return _profession; }
}
private readonly global::System.Collections.Generic.List<dfproto.UnitLaborAttr> _labor = new global::System.Collections.Generic.List<dfproto.UnitLaborAttr>();
[global::ProtoBuf.ProtoMember(3, Name=@"labor", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.UnitLaborAttr> labor
{
get { return _labor; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListMaterialsIn")]
public partial class ListMaterialsIn : global::ProtoBuf.IExtensible
{
public ListMaterialsIn() {}
private dfproto.BasicMaterialInfoMask _mask = null;
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"mask", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.BasicMaterialInfoMask mask
{
get { return _mask; }
set { _mask = value; }
}
private readonly global::System.Collections.Generic.List<dfproto.BasicMaterialId> _id_list = new global::System.Collections.Generic.List<dfproto.BasicMaterialId>();
[global::ProtoBuf.ProtoMember(2, Name=@"id_list", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.BasicMaterialId> id_list
{
get { return _id_list; }
}
private bool _builtin = default(bool);
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"builtin", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool builtin
{
get { return _builtin; }
set { _builtin = value; }
}
private bool _inorganic = default(bool);
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"inorganic", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool inorganic
{
get { return _inorganic; }
set { _inorganic = value; }
}
private bool _creatures = default(bool);
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"creatures", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool creatures
{
get { return _creatures; }
set { _creatures = value; }
}
private bool _plants = default(bool);
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"plants", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool plants
{
get { return _plants; }
set { _plants = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListMaterialsOut")]
public partial class ListMaterialsOut : global::ProtoBuf.IExtensible
{
public ListMaterialsOut() {}
private readonly global::System.Collections.Generic.List<dfproto.BasicMaterialInfo> _value = new global::System.Collections.Generic.List<dfproto.BasicMaterialInfo>();
[global::ProtoBuf.ProtoMember(1, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.BasicMaterialInfo> value
{
get { return _value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListUnitsIn")]
public partial class ListUnitsIn : global::ProtoBuf.IExtensible
{
public ListUnitsIn() {}
private dfproto.BasicUnitInfoMask _mask = null;
[global::ProtoBuf.ProtoMember(1, IsRequired = false, Name=@"mask", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(null)]
public dfproto.BasicUnitInfoMask mask
{
get { return _mask; }
set { _mask = value; }
}
private readonly global::System.Collections.Generic.List<int> _id_list = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(2, Name=@"id_list", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> id_list
{
get { return _id_list; }
}
private bool _scan_all = default(bool);
[global::ProtoBuf.ProtoMember(5, IsRequired = false, Name=@"scan_all", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool scan_all
{
get { return _scan_all; }
set { _scan_all = value; }
}
private int _race = default(int);
[global::ProtoBuf.ProtoMember(3, IsRequired = false, Name=@"race", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int race
{
get { return _race; }
set { _race = value; }
}
private int _civ_id = default(int);
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"civ_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(default(int))]
public int civ_id
{
get { return _civ_id; }
set { _civ_id = value; }
}
private bool _dead = default(bool);
[global::ProtoBuf.ProtoMember(6, IsRequired = false, Name=@"dead", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool dead
{
get { return _dead; }
set { _dead = value; }
}
private bool _alive = default(bool);
[global::ProtoBuf.ProtoMember(7, IsRequired = false, Name=@"alive", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool alive
{
get { return _alive; }
set { _alive = value; }
}
private bool _sane = default(bool);
[global::ProtoBuf.ProtoMember(8, IsRequired = false, Name=@"sane", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue(default(bool))]
public bool sane
{
get { return _sane; }
set { _sane = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListUnitsOut")]
public partial class ListUnitsOut : global::ProtoBuf.IExtensible
{
public ListUnitsOut() {}
private readonly global::System.Collections.Generic.List<dfproto.BasicUnitInfo> _value = new global::System.Collections.Generic.List<dfproto.BasicUnitInfo>();
[global::ProtoBuf.ProtoMember(1, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.BasicUnitInfo> value
{
get { return _value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListSquadsIn")]
public partial class ListSquadsIn : global::ProtoBuf.IExtensible
{
public ListSquadsIn() {}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"ListSquadsOut")]
public partial class ListSquadsOut : global::ProtoBuf.IExtensible
{
public ListSquadsOut() {}
private readonly global::System.Collections.Generic.List<dfproto.BasicSquadInfo> _value = new global::System.Collections.Generic.List<dfproto.BasicSquadInfo>();
[global::ProtoBuf.ProtoMember(1, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.BasicSquadInfo> value
{
get { return _value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"SetUnitLaborsIn")]
public partial class SetUnitLaborsIn : global::ProtoBuf.IExtensible
{
public SetUnitLaborsIn() {}
private readonly global::System.Collections.Generic.List<dfproto.UnitLaborState> _change = new global::System.Collections.Generic.List<dfproto.UnitLaborState>();
[global::ProtoBuf.ProtoMember(1, Name=@"change", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.UnitLaborState> change
{
get { return _change; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
}

@ -0,0 +1,119 @@
using System;
using UnityEngine;
using AT.MIN;
using dfproto;
namespace DFHack
{
public enum color_value
{
COLOR_RESET = -1,
COLOR_BLACK = 0,
COLOR_BLUE,
COLOR_GREEN,
COLOR_CYAN,
COLOR_RED,
COLOR_MAGENTA,
COLOR_BROWN,
COLOR_GREY,
COLOR_DARKGREY,
COLOR_LIGHTBLUE,
COLOR_LIGHTGREEN,
COLOR_LIGHTCYAN,
COLOR_LIGHTRED,
COLOR_LIGHTMAGENTA,
COLOR_YELLOW,
COLOR_WHITE,
COLOR_MAX = COLOR_WHITE
};
public class color_ostream
{
string buffer;
public void printerr(string Format, params object[] Parameters)
{
Debug.LogError(Tools.sprintf(Format, Parameters));
}
public void print(string Format, params object[] Parameters)
{
Debug.Log(Tools.sprintf(Format, Parameters));
}
public void begin_batch()
{
buffer = "";
}
public void end_batch()
{
Debug.Log(buffer);
buffer = null;
}
public void add_text(color_value color, string text)
{
//Debug.Log(text);
buffer += text;
}
}
public class buffered_color_ostream : color_ostream
{
//protected:
public new void add_text(color_value color, string text)
{
if (text.Length == 0)
return;
if (buffer.Length == 0)
{
buffer = text;
}
else
{
buffer += text;
}
}
// buffered_color_ostream() {}
// ~buffered_color_ostream() {}
// const std::list<fragment_type> &fragments() { return buffer; }
protected string buffer;
}
public class color_ostream_proxy : buffered_color_ostream
{
protected color_ostream target;
//virtual void flush_proxy();
public color_ostream_proxy(color_ostream targetIn)
{
target = targetIn;
}
public virtual color_ostream proxy_target() { return target; }
public void decode(dfproto.CoreTextNotification data)
{
int cnt = data.fragments.Count;
if (cnt > 0)
{
target.begin_batch();
for (int i = 0; i < cnt; i++)
{
var frag = data.fragments[i];
//color_value color = frag.has_color() ? color_value(frag.color()) : COLOR_RESET;
target.add_text(color_value.COLOR_RESET, frag.text);
//target.printerr(data.fragments[i].text);
}
target.end_batch();
}
}
}
}

@ -0,0 +1,311 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
// Generated from: CoreProtocol.proto
namespace dfproto
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreTextFragment")]
public partial class CoreTextFragment : global::ProtoBuf.IExtensible
{
public CoreTextFragment() {}
private string _text;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"text", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string text
{
get { return _text; }
set { _text = value; }
}
private dfproto.CoreTextFragment.Color _color = dfproto.CoreTextFragment.Color.COLOR_BLACK;
[global::ProtoBuf.ProtoMember(2, IsRequired = false, Name=@"color", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
[global::System.ComponentModel.DefaultValue(dfproto.CoreTextFragment.Color.COLOR_BLACK)]
public dfproto.CoreTextFragment.Color color
{
get { return _color; }
set { _color = value; }
}
[global::ProtoBuf.ProtoContract(Name=@"Color")]
public enum Color
{
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_BLACK", Value=0)]
COLOR_BLACK = 0,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_BLUE", Value=1)]
COLOR_BLUE = 1,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_GREEN", Value=2)]
COLOR_GREEN = 2,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_CYAN", Value=3)]
COLOR_CYAN = 3,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_RED", Value=4)]
COLOR_RED = 4,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_MAGENTA", Value=5)]
COLOR_MAGENTA = 5,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_BROWN", Value=6)]
COLOR_BROWN = 6,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_GREY", Value=7)]
COLOR_GREY = 7,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_DARKGREY", Value=8)]
COLOR_DARKGREY = 8,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_LIGHTBLUE", Value=9)]
COLOR_LIGHTBLUE = 9,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_LIGHTGREEN", Value=10)]
COLOR_LIGHTGREEN = 10,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_LIGHTCYAN", Value=11)]
COLOR_LIGHTCYAN = 11,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_LIGHTRED", Value=12)]
COLOR_LIGHTRED = 12,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_LIGHTMAGENTA", Value=13)]
COLOR_LIGHTMAGENTA = 13,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_YELLOW", Value=14)]
COLOR_YELLOW = 14,
[global::ProtoBuf.ProtoEnum(Name=@"COLOR_WHITE", Value=15)]
COLOR_WHITE = 15
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreTextNotification")]
public partial class CoreTextNotification : global::ProtoBuf.IExtensible
{
public CoreTextNotification() {}
private readonly global::System.Collections.Generic.List<dfproto.CoreTextFragment> _fragments = new global::System.Collections.Generic.List<dfproto.CoreTextFragment>();
[global::ProtoBuf.ProtoMember(1, Name=@"fragments", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<dfproto.CoreTextFragment> fragments
{
get { return _fragments; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreErrorNotification")]
public partial class CoreErrorNotification : global::ProtoBuf.IExtensible
{
public CoreErrorNotification() {}
private dfproto.CoreErrorNotification.ErrorCode _code;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"code", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public dfproto.CoreErrorNotification.ErrorCode code
{
get { return _code; }
set { _code = value; }
}
[global::ProtoBuf.ProtoContract(Name=@"ErrorCode")]
public enum ErrorCode
{
[global::ProtoBuf.ProtoEnum(Name=@"CR_LINK_FAILURE", Value=-3)]
CR_LINK_FAILURE = -3,
[global::ProtoBuf.ProtoEnum(Name=@"CR_WOULD_BREAK", Value=-2)]
CR_WOULD_BREAK = -2,
[global::ProtoBuf.ProtoEnum(Name=@"CR_NOT_IMPLEMENTED", Value=-1)]
CR_NOT_IMPLEMENTED = -1,
[global::ProtoBuf.ProtoEnum(Name=@"CR_OK", Value=0)]
CR_OK = 0,
[global::ProtoBuf.ProtoEnum(Name=@"CR_FAILURE", Value=1)]
CR_FAILURE = 1,
[global::ProtoBuf.ProtoEnum(Name=@"CR_WRONG_USAGE", Value=2)]
CR_WRONG_USAGE = 2,
[global::ProtoBuf.ProtoEnum(Name=@"CR_NOT_FOUND", Value=3)]
CR_NOT_FOUND = 3
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"EmptyMessage")]
public partial class EmptyMessage : global::ProtoBuf.IExtensible
{
public EmptyMessage() {}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"IntMessage")]
public partial class IntMessage : global::ProtoBuf.IExtensible
{
public IntMessage() {}
private int _value;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int value
{
get { return _value; }
set { _value = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"IntListMessage")]
public partial class IntListMessage : global::ProtoBuf.IExtensible
{
public IntListMessage() {}
private readonly global::System.Collections.Generic.List<int> _value = new global::System.Collections.Generic.List<int>();
[global::ProtoBuf.ProtoMember(1, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public global::System.Collections.Generic.List<int> value
{
get { return _value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StringMessage")]
public partial class StringMessage : global::ProtoBuf.IExtensible
{
public StringMessage() {}
private string _value;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string value
{
get { return _value; }
set { _value = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"StringListMessage")]
public partial class StringListMessage : global::ProtoBuf.IExtensible
{
public StringListMessage() {}
private readonly global::System.Collections.Generic.List<string> _value = new global::System.Collections.Generic.List<string>();
[global::ProtoBuf.ProtoMember(1, Name=@"value", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<string> value
{
get { return _value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreBindRequest")]
public partial class CoreBindRequest : global::ProtoBuf.IExtensible
{
public CoreBindRequest() {}
private string _method;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"method", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string method
{
get { return _method; }
set { _method = value; }
}
private string _input_msg;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"input_msg", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string input_msg
{
get { return _input_msg; }
set { _input_msg = value; }
}
private string _output_msg;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"output_msg", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string output_msg
{
get { return _output_msg; }
set { _output_msg = value; }
}
private string _plugin = "";
[global::ProtoBuf.ProtoMember(4, IsRequired = false, Name=@"plugin", DataFormat = global::ProtoBuf.DataFormat.Default)]
[global::System.ComponentModel.DefaultValue("")]
public string plugin
{
get { return _plugin; }
set { _plugin = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreBindReply")]
public partial class CoreBindReply : global::ProtoBuf.IExtensible
{
public CoreBindReply() {}
private int _assigned_id;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"assigned_id", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int assigned_id
{
get { return _assigned_id; }
set { _assigned_id = value; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"CoreRunCommandRequest")]
public partial class CoreRunCommandRequest : global::ProtoBuf.IExtensible
{
public CoreRunCommandRequest() {}
private string _command;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"command", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string command
{
get { return _command; }
set { _command = value; }
}
private readonly global::System.Collections.Generic.List<string> _arguments = new global::System.Collections.Generic.List<string>();
[global::ProtoBuf.ProtoMember(2, Name=@"arguments", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<string> arguments
{
get { return _arguments; }
}
private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}
}

@ -0,0 +1,720 @@
/*
https://github.com/peterix/dfhack
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
using dfproto;
using System;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Text;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections.Generic;
using System.Diagnostics;
namespace DFHack
{
using message_type = ProtoBuf.IExtensible;
public enum command_result
{
CR_LINK_FAILURE = -3, // RPC call failed due to I/O or protocol error
CR_NEEDS_CONSOLE = -2, // Attempt to call interactive command without console
CR_NOT_IMPLEMENTED = -1, // Command not implemented, or plugin not loaded
CR_OK = 0, // Success
CR_FAILURE = 1, // Failure
CR_WRONG_USAGE = 2, // Wrong arguments or ui state
CR_NOT_FOUND = 3 // Target object not found (for RPC mainly)
}
public enum DFHackReplyCode
{
RPC_REPLY_RESULT = -1,
RPC_REPLY_FAIL = -2,
RPC_REPLY_TEXT = -3,
RPC_REQUEST_QUIT = -4
}
class RPCHandshakeHeader
{
public string magic;
public int version;
public static string REQUEST_MAGIC = "DFHack?\n";
public static string RESPONSE_MAGIC = "DFHack!\n";
}
struct RPCMessageHeader
{
public const int MAX_MESSAGE_SIZE = 8 * 1048576;
public Int16 id;
public Int32 size;
public byte[] ConvertToBtyes()
{
List<byte> output = new List<byte>();
output.AddRange(BitConverter.GetBytes(id));
output.AddRange(new byte[2]);
output.AddRange(BitConverter.GetBytes(size));
return output.ToArray();
}
string BytesToString(byte[] input)
{
string output = "";
foreach (byte item in input)
{
if (output.Length > 0)
output += ",";
output += item;
}
return output;
}
}
/* Protocol description:
*
* 1. Handshake
*
* Client initiates connection by sending the handshake
* request header. The server responds with the response
* magic. Currently both versions must be 1.
*
* 2. Interaction
*
* Requests are done by exchanging messages between the
* client and the server. Messages consist of a serialized
* protobuf message preceeded by RPCMessageHeader. The size
* field specifies the length of the protobuf part.
*
* NOTE: As a special exception, RPC_REPLY_FAIL uses the size
* field to hold the error code directly.
*
* Every callable function is assigned a non-negative id by
* the server. Id 0 is reserved for BindMethod, which can be
* used to request any other id by function name. Id 1 is
* RunCommand, used to call console commands remotely.
*
* The client initiates every call by sending a message with
* appropriate function id and input arguments. The server
* responds with zero or more RPC_REPLY_TEXT:CoreTextNotification
* messages, followed by RPC_REPLY_RESULT containing the output
* of the function if it succeeded, or RPC_REPLY_FAIL with the
* error code if it did not.
*
* 3. Disconnect
*
* The client terminates the connection by sending an
* RPC_REQUEST_QUIT header with zero size and immediately
* closing the socket.
*/
public class RPCFunctionBase
{
public message_type p_in_template;
public message_type p_out_template;
public message_type make_in()
{
return (message_type)Activator.CreateInstance(p_in_template.GetType());
}
public message_type input()
{
if (p_in == null) p_in = make_in();
return p_in;
}
public message_type make_out()
{
return (message_type)Activator.CreateInstance(p_out_template.GetType());
}
public message_type output()
{
if (p_out == null) p_out = make_out();
return p_out;
}
public void reset(bool free = false)
{
if (free)
{
p_in = null;
p_out = null;
}
else
{
if (p_in != null)
p_in = (message_type)Activator.CreateInstance(p_in.GetType());
if (p_out != null)
p_out = (message_type)Activator.CreateInstance(p_out.GetType());
}
}
public RPCFunctionBase(message_type input, message_type output)
{
p_in_template = input;
p_out_template = output;
p_in = null;
p_out = null;
}
~RPCFunctionBase()
{
p_in = null;
p_out = null;
}
message_type p_in;
message_type p_out;
}
public class RemoteFunctionBase : RPCFunctionBase
{
public bool bind(RemoteClient client, string name,
string proto = "")
{
return bind(client.default_output(), client, name, proto);
}
public bool bind(color_ostream output,
RemoteClient client, string name,
string proto = "")
{
if (isValid())
{
if (p_client == client && this.name == name && this.proto == proto)
return true;
output.printerr("Function already bound to %s::%s\n",
this.proto, this.name);
return false;
}
this.name = name;
this.proto = proto;
this.p_client = client;
return client.bind(output, this, name, proto);
}
public bool isValid() { return (id >= 0); }
public RemoteFunctionBase(message_type input, message_type output)
: base(input, output)
{
p_client = null;
id = -1;
}
protected color_ostream default_ostream()
{
return p_client.default_output();
}
bool sendRemoteMessage(Socket socket, Int16 id, MemoryStream msg)
{
List<byte> buffer = new List<byte>();
RPCMessageHeader header = new RPCMessageHeader();
header.id = id;
header.size = (Int32)msg.Length;
buffer.AddRange(header.ConvertToBtyes());
buffer.AddRange(msg.ToArray());
int fullsz = buffer.Count;
int got = socket.Send(buffer.ToArray());
return (got == fullsz);
}
protected command_result execute<Input, Output>(color_ostream outString, Input input, Output output)
where Input : message_type, new()
where Output : message_type, new()
{
if (!isValid())
{
outString.printerr("Calling an unbound RPC function %s::%s.\n",
this.proto, this.name);
return command_result.CR_NOT_IMPLEMENTED;
}
if (p_client.socket == null)
{
outString.printerr("In call to %s::%s: invalid socket.\n",
this.proto, this.name);
return command_result.CR_LINK_FAILURE;
}
MemoryStream sendStream = new MemoryStream();
ProtoBuf.Serializer.Serialize<Input>(sendStream, input);
long send_size = sendStream.Length;
if (send_size > RPCMessageHeader.MAX_MESSAGE_SIZE)
{
outString.printerr("In call to %s::%s: message too large: %d.\n",
this.proto, this.name, send_size);
return command_result.CR_LINK_FAILURE;
}
if (!sendRemoteMessage(p_client.socket, id, sendStream))
{
outString.printerr("In call to %s::%s: I/O error in send.\n",
this.proto, this.name);
return command_result.CR_LINK_FAILURE;
}
color_ostream_proxy text_decoder = new color_ostream_proxy(outString);
CoreTextNotification text_data;
output = new Output();
//return command_result.CR_OK;
while (true)
{
RPCMessageHeader header = new RPCMessageHeader();
byte[] buffer = new byte[8];
if (!RemoteClient.readFullBuffer(p_client.socket, buffer, 8))
{
outString.printerr("In call to %s::%s: I/O error in receive header.\n",
this.proto, this.name);
return command_result.CR_LINK_FAILURE;
}
header.id = BitConverter.ToInt16(buffer, 0);
header.size = BitConverter.ToInt32(buffer, 4); //because something, somewhere, is fucking retarded
//outString.print("Received %d:%d.\n", header.id, header.size);
if ((DFHackReplyCode)header.id == DFHackReplyCode.RPC_REPLY_FAIL)
if (header.size == (int)command_result.CR_OK)
return command_result.CR_FAILURE;
else
return (command_result)header.size;
if (header.size < 0 || header.size > RPCMessageHeader.MAX_MESSAGE_SIZE)
{
outString.printerr("In call to %s::%s: invalid received size %d.\n",
this.proto, this.name, header.size);
return command_result.CR_LINK_FAILURE;
}
byte[] buf = new byte[header.size];
if (!RemoteClient.readFullBuffer(p_client.socket, buf, header.size))
{
outString.printerr("In call to %s::%s: I/O error in receive %d bytes of data.\n",
this.proto, this.name, header.size);
return command_result.CR_LINK_FAILURE;
}
switch ((DFHackReplyCode)header.id)
{
case DFHackReplyCode.RPC_REPLY_RESULT:
output = ProtoBuf.Serializer.Deserialize<Output>(new MemoryStream(buf));
if (output == null)
{
outString.printerr("In call to %s::%s: error parsing received result.\n",
this.proto, this.name);
return command_result.CR_LINK_FAILURE;
}
return command_result.CR_OK;
case DFHackReplyCode.RPC_REPLY_TEXT:
text_data = ProtoBuf.Serializer.Deserialize<CoreTextNotification>(new MemoryStream(buf));
if (text_data != null)
{
text_decoder.decode(text_data);
}
else
outString.printerr("In call to %s::%s: received invalid text data.\n",
this.proto, this.name);
break;
default:
break;
}
}
return command_result.CR_OK;
}
public string name, proto;
public RemoteClient p_client;
public Int16 id;
}
public class RemoteFunction<Input, Output> : RemoteFunctionBase
where Input : message_type, new()
where Output : message_type, new()
{
public new Input make_in() { return (Input)(base.make_in()); }
public new Input input() { return (Input)(base.input()); }
public new Output make_out() { return (Output)(base.make_out()); }
public new Output output() { return (Output)(base.output()); }
public RemoteFunction() : base(new Input(), new Output()) { }
public command_result execute()
{
if (p_client == null)
return command_result.CR_NOT_IMPLEMENTED;
else
return base.execute<Input, Output>(default_ostream(), input(), output());
}
public command_result execute(color_ostream stream)
{
return base.execute<Input, Output>(stream, input(), output());
}
public command_result execute(Input input, Output output)
{
if (p_client == null)
return command_result.CR_NOT_IMPLEMENTED;
else
return base.execute<Input, Output>(default_ostream(), input, output);
}
public command_result execute(color_ostream stream, Input input, Output output)
{
return base.execute<Input, Output>(stream, input, output);
}
}
public class RemoteFunction<Input> : RemoteFunctionBase
where Input : message_type, new()
{
public new Input make_in() { return (Input)(base.make_in()); }
public new Input input() { return (Input)(base.input()); }
public RemoteFunction() : base(new Input(), new EmptyMessage()) { }
public command_result execute()
{
if (p_client == null)
return command_result.CR_NOT_IMPLEMENTED;
else
return base.execute<Input, EmptyMessage>(default_ostream(), input(), (EmptyMessage)output());
}
public command_result execute(color_ostream stream)
{
return base.execute<Input, EmptyMessage>(stream, input(), (EmptyMessage)output());
}
public command_result execute(Input input)
{
if (p_client == null)
return command_result.CR_NOT_IMPLEMENTED;
else
return base.execute<Input, EmptyMessage>(default_ostream(), input, (EmptyMessage)output());
}
public command_result execute(color_ostream stream, Input input)
{
return base.execute<Input, EmptyMessage>(stream, input, (EmptyMessage)output());
}
};
public class RemoteClient
{
public static bool readFullBuffer(Socket socket, byte[] buf, int size)
{
if (!socket.Connected)
return false;
if (size == 0)
return true;
int cnt = socket.Receive(buf, size, SocketFlags.None);
if (cnt <= 0) return false;
return true;
}
public bool bind(color_ostream outStream, RemoteFunctionBase function,
string name, string proto)
{
if (!active || socket == null)
return false;
bind_call.reset();
{
var input = bind_call.input();
input.method = name;
if (proto.Length == 0)
input.plugin = proto;
input.input_msg = function.p_in_template.GetType().ToString();
input.output_msg = function.p_out_template.GetType().ToString();
}
if (bind_call.execute(outStream) != command_result.CR_OK)
return false;
function.id = (Int16)bind_call.output().assigned_id;
return true;
}
public RemoteClient(color_ostream default_output = null)
{
p_default_output = default_output;
active = false;
socket = null;
suspend_ready = false;
if (p_default_output == null)
{
delete_output = true;
p_default_output = new color_ostream();
}
else
delete_output = false;
}
~RemoteClient()
{
disconnect();
socket = null;
if (delete_output)
p_default_output = null;
}
public static int GetDefaultPort()
{
string port = System.Environment.GetEnvironmentVariable("DFHACK_PORT");
if (port == null) port = "0";
int portval = Int32.Parse(port);
if (portval <= 0)
return 5000;
else
return portval;
}
public color_ostream default_output()
{
return p_default_output;
}
private static Socket ConnectSocket(string server, int port)
{
Socket s = null;
IPHostEntry hostEntry = null;
// Get host related information.
hostEntry = Dns.GetHostEntry(server);
// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid
// an exception that occurs when the host IP Address is not compatible with the address family
// (typical in the IPv6 case).
foreach (IPAddress address in hostEntry.AddressList)
{
IPEndPoint ipe = new IPEndPoint(address, port);
Socket tempSocket =
new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
tempSocket.Connect(ipe);
if (tempSocket.Connected)
{
s = tempSocket;
break;
}
else
{
continue;
}
}
return s;
}
static bool partialArrayCompare(byte[] A, byte[] B) //compares the intersection of the two arrays, ignoring the rest.
{
int size = A.Length;
if (size > B.Length) size = B.Length;
for (int i = 0; i < size; i++)
{
if (A[i] != B[i])
return false;
}
return true;
}
public bool connect(int port = -1)
{
Debug.Assert(!active);
if (port <= 0)
port = GetDefaultPort();
socket = ConnectSocket("localhost", port);
if (socket == null)
{
default_output().printerr("Could not connect to localhost: %d\n", port);
return false;
}
active = true;
List<byte> headerList = new List<byte>();
headerList.AddRange(Encoding.ASCII.GetBytes(RPCHandshakeHeader.REQUEST_MAGIC));
headerList.AddRange(BitConverter.GetBytes((Int32)1));
byte[] header = headerList.ToArray();
if (socket.Send(header) != header.Length)
{
default_output().printerr("Could not send handshake header.\n");
socket.Close();
socket = null;
return active = false;
}
if (!readFullBuffer(socket, header, header.Length))
{
default_output().printerr("Could not read handshake header.\n");
socket.Close();
socket = null;
return active = false;
}
if (!partialArrayCompare(header, Encoding.ASCII.GetBytes(RPCHandshakeHeader.RESPONSE_MAGIC)) ||
BitConverter.ToInt32(header, Encoding.ASCII.GetBytes(RPCHandshakeHeader.RESPONSE_MAGIC).Length) != 1)
{
default_output().printerr("Invalid handshake response: %s.\n", System.Text.Encoding.Default.GetString(header));
socket.Close();
socket = null;
return active = false;
}
if (bind_call == null) bind_call = new RemoteFunction<CoreBindRequest, CoreBindReply>();
bind_call.name = "BindMethod";
bind_call.p_client = this;
bind_call.id = 0;
if (runcmd_call == null) runcmd_call = new RemoteFunction<CoreRunCommandRequest>();
runcmd_call.name = "RunCommand";
runcmd_call.p_client = this;
runcmd_call.id = 1;
return true;
}
public void disconnect()
{
if (active && socket != null)
{
RPCMessageHeader header;
header.id = (Int16)DFHackReplyCode.RPC_REQUEST_QUIT;
header.size = 0;
if (socket.Send(header.ConvertToBtyes()) != header.ConvertToBtyes().Length)
default_output().printerr("Could not send the disconnect message.\n");
socket.Close();
}
socket = null;
}
public command_result run_command(string cmd, List<string> args)
{
return run_command(default_output(), cmd, args);
}
public command_result run_command(color_ostream output, string cmd, List<string> args)
{
if (!active || socket == null)
{
output.printerr("In RunCommand: client connection not valid.\n");
return command_result.CR_FAILURE;
}
runcmd_call.reset();
runcmd_call.input().command = cmd;
for (int i = 0; i < args.Count; i++)
runcmd_call.input().arguments.Add(args[i]);
return runcmd_call.execute(output);
}
// // For executing multiple calls in rapid succession.
// // Best used via RemoteSuspender.
public int suspend_game()
{
if (!active)
return -1;
if (!suspend_ready)
{
suspend_ready = true;
suspend_call.bind(this, "CoreSuspend");
resume_call.bind(this, "CoreResume");
}
if (suspend_call.execute(default_output()) == command_result.CR_OK)
return suspend_call.output().value;
else
return -1;
}
public int resume_game()
{
if (!suspend_ready)
return -1;
if (resume_call.execute(default_output()) == command_result.CR_OK)
return resume_call.output().value;
else
return -1;
}
//private:
bool active, delete_output;
public Socket socket;
color_ostream p_default_output;
RemoteFunction<dfproto.CoreBindRequest, dfproto.CoreBindReply> bind_call;
RemoteFunction<dfproto.CoreRunCommandRequest> runcmd_call;
bool suspend_ready;
RemoteFunction<EmptyMessage, IntMessage> suspend_call, resume_call;
}
class RemoteSuspender
{
RemoteClient client;
public RemoteSuspender(RemoteClient clientIn)
{
client = clientIn;
if (client == null || client.suspend_game() <= 0) client = null;
}
~RemoteSuspender()
{
if (client != null) client.resume_game();
}
};
}

@ -0,0 +1,690 @@
#region Usings
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
#endregion
namespace AT.MIN
{
public static class Tools
{
#region Public Methods
#region IsNumericType
/// <summary>
/// Determines whether the specified value is of numeric type.
/// </summary>
/// <param name="o">The object to check.</param>
/// <returns>
/// <c>true</c> if o is a numeric type; otherwise, <c>false</c>.
/// </returns>
public static bool IsNumericType( object o )
{
return ( o is byte ||
o is sbyte ||
o is short ||
o is ushort ||
o is int ||
o is uint ||
o is long ||
o is ulong ||
o is float ||
o is double ||
o is decimal );
}
#endregion
#region IsPositive
/// <summary>
/// Determines whether the specified value is positive.
/// </summary>
/// <param name="Value">The value.</param>
/// <param name="ZeroIsPositive">if set to <c>true</c> treats 0 as positive.</param>
/// <returns>
/// <c>true</c> if the specified value is positive; otherwise, <c>false</c>.
/// </returns>
public static bool IsPositive( object Value, bool ZeroIsPositive )
{
switch ( Type.GetTypeCode( Value.GetType() ) )
{
case TypeCode.SByte:
return ( ZeroIsPositive ? (sbyte)Value >= 0 : (sbyte)Value > 0 );
case TypeCode.Int16:
return ( ZeroIsPositive ? (short)Value >= 0 : (short)Value > 0 );
case TypeCode.Int32:
return ( ZeroIsPositive ? (int)Value >= 0 : (int)Value > 0 );
case TypeCode.Int64:
return ( ZeroIsPositive ? (long)Value >= 0 : (long)Value > 0 );
case TypeCode.Single:
return ( ZeroIsPositive ? (float)Value >= 0 : (float)Value > 0 );
case TypeCode.Double:
return ( ZeroIsPositive ? (double)Value >= 0 : (double)Value > 0 );
case TypeCode.Decimal:
return ( ZeroIsPositive ? (decimal)Value >= 0 : (decimal)Value > 0 );
case TypeCode.Byte:
return ( ZeroIsPositive ? true : (byte)Value > 0 );
case TypeCode.UInt16:
return ( ZeroIsPositive ? true : (ushort)Value > 0 );
case TypeCode.UInt32:
return ( ZeroIsPositive ? true : (uint)Value > 0 );
case TypeCode.UInt64:
return ( ZeroIsPositive ? true : (ulong)Value > 0 );
case TypeCode.Char:
return ( ZeroIsPositive ? true : (char)Value != '\0' );
default:
return false;
}
}
#endregion
#region ToUnsigned
/// <summary>
/// Converts the specified values boxed type to its correpsonding unsigned
/// type.
/// </summary>
/// <param name="Value">The value.</param>
/// <returns>A boxed numeric object whos type is unsigned.</returns>
public static object ToUnsigned( object Value )
{
switch ( Type.GetTypeCode( Value.GetType() ) )
{
case TypeCode.SByte:
return (byte)( (sbyte)Value );
case TypeCode.Int16:
return (ushort)( (short)Value );
case TypeCode.Int32:
return (uint)( (int)Value );
case TypeCode.Int64:
return (ulong)( (long)Value );
case TypeCode.Byte:
return Value;
case TypeCode.UInt16:
return Value;
case TypeCode.UInt32:
return Value;
case TypeCode.UInt64:
return Value;
case TypeCode.Single:
return (UInt32)( (float)Value );
case TypeCode.Double:
return (ulong)( (double)Value );
case TypeCode.Decimal:
return (ulong)( (decimal)Value );
default:
return null;
}
}
#endregion
#region ToInteger
/// <summary>
/// Converts the specified values boxed type to its correpsonding integer
/// type.
/// </summary>
/// <param name="Value">The value.</param>
/// <returns>A boxed numeric object whos type is an integer type.</returns>
public static object ToInteger( object Value, bool Round )
{
switch ( Type.GetTypeCode( Value.GetType() ) )
{
case TypeCode.SByte:
return Value;
case TypeCode.Int16:
return Value;
case TypeCode.Int32:
return Value;
case TypeCode.Int64:
return Value;
case TypeCode.Byte:
return Value;
case TypeCode.UInt16:
return Value;
case TypeCode.UInt32:
return Value;
case TypeCode.UInt64:
return Value;
case TypeCode.Single:
return ( Round ? (int)Math.Round( (float)Value ) : (int)( (float)Value ) );
case TypeCode.Double:
return ( Round ? (long)Math.Round( (double)Value ) : (long)( (double)Value ) );
case TypeCode.Decimal:
return ( Round ? Math.Round( (decimal)Value ) : (decimal)Value );
default:
return null;
}
}
#endregion
#region UnboxToLong
public static long UnboxToLong( object Value, bool Round )
{
switch ( Type.GetTypeCode( Value.GetType() ) )
{
case TypeCode.SByte:
return (long)( (sbyte)Value );
case TypeCode.Int16:
return (long)( (short)Value );
case TypeCode.Int32:
return (long)( (int)Value );
case TypeCode.Int64:
return (long)Value;
case TypeCode.Byte:
return (long)( (byte)Value );
case TypeCode.UInt16:
return (long)( (ushort)Value );
case TypeCode.UInt32:
return (long)( (uint)Value );
case TypeCode.UInt64:
return (long)( (ulong)Value );
case TypeCode.Single:
return ( Round ? (long)Math.Round( (float)Value ) : (long)( (float)Value ) );
case TypeCode.Double:
return ( Round ? (long)Math.Round( (double)Value ) : (long)( (double)Value ) );
case TypeCode.Decimal:
return ( Round ? (long)Math.Round( (decimal)Value ) : (long)( (decimal)Value ) );
default:
return 0;
}
}
#endregion
#region ReplaceMetaChars
/// <summary>
/// Replaces the string representations of meta chars with their corresponding
/// character values.
/// </summary>
/// <param name="input">The input.</param>
/// <returns>A string with all string meta chars are replaced</returns>
public static string ReplaceMetaChars( string input )
{
return Regex.Replace( input, @"(\\)(\d{3}|[^\d])?", new MatchEvaluator( ReplaceMetaCharsMatch ) );
}
private static string ReplaceMetaCharsMatch( Match m )
{
// convert octal quotes (like \040)
if ( m.Groups[2].Length == 3 )
return Convert.ToChar( Convert.ToByte( m.Groups[2].Value, 8 ) ).ToString();
else
{
// convert all other special meta characters
//TODO: \xhhh hex and possible dec !!
switch ( m.Groups[2].Value )
{
case "0": // null
return "\0";
case "a": // alert (beep)
return "\a";
case "b": // BS
return "\b";
case "f": // FF
return "\f";
case "v": // vertical tab
return "\v";
case "r": // CR
return "\r";
case "n": // LF
return "\n";
case "t": // Tab
return "\t";
default:
// if neither an octal quote nor a special meta character
// so just remove the backslash
return m.Groups[2].Value;
}
}
}
#endregion
#region printf
public static void printf( string Format, params object[] Parameters )
{
Console.Write( Tools.sprintf( Format, Parameters ) );
}
#endregion
#region fprintf
public static void fprintf( TextWriter Destination, string Format, params object[] Parameters )
{
Destination.Write( Tools.sprintf( Format, Parameters ) );
}
#endregion
#region sprintf
public static string sprintf( string Format, params object[] Parameters )
{
#region Variables
StringBuilder f = new StringBuilder();
Regex r = new Regex( @"\%(\d*\$)?([\'\#\-\+ ]*)(\d*)(?:\.(\d+))?([hl])?([dioxXucsfeEgGpn%])" );
//"%[parameter][flags][width][.precision][length]type"
Match m = null;
string w = String.Empty;
int defaultParamIx = 0;
int paramIx;
object o = null;
bool flagLeft2Right = false;
bool flagAlternate = false;
bool flagPositiveSign = false;
bool flagPositiveSpace = false;
bool flagZeroPadding = false;
bool flagGroupThousands = false;
int fieldLength = 0;
int fieldPrecision = 0;
char shortLongIndicator = '\0';
char formatSpecifier = '\0';
char paddingCharacter = ' ';
#endregion
// find all format parameters in format string
f.Append( Format );
m = r.Match( f.ToString() );
while ( m.Success )
{
#region parameter index
paramIx = defaultParamIx;
if ( m.Groups[1] != null && m.Groups[1].Value.Length > 0 )
{
string val = m.Groups[1].Value.Substring( 0, m.Groups[1].Value.Length - 1 );
paramIx = Convert.ToInt32( val ) - 1;
};
#endregion
#region format flags
// extract format flags
flagAlternate = false;
flagLeft2Right = false;
flagPositiveSign = false;
flagPositiveSpace = false;
flagZeroPadding = false;
flagGroupThousands = false;
if ( m.Groups[2] != null && m.Groups[2].Value.Length > 0 )
{
string flags = m.Groups[2].Value;
flagAlternate = ( flags.IndexOf( '#' ) >= 0 );
flagLeft2Right = ( flags.IndexOf( '-' ) >= 0 );
flagPositiveSign = ( flags.IndexOf( '+' ) >= 0 );
flagPositiveSpace = ( flags.IndexOf( ' ' ) >= 0 );
flagGroupThousands = ( flags.IndexOf( '\'' ) >= 0 );
// positive + indicator overrides a
// positive space character
if ( flagPositiveSign && flagPositiveSpace )
flagPositiveSpace = false;
}
#endregion
#region field length
// extract field length and
// pading character
paddingCharacter = ' ';
fieldLength = int.MinValue;
if ( m.Groups[3] != null && m.Groups[3].Value.Length > 0 )
{
fieldLength = Convert.ToInt32( m.Groups[3].Value );
flagZeroPadding = ( m.Groups[3].Value[0] == '0' );
}
#endregion
if ( flagZeroPadding )
paddingCharacter = '0';
// left2right allignment overrides zero padding
if ( flagLeft2Right && flagZeroPadding )
{
flagZeroPadding = false;
paddingCharacter = ' ';
}
#region field precision
// extract field precision
fieldPrecision = int.MinValue;
if ( m.Groups[4] != null && m.Groups[4].Value.Length > 0 )
fieldPrecision = Convert.ToInt32( m.Groups[4].Value );
#endregion
#region short / long indicator
// extract short / long indicator
shortLongIndicator = Char.MinValue;
if ( m.Groups[5] != null && m.Groups[5].Value.Length > 0 )
shortLongIndicator = m.Groups[5].Value[0];
#endregion
#region format specifier
// extract format
formatSpecifier = Char.MinValue;
if ( m.Groups[6] != null && m.Groups[6].Value.Length > 0 )
formatSpecifier = m.Groups[6].Value[0];
#endregion
// default precision is 6 digits if none is specified except
if ( fieldPrecision == int.MinValue &&
formatSpecifier != 's' &&
formatSpecifier != 'c' &&
Char.ToUpper( formatSpecifier ) != 'X' &&
formatSpecifier != 'o' )
fieldPrecision = 6;
#region get next value parameter
// get next value parameter and convert value parameter depending on short / long indicator
if ( Parameters == null || paramIx >= Parameters.Length )
o = null;
else
{
o = Parameters[paramIx];
if ( shortLongIndicator == 'h' )
{
if ( o is int )
o = (short)( (int)o );
else if ( o is long )
o = (short)( (long)o );
else if ( o is uint )
o = (ushort)( (uint)o );
else if ( o is ulong )
o = (ushort)( (ulong)o );
}
else if ( shortLongIndicator == 'l' )
{
if ( o is short )
o = (long)( (short)o );
else if ( o is int )
o = (long)( (int)o );
else if ( o is ushort )
o = (ulong)( (ushort)o );
else if ( o is uint )
o = (ulong)( (uint)o );
}
}
#endregion
// convert value parameters to a string depending on the formatSpecifier
w = String.Empty;
switch ( formatSpecifier )
{
#region % - character
case '%': // % character
w = "%";
break;
#endregion
#region d - integer
case 'd': // integer
w = FormatNumber( ( flagGroupThousands ? "n" : "d" ), flagAlternate,
fieldLength, int.MinValue, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region i - integer
case 'i': // integer
goto case 'd';
#endregion
#region o - octal integer
case 'o': // octal integer - no leading zero
w = FormatOct( "o", flagAlternate,
fieldLength, int.MinValue, flagLeft2Right,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region x - hex integer
case 'x': // hex integer - no leading zero
w = FormatHex( "x", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region X - hex integer
case 'X': // same as x but with capital hex characters
w = FormatHex( "X", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region u - unsigned integer
case 'u': // unsigned integer
w = FormatNumber( ( flagGroupThousands ? "n" : "d" ), flagAlternate,
fieldLength, int.MinValue, flagLeft2Right,
false, false,
paddingCharacter, ToUnsigned( o ) );
defaultParamIx++;
break;
#endregion
#region c - character
case 'c': // character
if ( IsNumericType( o ) )
w = Convert.ToChar( o ).ToString();
else if ( o is char )
w = ( (char)o ).ToString();
else if ( o is string && ( (string)o ).Length > 0 )
w = ( (string)o )[0].ToString();
defaultParamIx++;
break;
#endregion
#region s - string
case 's': // string
string t = "{0" + ( fieldLength != int.MinValue ? "," + ( flagLeft2Right ? "-" : String.Empty ) + fieldLength.ToString() : String.Empty ) + ":s}";
w = o.ToString();
if ( fieldPrecision >= 0 )
w = w.Substring( 0, fieldPrecision );
if ( fieldLength != int.MinValue )
if ( flagLeft2Right )
w = w.PadRight( fieldLength, paddingCharacter );
else
w = w.PadLeft( fieldLength, paddingCharacter );
defaultParamIx++;
break;
#endregion
#region f - double number
case 'f': // double
w = FormatNumber( ( flagGroupThousands ? "n" : "f" ), flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region e - exponent number
case 'e': // double / exponent
w = FormatNumber( "e", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region E - exponent number
case 'E': // double / exponent
w = FormatNumber( "E", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region g - general number
case 'g': // double / exponent
w = FormatNumber( "g", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region G - general number
case 'G': // double / exponent
w = FormatNumber( "G", flagAlternate,
fieldLength, fieldPrecision, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, o );
defaultParamIx++;
break;
#endregion
#region p - pointer
case 'p': // pointer
if ( o is IntPtr )
w = "0x" + ( (IntPtr)o ).ToString( "x" );
defaultParamIx++;
break;
#endregion
#region n - number of processed chars so far
case 'n': // number of characters so far
w = FormatNumber( "d", flagAlternate,
fieldLength, int.MinValue, flagLeft2Right,
flagPositiveSign, flagPositiveSpace,
paddingCharacter, m.Index );
break;
#endregion
default:
w = String.Empty;
defaultParamIx++;
break;
}
// replace format parameter with parameter value
// and start searching for the next format parameter
// AFTER the position of the current inserted value
// to prohibit recursive matches if the value also
// includes a format specifier
f.Remove( m.Index, m.Length );
f.Insert( m.Index, w );
m = r.Match( f.ToString(), m.Index + w.Length );
}
return f.ToString();
}
#endregion
#endregion
#region Private Methods
#region FormatOCT
private static string FormatOct( string NativeFormat, bool Alternate,
int FieldLength, int FieldPrecision,
bool Left2Right,
char Padding, object Value )
{
string w = String.Empty;
string lengthFormat = "{0" + ( FieldLength != int.MinValue ?
"," + ( Left2Right ?
"-" :
String.Empty ) + FieldLength.ToString() :
String.Empty ) + "}";
if ( IsNumericType( Value ) )
{
w = Convert.ToString( UnboxToLong( Value, true ), 8 );
if ( Left2Right || Padding == ' ' )
{
if ( Alternate && w != "0" )
w = "0" + w;
w = String.Format( lengthFormat, w );
}
else
{
if ( FieldLength != int.MinValue )
w = w.PadLeft( FieldLength - ( Alternate && w != "0" ? 1 : 0 ), Padding );
if ( Alternate && w != "0" )
w = "0" + w;
}
}
return w;
}
#endregion
#region FormatHEX
private static string FormatHex( string NativeFormat, bool Alternate,
int FieldLength, int FieldPrecision,
bool Left2Right,
char Padding, object Value )
{
string w = String.Empty;
string lengthFormat = "{0" + ( FieldLength != int.MinValue ?
"," + ( Left2Right ?
"-" :
String.Empty ) + FieldLength.ToString() :
String.Empty ) + "}";
string numberFormat = "{0:" + NativeFormat + ( FieldPrecision != int.MinValue ?
FieldPrecision.ToString() :
String.Empty ) + "}";
if ( IsNumericType( Value ) )
{
w = String.Format( numberFormat, Value );
if ( Left2Right || Padding == ' ' )
{
if ( Alternate )
w = ( NativeFormat == "x" ? "0x" : "0X" ) + w;
w = String.Format( lengthFormat, w );
}
else
{
if ( FieldLength != int.MinValue )
w = w.PadLeft( FieldLength - ( Alternate ? 2 : 0 ), Padding );
if ( Alternate )
w = ( NativeFormat == "x" ? "0x" : "0X" ) + w;
}
}
return w;
}
#endregion
#region FormatNumber
private static string FormatNumber( string NativeFormat, bool Alternate,
int FieldLength, int FieldPrecision,
bool Left2Right,
bool PositiveSign, bool PositiveSpace,
char Padding, object Value )
{
string w = String.Empty;
string lengthFormat = "{0" + ( FieldLength != int.MinValue ?
"," + ( Left2Right ?
"-" :
String.Empty ) + FieldLength.ToString() :
String.Empty ) + "}";
string numberFormat = "{0:" + NativeFormat + ( FieldPrecision != int.MinValue ?
FieldPrecision.ToString() :
"0" ) + "}";
if ( IsNumericType( Value ) )
{
w = String.Format( numberFormat, Value );
if ( Left2Right || Padding == ' ' )
{
if ( IsPositive( Value, true ) )
w = ( PositiveSign ?
"+" : ( PositiveSpace ? " " : String.Empty ) ) + w;
w = String.Format( lengthFormat, w );
}
else
{
if ( w.StartsWith( "-" ) )
w = w.Substring( 1 );
if ( FieldLength != int.MinValue )
w = w.PadLeft( FieldLength - 1, Padding );
if ( IsPositive( Value, true ) )
w = ( PositiveSign ?
"+" : ( PositiveSpace ?
" " : ( FieldLength != int.MinValue ?
Padding.ToString() : String.Empty ) ) ) + w;
else
w = "-" + w;
}
}
return w;
}
#endregion
#endregion
}
}

@ -0,0 +1,21 @@
using DFHack;
using System.Collections.Generic;
using UnityEngine;
public class TestScript : MonoBehaviour {
RemoteClient remoteClient = new RemoteClient();
// Use this for initialization
void Start () {
if (!remoteClient.connect())
Debug.LogError("Could not connect");
else
{
remoteClient.run_command("ls", new List<string>());
}
}
// Update is called once per frame
void Update () {
}
}

@ -1 +1 @@
Subproject commit 24d29ef54a4f60efb26fd9608c5cb11dfcd4d940
Subproject commit 42736fe494e7edeb884caa45a8669996a0eafb11

@ -13,6 +13,7 @@ endif()
OPTION(BUILD_ISOWORLD "Build isoworld (needs a checkout first)." OFF)
if(BUILD_ISOWORLD)
DFHACK_PLUGIN(isoworldremote isoworldremote.cpp PROTOBUFS isoworldremote)
add_subdirectory (isoworld)
IF(UNIX)
if (APPLE)
@ -148,7 +149,6 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(trueTransformation trueTransformation.cpp)
DFHACK_PLUGIN(infiniteSky infiniteSky.cpp)
DFHACK_PLUGIN(createitem createitem.cpp)
DFHACK_PLUGIN(isoworldremote isoworldremote.cpp PROTOBUFS isoworldremote)
DFHACK_PLUGIN(buildingplan buildingplan.cpp)
DFHACK_PLUGIN(resume resume.cpp)
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
@ -164,3 +164,7 @@ OPTION(BUILD_SKELETON "Build the skeleton plugin." OFF)
if(BUILD_SKELETON)
add_subdirectory(skeleton)
endif()
OPTION(BUILD_RENDERMAX "Build the rendermax alt-renderers plugin." OFF)
if(BUILD_RENDERMAX)
add_subdirectory(rendermax)
endif()

@ -1 +1 @@
Subproject commit aa3b1bd51f269c07b3235392fd7ed21fe9171f3f
Subproject commit 29fad1ef8e7e2aceb2e68c93a3993933168fe885

@ -0,0 +1,4 @@
local _ENV = mkmodule('plugins.rendermax')
return _ENV

@ -0,0 +1,37 @@
PROJECT (rendermax)
# A list of source files
SET(PROJECT_SRCS
rendermax.cpp
renderer_light.cpp
)
# A list of headers
SET(PROJECT_HDRS
renderer_opengl.hpp
renderer_light.hpp
)
SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE)
# mash them together (headers are marked as headers and nothing will try to compile them)
LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS})
#linux
IF(UNIX)
add_definitions(-DLINUX_BUILD)
SET(PROJECT_LIBS
# add any extra linux libs here
lua
${PROJECT_LIBS}
)
# windows
ELSE(UNIX)
SET(PROJECT_LIBS
# add any extra windows libs here
lua
${PROJECT_LIBS}
$(NOINHERIT)
)
ENDIF(UNIX)
# this makes sure all the stuff is put in proper places and linked to dfhack
DFHACK_PLUGIN(rendermax ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS})

@ -0,0 +1,506 @@
#include "renderer_light.hpp"
#include <functional>
#include <string>
#include "Types.h"
#include "modules/Gui.h"
#include "modules/Screen.h"
#include "modules/Maps.h"
#include "df/graphic.h"
#include "df/viewscreen_dwarfmodest.h"
#include "df/flow_info.h"
#include "df/world.h"
#include "df/building.h"
#include "df/building_doorst.h"
#include "df/plant.h"
#include "df/plant_raw.h"
using df::global::gps;
using namespace DFHack;
using df::coord2d;
const float levelDim=0.2f;
rect2d getMapViewport()
{
const int AREA_MAP_WIDTH = 23;
const int MENU_WIDTH = 30;
if(!gps || !df::viewscreen_dwarfmodest::_identity.is_instance(DFHack::Gui::getCurViewscreen()))
return mkrect_wh(0,0,0,0);
int w=gps->dimx;
int h=gps->dimy;
int view_height=h-2;
int area_x2 = w-AREA_MAP_WIDTH-2;
int menu_x2=w-MENU_WIDTH-2;
int menu_x1=area_x2-MENU_WIDTH-1;
int view_rb=w-1;
int area_pos=*df::global::ui_area_map_width;
int menu_pos=*df::global::ui_menu_width;
if(area_pos<3)
{
view_rb=area_x2;
}
if (menu_pos<area_pos || df::global::ui->main.mode!=0)
{
if (menu_pos >= area_pos)
menu_pos = area_pos-1;
int menu_x = menu_x2;
if(menu_pos < 2) menu_x = menu_x1;
view_rb = menu_x;
}
return mkrect_wh(1,1,view_rb,view_height+1);
}
lightingEngineViewscreen::lightingEngineViewscreen(renderer_light* target):lightingEngine(target)
{
reinit();
initRawSpecific();
}
void lightingEngineViewscreen::reinit()
{
if(!gps)
return;
w=gps->dimx;
h=gps->dimy;
size_t size=w*h;
lightMap.resize(size,lightCell(1,1,1));
ocupancy.resize(size);
lights.resize(size);
}
void plotCircle(int xm, int ym, int r,std::function<void(int,int)> setPixel)
{
int x = -r, y = 0, err = 2-2*r; /* II. Quadrant */
do {
setPixel(xm-x, ym+y); /* I. Quadrant */
setPixel(xm-y, ym-x); /* II. Quadrant */
setPixel(xm+x, ym-y); /* III. Quadrant */
setPixel(xm+y, ym+x); /* IV. Quadrant */
r = err;
if (r <= y) err += ++y*2+1; /* e_xy+e_y < 0 */
if (r > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */
} while (x < 0);
}
void plotLine(int x0, int y0, int x1, int y1,std::function<bool(int,int,int,int)> setPixel)
{
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
int dy = -abs(y1-y0), sy = y0<y1 ? 1 : -1;
int err = dx+dy, e2; /* error value e_xy */
int rdx=0;
int rdy=0;
for(;;){ /* loop */
if(!setPixel(rdx,rdy,x0,y0))
return;
if (x0==x1 && y0==y1) break;
e2 = 2*err;
rdx=rdy=0;
if (e2 >= dy) { err += dy; x0 += sx; rdx=sx;} /* e_xy+e_x > 0 */
if (e2 <= dx) { err += dx; y0 += sy; rdy=sy;} /* e_xy+e_y < 0 */
}
}
lightCell blend(lightCell a,lightCell b)
{
return lightCell(std::max(a.r,b.r),std::max(a.g,b.g),std::max(a.b,b.b));
}
bool lightingEngineViewscreen::lightUpCell(lightCell& power,int dx,int dy,int tx,int ty)
{
if(tx>=mapPort.first.x && ty>=mapPort.first.y && tx<=mapPort.second.x && ty<=mapPort.second.y)
{
size_t tile=getIndex(tx,ty);
float dsq=dx*dx+dy*dy;
float dt=sqrt(dsq);
lightCell& v=ocupancy[tile];
lightSource& ls=lights[tile];
bool wallhack=false;
if(v.r+v.g+v.b==0)
wallhack=true;
if (dsq>0 && !wallhack)
{
power.r=power.r*(pow(v.r,dt));
power.g=power.g*(pow(v.g,dt));
power.b=power.b*(pow(v.b,dt));
}
if(ls.radius>0 && dsq>0)
{
if(power<ls.power)
return false;
}
//float dt=sqrt(dsq);
lightCell oldCol=lightMap[tile];
lightCell ncol=blend(power,oldCol);
lightMap[tile]=ncol;
if(wallhack)
return false;
float pwsq=power.r*power.r+power.g*power.g+power.b*power.b;
return pwsq>levelDim*levelDim;
}
else
return false;
}
void lightingEngineViewscreen::doRay(lightCell power,int cx,int cy,int tx,int ty)
{
using namespace std::placeholders;
lightCell curPower=power;
plotLine(cx,cy,tx,ty,std::bind(&lightingEngineViewscreen::lightUpCell,this,std::ref(curPower),_1,_2,_3,_4));
}
void lightingEngineViewscreen::doFovs()
{
mapPort=getMapViewport();
using namespace std::placeholders;
for(int i=mapPort.first.x;i<mapPort.second.x;i++)
for(int j=mapPort.first.y;j<mapPort.second.y;j++)
{
lightSource& csource=lights[getIndex(i,j)];
if(csource.radius>0)
{
lightCell power=csource.power;
int radius =csource.radius;
if(csource.flicker)
{
float flicker=(rand()/(float)RAND_MAX)/2.0f+0.5f;
radius*=flicker;
power=power*flicker;
}
plotCircle(i,j,radius,
std::bind(&lightingEngineViewscreen::doRay,this,power,i,j,_1,_2));
}
}
}
void lightingEngineViewscreen::calculate()
{
rect2d vp=getMapViewport();
const lightCell dim(levelDim,levelDim,levelDim);
lightMap.assign(lightMap.size(),lightCell(1,1,1));
lights.assign(lights.size(),lightSource());
for(int i=vp.first.x;i<vp.second.x;i++)
for(int j=vp.first.y;j<vp.second.y;j++)
{
lightMap[getIndex(i,j)]=dim;
}
doOcupancyAndLights();
doFovs();
//for each lightsource in viewscreen+x do light
}
void lightingEngineViewscreen::updateWindow()
{
tthread::lock_guard<tthread::fast_mutex> guard(myRenderer->dataMutex);
if(lightMap.size()!=myRenderer->lightGrid.size())
{
reinit();
myRenderer->invalidate();
return;
}
std::swap(lightMap,myRenderer->lightGrid);
rect2d vp=getMapViewport();
//myRenderer->invalidateRect(vp.first.x,vp.first.y,vp.second.x-vp.first.x,vp.second.y-vp.first.y);
myRenderer->invalidate();
//std::copy(lightMap.begin(),lightMap.end(),myRenderer->lightGrid.begin());
}
void lightSource::combine(const lightSource& other)
{
power=blend(power,other.power);
radius=std::max(other.radius,radius);//hack... but who cares
}
bool lightingEngineViewscreen::addLight(int tileId,const lightSource& light)
{
bool wasLight=lights[tileId].radius>0;
lights[tileId].combine(light);
if(light.flicker)
lights[tileId].flicker=true;
return wasLight;
}
lightCell getStandartColor(int colorId)
{
return lightCell(df::global::enabler->ccolor[colorId][0]/255.0f,
df::global::enabler->ccolor[colorId][1]/255.0f,
df::global::enabler->ccolor[colorId][2]/255.0f);
}
int getPlantNumber(const std::string& id)
{
std::vector<df::plant_raw*>& vec=df::plant_raw::get_vector();
for(int i=0;i<vec.size();i++)
{
if(vec[i]->id==id)
return i;
}
return -1;
}
void addPlant(const std::string& id,std::map<int,lightSource>& map,const lightSource& v)
{
int nId=getPlantNumber(id);
if(nId>0)
{
map[nId]=v;
}
}
void lightingEngineViewscreen::initRawSpecific()
{
addPlant("TOWER_CAP",glowPlants,lightSource(lightCell(0.65,0.65,0.65),6));
addPlant("MUSHROOM_CUP_DIMPLE",glowPlants,lightSource(lightCell(0.03,0.03,0.5),3));
addPlant("CAVE MOSS",glowPlants,lightSource(lightCell(0.1,0.1,0.4),2));
addPlant("MUSHROOM_HELMET_PLUMP",glowPlants,lightSource(lightCell(0.2,0.1,0.6),2));
}
static size_t max_list_size = 100000; // Avoid iterating over huge lists
void lightingEngineViewscreen::doOcupancyAndLights()
{
lightSource sun(lightCell(1,1,1),15);
lightSource lava(lightCell(0.8f,0.2f,0.2f),5);
lightSource candle(lightCell(0.96f,0.84f,0.03f),5);
lightSource torch(lightCell(0.9f,0.75f,0.3f),8);
rect2d vp=getMapViewport();
int window_x=*df::global::window_x;
int window_y=*df::global::window_y;
int window_z=*df::global::window_z;
int vpW=vp.second.x-vp.first.x;
int vpH=vp.second.y-vp.first.y;
int endBlockx = (window_x+vpW)/16;
int endBlocky = (window_y+vpH)/16;
if(endBlockx >= df::global::world->map.x_count_block) endBlockx = df::global::world->map.x_count_block-1;
if(endBlocky >= df::global::world->map.y_count_block) endBlocky = df::global::world->map.y_count_block-1;
for(int blockx=window_x/16;blockx<=endBlockx;blockx++)
for(int blocky=window_y/16;blocky<=endBlocky;blocky++)
{
lightCell cellArray[16][16];
for(int block_x = 0; block_x < 16; block_x++)
for(int block_y = 0; block_y < 16; block_y++)
{
cellArray[block_x][block_y] = lightCell(1,1,1);
}
int totalBlank = 0;
int topLevel = df::global::world->map.z_count-1;
for(int ZZ = topLevel; (ZZ >= window_z) && totalBlank < 256; ZZ--)
{
df::map_block* block=Maps::getBlock(blockx,blocky,ZZ);
totalBlank = 0;
if(block)
for(int block_x = 0; block_x < 16; block_x++)
for(int block_y = 0; block_y < 16; block_y++)
{
df::tiletype type = block->tiletype[block_x][block_y];
df::tile_designation d = block->designation[block_x][block_y];
df::tile_occupancy o = block->occupancy[block_x][block_y];
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,type);
df::tiletype_shape_basic basic_shape = ENUM_ATTR(tiletype_shape, basic_shape, shape);
if(basic_shape==df::tiletype_shape_basic::Wall)
{
cellArray[block_x][block_y]=lightCell(0,0,0);
}
else if(basic_shape==df::tiletype_shape_basic::Floor || basic_shape==df::tiletype_shape_basic::Ramp || basic_shape==df::tiletype_shape_basic::Stair)
{
if(ZZ!=window_z)
{
cellArray[block_x][block_y]=lightCell(0,0,0);
}
}
if(d.bits.liquid_type == df::enums::tile_liquid::Water && d.bits.flow_size)
{
cellArray[block_x][block_y] *= (lightCell(1,1,1) - (lightCell(1,1,1) - lightCell(0.63f,0.63f,0.75f))*(d.bits.flow_size/7));
}
else if(d.bits.liquid_type == df::enums::tile_liquid::Magma && d.bits.flow_size > 3)
{
cellArray[block_x][block_y]=lightCell(0,0,0);
}
if(cellArray[block_x][block_y].r < 0.003f && cellArray[block_x][block_y].g < 0.003f && cellArray[block_x][block_y].b < 0.003f)
totalBlank++;
}
}
for(int block_x = 0; block_x < 16; block_x++)
for(int block_y = 0; block_y < 16; block_y++)
{
df::coord2d pos;
pos.x = blockx*16+block_x;
pos.y = blocky*16+block_y;
int wx=pos.x-window_x+vp.first.x;
int wy=pos.y-window_y+vp.first.y;
if(wx>=vp.first.x && wy>=vp.first.y && wx<=vp.second.x && wy<=vp.second.y)
if(cellArray[block_x][block_y].r >= 0.003f && cellArray[block_x][block_y].g >= 0.003f && cellArray[block_x][block_y].b >= 0.003f)
{
lightSource sun=lightSource(cellArray[block_x][block_y],15);
addLight(getIndex(wx,wy),sun);
}
}
}
for(int x=window_x;x<window_x+vpW;x++)
for(int y=window_y;y<window_y+vpH;y++)
{
int wx=x-window_x+vp.first.x;
int wy=y-window_y+vp.first.y;
int tile=getIndex(wx,wy);
lightCell& curCell=ocupancy[tile];
curCell=lightCell(0.85f,0.85f,0.85f);
df::tiletype* type = Maps::getTileType(x,y,window_z);
if(!type)
{
//unallocated, do sky
addLight(tile,sun);
continue;
}
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,*type);
df::tile_designation* d=Maps::getTileDesignation(x,y,window_z);
df::tile_designation* d2=Maps::getTileDesignation(x,y,window_z-1);
df::tile_occupancy* o=Maps::getTileOccupancy(x,y,window_z);
df::tiletype_material m=ENUM_ATTR(tiletype,material,*type);
if(!o || !d )
continue;
if(shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::WALL || shape==df::tiletype_shape::TREE || d->bits.hidden )
{
if(shape==df::tiletype_shape::WALL && m==df::tiletype_material::FROZEN_LIQUID)
curCell*=lightCell(0.7,0.7,0.9);
else
curCell=lightCell(0,0,0);
}
else if(o->bits.building)
{
// Fixme: don't iterate the list every frame
size_t count = df::global::world->buildings.all.size();
if (count <= max_list_size)
{
for(size_t i = 0; i < count; i++)
{
df::building *bld = df::global::world->buildings.all[i];
if (window_z == bld->z &&
x >= bld->x1 && x <= bld->x2 &&
y >= bld->y1 && y <= bld->y2)
{
df::building_type type = bld->getType();
if (type == df::enums::building_type::WindowGlass)
{
if(bld->mat_type == 3)//green glass
{
curCell*=lightCell(0.1f,0.9f,0.5f);
}
else if(bld->mat_type == 4)//clear glass
{
curCell*=lightCell(0.5f,0.95f,0.9f);
}
else if(bld->mat_type == 5)//crystal glass
{
curCell*=lightCell(0.75f,0.95f,0.95f);
}
}
if (type == df::enums::building_type::Table)
{
addLight(tile,candle);
}
if (type==df::enums::building_type::Statue)
{
addLight(tile,torch);
}
if (type==df::enums::building_type::WindowGem)
{
DFHack::MaterialInfo mat(bld->mat_index,bld->mat_type);
if(mat.isInorganic())
{
int color=mat.inorganic->material.basic_color[0]+8*mat.inorganic->material.basic_color[2];
curCell*=getStandartColor(color);
}
}
if(type==df::enums::building_type::Door)
{
df::building_doorst* door=static_cast<df::building_doorst*>(bld);
if(door->door_flags.bits.closed)
curCell*=lightCell(0,0,0);
}
}
}
}
}
else if(!d->bits.liquid_type && d->bits.flow_size>3 )
{
curCell*=lightCell(0.7f,0.7f,0.8f);
}
//lights
if((d->bits.liquid_type && d->bits.flow_size>0)||
(
(shape==df::tiletype_shape::EMPTY || shape==df::tiletype_shape::RAMP_TOP || shape==df::tiletype_shape::STAIR_DOWN || shape==df::tiletype_shape::STAIR_UPDOWN )
&& d2 && d2->bits.liquid_type && d2->bits.flow_size>0)
)
{
addLight(tile,lava);
}
if(d->bits.outside && d->bits.flow_size==0)
{
addLight(tile,sun);
}
}
for(int blockx=window_x/16;blockx<=endBlockx;blockx++)
for(int blocky=window_y/16;blocky<=endBlocky;blocky++)
{
df::map_block* block=Maps::getBlock(blockx,blocky,window_z);
if(!block)
continue;
for(int i=0;i<block->flows.size();i++)
{
df::flow_info* f=block->flows[i];
if(f && f->density>0 && f->type==df::flow_type::Dragonfire || f->type==df::flow_type::Fire)
{
df::coord2d pos=f->pos;
int wx=pos.x-window_x+vp.first.x;
int wy=pos.y-window_y+vp.first.y;
int tile=getIndex(wx,wy);
if(wx>=vp.first.x && wy>=vp.first.y && wx<=vp.second.x && wy<=vp.second.y)
{
lightCell fireColor;
if(f->density>60)
{
fireColor=lightCell(0.98f,0.91f,0.30f);
}
else if(f->density>30)
{
fireColor=lightCell(0.93f,0.16f,0.16f);
}
else
{
fireColor=lightCell(0.64f,0.0f,0.0f);
}
lightSource fire(fireColor,f->density/5);
addLight(tile,fire);
}
}
}
for(int i=0;i<block->plants.size();i++)
{
df::plant* cPlant=block->plants[i];
df::coord2d pos=cPlant->pos;
int wx=pos.x-window_x+vp.first.x;
int wy=pos.y-window_y+vp.first.y;
int tile=getIndex(wx,wy);
if(wx>=vp.first.x && wy>=vp.first.y && wx<=vp.second.x && wy<=vp.second.y)
{
auto it=glowPlants.find(cPlant->material);
if(it!=glowPlants.end())
{
addLight(tile,it->second);
}
}
}
}
if(df::global::cursor->x>-30000)
{
lightSource cursor(lightCell(0.96f,0.84f,0.03f),11);
cursor.flicker=true;
int wx=df::global::cursor->x-window_x+vp.first.x;
int wy=df::global::cursor->y-window_y+vp.first.y;
int tile=getIndex(wx,wy);
addLight(tile,cursor);
}
}

@ -0,0 +1,130 @@
#ifndef RENDERER_LIGHT_INCLUDED
#define RENDERER_LIGHT_INCLUDED
#include "renderer_opengl.hpp"
#include "Types.h"
#include <map>
struct renderer_light : public renderer_wrap {
private:
void colorizeTile(int x,int y)
{
const int tile = x*(df::global::gps->dimy) + y;
old_opengl* p=reinterpret_cast<old_opengl*>(parent);
float *fg = p->fg + tile * 4 * 6;
float *bg = p->bg + tile * 4 * 6;
float *tex = p->tex + tile * 2 * 6;
lightCell light=lightGrid[tile];
for (int i = 0; i < 6; i++) {
*(fg++) *= light.r;
*(fg++) *= light.g;
*(fg++) *= light.b;
*(fg++) = 1;
*(bg++) *= light.r;
*(bg++) *= light.g;
*(bg++) *= light.b;
*(bg++) = 1;
}
}
void reinitLightGrid(int w,int h)
{
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
lightGrid.resize(w*h);
}
void reinitLightGrid()
{
reinitLightGrid(df::global::gps->dimy,df::global::gps->dimx);
}
public:
tthread::fast_mutex dataMutex;
std::vector<lightCell> lightGrid;
renderer_light(renderer* parent):renderer_wrap(parent)
{
reinitLightGrid();
}
virtual void update_tile(int32_t x, int32_t y) {
renderer_wrap::update_tile(x,y);
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
colorizeTile(x,y);
};
virtual void update_all() {
renderer_wrap::update_all();
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
for (int x = 0; x < df::global::gps->dimx; x++)
for (int y = 0; y < df::global::gps->dimy; y++)
colorizeTile(x,y);
};
virtual void grid_resize(int32_t w, int32_t h) {
renderer_wrap::grid_resize(w,h);
reinitLightGrid(w,h);
};
virtual void resize(int32_t w, int32_t h) {
renderer_wrap::resize(w,h);
reinitLightGrid();
}
};
class lightingEngine
{
public:
lightingEngine(renderer_light* target):myRenderer(target){}
virtual void reinit()=0;
virtual void calculate()=0;
virtual void updateWindow()=0;
protected:
renderer_light* myRenderer;
};
struct lightSource
{
lightCell power;
int radius;
bool flicker;
lightSource():power(0,0,0),radius(0),flicker(false)
{
}
lightSource(lightCell power,int radius):power(power),radius(radius),flicker(false)
{
}
float powerSquared()const
{
return power.r*power.r+power.g*power.g+power.b*power.b;
}
void combine(const lightSource& other);
};
class lightingEngineViewscreen:public lightingEngine
{
public:
lightingEngineViewscreen(renderer_light* target);
void reinit();
void calculate();
void updateWindow();
private:
void doOcupancyAndLights();
void doRay(lightCell power,int cx,int cy,int tx,int ty);
void doFovs();
bool lightUpCell(lightCell& power,int dx,int dy,int tx,int ty);
bool addLight(int tileId,const lightSource& light);
void initRawSpecific();
size_t inline getIndex(int x,int y)
{
return x*h+y;
}
std::vector<lightCell> lightMap;
std::vector<lightCell> ocupancy;
std::vector<lightSource> lights;
std::map<int,lightSource> glowPlants;
std::map<int,lightSource> glowVeins;
int w,h;
DFHack::rect2d mapPort;
};
#endif

@ -0,0 +1,377 @@
//original file from https://github.com/Baughn/Dwarf-Fortress--libgraphics-
#ifndef RENDERER_OPENGL_INCLUDED
#define RENDERER_OPENGL_INCLUDED
#include "tinythread.h"
#include "fast_mutex.h"
#include "Core.h"
#include <VTableInterpose.h>
#include "df/renderer.h"
#include "df/init.h"
#include "df/enabler.h"
#include "df/zoom_commands.h"
#include "df/texture_handler.h"
#include "df/graphic.h"
using df::renderer;
using df::init;
using df::enabler;
struct old_opengl:public renderer
{
void* sdlSurface;
int32_t dispx,dispy;
float *vertexes, *fg, *bg, *tex;
int32_t zoom_steps,forced_steps,natural_w,natural_h;
int32_t off_x,off_y,size_x,size_y;
};
struct renderer_wrap : public renderer {
private:
void set_to_null() {
screen = NULL;
screentexpos = NULL;
screentexpos_addcolor = NULL;
screentexpos_grayscale = NULL;
screentexpos_cf = NULL;
screentexpos_cbr = NULL;
screen_old = NULL;
screentexpos_old = NULL;
screentexpos_addcolor_old = NULL;
screentexpos_grayscale_old = NULL;
screentexpos_cf_old = NULL;
screentexpos_cbr_old = NULL;
}
void copy_from_inner() {
screen = parent->screen;
screentexpos = parent->screentexpos;
screentexpos_addcolor = parent->screentexpos_addcolor;
screentexpos_grayscale = parent->screentexpos_grayscale;
screentexpos_cf = parent->screentexpos_cf;
screentexpos_cbr = parent->screentexpos_cbr;
screen_old = parent->screen_old;
screentexpos_old = parent->screentexpos_old;
screentexpos_addcolor_old = parent->screentexpos_addcolor_old;
screentexpos_grayscale_old = parent->screentexpos_grayscale_old;
screentexpos_cf_old = parent->screentexpos_cf_old;
screentexpos_cbr_old = parent->screentexpos_cbr_old;
}
void copy_to_inner() {
parent->screen = screen;
parent->screentexpos = screentexpos;
parent->screentexpos_addcolor = screentexpos_addcolor;
parent->screentexpos_grayscale = screentexpos_grayscale;
parent->screentexpos_cf = screentexpos_cf;
parent->screentexpos_cbr = screentexpos_cbr;
parent->screen_old = screen_old;
parent->screentexpos_old = screentexpos_old;
parent->screentexpos_addcolor_old = screentexpos_addcolor_old;
parent->screentexpos_grayscale_old = screentexpos_grayscale_old;
parent->screentexpos_cf_old = screentexpos_cf_old;
parent->screentexpos_cbr_old = screentexpos_cbr_old;
}
public:
renderer_wrap(renderer* parent):parent(parent)
{
copy_from_inner();
}
virtual void update_tile(int32_t x, int32_t y) {
copy_to_inner();
parent->update_tile(x,y);
};
virtual void update_all() {
copy_to_inner();
parent->update_all();
};
virtual void render() {
copy_to_inner();
parent->render();
};
virtual void set_fullscreen() {
copy_to_inner();
parent->set_fullscreen();
};
virtual void zoom(df::zoom_commands z) {
copy_to_inner();
parent->zoom(z);
};
virtual void resize(int32_t w, int32_t h) {
copy_to_inner();
parent->resize(w,h);
copy_from_inner();
};
virtual void grid_resize(int32_t w, int32_t h) {
copy_to_inner();
parent->grid_resize(w,h);
copy_from_inner();
};
virtual ~renderer_wrap() {
df::global::enabler->renderer=parent;
};
virtual bool get_mouse_coords(int32_t* x, int32_t* y) {
return parent->get_mouse_coords(x,y);
};
virtual bool uses_opengl() {
return parent->uses_opengl();
};
void invalidateRect(int32_t x,int32_t y,int32_t w,int32_t h)
{
for(int i=x;i<x+w;i++)
for(int j=y;j<y+h;j++)
{
int index=i*df::global::gps->dimy + j;
screen_old[index*4]=0;
}
};
void invalidate()
{
//invalidateRect(0,0,df::global::gps->dimx,df::global::gps->dimy);
df::global::gps->force_full_display_count++;
};
protected:
renderer* parent;
};
struct renderer_trippy : public renderer_wrap {
private:
float rFloat()
{
return rand()/(float)RAND_MAX;
}
void colorizeTile(int x,int y)
{
const int tile = x*(df::global::gps->dimy) + y;
old_opengl* p=reinterpret_cast<old_opengl*>(parent);
float *fg = p->fg + tile * 4 * 6;
float *bg = p->bg + tile * 4 * 6;
float *tex = p->tex + tile * 2 * 6;
const float val=1/2.0;
float r=rFloat()*val - val/2;
float g=rFloat()*val - val/2;
float b=rFloat()*val - val/2;
float backr=rFloat()*val - val/2;
float backg=rFloat()*val - val/2;
float backb=rFloat()*val - val/2;
for (int i = 0; i < 6; i++) {
*(fg++) += r;
*(fg++) += g;
*(fg++) += b;
*(fg++) = 1;
*(bg++) += backr;
*(bg++) += backg;
*(bg++) += backb;
*(bg++) = 1;
}
}
public:
renderer_trippy(renderer* parent):renderer_wrap(parent)
{
}
virtual void update_tile(int32_t x, int32_t y) {
renderer_wrap::update_tile(x,y);
colorizeTile(x,y);
};
virtual void update_all() {
renderer_wrap::update_all();
for (int x = 0; x < df::global::gps->dimx; x++)
for (int y = 0; y < df::global::gps->dimy; y++)
colorizeTile(x,y);
};
};
struct lightCell
{
float r,g,b;
lightCell():r(0),g(0),b(0)
{
}
lightCell(float r,float g,float b):r(r),g(g),b(b)
{
}
lightCell operator-(lightCell cell)
{
return lightCell(r-cell.r,g-cell.g,b-cell.b);
}
lightCell operator*(float val)
{
return lightCell(r*val,g*val,b*val);
}
lightCell operator/(float val)
{
return lightCell(r/val,g/val,b/val);
}
lightCell operator*(lightCell cell)
{
return lightCell(r*cell.r,g*cell.g,b*cell.b);
}
lightCell operator*=(lightCell cell)
{
r*=cell.r;
g*=cell.g;
b*=cell.b;
return lightCell(r,g,b);
}
lightCell operator+(const lightCell& other)
{
return lightCell(r+other.r,g+other.g,b+other.b);
}
bool operator<(const lightCell& other)
{
return r<other.r && g<other.g && b<other.b;
}
};
struct renderer_test : public renderer_wrap {
private:
void colorizeTile(int x,int y)
{
const int tile = x*(df::global::gps->dimy) + y;
old_opengl* p=reinterpret_cast<old_opengl*>(parent);
float *fg = p->fg + tile * 4 * 6;
float *bg = p->bg + tile * 4 * 6;
float *tex = p->tex + tile * 2 * 6;
lightCell light=lightGrid[tile];
for (int i = 0; i < 6; i++) {
*(fg++) *= light.r;
*(fg++) *= light.g;
*(fg++) *= light.b;
*(fg++) = 1;
*(bg++) *= light.r;
*(bg++) *= light.g;
*(bg++) *= light.b;
*(bg++) = 1;
}
}
void reinitLightGrid(int w,int h)
{
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
lightGrid.resize(w*h);
}
void reinitLightGrid()
{
reinitLightGrid(df::global::gps->dimy,df::global::gps->dimx);
}
public:
tthread::fast_mutex dataMutex;
std::vector<lightCell> lightGrid;
renderer_test(renderer* parent):renderer_wrap(parent)
{
reinitLightGrid();
}
virtual void update_tile(int32_t x, int32_t y) {
renderer_wrap::update_tile(x,y);
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
colorizeTile(x,y);
//some sort of mutex or sth?
//and then map read
};
virtual void update_all() {
renderer_wrap::update_all();
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
for (int x = 0; x < df::global::gps->dimx; x++)
for (int y = 0; y < df::global::gps->dimy; y++)
colorizeTile(x,y);
//some sort of mutex or sth?
//and then map read
//same stuff for all of them i guess...
};
virtual void grid_resize(int32_t w, int32_t h) {
renderer_wrap::grid_resize(w,h);
reinitLightGrid(w,h);
};
virtual void resize(int32_t w, int32_t h) {
renderer_wrap::resize(w,h);
reinitLightGrid(w,h);
}
};
struct rgba
{
float r,g,b,a;
};
struct renderer_lua : public renderer_wrap {
private:
void overwriteTile(int x,int y)
{
const int tile = xyToTile(x,y);
old_opengl* p=reinterpret_cast<old_opengl*>(parent);
float *fg = p->fg + tile * 4 * 6;
float *bg = p->bg + tile * 4 * 6;
float *tex = p->tex + tile * 2 * 6;
lightCell fm=foreMult[tile];
lightCell fo=foreOffset[tile];
lightCell bm=backMult[tile];
lightCell bo=backOffset[tile];
for (int i = 0; i < 6; i++) {
rgba* fore=reinterpret_cast<rgba*>(fg);
fore->r=fore->r*fm.r+fo.r;
fore->g=fore->g*fm.g+fo.g;
fore->b=fore->b*fm.b+fo.b;
fg+=4;
rgba* back=reinterpret_cast<rgba*>(bg);
back->r=back->r*bm.r+bo.r;
back->g=back->g*bm.g+bo.g;
back->b=back->b*bm.b+bo.b;
bg+=4;
}
}
void reinitGrids(int w,int h)
{
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
foreOffset.resize(w*h);
foreMult.resize(w*h);
backOffset.resize(w*h);
backMult.resize(w*h);
}
void reinitGrids()
{
reinitGrids(df::global::gps->dimy,df::global::gps->dimx);
}
public:
tthread::fast_mutex dataMutex;
std::vector<lightCell> foreOffset,foreMult;
std::vector<lightCell> backOffset,backMult;
inline int xyToTile(int x, int y)
{
return x*(df::global::gps->dimy) + y;
}
renderer_lua(renderer* parent):renderer_wrap(parent)
{
reinitGrids();
}
virtual void update_tile(int32_t x, int32_t y) {
renderer_wrap::update_tile(x,y);
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
overwriteTile(x,y);
//some sort of mutex or sth?
//and then map read
};
virtual void update_all() {
renderer_wrap::update_all();
tthread::lock_guard<tthread::fast_mutex> guard(dataMutex);
for (int x = 0; x < df::global::gps->dimx; x++)
for (int y = 0; y < df::global::gps->dimy; y++)
overwriteTile(x,y);
//some sort of mutex or sth?
//and then map read
//same stuff for all of them i guess...
};
virtual void grid_resize(int32_t w, int32_t h) {
renderer_wrap::grid_resize(w,h);
reinitGrids(w,h);
};
virtual void resize(int32_t w, int32_t h) {
renderer_wrap::resize(w,h);
reinitGrids(w,h);
}
};
#endif

@ -0,0 +1,351 @@
#include <vector>
#include <string>
#include <LuaTools.h>
#include "Core.h"
#include "Console.h"
#include "Export.h"
#include "PluginManager.h"
#include <VTableInterpose.h>
#include "df/renderer.h"
#include "df/enabler.h"
#include "renderer_opengl.hpp"
#include "renderer_light.hpp"
using namespace DFHack;
using std::vector;
using std::string;
enum RENDERER_MODE
{
MODE_DEFAULT,MODE_TRIPPY,MODE_TRUECOLOR,MODE_LUA,MODE_LIGHT,MODE_LIGHT_OFF
};
RENDERER_MODE current_mode=MODE_DEFAULT;
lightingEngine *engine=NULL;
static command_result rendermax(color_ostream &out, vector <string> & parameters);
DFHACK_PLUGIN("rendermax");
DFhackCExport command_result plugin_init (color_ostream &out, std::vector <PluginCommand> &commands)
{
commands.push_back(PluginCommand(
"rendermax", "switch rendering engine.", rendermax, false,
" rendermax trippy\n"
" rendermax truecolor red|green|blue|white\n"
" rendermax lua\n"
" rendermax light\n"
" rendermax disable\n"
));
return CR_OK;
}
void removeOld()
{
if(current_mode!=MODE_DEFAULT)
delete df::global::enabler->renderer;
current_mode=MODE_DEFAULT;
}
void installNew(df::renderer* r,RENDERER_MODE newMode)
{
df::global::enabler->renderer=r;
current_mode=newMode;
}
static void lockGrids()
{
if(current_mode!=MODE_LUA)
return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
r->dataMutex.lock();
}
static void unlockGrids()
{
if(current_mode!=MODE_LUA)
return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
r->dataMutex.unlock();
}
static void resetGrids()
{
if(current_mode!=MODE_LUA)
return ;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
for(size_t i=0;i<r->foreMult.size();i++)
{
r->foreMult[i]=lightCell(1,1,1);
r->foreOffset[i]=lightCell(0,0,0);
r->backMult[i]=lightCell(1,1,1);
r->backOffset[i]=lightCell(0,0,0);
}
}
static int getGridsSize(lua_State* L)
{
if(current_mode!=MODE_LUA)
return -1;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
lua_pushnumber(L,df::global::gps->dimx);
lua_pushnumber(L,df::global::gps->dimy);
return 2;
}
static int getCell(lua_State* L)
{
if(current_mode!=MODE_LUA)
return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
int x=luaL_checknumber(L,1);
int y=luaL_checknumber(L,2);
int id=r->xyToTile(x,y);
lightCell fo=r->foreOffset[id];
lightCell fm=r->foreMult[id];
lightCell bo=r->backOffset[id];
lightCell bm=r->backMult[id];
lua_newtable(L);
lua_newtable(L);
lua_pushnumber(L,fo.r);
lua_setfield(L,-2,"r");
lua_pushnumber(L,fo.g);
lua_setfield(L,-2,"g");
lua_pushnumber(L,fo.b);
lua_setfield(L,-2,"b");
lua_setfield(L,-2,"fo");
lua_newtable(L);
lua_pushnumber(L,fm.r);
lua_setfield(L,-2,"r");
lua_pushnumber(L,fm.g);
lua_setfield(L,-2,"g");
lua_pushnumber(L,fm.b);
lua_setfield(L,-2,"b");
lua_setfield(L,-2,"fm");
lua_newtable(L);
lua_pushnumber(L,bo.r);
lua_setfield(L,-2,"r");
lua_pushnumber(L,bo.g);
lua_setfield(L,-2,"g");
lua_pushnumber(L,bo.b);
lua_setfield(L,-2,"b");
lua_setfield(L,-2,"bo");
lua_newtable(L);
lua_pushnumber(L,bm.r);
lua_setfield(L,-2,"r");
lua_pushnumber(L,bm.g);
lua_setfield(L,-2,"g");
lua_pushnumber(L,bm.b);
lua_setfield(L,-2,"b");
lua_setfield(L,-2,"bm");
return 1;
}
static int setCell(lua_State* L)
{
if(current_mode!=MODE_LUA)
return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
int x=luaL_checknumber(L,1);
int y=luaL_checknumber(L,2);
lightCell fo;
lua_getfield(L,3,"fo");
lua_getfield(L,-1,"r");
fo.r=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"g");
fo.g=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"b");
fo.b=lua_tonumber(L,-1);lua_pop(L,1);
lightCell fm;
lua_getfield(L,3,"fm");
lua_getfield(L,-1,"r");
fm.r=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"g");
fm.g=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"b");
fm.b=lua_tonumber(L,-1);lua_pop(L,1);
lightCell bo;
lua_getfield(L,3,"bo");
lua_getfield(L,-1,"r");
bo.r=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"g");
bo.g=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"b");
bo.b=lua_tonumber(L,-1);lua_pop(L,1);
lightCell bm;
lua_getfield(L,3,"bm");
lua_getfield(L,-1,"r");
bm.r=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"g");
bm.g=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,-1,"b");
bm.b=lua_tonumber(L,-1);lua_pop(L,1);
int id=r->xyToTile(x,y);
r->foreMult[id]=fm;
r->foreOffset[id]=fo;
r->backMult[id]=bm;
r->backOffset[id]=bo;
return 0;
}
static int invalidate(lua_State* L)
{
if(current_mode!=MODE_LUA)
return 0;
renderer_lua* r=reinterpret_cast<renderer_lua*>(df::global::enabler->renderer);
if(lua_gettop(L)==0)
{
r->invalidate();
}
else
{
int x,y,w,h;
lua_getfield(L,1,"x");
x=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,1,"y");
y=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,1,"w");
w=lua_tonumber(L,-1);lua_pop(L,1);
lua_getfield(L,1,"h");
h=lua_tonumber(L,-1);lua_pop(L,1);
r->invalidateRect(x,y,w,h);
}
return 0;
}
bool isEnabled()
{
return current_mode==MODE_LUA;
}
DFHACK_PLUGIN_LUA_FUNCTIONS {
DFHACK_LUA_FUNCTION(isEnabled),
DFHACK_LUA_FUNCTION(lockGrids),
DFHACK_LUA_FUNCTION(unlockGrids),
DFHACK_LUA_FUNCTION(resetGrids),
DFHACK_LUA_END
};
DFHACK_PLUGIN_LUA_COMMANDS {
DFHACK_LUA_COMMAND(getCell),
DFHACK_LUA_COMMAND(setCell),
DFHACK_LUA_COMMAND(getGridsSize),
DFHACK_LUA_COMMAND(invalidate),
DFHACK_LUA_END
};
static command_result rendermax(color_ostream &out, vector <string> & parameters)
{
if(parameters.size()==0)
return CR_WRONG_USAGE;
if(!df::global::enabler->renderer->uses_opengl())
{
out.printerr("Sorry, this plugin needs open gl enabled printmode. Try STANDARD or other non-2d");
return CR_FAILURE;
}
string cmd=parameters[0];
if(cmd=="trippy")
{
removeOld();
installNew(new renderer_trippy(df::global::enabler->renderer),MODE_TRIPPY);
return CR_OK;
}
else if(cmd=="truecolor")
{
if(current_mode!=MODE_TRUECOLOR)
{
removeOld();
installNew(new renderer_test(df::global::enabler->renderer),MODE_TRUECOLOR);
}
if(current_mode==MODE_TRUECOLOR && parameters.size()==2)
{
lightCell red(1,0,0),green(0,1,0),blue(0,0,1),white(1,1,1);
lightCell cur=white;
lightCell dim(0.2f,0.2f,0.2f);
string col=parameters[1];
if(col=="red")
cur=red;
else if(col=="green")
cur=green;
else if(col=="blue")
cur=blue;
renderer_test* r=reinterpret_cast<renderer_test*>(df::global::enabler->renderer);
tthread::lock_guard<tthread::fast_mutex> guard(r->dataMutex);
int h=df::global::gps->dimy;
int w=df::global::gps->dimx;
int cx=w/2;
int cy=h/2;
int rad=cx;
if(rad>cy)rad=cy;
rad/=2;
int radsq=rad*rad;
for(size_t i=0;i<r->lightGrid.size();i++)
{
r->lightGrid[i]=dim;
}
for(int i=-rad;i<rad;i++)
for(int j=-rad;j<rad;j++)
{
if((i*i+j*j)<radsq)
{
float val=(radsq-i*i-j*j)/(float)radsq;
r->lightGrid[(cx+i)*h+(cy+j)]=dim+cur*val;
}
}
return CR_OK;
}
}
else if(cmd=="lua")
{
removeOld();
installNew(new renderer_lua(df::global::enabler->renderer),MODE_LUA);
lockGrids();
resetGrids();
unlockGrids();
return CR_OK;
}
else if(cmd=="light")
{
removeOld();
renderer_light *myRender=new renderer_light(df::global::enabler->renderer);
installNew(myRender,MODE_LIGHT);
engine=new lightingEngineViewscreen(myRender);
engine->calculate();
engine->updateWindow();
return CR_OK;
}
else if(cmd=="disable")
{
if(current_mode==MODE_DEFAULT)
out.print("%s\n","Not installed, doing nothing.");
else if(current_mode==MODE_LIGHT)
current_mode=MODE_LIGHT_OFF;
else
removeOld();
return CR_OK;
}
return CR_WRONG_USAGE;
}
DFhackCExport command_result plugin_onupdate (color_ostream &out)
{
if(engine)
{
if(current_mode==MODE_LIGHT_OFF)
{
delete engine;
engine=0;
removeOld();
}
else
{
engine->calculate();
engine->updateWindow();
}
}
return CR_OK;
}
DFhackCExport command_result plugin_shutdown(color_ostream &)
{
removeOld();
return CR_OK;
}

@ -24,7 +24,7 @@ IF(UNIX)
# windows
ELSE(UNIX)
SET(PROJECT_LIBS
# add any extra linux libs here
# add any extra windows libs here
${PROJECT_LIBS}
$(NOINHERIT)
)

@ -1 +1 @@
Subproject commit 0d41614ff3dae9245e786ad667b0e463fe0dea3e
Subproject commit bbbda97c1cdd3d2456097eca799cfc7cf3410aaf

@ -0,0 +1,377 @@
-- an experimental lighting engine for df. param: "static" to not recalc when in game. press "~" to recalculate. "`" to exit
local gui = require 'gui'
local guidm = require 'gui.dwarfmode'
local render = require 'plugins.rendermax'
local levelDim=0.05
local tile_attrs = df.tiletype.attrs
local args={...}
function setCell(x,y,cell)
cell=cell or {}
cell.fm=cell.fm or {r=1,g=1,b=1}
cell.bm=cell.bm or {r=1,g=1,b=1}
cell.fo=cell.fo or {r=0,g=0,b=0}
cell.bo=cell.bo or {r=0,g=0,b=0}
render.setCell(x,y,cell)
end
function getCursorPos()
local g_cursor=df.global.cursor
if g_cursor.x ~= -30000 then
return copyall(g_cursor)
end
end
function falloff(color,sqDist,maxdist)
local v1=1/(sqDist/maxdist+1)
local v2=v1-1/(1+maxdist*maxdist)
local v=v2/(1-1/(1+maxdist*maxdist))
return {r=v*color.r,g=v*color.g,b=v*color.b}
end
function blend(c1,c2)
return {r=math.max(c1.r,c2.r),
g=math.max(c1.g,c2.g),
b=math.max(c1.b,c2.b)}
end
LightOverlay=defclass(LightOverlay,guidm.DwarfOverlay)
LightOverlay.ATTRS {
lightMap={},
dynamic=true,
dirty=false,
}
function LightOverlay:init(args)
self.tick=df.global.cur_year_tick_advmode
end
function lightPassable(shape)
if shape==df.tiletype_shape.WALL or
shape==df.tiletype_shape.BROOK_BED or
shape==df.tiletype_shape.TREE then
return false
else
return true
end
end
function circle(xm, ym,r,plot)
local x = -r
local y = 0
local err = 2-2*r -- /* II. Quadrant */
repeat
plot(xm-x, ym+y);--/* I. Quadrant */
plot(xm-y, ym-x);--/* II. Quadrant */
plot(xm+x, ym-y);--/* III. Quadrant */
plot(xm+y, ym+x);--/* IV. Quadrant */
r = err;
if (r <= y) then
y=y+1
err =err+y*2+1; --/* e_xy+e_y < 0 */
end
if (r > x or err > y) then
x=x+1
err =err+x*2+1; --/* e_xy+e_x > 0 or no 2nd y-step */
end
until (x >= 0);
end
function line(x0, y0, x1, y1,plot)
local dx = math.abs(x1-x0)
local dy = math.abs(y1-y0)
local sx,sy
if x0 < x1 then sx = 1 else sx = -1 end
if y0 < y1 then sy = 1 else sy = -1 end
local err = dx-dy
while true do
if not plot(x0,y0) then
return
end
if x0 == x1 and y0 == y1 then
break
end
local e2 = 2*err
if e2 > -dy then
err = err - dy
x0 = x0 + sx
end
if x0 == x1 and y0 == y1 then
if not plot(x0,y0) then
return
end
break
end
if e2 < dx then
err = err + dx
y0 = y0 + sy
end
end
end
function LightOverlay:calculateFovs()
self.fovs=self.fovs or {}
self.precalc=self.precalc or {}
for k,v in ipairs(self.fovs) do
self:calculateFov(v.pos,v.radius,v.color)
end
end
function LightOverlay:calculateFov(pos,radius,color)
local vp=self:getViewport()
local map = self.df_layout.map
local ray=function(tx,ty)
local power=copyall(color)
local lx=pos.x
local ly=pos.y
local setTile=function(x,y)
if x>0 and y>0 and x<=map.width and y<=map.height then
local dtsq=(lx-x)*(lx-x)+(ly-y)*(ly-y)
local dt=math.sqrt(dtsq)
local tile=x+y*map.width
if self.precalc[tile] then
local tcol=blend(self.precalc[tile],power)
if tcol.r==self.precalc[tile].r and tcol.g==self.precalc[tile].g and self.precalc[tile].b==self.precalc[tile].b
and dtsq>0 then
return false
end
end
local ocol=self.lightMap[tile] or {r=0,g=0,b=0}
local ncol=blend(power,ocol)
self.lightMap[tile]=ncol
local v=self.ocupancy[tile]
if dtsq>0 then
power.r=power.r*(v.r^dt)
power.g=power.g*(v.g^dt)
power.b=power.b*(v.b^dt)
end
lx=x
ly=y
local pwsq=power.r*power.r+power.g*power.g+power.b*power.b
return pwsq>levelDim*levelDim
end
return false
end
line(pos.x,pos.y,tx,ty,setTile)
end
circle(pos.x,pos.y,radius,ray)
end
function LightOverlay:placeLightFov(pos,radius,color)
local map = self.df_layout.map
local tile=pos.x+pos.y*map.width
local ocol=self.precalc[tile] or {r=0,g=0,b=0}
local ncol=blend(color,ocol)
self.precalc[tile]=ncol
local ocol=self.lightMap[tile] or {r=0,g=0,b=0}
local ncol=blend(color,ocol)
self.lightMap[tile]=ncol
table.insert(self.fovs,{pos=pos,radius=radius,color=color})
end
function LightOverlay:placeLightFov2(pos,radius,color,f,rays)
f=f or falloff
local raycount=rays or 25
local vp=self:getViewport()
local map = self.df_layout.map
local off=math.random(0,math.pi)
local done={}
for d=0,math.pi*2,math.pi*2/raycount do
local dx,dy
dx=math.cos(d+off)
dy=math.sin(d+off)
local cx=0
local cy=0
for dt=0,radius,0.01 do
if math.abs(math.floor(dt*dx)-cx)>0 or math.abs(math.floor(dt*dy)-cy)> 0then
local x=cx+pos.x
local y=cy+pos.y
if x>0 and y>0 and x<=map.width and y<=map.height and not done[tile] then
local tile=x+y*map.width
done[tile]=true
local ncol=f(color,dt*dt,radius)
local ocol=self.lightMap[tile] or {r=0,g=0,b=0}
ncol=blend(ncol,ocol)
self.lightMap[tile]=ncol
if --(ncol.r==ocol.r and ncol.g==ocol.g and ncol.b==ocol.b) or
not self.ocupancy[tile] then
break
end
end
cx=math.floor(dt*dx)
cy=math.floor(dt*dy)
end
end
end
end
function LightOverlay:placeLight(pos,radius,color,f)
f=f or falloff
local vp=self:getViewport()
local map = self.df_layout.map
for i=-radius,radius do
for j=-radius,radius do
local x=pos.x+i+1
local y=pos.y+j+1
if x>0 and y>0 and x<=map.width and y<=map.height then
local tile=x+y*map.width
local ncol=f(color,(i*i+j*j),radius)
local ocol=self.lightMap[tile] or {r=0,g=0,b=0}
self.lightMap[tile]=blend(ncol,ocol)
end
end
end
end
function LightOverlay:calculateLightLava()
local vp=self:getViewport()
local map = self.df_layout.map
for i=map.x1,map.x2 do
for j=map.y1,map.y2 do
local pos={x=i+vp.x1-1,y=j+vp.y1-1,z=vp.z}
local pos2={x=i+vp.x1-1,y=j+vp.y1-1,z=vp.z-1}
local t1=dfhack.maps.getTileFlags(pos)
local tt=dfhack.maps.getTileType(pos)
if tt then
local shape=tile_attrs[tt].shape
local t2=dfhack.maps.getTileFlags(pos2)
if (t1 and t1.liquid_type and t1.flow_size>0) or
(shape==df.tiletype_shape.EMPTY and t2 and t2.liquid_type and t2.flow_size>0) then
--self:placeLight({x=i,y=j},5,{r=0.8,g=0.2,b=0.2})
self:placeLightFov({x=i,y=j},5,{r=0.8,g=0.2,b=0.2},nil)
end
end
end
end
end
function LightOverlay:calculateLightSun()
local vp=self:getViewport()
local map = self.df_layout.map
for i=map.x1,map.x2+1 do
for j=map.y1,map.y2+1 do
local pos={x=i+vp.x1-1,y=j+vp.y1-1,z=vp.z}
local t1=dfhack.maps.getTileFlags(pos)
if (t1 and t1.outside ) then
self:placeLightFov({x=i,y=j},15,{r=1,g=1,b=1},nil)
end
end
end
end
function LightOverlay:calculateLightCursor()
local c=getCursorPos()
if c then
local vp=self:getViewport()
local pos=vp:tileToScreen(c)
--self:placeLight(pos,11,{r=0.96,g=0.84,b=0.03})
self:placeLightFov({x=pos.x+1,y=pos.y+1},11,{r=0.96,g=0.84,b=0.03})
end
end
function LightOverlay:buildOcupancy()
self.ocupancy={}
local vp=self:getViewport()
local map = self.df_layout.map
for i=map.x1,map.x2+1 do
for j=map.y1,map.y2+1 do
local pos={x=i+vp.x1-1,y=j+vp.y1-1,z=vp.z}
local tile=i+j*map.width
local tt=dfhack.maps.getTileType(pos)
local t1=dfhack.maps.getTileFlags(pos)
if tt then
local shape=tile_attrs[tt].shape
if not lightPassable(shape) then
self.ocupancy[tile]={r=0,g=0,b=0}
else
if t1 and not t1.liquid_type and t1.flow_size>2 then
self.ocupancy[tile]={r=0.5,g=0.5,b=0.7}
else
self.ocupancy[tile]={r=0.8,g=0.8,b=0.8}
end
end
end
end
end
end
function LightOverlay:changed()
if self.dirty or self.tick~=df.global.cur_year_tick_advmode then
self.dirty=false
self.tick=df.global.cur_year_tick_advmode
return true
end
return false
end
function LightOverlay:makeLightMap()
if not self:changed() then
return
end
self.fovs={}
self.precalc={}
self.lightMap={}
self:buildOcupancy()
self:calculateLightCursor()
self:calculateLightLava()
self:calculateLightSun()
self:calculateFovs()
end
function LightOverlay:onIdle()
self._native.parent:logic()
end
function LightOverlay:render(dc)
if self.dynamic then
self:makeLightMap()
end
self:renderParent()
local vp=self:getViewport()
local map = self.df_layout.map
self.lightMap=self.lightMap or {}
render.lockGrids()
render.invalidate({x=map.x1,y=map.y1,w=map.width,h=map.height})
render.resetGrids()
for i=map.x1,map.x2 do
for j=map.y1,map.y2 do
local v=self.lightMap[i+j*map.width]
if v then
setCell(i,j,{fm=v,bm=v})
else
local dimRgb={r=levelDim,g=levelDim,b=levelDim}
setCell(i,j,{fm=dimRgb,bm=dimRgb})
end
end
end
render.unlockGrids()
end
function LightOverlay:onDismiss()
render.lockGrids()
render.resetGrids()
render.invalidate()
render.unlockGrids()
end
function LightOverlay:onInput(keys)
if keys.STRING_A096 then
self:dismiss()
else
self:sendInputToParent(keys)
if keys.CHANGETAB then
self:updateLayout()
end
if keys.STRING_A126 and not self.dynamic then
self:makeLightMap()
end
self.dirty=true
end
end
if not render.isEnabled() then
qerror("Lua rendermode not enabled!")
end
local dyn=true
if #args>0 and args[1]=="static" then dyn=false end
local lview = LightOverlay{ dynamic=dyn}
lview:show()

@ -1,4 +1,6 @@
-- allows to do jobs in adv. mode.
--keybinding, change to your hearts content. Only the key part.
keybinds={
nextJob={key="CUSTOM_SHIFT_T",desc="Next job in the list"},
prevJob={key="CUSTOM_SHIFT_R",desc="Previous job in the list"},
@ -10,7 +12,17 @@ up_alt2={key="CURSOR_UP_Z_AUX",desc="Use job up"},
use_same={key="A_MOVE_SAME_SQUARE",desc="Use job at the tile you are standing"},
workshop={key="CHANGETAB",desc="Show building menu"},
}
-- building filters
build_filter={
forbid_all=true, --this forbits all except the "allow"
allow={"MetalSmithsForge"}, --ignored if forbit_all=false
forbid={"Custom"} --ignored if forbit_all==true
}
build_filter.HUMANish={
forbid_all=true,
allow={"Masons"},
forbid={}
}
local gui = require 'gui'
local wid=require 'gui.widgets'
@ -24,8 +36,35 @@ local tile_attrs = df.tiletype.attrs
settings={build_by_items=false,check_inv=false,df_assign=true}
function hasValue(tbl,val)
for k,v in pairs(tbl) do
if v==val then
return true
end
end
return false
end
function reverseRaceLookup(id)
return df.global.world.raws.creatures.all[id].creature_id
end
function deon_filter(name,type_id,subtype_id,custom_id, parent)
print(name)
local adv=df.global.world.units.active[0]
local race_filter=build_filter[reverseRaceLookup(adv.race)]
if race_filter then
if race_filter.forbid_all then
return hasValue(race_filter.allow,name)
else
return not hasValue(race_filter.forbid,name)
end
else
if build_filter.forbid_all then
return hasValue(build_filter.allow,name)
else
return not hasValue(build_filter.forbid,name)
end
end
end
local mode_name
for k,v in ipairs({...}) do --setting parsing
if v=="-c" or v=="--cheat" then
@ -176,6 +215,14 @@ function SetCreatureRef(args)
end
end
function SetWebRef(args)
local pos=args.pos
for k,v in pairs(df.global.world.items.other.ANY_WEBS) do
if v.pos.x==pos.x and v.pos.y==pos.y and v.pos.z==pos.z then
job.general_refs:insert("#",{new=df.general_ref_item,item_id=v.id})
end
end
end
function SetPatientRef(args)
local job=args.job
local pos=args.pos
@ -785,7 +832,7 @@ function AssignJobToBuild(args)
if bld~=nil then
CheckAndFinishBuilding(args,bld)
else
bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show()
bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true,building_filter=deon_filter}:show()
end
return true
end
@ -854,6 +901,7 @@ actions={
{"Build" ,AssignJobToBuild,{NoConstructedBuilding}},
{"BuildLast" ,BuildLast,{NoConstructedBuilding}},
{"Clean" ,df.job_type.Clean,{}},
{"GatherWebs" ,df.job_type.CollectWebs,{--[[HasWeb]]},{SetWebRef}},
}