mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-20 23:47:16 -05:00
commit
938ce20579
@ -101,6 +101,8 @@ const (
|
||||
|
||||
// Create creates a new instance of the application
|
||||
func Create(gitBranch, gitCommit string) *App {
|
||||
runtime.LockOSThread()
|
||||
|
||||
logger := d2util.NewLogger()
|
||||
logger.SetPrefix(appLoggerPrefix)
|
||||
|
||||
@ -258,8 +260,6 @@ func (a *App) LoadConfig() (*d2config.Configuration, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
//config.SetPath(filepath.Join(configAsset.Source().Path(), configAsset.Path()))
|
||||
|
||||
a.Infof("loaded configuration file from %s", config.Path())
|
||||
|
||||
return config, nil
|
||||
@ -623,6 +623,11 @@ func (a *App) ToCreateGame(filePath string, connType d2clientconnectiontype.Clie
|
||||
a.Error(err.Error())
|
||||
}
|
||||
|
||||
if gameClient == nil {
|
||||
a.Error("could not create client")
|
||||
return
|
||||
}
|
||||
|
||||
if err = gameClient.Open(host, filePath); err != nil {
|
||||
errorMessage := fmt.Sprintf("can not connect to the host: %s", host)
|
||||
a.Error(errorMessage)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package d2tbl
|
||||
|
||||
import (
|
||||
"log"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2datautils"
|
||||
@ -24,7 +24,7 @@ const (
|
||||
)
|
||||
|
||||
// LoadTextDictionary loads the text dictionary from the given data
|
||||
func LoadTextDictionary(dictionaryData []byte) TextDictionary {
|
||||
func LoadTextDictionary(dictionaryData []byte) (TextDictionary, error) {
|
||||
lookupTable := make(TextDictionary)
|
||||
|
||||
br := d2datautils.CreateStreamReader(dictionaryData)
|
||||
@ -37,7 +37,7 @@ func LoadTextDictionary(dictionaryData []byte) TextDictionary {
|
||||
|
||||
// Version (always 0)
|
||||
if _, err := br.ReadByte(); err != nil {
|
||||
log.Fatal("Error reading Version record")
|
||||
return nil, errors.New("error reading Version record")
|
||||
}
|
||||
|
||||
br.GetUInt32() // StringOffset
|
||||
@ -62,6 +62,10 @@ func LoadTextDictionary(dictionaryData []byte) TextDictionary {
|
||||
}
|
||||
|
||||
for idx, hashEntry := range hashEntries {
|
||||
if br.EOF() {
|
||||
return nil, errors.New("unexpected end of text dictionary file")
|
||||
}
|
||||
|
||||
if !hashEntry.IsActive {
|
||||
continue
|
||||
}
|
||||
@ -93,5 +97,5 @@ func LoadTextDictionary(dictionaryData []byte) TextDictionary {
|
||||
}
|
||||
}
|
||||
|
||||
return lookupTable
|
||||
return lookupTable, nil
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ func (l *Loader) AddSource(path string, sourceType types.SourceType) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Exists checks if the given path exists in at least one source
|
||||
func (l *Loader) Exists(subPath string) bool {
|
||||
subPath = filepath.Clean(subPath)
|
||||
|
||||
|
@ -62,7 +62,6 @@ func TestLoader_AddSource(t *testing.T) {
|
||||
if errE == nil {
|
||||
t.Error("expecting error on bad file path")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// nolint:gocyclo // this is just a test, not a big deal if we ignore linter here
|
||||
|
@ -42,12 +42,6 @@ func (a *Asset) Path() string {
|
||||
// Read will read asset data into the given buffer
|
||||
func (a *Asset) Read(buf []byte) (n int, err error) {
|
||||
return a.stream.Read(buf)
|
||||
//totalRead, err := a.stream.Read(buf)
|
||||
//if totalRead == 0 {
|
||||
// return 0, io.EOF
|
||||
//}
|
||||
//
|
||||
//return totalRead, err
|
||||
}
|
||||
|
||||
// Seek will seek the read position for the next read operation
|
||||
|
@ -274,9 +274,9 @@ func (am *AssetManager) LoadStringTable(tablePath string) (d2tbl.TextDictionary,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
table := d2tbl.LoadTextDictionary(data)
|
||||
if table == nil {
|
||||
return nil, fmt.Errorf("table not found: %s", tablePath)
|
||||
table, err := d2tbl.LoadTextDictionary(data)
|
||||
if err != nil {
|
||||
return table, err
|
||||
}
|
||||
|
||||
am.Debugf(fmtLoadStringTable, tablePath)
|
||||
@ -485,6 +485,7 @@ func (am *AssetManager) commandAssetClear([]string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadDT1 loads and returns the given path as a DT1
|
||||
func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) {
|
||||
if dt1Value, found := am.dt1s.Retrieve(dt1Path); found {
|
||||
return dt1Value.(*d2dt1.DT1), nil
|
||||
@ -492,7 +493,7 @@ func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) {
|
||||
|
||||
fileData, err := am.LoadFile("/data/global/tiles/" + dt1Path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not load /data/global/tiles/%s", dt1Path)
|
||||
return nil, fmt.Errorf("could not load /data/global/tiles/%s", dt1Path)
|
||||
}
|
||||
|
||||
dt1, err := d2dt1.LoadDT1(fileData)
|
||||
@ -507,6 +508,7 @@ func (am *AssetManager) LoadDT1(dt1Path string) (*d2dt1.DT1, error) {
|
||||
return dt1, nil
|
||||
}
|
||||
|
||||
// LoadDS1 loads and returns the given path as a DS1
|
||||
func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error) {
|
||||
if ds1Value, found := am.dt1s.Retrieve(ds1Path); found {
|
||||
return ds1Value.(*d2ds1.DS1), nil
|
||||
@ -527,9 +529,9 @@ func (am *AssetManager) LoadDS1(ds1Path string) (*d2ds1.DS1, error) {
|
||||
}
|
||||
|
||||
return ds1, nil
|
||||
|
||||
}
|
||||
|
||||
// LoadCOF loads and returns the given path as a COF
|
||||
func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error) {
|
||||
if cofValue, found := am.cofs.Retrieve(cofPath); found {
|
||||
return cofValue.(*d2cof.COF), nil
|
||||
@ -552,6 +554,7 @@ func (am *AssetManager) LoadCOF(cofPath string) (*d2cof.COF, error) {
|
||||
return cof, nil
|
||||
}
|
||||
|
||||
// LoadDCC loads and returns the given path as a DCC
|
||||
func (am *AssetManager) LoadDCC(dccPath string) (*d2dcc.DCC, error) {
|
||||
if dccValue, found := am.dccs.Retrieve(dccPath); found {
|
||||
return dccValue.(*d2dcc.DCC), nil
|
||||
|
@ -88,11 +88,18 @@ func CreateMapRenderer(asset *d2asset.AssetManager, renderer d2interface.Rendere
|
||||
result.Camera.position = &startPosition
|
||||
result.viewport.SetCamera(&result.Camera)
|
||||
|
||||
if err := term.Bind("mapdebugvis", "set map debug visualization level", []string{"level"}, result.commandMapDebugVis); err != nil {
|
||||
var name, desc, level string
|
||||
|
||||
name, desc = "mapdebugvis", "set map debug visualization level"
|
||||
level = "level"
|
||||
|
||||
if err := term.Bind(name, desc, []string{level}, result.commandMapDebugVis); err != nil {
|
||||
result.Errorf("could not bind the mapdebugvis action, err: %v", err)
|
||||
}
|
||||
|
||||
if err := term.Bind("entitydebugvis", "set entity debug visualization level", []string{"level"}, result.commandEntityDebugVis); err != nil {
|
||||
name, desc = "entitydebugvis", "set entity debug visualization level"
|
||||
|
||||
if err := term.Bind(name, desc, []string{level}, result.commandEntityDebugVis); err != nil {
|
||||
result.Errorf("could not bind the entitydebugvis action, err: %v", err)
|
||||
}
|
||||
|
||||
|
@ -863,6 +863,7 @@ type buttonStateDescriptor struct {
|
||||
|
||||
func (v *Button) createTooltip() {
|
||||
var t *Tooltip
|
||||
|
||||
switch v.buttonLayout.Tooltip {
|
||||
case buttonTooltipNone:
|
||||
return
|
||||
|
@ -3,7 +3,6 @@ package d2thread
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// CallQueueCap is the capacity of the call queue. This means how many calls to CallNonBlock will not
|
||||
@ -11,13 +10,9 @@ import (
|
||||
//
|
||||
// The default value is 16 and should be good for 99% usecases.
|
||||
var (
|
||||
callQueue chan func() //nolint:gochecknoglobals
|
||||
callQueue chan func() //nolint:gochecknoglobals // necessary evil for now
|
||||
)
|
||||
|
||||
func init() {
|
||||
runtime.LockOSThread()
|
||||
}
|
||||
|
||||
func checkRun() {
|
||||
if callQueue == nil {
|
||||
panic(errors.New("mainthread: did not call Run"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user