add tacking

This commit is contained in:
Fran Jurmanović
2025-05-24 00:44:26 +02:00
parent 31a2b73cf9
commit edf5a2c8c4
11 changed files with 210 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ import (
type IntString int
// Config tracks configuration modifications
type Config struct {
type Config struct {
ID uint `json:"id" gorm:"primaryKey"`
ServerID uint `json:"serverId" gorm:"not null"`
ConfigFile string `json:"configFile" gorm:"not null"` // e.g. "settings.json"
@@ -128,4 +128,12 @@ func (i *IntString) UnmarshalJSON(b []byte) error {
}
return fmt.Errorf("invalid postQualySeconds value")
}
func (i IntString) ToString() string {
return strconv.Itoa(int(i))
}
func (i IntString) ToInt() (int) {
return int(i)
}

View File

@@ -14,6 +14,7 @@ type Server struct {
Port int `gorm:"not null" json:"-"`
ConfigPath string `gorm:"not null" json:"-"` // e.g. "/acc/servers/server1/"
ServiceName string `gorm:"not null" json:"-"` // Windows service name
State ServerState `gorm:"-" json:"state"`
}
type PlayerState struct {
@@ -30,10 +31,26 @@ type PlayerState struct {
IsConnected bool
}
type AccServerInstance struct {
Model *Server
State *ServerState
}
type State struct {
Session string `json:"session"`
SessionStart time.Time `json:"sessionStart"`
PlayerCount int `json:"playerCount"`
// Players map[int]*PlayerState
// etc.
}
type ServerState struct {
sync.RWMutex
Session string
PlayerCount int
Players map[int]*PlayerState
Session string `json:"session"`
SessionStart time.Time `json:"sessionStart"`
PlayerCount int `json:"playerCount"`
Track string `json:"track"`
MaxConnections int `json:"maxConnections"`
// Players map[int]*PlayerState
// etc.
}