@@ -7,9 +7,9 @@ function http2_init()
77 // udp downloads begin
88 sp_sc_func_exec spf_sc_list_onchange_add_func cl_download_filename http2_dl_filename
99
10- set _http2_timer 0
10+
11+ zero _http2_prev_thread
1112 set _http2_not_exist_local 0
12- set _http2_thread_ids 0
1313 set _http2_out_in 1
1414
1515 set _http2_enabled 1
@@ -19,7 +19,7 @@ function http2_init()
1919
2020function http2_init_print()
2121{
22- echo "[HTTP] Version v1.8 Loaded"
22+ echo "[HTTP] Version v1.9 Loaded"
2323}
2424
2525//2 -> 4 -> 7 -> 8
@@ -37,26 +37,22 @@ function http2_state_change(*)
3737 sp_sc_flow_if text cvar _sp_cl_info_server != val "localhost"
3838 {
3939 sp_sc_cvar_copy ~state #~1
40- //echo state is $~state
41- // fully disconnected
40+
41+ // Fully Disconnected...
4242 sp_sc_flow_if text cvar ~state == val 1
4343 {
44- sp_sc_func_exec http2_fast_loop $_http2_thread_ids "stop"
44+ thread_kill _http2_prev_thread
4545 set _http2_out_in 1
4646 }
4747 // Attempting Connect...
4848 sp_sc_flow_if text cvar ~state == val 2
4949 {
50- //echo "state 2"
5150 sp_cl_info_map
52- //echo HMM: $_sp_cl_info_map
5351 }
54- // Reconnecting..
52+ // Reconnecting...
5553 sp_sc_flow_if text cvar ~state == val 4
5654 {
57- //echo "state 4"
5855 sp_cl_info_map
59- //echo HMM: $_sp_cl_info_map
6056 sp_sc_flow_if text cvar _http2_out_in == val 0
6157 {
6258 // This resets _sp_cl_info_map to ""
@@ -68,8 +64,6 @@ function http2_state_change(*)
6864 // Connecting..
6965 sp_sc_flow_if text cvar ~state == val 7
7066 {
71- //echo "State 7"
72-
7367 sp_sc_func_exec http2_on_connect
7468 }
7569
@@ -82,83 +76,47 @@ function http2_state_change(*)
8276 sp_sc_cvar_sset ~text "[HTTP] " #_sp_cl_info_map ".zip was downloaded."
8377 echo #~text
8478 }
85- sp_sc_func_exec http2_fast_loop $_http2_thread_ids "stop"
79+ thread_kill _http2_prev_thread
8680 }
8781 }
8882 }
8983}
9084// State == 7
9185function http2_on_connect()
9286{
93- //echo ON CONNECT
87+
9488 set _http2_out_in 0
95- set _http2_timer 0
9689 set _http2_not_exist_local 0
9790
98- //Only bounce between 1 and 5
99- add _http2_thread_ids 1
100- sp_sc_flow_if number cvar _http2_thread_ids > val 5
101- {
102- set _http2_thread_ids 1
103- }
104- sp_sc_func_exec http2_fast_loop $_http2_thread_ids "start"
91+ thread_kill _http2_prev_thread
92+
93+ //We do not know how to store it.
94+ thread_create 100 http2_fast_loop _http2_prev_thread
95+
10596}
10697
10798// Pros: Works even on linux server because doesn't depend on serverstatus
10899// A loop to get the mapname spamming sp_cl_info_map
109- function http2_fast_loop(~thread_id, ~mode )
100+ function http2_fast_loop()
110101{
111- set ~thread _http2_thread_ids_$~thread_id
112- sp_sc_flow_if text cvar ~mode == val "start"
113- {
114- //echo START
115- set $~thread 1
116- set ~mode "cont"
117- }
118- sp_sc_flow_if text cvar ~mode == val "stop"
119- {
120- //echo STOP
121- set $~thread 0
122- }
123- sp_sc_flow_if text cvar ~mode == val "cont"
102+ sp_cl_info_map
103+
104+ sp_sc_flow_if text cvar _sp_cl_info_map != val ""
124105 {
125- //echo CONT
126- // Thread guaranteed to die.
127- sp_sc_flow_if text cvar $~thread == val 1
128- {
129-
130- // is empty for a few frames before. perfect.
131- sp_cl_info_map
132- //echo MAP : $_sp_cl_info_map
133- sp_sc_flow_if text cvar _sp_cl_info_map != val ""
134- {
135- //echo Map variable appears at : $_http2_timer
136- //echo Map is $_sp_cl_info_map
137- sp_sc_func_exec http2_spawn_dl $~thread_id
138- }
139- add _http2_timer 100
140- sset ~cmd sp_sc_func_exec http2_fast_loop $~thread_id "cont"
141- sp_sc_timer 100 #~cmd
142- }
143- }
144- }
145- // Called by fast_loop if mapname seemed to change.
146- function http2_spawn_dl(~thread_id)
147- {
148- // Stop this thread, we have got the mapname we needed. Only a new connect creates new thread.
149- sp_sc_func_exec http2_fast_loop $~thread_id "stop"
106+ thread_kill _http2_prev_thread
150107
151- // Begin download.
152- sp_sc_cvar_append ~full_path #_sp_cl_info_map ".bsp"
108+ // Begin download.
109+ sp_sc_cvar_append ~full_path #_sp_cl_info_map ".bsp"
153110
154- sp_sc_file_find ~found maps/$~full_path file
155- sp_sc_flow_if text cvar ~found_0 == val "0"
156- {
157- // We have duration of configstrings to download map ( should freeze here possibly )
158- set _http2_not_exist_local 1
159- sp_sc_cvar_sset ~text "[HTTP] Checking repo for " #_sp_cl_info_map ".zip"
160- echo #~text
161- sp_sc_cvar_save http_tmp ~full_path
111+ sp_sc_file_find ~found maps/$~full_path file
112+ sp_sc_flow_if text cvar ~found_0 == val "0"
113+ {
114+ // We have duration of configstrings to download map ( should freeze here possibly )
115+ set _http2_not_exist_local 1
116+ sp_sc_cvar_sset ~text "[HTTP] Checking repo for " #_sp_cl_info_map ".zip"
117+ echo #~text
118+ sp_sc_cvar_save http_tmp ~full_path
119+ }
162120 }
163121}
164122
@@ -193,4 +151,4 @@ function http2_dl_filename(*)
193151 }
194152 }
195153
196- }
154+ }
0 commit comments