-
Notifications
You must be signed in to change notification settings - Fork 6
/
_DecAttr.php
42 lines (36 loc) · 1.2 KB
/
_DecAttr.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
#!/usr/bin/env php
<?php
/*
* DecMcpe
*
* Copyright (C) 2016 PEMapModder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PEMapModder
*/
$opts = getopt("", ["in:", "out:"]);
$SUBJECT = $opts["in"] ?? "in/mpe.asm";
$OUTPUT = $opts["out"] ?? "out/attrdump.json";
/** @noinspection PhpUsageOfSilenceOperatorInspection */
@mkdir(dirname($OUTPUT), 0777, true);
spl_autoload_register(function ($class){
require_once __DIR__ . DIRECTORY_SEPARATOR . str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
});
$output = [];
echo "\rOpening stream to read $SUBJECT";
$is = fopen($SUBJECT, "r");
$linesCnt = 0;
while(!feof($is)){
$linesCnt++;
$line = rtrim(fgets($is));
if(strpos($line, "<Player::registerAttributes()>:")){
if(preg_match('%<AttributeInstance::([a-zA-Z0-9_]+).*>:%', $line, $match)){
$output["AttributeInstance::" . $match[1]] = true;
}
}
}
file_put_contents($OUTPUT, json_encode(array_keys($output), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_BIGINT_AS_STRING));