summaryrefslogtreecommitdiff
path: root/game/04_init.rpy
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 /game/04_init.rpy
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)
Diffstat (limited to 'game/04_init.rpy')
-rw-r--r--game/04_init.rpy11
1 files changed, 7 insertions, 4 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.