From 528ab1a98cacde7f209fd12f3854ea471085dd4d Mon Sep 17 00:00:00 2001
From: Niek Schoemaker <32094562+niekschoemaker@users.noreply.github.com>
Date: Sat, 6 Jan 2024 19:41:10 +0100
Subject: [PATCH] Another big commit, updated to .NET 8.0 and a lot more
refactoring and optimizations
---
.editorconfig | 76 +
CodeWalker.Benchmarks/Benchmarks.cs | 447 +-
.../CodeWalker.Benchmarks.csproj | 60 +-
CodeWalker.Benchmarks/Program.cs | 7 +-
CodeWalker.Core/CodeWalker.Core.csproj | 24 +-
.../GameFiles/FileTypes/AwcFile.cs | 87 +-
.../FileTypes/Builders/YnvBuilder.cs | 80 +-
.../GameFiles/FileTypes/CacheDatFile.cs | 118 +-
.../GameFiles/FileTypes/CarColsFile.cs | 5 +-
.../GameFiles/FileTypes/CarVariationsFile.cs | 70 +-
.../GameFiles/FileTypes/CutFile.cs | 19 +-
.../GameFiles/FileTypes/DlcContentFile.cs | 283 +-
.../GameFiles/FileTypes/DlcSetupFile.cs | 4 +-
.../GameFiles/FileTypes/FxcFile.cs | 38 +-
.../GameFiles/FileTypes/GtxdFile.cs | 82 +-
.../GameFiles/FileTypes/Gxt2File.cs | 134 +-
.../GameFiles/FileTypes/HeightmapFile.cs | 65 +-
.../GameFiles/FileTypes/JPsoFile.cs | 3 -
.../GameFiles/FileTypes/MrfFile.cs | 2 +-
.../GameFiles/FileTypes/PedFile.cs | 29 +-
.../GameFiles/FileTypes/PedShopMetaFile.cs | 112 +
.../GameFiles/FileTypes/PedsFile.cs | 83 +-
.../GameFiles/FileTypes/RelFile.cs | 5879 ++++--
.../GameFiles/FileTypes/VehiclesFile.cs | 486 +-
.../GameFiles/FileTypes/WatermapFile.cs | 4 +-
.../GameFiles/FileTypes/YbnFile.cs | 41 +-
.../GameFiles/FileTypes/YcdFile.cs | 8 +-
.../GameFiles/FileTypes/YddFile.cs | 46 +-
.../GameFiles/FileTypes/YdrFile.cs | 48 +-
.../GameFiles/FileTypes/YedFile.cs | 6 +-
.../GameFiles/FileTypes/YfdFile.cs | 8 +-
.../GameFiles/FileTypes/YftFile.cs | 31 +-
.../GameFiles/FileTypes/YldFile.cs | 8 +-
.../GameFiles/FileTypes/YmapFile.cs | 6648 +++---
.../GameFiles/FileTypes/YmfFile.cs | 80 +-
.../GameFiles/FileTypes/YmtFile.cs | 100 +-
.../GameFiles/FileTypes/YndFile.cs | 319 +-
.../GameFiles/FileTypes/YnvFile.cs | 187 +-
.../GameFiles/FileTypes/YptFile.cs | 6 +-
.../GameFiles/FileTypes/YtdFile.cs | 24 +-
.../GameFiles/FileTypes/YtypFile.cs | 217 +-
.../GameFiles/FileTypes/YvrFile.cs | 6 +-
.../GameFiles/FileTypes/YwrFile.cs | 6 +-
CodeWalker.Core/GameFiles/GameFile.cs | 169 +-
CodeWalker.Core/GameFiles/GameFileCache.cs | 1117 +-
.../GameFiles/MetaTypes/Archetype.cs | 441 +-
CodeWalker.Core/GameFiles/MetaTypes/Meta.cs | 1089 +-
.../GameFiles/MetaTypes/MetaBuilder.cs | 190 +-
.../GameFiles/MetaTypes/MetaNames.cs | 49 +-
.../GameFiles/MetaTypes/MetaTypes.cs | 4545 ++--
.../GameFiles/MetaTypes/MetaXml.cs | 963 +-
CodeWalker.Core/GameFiles/MetaTypes/Pso.cs | 650 +-
.../GameFiles/MetaTypes/PsoBuilder.cs | 81 +-
.../GameFiles/MetaTypes/PsoTypes.cs | 17402 +---------------
.../MetaTypes/PsoTypes/GetEnumInfo.cs | 1453 ++
.../MetaTypes/PsoTypes/GetStructureInfo.cs | 14000 +++++++++++++
CodeWalker.Core/GameFiles/MetaTypes/Rbf.cs | 266 +-
.../GameFiles/MetaTypes/XmlMeta.cs | 87 +-
CodeWalker.Core/GameFiles/MetaTypes/XmlPso.cs | 115 +-
CodeWalker.Core/GameFiles/MetaTypes/XmlRbf.cs | 69 +-
CodeWalker.Core/GameFiles/Resources/Bounds.cs | 897 +-
CodeWalker.Core/GameFiles/Resources/Clip.cs | 537 +-
.../GameFiles/Resources/Clothes.cs | 171 +-
.../GameFiles/Resources/Drawable.cs | 1216 +-
.../GameFiles/Resources/Expression.cs | 20 +-
CodeWalker.Core/GameFiles/Resources/Filter.cs | 28 +-
CodeWalker.Core/GameFiles/Resources/Frag.cs | 15 +-
CodeWalker.Core/GameFiles/Resources/Nav.cs | 319 +-
CodeWalker.Core/GameFiles/Resources/Node.cs | 59 +-
.../GameFiles/Resources/Particle.cs | 366 +-
.../GameFiles/Resources/PedsFiles.cs | 158 +
.../GameFiles/Resources/ResourceAnalyzer.cs | 2 +
.../GameFiles/Resources/ResourceBaseTypes.cs | 1031 +-
.../GameFiles/Resources/ResourceBuilder.cs | 15 +-
.../GameFiles/Resources/ResourceData.cs | 288 +-
.../GameFiles/Resources/ResourceFile.cs | 54 +-
.../GameFiles/Resources/Texture.cs | 94 +-
.../GameFiles/Resources/VehicleRecord.cs | 6 +-
.../GameFiles/Resources/VertexType.cs | 11 +-
.../GameFiles/Resources/WaypointRecord.cs | 15 +-
CodeWalker.Core/GameFiles/RpfFile.cs | 942 +-
CodeWalker.Core/GameFiles/RpfManager.cs | 404 +-
CodeWalker.Core/GameFiles/Utils/DDSIO.cs | 76 +-
CodeWalker.Core/GameFiles/Utils/Data.cs | 121 +-
CodeWalker.Core/GameFiles/Utils/GTACrypto.cs | 82 +-
CodeWalker.Core/GameFiles/Utils/GTAKeys.cs | 38 +-
CodeWalker.Core/GameFiles/Utils/Jenk.cs | 264 +-
CodeWalker.Core/GlobalSuppressions.cs | 8 +
.../PublishProfiles/FolderProfile.pubxml | 15 +
CodeWalker.Core/Tests/GameFileCache.cs | 220 +-
CodeWalker.Core/Utils/BoundingBoxes.cs | 14 +-
CodeWalker.Core/Utils/Cache.cs | 55 +-
CodeWalker.Core/Utils/ETWEvents.cs | 33 +-
CodeWalker.Core/Utils/Fbx.cs | 11 +-
CodeWalker.Core/Utils/FbxConverter.cs | 48 +-
CodeWalker.Core/Utils/FileUtils.cs | 48 +
CodeWalker.Core/Utils/Matrices.cs | 26 +-
CodeWalker.Core/Utils/Quaternions.cs | 8 +-
CodeWalker.Core/Utils/SharedObjectPool.cs | 59 +
CodeWalker.Core/Utils/SplitEnumerator.cs | 184 +-
CodeWalker.Core/Utils/StreamingExtensions.cs | 444 +-
CodeWalker.Core/Utils/ThrowHelper.cs | 40 +-
CodeWalker.Core/Utils/Timer.cs | 19 +-
CodeWalker.Core/Utils/TriangleBVH.cs | 104 +-
CodeWalker.Core/Utils/Utils.cs | 194 +-
CodeWalker.Core/Utils/Vectors.cs | 208 +-
CodeWalker.Core/Utils/Xml.cs | 348 +-
CodeWalker.Core/World/AudioZones.cs | 47 +-
CodeWalker.Core/World/Camera.cs | 6 +-
CodeWalker.Core/World/Clouds.cs | 15 +-
CodeWalker.Core/World/Entity.cs | 6 +-
CodeWalker.Core/World/Heightmaps.cs | 50 +-
CodeWalker.Core/World/Ped.cs | 220 +-
CodeWalker.Core/World/PopZones.cs | 79 +-
CodeWalker.Core/World/Scenarios.cs | 741 +-
CodeWalker.Core/World/Space.cs | 805 +-
CodeWalker.Core/World/Timecycle.cs | 59 +-
CodeWalker.Core/World/TimecycleMods.cs | 20 +-
CodeWalker.Core/World/Trains.cs | 46 +-
CodeWalker.Core/World/Water.cs | 25 +-
CodeWalker.Core/World/Watermaps.cs | 161 +-
CodeWalker.Core/World/Weather.cs | 4 +-
CodeWalker.Peds/CodeWalker.Peds.csproj | 2 +-
CodeWalker.Peds/Program.cs | 16 +-
.../PublishProfiles/FolderProfile.pubxml | 18 +
.../CodeWalker.RPFExplorer.csproj | 6 +-
CodeWalker.RPFExplorer/Program.cs | 5 +-
.../PublishProfiles/FolderProfile.pubxml | 18 +
CodeWalker.Shaders/CodeWalker.Shaders.vcxproj | 7 +-
CodeWalker.Shaders/LightPS.hlsl | 3 +-
CodeWalker.Shaders/LightPS.hlsli | 25 +
CodeWalker.Shaders/LightPS_MS.hlsl | 3 +-
CodeWalker.Shaders/LodLightsVS.hlsl | 1 +
CodeWalker.Shaders/Shadowmap.hlsli | 9 +-
CodeWalker.Test/CodeWalker.Test.csproj | 10 +-
CodeWalker.Test/Files/content.xml | 382 +
CodeWalker.Test/FloatUtilTests.cs | 35 +
CodeWalker.Test/GTACryptTests.cs | 2 +-
CodeWalker.Test/GameFileTests.cs | 70 +
CodeWalker.Test/MetaTypesTests.cs | 716 +
CodeWalker.Test/ResourceBaseTypesTests.cs | 37 +
CodeWalker.Test/RpfFileTests.cs | 58 +
CodeWalker.Test/SequenceReaderTests.cs | 34 +
CodeWalker.Test/TestBinaryConversions.cs | 534 -
CodeWalker.Test/XmlTests.cs | 46 +-
.../CodeWalker.Vehicles.csproj | 2 +-
.../CodeWalker.WinForms.csproj | 3 +-
CodeWalker.WinForms/FormUtils.cs | 135 +-
.../PropertyGridFix.Designer.cs | 6 +-
.../ReadOnlyPropertyGrid.Designer.cs | 2 +-
CodeWalker.WinForms/ReadOnlyPropertyGrid.resx | 120 +
CodeWalker.sln | 6 +-
CodeWalker/.editorconfig | 0
CodeWalker/CodeWalker.csproj | 43 +-
CodeWalker/ExploreForm.cs | 849 +-
CodeWalker/Forms/HexForm.cs | 10 +-
CodeWalker/Forms/MetaForm.cs | 162 +-
CodeWalker/Forms/ModelForm.cs | 469 +-
CodeWalker/Forms/ModelLightForm.cs | 16 +-
CodeWalker/Forms/ModelMatForm.cs | 26 +-
CodeWalker/Forms/RelForm.Designer.cs | 942 +-
CodeWalker/Forms/RelForm.cs | 94 +-
CodeWalker/Forms/RelForm.resx | 114 +-
CodeWalker/Forms/TextForm.cs | 2 +-
CodeWalker/Forms/YtdForm.cs | 5 +-
CodeWalker/GameFiles/GameFileCacheFactory.cs | 5 -
CodeWalker/GameFiles/TextureFormats.cs | 2 +
CodeWalker/PedsForm.Designer.cs | 2168 +-
CodeWalker/PedsForm.cs | 608 +-
CodeWalker/PedsForm.resx | 50 +-
CodeWalker/Program.cs | 66 +-
CodeWalker/Project/MenyooXml.cs | 5 +-
.../Panels/EditAudioEmitterListPanel.cs | 8 +-
.../Project/Panels/EditAudioEmitterPanel.cs | 166 +-
.../Project/Panels/EditAudioZonePanel.cs | 11 +-
CodeWalker/Project/Panels/EditMultiPanel.cs | 6 +-
.../Panels/EditProjectManifestPanel.cs | 17 +-
.../Project/Panels/EditScenarioNodePanel.cs | 15 +-
.../Project/Panels/EditYmapGrassPanel.cs | 7 +-
CodeWalker/Project/Panels/EditYmapPanel.cs | 161 +-
.../Panels/EditYtypArchetypePanel.Designer.cs | 895 +-
.../Project/Panels/EditYtypArchetypePanel.cs | 50 +-
.../Panels/EditYtypArchetypePanel.resx | 50 +-
.../Project/Panels/EditYtypMloEntSetPanel.cs | 6 +-
.../Project/Panels/GenerateLODLightsPanel.cs | 26 +-
.../Project/Panels/GenerateNavMeshPanel.cs | 20 +-
.../Project/Panels/ProjectExplorerPanel.cs | 1443 +-
CodeWalker/Project/ProjectFile.cs | 1042 +-
CodeWalker/Project/ProjectForm.cs | 1837 +-
CodeWalker/Project/UndoStep.cs | 13 +-
.../PublishProfiles/ClickOnceProfile.pubxml | 43 +
.../PublishProfiles/FolderProfile.pubxml | 18 +
CodeWalker/Properties/Settings.Designer.cs | 76 +-
CodeWalker/Properties/Settings.settings | 12 +-
CodeWalker/Rendering/DirectX/DXForm.cs | 5 +-
CodeWalker/Rendering/DirectX/DXManager.cs | 146 +-
CodeWalker/Rendering/DirectX/DXUtility.cs | 6 +-
CodeWalker/Rendering/Renderable.cs | 409 +-
CodeWalker/Rendering/RenderableCache.cs | 83 +-
CodeWalker/Rendering/Renderer.cs | 953 +-
CodeWalker/Rendering/ShaderManager.cs | 205 +-
CodeWalker/Rendering/Shaders/BasicShader.cs | 96 +-
CodeWalker/Rendering/Shaders/BoundsShader.cs | 4 +-
CodeWalker/Rendering/Shaders/CableShader.cs | 9 +-
CodeWalker/Rendering/Shaders/CloudsShader.cs | 4 +-
CodeWalker/Rendering/Shaders/DeferredScene.cs | 239 +-
.../Rendering/Shaders/DistantLightsShader.cs | 6 +-
CodeWalker/Rendering/Shaders/MarkerShader.cs | 4 +-
CodeWalker/Rendering/Shaders/PathShader.cs | 4 +-
CodeWalker/Rendering/Shaders/PostProcessor.cs | 275 +-
CodeWalker/Rendering/Shaders/Shader.cs | 2 +-
CodeWalker/Rendering/Shaders/ShadowShader.cs | 53 +-
CodeWalker/Rendering/Shaders/SkydomeShader.cs | 7 +-
CodeWalker/Rendering/Shaders/TerrainShader.cs | 11 +-
.../Rendering/Shaders/TreesLodShader.cs | 4 +-
CodeWalker/Rendering/Shaders/WaterShader.cs | 24 +-
CodeWalker/Rendering/Shaders/WidgetShader.cs | 6 +-
CodeWalker/Rendering/Utils/GpuBuffers.cs | 271 +-
.../Rendering/Utils/ShaderExtensions.cs | 57 +
CodeWalker/Rendering/Utils/Shadowmap.cs | 6 +-
CodeWalker/Rendering/Utils/UnitCylinder.cs | 23 +-
CodeWalker/Rendering/Utils/UnitSphere.cs | 33 +-
CodeWalker/Rendering/VertexTypes.cs | 2 +-
CodeWalker/Settings.cs | 11 +-
CodeWalker/Tools/AudioExplorerForm.cs | 127 +-
CodeWalker/Tools/BinarySearchForm.cs | 65 +-
CodeWalker/Tools/BrowseForm.cs | 70 +-
CodeWalker/Tools/ExtractKeysForm.cs | 6 +-
CodeWalker/Tools/ExtractRawForm.cs | 9 +-
CodeWalker/Tools/ExtractScriptsForm.cs | 12 +-
CodeWalker/Tools/ExtractShadersForm.cs | 7 +-
CodeWalker/Tools/ExtractTexForm.cs | 22 +-
CodeWalker/Tools/ImportFbxForm.cs | 14 +-
CodeWalker/Tools/JenkIndForm.cs | 18 +-
CodeWalker/Utils/AudioUtils.cs | 20 +-
CodeWalker/Utils/ConsoleWindow.cs | 49 +-
CodeWalker/Utils/GTAFolder.cs | 3 +-
CodeWalker/Utils/MapUtils.cs | 35 +-
CodeWalker/Utils/NamedPipe.cs | 128 +-
CodeWalker/Utils/OpenAnyFile.cs | 4 +-
CodeWalker/Utils/Synthesizer.cs | 16 +-
CodeWalker/VehicleForm.cs | 196 +-
CodeWalker/World/CutsceneForm.cs | 185 +-
CodeWalker/World/MapSelection.cs | 801 +-
CodeWalker/World/Widget.cs | 2 +-
CodeWalker/World/WorldInfoForm.cs | 19 +-
CodeWalker/World/WorldSearchForm.cs | 322 +-
CodeWalker/WorldForm.Designer.cs | 7266 ++++---
CodeWalker/WorldForm.cs | 1269 +-
CodeWalker/WorldForm.resx | 110 +-
Shaders/BasicPS.cso | Bin 11084 -> 121072 bytes
Shaders/BasicPS_Deferred.cso | Bin 6744 -> 73828 bytes
Shaders/BasicVS_Box.cso | Bin 4548 -> 125712 bytes
Shaders/BasicVS_Capsule.cso | Bin 5208 -> 126388 bytes
Shaders/BasicVS_Cylinder.cso | Bin 5256 -> 126436 bytes
Shaders/BasicVS_PBBNCCT.cso | Bin 11832 -> 142404 bytes
Shaders/BasicVS_PBBNCCTTX.cso | Bin 12556 -> 147224 bytes
Shaders/BasicVS_PBBNCCTX.cso | Bin 12532 -> 145152 bytes
Shaders/BasicVS_PBBNCT.cso | Bin 11800 -> 142372 bytes
Shaders/BasicVS_PBBNCTT.cso | Bin 11824 -> 142396 bytes
Shaders/BasicVS_PBBNCTTT.cso | Bin 11848 -> 142420 bytes
Shaders/BasicVS_PBBNCTTX.cso | Bin 12524 -> 145144 bytes
Shaders/BasicVS_PBBNCTX.cso | Bin 12500 -> 145120 bytes
Shaders/BasicVS_PNCCT.cso | Bin 10120 -> 137888 bytes
Shaders/BasicVS_PNCCTT.cso | Bin 10144 -> 137912 bytes
Shaders/BasicVS_PNCCTTT.cso | Bin 10168 -> 137936 bytes
Shaders/BasicVS_PNCCTTTX.cso | Bin 10716 -> 140532 bytes
Shaders/BasicVS_PNCCTTX.cso | Bin 10692 -> 140508 bytes
Shaders/BasicVS_PNCCTX.cso | Bin 10668 -> 140484 bytes
Shaders/BasicVS_PNCT.cso | Bin 10088 -> 136564 bytes
Shaders/BasicVS_PNCTT.cso | Bin 10112 -> 136588 bytes
Shaders/BasicVS_PNCTTT.cso | Bin 10136 -> 136612 bytes
Shaders/BasicVS_PNCTTTX.cso | Bin 10684 -> 140500 bytes
Shaders/BasicVS_PNCTTX.cso | Bin 10660 -> 140476 bytes
Shaders/BasicVS_PNCTX.cso | Bin 10636 -> 140452 bytes
Shaders/BasicVS_Sphere.cso | Bin 4456 -> 123560 bytes
Shaders/BoundingBoxVS.cso | Bin 1524 -> 30000 bytes
Shaders/BoundingSphereVS.cso | Bin 1352 -> 27752 bytes
Shaders/BoundsPS.cso | Bin 504 -> 12404 bytes
Shaders/CablePS.cso | Bin 7116 -> 71744 bytes
Shaders/CablePS_Deferred.cso | Bin 3076 -> 57872 bytes
Shaders/CableVS.cso | Bin 9864 -> 135584 bytes
Shaders/CloudsPS.cso | Bin 2772 -> 48268 bytes
Shaders/CloudsVS.cso | Bin 4716 -> 70784 bytes
Shaders/DirLightPS.cso | Bin 7484 -> 87508 bytes
Shaders/DirLightPS_MS.cso | Bin 40892 -> 176680 bytes
Shaders/DirLightVS.cso | Bin 996 -> 27120 bytes
Shaders/DistantLightsPS.cso | Bin 660 -> 14572 bytes
Shaders/DistantLightsVS.cso | Bin 1892 -> 30312 bytes
Shaders/LightPS.cso | Bin 5968 -> 79196 bytes
Shaders/LightPS_MS.cso | Bin 33608 -> 143700 bytes
Shaders/LightVS.cso | Bin 2500 -> 30672 bytes
Shaders/LodLightsPS.cso | Bin 5984 -> 79212 bytes
Shaders/LodLightsPS_MS.cso | Bin 34656 -> 148844 bytes
Shaders/LodLightsVS.cso | Bin 2600 -> 32820 bytes
Shaders/MarkerPS.cso | Bin 584 -> 14496 bytes
Shaders/MarkerVS.cso | Bin 1360 -> 27732 bytes
Shaders/PPBloomFilterBPHCS.cso | Bin 3256 -> 21188 bytes
Shaders/PPBloomFilterVCS.cso | Bin 2556 -> 22536 bytes
Shaders/PPCopyPixelsPS.cso | Bin 884 -> 14856 bytes
Shaders/PPFinalPassPS.cso | Bin 1456 -> 15444 bytes
Shaders/PPFinalPassVS.cso | Bin 532 -> 12388 bytes
Shaders/PPLumBlendCS.cso | Bin 976 -> 14812 bytes
Shaders/PPReduceTo0DCS.cso | Bin 2224 -> 18108 bytes
Shaders/PPReduceTo1DCS.cso | Bin 2136 -> 20068 bytes
Shaders/PPSSAAPS.cso | Bin 1420 -> 17304 bytes
Shaders/PathBoxPS.cso | Bin 504 -> 12360 bytes
Shaders/PathBoxVS.cso | Bin 1316 -> 15344 bytes
Shaders/PathDynVS.cso | Bin 1420 -> 27764 bytes
Shaders/PathPS.cso | Bin 472 -> 12328 bytes
Shaders/PathVS.cso | Bin 984 -> 14992 bytes
Shaders/ShadowPS.cso | Bin 1156 -> 15156 bytes
Shaders/ShadowVS.cso | Bin 2588 -> 35292 bytes
Shaders/ShadowVS_Skin.cso | Bin 4220 -> 42632 bytes
Shaders/SkyMoonPS.cso | Bin 780 -> 14736 bytes
Shaders/SkyMoonVS.cso | Bin 1144 -> 27496 bytes
Shaders/SkySunPS.cso | Bin 508 -> 12408 bytes
Shaders/SkySunVS.cso | Bin 1104 -> 27456 bytes
Shaders/SkydomePS.cso | Bin 3720 -> 53252 bytes
Shaders/SkydomeVS.cso | Bin 5408 -> 83592 bytes
Shaders/TerrainPS.cso | Bin 13328 -> 102712 bytes
Shaders/TerrainPS_Deferred.cso | Bin 9300 -> 88672 bytes
Shaders/TerrainVS_PNCCT.cso | Bin 4912 -> 64632 bytes
Shaders/TerrainVS_PNCCTT.cso | Bin 4936 -> 64656 bytes
Shaders/TerrainVS_PNCCTTTX.cso | Bin 5508 -> 65228 bytes
Shaders/TerrainVS_PNCCTTX.cso | Bin 5484 -> 65204 bytes
Shaders/TerrainVS_PNCCTX.cso | Bin 5460 -> 65180 bytes
Shaders/TerrainVS_PNCTTTX.cso | Bin 5484 -> 65204 bytes
Shaders/TerrainVS_PNCTTX.cso | Bin 5460 -> 65180 bytes
Shaders/TreesLodPS.cso | Bin 2072 -> 32596 bytes
Shaders/TreesLodPS_Deferred.cso | Bin 1340 -> 29512 bytes
Shaders/TreesLodVS.cso | Bin 3012 -> 37748 bytes
Shaders/WaterPS.cso | Bin 9896 -> 138292 bytes
Shaders/WaterPS_Deferred.cso | Bin 5824 -> 74956 bytes
Shaders/WaterVS_PCT.cso | Bin 4600 -> 91020 bytes
Shaders/WaterVS_PNCT.cso | Bin 4604 -> 91024 bytes
Shaders/WaterVS_PNCTX.cso | Bin 5020 -> 91440 bytes
Shaders/WaterVS_PT.cso | Bin 4096 -> 88468 bytes
Shaders/WidgetPS.cso | Bin 544 -> 12400 bytes
Shaders/WidgetVS.cso | Bin 2068 -> 18412 bytes
340 files changed, 52838 insertions(+), 45035 deletions(-)
create mode 100644 .editorconfig
create mode 100644 CodeWalker.Core/GameFiles/FileTypes/PedShopMetaFile.cs
create mode 100644 CodeWalker.Core/GameFiles/MetaTypes/PsoTypes/GetEnumInfo.cs
create mode 100644 CodeWalker.Core/GameFiles/MetaTypes/PsoTypes/GetStructureInfo.cs
create mode 100644 CodeWalker.Core/GameFiles/Resources/PedsFiles.cs
create mode 100644 CodeWalker.Core/GlobalSuppressions.cs
create mode 100644 CodeWalker.Core/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 CodeWalker.Core/Utils/FileUtils.cs
create mode 100644 CodeWalker.Core/Utils/SharedObjectPool.cs
create mode 100644 CodeWalker.Peds/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 CodeWalker.RPFExplorer/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 CodeWalker.Test/Files/content.xml
create mode 100644 CodeWalker.Test/FloatUtilTests.cs
create mode 100644 CodeWalker.Test/GameFileTests.cs
create mode 100644 CodeWalker.Test/MetaTypesTests.cs
create mode 100644 CodeWalker.Test/ResourceBaseTypesTests.cs
create mode 100644 CodeWalker.Test/RpfFileTests.cs
create mode 100644 CodeWalker.Test/SequenceReaderTests.cs
delete mode 100644 CodeWalker.Test/TestBinaryConversions.cs
create mode 100644 CodeWalker.WinForms/ReadOnlyPropertyGrid.resx
create mode 100644 CodeWalker/.editorconfig
create mode 100644 CodeWalker/Properties/PublishProfiles/ClickOnceProfile.pubxml
create mode 100644 CodeWalker/Properties/PublishProfiles/FolderProfile.pubxml
create mode 100644 CodeWalker/Rendering/Utils/ShaderExtensions.cs
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a975f0c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,76 @@
+[*.cs]
+
+# CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
+
+error_prone.large_struct_threshold = 128
+csharp_indent_labels = one_less_than_current
+csharp_using_directive_placement = outside_namespace:silent
+csharp_prefer_simple_using_statement = true:suggestion
+csharp_prefer_braces = true:silent
+csharp_style_namespace_declarations = block_scoped:silent
+csharp_style_prefer_method_group_conversion = true:silent
+csharp_style_prefer_top_level_statements = true:silent
+csharp_style_prefer_primary_constructors = true:suggestion
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+csharp_style_expression_bodied_lambdas = true:silent
+csharp_style_expression_bodied_local_functions = false:silent
+[*.{cs,vb}]
+dotnet_style_operator_placement_when_wrapping = beginning_of_line
+tab_width = 4
+indent_size = 4
+end_of_line = crlf
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
+[*.{cs,vb}]
+#### Naming styles ####
+
+# Naming rules
+
+dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
+dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
+dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+
+dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.types_should_be_pascal_case.symbols = types
+dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+
+dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
+dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+
+# Symbol specifications
+
+dotnet_naming_symbols.interface.applicable_kinds = interface
+dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.interface.required_modifiers =
+
+dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
+dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.types.required_modifiers =
+
+dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
+dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+dotnet_naming_symbols.non_field_members.required_modifiers =
+
+# Naming styles
+
+dotnet_naming_style.begins_with_i.required_prefix = I
+dotnet_naming_style.begins_with_i.required_suffix =
+dotnet_naming_style.begins_with_i.word_separator =
+dotnet_naming_style.begins_with_i.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
+
+dotnet_naming_style.pascal_case.required_prefix =
+dotnet_naming_style.pascal_case.required_suffix =
+dotnet_naming_style.pascal_case.word_separator =
+dotnet_naming_style.pascal_case.capitalization = pascal_case
diff --git a/CodeWalker.Benchmarks/Benchmarks.cs b/CodeWalker.Benchmarks/Benchmarks.cs
index acf4ff9..6aa2e6c 100644
--- a/CodeWalker.Benchmarks/Benchmarks.cs
+++ b/CodeWalker.Benchmarks/Benchmarks.cs
@@ -1,189 +1,199 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
+using BenchmarkDotNet.Diagnosers;
+using BenchmarkDotNet.Disassemblers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using CodeWalker.Core.Utils;
using CodeWalker.GameFiles;
+using Collections.Pooled;
+using CommunityToolkit.HighPerformance;
+using SharpDX;
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
using System.Linq;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Xml;
using System.Xml.Linq;
+using static System.Net.Mime.MediaTypeNames;
namespace CodeWalker.Benchmarks
{
+ //[InProcess]
+ [ShortRunJob]
[MemoryDiagnoser]
public class Benchmarks
{
- public const string markup = @"
- vehshare
-
-
- -
- brabusgt600brabusgt600
- brabusgt600
- GT 600
- BRABUS
- null
- null
- null
- null
-
- null
- ta176m177
- LAYOUT_LOW
- BULLET_COVER_OFFSET_INFO
- EXPLOSION_INFO_DEFAULT
-
- DEFAULT_FOLLOW_VEHICLE_CAMERA
- MID_BOX_VEHICLE_AIM_CAMERA
- VEHICLE_BONNET_CAMERA_NEAR_EXTRA_HIGH
- DEFAULT_POV_CAMERA
-
-
-
-
-
-
-
-
-
-
-
-
-
- VFXVEHICLEINFO_CAR_BULLET
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 60.000000
- 80.000000
- 100.000000
- 120.000000
- 500.000000
- 500.000000
-
-
-
-
-
-
-
-
-
-
- SWANKNESS_3
-
- FLAG_SPORTS FLAG_RICH_CAR FLAG_NO_BROKEN_DOWN_SCENARIO FLAG_RECESSED_TAILLIGHT_CORONAS FLAG_NO_HEAVY_BRAKE_ANIMATION
- VEHICLE_TYPE_CAR
- VPT_FRONT_AND_BACK_PLATES
- VDT_BANSHEE
- VC_SPORT
- VWT_HIEND
-
-
- docktrailer
- - trailers
- - trailers2
- - trailers3
- - trailers4
- - tanker
- - trailerlogs
- - tr2
- - trflat
-
-
-
- -
- S_M_Y_Cop_01
-
-
-
-
-
-
-
-
-
-
-
- - WHEEL_FRONT_RIGHT_CAMERA
- - WHEEL_FRONT_LEFT_CAMERA
- - WHEEL_REAR_RIGHT_CAMERA
- - WHEEL_REAR_LEFT_CAMERA
-
-
-
-
-
-
-
-
-
-
- - LOW_BULLET_FRONT_LEFT
- - LOW_BULLET_FRONT_RIGHT
-
-
-
+ //private class Config : ManualConfig
+ //{
+ // public Config()
+ // {
+ // AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)));
+ // AddDiagnoser(new DisassemblyDiagnoser(new DisassemblyDiagnoserConfig()));
+
+
+ // }
+ //}
+ private static string markup = "\r\n ";
+ private List listClass;
+ private List listStruct;
+ private PooledList pooledListClass;
+ private PooledList pooledListStruct;
+
+ public class SimpleType
+ {
+ public int Value1;
+ }
+
+ public class SimpleType2 : SimpleType
+ {
+ public int Value2;
+ }
+
+ public class SimpleType3
+ {
+ public long Value1;
+ public long Value2;
+ public long Value3;
+
+ public SimpleType3()
+ {
+ Value1 = random.Next();
+ Value2 = random.Next();
+ Value3 = random.Next();
+ }
+ }
+
+ private SimpleType[] intArr;
+ private List intList;
+ private static Random random = new Random(42);
+ public struct BigStruct
+ {
+ public long Value1;
+ public long Value2;
+ public long Value3;
+ public long Value4;
+ public long Value5;
+ public long Value6;
+ public long Value7;
+ public long Value8;
+ public BigStruct()
+ {
+ Value1 = random.Next();
+ Value2 = random.Next();
+ Value3 = random.Next();
+ Value4 = random.Next();
+ Value5 = random.Next();
+ Value6 = random.Next();
+ Value7 = random.Next();
+ Value8 = random.Next();
+ }
+ public BigStruct(long value1, long value2, long value3, long value4, long value5, long value6, long value7, long value8)
+ {
+ Value1 = value1;
+ Value2 = value2;
+ Value3 = value3;
+ Value4 = value4;
+ Value5 = value5;
+ Value6 = value6;
+ Value7 = value7;
+ Value8 = value8;
+ }
+ public static BigStruct operator +(in BigStruct left, in BigStruct right)
+ {
+ return new BigStruct(
+ left.Value1 + right.Value1,
+ left.Value2 + right.Value2,
+ left.Value3 + right.Value3,
+ left.Value4 + right.Value4,
+ left.Value5 + right.Value5,
+ left.Value6 + right.Value6,
+ left.Value7 + right.Value7,
+ left.Value8 + right.Value8
+ );
+ }
+ }
+ [Params(10, 100, 1000)]
+ public int Length { get; set; } = 10000;
+ [Params(100)]
+ public int Chance { get; set; } = 25;
+ public ArrayOfChars64 chars64;
+ private BigStruct[] vectors = new BigStruct[0];
+ private BigStruct vector;
-
-
- -
- vehicles_banshee_interior
- brabusgt600
-
+ private byte valueByte;
+ private uint valueUint;
+ private uint[] data;
+ private MetaName[] Values;
-
-
-";
+ private int randomValue;
- private byte[] data;
- private RpfFileEntry fileEntry;
+ private uint[] ushorts = new uint[0];
+
+ private string Str = "iakslgbhfibnrihbderpiugaehigoI BIHGVUIVDSOUFVBOUADGBOIUYfgiuywetrg872q13rh9872`134tgyihsbaopuJGUIYODGBFIOUFgvbouailksdbhnfp";
[GlobalSetup]
public void Setup()
{
- data = new byte[2048];
- var random = new Random(42);
- for (int i = 0; i < data.Length; i++)
+ random = new Random(42);
+
+ valueByte = 0;
+ valueUint = 0;
+
+ ushorts = new uint[Length];
+
+ for (int i = 0; i < Length; i++)
{
- data[i] = (byte)random.Next(byte.MinValue, byte.MaxValue);
+ ushorts[i] = (uint)random.Next(0, int.MaxValue);
}
- GTA5Keys.LoadFromPath("C:\\Program Files\\Rockstar Games\\Grand Theft Auto V", "");
+
+ var hashes = MemoryMarshal.Cast(ushorts);
+
+ for (int i = 0; i < Length; i++)
+ {
+ Console.WriteLine($"{ushorts[i]} -> {hashes[i]}");
+ }
+
+ //Console.WriteLine("Setup done");
+
+ //XElement? result = null;
+ //var _doc = new XmlDocument();
+ //_doc.LoadXml(markup);
+
+ //var doc = XDocument.Load(new XmlNodeReader(_doc));
+ //Console.WriteLine(doc.Root);
+
+ //data = new byte[2048];
+ //var random = new Random(42);
+ //for (int i = 0; i < data.Length; i++)
+ //{
+ // data[i] = (byte)random.Next(byte.MinValue, byte.MaxValue);
+ //}
+ //GTA5Keys.LoadFromPath("C:\\Program Files\\Rockstar Games\\Grand Theft Auto V", "");
+
+ //rotation = new Quaternion(random.NextFloat(-1.0f, 1.0f), random.NextFloat(-1.0f, 1.0f), random.NextFloat(-1.0f, 1.0f), random.NextFloat(-1.0f, 1.0f));
+ //translation = new Vector3(random.NextFloat(-1.0f, 1.0f), random.NextFloat(-1.0f, 1.0f), random.NextFloat(-1.0f, 1.0f));
+ //scale = random.NextFloat(-1.0f, 1.0f);
+ //matrix = Matrix.AffineTransformation(scale, rotation, translation);
}
//[Benchmark(Baseline = true)]
@@ -200,16 +210,155 @@ namespace CodeWalker.Benchmarks
// vehiclesFile.Load(data, fileEntry);
//}
- [Benchmark]
- public void DecryptNGSpan()
+ //[Benchmark(Baseline = true)]
+ //public uint SwapBytes()
+ //{
+ // var result = test;
+ // for (int i = 0; i < 1000; i++)
+ // {
+ // result = MetaTypes.SwapBytes(result);
+ // }
+ // return result;
+ //}
+
+ //[Benchmark]
+ //public uint ReverseEndianness()
+ //{
+ // var result = test;
+ // for (int i = 0; i < 1000; i++)
+ // {
+ // result = BinaryPrimitives.ReverseEndianness(result);
+ // }
+
+ // return result;
+ //}
+
+ //[Benchmark]
+ //public int IndexOf()
+ //{
+ // return Str.IndexOf('\0');
+ //}
+
+ //[Benchmark]
+ //public int IndexOfAsSpan()
+ //{
+ // return Str.AsSpan().IndexOf('\0');
+ //}
+
+ private PooledList getPooledListClass()
{
- GTACrypto.DecryptNG(data.AsSpan(), "kaas", 2048);
+ var list = new PooledList();
+ for (int i = 0; i < Length; i++)
+ {
+ list.Add(new SimpleType3());
+ }
+
+ return list;
+ }
+
+ private PooledList getPooledListStruct()
+ {
+ var list = new PooledList();
+ for (int i = 0; i < Length; i++)
+ {
+ list.Add(new BigStruct());
+ }
+
+ return list;
+ }
+
+ private List getListClass()
+ {
+ var list = new List();
+ for (int i = 0; i < Length; i++)
+ {
+ list.Add(new SimpleType3());
+ }
+
+ return list;
+ }
+
+ private List getListStruct()
+ {
+ var list = new List();
+ for (int i = 0; i < Length; i++)
+ {
+ list.Add(new BigStruct());
+ }
+
+ return list;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private void inVectorOperator()
+ {
+ var vect = Vector256.Create(data.AsSpan());
+ var shiftVect = Vector256.Create(10);
+ var leftShiftVect = Vector256.Create(6);
+
+
+ }
+
+ private uint joaatLower(Span span)
+ {
+ uint h = 0;
+ for (int i = 0; i < span.Length; i++)
+ {
+ h += toLower(span[i]);
+ h += h << 10;
+ h ^= h >> 6;
+ }
+
+ return h;
+ }
+
+ private uint joaat(Span span)
+ {
+ uint h = 0;
+ for (int i = 0; i < span.Length; i++)
+ {
+ h += span[i];
+ h += h << 10;
+ h ^= h >> 6;
+ }
+
+ return h;
+ }
+
+ private void toLowerVectorized(Span span)
+ {
+ Ascii.ToLowerInPlace(span, out _);
+ }
+
+ private char toLower(char c)
+ {
+ return ('A' <= c && c <= 'Z') ? (char)(c | 0x20) : c;
+ }
+
+ private void toLowerPleb(Span span)
+ {
+ for (int i = 0; i < span.Length; i++)
+ {
+ span[i] = toLower(span[i]);
+ }
+ }
+
+
+
+ [Benchmark]
+ public void ReverseEndianness()
+ {
+ //BinaryPrimitives.ReverseEndianness(MemoryMarshal.Cast(ushorts), MemoryMarshal.Cast(ushorts));
}
[Benchmark]
- public void DecryptNG()
+ public void SwapBytes()
{
- GTACrypto.DecryptNG(data, "kaas", 2048);
+ var _ushorts = ushorts;
+ for (int i = 0; i < _ushorts.Length; i++)
+ {
+ _ushorts[i] = MetaTypes.SwapBytes(_ushorts[i]);
+ }
}
}
}
diff --git a/CodeWalker.Benchmarks/CodeWalker.Benchmarks.csproj b/CodeWalker.Benchmarks/CodeWalker.Benchmarks.csproj
index 69ad967..abffe71 100644
--- a/CodeWalker.Benchmarks/CodeWalker.Benchmarks.csproj
+++ b/CodeWalker.Benchmarks/CodeWalker.Benchmarks.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net8.0
Exe
false
CodeWalker.Benchmarks
@@ -8,8 +8,12 @@
Copyright © 2023
1.0.0.0
1.0.0.0
- latest
- true
+ latest
+ true
+ enable
+ AnyCPU
+ pdbonly
+ true
@@ -19,37 +23,37 @@
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/CodeWalker.Benchmarks/Program.cs b/CodeWalker.Benchmarks/Program.cs
index 4966c50..1267ce1 100644
--- a/CodeWalker.Benchmarks/Program.cs
+++ b/CodeWalker.Benchmarks/Program.cs
@@ -16,6 +16,10 @@ namespace CodeWalker.Benchmarks
static void Main(string[] args)
{
+#if DEBUG
+ var benchmarks = new Benchmarks();
+ benchmarks.Setup();
+
//var benchmarks = new Benchmarks();
//benchmarks.Setup();
@@ -28,8 +32,9 @@ namespace CodeWalker.Benchmarks
//benchmarks.GlobalCleanup();
//ParseBuffer();
-
+#else
BenchmarkRunner.Run();
+#endif
}
}
}
diff --git a/CodeWalker.Core/CodeWalker.Core.csproj b/CodeWalker.Core/CodeWalker.Core.csproj
index b5b3626..83a03f1 100644
--- a/CodeWalker.Core/CodeWalker.Core.csproj
+++ b/CodeWalker.Core/CodeWalker.Core.csproj
@@ -1,22 +1,28 @@
- net6.0
+ net8.0
latest
true
- annotations
+ enable
+
+
+
-
+
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
diff --git a/CodeWalker.Core/GameFiles/FileTypes/AwcFile.cs b/CodeWalker.Core/GameFiles/FileTypes/AwcFile.cs
index 0ed6b34..58db58a 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/AwcFile.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/AwcFile.cs
@@ -8,6 +8,7 @@ using TC = System.ComponentModel.TypeConverterAttribute;
using EXP = System.ComponentModel.ExpandableObjectConverter;
using System.Xml;
using System.Runtime.InteropServices;
+using CodeWalker.Core.Utils;
namespace CodeWalker.GameFiles
{
@@ -345,7 +346,8 @@ namespace CodeWalker.GameFiles
}
public static void WriteXmlNode(AwcFile f, StringBuilder sb, int indent, string wavfolder, string name = "AudioWaveContainer")
{
- if (f == null) return;
+ if (f == null)
+ return;
AwcXml.OpenTag(sb, indent, name);
f.WriteXml(sb, indent + 1, wavfolder);
AwcXml.CloseTag(sb, indent, name);
@@ -1014,7 +1016,7 @@ namespace CodeWalker.GameFiles
{
var export = !string.IsNullOrEmpty(wavfolder);
var fname = Name?.Replace("/", "")?.Replace("\\", "") ?? "0x0";
- byte[] fdata = null;
+ byte[] fdata;
if (MidiChunk != null)
{
fname += ".midi";
@@ -1038,8 +1040,10 @@ namespace CodeWalker.GameFiles
File.WriteAllBytes(filepath, fdata);
}
}
- catch
- { }
+ catch(Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
}
if (StreamFormat != null)
{
@@ -1107,8 +1111,10 @@ namespace CodeWalker.GameFiles
}
}
}
- catch
- { }
+ catch(Exception ex)
+ {
+ Console.WriteLine(ex);
+ }
}
@@ -1363,7 +1369,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- var hash = "0x" + (StreamInfo?.Id.ToString("X") ?? "0").PadLeft(8, '0') + ": ";
+ var hash = "0x" + (StreamInfo?.Id.ToString("X8") ?? "0000000") + ": ";
if (FormatChunk != null)
{
return hash + FormatChunk?.ToString() ?? "AwcAudio";
@@ -1876,7 +1882,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Id.ToString() + ", " + Codec.ToString() + ": " + Samples.ToString() + " samples, " + SamplesPerSecond.ToString() + " samples/sec, headroom: " + Headroom.ToString();
+ return $"{Id}, {Codec}: {Samples} samples, {SamplesPerSecond} samples/sec, headroom: {Headroom}";
}
}
@@ -1905,7 +1911,7 @@ namespace CodeWalker.GameFiles
resentry.SystemFlags = BitConverter.ToUInt32(data, 8);
resentry.GraphicsFlags = BitConverter.ToUInt32(data, 12);
- if (rsc7 != 0x37435352)
+ if (rsc7 != (uint)FileHeader.RSC7)
{ } //testing..
if (version != 46) //46 is Clip Dictionary...
{ }
@@ -2163,7 +2169,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return "gesture: " + (Gestures?.Length ?? 0).ToString() + " items";
+ return $"gesture: {Gestures?.Length ?? 0} items";
}
}
@@ -2198,32 +2204,26 @@ namespace CodeWalker.GameFiles
public void WriteLine(StringBuilder sb)
{
sb.Append(UnkUint1.ToString());
- sb.Append(" ");
+ sb.Append(' ');
sb.Append(FloatUtil.ToString(UnkFloat1));
- sb.Append(" ");
+ sb.Append(' ');
sb.Append(UnkUshort1.ToString());
- sb.Append(" ");
+ sb.Append(' ');
sb.Append(UnkUshort2.ToString());
sb.AppendLine();
}
public void ReadLine(string s)
{
- var split = s.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- var list = new List();
- foreach (var str in split)
+ Span ranges = stackalloc Range[5];
+ var span = s.AsSpan();
+ span.Split(ranges, ' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
+
+ if (ranges.Length >= 4)
{
- var tstr = str.Trim();
- if (!string.IsNullOrEmpty(tstr))
- {
- list.Add(tstr);
- }
- }
- if (list.Count >= 4)
- {
- uint.TryParse(list[0], out uint u1);
- FloatUtil.TryParse(list[1], out float f1);
- ushort.TryParse(list[2], out ushort s1);
- ushort.TryParse(list[3], out ushort s2);
+ uint.TryParse(span[ranges[0]], out uint u1);
+ FloatUtil.TryParse(span[ranges[1]], out float f1);
+ ushort.TryParse(span[ranges[2]], out ushort s1);
+ ushort.TryParse(span[ranges[3]], out ushort s2);
UnkUint1 = u1;
UnkFloat1 = f1;
UnkUshort1 = s1;
@@ -2247,7 +2247,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return UnkUint1.ToString() + ", " + UnkFloat1.ToString() + ", " + UnkUshort1.ToString() + ", " + UnkUshort2.ToString();
+ return $"{UnkUint1}, {UnkFloat1}, {UnkUshort1}, {UnkUshort2}";
}
}
@@ -2326,7 +2326,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return "granulargrains: " + (GranularGrains?.Length ?? 0).ToString() + " items";
+ return $"granulargrains: {(GranularGrains?.Length ?? 0)} items";
}
}
@@ -2410,7 +2410,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Identifier.ToString() + ": " + UnkUint1.ToString() + ": " + GrainCount.ToString() + " items";
+ return $"{Identifier}: {UnkUint1}: {GrainCount} items";
}
}
@@ -2456,7 +2456,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return "granularloops: " + (GranularLoops?.Length ?? 0).ToString() + " items";
+ return $"granularloops: {GranularLoops?.Length ?? 0} items";
}
}
@@ -2576,7 +2576,7 @@ namespace CodeWalker.GameFiles
break;
}
- return Name.ToString() + ": " + valstr + ", " + SampleOffset.ToString() + ", " + Unused.ToString();
+ return $"{Name}: {valstr}, {SampleOffset}, {Unused}";
}
}
@@ -3029,15 +3029,22 @@ namespace CodeWalker.GameFiles
public static string GetXml(AwcFile awc, string outputFolder = "")
{
- StringBuilder sb = new StringBuilder();
- sb.AppendLine(XmlHeader);
-
- if (awc != null)
+ StringBuilder sb = StringBuilderPool.Get();
+ try
{
- AwcFile.WriteXmlNode(awc, sb, 0, outputFolder);
- }
+ sb.AppendLine(XmlHeader);
- return sb.ToString();
+ if (awc != null)
+ {
+ AwcFile.WriteXmlNode(awc, sb, 0, outputFolder);
+ }
+
+ return sb.ToString();
+ }
+ finally
+ {
+ StringBuilderPool.Return(sb);
+ }
}
}
diff --git a/CodeWalker.Core/GameFiles/FileTypes/Builders/YnvBuilder.cs b/CodeWalker.Core/GameFiles/FileTypes/Builders/YnvBuilder.cs
index 37c97ec..0363214 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/Builders/YnvBuilder.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/Builders/YnvBuilder.cs
@@ -109,10 +109,10 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
foreach (var poly in polys) //split along borders
{
var verts = poly.Vertices;
- if (verts == null)
- { continue; }//ignore empty polys..
+ if (verts is null)
+ continue;//ignore empty polys..
if (verts.Length < 3)
- { continue; }//not enough verts for a triangle!
+ continue;//not enough verts for a triangle!
Vector2I gprev = NavGrid.GetCellPos(verts[0]);
int split1 = 0;
@@ -156,13 +156,18 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
verts1.Clear();
verts2.Clear();
- for (int i = 0; i < split1; i++) verts1.Add(verts[i]);
+ for (int i = 0; i < split1; i++)
+ verts1.Add(verts[i]);
+
verts1.Add(sp1);
verts1.Add(sp2);
- for (int i = split2end; i < verts.Length; i++) verts1.Add(verts[i]);
+
+ for (int i = split2end; i < verts.Length; i++)
+ verts1.Add(verts[i]);
verts2.Add(sp1);
- for (int i = split1; i < split2end; i++) verts2.Add(verts[i]);
+ for (int i = split1; i < split2end; i++)
+ verts2.Add(verts[i]);
verts2.Add(sp2);
poly1.Vertices = verts1.ToArray();
@@ -203,9 +208,9 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
var verts = poly.Vertices;
var ec = edges?.Length ?? 0;
if (ec <= 0)
- { continue; }//shouldn't happen - no edges?
+ continue;//shouldn't happen - no edges?
if (ec != poly.Vertices?.Length)
- { continue; }//shouldn't happen
+ continue;//shouldn't happen
var split1beg = polysplit.Split1 - 1;
var split1end = polysplit.Split1;
@@ -256,22 +261,22 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
foreach (var poly in newpolys) //fix any untouched edges that joined to split polys
{
- if (poly.Edges?.Length != poly.Vertices?.Length)
- { continue; }//shouldn't happen (no edges?)
+ if (poly.Edges is null || poly.Vertices is null || poly.Edges.Length != poly.Vertices.Length)
+ continue;//shouldn't happen (no edges?)
+
for (int i = 0; i < poly.Edges.Length; i++)
{
var edge = poly.Edges[i];
var vert = poly.Vertices[i];
if (edge == null)
- { continue; }//shouldn't happen
+ continue;//shouldn't happen
if (edge.Poly1 != edge.Poly2)
- { continue; }//shouldn't happen?
+ continue;//shouldn't happen?
if (edge.Poly1 == null)
- { continue; }//probably this edge joins to nothing
+ continue;//probably this edge joins to nothing
- YnvPolySplit polysplit;
- if (polysplits.TryGetValue(edge.Poly1, out polysplit))
+ if (polysplits.TryGetValue(edge.Poly1, out var polysplit))
{
var newpoly = polysplit.GetNearest(vert);
if (newpoly == null)
@@ -287,7 +292,7 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
return newpolys;
}
- private Vector3 GetSplitPos(Vector3 a, Vector3 b, bool xaxis)
+ private Vector3 GetSplitPos(in Vector3 a, in Vector3 b, bool xaxis)
{
Vector3 ca = NavGrid.GetCellRel(a);
Vector3 cb = NavGrid.GetCellRel(b);
@@ -311,19 +316,19 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
return a + (b - a) * Math.Min(Math.Max(f, 0.0f), 1.0f);
}
- private bool IsValidSplit(Vector3 s1, Vector3 s2, Vector3 v1a, Vector3 v1b, Vector3 v2a, Vector3 v2b)
+ private bool IsValidSplit(in Vector3 s1, in Vector3 s2, in Vector3 v1a, in Vector3 v1b, in Vector3 v2a, in Vector3 v2b)
{
- if (XYEqual(s1, s2)) return false;
- if (XYEqual(s1, v1a)) return false;
- if (XYEqual(s1, v1b)) return false;
- if (XYEqual(s2, v2a)) return false;
- if (XYEqual(s2, v2b)) return false;
+ if (XYEqual(in s1, in s2)) return false;
+ if (XYEqual(in s1, in v1a)) return false;
+ if (XYEqual(in s1, in v1b)) return false;
+ if (XYEqual(in s2, in v2a)) return false;
+ if (XYEqual(in s2, in v2b)) return false;
return true;
}
- private bool XYEqual(Vector3 v1, Vector3 v2)
+ private bool XYEqual(in Vector3 v1, in Vector3 v2)
{
- return ((v1.X == v2.X) && (v1.Y == v2.Y));
+ return v1.X == v2.X && v1.Y == v2.Y;
}
private class YnvPolySplit
@@ -335,8 +340,8 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
public int Split2;
public YnvPoly GetNearest(Vector3 v)
{
- if (New1?.Vertices == null) return New2;
- if (New2?.Vertices == null) return New1;
+ if (New1?.Vertices is null) return New2;
+ if (New2?.Vertices is null) return New1;
float len1 = float.MaxValue;
float len2 = float.MaxValue;
for (int i = 0; i < New1.Vertices.Length; i++)
@@ -357,11 +362,11 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
return New1;
}
}
- private YnvPolySplit TryGetSplit(Dictionary polysplits, YnvPoly poly)
+ private YnvPolySplit? TryGetSplit(Dictionary polysplits, YnvPoly poly)
{
- if (poly == null) return null;
- YnvPolySplit r = null;
- polysplits.TryGetValue(poly, out r);
+ if (poly == null)
+ return null;
+ _ = polysplits.TryGetValue(poly, out var r);
return r;
}
@@ -379,7 +384,7 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
if (ynv == null)
{
ynv = new YnvFile();
- ynv.Name = "navmesh[" + cell.FileX.ToString() + "][" + cell.FileY.ToString() + "]";
+ ynv.Name = $"navmesh[{cell.FileX}][{cell.FileY}]";
ynv.Nav = new NavMesh();
ynv.Nav.SetDefaults(false);
ynv.Nav.AABBSize = new Vector3(NavGrid.CellSize, NavGrid.CellSize, 0.0f);
@@ -411,14 +416,13 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
foreach (var poly in polys)
{
poly.CalculatePosition();
- var pos = poly.Position;
var verts = poly.Vertices;
- if (verts != null)
+ if (verts is not null)
{
- foreach (var vert in verts)
+ foreach (ref var vert in verts.AsSpan())
{
- bbmin = Vector3.Min(bbmin, vert);
- bbmax = Vector3.Max(bbmax, vert);
+ Vector3.Min(ref bbmin, ref vert, out bbmin);
+ Vector3.Max(ref bbmax, ref vert, out bbmax);
}
}
}
@@ -460,7 +464,9 @@ namespace CodeWalker.Core.GameFiles.FileTypes.Builders
float zmax = float.MinValue;
foreach (var poly in ynv.Polys)
{
- foreach (var vert in poly.Vertices)
+ if (poly.Vertices is null)
+ continue;
+ foreach (ref var vert in poly.Vertices.AsSpan())
{
zmin = Math.Min(zmin, vert.Z);
zmax = Math.Max(zmax, vert.Z);
diff --git a/CodeWalker.Core/GameFiles/FileTypes/CacheDatFile.cs b/CodeWalker.Core/GameFiles/FileTypes/CacheDatFile.cs
index 7ff9866..7b78075 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/CacheDatFile.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/CacheDatFile.cs
@@ -1,4 +1,5 @@
-using SharpDX;
+using Collections.Pooled;
+using SharpDX;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -28,6 +29,7 @@ namespace CodeWalker.GameFiles
public CInteriorProxy[] AllCInteriorProxies { get; set; }
public BoundsStoreItem[] AllBoundsStoreItems { get; set; }
+ [SkipLocalsInit]
public void Load(byte[] data, RpfFileEntry entry)
{
FileEntry = entry;
@@ -36,6 +38,7 @@ namespace CodeWalker.GameFiles
using BinaryReader br = new BinaryReader(ms);
Span charArr = stackalloc char[100];
+
var length = 0;
for (int i = 0; (i < 100) && (i < data.Length); i++)
{
@@ -56,10 +59,10 @@ namespace CodeWalker.GameFiles
uint structcount = 0;
uint modlen;
bool indates = false;
- var dates = new List();
- var allMapNodes = new List();
- var allCInteriorProxies = new List();
- var allBoundsStoreItems = new List();
+ using var dates = new PooledList();
+ using var allMapNodes = new PooledList();
+ using var allCInteriorProxies = new PooledList();
+ using var allBoundsStoreItems = new PooledList();
for (int i = 100; i < data.Length; i++)
{
byte b = data[i];
@@ -68,7 +71,6 @@ namespace CodeWalker.GameFiles
if (b == 0xA)
{
lastn = i;
- string line = new string(charArr.Slice(0, length));
switch (charArr.Slice(0, length))
{
case "":
@@ -125,6 +127,7 @@ namespace CodeWalker.GameFiles
{ } //just testing
else
{
+ string line = new string(charArr.Slice(0, length));
dates.Add(new CacheFileDate(line));//eg: 2740459947 (hash of: platform:/data/cdimages/scaleform_frontend.rpf) 130680580712018938 8944
}
break;
@@ -204,7 +207,6 @@ namespace CodeWalker.GameFiles
mapnode.InteriorProxyListToArray();
}
-
br.Dispose();
ms.Dispose();
@@ -407,7 +409,7 @@ namespace CodeWalker.GameFiles
public string ToCacheFileString()
{
- return FileName.Hash.ToString() + " " + TimeStamp.ToFileTimeUtc().ToString() + " " + FileID.ToString();
+ return $"{FileName.Hash} {TimeStamp.ToFileTimeUtc()} {FileID}";
}
public void WriteXml(StringBuilder sb, int indent)
@@ -425,7 +427,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return FileName.ToString() + ", " + TimeStamp.ToString() + ", " + FileID.ToString();
+ return $"{FileName}, {TimeStamp}, {FileID}";
}
}
@@ -478,10 +480,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Name.ToString() + ", " +
- Min.ToString() + ", " +
- Max.ToString() + ", " +
- Layer.ToString();
+ return $"{Name}, {Min}, {Max}, {Layer}";
}
}
@@ -775,19 +774,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Unk01.ToString() + ", " +
- Unk02.ToString() + ", " +
- Unk03.ToString() + ", " +
- Name.ToString() + ", " +
- Parent.ToString() + ", " +
- Position.ToString() + ", " +
- Orientation.ToString() + ", " +
- BBMin.ToString() + ", " +
- BBMax.ToString() + ", " +
- Unk11.ToString() + ", " +
- Unk12.ToString() + ", " +
- Unk13.ToString() + ", " +
- Unk14.ToString();
+ return $"{Unk01}, {Unk02}, {Unk03}, {Name}, {Parent}, {Position}, {Orientation}, {BBMin}, {BBMax}, {Unk11}, {Unk12}, {Unk13}, {Unk14}";
}
}
@@ -796,10 +783,10 @@ namespace CodeWalker.GameFiles
public MetaHash Name { get; set; }
public MetaHash ParentName { get; set; }
public uint ContentFlags { get; set; }
- public Vector3 streamingExtentsMin { get; set; }
- public Vector3 streamingExtentsMax { get; set; }
- public Vector3 entitiesExtentsMin { get; set; }
- public Vector3 entitiesExtentsMax { get; set; }
+ public Vector3 streamingExtentsMin;
+ public Vector3 streamingExtentsMax;
+ public Vector3 entitiesExtentsMin;
+ public Vector3 entitiesExtentsMax;
public byte Unk1 { get; set; }
public byte Unk2 { get; set; }
public byte Unk3 { get; set; }
@@ -912,15 +899,12 @@ namespace CodeWalker.GameFiles
public void AddChildToList(MapDataStoreNode child)
{
- if (ChildrenList == null)
- {
- ChildrenList = new List();
- }
+ ChildrenList ??= new List();
ChildrenList.Add(child);
}
public void ChildrenListToArray()
{
- if (ChildrenList != null)
+ if (ChildrenList is not null)
{
Children = ChildrenList.ToArray();
ChildrenList = null; //plz get this GC
@@ -928,15 +912,12 @@ namespace CodeWalker.GameFiles
}
public void AddInteriorToList(CInteriorProxy iprx)
{
- if (InteriorProxyList == null)
- {
- InteriorProxyList = new List();
- }
+ InteriorProxyList ??= new List();
InteriorProxyList.Add(iprx);
}
public void InteriorProxyListToArray()
{
- if (InteriorProxyList != null)
+ if (InteriorProxyList is not null)
{
InteriorProxies = InteriorProxyList.ToArray();
InteriorProxyList = null; //plz get this GC
@@ -945,13 +926,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Name.ToString() + ", " +
- ParentName.ToString() + ", " +
- ContentFlags.ToString() + ", " +
- streamingExtentsMin.ToString() + ", " +
- streamingExtentsMax.ToString() + ", " +
- entitiesExtentsMin.ToString() + ", " +
- entitiesExtentsMax.ToString();// + ", " +
+ return $"{Name}, {ParentName}, {ContentFlags}, {streamingExtentsMin}, {streamingExtentsMax}, {entitiesExtentsMin}, {entitiesExtentsMax}";// + ", " +
}
}
@@ -972,16 +947,24 @@ namespace CodeWalker.GameFiles
{
get
{
- StringBuilder sb = new StringBuilder();
- if (Unk02 != null)
+ if (Unk02 is null)
+ return string.Empty;
+
+ StringBuilder sb = MetaXmlBase.StringBuilderPool.Get();
+ try
{
- for (int i = 0; i < Unk02.Length; i++)
+ foreach (var b in Unk02)
{
- if (Unk02[i] == 0) break;
- sb.Append((char)Unk02[i]);
+ if (b == 0)
+ break;
+ sb.Append((char)b);
}
+ return sb.ToString();
+ }
+ finally
+ {
+ MetaXmlBase.StringBuilderPool.Return(sb);
}
- return sb.ToString();
}
}
@@ -1027,7 +1010,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Unk01.ToString() + ", " + Unk02str;
+ return $"{Unk01}, {Unk02str}";
}
}
@@ -1038,21 +1021,28 @@ namespace CodeWalker.GameFiles
public static string GetXml(CacheDatFile cdf)
{
- StringBuilder sb = new StringBuilder();
- sb.AppendLine(XmlHeader);
-
- if (cdf != null)
+ StringBuilder sb = StringBuilderPool.Get();
+ try
{
- var name = "CacheFile";
+ sb.AppendLine(XmlHeader);
- OpenTag(sb, 0, name);
+ if (cdf != null)
+ {
+ var name = "CacheFile";
- cdf.WriteXml(sb, 1);
+ OpenTag(sb, 0, name);
- CloseTag(sb, 0, name);
+ cdf.WriteXml(sb, 1);
+
+ CloseTag(sb, 0, name);
+ }
+
+ return sb.ToString();
+ }
+ finally
+ {
+ StringBuilderPool.Return(sb);
}
-
- return sb.ToString();
}
diff --git a/CodeWalker.Core/GameFiles/FileTypes/CarColsFile.cs b/CodeWalker.Core/GameFiles/FileTypes/CarColsFile.cs
index 689ce78..654dee3 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/CarColsFile.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/CarColsFile.cs
@@ -35,8 +35,7 @@ namespace CodeWalker.GameFiles
//can be PSO .ymt or XML .meta
- MemoryStream ms = new MemoryStream(data);
- if (PsoFile.IsPSO(ms))
+ if (PsoFile.IsPSO(data.AsSpan(0, 4)))
{
Pso = new PsoFile();
Pso.Load(data);
@@ -59,8 +58,6 @@ namespace CodeWalker.GameFiles
var msg = ex.Message;
}
}
- else
- { }
if (xdoc.DocumentElement != null)
diff --git a/CodeWalker.Core/GameFiles/FileTypes/CarVariationsFile.cs b/CodeWalker.Core/GameFiles/FileTypes/CarVariationsFile.cs
index b092b39..6325e7b 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/CarVariationsFile.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/CarVariationsFile.cs
@@ -10,6 +10,7 @@ using System.Xml;
using TC = System.ComponentModel.TypeConverterAttribute;
using EXP = System.ComponentModel.ExpandableObjectConverter;
+using CodeWalker.Core.Utils;
namespace CodeWalker.GameFiles
{
@@ -78,12 +79,11 @@ namespace CodeWalker.GameFiles
public CVehicleModelInfoVariation(XmlNode node)
{
- XmlNode cnode;
- cnode = node.SelectSingleNode("variationData");
- if (cnode != null)
+ var variationNode = node.SelectSingleNode("variationData");
+ if (variationNode is not null)
{
- var items = cnode.SelectNodes("Item");
- if (items.Count > 0)
+ var items = variationNode.SelectNodes("Item");
+ if (items is not null && items.Count > 0)
{
variationData = new CVehicleModelInfoVariation_418053801[items.Count];
for (int i = 0; i < items.Count; i++)
@@ -107,12 +107,11 @@ namespace CodeWalker.GameFiles
public CVehicleModelInfoVariation_418053801(XmlNode node)
{
modelName = Xml.GetChildInnerText(node, "modelName");
- XmlNode cnode;
- cnode = node.SelectSingleNode("colors");
- if (cnode != null)
+ var colorsNode = node.SelectSingleNode("colors");
+ if (colorsNode is not null)
{
- var items = cnode.SelectNodes("Item");
- if (items.Count > 0)
+ var items = colorsNode.SelectNodes("Item");
+ if (items is not null && items.Count > 0)
{
colors = new CVehicleModelInfoVariation_2575850962[items.Count];
for (int i = 0; i < items.Count; i++)
@@ -121,11 +120,11 @@ namespace CodeWalker.GameFiles
}
}
}
- cnode = node.SelectSingleNode("kits");
- if (cnode != null)
+ var kitsNode = node.SelectSingleNode("kits");
+ if (kitsNode is not null)
{
- var items = cnode.SelectNodes("Item");
- if (items.Count > 0)
+ var items = kitsNode.SelectNodes("Item");
+ if (items is not null && items.Count > 0)
{
kits = new MetaHash[items.Count];
for (int i = 0; i < items.Count; i++)
@@ -134,11 +133,11 @@ namespace CodeWalker.GameFiles
}
}
}
- cnode = node.SelectSingleNode("windowsWithExposedEdges");
- if (cnode != null)
+ var windowsNodes = node.SelectSingleNode("windowsWithExposedEdges");
+ if (windowsNodes is not null)
{
- var items = cnode.SelectNodes("Item");
- if (items.Count > 0)
+ var items = windowsNodes.SelectNodes("Item");
+ if (items is not null && items.Count > 0)
{
windowsWithExposedEdges = new MetaHash[items.Count];
for (int i = 0; i < items.Count; i++)
@@ -147,10 +146,10 @@ namespace CodeWalker.GameFiles
}
}
}
- cnode = node.SelectSingleNode("plateProbabilities");
- if (cnode != null)
+ var plateProbabilitiesNode = node.SelectSingleNode("plateProbabilities");
+ if (plateProbabilitiesNode is not null)
{
- plateProbabilities = new PlateProbabilities(cnode);
+ plateProbabilities = new PlateProbabilities(plateProbabilitiesNode);
}
lightSettings = (byte)Xml.GetChildIntAttribute(node, "lightSettings", "value");
sirenSettings = (byte)Xml.GetChildIntAttribute(node, "sirenSettings", "value");
@@ -168,28 +167,25 @@ namespace CodeWalker.GameFiles
public CVehicleModelInfoVariation_2575850962(XmlNode node)
{
- XmlNode cnode;
- cnode = node.SelectSingleNode("indices");
- if (cnode != null)
+ var indicesNode = node.SelectSingleNode("indices");
+ if (indicesNode is not null)
{
- var astr = cnode.InnerText;
- var arrr = astr.Split(new[] { '\n', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
+ var astr = indicesNode.InnerText;
var alist = new List();
- foreach (var item in arrr)
+ foreach (var item in astr.EnumerateSplitAny(['\n', ' ', '\t']))
{
var titem = item.Trim();
- byte v;
- if (byte.TryParse(titem, out v))
+ if (byte.TryParse(titem, out var v))
{
alist.Add(v);
}
}
indices = alist.ToArray();
}
- cnode = node.SelectSingleNode("liveries");
- if (cnode != null)
+ var liveriesNode = node.SelectSingleNode("liveries");
+ if (liveriesNode is not null)
{
- var items = cnode.SelectNodes("Item");
+ var items = liveriesNode.SelectNodes("Item");
if (items.Count > 0)
{
liveries = new bool[items.Count];
@@ -200,14 +196,12 @@ namespace CodeWalker.GameFiles
}
else
{
- var astr = cnode.InnerText;
- var arrr = astr.Split(new[] { '\n', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
+ var astr = liveriesNode.InnerText;
var alist = new List();
- foreach (var item in arrr)
+ foreach (var item in astr.EnumerateSplitAny(['\n', ' ', '\t']))
{
var titem = item.Trim();
- byte v;
- if (byte.TryParse(titem, out v))
+ if (byte.TryParse(titem, out var v))
{
alist.Add(v > 0);
}
@@ -254,7 +248,7 @@ namespace CodeWalker.GameFiles
public override string ToString()
{
- return Name.ToString() + ": " + Value.ToString();
+ return $"{Name}: {Value}";
}
}
diff --git a/CodeWalker.Core/GameFiles/FileTypes/CutFile.cs b/CodeWalker.Core/GameFiles/FileTypes/CutFile.cs
index 627c871..fbbc1ee 100644
--- a/CodeWalker.Core/GameFiles/FileTypes/CutFile.cs
+++ b/CodeWalker.Core/GameFiles/FileTypes/CutFile.cs
@@ -9,6 +9,7 @@ using System.Xml;
using TC = System.ComponentModel.TypeConverterAttribute;
using EXP = System.ComponentModel.ExpandableObjectConverter;
+using Collections.Pooled;
namespace CodeWalker.GameFiles
{
@@ -33,12 +34,10 @@ namespace CodeWalker.GameFiles
{
FileEntry = entry;
- MemoryStream ms = new MemoryStream(data);
-
- if (PsoFile.IsPSO(ms))
+ if (PsoFile.IsPSO(data.AsSpan(0, 4)))
{
Pso = new PsoFile();
- Pso.Load(ms);
+ Pso.Load(data);
var xml = PsoXml.GetXml(Pso);
XmlDocument doc = new XmlDocument();
@@ -48,10 +47,6 @@ namespace CodeWalker.GameFiles
CutsceneFile2 = new CutsceneFile2();
CutsceneFile2.ReadXml(node);
- }
- else
- {
-
}
}
@@ -228,7 +223,7 @@ namespace CodeWalker.GameFiles
- public static CutBase ConstructObject(string type)
+ public static CutBase? ConstructObject(string type)
{
switch (type)
{
@@ -279,7 +274,7 @@ namespace CodeWalker.GameFiles
default: return null;
}
}
- public static T ReadObject(XmlNode node, string name) where T : IMetaXmlItem, new()
+ public static T? ReadObject(XmlNode node, string name) where T : IMetaXmlItem, new()
{
var onode = node.SelectSingleNode(name);
if (onode != null)
@@ -288,7 +283,7 @@ namespace CodeWalker.GameFiles
o.ReadXml(onode);
return o;
}
- return default(T);
+ return default;
}
public static object[] ReadObjectArray(XmlNode node, string name)
{
@@ -298,7 +293,7 @@ namespace CodeWalker.GameFiles
var inodes = aNode.SelectNodes("Item");
if (inodes?.Count > 0)
{
- var oList = new List