Giter Site home page Giter Site logo

db2's Introduction

Build Status Coverage Status Become a Patron!

DB2 Reader

This is a small library to read DB2 and ADB/DBCache files (data tables) from World of Warcraft.

Requirements

This was developed using 64-bit PHP 7. Tests are also run against PHP 5.6. 64-bit versions are recommended to support unsigned 32-bit ints and 64-bit ints.

Mbstring extension is required for all formats, and gmp extension is required for WDC1 support.

Usage

// Instantiate an object with the path to a DB2 file.
$db2Reader = new Reader("Achievement.db2"); 
 
// Records are presented as simple arrays.
// Some fields are, themselves, arrays of values.
// Get individual records by ID with:
$record = $db2Reader->getRecord(17);
 
// Loop through records with:
foreach ($db2Reader->generateRecords() as $id => $record) { ... }
 
// All valid record IDs:
$ids = $db2Reader->getIds();
 
// You can set field names for convenience:
$db2Reader->setFieldNames([0 => "name", 1 => "note", ...]);
$record = $db2Reader->getRecord(17);
if ($record['name'] == "...") ...
 
// All integers are assumed to be unsigned, but you can change that by field:
$db2Reader->setFieldsSigned([2 => true, 7 => true]);
$record = $db2Reader->getRecord(17);
if ($record[2] < 0) ...
 
// You can get the calculated field types, 
// useful when dynamically creating database tables:
$types = $db2Reader->getFieldTypes();
if ($types['name'] == Reader::FIELD_TYPE_STRING) ...
 
// You can load an ADB or DBCache, as long as you have its parent DB2.
// That reader will only expose records in the Hotfix/DBCache file.
$adbReader = $db2Reader->loadAdb("Achievement.adb");
$dbCacheReader = $db2Reader->loadDBCache("DBCache.bin");

// Finally, you can specify both the DB2 and the DBCache file when constructing a HotfixedReader.
// This has the same interface as Reader, but will substitute hotfixed records when available.
$hotReader = new HotfixedReader("Achievement.db2", "DBCache.bin");

Also check out example.php, which is what I'm using during development.

Compatibility

Version Format Works Unit Tests
3.x - 6.x WDB2
7.0.1 WDB3
7.0.3 WDB4
7.0.3 - 7.2.0 WDB5
7.0.3 - 7.2.0 WCH7/8
7.2.0 - 7.3.2 WDB6
7.2.0 - ? DBCache.bin
7.3.5 WDC1
8.0.1 WDC2
1.13.2 1SLC
8.1.0 - ? WDC3

All features of DB2 files should be supported (offset map / embedded strings, copy blocks, common blocks, pallet data, etc).

Encrypted blocks are expected to be decrypted by your CASC tool before being read by this library. For blocks that cannot be decrypted (because the key is unknown, for example), your CASC tool should substitute NUL bytes for the length of the encrypted blocks. DB2Reader ignores blocks which are encrypted and are empty of data.

ADBs/DBCache require their counterpart DB2 file for necessary metadata, and Internet access to get field sizes via WoWDBDefs.

Goals

This is used for The Undermine Journal (Newsstand) to datamine items, pets, and other entities.

Disclaimers

This work is neither endorsed by nor affiliated with Blizzard Entertainment.

Thanks

Most of the file format details were found by documentation at the WoWDev wiki. Thanks to those who contribute there!

Thanks to WoWDBDefs for providing the table formats used by the game executable so we can parse hotfixes.

License

Copyright 2017 Gerard Dombroski

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

db2's People

Contributors

erorus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

db2's Issues

Custom Project: ItemSparse names are integers

Good time of the day, i'm trying to create a library which should be of any use for people who want to work with the DB2 files. I've used your project as a base for the library.

I understand if you don't want to support '3rd party implementations', but it would be nice if you would give me at least a hint on where this error might be.
Thank you for your time, and thank you for such an amazing library!
P.S. Here is the link to the project https://github.com/darki73/trinitycore-support/tree/master/source

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.