def prepare_multiplayer(game, trader_enabled=True, pirate_enabled=True, natural_resource_multiplier=1): """Starts a multiplayer game server TODO: actual game data parameter passing """ global gui, session, preloader gui.show_loading_screen() preloader.wait_for_finish() # remove cursor while loading horizons.globals.fife.cursor.set(fife_module.CURSOR_NONE) horizons.globals.fife.engine.pump() horizons.globals.fife.set_cursor_image('default') # destruct old session (right now, without waiting for gc) if session is not None and session.is_alive: session.end() # start new session from horizons.mpsession import MPSession # get random seed for game uuid = game.uuid random = sum([int(uuid[i : i + 2], 16) for i in range(0, len(uuid), 2)]) session = MPSession(horizons.globals.db, NetworkInterface(), rng_seed=random) # NOTE: this data passing is only temporary, maybe use a player class/struct if game.is_savegame: map_file = SavegameManager.get_multiplayersave_map(game.map_name) else: map_file = SavegameManager.get_map(game.map_name) options = StartGameOptions.create_start_multiplayer(map_file, game.get_player_list(), not game.is_savegame) session.load(options)
def prepare_multiplayer(game, trader_enabled=True, pirate_enabled=True, natural_resource_multiplier=1): """Starts a multiplayer game server TODO: actual game data parameter passing """ global gui, session, preloader gui.show_loading_screen() preloader.wait_for_finish() # remove cursor while loading horizons.globals.fife.cursor.set(fife_module.CURSOR_NONE) horizons.globals.fife.engine.pump() horizons.globals.fife.set_cursor_image('default') # destruct old session (right now, without waiting for gc) if session is not None and session.is_alive: session.end() # start new session from horizons.mpsession import MPSession # get random seed for game uuid = game.uuid random = sum([int(uuid[i: i + 2], 16) for i in range(0, len(uuid), 2)]) session = MPSession(horizons.globals.db, NetworkInterface(), rng_seed=random) # NOTE: this data passing is only temporary, maybe use a player class/struct if game.is_savegame: map_file = SavegameManager.get_multiplayersave_map(game.map_name) else: map_file = SavegameManager.get_map(game.map_name) options = StartGameOptions.create_start_multiplayer(map_file, game.get_player_list(), not game.is_savegame) session.load(options)