Skip to content

Commit

Permalink
Move private packages to /internal
Browse files Browse the repository at this point in the history
  • Loading branch information
weqqr committed Apr 23, 2023
1 parent b9d2f5b commit 8483073
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 52 deletions.
14 changes: 7 additions & 7 deletions cmd/panorama/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"log"
"path"

"github.com/lord-server/panorama/pkg/config"
"github.com/lord-server/panorama/pkg/game"
"github.com/lord-server/panorama/pkg/render"
"github.com/lord-server/panorama/pkg/render/isometric"
"github.com/lord-server/panorama/pkg/tile"
"github.com/lord-server/panorama/pkg/web"
"github.com/lord-server/panorama/pkg/world"
"github.com/lord-server/panorama/internal/config"
"github.com/lord-server/panorama/internal/game"
"github.com/lord-server/panorama/internal/render"
"github.com/lord-server/panorama/internal/render/isometric"
"github.com/lord-server/panorama/internal/tile"
"github.com/lord-server/panorama/internal/web"
"github.com/lord-server/panorama/internal/world"
)

type Args struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go → internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/BurntSushi/toml"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/internal/spatial"
)

type Web struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/game/game.go → internal/game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"image"
"os"

"github.com/lord-server/panorama/pkg/mesh"
"github.com/lord-server/panorama/internal/mesh"
)

type gameDescriptor struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/game/media.go → internal/game/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"path/filepath"
"strings"

"github.com/lord-server/panorama/pkg/mesh"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/internal/mesh"
"github.com/lord-server/panorama/internal/raster"
)

type MediaCache struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/mesh/mesh.go → internal/mesh/mesh.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mesh

import (
"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/internal/lm"
)

type Vertex struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/mesh/obj.go → internal/mesh/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/internal/lm"
)

func parseVector3(fields []string) (lm.Vector3, error) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"image"
"math"

"github.com/lord-server/panorama/pkg/game"
"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/pkg/mesh"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/pkg/render"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/pkg/world"
"github.com/lord-server/panorama/internal/game"
"github.com/lord-server/panorama/internal/lm"
"github.com/lord-server/panorama/internal/mesh"
"github.com/lord-server/panorama/internal/raster"
"github.com/lord-server/panorama/internal/render"
"github.com/lord-server/panorama/internal/spatial"
"github.com/lord-server/panorama/internal/world"
)

var (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package render

import (
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/pkg/world"
"github.com/lord-server/panorama/internal/spatial"
"github.com/lord-server/panorama/internal/world"
)

type BlockNeighborhood struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/render/rasterizer.go → internal/render/rasterizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"image/color"
"math"

"github.com/lord-server/panorama/pkg/game"
"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/pkg/mesh"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/internal/game"
"github.com/lord-server/panorama/internal/lm"
"github.com/lord-server/panorama/internal/mesh"
"github.com/lord-server/panorama/internal/raster"
)

const Gamma = 2.2
Expand Down
8 changes: 4 additions & 4 deletions pkg/render/renderer.go → internal/render/renderer.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package render

import (
"github.com/lord-server/panorama/pkg/game"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/pkg/world"
"github.com/lord-server/panorama/internal/game"
"github.com/lord-server/panorama/internal/raster"
"github.com/lord-server/panorama/internal/spatial"
"github.com/lord-server/panorama/internal/world"
)

type TilePosition struct {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions pkg/tile/downscale.go → internal/tile/downscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/nfnt/resize"

"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/pkg/render"
"github.com/lord-server/panorama/internal/lm"
"github.com/lord-server/panorama/internal/raster"
"github.com/lord-server/panorama/internal/render"
)

func uniquePositions(input []render.TilePosition) []render.TilePosition {
Expand Down
12 changes: 6 additions & 6 deletions pkg/tile/tiler.go → internal/tile/tiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"strings"
"sync"

"github.com/lord-server/panorama/pkg/game"
"github.com/lord-server/panorama/pkg/lm"
"github.com/lord-server/panorama/pkg/raster"
"github.com/lord-server/panorama/pkg/render"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/pkg/world"
"github.com/lord-server/panorama/internal/game"
"github.com/lord-server/panorama/internal/lm"
"github.com/lord-server/panorama/internal/raster"
"github.com/lord-server/panorama/internal/render"
"github.com/lord-server/panorama/internal/spatial"
"github.com/lord-server/panorama/internal/world"
)

type Tiler struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
"github.com/gofiber/fiber/v2"

"github.com/lord-server/panorama/pkg/config"
"github.com/lord-server/panorama/internal/config"
)

func Metadata(config *config.Config) func(c *fiber.Ctx) error {
Expand Down
4 changes: 2 additions & 2 deletions pkg/web/server.go → internal/web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/gofiber/fiber/v2"

"github.com/lord-server/panorama/pkg/config"
"github.com/lord-server/panorama/pkg/web/handlers"
"github.com/lord-server/panorama/internal/config"
"github.com/lord-server/panorama/internal/web/handlers"
)

func Serve(config *config.Config) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/world/block.go → internal/world/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"

"github.com/klauspost/compress/zstd"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/internal/spatial"
)

const NodeSizeInBytes = 4
Expand Down
18 changes: 9 additions & 9 deletions pkg/world/world.go → internal/world/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
lru "github.com/hashicorp/golang-lru/v2"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/lord-server/panorama/pkg/spatial"
"github.com/lord-server/panorama/internal/spatial"
)

type Backend interface {
Expand Down Expand Up @@ -49,23 +49,23 @@ func (p *PostgresBackend) GetBlockData(pos spatial.BlockPosition) ([]byte, error
}

type World struct {
backend Backend
blockCache *lru.Cache[spatial.BlockPosition, *MapBlock]
backend Backend
decodedBlockCache *lru.Cache[spatial.BlockPosition, *MapBlock]
}

func NewWorldWithBackend(backend Backend) World {
blockCache, err := lru.New[spatial.BlockPosition, *MapBlock](1024 * 16)
decodedBlockCache, err := lru.New[spatial.BlockPosition, *MapBlock](1024 * 16)
if err != nil {
panic(err)
}
return World{
backend: backend,
blockCache: blockCache,
backend: backend,
decodedBlockCache: decodedBlockCache,
}
}

func (w *World) GetBlock(pos spatial.BlockPosition) (*MapBlock, error) {
cachedBlock, ok := w.blockCache.Get(pos)
cachedBlock, ok := w.decodedBlockCache.Get(pos)

if ok {
if cachedBlock == nil {
Expand All @@ -80,7 +80,7 @@ func (w *World) GetBlock(pos spatial.BlockPosition) (*MapBlock, error) {
}

if data == nil {
w.blockCache.Add(pos, nil)
w.decodedBlockCache.Add(pos, nil)
return nil, nil
}

Expand All @@ -89,7 +89,7 @@ func (w *World) GetBlock(pos spatial.BlockPosition) (*MapBlock, error) {
return nil, err
}

w.blockCache.Add(pos, block)
w.decodedBlockCache.Add(pos, block)

return block, nil
}

0 comments on commit 8483073

Please sign in to comment.