示例#1
0
    def __init__(self, server):
        super(WorldServer, self).__init__()
        import savingsystem #This module doesn't like being imported at modulescope
        self.savingsystem = savingsystem
        if not os.path.lexists(os.path.join(G.game_dir, "world", "players")):
            os.makedirs(os.path.join(G.game_dir, "world", "players"))

        self.sectors = defaultdict(list)
        self.exposed_cache = dict()

        self.urgent_queue = deque()
        self.lazy_queue = deque()
        self.sector_queue = OrderedDict()
        self.generation_queue = deque()
        self.spreading_mutable_blocks = deque()

        self.server_lock = threading.Lock()
        self.server = server

        if os.path.exists(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed")):
            with open(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed"), "rb") as f:
                G.SEED = f.read()
        else:
            if not os.path.exists(os.path.join(G.game_dir, G.SAVE_FILENAME)): os.makedirs(os.path.join(G.game_dir, G.SAVE_FILENAME))
            with open(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed"), "wb") as f:
                f.write(self.generate_seed())

        self.terraingen = terrain.TerrainGeneratorSimple(self, G.SEED)
示例#2
0
    def __init__(self, server):
        super(WorldServer, self).__init__()
        if not os.path.lexists(os.path.join(G.game_dir, "world", "players")):
            os.makedirs(os.path.join(G.game_dir, "world", "players"))

        self.sectors = defaultdict(list)
        self.exposed_cache = dict()

        self.spreading_mutable_blocks = deque()

        self.server_lock = threading.Lock()
        self.server = server

        if os.path.exists(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed")):
            with open(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed"),
                      "rb") as f:
                G.SEED = int(f.read().decode('utf-8'))
        else:
            if not os.path.exists(os.path.join(G.game_dir, G.SAVE_FILENAME)):
                os.makedirs(os.path.join(G.game_dir, G.SAVE_FILENAME))
            with open(os.path.join(G.game_dir, G.SAVE_FILENAME, "seed"),
                      "wb") as f:
                f.write(str(self.generate_seed()).encode('utf-8'))

        self.terraingen = terrain.TerrainGeneratorSimple(self, G.SEED)