Most visitors online was 1443 , on 24 May 2023
Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!
Join Today!hello. how do i get a key i tried 256 and dont know what to put in output..
Client downloaded in mediafire it's crashing when I to select the character to play.
Hello there,
Can you shoot a video for installation. Thanks for your help.
is there a tutorial on how to put online? never saw the game wanted to learn how I leave online for testing
package config
import (
"log"
"os"
"strconv"
)
var Default = &config{
Database: Database{
Driver: "postgres",
IP: os.Getenv("POSTGRES_HOST"),
Port: getPort(),
User: os.Getenv("POSTGRES_USER")
Password: os.Getenv("POSTGRES_PASSWORD"),
Name: os.Getenv("POSTGRES_DB"),
ConnMaxIdle: 96,
ConnMaxOpen: 144,
ConnMaxLifetime: 10,
Debug: false,
SSLMode: "disable",
},
Server: Server{
IP: "192.168.15.10", //os.Getenv("SERVER_IP),
Port: 4510,
},
}
func getPort() int {
sPort := 4510 ("POSTGRES_PORT")
port, err := strconv.ParseInt(sPort, 10, 32)
if err != nil {
log.Fatalln(err)
}
return int(port)
}
package main
import (
"fmt"
"log"
"net"
"os"
"sort"
"strconv"
"time"
"github.com/robfig/cron"
"github.com/syntaxgame/dragon-legend/ai"
_ "github.com/syntaxgame/dragon-legend/ai"
"github.com/syntaxgame/dragon-legend/api"
"github.com/syntaxgame/dragon-legend/config"
"github.com/syntaxgame/dragon-legend/database"
_ "github.com/syntaxgame/dragon-legend/factory"
"github.com/syntaxgame/dragon-legend/logging"
"github.com/syntaxgame/dragon-legend/nats"
"github.com/syntaxgame/dragon-legend/redis"
"github.com/thoas/go-funk"
)
var (
logger = logging.Logger
)
func initDatabase() {
for {
err := database.InitDB()
if err == nil {
log.Printf("Connected to database...")
return
}
log.Printf("Database connection error: %+v, waiting 30 sec...", err)
time.Sleep(time.Duration(30) * time.Second)
}
}
func initRedis() {
for {
err := redis.InitRedis()
if err != nil {
log.Printf("Redis connection error: %+v, waiting 30 sec...", err)
time.Sleep(time.Duration(30) * time.Second)
continue
}
if redisHost := os.Getenv("REDIS_HOST"); redisHost != "" {
log.Printf("Connected to redis...")
go logger.StartLogging()
}
return
}
}
func startServer() {
cfg := config.Default
port := cfg.Server.Port
listen, err := net.Listen("tcp4", ":"+strconv.Itoa(port))
defer listen.Close()
if err != nil {
log.Fatalf("Socket listen port %d failed,%s", port, err)
os.Exit(1)
}
log.Printf("Begin listen port: %d", port)
//connections = make(map[string]net.Conn)
//remoteAddrs = make(map[string]int)
for {
conn, err := listen.Accept()
if err != nil {
log.Fatalln(err)
continue
}
ws := database.Socket{Conn: conn}
//ws.SetPingDuration(time.Second * 2)
//ws.SetPingHandler(nil)
go ws.Read()
}
}
func cronHandler() {
c := cron.New()
c.AddFunc("0 0 0 * * *", func() {
database.RefreshAIDs()
})
c.Start()
}
func main() {
initRedis()
initDatabase()
cronHandler()
ai.Init()
go database.UnbanUsers()
s := nats.RunServer(nil)
defer s.Shutdown()
c, err := nats.ConnectSelf(nil)
defer c.Close()
if err != nil {
log.Fatalln(err)
}
go api.InitGRPC()
startServer()
}
func resolveOverlappingItems() { //67-306
ids := []string{}
for _, userid := range ids {
fmt.Println("user id:", userid)
bankSlots, _ := database.FindBankSlotsByUserID(userid)
freeSlots := make(map[int16]struct{})
for _, s := range bankSlots {
freeSlots[s.SlotID] = struct{}{}
}
findSlot := func() int16 {
for i := int16(67); i <= 306; i++ {
if _, ok := freeSlots; !ok {
return i
}
}
return -1
}
for i := 0; i < len(bankSlots)-1; i++ {
for j := i; true; j++ {
if len(bankSlots) == j+1 || bankSlots.SlotID != bankSlots[j+1].SlotID {
break
}
free := findSlot()
if free == -1 {
continue
}
fmt.Printf("%d => %d\n", bankSlots[j+1].SlotID, free)
freeSlots[free] = struct{}{}
bankSlots[j+1].SlotID = free
bankSlots[j+1].Update()
}
}
}
}
func createServerMobs(server int) {
aiSet := funk.Filter(funk.Values(database.AIs), func(ai *database.AI) bool {
return ai.Server == 1
}).([]*database.AI)
sort.Slice(aiSet, func(i, j int) bool {
return aiSet.ID < aiSet[j].ID
})
for _, ai := range aiSet {
newAI := *ai
newAI.ID = 0
newAI.Server = server
err := newAI.Create()
if err != nil {
log.Print(err)
}
}
}