Skip to content

Commit

Permalink
use mtdb.NewBlockDB instead of the whole db context
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Feb 19, 2023
1 parent b4c1fc8 commit 8dce5c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (

"github.com/minetest-go/areasparser"
"github.com/minetest-go/mtdb"
"github.com/minetest-go/mtdb/block"
"github.com/sirupsen/logrus"
)

var Version string
var ctx *mtdb.Context
var block_repo block.BlockRepository
var wd string

func main() {
Expand All @@ -35,7 +36,7 @@ func main() {
"version": Version,
}).Info("Starting mapcleaner")

ctx, err = mtdb.New(wd)
block_repo, err = mtdb.NewBlockDB(wd)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions protected.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func IsEmerged(chunk_x, chunk_y, chunk_z int) (bool, error) {
for _, x := range []int{x1, x2} {
for _, y := range []int{y1, y2} {
for _, z := range []int{z1, z2} {
data, err := ctx.Blocks.GetByPos(x, y, z)
data, err := block_repo.GetByPos(x, y, z)
if err != nil {
return false, err
}
Expand Down Expand Up @@ -133,7 +133,7 @@ func IsProtected(chunk_x, chunk_y, chunk_z int) (bool, error) {
"z": z,
}).Debug("Checking mapblock")

block, err := ctx.Blocks.GetByPos(x, y, z)
block, err := block_repo.GetByPos(x, y, z)
if err != nil {
return false, err
}
Expand Down
2 changes: 1 addition & 1 deletion remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func RemoveChunk(chunk_x, chunk_y, chunk_z int) error {
"z": z,
}).Debug("Removing mapblock")

err := ctx.Blocks.Delete(x, y, z)
err := block_repo.Delete(x, y, z)
if err != nil {
return err
}
Expand Down

0 comments on commit 8dce5c1

Please sign in to comment.