-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The DBC files can be readed into structs directly with the new dbc.Reader - You can tag the struct fields with dbc tag to instruct the reader - The new DBC reader can read string, localized string fields too
- Loading branch information
Showing
8 changed files
with
449 additions
and
85 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dbc | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/paalgyula/summit/pkg/summit/tools/dbc/wotlk" | ||
) | ||
|
||
func LoadMaps(dbcDirectoryPath string) ([]wotlk.MapEntry, error) { | ||
filename := "Map.dbc" | ||
f, err := os.Open(path.Join(filename)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
r, err := NewReader[wotlk.MapEntry](f) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err := r.ReadAll(); err != nil { | ||
return nil, err | ||
} | ||
|
||
fmt.Println(r.Records[0].MapName.Value()) | ||
|
||
// fmt.Println(string(r.Strings())) | ||
return r.Records, nil | ||
} | ||
|
||
func LoadCharacter(dbcDirectoryPath string) ([]wotlk.CharStartOutfitEntry, error) { | ||
filename := "CharStartOutfit.dbc" | ||
f, err := os.Open(path.Join(dbcDirectoryPath, filename)) | ||
if err != nil { | ||
return nil, fmt.Errorf("cannot load CharStartOutfit.dbc: %w", err) | ||
} | ||
|
||
r, err := NewReader[wotlk.CharStartOutfitEntry](f) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err := r.ReadAll(); err != nil { | ||
return nil, err | ||
} | ||
|
||
fmt.Println("Loaded", len(r.Records), "records") | ||
|
||
return r.Records, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package dbc | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/paalgyula/summit/pkg/summit/tools/dbc/wotlk" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGenerate(t *testing.T) { | ||
// LoadCharacterRaces() | ||
// LoadClassInfo() | ||
|
||
f, err := os.Open("../../../../dbc/ChrClasses.dbc") | ||
assert.NoError(t, err) | ||
|
||
dr, err := NewReader[wotlk.ChrClassesEntry](f) | ||
assert.NoError(t, err) | ||
assert.EqualValues(t, 0xa, dr.Header.RecordCount) | ||
|
||
dr.ReadAll() | ||
|
||
fmt.Println(dr.Records[1].Name.Value()) | ||
|
||
// fmt.Printf("%+v\n\n", dr.Header) | ||
} | ||
|
||
func TestLoadMap(t *testing.T) { | ||
LoadMaps("../../../../dbc") | ||
} | ||
|
||
func TestLoadCharacters(t *testing.T) { | ||
_, err := LoadCharacter("../../../../dbc") | ||
assert.NoError(t, err) | ||
} |
Oops, something went wrong.