aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


server/world_services.go (1616B)


      1 package main
      2 
      3 import (
      4 	"database/sql"
      5 	"maps"
      6 )
      7 
      8 // Shared service handles and immutable content contain no live simulation state.
      9 // The directory uses these dependencies to construct independent zone owners.
     10 type worldServices struct {
     11 	browserVisitors *browserVisitors
     12 
     13 	populations    map[uint32]npcPopulation
     14 	db             *sql.DB
     15 	databaseWriter *databaseWriter
     16 	teamService    *teamDirectory
     17 	chatService    *chatRuntime
     18 	playerLimit    *playerLimit
     19 	identities     *worldIdentities
     20 	passwordHasher *passwordHasher
     21 	combatRoll     func(uint32) uint32
     22 	loginPort      int
     23 	worldPort      int
     24 	httpPort       int
     25 	baseURL        string
     26 	terrain        map[uint32]*terrain
     27 	geometry       *sceneGeometry
     28 	zoneLinks      map[string]map[uint32]zoneLinks
     29 	cityDoors      map[doorOrigin]bool
     30 	worldResources map[uint32]worldResource
     31 }
     32 
     33 func (state *server) services() worldServices {
     34 	state.identityAllocator()
     35 	return state.worldServices
     36 }
     37 
     38 func (services worldServices) newZone(environment worldEnvironment) *server {
     39 	services.cityDoors = maps.Clone(services.cityDoors)
     40 	return &server{
     41 		worldServices: services,
     42 		gameSeconds:   environment.gameSeconds, clockStarted: environment.clockStarted,
     43 		weather: environment.weather, weatherUntil: environment.weatherUntil,
     44 		characters: make(map[uint32]*character), clients: make(map[uint32]*worldClient),
     45 		items: make(map[uint32]itemRecord), itemPlacements: make(map[uint32]itemPlacement),
     46 		worldItems: make(map[uint32]worldItem), depletedResources: make(map[uint32]bool),
     47 		fighting: make(map[uint32]*character), mobileNPCs: make(map[uint32][]*character),
     48 	}
     49 }