mirror of
https://github.com/Mezeporta/Erupe.git
synced 2025-12-13 07:25:03 +01:00
@@ -13,6 +13,7 @@
|
|||||||
"DeleteOnSaveCorruption": false,
|
"DeleteOnSaveCorruption": false,
|
||||||
"ClientMode": "ZZ",
|
"ClientMode": "ZZ",
|
||||||
"QuestCacheExpiry": 300,
|
"QuestCacheExpiry": 300,
|
||||||
|
"ProxyPort": 0,
|
||||||
"DevMode": true,
|
"DevMode": true,
|
||||||
"DevModeOptions": {
|
"DevModeOptions": {
|
||||||
"AutoCreateAccount": true,
|
"AutoCreateAccount": true,
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ type Config struct {
|
|||||||
DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion
|
DeleteOnSaveCorruption bool // Attempts to save corrupted data will flag the save for deletion
|
||||||
ClientMode string
|
ClientMode string
|
||||||
RealClientMode Mode
|
RealClientMode Mode
|
||||||
QuestCacheExpiry int // Number of seconds to keep quest data cached
|
QuestCacheExpiry int // Number of seconds to keep quest data cached
|
||||||
|
ProxyPort uint16 // Forces the game to connect to a channel server proxy
|
||||||
DevMode bool
|
DevMode bool
|
||||||
|
|
||||||
DevModeOptions DevModeOptions
|
DevModeOptions DevModeOptions
|
||||||
|
|||||||
12
main.go
12
main.go
@@ -22,11 +22,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Temporary DB auto clean on startup for quick development & testing.
|
// Temporary DB auto clean on startup for quick development & testing.
|
||||||
func cleanDB(db *sqlx.DB) {
|
func cleanDB(db *sqlx.DB, config *_config.Config) {
|
||||||
_ = db.MustExec("DELETE FROM guild_characters")
|
_ = db.MustExec("DELETE FROM guild_characters")
|
||||||
_ = db.MustExec("DELETE FROM guilds")
|
_ = db.MustExec("DELETE FROM guilds")
|
||||||
_ = db.MustExec("DELETE FROM characters")
|
_ = db.MustExec("DELETE FROM characters")
|
||||||
_ = db.MustExec("DELETE FROM sign_sessions")
|
if config.ProxyPort == 0 {
|
||||||
|
_ = db.MustExec("DELETE FROM sign_sessions")
|
||||||
|
}
|
||||||
_ = db.MustExec("DELETE FROM users")
|
_ = db.MustExec("DELETE FROM users")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,14 +126,16 @@ func main() {
|
|||||||
logger.Info("Database: Started successfully")
|
logger.Info("Database: Started successfully")
|
||||||
|
|
||||||
// Clear stale data
|
// Clear stale data
|
||||||
_ = db.MustExec("DELETE FROM sign_sessions")
|
if config.ProxyPort == 0 {
|
||||||
|
_ = db.MustExec("DELETE FROM sign_sessions")
|
||||||
|
}
|
||||||
_ = db.MustExec("DELETE FROM servers")
|
_ = db.MustExec("DELETE FROM servers")
|
||||||
_ = db.MustExec(`UPDATE guild_characters SET treasure_hunt=NULL`)
|
_ = db.MustExec(`UPDATE guild_characters SET treasure_hunt=NULL`)
|
||||||
|
|
||||||
// Clean the DB if the option is on.
|
// Clean the DB if the option is on.
|
||||||
if config.DevMode && config.DevModeOptions.CleanDB {
|
if config.DevMode && config.DevModeOptions.CleanDB {
|
||||||
logger.Info("Database: Started clearing...")
|
logger.Info("Database: Started clearing...")
|
||||||
cleanDB(db)
|
cleanDB(db, config)
|
||||||
logger.Info("Database: Finished clearing")
|
logger.Info("Database: Finished clearing")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,11 @@ func encodeServerInfo(config *_config.Config, s *Server, local bool) []byte {
|
|||||||
|
|
||||||
for channelIdx, ci := range si.Channels {
|
for channelIdx, ci := range si.Channels {
|
||||||
sid = (4096 + serverIdx*256) + (16 + channelIdx)
|
sid = (4096 + serverIdx*256) + (16 + channelIdx)
|
||||||
bf.WriteUint16(ci.Port)
|
if _config.ErupeConfig.DevMode && _config.ErupeConfig.ProxyPort != 0 {
|
||||||
|
bf.WriteUint16(_config.ErupeConfig.ProxyPort)
|
||||||
|
} else {
|
||||||
|
bf.WriteUint16(ci.Port)
|
||||||
|
}
|
||||||
bf.WriteUint16(16 + uint16(channelIdx))
|
bf.WriteUint16(16 + uint16(channelIdx))
|
||||||
bf.WriteUint16(ci.MaxPlayers)
|
bf.WriteUint16(ci.MaxPlayers)
|
||||||
var currentPlayers uint16
|
var currentPlayers uint16
|
||||||
|
|||||||
Reference in New Issue
Block a user