-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodule.hsp
More file actions
628 lines (485 loc) · 16.1 KB
/
Copy pathmodule.hsp
File metadata and controls
628 lines (485 loc) · 16.1 KB
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
#module
//エラー表示
#deffunc error str errmes, int mode
if errmes = "" {
errmes = "U01 : 原因を特定できません"
}
dstat = 0
if mode = 0 {
dialog "エラーが発生しました\n"+errmes+"\n処理を中断しますか?", 3, "Cities Box Error"
dstat = stat
}
notesel error_log@
noteadd "\n"+gettime(0)+"/"+strf("%02d",gettime(3))+"/"+strf("%02d",gettime(3))+" "+strf("%02d",gettime(4))+":"+strf("%02d",gettime(5))+"."+strf("%02d",gettime(6))+"\n"+errmes+"\n"
chdir ""+directory@+""
notesave "data/error_log.txt"
if dstat = 6 {
goto *exit@
}
return
//指定された範囲内にマウスがあるか確認する関数(使用例:click_range (100, 0, 300, 300) )
#defcfunc click_range int mouse_x, int mouse_y, int mouse_x2, int mouse_y2
if ginfo_wx1 <= ginfo_mx and ginfo_wx2 >= ginfo_mx and ginfo_wy1 <= ginfo_my and ginfo_wy2 >= ginfo_my and mouse_x <= mousex and mouse_x2 >= mousex and mouse_y <= mousey and mouse_y2 >= mousey {
return 1
}
return 0
//各項目の読み込み(使用例:get_chapter(元の変数, "検索する項目", "始点区切りコード", "終端コード") )
#defcfunc get_chapter var underlying_var, str search_chapter, str punctuate, str end_word
value = instr(underlying_var, 0, ""+search_chapter+""+punctuate+"")
if end_word = "" {
get_chapter_buf = strmid ( underlying_var, value + strlen(""+search_chapter+""+punctuate+""), strlen(underlying_var) )
} else {
get_chapter_buf = strmid ( underlying_var, value + strlen(""+search_chapter+""+punctuate+""), instr(underlying_var, value + strlen(""+search_chapter+""+punctuate+""), end_word) )
}
if instr(underlying_var, 0, ""+search_chapter+""+punctuate+"") = -1 {
return ""
}
return get_chapter_buf
/*指定された文字列が何番目の要素にあるかを取得(2次配列用)*/
#defcfunc element2 int search_addon_number, var notename, str search_word
finish = -1
repeat sdnsize(notename, search_addon_number)
if sdnl(notename, search_addon_number, cnt) = search_word {
finish = cnt
break
}
loop
if finish = -1 {
error@ "Cities Box Error A04 : 要素名が見つかりません\nアドオン名 "+sdnl(addon_name@, search_addon_number, 0)+"\nのアドオンファイル(*.adat)内の\n要素 "+search_word+"が、\n規定のタイプ要素と合致しません。\nアドオン製作者にお問い合わせください。", 1
}
return finish
/*指定された文字列が何番目の要素にあるかを取得(3次配列用)*/
#defcfunc element3 int search_addon_number, int search_type_number, var notename, str search_word
finish = -1
repeat sdnsize(notename, search_addon_number)
if sdnl3(notename, search_addon_number, search_type_number, cnt) = search_word {
finish = cnt
break
}
loop
if finish = -1 {
error@ "Cities Box Error A05 : 要素名が見つかりません\nアドオン名 "+sdnl(addon_name@, search_addon_number, 0)+"\nのアドオンファイル(*.adat)内の\n"+(search_type_number+1)+"番目の要素の\n向き "+search_word+"が、\n規定のタイプ要素と合致しません。\nアドオン製作者にお問い合わせください。", 1
}
return finish
//割り算(0で除算する場合はv3の値を返す)
#defcfunc avoid_div_in_zero int v1, int v2, int v3
if i2 = 0 {
return v3
} else {
return (v1 / v2)
}
/*文字列の取得(マップサイズを超えている場合は空白を返す)*/
#defcfunc safesearch_str array buf, int w, int x, int y, int z, int mapsizew, int mapsizex
if mapsizex = -1 { ; mapsizeyが-1のときは1次配列とみなす
if w < 0 or w > mapsizew-1 {
return ""
} else {
return buf(w)
}
} else {
if w < 0 or x < 0 or w > mapsizew-1 or x > mapsizex-1 {
return ""
} else {
return buf(w,x,y,z)
}
}
/*数値の取得(マップサイズを超えている場合は-1を返す)*/
#defcfunc safesearch_int array buf, int x, int y, int mapsizex, int mapsizey
if mapsizey = -1 { ; mapsizeyが-1のときは1次配列とみなす
if x < 0 or x >= mapsizex {
return -1
} else {
return buf(x)
}
} else {
if x < 0 or y < 0 or x >= mapsizex or y >= mapsizey {
return -1
} else {
return buf(x,y)
}
}
/*文字を中央に表示(使用例:cmes "hogehoge", 0, 640, 0, 480, 0)*/
#deffunc cmes str ctext, int cx, int cy, int cx2, int cy2, int redraw_exist
RECT = cx, cy, cx2, cy2
DrawText@ hdc, ctext, -1, varptr(RECT), $01
if redraw_exist = 0 : redraw 1
return
/*画像をぼかす(hsp/sample/new/gblur.hsp | 使用例:gblur 2)*/
#deffunc gblur int p1, int p2
gmode 3, ginfo_sx, ginfo_sy, 128
if (p2&1)=0 {
repeat p1
pos 1,0:gcopy ginfo(3)
pos 0,0:gcopy ginfo(3),2,0
loop
}
if (p2&2)=0 {
repeat p1
pos 0,1:gcopy ginfo(3)
pos 0,0:gcopy ginfo(3),0,2
loop
}
return
/*半透明色表示命令(機能はboxfaと同じ)*/
#deffunc sboxf int depth, int ax, int ay, int bx, int by
pdx = ax, bx, bx, ax
pdy = ay, ay, by, by
gmode 3,,,depth
gsquare -1,pdx, pdy
return
/*アドオンの情報を取得*/
#deffunc get_about_addon int search_addon_number@, int search_type_number@, int search_direction_number@, var input_top_left_x, var input_top_left_y, var input_bottom_right_x, var input_bottom_right_y,var input_size_x, var input_size_y, var input_chip_x, var input_chip_y
//オブジェクトの画像上の座標を取得
onerror gosub *er
chdir drectory@
notesel addon_top_left_x@
input_top_left_x = sdnl3(addon_top_left_x@, search_addon_number@, search_type_number@, search_direction_number@)
input_top_left_y = sdnl3(addon_top_left_y@, search_addon_number@, search_type_number@, search_direction_number@)
input_bottom_right_x = sdnl3(addon_bottom_right_x@, search_addon_number@, search_type_number@, search_direction_number@)
input_bottom_right_y = sdnl3(addon_bottom_right_y@, search_addon_number@, search_type_number@, search_direction_number@)
input_size_x = sdnl3(addon_size_x@, search_addon_number@, search_type_number@, search_direction_number@)
input_size_y = sdnl3(addon_size_x@, search_addon_number@, search_type_number@, search_direction_number@)
input_chip_x = sdnl3(addon_chip_x@, search_addon_number@, search_type_number@, search_direction_number@)
input_chip_y = sdnl3(addon_chip_x@, search_addon_number@, search_type_number@, search_direction_number@)
return
*er
error "A13 : obj_type(x,y)またはobj_dire(x,y)の数値が異常です\nアドオンに存在しないobj_type(x,y)またはobj_dire(x.y)が設定されています。\nアドオン番号:"+search_addon_number+"\nobj_type(x,y):"+search_type_number+"\nobj_dire(x,y):"+obj_dire(x,y)+""
return
//ダウンロード(要hspinet.dll)
#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
; 条件分岐 if (... = ** or ... = **) ..に当てはまる数を返す関数(条件2つ用)*/
#defcfunc iforandcorrect_2 var a1, var a2, var b1, var b2, var c1, var c2, var d1, var d2, str searchword1, str searchword2
correct = 0
if str(a2) = "0" : a2 = ""
if a1 = searchword1 or a2 = searchword2 {
correct++
}
if str(b2) = "0" : b2 = ""
if b1 = searchword1 or b2 = searchword2 {
correct++
}
if str(c2) = "0" : c2 = ""
if c1 = searchword1 or c2 = searchword2 {
correct++
}
if str(d2) = "0" : d2 = ""
if d1 = searchword1 or d2 = searchword2 {
correct++
}
return correct
; 条件分岐 if (... = ** or ... = **) ..に当てはまる数を返す関数(条件3つ用)*/
#defcfunc iforandcorrect_3 var a1, var a2, var b1, var b2, var c1, var c2, var d1, var d2, str searchword1, str searchword2, str searchword3
correct = 0
if str(a2) = "0" : a2 = ""
if a1 = searchword1 or a2 = searchword2 or a2 = searchword3 {
correct++
}
if str(b2) = "0" : b2 = ""
if b1 = searchword1 or b2 = searchword2 or b2 = searchword3 {
correct++
}
if str(c2) = "0" : c2 = ""
if c1 = searchword1 or c2 = searchword2 or c2 = searchword3 {
correct++
}
if str(d2) = "0" : d2 = ""
if d1 = searchword1 or d2 = searchword2 or d2 = searchword3 {
correct++
}
return correct
; 条件分岐 if (... = ** or ... = **) ..に当てはまる数を返す関数(条件3つ用2)*/
#defcfunc iforandcorrect_3_2 var a1, var a2, var b1, var b2, var c1, var c2, var d1, var d2, str searchword1, str searchword2, str searchword3
correct = 0
if str(a2) = "0" : a2 = ""
if a1 = searchword1 or a1 = searchword2 or a2 = searchword3 {
correct++
}
if str(b2) = "0" : b2 = ""
if b1 = searchword1 or b1 = searchword2 or b2 = searchword3 {
correct++
}
if str(c2) = "0" : c2 = ""
if c1 = searchword1 or c1 = searchword2 or c2 = searchword3 {
correct++
}
if str(d2) = "0" : d2 = ""
if d1 = searchword1 or d1 = searchword2 or d2 = searchword3 {
correct++
}
return correct
; 条件分岐 if (... = ** or ... = **) ..に当てはまる数を返す関数(条件4つ用)*/
#defcfunc iforandcorrect_4 var a1, var a2, var b1, var b2, var c1, var c2, var d1, var d2, str searchword1, str searchword2, str searchword3, str searchword4
correct = 0
if str(a2) = "0" : a2 = ""
if a1 = searchword1 or a1 = searchword2 or a2 = searchword3 or a2 = searchword4 {
correct++
}
if str(b2) = "0" : b2 = ""
if b1 = searchword1 or b1 = searchword2 or b2 = searchword3 or b2 = searchword4 {
correct++
}
if str(c2) = "0" : c2 = ""
if c1 = searchword1 or c1 = searchword2 or c2 = searchword3 or c2 = searchword4 {
correct++
}
if str(d2) = "0" : d2 = ""
if d1 = searchword1 or d1 = searchword2 or d2 = searchword3 or d2 = searchword4 {
correct++
}
return correct
; 疑似配列に変数の内容を保存(2次配列用)
#deffunc sdns var notename, int dy, int dx, var inp, int sy, int sx
//空白であれば初期化
if str(notename) = "" or str(notename) = "0" {
notename = ""
if sx = 0 {
sx_tmp = 128
} else {
sx_tmp = sx + 1
}
if sy = 0 {
sy_tmp = 128
} else {
sy_tmp = sy + 1
}
repeat sy_tmp
yc = cnt
xtmp = ""
repeat sx_tmp
xtmp += "< >"
loop
notename += ""+xtmp+"§"
loop
; 最大数を記録
maxsize = "["+(sx_tmp-1)+", "+(sy_tmp-1)+"]"
} else {
split notename, "[", notuse, sptmp
maxsize_tmp = strmid(sptmp, 0, instr(sptmp, 0, "]"))
maxsize = "["+maxsize_tmp+"]"
}
xtmp = ""
//所定の位置に書き込み
split notename, "§", line_tmp : split_stat = stat - 1
xtmp = line_tmp(dy)
punc = -1
xtmp_2 = ""
xtmp_2_strlen = 0
i = 0
repeat strlen(xtmp)
if strmid(xtmp, cnt, 1) = "<" {
punc ++
if punc = dx {
xtmp_2 += "<"+inp+">"
}
}
if punc != dx {
xtmp_2 += strmid(xtmp, cnt, 1)
}
loop
notename_tmp = ""
repeat split_stat
if cnt = dy {
notename_tmp += ""+xtmp_2+"§"
} else {
notename_tmp += ""+line_tmp(cnt)+"§"
}
loop
notename = notename_tmp
; 最大数を記録
notename += maxsize
return
; 疑似配列の内容を読み込み(2次配列用)
#defcfunc sdnl var notename, int ly, int lx
split notename, "§", line_tmp
xtmp = line_tmp(ly)
split xtmp, "<", get_tmps
if lx+1 > stat-1 {
return ""
}
get_tmp = get_tmps(lx+1)
ret_tmp = strmid(get_tmp, 0, strlen(get_tmp)-1)
return ret_tmp
; 疑似配列の各行のサイズを取得(2次配列用)
#defcfunc sdnsize var notename, int ly
split notename, "[", notuse, sptmp
split sptmp, ", ", sizex, sizey
max = int(sizex)+1
repeat max + 1
search_i = int(sizex) - cnt
if sdnl(notename, ly, search_i-1) = " " {
max = search_i
} else {
break
}
loop
return max-1
; 疑似配列内のインデックスを取得(2次配列用)
#deffunc sdnsearch var notename, str search_word, var inputy, var inputx
split notename, "[", notuse, sptmp
maxsize_tmp = strmid(sptmp, 0, instr(sptmp, 0, "]"))
split maxsize_tmp, ", ", sizex, sizey
x = -1
y = -1
searchtmp = ""
repeat int(sizex)
x = cnt
repeat int(sizey)
y = cnt
searchtmp = sdnl(notename, y, x)
if searchtmp = search_word {
inputx = x
inputy = y
break
}
loop
loop
return
; 疑似配列に変数の内容を保存(3次配列用)
#deffunc sdns3 var notename, int dy, int dx, int dz, var inp, int sy, int sx, int sz
punc_word = "\\"
//空白であれば初期化
if str(notename) = "" or str(notename) = "0" {
notename = ""
if sx = 0 {
sx_tmp = 128
} else {
sx_tmp = sx + 1
}
if sy = 0 {
sy_tmp = 128
} else {
sy_tmp = sy + 1
}
if sz = 0 {
sz_tmp = 32
} else {
sz_tmp = sz + 1
}
repeat sy_tmp
yc = cnt
xtmp = ""
repeat sx_tmp
xtmp += "<"
repeat sz_tmp-1
xtmp += punc_word
loop
xtmp += ">"
loop
notename += ""+xtmp+"§"
loop
; 最大数を記録
maxsize = "["+(sx_tmp-1)+", "+(sy_tmp-1)+", "+(sz_tmp-1)+"]"
} else {
split notename, "[", notuse, sptmp
maxsize_tmp = strmid(sptmp, 0, instr(sptmp, 0, "]"))
if sx = 0 and sy = 0 and sz = 0 {
split maxsize_tmp, ", ", sx_tmp, sy_tmp, sz_tmp
}
maxsize = "["+maxsize_tmp+"]"
}
xtmp = ""
//所定の位置に書き込み
split notename, "§", line_tmp
xtmp = line_tmp(dy)
split xtmp, "<", element_tmp : split_stat_x = stat
element_xtmp = strmid(element_tmp(dx+1), 0, strlen(element_tmp(dx+1))-1)
split element_xtmp, punc_word, element_tmp2 : split_stat_z = stat
element_tmp2(dz) = inp
element_xtmp = "<"
repeat sz_tmp-1
element_xtmp += element_tmp2(cnt)
if cnt < split_stat_z {
element_xtmp += punc_word
}
loop
element_xtmp += ">"
xtmp = ""
repeat sx_tmp
if cnt = dx {
xtmp += element_xtmp
} else {
xtmp += "<" + element_tmp(cnt+1)
}
loop
xtmp += "§"
notename = ""
repeat sy_tmp
if cnt != dy {
notename += line_tmp(cnt) + "§"
} else {
notename += xtmp
}
loop
; 最大数を記録
notename += maxsize
return
; 疑似配列の内容を取得(3次配列用)
#defcfunc sdnl3 var notename, int ly, int lx, int lz
split notename, "§", line_tmp
xtmp = line_tmp(ly)
split xtmp, "<", get_tmps
get_tmp = get_tmps(lx+1)
ret_tmp = strmid(get_tmp, 0, strlen(get_tmp)-1)
split ret_tmp, "\\", ret_tmp_2
if lz > stat-1 {
return ""
}
return ret_tmp_2(lz)
// 以下はバイナリ操作用
#defcfunc binaryCut var binaryVar, int startIndex, int endIndex, int size
sdim returnBinary, endIndex-startIndex+1
/*
cutSize = endIndex-startIndex
if endIndex > size : cutSize = size-startIndex
memcpy returnBinary, binaryVar, cutSize, 0, startIndex
//if startIndex > 8000 : dialog ""+returnBinary+""
if endIndex-startIndex > 100 : dialog ""+cutSize+"\n\n"+yreturnBinary+""
*/
sdim peekTemp, 8
repeat endIndex-startIndex
if startIndex+cnt >= size {
break
}
peekTemp = peek(binaryVar, startIndex+cnt)
if peekTemp = 0 {
poke returnBinary, cnt, 1
} else {
poke returnBinary, cnt, peekTemp
}
loop
return returnBinary
#defcfunc binarySearch var binaryVar, int startIndex, str searchWord, int size
returnIndex = -1
searchSize = strlen(searchWord)
sdim searchingBinaryVar, searchSize
index = startIndex
repeat
repeat searchSize
if index+cnt >= size {
break
}
poke searchingBinaryVar, cnt, peek(binaryVar, index+cnt)
loop
if searchingBinaryVar = searchWord {
returnIndex = index
break
}
index ++
if index >= size {
break
}
loop
return returnIndex
#global