summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-15 19:19:00 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-15 19:19:00 -0300
commit8610f918a5ffcc047b45c5182a63a3fc6a0dd318 (patch)
tree690d7af8e05359ffa19b600b8db4576804e05c3d /game
parent8fc50aeea7f79c32be085fddc18f6a99860c8603 (diff)
downloadclient-8610f918a5ffcc047b45c5182a63a3fc6a0dd318.tar.gz
client-8610f918a5ffcc047b45c5182a63a3fc6a0dd318.tar.bz2
client-8610f918a5ffcc047b45c5182a63a3fc6a0dd318.tar.xz
client-8610f918a5ffcc047b45c5182a63a3fc6a0dd318.zip
Small optimizations to make the good ol' libraries work again
Diffstat (limited to 'game')
-rw-r--r--game/defs.rpy6
-rw-r--r--game/script.rpy25
2 files changed, 24 insertions, 7 deletions
diff --git a/game/defs.rpy b/game/defs.rpy
index 1c41462..ad0e6dd 100644
--- a/game/defs.rpy
+++ b/game/defs.rpy
@@ -20,7 +20,7 @@
init -3 python:
renpy.add_python_directory("python-extra")
- import requests, zlib, base64, sys, copy
+ import requests, zlib, base64, sys, copy, uuid
import websock as wsock
# set PYTHON_VERSION variable (should be 2713, 3605 could fail)
@@ -455,7 +455,9 @@ init -1 python:
return True
def send_packet(packet, args=""):
- global tr_load, tr_val
+ global tr_load, tr_val, tr_busy
+ # TODO: if tr_busy already true, wait until it is made false
+
# This is a secret variable which disables threading
# This may cause hangs and other issues.
if persistent.nothreading:
diff --git a/game/script.rpy b/game/script.rpy
index 07bc415..ad0e091 100644
--- a/game/script.rpy
+++ b/game/script.rpy
@@ -22,8 +22,7 @@ No warranties.{/b}{fast}"
return
init python:
- tr_busy=False
-
+ # FIXME: Drop dead if session_id mismatches (new "token")
# Same as ondata?
def onmsg(self, message):
global tr_load, tr_val, tr_busy
@@ -51,7 +50,11 @@ init python:
return
def onopen(self):
+ global tr_busy, tr_load, tr_val
print("Opening connection")
+ tr_load=True
+ tr_val=""
+ tr_busy=False
self.send("Ping")
def onerror(self, err):
@@ -60,13 +63,21 @@ init python:
# Inform you are now ingame
label start:
- scene black
+ # Begin the initial displays
# TODO: a fairy :(
+ scene black
show spinner at truecenter
- pause 0.1
+
+ # Initial configuration
+ python:
+ tr_busy=True
+ tr_val=""
+ tr_load=False
+ session_id=uuid.uuid4().hex
"We shall now begin testing a websocket"
python:
+
ws=persistent.ws
if (ws is not None):
stdout("Socket exists, trying to reuse connection...")
@@ -93,8 +104,12 @@ label start:
renpy.invoke_in_thread(ws.run_forever, sslopt={"cert_reqs": ssl.CERT_NONE})
#ws.connect("wss://localhost:61000")
+ while not tr_load:
+ renpy.pause(0.02)
+
+ hide spinner
"Connection established!"
- $ ws.send("Hello world")
+ $ send_packet("Hello world")
"Message sent!"
return
# Run updater