diff --git a/d2common/d2fileformats/d2ds1/ds1_layers.go b/d2common/d2fileformats/d2ds1/ds1_layers.go index 2af493cc..e7d872ee 100644 --- a/d2common/d2fileformats/d2ds1/ds1_layers.go +++ b/d2common/d2fileformats/d2ds1/ds1_layers.go @@ -132,7 +132,7 @@ func (l *ds1Layers) push(t LayerGroupType, layer *Layer) { group := l.getLayersGroup(t) - max := getMaxGroupLen(t) + max := GetMaxGroupLen(t) if len(*group) < max { *group = append(*group, layer) @@ -194,7 +194,7 @@ func (l *ds1Layers) insert(t LayerGroupType, idx int, newLayer *Layer) { return } - if len(*group)+1 > getMaxGroupLen(t) { + if len(*group)+1 > GetMaxGroupLen(t) { return } @@ -335,7 +335,8 @@ func (l *ds1Layers) getLayersGroup(t LayerGroupType) (group *layerGroup) { return group } -func getMaxGroupLen(t LayerGroupType) (max int) { +// GetMaxGroupLen returns maximum length of layer group of type given +func GetMaxGroupLen(t LayerGroupType) (max int) { switch t { case FloorLayerGroup: max = maxFloorLayers diff --git a/d2common/d2fileformats/d2ds1/ds1_layers_test.go b/d2common/d2fileformats/d2ds1/ds1_layers_test.go index 2df948cb..97015652 100644 --- a/d2common/d2fileformats/d2ds1/ds1_layers_test.go +++ b/d2common/d2fileformats/d2ds1/ds1_layers_test.go @@ -116,7 +116,7 @@ func Test_ds1Layers_Insert(t *testing.T) { func ds1LayersInsert(t *testing.T, lt LayerGroupType) { ds1 := DS1{} - layers := make([]*Layer, getMaxGroupLen(lt)+1) + layers := make([]*Layer, GetMaxGroupLen(lt)+1) for i := range layers { i := i @@ -150,7 +150,7 @@ func ds1LayersInsert(t *testing.T, lt LayerGroupType) { insert(i) } - if len(*group) != getMaxGroupLen(lt) { + if len(*group) != GetMaxGroupLen(lt) { t.Fatal("unexpected floor len after setting") }