mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-06-12 02:30:43 +00:00
be354f139b
* removing objects records from d2datadict * removing Overlay singleton from d2datadict * remove PetTypes singleton from d2datadict * remove PlayerClass singleton from d2datadict * removed PlrModes singleton from d2datadict * removed Properties singleton from d2datadict * removed ItemQuality singleton from d2datadict * removed RarePrefix and RareSuffix singletons from d2datadict * removed States singleton from d2datadict * removed Runewords singleton from d2datadict * removed Sets and SetItems singletons from d2datadict * remoed Shrines singleton from d2datadict * removed UniqueItems singleton from d2datadict * removed SuperUniques singleton from d2datadict * removed TreasureClass singleton from d2datadict * removed UniqueAppellation singleton from d2datadict * removed d2datadict * removed data dict init from d2app, this has moved to asset manager init
45 lines
827 B
Go
45 lines
827 B
Go
package d2records
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
|
)
|
|
|
|
const (
|
|
nameSize = 32
|
|
tokenSize = 20
|
|
)
|
|
|
|
// LoadObjectTypes loads ObjectTypeRecords from objtype.txt
|
|
func objectTypesLoader(r *RecordManager, d *d2txt.DataDictionary) error {
|
|
records := make(ObjectTypes, 0)
|
|
|
|
for d.Next() {
|
|
record := ObjectTypeRecord{
|
|
Name: sanitizeObjectString(d.String("Name")),
|
|
Token: sanitizeObjectString(d.String("Token")),
|
|
}
|
|
|
|
records = append(records, record)
|
|
}
|
|
|
|
if d.Err != nil {
|
|
return d.Err
|
|
}
|
|
|
|
log.Printf("Loaded %d object types", len(records))
|
|
|
|
r.Object.Types = records
|
|
|
|
return nil
|
|
}
|
|
|
|
func sanitizeObjectString(str string) string {
|
|
result := strings.TrimSpace(strings.ReplaceAll(str, string(byte(0)), ""))
|
|
result = strings.ToLower(result)
|
|
|
|
return result
|
|
}
|