-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatchtest.php
More file actions
57 lines (48 loc) · 1.93 KB
/
patchtest.php
File metadata and controls
57 lines (48 loc) · 1.93 KB
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
<pre>
</pre>
<?php
require_once('includes/autoload.php');
define('_DIRECTORY', './R60_2005/');
define('_DESCRIPTION', 'Description');
define('_LISTENTRY', 'ListEntry');
define('_RANGES', 'Ranges');
define('_RANGESCOUNT', 'RangesCount');
$files = scandir(_DIRECTORY);
$maps = array( );
//var_dump($files);
foreach($files as $file){
if(strpos($file, '.2PF')===false)continue;
$mapIni = parse_ini_file(_DIRECTORY.$file, true, INI_SCANNER_RAW);
$map = new Map(str_replace('.2PF', '', $file));
foreach($mapIni as $sectionName => $section){
switch($sectionName){
case _RANGES:
$rangesCount = $section[_RANGESCOUNT];
for($i=1; $i <= $rangesCount; $i++){
if(!array_key_exists('Range'.$i.'Start', $section) || !array_key_exists('Range'.$i.'End', $section)) {
throw new Exception('RangesCount differs from actual number of ranges');
}
$range = new Range($section['Range'.$i.'Start'], $section['Range'.$i.'End']);
$map->addRange($range);
}
break;
default:
$setting = new Setting($sectionName, $section[_DESCRIPTION], $section[_LISTENTRY], array());
foreach($section as $key => $value){
if($key == _DESCRIPTION || $key == _LISTENTRY) continue;
$value = new Value($key, $value);
$setting->addValue($value);
}
$map->addSetting($setting);
break;
}
}
$maps[] = $map;
}
$settingKeys = $maps[0]->getSettingKeys();
$mod1 = new Modification($maps[0], $maps[0]->getSetting($settingKeys[1]));
$patcher = new Patcher();
$patcher->addModification($mod1);
echo "<pre>";
$patcher->createTunedFile(_DIRECTORY.'original.rom', _DIRECTORY.'original.rom');
echo "</pre>";