Peds form beginnings, new MetaNames, updated index field types for Bone, added EBoneFlags

This commit is contained in:
dexy
2019-11-06 04:53:20 +11:00
Unverified
parent d5aa1c500c
commit 90142cb6da
25 changed files with 3206 additions and 102 deletions
@@ -44,7 +44,7 @@ namespace CodeWalker.GameFiles
}
else
{
Xml = Encoding.UTF8.GetString(data);
Xml = TextUtil.GetUTF8Text(data);
}
XmlDocument xdoc = new XmlDocument();
@@ -43,7 +43,7 @@ namespace CodeWalker.GameFiles
}
else
{
Xml = Encoding.UTF8.GetString(data);
Xml = TextUtil.GetUTF8Text(data);
}
XmlDocument xdoc = new XmlDocument();
@@ -60,13 +60,7 @@ namespace CodeWalker.GameFiles
else if (entry.NameLower.EndsWith(".meta"))
{
//required for update\x64\dlcpacks\mpheist\dlc.rpf\common\data\gtxd.meta and update\x64\dlcpacks\mpluxe\dlc.rpf\common\data\gtxd.meta
string bom = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
string xml = Encoding.UTF8.GetString(data);
if (xml.StartsWith(bom, StringComparison.Ordinal))
{
xml = xml.Remove(0, bom.Length);
}
string xml = TextUtil.GetUTF8Text(data);
LoadTxdRelationships(xml);
Loaded = true;
@@ -0,0 +1,348 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SharpDX;
using System.IO;
using System.Xml;
using TC = System.ComponentModel.TypeConverterAttribute;
using EXP = System.ComponentModel.ExpandableObjectConverter;
namespace CodeWalker.GameFiles
{
[TC(typeof(EXP))] public class PedsFile : GameFile, PackedFile
{
public PsoFile Pso { get; set; }
public string Xml { get; set; }
public CPedModelInfo__InitDataList InitDataList { get; set; }
public PedsFile() : base(null, GameFileType.Peds)
{ }
public PedsFile(RpfFileEntry entry) : base(entry, GameFileType.Peds)
{
}
public void Load(byte[] data, RpfFileEntry entry)
{
RpfFileEntry = entry;
Name = entry.Name;
FilePath = Name;
//can be PSO .ymt or XML .meta
MemoryStream ms = new MemoryStream(data);
if (PsoFile.IsPSO(ms))
{
Pso = new PsoFile();
Pso.Load(data);
Xml = PsoXml.GetXml(Pso); //yep let's just convert that to XML :P
}
else
{
Xml = TextUtil.GetUTF8Text(data);
}
XmlDocument xdoc = new XmlDocument();
if (!string.IsNullOrEmpty(Xml))
{
try
{
xdoc.LoadXml(Xml);
}
catch (Exception ex)
{
var msg = ex.Message;
}
}
else
{ }
if (xdoc.DocumentElement != null)
{
InitDataList = new CPedModelInfo__InitDataList(xdoc.DocumentElement);
}
Loaded = true;
}
}
[TC(typeof(EXP))] public class CPedModelInfo__InitDataList
{
public string residentTxd { get; set; }
public string[] residentAnims { get; set; }
public CPedModelInfo__InitData[] InitDatas { get; set; }
public CTxdRelationship[] txdRelationships { get; set; }
public CMultiTxdRelationship[] multiTxdRelationships { get; set; }
public CPedModelInfo__InitDataList(XmlNode node)
{
XmlNodeList items;
residentTxd = Xml.GetChildInnerText(node, "residentTxd");
items = node.SelectSingleNode("residentAnims")?.SelectNodes("Item");
if (items?.Count > 0)
{
residentAnims = new string[items.Count];
for (int i = 0; i < items.Count; i++)
{
residentAnims[i] = items[i].InnerText;
}
}
items = node.SelectSingleNode("InitDatas")?.SelectNodes("Item");
if (items?.Count > 0)
{
InitDatas = new CPedModelInfo__InitData[items.Count];
for (int i = 0; i < items.Count; i++)
{
InitDatas[i] = new CPedModelInfo__InitData(items[i]);
}
}
items = node.SelectSingleNode("txdRelationships")?.SelectNodes("Item");
if (items?.Count > 0)
{
txdRelationships = new CTxdRelationship[items.Count];
for (int i = 0; i < items.Count; i++)
{
txdRelationships[i] = new CTxdRelationship(items[i]);
}
}
items = node.SelectSingleNode("multiTxdRelationships")?.SelectNodes("Item");
if (items?.Count > 0)
{
multiTxdRelationships = new CMultiTxdRelationship[items.Count];
for (int i = 0; i < items.Count; i++)
{
multiTxdRelationships[i] = new CMultiTxdRelationship(items[i]);
}
}
}
}
[TC(typeof(EXP))] public class CPedModelInfo__InitData
{
public string Name { get; set; }
public string PropsName { get; set; }
public string ClipDictionaryName { get; set; }
public string BlendShapeFileName { get; set; }
public string ExpressionSetName { get; set; }
public string ExpressionDictionaryName { get; set; }
public string ExpressionName { get; set; }
public string Pedtype { get; set; }
public string MovementClipSet { get; set; }
public string[] MovementClipSets { get; set; }
public string StrafeClipSet { get; set; }
public string MovementToStrafeClipSet { get; set; }
public string InjuredStrafeClipSet { get; set; }
public string FullBodyDamageClipSet { get; set; }
public string AdditiveDamageClipSet { get; set; }
public string DefaultGestureClipSet { get; set; }
public string FacialClipsetGroupName { get; set; }
public string DefaultVisemeClipSet { get; set; }
public string SidestepClipSet { get; set; }
public string PoseMatcherName { get; set; }
public string PoseMatcherProneName { get; set; }
public string GetupSetHash { get; set; }
public string CreatureMetadataName { get; set; }
public string DecisionMakerName { get; set; }
public string MotionTaskDataSetName { get; set; }
public string DefaultTaskDataSetName { get; set; }
public string PedCapsuleName { get; set; }
public string PedLayoutName { get; set; }
public string PedComponentSetName { get; set; }
public string PedComponentClothName { get; set; }
public string PedIKSettingsName { get; set; }
public string TaskDataName { get; set; }
public bool IsStreamedGfx { get; set; }
public bool AmbulanceShouldRespondTo { get; set; }
public bool CanRideBikeWithNoHelmet { get; set; }
public bool CanSpawnInCar { get; set; }
public bool IsHeadBlendPed { get; set; }
public bool bOnlyBulkyItemVariations { get; set; }
public string RelationshipGroup { get; set; }
public string NavCapabilitiesName { get; set; }
public string PerceptionInfo { get; set; }
public string DefaultBrawlingStyle { get; set; }
public string DefaultUnarmedWeapon { get; set; }
public string Personality { get; set; }
public string CombatInfo { get; set; }
public string VfxInfoName { get; set; }
public string AmbientClipsForFlee { get; set; }
public string Radio1 { get; set; } // MetaName.ePedRadioGenre
public string Radio2 { get; set; } // MetaName.ePedRadioGenre
public float FUpOffset { get; set; }
public float RUpOffset { get; set; }
public float FFrontOffset { get; set; }
public float RFrontOffset { get; set; }
public float MinActivationImpulse { get; set; }
public float Stubble { get; set; }
public float HDDist { get; set; }
public float TargetingThreatModifier { get; set; }
public float KilledPerceptionRangeModifer { get; set; }
public string Sexiness { get; set; } // MetaTypeName.ARRAYINFO MetaName.eSexinessFlags
public byte Age { get; set; }
public byte MaxPassengersInCar { get; set; }
public string ExternallyDrivenDOFs { get; set; } // MetaTypeName.ARRAYINFO MetaName.eExternallyDrivenDOFs
public string PedVoiceGroup { get; set; }
public string AnimalAudioObject { get; set; }
public string AbilityType { get; set; } // MetaName.SpecialAbilityType
public string ThermalBehaviour { get; set; } // MetaName.ThermalBehaviour
public string SuperlodType { get; set; } // MetaName.eSuperlodType
public string ScenarioPopStreamingSlot { get; set; } // MetaName.eScenarioPopStreamingSlot
public string DefaultSpawningPreference { get; set; } // MetaName.DefaultSpawnPreference
public float DefaultRemoveRangeMultiplier { get; set; }
public bool AllowCloseSpawning { get; set; }
public CPedModelInfo__InitData(XmlNode node)
{
Name = Xml.GetChildInnerText(node, "Name");
PropsName = Xml.GetChildInnerText(node, "PropsName");
ClipDictionaryName = Xml.GetChildInnerText(node, "ClipDictionaryName");
BlendShapeFileName = Xml.GetChildInnerText(node, "BlendShapeFileName");
ExpressionSetName = Xml.GetChildInnerText(node, "ExpressionSetName");
ExpressionDictionaryName = Xml.GetChildInnerText(node, "ExpressionDictionaryName");
ExpressionName = Xml.GetChildInnerText(node, "ExpressionName");
Pedtype = Xml.GetChildInnerText(node, "Pedtype");
MovementClipSet = Xml.GetChildInnerText(node, "MovementClipSet");
var items = node.SelectSingleNode("MovementClipSets")?.SelectNodes("Item");
if (items?.Count > 0)
{
MovementClipSets = new string[items.Count];
for (int i = 0; i < items.Count; i++)
{
MovementClipSets[i] = items[i].InnerText;
}
}
StrafeClipSet = Xml.GetChildInnerText(node, "StrafeClipSet");
MovementToStrafeClipSet = Xml.GetChildInnerText(node, "MovementToStrafeClipSet");
InjuredStrafeClipSet = Xml.GetChildInnerText(node, "InjuredStrafeClipSet");
FullBodyDamageClipSet = Xml.GetChildInnerText(node, "FullBodyDamageClipSet");
AdditiveDamageClipSet = Xml.GetChildInnerText(node, "AdditiveDamageClipSet");
DefaultGestureClipSet = Xml.GetChildInnerText(node, "DefaultGestureClipSet");
FacialClipsetGroupName = Xml.GetChildInnerText(node, "FacialClipsetGroupName");
DefaultVisemeClipSet = Xml.GetChildInnerText(node, "DefaultVisemeClipSet");
SidestepClipSet = Xml.GetChildInnerText(node, "SidestepClipSet");
PoseMatcherName = Xml.GetChildInnerText(node, "PoseMatcherName");
PoseMatcherProneName = Xml.GetChildInnerText(node, "PoseMatcherProneName");
GetupSetHash = Xml.GetChildInnerText(node, "GetupSetHash");
CreatureMetadataName = Xml.GetChildInnerText(node, "CreatureMetadataName");
DecisionMakerName = Xml.GetChildInnerText(node, "DecisionMakerName");
MotionTaskDataSetName = Xml.GetChildInnerText(node, "MotionTaskDataSetName");
DefaultTaskDataSetName = Xml.GetChildInnerText(node, "DefaultTaskDataSetName");
PedCapsuleName = Xml.GetChildInnerText(node, "PedCapsuleName");
PedLayoutName = Xml.GetChildInnerText(node, "PedLayoutName");
PedComponentSetName = Xml.GetChildInnerText(node, "PedComponentSetName");
PedComponentClothName = Xml.GetChildInnerText(node, "PedComponentClothName");
PedIKSettingsName = Xml.GetChildInnerText(node, "PedIKSettingsName");
TaskDataName = Xml.GetChildInnerText(node, "TaskDataName");
IsStreamedGfx = Xml.GetChildBoolAttribute(node, "IsStreamedGfx", "value");
AmbulanceShouldRespondTo = Xml.GetChildBoolAttribute(node, "AmbulanceShouldRespondTo", "value");
CanRideBikeWithNoHelmet = Xml.GetChildBoolAttribute(node, "CanRideBikeWithNoHelmet", "value");
CanSpawnInCar = Xml.GetChildBoolAttribute(node, "CanSpawnInCar", "value");
IsHeadBlendPed = Xml.GetChildBoolAttribute(node, "IsHeadBlendPed", "value");
bOnlyBulkyItemVariations = Xml.GetChildBoolAttribute(node, "bOnlyBulkyItemVariations", "value");
RelationshipGroup = Xml.GetChildInnerText(node, "RelationshipGroup");
NavCapabilitiesName = Xml.GetChildInnerText(node, "NavCapabilitiesName");
PerceptionInfo = Xml.GetChildInnerText(node, "PerceptionInfo");
DefaultBrawlingStyle = Xml.GetChildInnerText(node, "DefaultBrawlingStyle");
DefaultUnarmedWeapon = Xml.GetChildInnerText(node, "DefaultUnarmedWeapon");
Personality = Xml.GetChildInnerText(node, "Personality");
CombatInfo = Xml.GetChildInnerText(node, "CombatInfo");
VfxInfoName = Xml.GetChildInnerText(node, "VfxInfoName");
AmbientClipsForFlee = Xml.GetChildInnerText(node, "AmbientClipsForFlee");
Radio1 = Xml.GetChildInnerText(node, "Radio1"); // MetaName.ePedRadioGenre
Radio2 = Xml.GetChildInnerText(node, "Radio2"); // MetaName.ePedRadioGenre
FUpOffset = Xml.GetChildFloatAttribute(node, "FUpOffset", "value");
RUpOffset = Xml.GetChildFloatAttribute(node, "RUpOffset", "value");
FFrontOffset = Xml.GetChildFloatAttribute(node, "FFrontOffset", "value");
RFrontOffset = Xml.GetChildFloatAttribute(node, "RFrontOffset", "value");
MinActivationImpulse = Xml.GetChildFloatAttribute(node, "MinActivationImpulse", "value");
Stubble = Xml.GetChildFloatAttribute(node, "Stubble", "value");
HDDist = Xml.GetChildFloatAttribute(node, "HDDist", "value");
TargetingThreatModifier = Xml.GetChildFloatAttribute(node, "TargetingThreatModifier", "value");
KilledPerceptionRangeModifer = Xml.GetChildFloatAttribute(node, "KilledPerceptionRangeModifer", "value");
Sexiness = Xml.GetChildInnerText(node, "Sexiness"); // MetaTypeName.ARRAYINFO MetaName.eSexinessFlags
Age = (byte)Xml.GetChildUIntAttribute(node, "Age", "value");
MaxPassengersInCar = (byte)Xml.GetChildUIntAttribute(node, "MaxPassengersInCar", "value");
ExternallyDrivenDOFs = Xml.GetChildInnerText(node, "ExternallyDrivenDOFs"); // MetaTypeName.ARRAYINFO MetaName.eExternallyDrivenDOFs
PedVoiceGroup = Xml.GetChildInnerText(node, "PedVoiceGroup");
AnimalAudioObject = Xml.GetChildInnerText(node, "AnimalAudioObject");
AbilityType = Xml.GetChildInnerText(node, "AbilityType"); // MetaName.SpecialAbilityType
ThermalBehaviour = Xml.GetChildInnerText(node, "ThermalBehaviour"); // MetaName.ThermalBehaviour
SuperlodType = Xml.GetChildInnerText(node, "SuperlodType"); // MetaName.eSuperlodType
ScenarioPopStreamingSlot = Xml.GetChildInnerText(node, "ScenarioPopStreamingSlot"); // MetaName.eScenarioPopStreamingSlot
DefaultSpawningPreference = Xml.GetChildInnerText(node, "DefaultSpawningPreference"); // MetaName.DefaultSpawnPreference
DefaultRemoveRangeMultiplier = Xml.GetChildFloatAttribute(node, "DefaultRemoveRangeMultiplier", "value");
AllowCloseSpawning = Xml.GetChildBoolAttribute(node, "AllowCloseSpawning", "value");
}
public override string ToString()
{
return Name;
}
}
[TC(typeof(EXP))] public class CTxdRelationship
{
public string parent { get; set; }
public string child { get; set; }
public CTxdRelationship(XmlNode node)
{
parent = Xml.GetChildInnerText(node, "parent");
child = Xml.GetChildInnerText(node, "child");
}
public override string ToString()
{
return parent + ": " + child;
}
}
[TC(typeof(EXP))] public class CMultiTxdRelationship
{
public string parent { get; set; }
public string[] children { get; set; }
public CMultiTxdRelationship(XmlNode node)
{
parent = Xml.GetChildInnerText(node, "parent");
var items = node.SelectSingleNode("children")?.SelectNodes("Item");
if (items?.Count > 0)
{
children = new string[items.Count];
for (int i = 0; i < items.Count; i++)
{
children[i] = items[i].InnerText;
}
}
}
public override string ToString()
{
return parent + ": " + (children?.Length ?? 0).ToString() + " children";
}
}
}
@@ -26,7 +26,7 @@ namespace CodeWalker.GameFiles
//always XML .meta
Xml = Encoding.UTF8.GetString(data);
Xml = TextUtil.GetUTF8Text(data);
//TODO: parse CVehicleMetadataMgr XML
@@ -37,14 +37,7 @@ namespace CodeWalker.GameFiles
if (entry.NameLower.EndsWith(".meta"))
{
//required for update\x64\dlcpacks\mpheist\dlc.rpf\common\data\gtxd.meta and update\x64\dlcpacks\mpluxe\dlc.rpf\common\data\gtxd.meta
string bom = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
string xml = Encoding.UTF8.GetString(data);
if (xml.StartsWith(bom, StringComparison.Ordinal))
{
xml = xml.Remove(0, bom.Length);
}
string xml = TextUtil.GetUTF8Text(data);
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(xml);
+1
View File
@@ -75,6 +75,7 @@ namespace CodeWalker.GameFiles
CarModCols = 19,
CarVariations = 20,
VehicleLayouts = 21,
Peds = 22,
}
+69 -1
View File
@@ -79,7 +79,7 @@ namespace CodeWalker.GameFiles
public Dictionary<uint, World.TimecycleMod> TimeCycleModsDict = new Dictionary<uint, World.TimecycleMod>();
public Dictionary<MetaHash, VehicleInitData> VehiclesInitDict { get; set; }
public Dictionary<MetaHash, CPedModelInfo__InitData> PedsInitDict { get; set; }
public List<RpfFile> BaseRpfs { get; private set; }
public List<RpfFile> AllRpfs { get; private set; }
@@ -89,6 +89,7 @@ namespace CodeWalker.GameFiles
public bool BuildExtendedJenkIndex = true;
public bool LoadArchetypes = true;
public bool LoadVehicles = false;
public bool LoadPeds = false;
private bool PreloadedMode = false;
private string GTAFolder;
@@ -273,6 +274,10 @@ namespace CodeWalker.GameFiles
UpdateStatus("Loading vehicles...");
InitVehicles();
UpdateStatus("Loading peds...");
InitPeds();
}
private void InitDlcList()
@@ -1592,6 +1597,69 @@ namespace CodeWalker.GameFiles
}
public void InitPeds()
{
if (!LoadPeds) return;
IEnumerable<RpfFile> rpfs = PreloadedMode ? AllRpfs : (IEnumerable<RpfFile>)ActiveMapRpfFiles.Values;
var allPeds = new Dictionary<MetaHash, CPedModelInfo__InitData>();
var allPedsFiles = new List<PedsFile>();
var addPedsFiles = new Action<IEnumerable<RpfFile>>((from) =>
{
foreach (RpfFile file in from)
{
if (file.AllEntries == null) continue;
foreach (RpfEntry entry in file.AllEntries)
{
#if !DEBUG
try
#endif
{
if ((entry.NameLower == "peds.ymt") || (entry.NameLower == "peds.meta"))
{
var pf = RpfMan.GetFile<PedsFile>(entry);
if (pf.InitDataList?.InitDatas != null)
{
foreach (var initData in pf.InitDataList.InitDatas)
{
var name = initData.Name.ToLowerInvariant();
var hash = JenkHash.GenHash(name);
if (allPeds.ContainsKey(hash))
{ }
allPeds[hash] = initData;
}
}
allPedsFiles.Add(pf);
}
}
#if !DEBUG
catch (Exception ex)
{
string errstr = entry.Path + "\n" + ex.ToString();
ErrorLog(errstr);
}
#endif
}
}
});
addPedsFiles(rpfs);
if (EnableDlc)
{
addPedsFiles(DlcActiveRpfs);
}
PedsInitDict = allPeds;
}
public bool SetDlcLevel(string dlc, bool enable)
{
+1 -4
View File
@@ -1110,10 +1110,7 @@ namespace CodeWalker.GameFiles
{
var str = JenkIndex.TryGetString(Hash);
if (!string.IsNullOrEmpty(str)) return str;
if (Enum.IsDefined(typeof(MetaName), Hash))
{
return ((MetaName)Hash).ToString();
}
if (MetaNames.TryGetString(Hash, out str)) return str;
return GlobalText.GetString(Hash);
}
@@ -8,6 +8,21 @@ using System.Threading.Tasks;
namespace CodeWalker.GameFiles
{
public static class MetaNames
{
public static bool TryGetString(uint h, out string str)
{
if (Enum.IsDefined(typeof(MetaName), h))
{
str = ((MetaName)h).ToString();
if (str.StartsWith("@")) str = str.Substring(1); //mainly to handle the @null entry
return true;
}
str = null;
return false;
}
}
public class MetaNamesUtil
{
@@ -3468,11 +3483,60 @@ namespace CodeWalker.GameFiles
ePedVarComp = 884254308,
ePropRenderFlags = 4212977111,
CPedPropTexData = 254518642,
eScenarioPopStreamingSlot = 3029795674,
eFadeCurveType = 3057039286,
eSuperlodType = 4015041481,
ePedRadioGenre = 2942646938,
eSexinessFlags = 374769227,
eExternallyDrivenDOFs = 637184392,
SpecialAbilityType = 2011786168,
DefaultSpawnPreference = 888587604,
CScenarioChainingEdge__eAction = 3609807418,
CScenarioChainingEdge__eNavMode = 3971773454,
CScenarioChainingEdge__eNavSpeed = 941086046,
standard_ped = 2703423328, //in peds.ymt
standard_male = 1860494962, //in peds.ymt PedCapsuleName
standard_female = 3778684510, //in peds.ymt PedCapsuleName
facial_clipset_group_gen_male = 2968316036, //in peds.ymt FacialClipsetGroupName
facial_clipset_group_gen_female = 984918963, //in peds.ymt FacialClipsetGroupName
facial_clipset_group_p_m_zero = 3839850645, //in peds.ymt FacialClipsetGroupName
facial_clipset_group_p_m_one = 3697506179, //in peds.ymt FacialClipsetGroupName
facial_clipset_group_p_m_two = 3958944905, //in peds.ymt FacialClipsetGroupName
anim_group_gesture_m_generic = 4080627616, //in peds.ymt DefaultGestureClipSet
anim_group_gesture_f_generic = 1375166916, //in peds.ymt DefaultGestureClipSet
anim_group_visemes_m_lo = 3326036851, //in peds.ymt DefaultVisemeClipSet
anim_group_visemes_f_lo = 2783456433, //in peds.ymt DefaultVisemeClipSet
nmbs_slow_getups = 69709351, //peds.ymt GetupSetHash
clip_set_id_invalid = 2106583169, //in peds.ymt
move_strafe_injured = 1434752434, //in peds.ymt InjuredStrafeClipSet
move_ped_to_strafe = 3943634031, //in peds.ymt MovementToStrafeClipSet
move_ped_strafing = 2464962150, //in peds.ymt StrafeClipSet
civmale = 45677184, //in peds.ymt Pedtype
civfemale = 1191392768, //in peds.ymt Pedtype
vfxpedinfo_human_generic = 1167185222, //in peds.ymt VfxInfoName
expr_set_ambient_male = 2495275024, //in peds.ymt ExpressionSetName
expr_set_ambient_female = 3793172393, //in peds.ymt ExpressionSetName
default_perception = 3537703288, //in peds.ymt PerceptionInfo
streamed_male = 4014297412, //in peds.ymt Personality
streamed_female = 991949850, //in peds.ymt Personality
fitnessmale = 921466782, //in peds.ymt Personality
fitnessfemale = 419688606, //in peds.ymt Personality
youngrichman = 3818603935, //in peds.ymt Personality
youngrichwoman = 367809573, //in peds.ymt Personality
youngaverageweakman = 3971800366, //in peds.ymt Personality
youngaverageweakwoman = 806694113, //in peds.ymt Personality
bs_ai = 2150391885, //in peds.ymt DefaultBrawlingStyle
bs_franklin = 1037948029, //in peds.ymt DefaultBrawlingStyle
bs_michael = 2057220685, //in peds.ymt DefaultBrawlingStyle
bs_trevor = 1249954968, //in peds.ymt DefaultBrawlingStyle
weapon_unarmed = 2725352035, //in peds.ymt DefaultUnarmedWeapon
silent_pvg = 423993118, //in peds.ymt PedVoiceGroup
silent_cutscene_pvg = 1896822940, //in peds.ymt PedVoiceGroup
@null = 987444055, // how best to handle this? C# doesn't like it
+7 -15
View File
@@ -1827,12 +1827,10 @@ namespace CodeWalker.GameFiles
uint uh = (uint)h;
if (uh == 0) return "";
if (Enum.IsDefined(typeof(MetaName), h))
{
return h.ToString();
}
string str;
if (MetaNames.TryGetString(uh, out str)) return str;
var str = JenkIndex.TryGetString(uh);
str = JenkIndex.TryGetString(uh);
if (!string.IsNullOrEmpty(str)) return str;
//TODO: do extra hash lookup here
@@ -1849,11 +1847,7 @@ namespace CodeWalker.GameFiles
if (string.IsNullOrEmpty(str))
{
var nh = (MetaName)(uint)h;
if (Enum.IsDefined(typeof(MetaName), nh))
{
return nh.ToString();
}
if (MetaNames.TryGetString(h, out str)) return str;
}
//todo: make sure JenkIndex is built!
@@ -1880,12 +1874,10 @@ namespace CodeWalker.GameFiles
public static string UintString(uint h)
{
if (Enum.IsDefined(typeof(MetaName), h))
{
return ((MetaName)h).ToString();
}
string str;
if (MetaNames.TryGetString(h, out str)) return str;
var str = JenkIndex.TryGetString(h);
str = JenkIndex.TryGetString(h);
if (!string.IsNullOrEmpty(str)) return str;
//TODO: do extra hash lookup here
+25 -25
View File
@@ -800,8 +800,8 @@ namespace CodeWalker.GameFiles
new PsoStructureEntryInfo(MetaName.CombatInfo, PsoDataType.String, 192, 7, 0),
new PsoStructureEntryInfo(MetaName.VfxInfoName, PsoDataType.String, 196, 7, 0),
new PsoStructureEntryInfo(MetaName.AmbientClipsForFlee, PsoDataType.String, 200, 7, 0),
new PsoStructureEntryInfo(MetaName.Radio1, PsoDataType.Enum, 204, 0, (MetaName)2942646938),
new PsoStructureEntryInfo(MetaName.Radio2, PsoDataType.Enum, 208, 0, (MetaName)2942646938),
new PsoStructureEntryInfo(MetaName.Radio1, PsoDataType.Enum, 204, 0, MetaName.ePedRadioGenre),
new PsoStructureEntryInfo(MetaName.Radio2, PsoDataType.Enum, 208, 0, MetaName.ePedRadioGenre),
new PsoStructureEntryInfo(MetaName.FUpOffset, PsoDataType.Float, 212, 0, 0),
new PsoStructureEntryInfo(MetaName.RUpOffset, PsoDataType.Float, 216, 0, 0),
new PsoStructureEntryInfo(MetaName.FFrontOffset, PsoDataType.Float, 220, 0, 0),
@@ -811,19 +811,19 @@ namespace CodeWalker.GameFiles
new PsoStructureEntryInfo(MetaName.HDDist, PsoDataType.Float, 236, 0, 0),
new PsoStructureEntryInfo(MetaName.TargetingThreatModifier, PsoDataType.Float, 240, 0, 0),
new PsoStructureEntryInfo(MetaName.KilledPerceptionRangeModifer, PsoDataType.Float, 244, 0, 0),
new PsoStructureEntryInfo((MetaName)MetaTypeName.ARRAYINFO, PsoDataType.Enum, 0, 0, (MetaName)374769227),
new PsoStructureEntryInfo((MetaName)MetaTypeName.ARRAYINFO, PsoDataType.Enum, 0, 0, MetaName.eSexinessFlags),
new PsoStructureEntryInfo(MetaName.Sexiness, PsoDataType.Flags, 248, 0, (MetaName)2097211),
new PsoStructureEntryInfo(MetaName.Age, PsoDataType.UByte, 252, 0, 0),
new PsoStructureEntryInfo(MetaName.MaxPassengersInCar, PsoDataType.UByte, 253, 0, 0),
new PsoStructureEntryInfo((MetaName)MetaTypeName.ARRAYINFO, PsoDataType.Enum, 0, 0, (MetaName)637184392),
new PsoStructureEntryInfo((MetaName)MetaTypeName.ARRAYINFO, PsoDataType.Enum, 0, 0, MetaName.eExternallyDrivenDOFs),
new PsoStructureEntryInfo(MetaName.ExternallyDrivenDOFs, PsoDataType.Flags, 254, 2, (MetaName)327743),
new PsoStructureEntryInfo(MetaName.PedVoiceGroup, PsoDataType.String, 256, 7, 0),
new PsoStructureEntryInfo(MetaName.AnimalAudioObject, PsoDataType.String, 260, 7, 0),
new PsoStructureEntryInfo(MetaName.AbilityType, PsoDataType.Enum, 264, 0, (MetaName)2011786168),
new PsoStructureEntryInfo(MetaName.AbilityType, PsoDataType.Enum, 264, 0, MetaName.SpecialAbilityType),
new PsoStructureEntryInfo(MetaName.ThermalBehaviour, PsoDataType.Enum, 268, 0, MetaName.ThermalBehaviour),
new PsoStructureEntryInfo(MetaName.SuperlodType, PsoDataType.Enum, 272, 0, (MetaName)4015041481),
new PsoStructureEntryInfo(MetaName.ScenarioPopStreamingSlot, PsoDataType.Enum, 276, 0, (MetaName)3029795674),
new PsoStructureEntryInfo(MetaName.DefaultSpawningPreference, PsoDataType.Enum, 280, 0, (MetaName)888587604),
new PsoStructureEntryInfo(MetaName.SuperlodType, PsoDataType.Enum, 272, 0, MetaName.eSuperlodType),
new PsoStructureEntryInfo(MetaName.ScenarioPopStreamingSlot, PsoDataType.Enum, 276, 0, MetaName.eScenarioPopStreamingSlot),
new PsoStructureEntryInfo(MetaName.DefaultSpawningPreference, PsoDataType.Enum, 280, 0, MetaName.DefaultSpawnPreference),
new PsoStructureEntryInfo(MetaName.DefaultRemoveRangeMultiplier, PsoDataType.Float, 284, 0, 0),
new PsoStructureEntryInfo(MetaName.AllowCloseSpawning, PsoDataType.Bool, 288, 0, 0)
);
@@ -841,7 +841,7 @@ namespace CodeWalker.GameFiles
new PsoStructureEntryInfo(MetaName.mediumCharge, PsoDataType.SInt, 28, 0, 0),
new PsoStructureEntryInfo(MetaName.largeCharge, PsoDataType.SInt, 32, 0, 0),
new PsoStructureEntryInfo(MetaName.continuousCharge, PsoDataType.SInt, 36, 0, 0),
new PsoStructureEntryInfo(MetaName.fadeCurveType, PsoDataType.Enum, 40, 0, (MetaName)3057039286),
new PsoStructureEntryInfo(MetaName.fadeCurveType, PsoDataType.Enum, 40, 0, MetaName.eFadeCurveType),
new PsoStructureEntryInfo(MetaName.halfSigmoidConstant, PsoDataType.Float, 44, 0, 0),
new PsoStructureEntryInfo(MetaName.sigmoidConstant, PsoDataType.Float, 48, 0, 0),
new PsoStructureEntryInfo(MetaName.fadeInTime, PsoDataType.Float, 52, 0, 0),
@@ -14849,8 +14849,8 @@ namespace CodeWalker.GameFiles
new PsoEnumEntryInfo(MetaName.PARTITION_2, 2),
new PsoEnumEntryInfo(MetaName.PARTITION_MAX, 3)
);
case (MetaName)2942646938:
return new PsoEnumInfo((MetaName)2942646938, 1,
case MetaName.ePedRadioGenre:
return new PsoEnumInfo(MetaName.ePedRadioGenre, 1,
new PsoEnumEntryInfo(MetaName.RADIO_GENRE_OFF, 0),
new PsoEnumEntryInfo(MetaName.RADIO_GENRE_MODERN_ROCK, 1),
new PsoEnumEntryInfo(MetaName.RADIO_GENRE_CLASSIC_ROCK, 2),
@@ -14869,20 +14869,20 @@ namespace CodeWalker.GameFiles
new PsoEnumEntryInfo(MetaName.RADIO_GENRE_SURF, 15),
new PsoEnumEntryInfo(MetaName.RADIO_GENRE_UNSPECIFIED, 16)
);
case (MetaName)374769227:
return new PsoEnumInfo((MetaName)374769227, 1,
case MetaName.eSexinessFlags:
return new PsoEnumInfo(MetaName.eSexinessFlags, 1,
new PsoEnumEntryInfo(MetaName.SF_JEER_AT_HOT_PED, 0),
new PsoEnumEntryInfo((MetaName)296569367, 1),
new PsoEnumEntryInfo(MetaName.SF_HOT_PERSON, 2)
);
case (MetaName)637184392:
return new PsoEnumInfo((MetaName)637184392, 1,
case MetaName.eExternallyDrivenDOFs:
return new PsoEnumInfo(MetaName.eExternallyDrivenDOFs, 1,
new PsoEnumEntryInfo(MetaName.EMPTY, 0),
new PsoEnumEntryInfo(MetaName.HIGH_HEELS, 1),
new PsoEnumEntryInfo(MetaName.COLLAR, 2)
);
case (MetaName)2011786168:
return new PsoEnumInfo((MetaName)2011786168, 1,
case MetaName.SpecialAbilityType: //CPedModelInfo__InitData AbilityType
return new PsoEnumInfo(MetaName.SpecialAbilityType, 1,
new PsoEnumEntryInfo(MetaName.SAT_NONE, -1),
new PsoEnumEntryInfo(MetaName.SAT_CAR_SLOWDOWN, 0),
new PsoEnumEntryInfo(MetaName.SAT_RAGE, 1),
@@ -14897,28 +14897,28 @@ namespace CodeWalker.GameFiles
new PsoEnumEntryInfo(MetaName.TB_WARM, 2),
new PsoEnumEntryInfo(MetaName.TB_HOT, 3)
);
case (MetaName)4015041481:
return new PsoEnumInfo((MetaName)4015041481, 1,
case MetaName.eSuperlodType:
return new PsoEnumInfo(MetaName.eSuperlodType, 1,
new PsoEnumEntryInfo(MetaName.SLOD_HUMAN, 0),
new PsoEnumEntryInfo(MetaName.SLOD_SMALL_QUADPED, 1),
new PsoEnumEntryInfo(MetaName.SLOD_LARGE_QUADPED, 2),
new PsoEnumEntryInfo(MetaName.SLOD_NULL, 3),
new PsoEnumEntryInfo(MetaName.SLOD_KEEP_LOWEST, 4)
);
case (MetaName)3029795674: //CPedModelInfo__InitData ScenarioPopStreamingSlot
return new PsoEnumInfo((MetaName)3029795674, 1,
case MetaName.eScenarioPopStreamingSlot: //CPedModelInfo__InitData ScenarioPopStreamingSlot
return new PsoEnumInfo(MetaName.eScenarioPopStreamingSlot, 1,
new PsoEnumEntryInfo(MetaName.SCENARIO_POP_STREAMING_NORMAL, 0),
new PsoEnumEntryInfo(MetaName.SCENARIO_POP_STREAMING_SMALL, 1)
);
case (MetaName)888587604:
return new PsoEnumInfo((MetaName)888587604, 1,
case MetaName.DefaultSpawnPreference: //CPedModelInfo__InitData DefaultSpawningPreference
return new PsoEnumInfo(MetaName.DefaultSpawnPreference, 1,
new PsoEnumEntryInfo(MetaName.DSP_AERIAL, 0),
new PsoEnumEntryInfo(MetaName.DSP_AQUATIC, 1),
new PsoEnumEntryInfo(MetaName.DSP_GROUND_WILDLIFE, 2),
new PsoEnumEntryInfo(MetaName.DSP_NORMAL, 3)
);
case (MetaName)3057039286:
return new PsoEnumInfo((MetaName)3057039286, 1,
case MetaName.eFadeCurveType:
return new PsoEnumInfo(MetaName.eFadeCurveType, 1,
new PsoEnumEntryInfo(MetaName.FCT_NONE, 0),
new PsoEnumEntryInfo(MetaName.FCT_LINEAR, 1),
new PsoEnumEntryInfo(MetaName.FCT_HALF_SIGMOID, 2),
+39 -18
View File
@@ -541,13 +541,13 @@ namespace CodeWalker.GameFiles
public Matrix[] TransformationsInverted { get; set; }
public Matrix[] Transformations { get; set; }
public ushort[] ParentIndices { get; set; }
public ushort[] ChildIndices { get; set; }//mapping child->parent indices, first child index, then parent
public short[] ParentIndices { get; set; }
public short[] ChildIndices { get; set; }//mapping child->parent indices, first child index, then parent
private ResourceSystemStructBlock<Matrix> TransformationsInvertedBlock = null;//for saving only
private ResourceSystemStructBlock<Matrix> TransformationsBlock = null;
private ResourceSystemStructBlock<ushort> ParentIndicesBlock = null;
private ResourceSystemStructBlock<ushort> ChildIndicesBlock = null;
private ResourceSystemStructBlock<short> ParentIndicesBlock = null;
private ResourceSystemStructBlock<short> ChildIndicesBlock = null;
public Dictionary<ushort, Bone> BonesMap { get; set; }//for convienience finding bones by tag
@@ -597,8 +597,8 @@ namespace CodeWalker.GameFiles
);
this.TransformationsInverted = reader.ReadStructsAt<Matrix>(this.TransformationsInvertedPointer, this.BonesCount);
this.Transformations = reader.ReadStructsAt<Matrix>(this.TransformationsPointer, this.BonesCount);
this.ParentIndices = reader.ReadUshortsAt(this.ParentIndicesPointer, this.BonesCount);
this.ChildIndices = reader.ReadUshortsAt(this.ChildIndicesPointer, this.ChildIndicesCount);
this.ParentIndices = reader.ReadShortsAt(this.ParentIndicesPointer, this.BonesCount);
this.ChildIndices = reader.ReadShortsAt(this.ChildIndicesPointer, this.ChildIndicesCount);
if ((Bones != null) && (ParentIndices != null))
@@ -608,7 +608,7 @@ namespace CodeWalker.GameFiles
{
var bone = Bones[i];
var pind = ParentIndices[i];
if (pind < Bones.Count)
if ((pind >= 0) && (pind < Bones.Count))
{
bone.Parent = Bones[pind];
}
@@ -698,12 +698,12 @@ namespace CodeWalker.GameFiles
}
if (ParentIndices != null)
{
ParentIndicesBlock = new ResourceSystemStructBlock<ushort>(ParentIndices);
ParentIndicesBlock = new ResourceSystemStructBlock<short>(ParentIndices);
list.Add(ParentIndicesBlock);
}
if (ChildIndices != null)
{
ChildIndicesBlock = new ResourceSystemStructBlock<ushort>(ChildIndices);
ChildIndicesBlock = new ResourceSystemStructBlock<short>(ChildIndices);
list.Add(ChildIndicesBlock);
}
return list.ToArray();
@@ -771,6 +771,27 @@ namespace CodeWalker.GameFiles
}
}
[Flags] public enum EBoneFlags : ushort
{
None = 0,
RotX = 0x1,
RotY = 0x2,
RotZ = 0x4,
LimitRotation = 0x8,
TransX = 0x10,
TransY = 0x20,
TransZ = 0x40,
LimitTranslation = 0x80,
ScaleX = 0x100,
ScaleY = 0x200,
ScaleZ = 0x400,
LimitScale = 0x800,
Unk0 = 0x1000,
Unk1 = 0x2000,
Unk2 = 0x4000,
Unk3 = 0x8000,
}
[TypeConverter(typeof(ExpandableObjectConverter))] public class Bone : ResourceSystemBlock
{
public override long BlockLength
@@ -788,14 +809,14 @@ namespace CodeWalker.GameFiles
public uint Unknown_1Ch { get; set; } // 0x00000000 RHW?
public Vector3 Scale { get; set; }
public float Unknown_2Ch { get; set; } // 1.0 RHW?
public ushort NextSiblingIndex { get; set; } //limb end index? IK chain?
public short NextSiblingIndex { get; set; } //limb end index? IK chain?
public short ParentIndex { get; set; }
public uint Unknown_34h { get; set; } // 0x00000000
public ulong NamePointer { get; set; }
public ushort Flags { get; set; }
public ushort Index { get; set; }
public EBoneFlags Flags { get; set; }
public short Index { get; set; }
public ushort Tag { get; set; }
public ushort Index2 { get; set; }//same as Index?
public short Index2 { get; set; }//same as Index?
public uint Unknown_48h { get; set; } // 0x00000000
public uint Unknown_4Ch { get; set; } // 0x00000000
@@ -826,14 +847,14 @@ namespace CodeWalker.GameFiles
this.Unknown_1Ch = reader.ReadUInt32();
this.Scale = reader.ReadVector3();
this.Unknown_2Ch = reader.ReadSingle();
this.NextSiblingIndex = reader.ReadUInt16();
this.NextSiblingIndex = reader.ReadInt16();
this.ParentIndex = reader.ReadInt16();
this.Unknown_34h = reader.ReadUInt32();
this.NamePointer = reader.ReadUInt64();
this.Flags = reader.ReadUInt16();
this.Index = reader.ReadUInt16();
this.Flags = (EBoneFlags)reader.ReadUInt16();
this.Index = reader.ReadInt16();
this.Tag = reader.ReadUInt16();
this.Index2 = reader.ReadUInt16();
this.Index2 = reader.ReadInt16();
this.Unknown_48h = reader.ReadUInt32();
this.Unknown_4Ch = reader.ReadUInt32();
@@ -866,7 +887,7 @@ namespace CodeWalker.GameFiles
writer.Write(this.ParentIndex);
writer.Write(this.Unknown_34h);
writer.Write(this.NamePointer);
writer.Write(this.Flags);
writer.Write((ushort)this.Flags);
writer.Write(this.Index);
writer.Write(this.Tag);
writer.Write(this.Index2);
@@ -266,6 +266,15 @@ namespace CodeWalker.GameFiles
//Position = posbackup;
return result;
}
public short[] ReadShortsAt(ulong position, uint count)
{
if ((position <= 0) || (count == 0)) return null;
var result = new short[count];
var length = count * 2;
byte[] data = ReadBytesAt(position, length);
Buffer.BlockCopy(data, 0, result, 0, (int)length);
return result;
}
public uint[] ReadUintsAt(ulong position, uint count)
{
if ((position <= 0) || (count == 0)) return null;
+1 -12
View File
@@ -283,18 +283,7 @@ namespace CodeWalker.GameFiles
public string GetFileUTF8Text(string path)
{
byte[] bytes = GetFileData(path);
if (bytes == null)
{ return string.Empty; } //file not found..
if ((bytes.Length > 3) && (bytes[0] == 0xEF) && (bytes[1] == 0xBB) && (bytes[2] == 0xBF))
{
byte[] newb = new byte[bytes.Length - 3];
for (int i = 3; i < bytes.Length; i++)
{
newb[i - 3] = bytes[i];
}
bytes = newb; //trim starting 3 "magic" bytes?
}
return Encoding.UTF8.GetString(bytes);
return TextUtil.GetUTF8Text(bytes);
}
public XmlDocument GetFileXml(string path)
{