PR #182 but slightly nicer

This commit is contained in:
dexy 2024-07-11 09:53:09 +10:00
parent 27a07461b1
commit 92bdf65d7f

View File

@ -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;
}