mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-27 21:56:50 +01:00
Save towns as plain PHP File in cache folder
+ Also load them on install + on reload items = better performance when in dev mode
This commit is contained in:
@@ -159,60 +159,5 @@ else {
|
||||
}
|
||||
unset($tmp, $id, $vocation);
|
||||
|
||||
//////////////////////////////////////
|
||||
// load towns from database or OTBM //
|
||||
//////////////////////////////////////
|
||||
|
||||
$tmp = '';
|
||||
$towns = [];
|
||||
if($cache->enabled() && $cache->fetch('towns', $tmp)) {
|
||||
$towns = unserialize($tmp);
|
||||
}
|
||||
else {
|
||||
if($db->hasTable('towns')) {
|
||||
$query = $db->query('SELECT `id`, `name` FROM `towns`;')->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach($query as $town) {
|
||||
$towns[$town['id']] = $town['name'];
|
||||
}
|
||||
|
||||
unset($query);
|
||||
}
|
||||
else {
|
||||
$mapName = configLua('mapName');
|
||||
if (!isset($mapName)) {
|
||||
$mapName = configLua('map');
|
||||
$mapFile = $config['server_path'] . $mapName;
|
||||
}
|
||||
|
||||
if (strpos($mapName, '.otbm') === false) {
|
||||
$mapName .= '.otbm';
|
||||
}
|
||||
|
||||
if (!isset($mapFile)) {
|
||||
$mapFile = config('data_path') . 'world/' . $mapName;
|
||||
}
|
||||
|
||||
if (file_exists($mapFile)) {
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
require LIBS . 'TownsReader.php';
|
||||
$townsReader = new TownsReader($mapFile);
|
||||
$townsReader->load();
|
||||
|
||||
$towns = $townsReader->get();
|
||||
}
|
||||
else {
|
||||
$towns = config('towns');
|
||||
}
|
||||
}
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->set('towns', serialize($towns), 600);
|
||||
}
|
||||
}
|
||||
|
||||
config(['towns', $towns]);
|
||||
////////////////////////////////////////////
|
||||
// END - load towns from database or OTBM //
|
||||
////////////////////////////////////////////
|
||||
require LIBS . 'Towns.php';
|
||||
Towns::load();
|
||||
Reference in New Issue
Block a user