summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-29 17:45:42 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-29 17:45:42 -0300
commita4eee47265e06d302fc482e68a2abcdd6cd97c81 (patch)
treee0ebe39c16caff20be0dcd8be3651e62ad15b222
parent7da62b659852c0b30d622f09fe98ed323f29a6d2 (diff)
downloadclient-a4eee47265e06d302fc482e68a2abcdd6cd97c81.tar.gz
client-a4eee47265e06d302fc482e68a2abcdd6cd97c81.tar.bz2
client-a4eee47265e06d302fc482e68a2abcdd6cd97c81.tar.xz
client-a4eee47265e06d302fc482e68a2abcdd6cd97c81.zip
Add "foreground" attribute to wait_packet.
This prevents AP Timer from pausing main game from a thread (race condition)
-rw-r--r--game/04_init.rpy11
-rw-r--r--game/misc.rpy2
-rw-r--r--game/script.rpy2
3 files changed, 8 insertions, 7 deletions
diff --git a/game/04_init.rpy b/game/04_init.rpy
index 482ddde..ba7ccd1 100644
--- a/game/04_init.rpy
+++ b/game/04_init.rpy
@@ -116,13 +116,16 @@ init python:
return
- def wait_packet():
+ def wait_packet(fg=True):
global tr_load, tr_val, tr_busy
timeout=0.0
print("Now waiting for packet!")
while not tr_load:
- sdelay() # FIXME: This can cause errors in mobile?
+ if fg:
+ sdelay() # FIXME: This can cause errors in mobile?
+ else:
+ time.sleep(0.02)
timeout+=0.02
if timeout >= TIMEOUT_INTERVAL:
@@ -161,11 +164,11 @@ init python:
return
- def send_packet(packet, args=""):
+ def send_packet(packet, args="", fg=True):
global tr_cmd, tr_busy, tr_load
schedule_packet()
send_packet_now(packet, args)
- return wait_packet()
+ return wait_packet(fg)
# In past, this would keep running, in hopes of catching the program quit
# and being able to kill the threads... But well, it worked poorly.
diff --git a/game/misc.rpy b/game/misc.rpy
index a37d779..27659dc 100644
--- a/game/misc.rpy
+++ b/game/misc.rpy
@@ -299,7 +299,7 @@ image spinner:
init python:
def ap_restore():
# Request AP Data from websocket
- raw=send_packet("apdata")
+ raw=send_packet("apdata", fg=False)
apdata=json_decode(raw)
try:
Player["ap"]=apdata["ap"]
diff --git a/game/script.rpy b/game/script.rpy
index ad0ced0..4bd7081 100644
--- a/game/script.rpy
+++ b/game/script.rpy
@@ -243,8 +243,6 @@ label quit:
pass
# Data cleaned up
- # Destroy the socket
- $ persistent.ws = None
$ print("Sockets closed and data flushed!")
return