Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr

:warning: This server code is versioned separately to the download of the [Hiro game framework](https://heroiclabs.com/hiro/). :warning:

## [Unreleased]
### Changed
- The "Init" function takes a database handle, which is passed through to the gameplay systems. Callers must pass the "db" given to "InitModule".

## [1.35.0] - 2026-07-29
### Added
- Streaks have new options "grace_window_sec" and "auto_claim" for configuration.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
)

func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
systems, err := hiro.Init(ctx, logger, nk, initializer, "hiro.bin", "LicenseKey",
systems, err := hiro.Init(ctx, logger, db, nk, initializer, "hiro.bin", "LicenseKey",
hiro.WithEconomySystem("economy.json", true),
hiro.WithEnergySystem("energy.json", true),
hiro.WithInventorySystem("inventory.json", true))
Expand Down
6 changes: 3 additions & 3 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const (
)

// Init initializes a Hiro type with the configurations provided.
func Init(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, initializer runtime.Initializer, binPath string, licenseKey string, configs ...SystemConfig) (Hiro, error) {
func Init(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer, binPath string, licenseKey string, configs ...SystemConfig) (Hiro, error) {
Comment thread
Calm0 marked this conversation as resolved.
// Open the plugin.
binFile, err := nk.ReadFile(binPath)
if err != nil {
Expand All @@ -180,7 +180,7 @@ func Init(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, i
}

// Ensure the function has the correct types.
fn, ok := f.(func(context.Context, runtime.Logger, runtime.NakamaModule, runtime.Initializer, *protojson.MarshalOptions, *protojson.UnmarshalOptions, string, ...SystemConfig) (Hiro, error))
fn, ok := f.(func(context.Context, runtime.Logger, *sql.DB, runtime.NakamaModule, runtime.Initializer, *protojson.MarshalOptions, *protojson.UnmarshalOptions, string, ...SystemConfig) (Hiro, error))
Comment thread
Calm0 marked this conversation as resolved.
if !ok {
return nil, errors.New("error reading hiro-gdk.Init function in Go module")
}
Expand All @@ -192,7 +192,7 @@ func Init(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, i
}
unmarshaler := &protojson.UnmarshalOptions{DiscardUnknown: false}

return fn(ctx, logger, nk, initializer, marshaler, unmarshaler, licenseKey, configs...)
return fn(ctx, logger, db, nk, initializer, marshaler, unmarshaler, licenseKey, configs...)
}

// The SystemConfig describes the configuration that each gameplay system must use to configure itself.
Expand Down
Loading