Exemplo n.º 1
0
def main(options):
    G.GAME_MODE = options.game_mode
    G.SAVE_FILENAME = options.save
    G.DISABLE_SAVE = options.disable_save_all
    G.PENDING_NOTIFICATIONS += ("Starting " + G.APP_NAME, )
    G.update_notifications()

    for name, val in options._get_kwargs():
        setattr(G.LAUNCH_OPTIONS, name, val)

    if options.fast:
        G.TIME_RATE //= 20

    if G.LANGUAGE != 'default':
        reload(sys)
        sys.setdefaultencoding('utf8')
        gettext.install(True, localedir=None)
        gettext.find(G.APP_NAME.lower(), 'locale')
        gettext.textdomain(G.APP_NAME.lower())
        gettext.bind_textdomain_codeset(G.APP_NAME.lower(), 'utf8')
        language = gettext.translation(G.APP_NAME.lower(),
                                       'locale',
                                       languages=[G.LANGUAGE],
                                       fallback=True)
        G._ = lambda s: language.ugettext(s)

    load_modules()

    if G.MULTISAMPLING:
        try:
            window_config = Config(
                sample_buffers=1, samples=4, depth_size=8, double_buffer=True
            )  # TODO Break anti-aliasing/multisampling into an explicit menu option
            window = Window(resizable=True, config=window_config)
            pyglet.app.run()
        except pyglet.window.NoSuchConfigException as e:
            print("Multisampling could not be initialized.", e)
            window = Window(resizable=True, vsync=False)
            pyglet.app.run()
    else:
        window = Window(resizable=True, vsync=False)
        pyglet.app.run()

    if G.CLIENT:
        G.CLIENT.stop()

    if G.SERVER:
        G.main_timer.stop()
        G.SERVER._stop.set()
        G.SERVER.shutdown()
Exemplo n.º 2
0
def main(options):
    G.GAME_MODE = options.game_mode
    G.SAVE_FILENAME = options.save
    G.DISABLE_SAVE = options.disable_save
    for name, val in options._get_kwargs():
        setattr(G.LAUNCH_OPTIONS, name, val)

    if options.fast:
        G.TIME_RATE //= 20

    if G.LANGUAGE != 'default':
        reload(sys)
        sys.setdefaultencoding('utf8')
        gettext.install(True, localedir=None, str=1)
        gettext.find(G.APP_NAME.lower(), 'locale')
        gettext.textdomain(G.APP_NAME.lower())
        gettext.bind_textdomain_codeset(G.APP_NAME.lower(), 'utf8')
        language = gettext.translation(G.APP_NAME.lower(),
                                       'locale',
                                       languages=[G.LANGUAGE],
                                       fallback=True)
        G._ = lambda s: language.ugettext(s)

    load_modules()

    # try:
    # window_config = Config(sample_buffers=1, samples=4) #, depth_size=8)  #, double_buffer=True) #TODO Break anti-aliasing/multisampling into an explicit menu option
    # window = Window(resizable=True, config=window_config)
    # except pyglet.window.NoSuchConfigException:
    window = Window(resizable=True, vsync=False)
    pyglet.app.run()

    if G.CLIENT:
        G.CLIENT.stop()

    if G.SERVER:
        print('Saving...')
        save_world(G.SERVER, "world")
        print('Shutting down internal server...')
        G.main_timer.stop()
        G.SERVER._stop.set()
        G.SERVER.shutdown()
Exemplo n.º 3
0
def main(options):
    G.GAME_MODE = options.game_mode
    G.SAVE_FILENAME = options.save
    G.DISABLE_SAVE = options.disable_save
    for name, val in options._get_kwargs():
        setattr(G.LAUNCH_OPTIONS, name, val)

    if options.fast:
        G.TIME_RATE //= 20

    if G.LANGUAGE != 'default':
        reload(sys)
        sys.setdefaultencoding('utf8')
        gettext.install(True, localedir=None, str=1)
        gettext.find(G.APP_NAME.lower(), 'locale')
        gettext.textdomain(G.APP_NAME.lower())
        gettext.bind_textdomain_codeset(G.APP_NAME.lower(), 'utf8')
        language = gettext.translation(G.APP_NAME.lower(), 'locale', languages=[G.LANGUAGE], fallback=True)
        G._ = lambda s: language.ugettext(s)

    load_modules()

    # try:
        # window_config = Config(sample_buffers=1, samples=4) #, depth_size=8)  #, double_buffer=True) #TODO Break anti-aliasing/multisampling into an explicit menu option
        # window = Window(resizable=True, config=window_config)
    # except pyglet.window.NoSuchConfigException:
    window = Window(resizable=True, vsync=False)
    pyglet.app.run()

    if G.CLIENT:
        G.CLIENT.stop()
        
    if G.SERVER:
        print('Saving...')
        save_world(G.SERVER, "world")
        print('Shutting down internal server...')
        G.main_timer.stop()
        G.SERVER._stop.set()
        G.SERVER.shutdown()
    threading.Thread(target=server.world.content_update, name="world_server.content_update").start()

    # start server timer
    G.main_timer = timer.Timer(G.TIMER_INTERVAL, name="G.main_timer")
    G.main_timer.start()

    return server, server_thread


if __name__ == '__main__':
    #TODO: Enable server launch options
    #In the mean time, manually set
    setattr(G.LAUNCH_OPTIONS, "seed", None)
    G.SAVE_FILENAME = "world"

    load_modules(server=True)

    server, server_thread = start_server()
    print('Server loop running in thread: ' + server_thread.name)

    ip, port = server.server_address
    print "Listening on",ip,port

    helptext = "Available commands: " + ", ".join(["say", "stop", "save"])
    while 1:
        args = raw_input().replace(chr(13), "").split(" ")  # On some systems CR is appended, gotta remove that
        cmd = args.pop(0)
        if cmd == "say":
            msg = "Server: %s" % " ".join(args)
            print msg
            for player in server.players.itervalues():
Exemplo n.º 5
0
    threading.Thread(target=server.world.content_update, name="world_server.content_update").start()

    # start server timer
    G.main_timer = timer.Timer(G.TIMER_INTERVAL, name="G.main_timer")
    G.main_timer.start()

    return server, server_thread


if __name__ == '__main__':
    #TODO: Enable server launch options
    #In the mean time, manually set
    setattr(G.LAUNCH_OPTIONS, "seed", None)
    G.SAVE_FILENAME = "world"

    load_modules(server=True)

    server, server_thread = start_server()
    print('Server loop running in thread: ' + server_thread.name)

    ip, port = server.server_address
    print "Listening on",ip,port

    helptext = "Available commands: " + ", ".join(["say", "stop", "save"])
    while 1:
        args = raw_input().replace(chr(13), "").split(" ")  # On some systems CR is appended, gotta remove that
        cmd = args.pop(0)
        if cmd == "say":
            msg = "Server: %s" % " ".join(args)
            print msg
            for player in server.players.itervalues():
Exemplo n.º 6
0
 def ready(self):
     try:
         mod.load_modules()
         create_default_groups()
     except Exception as e:
         print("Error while loading modules:", e)
Exemplo n.º 7
0
 def ready(self):
     from mod import load_modules
     load_modules()
Exemplo n.º 8
0
    def ready(self):
        from mod import load_modules

        load_modules()