mirror of
https://github.com/slawkens/myaac.git
synced 2025-06-12 07:44:29 +02:00
fixed #87
This commit is contained in:
parent
f5374e8ce7
commit
49fe7a4b38
@ -11,21 +11,21 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Creatures {
|
||||
private static $monstersList = null;
|
||||
private static $monstersList;
|
||||
private static $lastError = '';
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
global $db;
|
||||
|
||||
try { $db->query("DELETE FROM `myaac_monsters`;"); } catch(PDOException $error) {}
|
||||
try { $db->exec('DELETE FROM `' . TABLE_PREFIX . 'monsters`;'); } catch(PDOException $error) {}
|
||||
|
||||
if($show) {
|
||||
echo '<h2>Reload monsters.</h2>';
|
||||
echo "<h2>All records deleted from table 'myaac_monsters' in database.</h2>";
|
||||
echo "<h2>All records deleted from table '" . TABLE_PREFIX . "monsters' in database.</h2>";
|
||||
}
|
||||
|
||||
try {
|
||||
self::$monstersList = new OTS_MonstersList($config['data_path'].'monster/');
|
||||
self::$monstersList = new OTS_MonstersList(config('data_path') . 'monster/');
|
||||
}
|
||||
catch(Exception $e) {
|
||||
self::$lastError = $e->getMessage();
|
||||
@ -33,9 +33,9 @@ class Creatures {
|
||||
}
|
||||
|
||||
$items = array();
|
||||
$items_db = $db->query('SELECT `id`, `name` FROM `' . TABLE_PREFIX . 'items`;');
|
||||
foreach($items_db->fetchAll() as $item) {
|
||||
$items[$item['name']] = $item['id'];
|
||||
Items::load();
|
||||
foreach((array)Items::$items as $id => $item) {
|
||||
$items[$item['name']] = $id;
|
||||
}
|
||||
|
||||
//$names_added must be an array
|
||||
|
@ -13,7 +13,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
class Items
|
||||
{
|
||||
private static $error = '';
|
||||
private static $items;
|
||||
public static $items;
|
||||
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
@ -36,7 +36,7 @@ class Items
|
||||
} else {
|
||||
$tmp = self::parseNode($item->getAttribute('id'), $item, $show);
|
||||
$items[$tmp['id']] = $tmp['content'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once LIBS . 'cache_php.php';
|
||||
@ -62,7 +62,7 @@ class Items
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function loadItems() {
|
||||
public static function load() {
|
||||
if(self::$items) {
|
||||
return;
|
||||
}
|
||||
@ -72,15 +72,15 @@ class Items
|
||||
self::$items = $cache_php->get('items');
|
||||
}
|
||||
|
||||
public static function getItem($id) {
|
||||
self::loadItems();
|
||||
public static function get($id) {
|
||||
self::load();
|
||||
return self::$items[$id];
|
||||
}
|
||||
|
||||
public static function getDescription($id, $count = 1) {
|
||||
global $db;
|
||||
|
||||
$item = self::getItem($id);
|
||||
$item = self::get($id);
|
||||
|
||||
$attr = $item['attributes'];
|
||||
$s = '';
|
||||
|
Loading…
x
Reference in New Issue
Block a user