From 4492fb781ac9a3f5707a3d83f033d7807cd5b8cd Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 16 Dec 2020 19:41:56 -0300 Subject: Split defs.rpy in five files --- game/script.rpy | 77 +++++++++------------------------------------------------ 1 file changed, 12 insertions(+), 65 deletions(-) (limited to 'game/script.rpy') diff --git a/game/script.rpy b/game/script.rpy index 6009b2d..b224474 100644 --- a/game/script.rpy +++ b/game/script.rpy @@ -21,59 +21,6 @@ by sending an email to {a=mailto:dmca@tmw2.org}dmca@tmw2.org{/a}.{/color}\n\ No warranties.{/b}{fast}" return -init python: - # FIXME: Drop dead if session_id mismatches (new "token") - # Same as ondata? - def onmsg(self, message): - global tr_load, tr_val, tr_busy - stdout("Server : " + message) - - # Inform whatever is waiting for us that a reply was obtained - tr_load=True - tr_val=str(received) - # We do not clean tr_busy here - return - - def ondata(self, msg, dtype, cont): - #print("data received") - """ - on_data: callback object which is called when a message received. - This is called before on_message or on_cont_message, - and then on_message or on_cont_message is called. - on_data has 4 argument. - The 1st argument is this class object. - The 2nd argument is utf-8 string which we get from the server. - The 3rd argument is data type. ABNF.OPCODE_TEXT or ABNF.OPCODE_BINARY will be came. - The 4th argument is continue flag. if 0, the data continue - """ - #renpy.notify(msg) - return - - def onopen(self): - global tr_busy, tr_load, tr_val, HOST - print("Opening connection to %s" % HOST) - tr_load=True - tr_val="" - tr_busy=False - self.send("PING") - - def onerror(self, err): - stdout("ERROR RECEIVED") - stdout("More details: %s" % repr(err)) - stdout("An error happened: %s" % str(err)) - # FIXME: If such error happen, the game never dies - # This is a huge problem o.o - while True: - renpy.call_screen("msgbox", - "An unrecoverable error happened.\nPress OK to return to main menu screen.") - #raise KeyboardException(str(err)) - #raise err - # FIXME: Not working, and the loop also does not work - # Maybe because it causes an Exception? - # I wonder if I can/should run this in a non-daemon thread? - #renpy.quit(relaunch=True, status=1) - sdelay(1.0) - return 1 # Inform you are now ingame label start: @@ -83,18 +30,11 @@ label start: show spinner at truecenter # Initial configuration - python: - tr_busy=True - tr_val="" - tr_load=False - tr_uptodate=False - tr_memcheck=False - session_id=uuid.uuid4().hex + call prestart #"We shall now begin testing a websocket" python: # FIXME: Broken code - ws=persistent.ws if (ws is not None): stdout("Socket exists, trying to reuse connection...") try: @@ -128,8 +68,8 @@ label start: renpy.invoke_in_thread(ws.run_forever) except: # Enter in infinite loop, this will never resolve - tr_load=False stdout("Unrecoverable error, the program is dead.") + tr_load=False while not tr_load: sdelay() @@ -143,8 +83,6 @@ label start: while not tr_load: sdelay() - hide spinner - # Open game scene bg town with Dissolve(0.3) pause 0.1 @@ -152,6 +90,16 @@ label start: $ password=persistent.password $ email="" + if config.developer: + menu: + "tr_load is [tr_load]\ntr_busy is [tr_busy]" + "Send ping": + $ send_packet_now('PING') + "Send formatted packet": + $ send_packet_now('TOKEN;PACKET;') + "Send invalid packet": + $ send_packet_now('INVALID PACKET') + # Check if we need to register if persistent.password is None: call screen welcome @@ -219,7 +167,6 @@ label login: python: try: message=int(message) - import copy dlcode=copy.copy(message) except: print "AN ERROR HAPPENED AT LOGIN TIME" -- cgit v1.2.3-60-g2f50