This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
core-old/internal/tw/server_config.go
Dawid Wysokiński 95641c8513
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
fix: strconv.ParseInt: parsing "On": invalid syntax - ServerConfigGame
2022-12-25 11:48:33 +01:00

187 lines
6.0 KiB
Go

package tw
import (
"encoding/xml"
"fmt"
"strings"
)
type ServerConfigBuild struct {
Destroy int8 `xml:"destroy"`
}
type ServerConfigMisc struct {
KillRanking int8 `xml:"kill_ranking"`
Tutorial int8 `xml:"tutorial"`
TradeCancelTime int16 `xml:"trade_cancel_time"`
}
type ServerConfigCommands struct {
MillisArrival int16 `xml:"millis_arrival"`
CommandCancelTime int16 `xml:"command_cancel_time"`
}
type ServerConfigNewbie struct {
Days int16 `xml:"days"`
RatioDays int16 `xml:"ratio_days"`
Ratio int16 `xml:"ratio"`
RemoveNewbieVillages int8 `xml:"removeNewbieVillages"`
}
type KnightNewItems int8
func (k KnightNewItems) Int8() int8 {
return int8(k)
}
func (k *KnightNewItems) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
if err := d.DecodeElement(&s, &start); err != nil {
return err
}
switch strings.ToUpper(s) {
case "ON", "1":
*k = 1
case "OFF", "0", "":
*k = 0
default:
return fmt.Errorf(`KnightNewItems: parsing "%s": invalid syntax`, s)
}
return nil
}
type ServerConfigGame struct {
BuildtimeFormula int8 `xml:"buildtime_formula"`
Knight int8 `xml:"knight"`
KnightNewItems KnightNewItems `xml:"knight_new_items"`
Archer int8 `xml:"archer"`
Tech int8 `xml:"tech"`
FarmLimit int32 `xml:"farm_limit"`
Church int8 `xml:"church"`
Watchtower int8 `xml:"watchtower"`
Stronghold int8 `xml:"stronghold"`
FakeLimit float64 `xml:"fake_limit"`
BarbarianRise float64 `xml:"barbarian_rise"`
BarbarianShrink int8 `xml:"barbarian_shrink"`
BarbarianMaxPoints int32 `xml:"barbarian_max_points"`
Scavenging int8 `xml:"scavenging"`
Hauls int8 `xml:"hauls"`
HaulsBase int32 `xml:"hauls_base"`
HaulsMax int32 `xml:"hauls_max"`
BaseProduction int32 `xml:"base_production"`
Event int16 `xml:"event"`
SuppressEvents int8 `xml:"suppress_events"`
}
type ServerConfigBuildings struct {
CustomMain int8 `xml:"custom_main"`
CustomFarm int8 `xml:"custom_farm"`
CustomStorage int8 `xml:"custom_storage"`
CustomPlace int8 `xml:"custom_place"`
CustomBarracks int8 `xml:"custom_barracks"`
CustomChurch int8 `xml:"custom_church"`
CustomSmith int8 `xml:"custom_smith"`
CustomWood int8 `xml:"custom_wood"`
CustomStone int8 `xml:"custom_stone"`
CustomIron int8 `xml:"custom_iron"`
CustomMarket int8 `xml:"custom_market"`
CustomStable int8 `xml:"custom_stable"`
CustomWall int8 `xml:"custom_wall"`
CustomGarage int8 `xml:"custom_garage"`
CustomHide int8 `xml:"custom_hide"`
CustomSnob int8 `xml:"custom_snob"`
CustomStatue int8 `xml:"custom_statue"`
CustomWatchtower int8 `xml:"custom_watchtower"`
}
type ServerConfigSnob struct {
Gold int8 `xml:"gold"`
CheapRebuild int8 `xml:"cheap_rebuild"`
Rise int8 `xml:"rise"`
MaxDist int16 `xml:"max_dist"`
Factor float64 `xml:"factor"`
CoinWood int32 `xml:"coin_wood"`
CoinStone int32 `xml:"coin_stone"`
CoinIron int32 `xml:"coin_iron"`
NoBarbConquer int8 `xml:"no_barb_conquer"`
}
type ServerConfigAlly struct {
NoHarm int8 `xml:"no_harm"`
NoOtherSupport int8 `xml:"no_other_support"`
NoOtherSupportType int8 `xml:"no_other_support_type"`
AllytimeSupport int32 `xml:"allytime_support"`
NoLeave int8 `xml:"no_leave"`
NoJoin int8 `xml:"no_join"`
Limit int16 `xml:"limit"`
FixedAllies int8 `xml:"fixed_allies"`
PointsMemberCount int32 `xml:"points_member_count"`
WarsMemberRequirement int16 `xml:"wars_member_requirement"`
WarsPointsRequirement int32 `xml:"wars_points_requirement"`
WarsAutoacceptDays int16 `xml:"wars_autoaccept_days"`
Levels int8 `xml:"levels"`
XpRequirements string `xml:"xp_requirements"`
}
type ServerConfigCoord struct {
MapSize int16 `xml:"map_size"`
Func int8 `xml:"func"`
EmptyVillages int16 `xml:"empty_villages"`
BonusVillages int16 `xml:"bonus_villages"`
BonusNew int16 `xml:"bonus_new"`
Inner int16 `xml:"inner"`
SelectStart int8 `xml:"select_start"`
VillageMoveWait int32 `xml:"village_move_wait"`
NobleRestart int8 `xml:"noble_restart"`
StartVillages int8 `xml:"start_villages"`
}
type ServerConfigSitter struct {
Allow int8 `xml:"allow"`
}
type ServerConfigSleep struct {
Active int8 `xml:"active"`
Delay int32 `xml:"delay"`
Min int16 `xml:"min"`
Max int16 `xml:"max"`
MinAwake int16 `xml:"min_awake"`
MaxAwake int16 `xml:"max_awake"`
WarnTime int16 `xml:"warn_time"`
}
type ServerConfigNight struct {
Active int8 `xml:"active"`
StartHour int8 `xml:"start_hour"`
EndHour int8 `xml:"end_hour"`
DefFactor float64 `xml:"def_factor"`
Duration int8 `xml:"duration"`
}
type ServerConfigWin struct {
Check int16 `xml:"check"`
}
type ServerConfig struct {
XMLName xml.Name `xml:"config"`
Speed float64 `xml:"speed"`
UnitSpeed float64 `xml:"unit_speed"`
Moral int16 `xml:"moral"`
Build ServerConfigBuild `xml:"build"`
Misc ServerConfigMisc `xml:"misc"`
Commands ServerConfigCommands `xml:"commands"`
Newbie ServerConfigNewbie `xml:"newbie"`
Game ServerConfigGame `xml:"game"`
Buildings ServerConfigBuildings `xml:"buildings"`
Snob ServerConfigSnob `xml:"snob"`
Ally ServerConfigAlly `xml:"ally"`
Coord ServerConfigCoord `xml:"coord"`
Sitter ServerConfigSitter `xml:"sitter"`
Sleep ServerConfigSleep `xml:"sleep"`
Night ServerConfigNight `xml:"night"`
Win ServerConfigWin `xml:"win"`
}