Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Fixed subscriber for server side run
Browse files Browse the repository at this point in the history
  • Loading branch information
nictuku committed Mar 17, 2016
1 parent 2837e60 commit 6034864
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions parser/parse_tiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"os"
"path"
"strings"
"sync"

"github.com/salviati/go-tmx/tmx"
Expand All @@ -29,6 +30,7 @@ type Map struct {
}

func (m *Map) FetchSource(s string) (image.Image, error) {
s = strings.Replace(s, `\`, "/", -1)
m.mu.Lock()
defer m.mu.Unlock()
img, ok := m.imageSources[s]
Expand Down
4 changes: 2 additions & 2 deletions subscriber/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Log(handler http.Handler) http.Handler {
})
}

func homeDir() string {
func wwwDir() string {
home := os.Getenv("HOME")
if home == "" {
home = string(filepath.Separator)
Expand Down Expand Up @@ -59,7 +59,7 @@ func RunHTTPServer() {
}

func init() {
dir := homeDir()
dir := wwwDir()
log.Printf("Serving files from %v", dir)
http.Handle("/", Log(gziphandler.GzipHandler(http.FileServer(http.Dir(dir)))))
http.Handle("/lastsave", Log(gziphandler.GzipHandler(http.HandlerFunc(LastSave))))
Expand Down
3 changes: 2 additions & 1 deletion subscriber/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"path"

"github.com/nictuku/stardew-rocks/parser"
"github.com/nictuku/stardew-rocks/view"
Expand Down Expand Up @@ -84,7 +85,7 @@ func main() {
log.Printf("blank player name")
break
}
mapFile := fmt.Sprintf("map-%v.png", saveGame.Player.Name)
mapFile := path.Join(wwwDir(), fmt.Sprintf("map-%v.png", saveGame.Player.Name))
f, err := os.OpenFile(mapFile, os.O_CREATE|os.O_WRONLY, 0666)
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 6034864

Please sign in to comment.