// create four children that fully divide this quad into four quads of equal area private void subdivide() { int x = this.boundary.southWest.x; int y = this.boundary.southWest.y; int halfDimension = this.boundary.dimension / 2; BoundarySouthWest northWestNodeField = new BoundarySouthWest(x, y + halfDimension); Bounding northWestBounding = new Bounding(northWestNodeField, halfDimension); this.northWest = new NodeQuadTree(northWestBounding); BoundarySouthWest northEastNodeField = new BoundarySouthWest(x + halfDimension, y + halfDimension); Bounding northEastBounding = new Bounding(northEastNodeField, halfDimension); this.northEast = new NodeQuadTree(northEastBounding); BoundarySouthWest southWestNodeField = new BoundarySouthWest(x, y); Bounding southWestBounding = new Bounding(southWestNodeField, halfDimension); this.southWest = new NodeQuadTree(southWestBounding); BoundarySouthWest southEastNodeField = new BoundarySouthWest(x + halfDimension, y); Bounding southEastBounding = new Bounding(southEastNodeField, halfDimension); this.southEast = new NodeQuadTree(southEastBounding); }
//public SpaceGame.Game Socket; private Core(bool loadData = true, DataConnector connector = null) { if (connector == null) { dataConnection = new SpacegameServer.DataConnectors.SqlConnector(); } else { dataConnection = connector; } writeToLog("Starting"); InfluenceManager.InitInfluenceRings(); identities.shipLock = new IdentityNumbers(); identities.templateLock = new IdentityNumbers(); identities.colonyId = new IdentityNumbers(); identities.colonyBuildingId = new IdentityNumbers(); identities.planetSurfaceId = new IdentityNumbers(); identities.allianceId = new IdentityNumbers(); identities.commNode = new IdentityNumbers(); identities.commNodeMessage = new IdentityNumbers(); identities.message = new IdentityNumbers(); identities.combat = new IdentityNumbers(); identities.galacticEvents = new IdentityNumbers(); identities.trades = new IdentityNumbers(); identities.routes = new IdentityNumbers(); identities.chat = new IdentityNumbers(); //fill the regions array with (yet empty) regions //ToDo: this leads to a maximum siz of the world. Units should not leave the area... GeometryIndex.createIndex(); //RULES //int ObjectDescriptionsSize = 20000; int GoodsSize = 10000; int BuildingsSize = 10000; int ModuleSize = 5000; int SurfaceImagesSize = 50; //TODO int ShipHullsSize = 230; //int ShipHullsImagesSize = 100; int QuestSize = 1000; int ResearchsSize = 10000; //int SpecializationGroupSize = 10; int ResearchQuestPrerequisitesSize = 500; int SurfaceTilesSize = 30; int languageSize = 8; //MAP //int StarMapSize = 100000; //int SolarSystemInstanceSize = 1000000; //int PlanetSurfaceSize = 1000000; //USERS //int UserSize = 1000; //int ShipTemplateSize = UserSize * 1000; //int ShipSize = UserSize * 100; //int ColonySize = UserSize * 10; //int ColonyBuildingSize = ColonySize * 100; NodeQuadTree.BoundarySouthWest boundarySouthWest = new NodeQuadTree.BoundarySouthWest(4096, 4096); NodeQuadTree.Bounding NodeQuadTreeBounding = new NodeQuadTree.Bounding(boundarySouthWest, 2048); nodeQuadTree = new NodeQuadTree.NodeQuadTree(NodeQuadTreeBounding); //RULES ObjectDescriptions = new Dictionary <int, ObjectDescription>(); //[ObjectDescriptionsSize]; ObjectsOnMap = new Dictionary <short, ObjectOnMap>(); ObjectWeaponModificators = new Dictionary <short, Dictionary <short, ObjectWeaponModificator> >(); Goods = new Good[GoodsSize]; Buildings = new Building[BuildingsSize]; PlanetTypes = new List <PlanetType>(10); Modules = new Module[ModuleSize]; ShipHulls = new ShipHull[ShipHullsSize]; ShipHullsImages = new List <ShipHullsImage>(); Quests = new Quest[QuestSize]; Researchs = new Research[ResearchsSize]; ResearchGains = new List <ResearchGain>(); SpecializationGroups = new List <SpecializationGroup>(); ResearchQuestPrerequisites = new List <ResearchQuestPrerequisite>(ResearchQuestPrerequisitesSize); SurfaceImages = new SurfaceImage[SurfaceImagesSize]; SurfaceTiles = new SurfaceTile[SurfaceTilesSize]; BuildOptions = new List <BuildOption>(); objectRelations = new List <ResearchQuestPrerequisite>(1000); surfaceDefaultMaps = new List <SurfaceDefaultMap>(3000); TurnEvaluations = new List <TurnEvaluation>(1000); languages = new Language[languageSize]; //SurfaceImages = new SurfaceImages //MAP stars = new Dictionary <int, SystemMap>(); // StarMap[StarMapSize]; planets = new Dictionary <int, SolarSystemInstance>(); //[SolarSystemInstanceSize]; planetSurface = new Dictionary <long, PlanetSurface>(); // [PlanetSurfaceSize]; //USERS users = new ConcurrentDictionary <int, User>(); // [UserSize]; shipTemplate = new ConcurrentDictionary <int, ShipTemplate>(); // ShipTemplate[ShipTemplateSize]; ships = new ConcurrentDictionary <int, Ship>(); //Ship[ShipSize]; colonies = new ConcurrentDictionary <int, Colony>(); //Colony[ColonySize]; colonyBuildings = new ConcurrentDictionary <int, ColonyBuilding>(); //ColonyBuilding[ColonyBuildingSize]; alliances = new ConcurrentDictionary <int, Alliance>(); invitesPerAlliance = new ConcurrentDictionary <int, List <int> >(); invitesPerUser = new ConcurrentDictionary <int, List <int> >(); tradeOffer = new ConcurrentDictionary <int, TradeOffer>(); routes = new ConcurrentDictionary <int, Route>(); chatLog = new ConcurrentDictionary <int, ChatLog>(); userRelations = new UserRelations(); labels = new List <Label>(); shipRefits = new List <shipRefit>(); commNodes = new ConcurrentDictionary <int, CommunicationNode>(); messages = new ConcurrentDictionary <int, MessageHead>(); combats = new ConcurrentDictionary <int, Combat>(); galactivEvents = new ConcurrentDictionary <int, GalacticEvents>(); //read all data if (loadData) { dataConnection.loadData(this); } /* * (new TurnSummary(this)).researchSpread(this); //Todo - remove, save to db after turn summary, restore from db when getAll(_core); is called * (new TurnSummary(this)).CalcGalaxyOwnership(); * * * //update data in all ships * foreach (var ship in this.ships.Values) * { * var clone = ship.clone(); * SpacegameServer.Core.StatisticsCalculator.calc(clone, this); * ship.CombatMaxHitpoint = clone.hitpoints; * ship.CombatStartHitpoint = ship.hitpoints; * } * * * //TODO * if (identities.shipLock.id == -1) identities.shipLock.id = 1000; //ToDo: F***ing ugly stupid and not even really functioning workaround, :ToDo : 1000 is a really bad workaround, because ships and colonies will sometimes (for example during trading) be stored in the same array as spaceobjects... * * * createTurnTimer(); */ }