Chorizite.DatReaderWriter
1.0.0
dotnet add package Chorizite.DatReaderWriter --version 1.0.0
NuGet\Install-Package Chorizite.DatReaderWriter -Version 1.0.0
<PackageReference Include="Chorizite.DatReaderWriter" Version="1.0.0" />
<PackageVersion Include="Chorizite.DatReaderWriter" Version="1.0.0" />
<PackageReference Include="Chorizite.DatReaderWriter" />
paket add Chorizite.DatReaderWriter --version 1.0.0
#r "nuget: Chorizite.DatReaderWriter, 1.0.0"
#:package Chorizite.DatReaderWriter@1.0.0
#addin nuget:?package=Chorizite.DatReaderWriter&version=1.0.0
#tool nuget:?package=Chorizite.DatReaderWriter&version=1.0.0
DatReaderWriter
DatReaderWriter is an open-source library for reading and writing .dat files used by the game Asheron's Call. This tool allows players and developers to access and modify game data files for various purposes, such as creating mods or analyzing game content.
Table of Contents
Features
- Read/Write AC end-of-retail .dat files (Including creating new dats!)
- Full Dat BTree seeking / insertion / removal / range queries
- Built-in caching options
- net8.0;netstandard2.0;net48 nuget packages
- Most DBObj file formats are in the dats.xml, which could be potentially used to generate readerwriters in other languages
Basic Usage
- Install
Chorizite.DatReaderWriter
package from nuget.org - See Tests for further usage.
Getting Started
// Open a set of dat file for reading. This will open all the eor dat files as a single collection.
// (client_portal.dat, client_cell_1.dat, client_local_English.dat, and client_highres.dat)
var datPath = @"C:\Turbing\Asheron's Call\";
var dats= new DatCollection(EORCommonData.DatDirectory, DatAccessType.ReadWrite);
// read files
LayoutDesc? layoutDesc = dats.Get<LayoutDesc>(0x21000000u);
// check iteration of portal dat
Console.WriteLine($"Portal Iteration: {dats.Portal.Iteration.CurrentIteration}");
// get ids of all Animations
IEnumerable<uint> allAnimationIds = dats.GetAllIdsOfType<Animation>();
// determine type from a file id
var type = dats.Local.TypeFromId(0x21000000u);
Assert.AreEqual(DBObjType.LayoutDesc, type);
// write a file with a new iteration
StringTable? stringTable = dats.Get<StringTable>(0x23000001u) ?? throw new Exception("StringTable not found");
stringTable.StringTableData.Add(0x1234u, new StringTableData() {
Strings = ["foo", "bar"]
});
var newIteration = dats.Local.Iteration.CurrentIteration + 1;
if (!dats.TryWriteFile(stringTable, newIteration)) throw new Exception($"Failed to write StringTable");
// Dispose dat collection to flush any changes and close the files
dats.Dispose();
Update spell names and descriptions
var portalDat = new PortalDatabase(Path.Combine(config.clientDir, "client_portal.dat"), DatAccessType.ReadWrite);
var spellTable = portalDat.SpellTable ?? throw new Exception("Failed to read spell table");
// update spell name / description (no need to worry about updating Components with newly
// encrypted values, they will be transparently decrypted/encrypted during (un)packing).
spellTable.Spells[1].Name = "Strength Other I (updated)";
spellTable.Spells[1].Description = "Increases the target's Strength by 10 points. (updated)";
//write the updated spell table
if (!portalDat.TryWriteFile(spellTable)) {
throw new Exception("Failed to write spell table");
}
// close dat
portalDat.Dispose();
Rewrite all MotionTables to be 100x speed
var portalDat = new PortalDatabase(Path.Combine(config.clientDir, "client_portal.dat"), DatAccessType.ReadWrite);
// loop through all motion tables and update framerates
foreach (var mTable in portalDat.MotionTables) {
// build a list of all animations
var anims = new List<AnimData>();
anims.AddRange(mTable.Cycles.Values.SelectMany(c => c.Anims));
anims.AddRange(mTable.Modifiers.Values.SelectMany(c => c.Anims));
anims.AddRange(mTable.Links.Values.SelectMany(v => v.MotionData.Values.SelectMany(c => c.Anims)));
// update all animation framerates
foreach (var anim in anims) {
anim.Framerate *= 100f;
}
// write MotionTable back to the dat
portalDat.TryWriteFile(mTable);
}
// close dat
portalDat.Dispose();
Todo
- Support for older dat formats
- Clean up source gen so the library can be generated in other languages (kaitai struct?)
- DBObjs left to implement:
- RenderMaterial
Contributing
We welcome contributions from the community! If you would like to contribute to DatReaderWriter, please follow these steps:
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes.
- Commit your changes (git commit -am 'Add some feature').
- Push to the branch (git push origin feature-branch).
- Create a new Pull Request.
Thanks
In no particular order, thanks to ACE team, GDLE team, gmriggs, OptimShi, paradox, and Yonneh. Used lots of projects as a reference for different parts.
License
This project is licensed under the MIT License. See the LICENSE.txt file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.8
- System.Buffers (>= 4.6.1)
- System.IO.Pipelines (>= 9.0.5)
- System.Memory (>= 4.6.3)
-
.NETStandard 2.0
- System.Buffers (>= 4.6.1)
- System.IO.Pipelines (>= 9.0.5)
- System.Memory (>= 4.6.3)
-
net8.0
- System.Buffers (>= 4.6.1)
- System.IO.Pipelines (>= 9.0.5)
- System.Memory (>= 4.6.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Chorizite.DatReaderWriter:
Package | Downloads |
---|---|
Chorizite.Core
Chorizite core library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 355 | 5/14/2025 |
## What's Changed
* readme by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/1
* Dat BTree reading / writing by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/2
* cleanup by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/3
* Fixes and stuff by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/4
* add *enough* transaction support to let the client load generated dat… by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/5
* tree deletion support by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/6
* add nuget / gitversion by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/7
* ci / gitversion by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/10
* update version... by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/11
* fix namespace by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/12
* Proper writing support, added a few DBObj types by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/13
* Add support for Region / DidMapper. Fix bugs by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/14
* wip dat writing / initialization.. add more types by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/15
* add dotnet framework 4.8 target by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/16
* Add enumerable collections on CellDatabase/PortalDatabase. Add Tree.G… by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/17
* Collection fixes and SpellTable / SpellComponentTable support by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/18
* Update SpellBase so that Components array is transparently encrypted … by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/19
* remove immutable ref by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/20
* SpellBase cleanup by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/21
* fix? by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/22
* Add ThrowIfError method to Result<> by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/23
* add file stream block allocator by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/24
* refactor by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/25
* use StreamBlockAllocator by default on x86 by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/26
* keymaps by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/27
* More dbobjs by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/28
* Add VitalTable and SkillTable DBObjs by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/29
* add chargen by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/30
* add missing terrain texture types by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/31
* Update beta-release.yml by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/32
* Update beta-release.yml by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/33
* add namefiltertable dbobj by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/34
* Dbobjs by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/35
* Add LanguageInfo DBObj, add LocalDatabase wrapper by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/36
* More dbobjs by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/37
* Renamed Keymap to MasterInputMap, also fixed reading/writing by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/38
* DatDatabase is now solely responsible for disposing the block allocat… by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/39
* More by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/40
* Fix bug where EnvCell StaticObjects were being read incorrectly (than… by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/42
* add SpellIndex enum by @gmriggs in https://github.com/Chorizite/DatReaderWriter/pull/41
* Define more enums for SpellBase (thanks gmriggs) by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/43
* Uilayout by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/44
* add some missing [Flags] attributes by @gmriggs in https://github.com/Chorizite/DatReaderWriter/pull/45
* sync SkillFormula up to acclient by @gmriggs in https://github.com/Chorizite/DatReaderWriter/pull/46
* add missing shield skill by @gmriggs in https://github.com/Chorizite/DatReaderWriter/pull/47
* Fix SoundDatas with multiple entries by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/48
* Fixes (DBProperties, LayoutDesc), more finalized api by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/49
* bsp trees now write correctly by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/50
* Update README.md by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/51
* Update README.md by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/52
* readme updates, add DatCollection.TryWriteFile(IDBObj) by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/53
* add ActionMap (thanks Optim), cleanup stuff for release by @trevis in https://github.com/Chorizite/DatReaderWriter/pull/54
## New Contributors
* @trevis made their first contribution in https://github.com/Chorizite/DatReaderWriter/pull/1
* @gmriggs made their first contribution in https://github.com/Chorizite/DatReaderWriter/pull/41
**Full Changelog**: https://github.com/Chorizite/DatReaderWriter/commits/release/1.0.0