Skip to content

Commit

Permalink
loadConfig.php überarbeitet.
Browse files Browse the repository at this point in the history
Redundanten Programmcode entfernt. 
Neues Dateiformat für die Karteninformationen.
  • Loading branch information
lbleckwenn committed Jan 18, 2018
1 parent 7122d30 commit 244b59e
Show file tree
Hide file tree
Showing 21 changed files with 278 additions and 171 deletions.
26 changes: 26 additions & 0 deletions config/goldcrestValley/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Goldcrest Valley

// Short map name (for e.g. the navbar)
Short=Goldcrest Valley

// Version of the map
Version=

// Download link of the map
Link=https://giants-software.com/

// Map creator / copyright
Copyright=Copyright 2017 GIANTS Software GmbH

// Map size (standard: 2048; 4x maps: 4096)
Size=2048

// Config creator / copyright
configBy=John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=php
9 changes: 0 additions & 9 deletions config/goldcrestValley/map.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions config/mods/vehicles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<mapconfig>
<l10n>
<!-- FS17_kotteUniversalPack -->
<text name="kotteUniSemi">
<en>Universal Sattelauflieger</en>
<de>Universal Sattelauflieger</de>
<fr>Universal Sattelauflieger</fr>
</text>
<!-- krampeSB3060_Mod -->
<text name="krampeSB3060_Mod">
<en>Bandit SB 30/60</en>
<de>Bandit SB 30/60</de>
<fr>Bandit SB 30/60</fr>
</text>
<!-- Fortuna Pack -->
<text name="SA_T">
<en>SA T</en>
<de>SA T</de>
<fr>SA T</fr>
</text>
<!-- Claas Lexion -->
<text name="Lexion">
<en>Lexion</en>
<de>Lexion</de>
<fr>Lexion</fr>
</text>
</l10n>
</mapconfig>
26 changes: 26 additions & 0 deletions config/nfmarsch29/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Nordfriesische Marsch

// Short map name (for e.g. the navbar)
Short=NF Marsch

// Version of the map
Version=2.9

// Download link of the map
Link=https://www.fedaction-letsplay.de

// Map creator / copyright
Copyright=Copyright dani1803 / FedActionLetsPlay

// Map size (standard: 2048; 4x maps: 4096)
Size=2048

// Config creator / copyright
configBy=John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=php
26 changes: 26 additions & 0 deletions config/nfmarsch30/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Nordfriesische Marsch

// Short map name (for e.g. the navbar)
Short=NF Marsch

// Version of the map
Version=3.0

// Download link of the map
Link=https://www.fedaction-letsplay.de

// Map creator / copyright
Copyright=Copyright dani1803 / FedActionLetsPlay

// Map size (standard: 2048; 4x maps: 4096)
Size=2048

// Config creator / copyright
configBy=John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=php
9 changes: 0 additions & 9 deletions config/nfmarsch30/map.txt

This file was deleted.

26 changes: 26 additions & 0 deletions config/nfmarsch4f13/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Nordfriesische Marsch

// Short map name (for e.g. the navbar)
Short=NF Marsch

// Version of the map
Version=4fach 1.3

// Download link of the map
Link=https://www.fedaction-letsplay.de

// Map creator / copyright
Copyright=Copyright dani1803 / FedActionLetsPlay

// Map size (standard: 2048; 4x maps: 4096)
Size=4096

// Config creator / copyright
configBy=alex83we, John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=xml
9 changes: 0 additions & 9 deletions config/nfmarsch4f13/map.txt

This file was deleted.

26 changes: 26 additions & 0 deletions config/sosnovka/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Sosnovka

// Short map name (for e.g. the navbar)
Short=Sosnovka

// Version of the map
Version=

// Download link of the map
Link=https://giants-software.com/

// Map creator / copyright
Copyright=Copyright 2017 GIANTS Software GmbH

// Map size (standard: 2048; 4x maps: 4096)
Size=2048

// Config creator / copyright
configBy=John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=php
9 changes: 0 additions & 9 deletions config/sosnovka/map.txt

This file was deleted.

26 changes: 26 additions & 0 deletions config/tanneberg20/map.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Full map name
Name=Tanneberg

// Short map name (for e.g. the navbar)
Short=Tanneberg

// Version of the map
Version=2.0

// Download link of the map
Link=https://www.modhoster.de/mods/tanneberg-fs17

// Map creator / copyright
Copyright=Copyright ruffrider

// Map size (standard: 2048; 4x maps: 4096)
Size=2048

// Config creator / copyright
configBy=John Hawk

// Version of the map config
configVersion=1.0

// Config format (old = php; new = xml)
configFormat=php
9 changes: 0 additions & 9 deletions config/tanneberg20/map.txt

This file was deleted.

31 changes: 0 additions & 31 deletions config/vehicles.conf

This file was deleted.

68 changes: 68 additions & 0 deletions include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,53 @@ function addFillType($i3dName, $fillLevel, $fillMax, $prodPerHour, $factor, $sta
'state' => $state
);
}

// Load XML configurations files
function loadXMLMapConfig($directory, $language) {
$objects = $translations = array ();
foreach ( glob ( "./config/$directory/*.xml" ) as $filename ) {
$object = simplexml_load_file ( $filename );
if (isset ( $object->item )) {
foreach ( $object->item as $item ) {
$className = strval ( $item ['name'] );
$objects = array_merge ( $objects, array (
$className => array ()
) );
foreach ( $item->attributes () as $attribute => $value ) {
if ($attribute != 'filename') {
$objects [$className] [$attribute] = get_bool ( $value );
}
}
foreach ( $item->children () as $childName => $childData ) {
if (empty ( $objects [$className] [$childName] ) || ! is_array ( $objects [$className] [$childName] )) {
$objects [$className] [$childName] = array ();
}
$fillType = strval ( $childData ['name'] );
$objects [$className] [$childName] [$fillType] = array ();
foreach ( $childData->attributes () as $attribute => $value ) {
if ($attribute != 'name') {
$objects [$className] [$childName] [$fillType] [$attribute] = get_bool ( $value );
}
}
}
}
}
if (isset ( $object->l10n )) {
foreach ( $object->l10n->text as $text ) {
$key = strval ( $text ['name'] );
$value = strval ( $text->$language );
$translations = array_merge ( $translations, array (
$key => $value
) );
}
}
}
return array (
$objects,
$translations
);
}

// convert values while reading xml files
function get_bool($value) {
$value = strval ( $value );
Expand All @@ -86,6 +133,27 @@ function get_bool($value) {
return $value;
}

// Load CFG configurations files
function loadCFGfiles ($readFile) {
$returnArray = array ();
if (file_exists ( $readFile )) {
$entries = file ( $readFile );
foreach ( $entries as $row ) {
if (substr ( ltrim ( $row ), 0, 2 ) == '//' || trim ( $row ) == '') { // ignore comments and emtpty rows
continue;
}
$keyValuePair = explode ( '=', $row );
$key = trim ( $keyValuePair [0] );
$value = $keyValuePair [1];
if (! empty ( $key )) {
$returnArray [$key] = chop ( $value );
}
}
return $returnArray;
}
return false;
}

// Karten laden
function getMaps() {
$maps = array ();
Expand Down

0 comments on commit 244b59e

Please sign in to comment.