Skip to content

Commit ff1cf35

Browse files
committed
chore: clean files + add readme on example
1 parent 0d96317 commit ff1cf35

15 files changed

Lines changed: 91 additions & 656 deletions

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.github export-ignore
2+
example export-ignore
3+
tests export-ignore

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"php": "~8.4",
1414
"ext-imagick": "*",
1515
"ext-gd": "*",
16-
"arakne/swf": "^0.2.2",
17-
"workerman/workerman": "~5.1"
16+
"arakne/swf": "^0.2.2"
1817
},
1918
"require-dev": {
2019
"phpunit/phpunit": "~12.0",

example/worldmap/.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ DB_DSN=mysql:host=172.17.0.1;dbname=araknemu
22
DB_USER=araknemu
33
DB_PASSWORD=araknemu
44
DOFUS_PATH=/srv/data/dofus
5-
MAPS_PATH=/srv/data/maps
5+
MAPS_PATH=/srv/data/maps
6+
LISTEN_PORT=80
7+
WORKER_COUNT=8

example/worldmap/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# WorldMap Viewer
2+
3+
This example provides a simple application with:
4+
- Incarnam and Amakna worldmap viewer using Leaflet.js
5+
- Shows teleportation cells on maps
6+
- Display a single map
7+
8+
It uses database from [Araknemu](https://github.com/Arakne/Araknemu).
9+
10+
## Installation (using docker)
11+
12+
Retrieve all necessary assets:
13+
- Setup the araknemu database
14+
- Download and extract the Dofus 1.29 client
15+
- Download and extract the dofus maps
16+
17+
Configure the `.env`:
18+
19+
```bash
20+
# Configure the DB connection to your araknemu database
21+
# Don't forget that the database must be accessible from the docker container
22+
DB_DSN=mysql:host=172.17.0.1;dbname=araknemu
23+
DB_USER=araknemu
24+
DB_PASSWORD=araknemu
25+
26+
# Do not change paths: they are mounted from the host to the container
27+
DOFUS_PATH=/srv/data/dofus
28+
MAPS_PATH=/srv/data/maps
29+
30+
# Docker allows to bind ports from the host to the container
31+
# So port 80 is fine in this case
32+
LISTEN_PORT=80
33+
34+
# Number of worker processes
35+
# Consider setting this to the number of CPU cores you have on small traffics
36+
# Or the double on high traffics
37+
# Note: higher number of workers means more memory usage (one process = ~200MB)
38+
WORKER_COUNT=8
39+
```
40+
41+
Create a `docker-compose.override.yml` file:
42+
43+
```yaml
44+
services:
45+
php:
46+
restart: unless-stopped
47+
48+
# Map the dofus client and maps from the host to the container
49+
# Also keep the cache as persistent volume, so it will not be rebuilt at each container restart
50+
volumes:
51+
- ./dofus/client/path:/srv/data/dofus:ro
52+
- ./dofus/maps/path:/srv/data/maps:ro
53+
- ./cache:/srv/cache
54+
```
55+
56+
Now you can build and start the container:
57+
58+
```bash
59+
docker-compose build
60+
docker-compose up -d
61+
```
62+
63+
To optimise the cache, you can pre-generate the map tiles:
64+
65+
```bash
66+
docker-compose exec php php index.php warmup
67+
```
68+
69+
> [!NOTE]
70+
> The `exec` command runs a command inside the running container, so make sure the container is running before executing it.
71+
> Use `run` instead of `exec` if you want to run it in a new container.
72+
73+
You can now access the application at [http://127.0.0.1:5000/](http://127.0.0.1:5000/) (or your server IP if not running locally).
74+
75+
## Screenshot
76+
77+
![Amakna worldmap](./screen/amakna-worldmap.png)
78+
![Incarnam worldmap](./screen/incarnam-worldmap.png)
79+
![Amakna worldmap zoom](./screen/amakna-zoom.png)
80+
![Map view](./screen/showmap.png)

example/worldmap/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
exit(0);
1919
}
2020

21-
$worker = new \Workerman\Worker('http://0.0.0.0:80');
22-
$worker->count = 16;
21+
$worker = new \Workerman\Worker('http://0.0.0.0:' . (getenv('LISTEN_PORT') ?: '80'));
22+
$worker->count = (int) (getenv('WORKER_COUNT') ?: 4);
2323

2424
$worker->onMessage = function (TcpConnection $connection, Request $request) use ($app) {
2525
$app->run($request->path(), $request->get(), function (string $data, array $headers = []) use ($connection) {
332 KB
Loading
1.44 MB
Loading
559 KB
Loading
760 KB
Loading

example/worldmap/src/Application.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function (string $name, int $current, int $total) {
7474
echo sprintf("[Amakna] Building %s (%d/%d)\n", $name, $current, $total);
7575
},
7676
);
77+
7778
echo "Warming up Incarnam...\n";
7879
$this->incarnam->warmup(
7980
function (string $name, int $current, int $total) {

0 commit comments

Comments
 (0)