This repository has been archived by the owner on Apr 2, 2023. It is now read-only.
/
f3_cellbounds_gen.php
122 lines (97 loc) · 1.83 KB
/
f3_cellbounds_gen.php
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
<?php
function import($file,$dlc)
{
$maxx=array();
$maxy=array();
$maxz=array();
$minx=array();
$miny=array();
$minz=array();
$res = 0;
global $db;
$f=file_get_contents($file);
if($f===FALSE)
die("Error loading $file");
$c=explode("\n",$f);
foreach($c as $t)
{
list($tb,$eid,$ref,$base,$count,$health,$cell,$x,$y,$z,$ax,$ay,$az,$flags,$lock,$key,$link)=explode("|",$t);
$tb = 'refs_' . $tb;
$ref=hexdec($ref);
$base=hexdec($base);
$cell=hexdec($cell);
$flags=hexdec($flags);
$key=hexdec($key);
$link=hexdec($link);
if (!$ref)
continue;
if(!isset($maxx[$cell]))
{
$maxx[$cell]=-999999;
}
if(!isset($maxy[$cell]))
{
$maxy[$cell]=-999999;
}
if(!isset($maxz[$cell]))
{
$maxz[$cell]=-999999;
}
if(!isset($minx[$cell]))
{
$minx[$cell]=999999;
}
if(!isset($miny[$cell]))
{
$miny[$cell]=999999;
}
if(!isset($minz[$cell]))
{
$minz[$cell]=999999;
}
if($maxx[$cell]<$x)
{
$maxx[$cell]=$x;
}
if($maxy[$cell]<$y)
{
$maxy[$cell]=$y;
}
if($maxz[$cell]<$z)
{
$maxz[$cell]=$z;
}
if($minx[$cell]>$x)
{
$minx[$cell]=$x;
}
if($miny[$cell]>$y)
{
$miny[$cell]=$y;
}
if($minz[$cell]>$z)
{
$minz[$cell]=$z;
}
$res++;
}
$f2=str_replace("refr","cellbounds",$file);
unlink($f2);
$out="";
foreach($maxx as $key=>$val)
{
$out.="$key|".$maxx[$key]."|".$maxy[$key]."|".$maxz[$key]."|".$minx[$key]."|".$miny[$key]."|".$minz[$key]."\r\n";
}
file_put_contents($f2,$out);
return $res;
}
$dat = 0;
$dat += import("data3/f3_main_refr.txt",0);
$dat += import("data3/f3_tp_refr.txt",1);
$dat += import("data3/f3_oa_refr.txt",2);
$dat += import("data3/f3_bsn_refr.txt",3);
$dat += import("data3/f3_pl_refr.txt",4);
$dat += import("data3/f3_mz_refr.txt",5);
echo "Imported " . $dat;
//Remove duplicates
$arr=array("");