├── .gitattributes ├── .github └── workflows │ ├── codeql-analysis.yml │ └── dotnetcore.yml ├── .gitignore ├── DBCLib.Test ├── DBCFileTest.cs ├── DBCInfoTest.cs ├── DBCLib.Test.csproj └── Structures │ └── CharTitlesEntry.cs ├── DBCLib.sln ├── DBCLib ├── DBC │ ├── DBCFile.cs │ ├── DBCInfo.cs │ ├── DBCReader.cs │ ├── DBCUtility.cs │ └── DBCWriter.cs ├── DBCLib.csproj ├── Exceptions │ ├── DBCFileNotLoadedException.cs │ ├── InvalidDBCFieldsException.cs │ └── InvalidSignatureException.cs ├── Properties │ └── AssemblyInfo.cs └── Types │ └── LocalizedString.cs ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '25 23 * * 1' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'csharp' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | - name: Setup .NET 6.0 45 | uses: actions/setup-dotnet@v1 46 | with: 47 | dotnet-version: '6.0' 48 | include-prerelease: True 49 | 50 | # Initializes the CodeQL tools for scanning. 51 | - name: Initialize CodeQL 52 | uses: github/codeql-action/init@v1 53 | with: 54 | languages: ${{ matrix.language }} 55 | # If you wish to specify custom queries, you can do so here or in a config file. 56 | # By default, queries listed here will override any specified in a config file. 57 | # Prefix the list here with "+" to use these queries and those in the config file. 58 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 59 | 60 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 61 | # If this step fails, then you should remove it and run the build manually (see below) 62 | - name: Autobuild 63 | uses: github/codeql-action/autobuild@v1 64 | 65 | # ℹ️ Command-line programs to run using the OS shell. 66 | # 📚 https://git.io/JvXDl 67 | 68 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 69 | # and modify them (or add more) to build your code if your project 70 | # uses a compiled language 71 | 72 | #- run: | 73 | # make bootstrap 74 | # make release 75 | 76 | - name: Perform CodeQL Analysis 77 | uses: github/codeql-action/analyze@v1 78 | -------------------------------------------------------------------------------- /.github/workflows/dotnetcore.yml: -------------------------------------------------------------------------------- 1 | name: .NET 7.0 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: windows-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: Setup .NET 7.0 13 | uses: actions/setup-dotnet@v1 14 | with: 15 | dotnet-version: '7.0.x' 16 | - name: Install dependencies 17 | run: dotnet restore 18 | - name: Build with dotnet 19 | run: dotnet build --configuration Release --no-restore 20 | - name: Test 21 | run: dotnet test --no-restore --verbosity normal 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /DBCLib.Test/DBCFileTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using DBCLib.Test.Structures; 4 | 5 | namespace DBCLib.Test 6 | { 7 | public class DBCFileTest 8 | { 9 | [Fact] 10 | public void DBCType_Equal() 11 | { 12 | DBCFile dbcFile = new("//path//", "signature"); 13 | 14 | Assert.Equal(typeof(CharTitlesEntry), dbcFile.GetDBCType()); 15 | } 16 | 17 | [Theory] 18 | [InlineData("")] 19 | [InlineData(" ")] 20 | [InlineData(" ")] 21 | [InlineData(" ")] 22 | [InlineData(null)] 23 | public void Constructor_Path_ThrowsArgumentNullException(string path) 24 | { 25 | DBCFile dbcFile = new("//path//", "signature"); 26 | 27 | Assert.Throws(() => new DBCFile(path, "signature")); 28 | } 29 | 30 | [Theory] 31 | [InlineData("")] 32 | [InlineData(null)] 33 | public void Constructor_Signature_ThrowsArgumentNullException(string signature) 34 | { 35 | DBCFile dbcFile = new("//path//", "signature"); 36 | 37 | Assert.Throws(() => new DBCFile("//path//", signature)); 38 | } 39 | 40 | //[Theory] 41 | //[InlineData(0)] 42 | //[InlineData(10)] 43 | //[InlineData(100)] 44 | //[InlineData(1000)] 45 | //[InlineData(uint.MaxValue)] 46 | //public void MaxKey_Equal(uint key) 47 | //{ 48 | // DBCFile dbcFile = new("//path//", "signature"); 49 | // dbcFile.AddEntry(key, new CharTitlesEntry()); 50 | 51 | // Assert.Equal(key, dbcFile.MaxKey); 52 | //} 53 | 54 | //[Theory] 55 | //[InlineData(0)] 56 | //[InlineData(10)] 57 | //[InlineData(100)] 58 | //[InlineData(1000)] 59 | //[InlineData(uint.MaxValue - 1)] 60 | //public void MaxKey_NotEqual(uint key) 61 | //{ 62 | // DBCFile dbcFile = new("//path//", "signature"); 63 | // dbcFile.AddEntry(uint.MaxValue, new CharTitlesEntry()); 64 | 65 | // dbcFile.AddEntry(key, new CharTitlesEntry()); 66 | 67 | // Assert.NotEqual(key, dbcFile.MaxKey); 68 | //} 69 | 70 | [Fact] 71 | public void FieldCount_Equal() 72 | { 73 | DBCFile dbcFile = new("//path//", "signature"); 74 | var fields = dbcFile.GetDBCType().GetFields(); 75 | 76 | // Calculate field counts of DBC file 77 | int fieldCounts = DBCUtility.FieldCount(fields, dbcFile.GetDBCType()); 78 | 79 | Assert.Equal(37, fieldCounts); 80 | } 81 | 82 | //[Fact] 83 | //public void RemoveEntry_DoesNotContain() 84 | //{ 85 | // DBCFile dbcFile = new("//path//", "signature"); 86 | // CharTitlesEntry charTitlesEntry = new() 87 | // { 88 | // Id = 1, 89 | // NameMale = "Title %s", 90 | // NameFemale = "Title %s", 91 | // TitleMaskId = 1 92 | // }; 93 | 94 | // dbcFile.AddEntry(1, charTitlesEntry); 95 | // dbcFile.RemoveEntry(1); 96 | 97 | // Assert.DoesNotContain(charTitlesEntry, dbcFile.Records); 98 | //} 99 | 100 | [Fact] 101 | public void RemoveEntry_ThrowsArgumentException() 102 | { 103 | DBCFile dbcFile = new("//path//", "signature"); 104 | 105 | Assert.Throws(() => dbcFile.RemoveEntry(1)); 106 | } 107 | 108 | //[Fact] 109 | //public void ReplaceEntry_Contains() 110 | //{ 111 | // DBCFile dbcFile = new("//path//", "signature"); 112 | // CharTitlesEntry charTitlesEntry = new() 113 | // { 114 | // Id = 1, 115 | // NameMale = "Title %s", 116 | // NameFemale = "Title %s", 117 | // TitleMaskId = 1 118 | // }; 119 | 120 | // dbcFile.AddEntry(1, new CharTitlesEntry()); 121 | // dbcFile.ReplaceEntry(1, charTitlesEntry); 122 | 123 | // Assert.Contains(charTitlesEntry, dbcFile.Records); 124 | //} 125 | 126 | [Fact] 127 | public void ReplaceEntry_ThrowsArgumentException() 128 | { 129 | DBCFile dbcFile = new("//path//", "signature"); 130 | 131 | Assert.Throws(() => dbcFile.ReplaceEntry(1, new CharTitlesEntry())); 132 | } 133 | 134 | [Fact] 135 | public void ReplaceEntry_ThrowsArgumentNullException() 136 | { 137 | DBCFile dbcFile = new("//path//", "signature"); 138 | dbcFile.AddEntry(1, new CharTitlesEntry()); 139 | 140 | Assert.Throws(() => dbcFile.ReplaceEntry(1, null)); 141 | } 142 | 143 | //[Fact] 144 | //public void AddEntry_Contains() 145 | //{ 146 | // DBCFile dbcFile = new("//path//", "signature"); 147 | // CharTitlesEntry charTitlesEntry = new() 148 | // { 149 | // Id = 1, 150 | // NameMale = "Title %s", 151 | // NameFemale = "Title %s", 152 | // TitleMaskId = 1 153 | // }; 154 | 155 | // dbcFile.AddEntry(1, charTitlesEntry); 156 | 157 | // Assert.Contains(charTitlesEntry, dbcFile.Records); 158 | //} 159 | 160 | [Fact] 161 | public void AddEntry_ThrowsArgumentException() 162 | { 163 | DBCFile dbcFile = new("//path//", "signature"); 164 | CharTitlesEntry charTitlesEntry = new() 165 | { 166 | Id = 1, 167 | NameMale = "Title %s", 168 | NameFemale = "Title %s", 169 | TitleMaskId = 1 170 | }; 171 | 172 | dbcFile.AddEntry(1, charTitlesEntry); 173 | 174 | Assert.Throws(() => dbcFile.AddEntry(1, new CharTitlesEntry())); 175 | } 176 | 177 | [Fact] 178 | public void AddEntry_ThrowsArgumentNullException() 179 | { 180 | DBCFile dbcFile = new("//path//", "signature"); 181 | 182 | Assert.Throws(() => dbcFile.AddEntry(1, null)); 183 | } 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /DBCLib.Test/DBCInfoTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | namespace DBCLib.Test 4 | { 5 | public class DBCInfoTest 6 | { 7 | [Fact] 8 | public void DBCRecords_Equal() 9 | { 10 | DBCInfo dbcInfo = new(0, 1, 2, 3); 11 | 12 | Assert.Equal((uint)0, dbcInfo.DBCRecords); 13 | } 14 | 15 | [Fact] 16 | public void DBCFields_Equal() 17 | { 18 | DBCInfo dbcInfo = new(0, 1, 2, 3); 19 | 20 | Assert.Equal((uint)1, dbcInfo.DBCFields); 21 | } 22 | 23 | [Fact] 24 | public void RecordSize_Equal() 25 | { 26 | DBCInfo dbcInfo = new(0, 1, 2, 3); 27 | 28 | Assert.Equal((uint)2, dbcInfo.RecordSize); 29 | } 30 | 31 | [Fact] 32 | public void StringSize_Equal() 33 | { 34 | DBCInfo dbcInfo = new(0, 1, 2, 3); 35 | 36 | Assert.Equal((uint)3, dbcInfo.StringSize); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /DBCLib.Test/DBCLib.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /DBCLib.Test/Structures/CharTitlesEntry.cs: -------------------------------------------------------------------------------- 1 | namespace DBCLib.Test.Structures 2 | { 3 | public class CharTitlesEntry 4 | { 5 | public uint Id; // 0 6 | public uint ConditionId; // 1 This is never used by the client. Still looks like pointing somewhere. Serverside? 7 | public LocalizedString NameMale; // 2-18 8 | public LocalizedString NameFemale; // 19-35 9 | public uint TitleMaskId; // 36 Used ingame in the drop down menu. 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DBCLib.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBCLib", "DBCLib\DBCLib.csproj", "{7BCF3CAD-4FDF-4E43-BA1C-B0AC322EA49F}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBCLib.Test", "DBCLib.Test\DBCLib.Test.csproj", "{18C70640-F7E8-4567-9686-745B1A5DB402}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7BCF3CAD-4FDF-4E43-BA1C-B0AC322EA49F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {7BCF3CAD-4FDF-4E43-BA1C-B0AC322EA49F}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {7BCF3CAD-4FDF-4E43-BA1C-B0AC322EA49F}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {7BCF3CAD-4FDF-4E43-BA1C-B0AC322EA49F}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {18C70640-F7E8-4567-9686-745B1A5DB402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {18C70640-F7E8-4567-9686-745B1A5DB402}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {18C70640-F7E8-4567-9686-745B1A5DB402}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {18C70640-F7E8-4567-9686-745B1A5DB402}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {B19D50B0-1EDE-494E-A778-9F42E2F03EF4} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /DBCLib/DBC/DBCFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using DBCLib.Exceptions; 7 | 8 | namespace DBCLib 9 | { 10 | /// 11 | /// The purpose if this class is to encapsulate the DBC file for ease of use. 12 | /// 13 | /// The type of DBC file. 14 | public class DBCFile where T : class, new() 15 | { 16 | private readonly Dictionary records = new(); 17 | private readonly Type dbcType; 18 | private readonly string filePath; 19 | private readonly string dbcSignature; 20 | private bool isEdited; 21 | private bool isLoaded; 22 | 23 | /// 24 | /// Initialize the DBCFile class with file path and DBC signature. 25 | /// 26 | /// The file path to the DBC file. 27 | /// The signature of the DBC file. 28 | /// 29 | public DBCFile(string filePath, string dbcSignature = "WDBC") 30 | { 31 | if (string.IsNullOrWhiteSpace(filePath)) 32 | throw new ArgumentNullException(nameof(filePath)); 33 | 34 | if (string.IsNullOrWhiteSpace(dbcSignature)) 35 | throw new ArgumentNullException(nameof(dbcSignature)); 36 | 37 | this.filePath = filePath; 38 | this.dbcSignature = dbcSignature; 39 | dbcType = typeof(T); 40 | isEdited = false; 41 | isLoaded = false; 42 | } 43 | 44 | /// 45 | /// Dictionary of the records in the loaded DBC file. If the DBC file is not loaded, an exception will be thrown. 46 | /// 47 | public Dictionary.ValueCollection Records => isLoaded ? records.Values : throw new DBCFileNotLoadedException(); 48 | /// 49 | /// The Max Key of all the records in the loaded DBC file. If the DBC file is not loaded, an exception will be thrown. 50 | /// 51 | public uint MaxKey => isLoaded ? records.Keys.Max() : throw new DBCFileNotLoadedException(); 52 | 53 | internal Type GetDBCType() => dbcType; 54 | internal uint LocalFlag { get; set; } 55 | internal uint LocalPosition { get; set; } 56 | 57 | /// 58 | /// Loads the specified DBC file provided in the constructor. 59 | /// 60 | /// Exception thrown if the file is not found. 61 | public void Load() 62 | { 63 | if (isLoaded) 64 | return; 65 | 66 | if (!File.Exists(filePath)) 67 | throw new FileNotFoundException("Could not find DBC File.", filePath); 68 | 69 | ReadDBC(); 70 | 71 | // Set IsLoaded to true to avoid loading the same DBC file multiple times 72 | isLoaded = true; 73 | } 74 | 75 | /// 76 | /// Saves the specified DBC file provided in the constructor. 77 | /// 78 | /// 79 | public void Save() 80 | { 81 | if (!isEdited) 82 | return; 83 | 84 | var dbcWriter = new DBCWriter(); 85 | dbcWriter.WriteDBC(this, filePath, dbcSignature); 86 | 87 | isEdited = false; 88 | } 89 | 90 | /// 91 | /// Adds the specified value at the specified key in the DBC records. 92 | /// 93 | /// The key used for location in the DBC records. 94 | /// The value that is added to the DBC record. 95 | /// Exception thrown if the provided key already exists in the DBC records. 96 | /// Exception thrown if the provided value is null. 97 | public void AddEntry(uint key, T value) 98 | { 99 | if (records.ContainsKey(key)) 100 | throw new ArgumentException("The DBC File already contains the entry.", nameof(key)); 101 | 102 | records[key] = value ?? throw new ArgumentNullException(nameof(value)); 103 | 104 | isEdited = true; 105 | } 106 | 107 | /// 108 | /// Removes the entry for the specified key in the DBC records. 109 | /// 110 | /// The key used for location in the DBC records. 111 | /// Exception thrown if the provided key does not exist in the DBC records. 112 | public void RemoveEntry(uint key) 113 | { 114 | if (!records.ContainsKey(key)) 115 | throw new ArgumentException("The DBC File does not contain the entry.", nameof(key)); 116 | 117 | records.Remove(key); 118 | 119 | isEdited = true; 120 | } 121 | 122 | /// 123 | /// Replaces the specified value at the specified key in the DBC records. 124 | /// 125 | /// The key used for location in the DBC records. 126 | /// The value that is added to the DBC record. 127 | /// Exception thrown if the provided key does not exist in the DBC records. 128 | /// Exception thrown if the provided value is null. 129 | public void ReplaceEntry(uint key, T value) 130 | { 131 | if (!records.ContainsKey(key)) 132 | throw new ArgumentException("The DBC File does not contain the entry.", nameof(key)); 133 | 134 | records[key] = value ?? throw new ArgumentNullException(nameof(value)); 135 | 136 | isEdited = true; 137 | } 138 | 139 | private void ReadDBC() 140 | { 141 | using var reader = new BinaryReader(File.OpenRead(filePath)); 142 | var byteSignature = reader.ReadBytes(dbcSignature.Length); 143 | string stringSignature = Encoding.UTF8.GetString(byteSignature); 144 | if (stringSignature != dbcSignature) 145 | throw new InvalidSignatureException(stringSignature); 146 | 147 | // Read the DBC File 148 | DBCReader.ReadDBC(this, reader); 149 | } 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /DBCLib/DBC/DBCInfo.cs: -------------------------------------------------------------------------------- 1 | namespace DBCLib 2 | { 3 | internal readonly struct DBCInfo 4 | { 5 | public readonly uint DBCRecords { get; } 6 | public readonly uint DBCFields { get; } 7 | public readonly uint RecordSize { get; } 8 | public readonly uint StringSize { get; } 9 | 10 | public DBCInfo(uint dbcRecords, uint dbcFields, uint recordSize, uint stringSize) 11 | { 12 | DBCRecords = dbcRecords; 13 | DBCFields = dbcFields; 14 | RecordSize = recordSize; 15 | StringSize = stringSize; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DBCLib/DBC/DBCReader.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using DBCLib.Exceptions; 6 | 7 | namespace DBCLib 8 | { 9 | internal static class DBCReader where T : class, new() 10 | { 11 | internal static void ReadDBC(DBCFile dbcFile, BinaryReader reader) 12 | { 13 | if (reader is null) 14 | return; 15 | 16 | var info = DBCUtility.GetDBCInfo(reader); 17 | 18 | // Validate the DBC fields 19 | var fields = dbcFile.GetDBCType().GetFields(); 20 | int fieldCounts = DBCUtility.FieldCount(fields, dbcFile.GetDBCType()); 21 | if (info.DBCFields != fieldCounts) 22 | throw new InvalidDBCFieldsException(dbcFile.GetDBCType().ToString()); 23 | 24 | // We don't need to read the first bytes again (signature) 25 | long headerSize = reader.BaseStream.Position; 26 | 27 | // Extract all strings and construct string table 28 | var stringTable = DBCUtility.GetStringTable(reader, info, headerSize); 29 | 30 | // Reset position to base position 31 | reader.BaseStream.Position = headerSize; 32 | 33 | // Loop through all of the records in the DBC file 34 | for (uint i = 0; i < info.DBCRecords; ++i) 35 | { 36 | var instance = Activator.CreateInstance(dbcFile.GetDBCType()); 37 | 38 | foreach (var field in fields) 39 | { 40 | switch (Type.GetTypeCode(field.FieldType)) 41 | { 42 | case TypeCode.Object: 43 | { 44 | if (field.FieldType == typeof(LocalizedString)) 45 | { 46 | var value = ""; 47 | for (uint j = 0; j < LocalizedString.Size - 1; ++j) 48 | { 49 | int offsetKey = reader.ReadInt32(); 50 | if (string.IsNullOrEmpty(value) && offsetKey != 0 && stringTable.TryGetValue(offsetKey, out string stringFromTable)) 51 | { 52 | value = stringFromTable; 53 | dbcFile.LocalPosition = j; 54 | } 55 | } 56 | 57 | dbcFile.LocalFlag = reader.ReadUInt32(); 58 | 59 | field.SetValue(instance, (LocalizedString)value); 60 | } 61 | else if (field.FieldType.IsArray) 62 | { 63 | Array array; 64 | int arrayLength; 65 | 66 | switch (Type.GetTypeCode(field.FieldType.GetElementType())) 67 | { 68 | case TypeCode.Int32: 69 | // Get length of array 70 | arrayLength = ((int[])field.GetValue(instance)).Length; 71 | 72 | // Set Array 73 | array = new int[arrayLength]; 74 | 75 | // Set Value of DBC object by looping through the array 76 | for (var j = 0; j < arrayLength; ++j) 77 | array.SetValue(reader.ReadInt32(), j); 78 | field.SetValue(instance, array); 79 | break; 80 | case TypeCode.UInt32: 81 | // Get length of array 82 | arrayLength = ((uint[])field.GetValue(instance)).Length; 83 | 84 | // Set Array 85 | array = new uint[arrayLength]; 86 | 87 | // Set Value of DBC object by looping through the array 88 | for (var j = 0; j < arrayLength; ++j) 89 | array.SetValue(reader.ReadUInt32(), j); 90 | field.SetValue(instance, array); 91 | break; 92 | case TypeCode.Single: 93 | // Get length of array 94 | arrayLength = ((float[])field.GetValue(instance)).Length; 95 | 96 | // Set Array 97 | array = new float[arrayLength]; 98 | 99 | // Set Value of DBC object by looping through the array 100 | for (var j = 0; j < arrayLength; ++j) 101 | array.SetValue(reader.ReadSingle(), j); 102 | field.SetValue(instance, array); 103 | break; 104 | default: 105 | throw new NotImplementedException(Type.GetTypeCode(field.FieldType.GetElementType()).ToString()); 106 | } 107 | } 108 | break; 109 | } 110 | case TypeCode.Byte: 111 | { 112 | byte value = reader.ReadByte(); 113 | field.SetValue(instance, value); 114 | break; 115 | } 116 | case TypeCode.Int32: 117 | { 118 | int value = reader.ReadInt32(); 119 | field.SetValue(instance, value); 120 | break; 121 | } 122 | case TypeCode.UInt32: 123 | { 124 | uint value = reader.ReadUInt32(); 125 | field.SetValue(instance, value); 126 | break; 127 | } 128 | case TypeCode.Single: 129 | { 130 | float value = reader.ReadSingle(); 131 | field.SetValue(instance, value); 132 | break; 133 | } 134 | case TypeCode.String: 135 | { 136 | // Get offset for string table 137 | int offsetKey = reader.ReadInt32(); 138 | 139 | // Check if offset exists in the string table 140 | if (!stringTable.TryGetValue(offsetKey, out string stringFromTable)) 141 | throw new KeyNotFoundException(offsetKey.ToString()); 142 | 143 | string value = stringFromTable; 144 | field.SetValue(instance, value); 145 | break; 146 | } 147 | default: 148 | throw new NotImplementedException(Type.GetTypeCode(field.FieldType).ToString()); 149 | } 150 | } 151 | 152 | // Get the first value of the record and use that as the key for the DBC record 153 | var firstValue = fields[0].GetValue(instance); 154 | var key = (uint)Convert.ChangeType(firstValue, typeof(uint)); 155 | dbcFile.AddEntry(key, (T)instance); 156 | } 157 | } 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /DBCLib/DBC/DBCUtility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Reflection; 5 | using System.Text; 6 | 7 | namespace DBCLib 8 | { 9 | internal static class DBCUtility 10 | { 11 | internal static int FieldCount(FieldInfo[] fields, Type type) 12 | { 13 | var instance = Activator.CreateInstance(type); 14 | var fieldCount = 0; 15 | foreach (var field in fields) 16 | { 17 | if (Type.GetTypeCode(field.FieldType) == TypeCode.Object) 18 | { 19 | if (field.FieldType == typeof(LocalizedString)) 20 | { 21 | fieldCount += LocalizedString.Size; 22 | } 23 | else if (field.FieldType.IsArray) 24 | { 25 | fieldCount += Type.GetTypeCode(field.FieldType.GetElementType()) switch 26 | { 27 | TypeCode.Int32 => ((int[])field.GetValue(instance)).Length, 28 | TypeCode.UInt32 => ((uint[])field.GetValue(instance)).Length, 29 | TypeCode.Single => ((float[])field.GetValue(instance)).Length, 30 | _ => throw new NotImplementedException(Type.GetTypeCode(field.FieldType.GetElementType()).ToString()), 31 | }; 32 | } 33 | } 34 | else 35 | ++fieldCount; 36 | } 37 | 38 | return fieldCount; 39 | } 40 | 41 | internal static DBCInfo GetDBCInfo(BinaryReader reader) 42 | { 43 | if (reader is null) 44 | throw new ArgumentNullException(nameof(reader), "Reader cannot be null."); 45 | 46 | var info = new DBCInfo( 47 | dbcRecords: reader.ReadUInt32(), 48 | dbcFields: reader.ReadUInt32(), 49 | recordSize: reader.ReadUInt32(), 50 | stringSize: reader.ReadUInt32() 51 | ); 52 | 53 | return info; 54 | } 55 | 56 | internal static Dictionary GetStringTable(BinaryReader reader, DBCInfo info, long headerSize) 57 | { 58 | if (reader is null) 59 | throw new ArgumentNullException(nameof(reader), "Reader cannot be null."); 60 | 61 | // DBC records can contain strings. These strings are not stored in the record but in an additional string block, at the end of the dbc file. 62 | // A record contains an offset into that string block. 63 | // These stings are zero terminated (read: c strings) and might be zero length. 64 | reader.BaseStream.Position = info.DBCRecords * info.RecordSize + headerSize; 65 | var stringData = reader.ReadBytes((int)info.StringSize); 66 | string fullString = Encoding.UTF8.GetString(stringData); 67 | var strings = fullString.Split(new[] { '\0' }); 68 | 69 | var stringTable = new Dictionary(); 70 | var currentPosition = 0; 71 | foreach (string str in strings) 72 | { 73 | stringTable.Add(currentPosition, str); 74 | currentPosition += Encoding.UTF8.GetByteCount(str) + 1; 75 | } 76 | 77 | return stringTable; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /DBCLib/DBC/DBCWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace DBCLib 8 | { 9 | internal class DBCWriter where T : class, new() 10 | { 11 | private readonly Dictionary stringHashes = new Dictionary(); 12 | private readonly Dictionary stringTable = new Dictionary(); 13 | private KeyValuePair lastItem; 14 | 15 | internal void WriteDBC(DBCFile dbcFile, string path, string signature) 16 | { 17 | using var fileStream = File.OpenWrite(path); 18 | using var writer = new BinaryWriter(fileStream); 19 | // Sign the file with the signature 20 | var signatureBytes = Encoding.UTF8.GetBytes(signature); 21 | writer.Write(signatureBytes); 22 | writer.Write(dbcFile.Records.Count); 23 | 24 | // Get fields of the DBC type and write to the DBC file 25 | var dbcType = dbcFile.GetDBCType(); 26 | var fields = dbcType.GetFields(); 27 | int fieldCount = DBCUtility.FieldCount(fields, dbcType); 28 | writer.Write(fieldCount); 29 | writer.Write(fieldCount * 4); 30 | writer.Write(0); 31 | 32 | // Adding an empty string to obtain the correct size 33 | if (signature == "WDBC") 34 | AddStringToDictionary(string.Empty); 35 | 36 | foreach (var record in dbcFile.Records) 37 | { 38 | foreach (var field in fields) 39 | { 40 | switch (Type.GetTypeCode(field.FieldType)) 41 | { 42 | case TypeCode.Object: 43 | { 44 | if (field.FieldType == typeof(LocalizedString)) 45 | { 46 | int position = AddStringToDictionary((LocalizedString)field.GetValue(record)); 47 | 48 | // Local strings before the local position 49 | for (uint i = 0; i < dbcFile.LocalPosition; ++i) 50 | { 51 | writer.Write(0); 52 | } 53 | 54 | // Write to the Local Position 55 | writer.Write(position); 56 | 57 | // Local strings after the local position 58 | for (uint j = dbcFile.LocalPosition + 1; j < LocalizedString.Size - 1; ++j) 59 | writer.Write(0); 60 | 61 | // 17th location field 62 | writer.Write(dbcFile.LocalFlag); 63 | } 64 | else 65 | { 66 | if (field.GetValue(record) is Array array) 67 | { 68 | int arrayLength = array.Length; 69 | 70 | switch (Type.GetTypeCode(field.FieldType.GetElementType())) 71 | { 72 | case TypeCode.Int32: 73 | for (var i = 0; i < arrayLength; ++i) 74 | writer.Write((int)array.GetValue(i)); 75 | break; 76 | case TypeCode.UInt32: 77 | for (var i = 0; i < arrayLength; ++i) 78 | writer.Write((uint)array.GetValue(i)); 79 | break; 80 | case TypeCode.Single: 81 | for (var i = 0; i < arrayLength; ++i) 82 | writer.Write((float)array.GetValue(i)); 83 | break; 84 | default: 85 | throw new NotImplementedException(Type.GetTypeCode(field.FieldType.GetElementType()).ToString()); 86 | } 87 | } 88 | } 89 | break; 90 | } 91 | case TypeCode.Byte: 92 | { 93 | var value = (byte)field.GetValue(record); 94 | writer.Write(value); 95 | break; 96 | } 97 | case TypeCode.Int32: 98 | { 99 | var value = (int)field.GetValue(record); 100 | writer.Write(value); 101 | break; 102 | } 103 | case TypeCode.UInt32: 104 | { 105 | var value = (uint)field.GetValue(record); 106 | writer.Write(value); 107 | break; 108 | } 109 | case TypeCode.String: 110 | { 111 | var str = field.GetValue(record) as string; 112 | writer.Write(AddStringToDictionary(str)); 113 | break; 114 | } 115 | case TypeCode.Single: 116 | { 117 | var value = (float)field.GetValue(record); 118 | writer.Write(value); 119 | break; 120 | } 121 | default: 122 | throw new NotImplementedException(Type.GetTypeCode(field.FieldType).ToString()); 123 | } 124 | } 125 | } 126 | 127 | // Write all of the strings to the DBC file 128 | foreach (var stringTableBytes in stringTable.Values.Select(str => Encoding.UTF8.GetBytes(str))) 129 | { 130 | writer.Write(stringTableBytes); 131 | writer.Write((byte)0); 132 | } 133 | 134 | // TODO: Allow for dynamic header size 135 | writer.BaseStream.Position = 16; 136 | if (stringTable.Count > 0) 137 | writer.Write(stringTable.Last().Key + Encoding.UTF8.GetByteCount(stringTable.Last().Value) + 1); 138 | } 139 | 140 | private int AddStringToDictionary(string str) 141 | { 142 | str ??= ""; 143 | 144 | // Check if the string already exists, if it exists, just return the position of the existing string. 145 | int hashCode = str.GetHashCode(); 146 | if (stringHashes.TryGetValue(hashCode, out int position)) 147 | return position; 148 | 149 | if (stringTable.Count > 0) 150 | position = lastItem.Key + Encoding.UTF8.GetByteCount(lastItem.Value) + 1; 151 | 152 | // Add the values to the dictionaries 153 | stringTable.Add(position, str); 154 | stringHashes.Add(hashCode, position); 155 | lastItem = new KeyValuePair(position, str); 156 | 157 | return position; 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /DBCLib/DBCLib.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | Jacob Tønder 6 | Copyright (c) Jacob Tønder 2023 7 | DBCLib 8 | https://jacobtonder.dk/ 9 | DBCLib is a .NET library intended to enable developers to modify DBC files with WDBC signature with ease. 10 | https://github.com/jacobtonder/DBCLib 11 | git 12 | C#; DBCLib; DBC; .NET; WDBC; WOW 13 | MIT 14 | true 15 | 1.1.2 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /DBCLib/Exceptions/DBCFileNotLoadedException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace DBCLib.Exceptions 5 | { 6 | /// 7 | /// Exception thrown when the DBC file is not loaded. 8 | /// 9 | [Serializable] 10 | public class DBCFileNotLoadedException : Exception 11 | { 12 | internal DBCFileNotLoadedException() 13 | { 14 | } 15 | 16 | internal DBCFileNotLoadedException(string message) : base(message) 17 | { 18 | } 19 | 20 | internal DBCFileNotLoadedException(string message, Exception innerException) : base(message, innerException) 21 | { 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /DBCLib/Exceptions/InvalidDBCFieldsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DBCLib.Exceptions 4 | { 5 | /// 6 | /// Exception thrown when the field count of the specified DBC file does not match the field count of the specified DBC type. 7 | /// 8 | [Serializable] 9 | public class InvalidDBCFieldsException : Exception 10 | { 11 | internal InvalidDBCFieldsException() 12 | { 13 | } 14 | 15 | internal InvalidDBCFieldsException(string message) : base(message) 16 | { 17 | } 18 | 19 | internal InvalidDBCFieldsException(string message, Exception innerException) : base(message, innerException) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DBCLib/Exceptions/InvalidSignatureException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DBCLib.Exceptions 4 | { 5 | /// 6 | /// Exception thrown when the signature of the specified DBC file does not match the signature of the specified DBC instance. 7 | /// 8 | [Serializable] 9 | public class InvalidSignatureException : Exception 10 | { 11 | internal InvalidSignatureException() 12 | { 13 | } 14 | 15 | internal InvalidSignatureException(string message) : base(message) 16 | { 17 | } 18 | 19 | internal InvalidSignatureException(string message, Exception inner) : base(message, inner) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DBCLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("DBCLib.Test")] 2 | -------------------------------------------------------------------------------- /DBCLib/Types/LocalizedString.cs: -------------------------------------------------------------------------------- 1 | namespace DBCLib 2 | { 3 | /// 4 | /// The purpose of this class is to support reading DBC files with localized strings. 5 | /// 6 | public class LocalizedString 7 | { 8 | internal LocalizedString(string str) => String = str; 9 | 10 | /// 11 | /// Size of the localized string. 12 | /// 13 | public static readonly int Size = 17; 14 | /// 15 | /// The value of the localized string for the specific dbc local flag. 16 | /// 17 | public string String { get; set; } 18 | 19 | /// 20 | /// Used for implicit conversion from string to localized string. 21 | /// 22 | /// The specified string to convert to localized sting. 23 | public static implicit operator LocalizedString(string str) => new(str); 24 | /// 25 | /// Used for implicit conversion from localized string to string. 26 | /// 27 | /// The specified localized string to convert to sting. 28 | public static implicit operator string(LocalizedString str) => str.String; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jacob Tønder 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DBCLib 2 | This repository consists of a library to handle DBC files. 3 | 4 | Features: 5 | * Add entries to DBC files. 6 | * Remove entries in DBC files. 7 | * Replace entries in DBC files. 8 | * Save DBC files. 9 | * Load DBC files. 10 | 11 | ## NuGet package 12 | 13 | https://www.nuget.org/packages/DBCLib 14 | 15 | ## Example (Winforms) 16 | See [DBC Editor](https://github.com/jacobtonder/DBCEditorExample/) for an example of how to use this library. 17 | --------------------------------------------------------------------------------