From 1ce81f1aec2f1c7a8cd02151f62b1386b11cd1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrkan=20Kaymak?= Date: Fri, 24 Jul 2020 14:54:52 +0300 Subject: [PATCH] fixed Id renaming in strings (#618) --- d2common/d2data/d2datadict/hireling.go | 4 ++-- d2common/d2data/d2datadict/level_warp.go | 2 +- d2common/d2data/d2datadict/levels.go | 12 ++++++------ d2common/d2data/d2datadict/monstats.go | 14 +++++++------- d2common/d2data/d2datadict/monstats2.go | 2 +- d2common/d2data/d2datadict/skills.go | 2 +- d2common/d2data/object.go | 2 +- d2common/d2fileformats/d2ds1/ds1.go | 2 +- d2core/d2map/d2mapstamp/stamp.go | 4 ++-- d2core/d2stats/diablo2stats/stat_test.go | 2 +- .../d2stats/diablo2stats/stat_value_stringers.go | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/d2common/d2data/d2datadict/hireling.go b/d2common/d2data/d2datadict/hireling.go index 21a418f4..53141aa1 100644 --- a/d2common/d2data/d2datadict/hireling.go +++ b/d2common/d2data/d2datadict/hireling.go @@ -96,7 +96,7 @@ func LoadHireling(file []byte) { hireling := &HirelingRecord{ Hireling: d.String("Hireling"), SubType: d.String("SubType"), - ID: d.Number("ID"), + ID: d.Number("Id"), Class: d.Number("Class"), Act: d.Number("Act"), Difficulty: d.Number("Difficulty"), @@ -109,7 +109,7 @@ func LoadHireling(file []byte) { HP: d.Number("HP"), HPPerLvl: d.Number("HP/Lvl"), Defense: d.Number("Defense"), - DefPerLvl: d.Number("ID"), + DefPerLvl: d.Number("Id"), Str: d.Number("Str"), StrPerLvl: d.Number("Str/Lvl"), Dex: d.Number("Dex"), diff --git a/d2common/d2data/d2datadict/level_warp.go b/d2common/d2data/d2datadict/level_warp.go index 58996626..3ac24b46 100644 --- a/d2common/d2data/d2datadict/level_warp.go +++ b/d2common/d2data/d2datadict/level_warp.go @@ -36,7 +36,7 @@ func LoadLevelWarps(file []byte) { for d.Next() { record := &LevelWarpRecord{ Name: d.String("Name"), - ID: d.Number("ID"), + ID: d.Number("Id"), SelectX: d.Number("SelectX"), SelectY: d.Number("SelectY"), SelectDX: d.Number("SelectDX"), diff --git a/d2common/d2data/d2datadict/levels.go b/d2common/d2data/d2datadict/levels.go index fc088d27..099c8bce 100644 --- a/d2common/d2data/d2datadict/levels.go +++ b/d2common/d2data/d2datadict/levels.go @@ -95,7 +95,7 @@ type LevelDetailsRecord struct { // ID // Level ID (used in columns like VIS0-7) - Id int //nolint:golint,stylecheck // ID is the right key + ID int // Palette is the Act Palette . Reference only Palette int // Pal @@ -138,7 +138,7 @@ type LevelDetailsRecord struct { // location. DependantLevelID int // Depend - // The type of the Level (ID from lvltypes.txt) + // The type of the Level (Id from lvltypes.txt) LevelType int // LevelType // Controls if teleport is allowed in that level. @@ -367,10 +367,10 @@ type LevelDetailsRecord struct { //nolint:gochecknoglobals // Currently global by design, only written once var LevelDetails map[int]*LevelDetailsRecord -// GetLevelDetails gets a LevelDetailsRecord by the record ID +// GetLevelDetails gets a LevelDetailsRecord by the record Id func GetLevelDetails(id int) *LevelDetailsRecord { for i := 0; i < len(LevelDetails); i++ { - if LevelDetails[i].Id == id { + if LevelDetails[i].ID == id { return LevelDetails[i] } } @@ -387,7 +387,7 @@ func LoadLevelDetails(file []byte) { for d.Next() { record := &LevelDetailsRecord{ Name: d.String("Name "), - Id: d.Number("ID"), + ID: d.Number("Id"), Palette: d.Number("Pal"), Act: d.Number("Act"), QuestFlag: d.Number("QuestFlag"), @@ -532,7 +532,7 @@ func LoadLevelDetails(file []byte) { ObjectGroupSpawnChance6: d.Number("ObjPrb6"), ObjectGroupSpawnChance7: d.Number("ObjPrb7"), } - LevelDetails[record.Id] = record + LevelDetails[record.ID] = record } if d.Err != nil { diff --git a/d2common/d2data/d2datadict/monstats.go b/d2common/d2data/d2datadict/monstats.go index 2b6dc0f0..d955a959 100644 --- a/d2common/d2data/d2datadict/monstats.go +++ b/d2common/d2data/d2datadict/monstats.go @@ -17,9 +17,9 @@ type ( // Key contains the pointer that will be used in other txt files // such as levels.txt and superuniques.txt. - Key string // called `ID` in monstats.txt + Key string // called `Id` in monstats.txt - // ID is the actual internal ID of the unit (this is what the ID pointer + // Id is the actual internal ID of the unit (this is what the ID pointer // actually points at) remember that no two units can have the same ID, // this will result in lots of unpredictable behavior and crashes so please // don’t do it. This 'HarcCodedInDeX' is used for several things, such as @@ -28,7 +28,7 @@ type ( // column also links other hardcoded effects to the units, such as the // transparency on necro summons and the name-color change on unique boss // units (thanks to Kingpin for the info) - Id int //nolint:golint,stylecheck // called `hcIdx` in monstats.txt + ID int // called `hcIdx` in monstats.txt // BaseKey is an ID pointer of the “base” unit for this specific // monster type (ex. There are five types of “Fallen”; all of them have @@ -80,10 +80,10 @@ type ( // which animation mode will the spawned monster be spawned in. SpawnAnimationKey string // called `spawnmode` in monstats.txt - // MinionId1 is an ID of a minion that spawns when this monster is created + // MinionId1 is an Id of a minion that spawns when this monster is created MinionId1 string //nolint:golint,stylecheck // called `minion1` in monstats.txt - // MinionId2 is an ID of a minion that spawns when this monster is created + // MinionId2 is an Id of a minion that spawns when this monster is created MinionId2 string //nolint:golint,stylecheck // called `minion2` in monstats.txt // SoundKeyNormal, SoundKeySpecial @@ -690,8 +690,8 @@ func LoadMonStats(file []byte) { // nolint:funlen // Makes no sense to split d := d2common.LoadDataDictionary(file) for d.Next() { record := &MonStatsRecord{ - Key: d.String("ID"), - Id: d.Number("hcIdx"), + Key: d.String("Id"), + ID: d.Number("hcIdx"), BaseKey: d.String("BaseId"), NextKey: d.String("NextInClass"), PaletteId: d.Number("TransLvl"), diff --git a/d2common/d2data/d2datadict/monstats2.go b/d2common/d2data/d2datadict/monstats2.go index b7e94ff4..0799e95b 100644 --- a/d2common/d2data/d2datadict/monstats2.go +++ b/d2common/d2data/d2datadict/monstats2.go @@ -177,7 +177,7 @@ func LoadMonStats2(file []byte) { d := d2common.LoadDataDictionary(file) for d.Next() { record := &MonStats2Record{ - Key: d.String("ID"), + Key: d.String("Id"), Height: d.Number("Height"), OverlayHeight: d.Number("OverlayHeight"), PixelHeight: d.Number("pixHeight"), diff --git a/d2common/d2data/d2datadict/skills.go b/d2common/d2data/d2datadict/skills.go index b9c48608..10f70ac9 100644 --- a/d2common/d2data/d2datadict/skills.go +++ b/d2common/d2data/d2datadict/skills.go @@ -281,7 +281,7 @@ func LoadSkills(file []byte) { for d.Next() { record := &SkillRecord{ Skill: d.String("skill"), - ID: d.Number("ID"), + ID: d.Number("Id"), Charclass: d.String("charclass"), Skilldesc: d.String("skilldesc"), Srvstfunc: d.Number("srvstfunc"), diff --git a/d2common/d2data/object.go b/d2common/d2data/object.go index 4240ad8b..c2abade2 100644 --- a/d2common/d2data/object.go +++ b/d2common/d2data/object.go @@ -7,7 +7,7 @@ import ( // Object is a game world object type Object struct { Type int - Id int //nolint:golint ID is the right key + ID int X int Y int Flags int diff --git a/d2common/d2fileformats/d2ds1/ds1.go b/d2common/d2fileformats/d2ds1/ds1.go index a37d979a..f81003aa 100644 --- a/d2common/d2fileformats/d2ds1/ds1.go +++ b/d2common/d2fileformats/d2ds1/ds1.go @@ -115,7 +115,7 @@ func (ds1 *DS1) loadObjects(br *d2common.StreamReader) { for objIdx := 0; objIdx < int(numberOfObjects); objIdx++ { newObject := d2data.Object{} newObject.Type = int(br.GetInt32()) - newObject.Id = int(br.GetInt32()) + newObject.ID = int(br.GetInt32()) newObject.X = int(br.GetInt32()) newObject.Y = int(br.GetInt32()) newObject.Flags = int(br.GetInt32()) diff --git a/d2core/d2map/d2mapstamp/stamp.go b/d2core/d2map/d2mapstamp/stamp.go index 0524597d..936d736c 100644 --- a/d2core/d2map/d2mapstamp/stamp.go +++ b/d2core/d2map/d2mapstamp/stamp.go @@ -127,7 +127,7 @@ func (mr *Stamp) Entities(tileOffsetX, tileOffsetY int) []d2interface.MapEntity for _, object := range mr.ds1.Objects { if object.Type == int(d2enum.ObjectTypeCharacter) { - monstat := d2datadict.MonStats[d2datadict.MonPresets[mr.ds1.Act][object.Id]] + monstat := d2datadict.MonStats[d2datadict.MonPresets[mr.ds1.Act][object.ID]] // If monstat is nil here it is a place_ type object, idk how to handle those yet. // (See monpreset and monplace txts for reference) if monstat != nil { @@ -145,7 +145,7 @@ func (mr *Stamp) Entities(tileOffsetX, tileOffsetY int) []d2interface.MapEntity if object.Type == int(d2enum.ObjectTypeItem) { // For objects the DS1 ID to objectID is hardcoded in the game // use the lookup table - lookup := d2datadict.LookupObject(int(mr.ds1.Act), object.Type, object.Id) + lookup := d2datadict.LookupObject(int(mr.ds1.Act), object.Type, object.ID) if lookup == nil { continue diff --git a/d2core/d2stats/diablo2stats/stat_test.go b/d2core/d2stats/diablo2stats/stat_test.go index 303d7333..8d046736 100644 --- a/d2core/d2stats/diablo2stats/stat_test.go +++ b/d2core/d2stats/diablo2stats/stat_test.go @@ -250,7 +250,7 @@ func TestStat_InitMockData(t *testing.T) { } var monStats = map[string]*d2datadict.MonStatsRecord{ - "Specter": {NameString: "Specter", Id: 40}, + "Specter": {NameString: "Specter", ID: 40}, } d2datadict.ItemStatCosts = itemStatCosts diff --git a/d2core/d2stats/diablo2stats/stat_value_stringers.go b/d2core/d2stats/diablo2stats/stat_value_stringers.go index 36b313d3..b78d9ec7 100644 --- a/d2core/d2stats/diablo2stats/stat_value_stringers.go +++ b/d2core/d2stats/diablo2stats/stat_value_stringers.go @@ -74,7 +74,7 @@ func stringerSkillName(sv d2stats.StatValue) string { func stringerMonsterName(sv d2stats.StatValue) string { for key := range d2datadict.MonStats { - if d2datadict.MonStats[key].Id == sv.Int() { + if d2datadict.MonStats[key].ID == sv.Int() { return d2datadict.MonStats[key].NameString } }