This commit is contained in:
NatureFreshMilk 2019-01-25 13:14:49 +01:00
parent bd2f794af8
commit a36a881129
2 changed files with 13 additions and 12 deletions

View File

@ -24,15 +24,16 @@ func Setup(p params.ParamsType, cfg *Config) (*App, error) {
a.Worldconfig = worldconfig.Parse("world.mt")
logrus.WithFields(logrus.Fields{"version": Version}).Info("Starting mapserver")
if a.Worldconfig.Backend != worldconfig.BACKEND_SQLITE3 {
return nil, errors.New("no supported backend found!")
}
//create db accessor
var err error
a.Blockdb, err = db.NewSqliteAccessor("map.sqlite")
if err != nil {
return nil, err
switch a.Worldconfig.Backend {
case worldconfig.BACKEND_SQLITE3:
a.Blockdb, err = db.NewSqliteAccessor("map.sqlite")
if err != nil {
return nil, err
}
default:
return nil, errors.New("map-backend not supported: " + a.Worldconfig.Backend)
}
//migrate block db

View File

@ -33,11 +33,11 @@ type WorldConfig struct {
Backend string
PlayerBackend string
PsqlConnection PsqlConfig
PsqlPlayerConnection PsqlConfig
PsqlConnection *PsqlConfig
PsqlPlayerConnection *PsqlConfig
}
func parseConnectionString(str string) PsqlConfig {
func parseConnectionString(str string) *PsqlConfig {
cfg := PsqlConfig{}
pairs := strings.Split(str, " ")
@ -58,7 +58,7 @@ func parseConnectionString(str string) PsqlConfig {
}
}
return cfg
return &cfg
}
func Parse(filename string) WorldConfig {