summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-12-16 14:55:02 -0300
committerJesusaves <cpntb1@ymail.com>2020-12-16 14:55:02 -0300
commit400b0d7c07765b592979dbe550877d9dcec37de8 (patch)
treee8d8caf2a05953d4d48fe657b60435d184068998
parent64a9b291096910252cdb1f00b59e02e342f4edf8 (diff)
downloadclient-400b0d7c07765b592979dbe550877d9dcec37de8.tar.gz
client-400b0d7c07765b592979dbe550877d9dcec37de8.tar.bz2
client-400b0d7c07765b592979dbe550877d9dcec37de8.tar.xz
client-400b0d7c07765b592979dbe550877d9dcec37de8.zip
try to prevent a race condition
-rw-r--r--game/defs.rpy11
-rw-r--r--game/script.rpy10
2 files changed, 20 insertions, 1 deletions
diff --git a/game/defs.rpy b/game/defs.rpy
index ae53c57..226f7a4 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, uuid
+ import requests, zlib, base64, sys, copy, uuid, time
import websock as wsock
# set PYTHON_VERSION variable (should be 2713, 3605 could fail)
@@ -310,6 +310,7 @@ init -3 python:
# Download server news
# Handled by GAME_LOADER
+ tr_uptodate=True
tr_load=True
return tr_load
@@ -486,6 +487,13 @@ init -1 python:
global allnews, tr_load
tr_load=False
+ # Wait until everything is up to date
+ while not tr_uptodate:
+ try:
+ renpy.pause(0.02)
+ except:
+ time.sleep(0.02)
+
# Load unit data
allunitsbase=json.loads(requests.get("http://"+HOST+'/units.json').text)
# f=open(get_path_if_exists("units.json"), "r")
@@ -531,6 +539,7 @@ init -1 python:
stdout("[OK] Game data loaded to memory")
tr_load=True
+ tr_memcheck=True
return tr_load
diff --git a/game/script.rpy b/game/script.rpy
index bf0c10b..daac0cd 100644
--- a/game/script.rpy
+++ b/game/script.rpy
@@ -75,6 +75,8 @@ label start:
tr_busy=True
tr_val=""
tr_load=False
+ tr_uptodate=False
+ tr_memcheck=False
session_id=uuid.uuid4().hex
#"We shall now begin testing a websocket"
@@ -243,6 +245,14 @@ label login:
# Remove some temporary variables
$ del password
+ # Wait until everything is loaded
+ python:
+ while not tr_memcheck:
+ try:
+ renpy.pause(0.02)
+ except:
+ time.sleep(0.02)
+
if (email):
$ del email
jump prologue