Update GaCy-GO

This commit is contained in:
CAtlas0784 committed 2026-10-28 18:54:43 +07:00
1 parent da8a32f60d
commit 0cbe460e49
345 files changed
+98202 -77559

No files matched your search

+57 -1
View File
@@ -4,9 +4,14 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"path/filepath"
"sort"
"strings"
"sync"
"time"
"gac-hkrpg-go"
)
// LogInfo prints a timestamped info line (kept dependency-free).
@@ -162,7 +167,8 @@ type AnchorConfigFile struct {
AnchorConfig []AnchorConfigEntry `json:"anchor_config"`
}
// ReadResourceFile reads a resource file checking current directory and parent directories.
// ReadResourceFile reads editable files from the current directory and its
// parents, then falls back to bundled data in ship builds.
func ReadResourceFile(paths ...string) ([]byte, error) {
for _, p := range paths {
for _, prefix := range []string{"", "..", "../..", "../../.."} {
@@ -172,9 +178,59 @@ func ReadResourceFile(paths ...string) ([]byte, error) {
}
}
}
for _, p := range paths {
name := path.Clean(strings.ReplaceAll(filepath.ToSlash(p), "\\", "/"))
if name == "." || name == ".." || strings.HasPrefix(name, "../") || strings.HasPrefix(name, "/") {
continue
}
if raw, err := runtimeassets.ReadFile(name); err == nil {
return raw, nil
}
}
return nil, os.ErrNotExist
}
type ClientLuaScript struct {
Name string
Data []byte
}
// ClientLuaScripts combines maintained embedded scripts with operator-provided
// scripts. Files on disk override embedded files by name.
func ClientLuaScripts() []ClientLuaScript {
files := make(map[string][]byte)
if entries, err := runtimeassets.ReadDir("scripts"); err == nil {
for _, entry := range entries {
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".lua") {
continue
}
if data, err := runtimeassets.ReadFile(path.Join("scripts", entry.Name())); err == nil {
files[entry.Name()] = data
}
}
}
if entries, err := os.ReadDir("scripts"); err == nil {
for _, entry := range entries {
if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".lua") {
continue
}
if data, err := os.ReadFile(filepath.Join("scripts", entry.Name())); err == nil {
files[entry.Name()] = data
}
}
}
names := make([]string, 0, len(files))
for name := range files {
names = append(names, name)
}
sort.Strings(names)
result := make([]ClientLuaScript, 0, len(names))
for _, name := range names {
result = append(result, ClientLuaScript{Name: name, Data: files[name]})
}
return result
}
func readResourceFile(paths ...string) ([]byte, error) {
return ReadResourceFile(paths...)
}