forked from X-Genesis-Qhulut/alpha
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwow_alpha_ports.php
215 lines (160 loc) · 4.63 KB
/
wow_alpha_ports.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
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
<?php
/*
Author: X'Genesis Qhulut <XGenesis-Qhulut@protonmail.com>
Date: August 2022
See LICENSE for license details.
*/
// WORLD PORTS (for use with .tel command)
function findNearbyPorts (&$info)
{
global $id;
$row = $info ['row'];
$x = $row ['x'];
$y = $row ['y'];
$z = $row ['z'];
$map = $row ['map'];
$nearbyResults = dbQueryParam ("SELECT *,
SQRT(POWER(? - x, 2) + POWER(? - y, 2) + POWER(? - z, 2))
AS distance
FROM ".WORLDPORTS."
WHERE map = ? AND entry <> ?
HAVING distance <= ".NEARBY_PORTS_DISTANCE."
ORDER BY distance
LIMIT " . QUERY_LIMIT * 2, // more generous query limit for this
array ('dddii', &$x, &$y, &$z, &$map, &$id));
$info ['nearbyResults'] = $nearbyResults;
} // end of findNearbyPorts
function portTopLeft ($info)
{
global $id;
$extras = $info ['extras'];
comment ('PORT DETAILS');
showOneThing (WORLDPORTS, 'entry', $id, "Teleport: .tel <name>", "name", $extras); // —>
} // end of portTopLeft
function portTopRight ($info)
{
global $id;
$row = $info ['row'];
$nearbyResults = $info ['nearbyResults'];
foreach ($nearbyResults as &$portRow)
$portRow ['color'] = 'cyan';
$nearbyResults [] = $row;
echo "<div class='caroussel__maps'>\n";
showSpawnPoints ($nearbyResults, 'Teleport location', WORLDPORTS,
'entry', 'x', 'y', 'z', 'map');
endDiv ('caroussel__maps');
} // end of portTopRight
function showNearbyPorts ($info)
{
$nearbyResults = $info ['nearbyResults'];
boxTitle ('Nearby teleports');
echo "<table class='table-rows'>\n";
echo "<thead>\n";
echo "<tr>\n";
th ('Name');
th ('X');
th ('Y');
th ('Z');
th ('Map');
th ('Distance (yards)');
echo "</tr>\n";
echo "</thead>\n";
echo "<tbody>\n";
$td = function ($s) use (&$portRow) { td ($portRow [$s]); };
$searchURI = makeSearchURI (true);
$pos = 0;
foreach ($nearbyResults as $portRow)
{
$pos++;
$entry = $portRow ['entry'];
$distance = $portRow ['distance'];
$name = $portRow ['name'];
echo "<tr>\n";
tdh ("<a href='?action=show_port&id=$entry'>$name</a>");
$td ('x');
$td ('y');
$td ('z');
$td ('map');
td (round ($distance, 0));
echo "</tr>\n";
} // end of foreach
echo "</tbody>\n";
echo "</table>\n";
} // end of showNearbyPorts
function portDetails ($info)
{
global $id;
findNearbyPorts ($info);
topSection ($info, function ($info)
{
topMiddle ($info, 'portTopLeft');
topRight ($info, 'portTopRight');
});
if ($info ['row'] ['map'] <= 1)
{
bottomSection ($info, function ($info)
{
showNearbyPorts ($info);
});
}
} // end of portDetails
function showOnePort ()
{
global $id;
if (($id === false && !repositionSearch()) || !checkID ())
return;
// we need the item info in this function
$row = dbQueryOneParam ("SELECT * FROM ".WORLDPORTS." WHERE entry = ?", array ('i', &$id));
if (!$row)
{
ShowWarning ("Port $id is not on the database");
return;
} // end of not finding it
$name = $row ['name'];
setTitle ("Port $name");
$extras = array ('map' => 'map');
// we pass this stuff around to the helper functions
$info = array ('row' => $row, 'extras' => $extras, 'limit' => array ());
// ready to go! show the page info and work our way down into the sub-functions
pageContent ($info, 'Teleport', $name, 'ports', 'portDetails', WORLDPORTS);
} // end of showOnePort
function showPorts ()
{
global $where, $params, $maps, $sort_order, $matches;
$sortFields = array (
'entry',
'name',
'x',
'y',
'z',
'map',
);
if (!in_array ($sort_order, $sortFields))
$sort_order = 'name';
setTitle ("Ports listing");
$td = function ($s) use (&$row) { tdx ($row [$s]); };
$headings = array ('Entry', 'Name', 'x', 'y', 'z', 'Map');
$results = setUpSearch ('Teleports', $sortFields, $headings);
if (!$results)
return;
echo "<ul><li>For use with <b>.tel</b> command. Only map 0 and 1 shown.</ul>\n";
$searchURI = makeSearchURI (true);
$pos = 0;
foreach ($results as $row)
{
$pos++;
echo "<tr>\n";
$id = $row ['entry'];
tdhr ("<a href='?action=show_port&id=$id$searchURI&pos=$pos&max=$matches'>$id</a>");
tdhr ("<a href='?action=show_port&id=$id$searchURI&pos=$pos&max=$matches'>" . fixHTML ($row ['name']) . "</a>");
$td ('x');
$td ('y');
$td ('z');
$map = $row ['map'];
tdh (expandSimple ($maps, $map));
showFilterColumn ($row);
echo "</tr>\n";
}
wrapUpSearch ();
} // end of showPorts
?>