Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add manual build documentation, support for mods outside the game #47

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,32 @@ services:

### Building manually

Coming soon! Follow commands in [Dockerfile](https://github.com/lord-server/panorama/blob/master/Dockerfile) in the meantime.
Building panorama manually requires go 1.21 or newer, due to its use
of `log/slog`. Afterwards, build the module with the following
commands:

```
go mod download && go mod verify
go build -v ./cmd/panorama
```

This builds the panorama binary in `./panorama`.

### Configuration

An example config is provided in `config.example.toml`. To work
correctly, panorama needs to know how to connect to the server and how
to render the world. To connect, you need to specify the postgres
connection using the `world_dsn` variable, panorama is not yet capable
of doing this automatically. If you leave `world_dsn` empty, you might
only receive empty tiles! The node descriptions are obtained from the
world directory using the output from the `nodes_dump` mod.

The textures and meshes (only .obj currently supported) are fetched
from the game and mod directories. These are specified using the
`game_path` and `mod_path`directories.



## License

Expand Down
5 changes: 2 additions & 3 deletions cmd/panorama/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ var args Args
func fullrender(config config.Config) error {
descPath := path.Join(config.System.WorldPath, "nodes_dump.json")

slog.Info("loading game description", "game", config.System.GamePath, "desc", descPath)
slog.Info("loading game description", "game", config.System.GamePath, "mods", config.System.ModPath, "desc", descPath)

game, err := game.LoadGame(descPath, config.System.GamePath)
game, err := game.LoadGame(descPath, config.System.GamePath, config.System.ModPath)
if err != nil {
slog.Error("unable to load game description", "error", err)
return err
}

backend, err := world.NewPostgresBackend(config.System.WorldDSN)
if err != nil {
slog.Error("unable to connect to world DB", "error", err)
Expand Down
4 changes: 4 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ game_path = "/var/lib/panorama/game"
# Default: "/var/lib/panorama/world"
world_path = "/var/lib/panorama/world"

# Path to the directory containing the mods
mod_path = "/var/lib/panorama/mods"


# DSN string used for connecting to PostgreSQL
# Default: ""
world_dsn = ""
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Renderer struct {

type System struct {
GamePath string `toml:"game_path"`
ModPath string `toml:"mod_path"`
TilesPath string `toml:"tiles_path"`
WorldPath string `toml:"world_path"`
WorldDSN string `toml:"world_dsn"`
Expand Down
6 changes: 5 additions & 1 deletion internal/game/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func ResolveNode(descriptor NodeDescriptor, mediaCache *MediaCache) NodeDefiniti
return nd
}

func LoadGame(desc string, path string) (Game, error) {
func LoadGame(desc string, path string, modpath string) (Game, error) {
descJSON, err := os.ReadFile(desc)
if err != nil {
return Game{}, err
Expand All @@ -163,6 +163,10 @@ func LoadGame(desc string, path string) (Game, error) {
if err != nil {
return Game{}, err
}
err = mediaCache.fetchMedia(modpath)
if err != nil {
return Game{}, err
}

nodes := make(map[string]NodeDefinition)
for name, gameNode := range descriptor.Nodes {
Expand Down
16 changes: 9 additions & 7 deletions internal/game/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const (
)

var DrawTypeNames = map[string]DrawType{
"node": DrawTypeNormal,
"normal": DrawTypeNormal,
"airlike": DrawTypeAirlike,
"liquid": DrawTypeLiquid,
Expand All @@ -38,13 +39,14 @@ var DrawTypeNames = map[string]DrawType{
"allfaces_optional": DrawTypeAllFaces,
"torchlike": DrawTypeTorchlike,
"signlike": DrawTypeSignlike,
"plantlike": DrawTypePlantlike,
"firelike": DrawTypeFirelike,
"fencelike": DrawTypeFencelike,
"raillike": DrawTypeRaillike,
"nodebox": DrawTypeNodeBox,
"mesh": DrawTypeMesh,
"plantlike_rooted": DrawTypePlantlikeRooted,
// "plantlike": DrawTypePlantlike,
"plantlike": DrawTypeAllFaces,
"firelike": DrawTypeFirelike,
"fencelike": DrawTypeFencelike,
"raillike": DrawTypeRaillike,
"nodebox": DrawTypeNodeBox,
"mesh": DrawTypeMesh,
"plantlike_rooted": DrawTypePlantlikeRooted,
}

func (t DrawType) IsLiquid() bool {
Expand Down
Loading