improved file read/copy logic
This commit is contained in:
57
ini.go
57
ini.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"gopkg.in/ini.v1"
|
||||
@@ -9,17 +10,17 @@ import (
|
||||
|
||||
type RoomIni struct {
|
||||
night int
|
||||
room int
|
||||
room int
|
||||
|
||||
size float64
|
||||
speed float64
|
||||
fov float64
|
||||
size float64
|
||||
speed float64
|
||||
fov float64
|
||||
textureRepeat float64
|
||||
roomHeight float64
|
||||
layerFrames int
|
||||
fogColor int
|
||||
fogEnd float64
|
||||
miniSpeed float64
|
||||
roomHeight float64
|
||||
layerFrames int
|
||||
fogColor int
|
||||
fogEnd float64
|
||||
miniSpeed float64
|
||||
}
|
||||
|
||||
func (r *RoomIni) ToIni() string {
|
||||
@@ -39,29 +40,29 @@ Fog_Color=%d
|
||||
Fog_End=%s
|
||||
Mini_speed=%s
|
||||
`,
|
||||
r.night, r.room,
|
||||
f(r.size), f(r.speed),
|
||||
f(r.fov), f(r.textureRepeat),
|
||||
f(r.roomHeight), r.layerFrames,
|
||||
r.fogColor, f(r.fogEnd),
|
||||
f(r.miniSpeed),
|
||||
)
|
||||
r.night, r.room,
|
||||
f(r.size), f(r.speed),
|
||||
f(r.fov), f(r.textureRepeat),
|
||||
f(r.roomHeight), r.layerFrames,
|
||||
r.fogColor, f(r.fogEnd),
|
||||
f(r.miniSpeed),
|
||||
)
|
||||
}
|
||||
|
||||
func NewRoomIni() RoomIni {
|
||||
return RoomIni {
|
||||
return RoomIni{
|
||||
night: -1,
|
||||
room: -1,
|
||||
room: -1,
|
||||
|
||||
size: 1,
|
||||
speed: 1,
|
||||
fov: 55,
|
||||
size: 1,
|
||||
speed: 1,
|
||||
fov: 55,
|
||||
textureRepeat: 3,
|
||||
roomHeight: 350,
|
||||
layerFrames: 1,
|
||||
fogColor: 0,
|
||||
fogEnd: -1,
|
||||
miniSpeed: 1,
|
||||
roomHeight: 350,
|
||||
layerFrames: 1,
|
||||
fogColor: 0,
|
||||
fogEnd: -1,
|
||||
miniSpeed: 1,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +72,6 @@ func ReadIni(path string) (RoomIni, error) {
|
||||
return RoomIni{}, err
|
||||
}
|
||||
|
||||
|
||||
meta, err := cfg.GetSection("DEFAULT")
|
||||
if err != nil {
|
||||
return RoomIni{}, fmt.Errorf("unable to load DEFAULT section in %s: %+v", path, err)
|
||||
@@ -82,7 +82,7 @@ func ReadIni(path string) (RoomIni, error) {
|
||||
|
||||
for _, sec := range sections {
|
||||
if room != nil {
|
||||
fmt.Printf("WARN: extra section in %s, section: %s\n", path, sec.Name())
|
||||
log.Printf("WARN: extra section in %s, section: %s", path, sec.Name())
|
||||
continue
|
||||
}
|
||||
if sec.Name() != "default" {
|
||||
@@ -117,7 +117,6 @@ func loadIni(meta *ini.Section, room *ini.Section) (RoomIni, error) {
|
||||
return RoomIni{}, fmt.Errorf("night is set but room is not set")
|
||||
}
|
||||
|
||||
|
||||
if val, err := loatFloat(room, "size", 1); err != nil {
|
||||
return RoomIni{}, err
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user