/
updater_Dev.hsp
241 lines (171 loc) · 6.25 KB
/
updater_Dev.hsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#include "hspinet.as"
#pack "logo.png"
#module
#deffunc download str url, str request, str dlname
netinit@
neturl@ url
netdlname@ dlname ; ダウンロード後のファイル名
netrequest@ request ; ファイル名の指定(ここで指定する)
repeat
exist dlname
netexec@ res
if res : break
await 50
loop
netterm@
return
#defcfunc get_chapter var underlying_var, str search_chapter, str punctuate, str end_word
value = instr(underlying_var, 0, search_chapter)
get_chapter_buf = strmid ( underlying_var, value + strlen(""+search_chapter+""+punctuate+""), instr(underlying_var, value + strlen(""+search_chapter+""+punctuate+""), end_word) )
return get_chapter_buf
#global
*buf
celload "logo.png", 1
*main
screen 0, 400, 50
color 50, 50, 50 : boxf
title "Cities Box Updater r13"
now_DIR = dirinfo(0)
font "Yu Gothic", 14, 1
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 255, 127, 39 : pos 60, 10 : mes "ファイル一覧リストをダウンロード中..."
notesel datacenter_url
noteload "data/datacenter_url.txt"
;delete "data/datacenter_url.txt"
notesel about
noteload "data/about.txt"
noteget tmp_about, 2
split tmp_about, " : ", tmp, NOW_Release_number
NOW_Release_number = int(NOW_Release_number)
download datacenter_url, "Dev_update.txt", "data/Dev_update.txt"
notesel NEW_file_list
noteload "data/Dev_update.txt"
NEW_file_list_max = notemax
if instr(NEW_file_list, 0, "<!DOCTYPE html>") != -1 {
dialog "アップデートに失敗しました"
end
}
notesel Dev_latest_version
noteload "data/Dev_latest_version.txt"
Dev_latest_version__Release_Number = get_chapter(Dev_latest_version, "Release Number", " : ", ";")
Dev_latest_version__Title = get_chapter(Dev_latest_version, "Title", " : ", ";")
Dev_latest_version__Version = get_chapter(Dev_latest_version, "Version", " : ", ";")
Dev_latest_version__URL = get_chapter(Dev_latest_version, "URL", " : ", ";")
notesel NOW_file_list
noteload "data/file_list.dat"
NOW_file_list_max = notemax
repeat NEW_file_list_max
notesel NEW_file_list
noteget tmp_NEW_file_list, cnt
notesel NOW_file_list
noteget tmp_NOW_file_list, cnt
split tmp_NEW_file_list, " : ", NEW_file_list_name, NEW_file_list_version, move, move_path
split tmp_NOW_file_list, " : ", NOW_file_list_name, NOW_file_list_version
move_path = strmid(move_path, 0, strlen(move_path)-1)
if int(NEW_file_list_version) > int(NOW_Release_number) {
//ディレクトリが存在しなければ作成
getpath32_NEW_file_list_name = getpath(NEW_file_list_name, 32)
split getpath32_NEW_file_list_name, "\\", NEW_file_list_name_DIR
split_stat = stat
#include "hspext.as"
NEW_file_list_name_DIR_tmp = now_DIR
repeat split_stat - 1
dirlist2 x, NEW_file_list_name_DIR(cnt), 1
if stat = 0 {
mkdir ""+NEW_file_list_name_DIR_tmp+"\\"+NEW_file_list_name_DIR(cnt)+"\\"
}
NEW_file_list_name_DIR_tmp += "\\"+NEW_file_list_name_DIR(cnt)+"\\"
chdir NEW_file_list_name_DIR_tmp
wait 10
loop
chdir now_DIR
color 50, 50, 50 : boxf
color 34, 177, 76 : pos 60, 7 : mes "ダウンロード中 : \n"+NEW_file_list_name+""
pos 5, 5 : gcopy 1, 0, 0, 50, 50
exist NEW_file_list_name
if strsize != -1 {
delete NEW_file_list_name
}
download Dev_latest_version__URL, NEW_file_list_name, NEW_file_list_name
//文字化け解消
if instr(NEW_file_list_name, 0, ".hsp") != -1 or instr(NEW_file_list_name, 0, ".txt") != -1 or instr(NEW_file_list_name, 0, ".adat") != -1 {
notesel dl_tmp
noteload NEW_file_list_name
nkfcnv new_dl_tmp, dl_tmp, "s", strlen(dl_tmp), strlen(dl_tmp) + 1024
notesel new_dl_tmp
notesave NEW_file_list_name
}
}
if int(NEW_file_list_version) = -1 {
color 50, 50, 50 : boxf
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 255, 0, 0 : pos 60, 10 : mes "削除中 : "+NEW_file_list_name+""
exist NEW_file_list_name
if strsize >= 0 {
delete NEW_file_list_name
}
}
exist move_path
if strsize = -1 and instr(move, 0, "move_to") != -1 {
color 50, 50, 50 : boxf
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 255, 0, 255 : pos 60, 10 : mes "移動中 : "+NEW_file_list_name+" → "+move_path+""
//ディレクトリが存在しなければ作成
getpath32_move_path = getpath(move_path, 32)
split getpath32_move_path, "\\", move_path_DIR
split_stat = stat
move_path_DIR_tmp = now_DIR
repeat split_stat - 1
dirlist2 x, move_path_DIR(cnt), 1
if stat = 0 {
mkdir ""+move_path_DIR_tmp+"\\"+move_path_DIR(cnt)+"\\"
}
move_path_DIR_tmp += "\\"+move_path_DIR(cnt)+"\\"
chdir move_path_DIR_tmp
wait 10
loop
chdir now_DIR
exist NEW_file_list_name
if strsize != -1 {
bcopy NEW_file_list_name, move_path
delete NEW_file_list_name
}
}
wait 1
loop
color 50, 50, 50 : boxf
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 163, 73, 164 : pos 60, 10 : mes "バージョン情報更新中..."
notesel about
noteload "data/about.txt"
repeat notemax
noteget about_tmp, cnt
if instr(about_tmp, 0, "Release_number : ") != -1 {
noteadd "Release_number : "+Dev_latest_version__Release_Number+"", cnt, 1
}
if instr(about_tmp, 0, "Title : ") != -1 {
noteadd "Title : "+Dev_latest_version__Title+"", cnt, 1
}
if instr(about_tmp, 0, "Version : ") != -1 {
noteadd "Version : "+Dev_latest_version__Version+"", cnt, 1
}
wait 1
loop
notesel about
notesave "data/about.txt"
color 50, 50, 50 : boxf
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 163, 73, 164 : pos 60, 10 : mes "一時ファイル削除中..."
chdir now_DIR
exist "data/Dev_datacenter_url.txt"
if strsize >= 0 : delete "data/Dev_datacenter_url.txt"
exist "data/Dev_latest_version.txt"
; if strsize >= 0 : delete "data/Dev_latest_version.txt"
exist "data/Dev_update.txt"
if strsize >= 0 : delete "data/Dev_update.txt"
font "Yu Gothic", 11, 1
color 50, 50, 50 : boxf
pos 5, 5 : gcopy 1, 0, 0, 50, 50
color 0, 162, 232 : pos 60, 7 : mes "開発版のアップデートが完了しました。Cities Boxを再起動してください。\n(再起動するとこのアップデーターは自動で削除されます)"
wait 500
end