From 92bdf65d7ff48cf2e2ad494e398143519bb8a0c9 Mon Sep 17 00:00:00 2001 From: dexy Date: Thu, 11 Jul 2024 09:53:09 +1000 Subject: [PATCH] PR #182 but slightly nicer --- CodeWalker.Core/World/Water.cs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CodeWalker.Core/World/Water.cs b/CodeWalker.Core/World/Water.cs index 9503eca..3f613e6 100644 --- a/CodeWalker.Core/World/Water.cs +++ b/CodeWalker.Core/World/Water.cs @@ -21,16 +21,30 @@ namespace CodeWalker.World { GameFileCache = gameFileCache; - var rpfman = gameFileCache.RpfMan; - string filename = "common.rpf\\data\\levels\\gta5\\water.xml"; + WaterQuads.Clear(); + CalmingQuads.Clear(); + WaveQuads.Clear(); + LoadWaterXml("common.rpf\\data\\levels\\gta5\\water.xml"); + + if (GameFileCache.EnableDlc) + { + LoadWaterXml("update\\update.rpf\\common\\data\\levels\\gta5\\water_heistisland.xml"); + } + + + Inited = true; + } + + private void LoadWaterXml(string filename) + { + var rpfman = GameFileCache.RpfMan; XmlDocument waterxml = rpfman.GetFileXml(filename); XmlElement waterdata = waterxml.DocumentElement; XmlNodeList waterquads = waterdata.SelectNodes("WaterQuads/Item"); - WaterQuads.Clear(); for (int i = 0; i < waterquads.Count; i++) { var waterquad = new WaterQuad(); @@ -39,7 +53,6 @@ namespace CodeWalker.World } XmlNodeList calmingquads = waterdata.SelectNodes("CalmingQuads/Item"); - CalmingQuads.Clear(); for (int i = 0; i < calmingquads.Count; i++) { var calmingquad = new WaterCalmingQuad(); @@ -48,7 +61,6 @@ namespace CodeWalker.World } XmlNodeList wavequads = waterdata.SelectNodes("WaveQuads/Item"); - WaveQuads.Clear(); for (int i = 0; i < wavequads.Count; i++) { var wavequad = new WaterWaveQuad(); @@ -56,7 +68,6 @@ namespace CodeWalker.World WaveQuads.Add(wavequad); } - Inited = true; }