mirror of
https://github.com/slawkens/myaac.git
synced 2026-03-16 16:03:31 +01:00
[WIP] Outfits TOML + XML
Deprecate old Outfits & Mounts functions
This commit is contained in:
@@ -74,3 +74,57 @@ function fieldExist($field, $table)
|
||||
global $db;
|
||||
return $db->hasColumn($table, $field);
|
||||
}
|
||||
|
||||
function Outfits_loadfromXML(): ?array
|
||||
{
|
||||
global $config;
|
||||
$file_path = $config['data_path'] . 'XML/outfits.xml';
|
||||
if (!file_exists($file_path)) { return null; }
|
||||
|
||||
$xml = new DOMDocument;
|
||||
$xml->load($file_path);
|
||||
|
||||
$outfits = null;
|
||||
foreach ($xml->getElementsByTagName('outfit') as $outfit) {
|
||||
$outfits[] = Outfit_parseNode($outfit);
|
||||
}
|
||||
return $outfits;
|
||||
}
|
||||
|
||||
function Outfit_parseNode($node): array
|
||||
{
|
||||
$looktype = (int)$node->getAttribute('looktype');
|
||||
$type = (int)$node->getAttribute('type');
|
||||
$lookname = $node->getAttribute('name');
|
||||
$premium = $node->getAttribute('premium');
|
||||
$unlocked = $node->getAttribute('unlocked');
|
||||
$enabled = $node->getAttribute('enabled');
|
||||
return array('id' => $looktype, 'type' => $type, 'name' => $lookname, 'premium' => $premium, 'unlocked' => $unlocked, 'enabled' => $enabled);
|
||||
}
|
||||
|
||||
function Mounts_loadfromXML(): ?array
|
||||
{
|
||||
global $config;
|
||||
$file_path = $config['data_path'] . 'XML/mounts.xml';
|
||||
if (!file_exists($file_path)) { return null; }
|
||||
|
||||
$xml = new DOMDocument;
|
||||
$xml->load($file_path);
|
||||
|
||||
$mounts = null;
|
||||
foreach ($xml->getElementsByTagName('mount') as $mount) {
|
||||
$mounts[] = Mount_parseNode($mount);
|
||||
}
|
||||
return $mounts;
|
||||
}
|
||||
|
||||
function Mount_parseNode($node): array
|
||||
{
|
||||
$id = (int)$node->getAttribute('id');
|
||||
$clientid = (int)$node->getAttribute('clientid');
|
||||
$name = $node->getAttribute('name');
|
||||
$speed = (int)$node->getAttribute('speed');
|
||||
$premium = $node->getAttribute('premium');
|
||||
$type = $node->getAttribute('type');
|
||||
return array('id' => $id, 'clientid' => $clientid, 'name' => $name, 'speed' => $speed, 'premium' => $premium, 'type' => $type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user