From 81e24ef86f5e8c5b1d30f33b2848c5dd9520c26a Mon Sep 17 00:00:00 2001 From: dexyfex Date: Sun, 1 Oct 2017 18:52:50 +1100 Subject: [PATCH] Selected CarGen using popGroup for vehicle model set --- GameFiles/FileTypes/YmapFile.cs | 10 ++++++++++ WorldForm.cs | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/GameFiles/FileTypes/YmapFile.cs b/GameFiles/FileTypes/YmapFile.cs index d3f6bea..d0674d0 100644 --- a/GameFiles/FileTypes/YmapFile.cs +++ b/GameFiles/FileTypes/YmapFile.cs @@ -1358,6 +1358,16 @@ namespace CodeWalker.GameFiles BBMax = new Vector3(hlen); } + public string NameString() + { + MetaHash mh = _CCarGen.carModel; + if ((mh == 0) && (_CCarGen.popGroup != 0)) + { + mh = _CCarGen.popGroup; + } + return mh.ToString(); + } + public override string ToString() { return _CCarGen.carModel.ToString() + ", " + Position.ToString() + ", " + _CCarGen.popGroup.ToString() + ", " + _CCarGen.livery.ToString(); diff --git a/WorldForm.cs b/WorldForm.cs index 5fa31f0..5f47b44 100644 --- a/WorldForm.cs +++ b/WorldForm.cs @@ -3161,6 +3161,19 @@ namespace CodeWalker SelectedCarGenEntity.SetOrientation(cgori); uint carhash = cg._CCarGen.carModel; + if ((carhash == 0) && (cg._CCarGen.popGroup != 0)) + { + //find the pop group... and choose a vehicle.. + var stypes = Scenarios.ScenarioTypes; + if (stypes != null) + { + var modelset = stypes.GetVehicleModelSet(cg._CCarGen.popGroup); + if ((modelset != null) && (modelset.Models != null) && (modelset.Models.Length > 0)) + { + carhash = JenkHash.GenHash(modelset.Models[0].NameLower); + } + } + } if (carhash == 0) carhash = 418536135; //"infernus" YftFile caryft = gameFileCache.GetYft(carhash); @@ -9484,7 +9497,7 @@ namespace CodeWalker } if (CarGenerator != null) { - name = CarGenerator.CCarGen.carModel.ToString(); + name = CarGenerator.NameString(); } if (EntityExtension != null) {