<?php

// Необходима функция creatureinfo
require('includes/allnpcs.php');

$smarty->config_load($conf_file, 'npcs');

global $npc_cols;

// Разделяем из запроса класс и подкласс вещей
point_delim($podrazdel,$type,$family);

$cache_str = (empty($type)?'x':intval($type)).'_'.(empty($family)?'x':intval($family));

if(!$npcs = load_cache(2, $cache_str))
{
	unset($npcs);

	global $AoWoWconf;
	global $DB;

	$rows = $DB->select('
		SELECT c.?#, c.entry
		{
			, l.name_loc?d as `name_loc`
			, l.subname_loc'.$_SESSION['locale'].' as `subname_loc`
		}
		FROM ?_factiontemplate, creature_template c
		{ LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ? }
		WHERE 1=1
			{AND type=?}
			{AND family=?}
			AND factiontemplateID=faction_A
		ORDER BY minlevel DESC, name
		{LIMIT ?d}
		',
		$npc_cols[0],
		($_SESSION['locale']>0)? $_SESSION['locale']: DBSIMPLE_SKIP,
		($_SESSION['locale']>0)? 1: DBSIMPLE_SKIP,
		($type!='')? $type: DBSIMPLE_SKIP,
		(isset($family))? $family: DBSIMPLE_SKIP,
		($AoWoWconf['limit']!=0)? $AoWoWconf['limit']: DBSIMPLE_SKIP
	);

	$npcs = array();
	foreach ($rows as $numRow=>$row)
	{
		$npcs[$numRow] = array();
		$npcs[$numRow] = creatureinfo2($row);
	}
	save_cache(5, $cache_str, $npcs);
}

global $page;
$page = array(
	'Mapper' => false,
	'Book' => false,
	'Title' => $smarty->get_config_vars('NPCs'),
	'tab' => 0,
	'type' => 0,
	'typeid' => 0,
	'path' => '[0, 4,'.$type.','.$family.']'
);
$smarty->assign('page', $page);

if (count($npcs>=0))
	$smarty->assign('npcs',$npcs);
// Количество MySQL запросов
$smarty->assign('mysql', $DB->getStatistics());
// Загружаем страницу
$smarty->display('npcs.tpl');

?>
