/
makequestmap.php
79 lines (75 loc) · 2.49 KB
/
makequestmap.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
<?
include("config.php");
$file = fopen($irpg_db,"r");
fgets($file,1024);
session_start(); // sessions to generate only one map / person / 20s
if (isset($_SESSION['time']) && time()-$_SESSION['time'] < 20) {
header("Location: maperror.png");
exit(0);
}
$_SESSION['time']=time();
$file = fopen($irpg_qfile,"r");
$type=0;
while ($line=fgets($file,1024)) {
$arg = explode(" ",trim($line));
if ($arg[0] == "Y") {
$type = $arg[1];
}
elseif ($arg[0] == "P") {
$p1[0] = $arg[1];
$p1[1] = $arg[2];
$p2[0] = $arg[3];
$p2[1] = $arg[4];
}
elseif ($arg[0] == "S") {
if ($type == 1) $time = $arg[1];
elseif ($type == 2) $stage = $arg[1];
}
elseif ($arg[0] == "P1") {
$player[1]['name'] = $arg[1];
if ($type == 2) {
$player[1]['x'] = $arg[2];
$player[1]['y'] = $arg[3];
}
}
elseif ($arg[0] == "P2") {
$player[2]['name'] = $arg[1];
if ($type == 2) {
$player[2]['x'] = $arg[2];
$player[2]['y'] = $arg[3];
}
}
elseif ($arg[0] == "P3") {
$player[3]['name'] = $arg[1];
if ($type == 2) {
$player[3]['x'] = $arg[2];
$player[3]['y'] = $arg[3];
}
}
elseif ($arg[0] == "P4") {
$player[4]['name'] = $arg[1];
if ($type == 2) {
$player[4]['x'] = $arg[2];
$player[4]['y'] = $arg[3];
}
}
}
if ($type != 2) {
header("Location: maperror.png");
exit(0);
}
$map = imageCreate(500,500);
$magenta = imageColorAllocate($map, 255, 0, 255);
imageColorTransparent($map,$magenta);
$blue = imageColorAllocate($map, 0, 128, 255);
$red = imageColorAllocate($map, 255, 0, 0);
imageFilledEllipse($map, $player[1]['x'], $player[1]['y'], 6, 6, $blue);
imageFilledEllipse($map, $player[2]['x'], $player[2]['y'], 6, 6, $blue);
imageFilledEllipse($map, $player[3]['x'], $player[3]['y'], 6, 6, $blue);
imageFilledEllipse($map, $player[4]['x'], $player[4]['y'], 6, 6, $blue);
if ($stage == 1) imageFilledEllipse($map, $p1[0], $p1[1], 8, 8, $red);
else imageFilledEllipse($map, $p2[0], $p2[1], 9, 9, $red);
header("Content-type: image/png");
imagePNG($map);
imageDestroy($map);
?>