- updated Loot-class to work with TrinityCore:master/55b43c67519359f0e5a96004c393898b3c62add3

- fixed some awkward names for skinning-tabs on npc.php
- only send calendar if we have events to display on event.php
- do not display conditions column if there are no conditions on item.php
This commit is contained in:
Sarjuuk
2014-09-28 13:30:17 +02:00
parent 713df0d7f2
commit 0806e616ae
7 changed files with 53 additions and 60 deletions

View File

@@ -15,7 +15,7 @@ if (!defined('AOWOW_REVISION'))
pickpocketing_loot_template entry many <- many creature_template pickpocketloot pickpocketing_loot_template entry many <- many creature_template pickpocketloot
skinning_loot_template entry many <- many creature_template skinloot Can also store minable/herbable items gathered from creatures skinning_loot_template entry many <- many creature_template skinloot Can also store minable/herbable items gathered from creatures
quest_mail_loot_template entry quest_template RewMailTemplateId quest_mail_loot_template entry quest_template RewMailTemplateId
reference_loot_template entry many <- many _loot_template -mincountOrRef In case of negative mincountOrRef reference_loot_template entry many <- many *_loot_template reference
*/ */
class Loot class Loot
@@ -89,7 +89,7 @@ class Loot
if (!$tableName || !$lootId) if (!$tableName || !$lootId)
return null; return null;
$rows = DB::Aowow()->select('SELECT * FROM ?# WHERE entry = ?d{ AND groupid = ?d}', $tableName, abs($lootId), $groupId ?: DBSIMPLE_SKIP); $rows = DB::Aowow()->select('SELECT * FROM ?# WHERE entry = ?d{ AND groupid = ?d}', $tableName, $lootId, $groupId ?: DBSIMPLE_SKIP);
if (!$rows) if (!$rows)
return null; return null;
@@ -98,9 +98,9 @@ class Loot
foreach ($rows as $entry) foreach ($rows as $entry)
{ {
$set = array( $set = array(
'quest' => $entry['ChanceOrQuestChance'] < 0, 'quest' => $entry['needsquest'],
'group' => $entry['groupid'], 'group' => $entry['groupid'],
'reference' => $lootId < 0 ? abs($lootId) : 0, 'parentRef' => $tableName == LOOT_REFERENCE ? $lootId : 0,
'realChanceMod' => $baseChance 'realChanceMod' => $baseChance
); );
@@ -129,27 +129,26 @@ class Loot
'25man heroic '25man heroic
*/ */
if ($entry['mincountOrRef'] < 0) if ($entry['reference'])
{ {
// bandaid.. remove when propperly handling lootmodes // bandaid.. remove when propperly handling lootmodes
if (!in_array($entry['mincountOrRef'], $handledRefs)) if (!in_array($entry['reference'], $handledRefs))
{ // todo (high): find out, why i used this in the first place. (don't do drugs, kids) { // todo (high): find out, why i used this in the first place. (don't do drugs, kids)
list($data, $raw) = self::getByContainerRecursive(LOOT_REFERENCE, $entry['mincountOrRef'], $handledRefs, /*$entry['groupid'],*/ 0, abs($entry['ChanceOrQuestChance'] / 100)); list($data, $raw) = self::getByContainerRecursive(LOOT_REFERENCE, $entry['reference'], $handledRefs, /*$entry['groupid'],*/ 0, $entry['chance'] / 100);
$handledRefs[] = $entry['mincountOrRef']; $handledRefs[] = $entry['reference'];
$loot = array_merge($loot, $data); $loot = array_merge($loot, $data);
$rawItems = array_merge($rawItems, $raw); $rawItems = array_merge($rawItems, $raw);
} }
$set['reference'] = $entry['reference'];
$set['content'] = $entry['mincountOrRef'];
$set['multiplier'] = $entry['maxcount']; $set['multiplier'] = $entry['maxcount'];
} }
else else
{ {
$rawItems[] = $entry['item']; $rawItems[] = $entry['item'];
$set['content'] = $entry['item']; $set['content'] = $entry['item'];
$set['min'] = $entry['mincountOrRef']; $set['min'] = $entry['mincount'];
$set['max'] = $entry['maxcount']; $set['max'] = $entry['maxcount'];
} }
@@ -160,16 +159,16 @@ class Loot
} }
if ($set['quest'] || !$set['group']) if ($set['quest'] || !$set['group'])
$set['groupChance'] = abs($entry['ChanceOrQuestChance']); $set['groupChance'] = $entry['chance'];
else if ($entry['groupid'] && !$entry['ChanceOrQuestChance']) else if ($entry['groupid'] && !$entry['chance'])
{ {
$nGroupEquals[$entry['groupid']]++; $nGroupEquals[$entry['groupid']]++;
$set['groupChance'] = &$groupChances[$entry['groupid']]; $set['groupChance'] = &$groupChances[$entry['groupid']];
} }
else if ($entry['groupid'] && $entry['ChanceOrQuestChance']) else if ($entry['groupid'] && $entry['chance'])
{ {
@$groupChances[$entry['groupid']] += $entry['ChanceOrQuestChance']; @$groupChances[$entry['groupid']] += $entry['chance'];
$set['groupChance'] = abs($entry['ChanceOrQuestChance']); $set['groupChance'] = $entry['chance'];
} }
else // shouldn't have happened else // shouldn't have happened
{ {
@@ -239,13 +238,13 @@ class Loot
if ($_ = $loot['mode']) if ($_ = $loot['mode'])
$base['mode'] = $_; $base['mode'] = $_;
if ($_ = $loot['reference']) if ($_ = $loot['parentRef'])
$base['reference'] = $_; $base['reference'] = $_;
if ($_ = self::createStack($loot)) if ($_ = self::createStack($loot))
$base['pctstack'] = $_; $base['pctstack'] = $_;
if ($loot['content'] > 0) // regular drop if (empty($loot['reference'])) // regular drop
{ {
if (!User::isInGroup(U_GROUP_EMPLOYEE)) if (!User::isInGroup(U_GROUP_EMPLOYEE))
{ {
@@ -260,14 +259,14 @@ class Loot
else if (User::isInGroup(U_GROUP_EMPLOYEE)) // create dummy for ref-drop else if (User::isInGroup(U_GROUP_EMPLOYEE)) // create dummy for ref-drop
{ {
$data = array( $data = array(
'id' => $loot['content'], 'id' => $loot['reference'],
'name' => '@REFERENCE: '.abs($loot['content']), 'name' => '@REFERENCE: '.$loot['reference'],
'icon' => 'trade_engineering', 'icon' => 'trade_engineering',
'stack' => [$loot['multiplier'], $loot['multiplier']] 'stack' => [$loot['multiplier'], $loot['multiplier']]
); );
$this->results[] = array_merge($base, $data); $this->results[] = array_merge($base, $data);
$this->jsGlobals[TYPE_ITEM][$loot['content']] = $data; $this->jsGlobals[TYPE_ITEM][$loot['reference']] = $data;
} }
} }
@@ -348,22 +347,22 @@ class Loot
$refResults = []; $refResults = [];
$chanceMods = []; $chanceMods = [];
$query = 'SELECT $query = 'SELECT
-lt1.entry AS ARRAY_KEY, lt1.entry AS ARRAY_KEY,
IF(lt1.mincountOrRef > 0, lt1.item, lt1.mincountOrRef) AS item, IF(lt1.reference = 0, lt1.item, lt1.reference) AS item,
lt1.ChanceOrQuestChance AS chance, lt1.chance,
SUM(IF(lt2.ChanceOrQuestChance = 0, 1, 0)) AS nZeroItems, SUM(IF(lt2.chance = 0, 1, 0)) AS nZeroItems,
SUM(IF(lt2.ChanceOrQuestChance > 0, lt2.ChanceOrQuestChance, 0)) AS sumChance, SUM(lt2.chance) AS sumChance,
IF(lt1.groupid > 0, 1, 0) AS isGrouped, IF(lt1.groupid > 0, 1, 0) AS isGrouped,
IF(lt1.mincountOrRef > 0, lt1.mincountOrRef, 1) AS min, IF(lt1.reference = 0, lt1.mincount, 1) AS min,
IF(lt1.mincountOrRef > 0, lt1.maxcount, 1) AS max, IF(lt1.reference = 0, lt1.maxcount, 1) AS max,
IF(lt1.mincountOrRef < 0, lt1.maxcount, 1) AS multiplier IF(lt1.reference > 0, lt1.maxcount, 1) AS multiplier
FROM FROM
?# lt1 ?# lt1
LEFT JOIN LEFT JOIN
?# lt2 ON lt1.entry = lt2.entry AND lt1.groupid = lt2.groupid ?# lt2 ON lt1.entry = lt2.entry AND lt1.groupid = lt2.groupid
WHERE WHERE
%s %s
GROUP BY lt2.entry'; GROUP BY lt2.entry, lt2.groupid';
$calcChance = function ($refs, $parents = []) use (&$chanceMods) $calcChance = function ($refs, $parents = []) use (&$chanceMods)
{ {
@@ -424,7 +423,7 @@ class Loot
get references containing the item get references containing the item
*/ */
$newRefs = DB::Aowow()->select( $newRefs = DB::Aowow()->select(
sprintf($query, 'lt1.item = ?d AND lt1.mincountOrRef > 0'), sprintf($query, 'lt1.item = ?d AND lt1.reference = 0'),
LOOT_REFERENCE, LOOT_REFERENCE, LOOT_REFERENCE, LOOT_REFERENCE,
$this->entry $this->entry
); );
@@ -433,7 +432,7 @@ class Loot
{ {
$curRefs = $newRefs; $curRefs = $newRefs;
$newRefs = DB::Aowow()->select( $newRefs = DB::Aowow()->select(
sprintf($query, 'lt1.mincountOrRef IN (?a)'), sprintf($query, 'lt1.reference IN (?a)'),
LOOT_REFERENCE, LOOT_REFERENCE, LOOT_REFERENCE, LOOT_REFERENCE,
array_keys($curRefs) array_keys($curRefs)
); );
@@ -447,7 +446,7 @@ class Loot
for ($i = 1; $i < count($this->lootTemplates); $i++) for ($i = 1; $i < count($this->lootTemplates); $i++)
{ {
$result = $calcChance(DB::Aowow()->select( $result = $calcChance(DB::Aowow()->select(
sprintf($query, '{lt1.mincountOrRef IN (?a) OR }(lt1.mincountOrRef > 0 AND lt1.item = ?d)'), sprintf($query, '{lt1.reference IN (?a) OR }(lt1.reference = 0 AND lt1.item = ?d)'),
$this->lootTemplates[$i], $this->lootTemplates[$i], $this->lootTemplates[$i], $this->lootTemplates[$i],
$refResults ? array_keys($refResults) : DBSIMPLE_SKIP, $refResults ? array_keys($refResults) : DBSIMPLE_SKIP,
$this->entry $this->entry
@@ -487,9 +486,9 @@ class Loot
$srcData = $srcObj->getListviewData(); $srcData = $srcObj->getListviewData();
foreach ($srcObj->iterate() as $curTpl) foreach ($srcObj->iterate() as $__id => $curTpl)
{ {
switch ($curTpl['type']) switch ($curTpl['typeCat'])
{ {
case 25: $tabId = 15; break; // fishing node case 25: $tabId = 15; break; // fishing node
case -3: $tabId = 14; break; // herb case -3: $tabId = 14; break; // herb

View File

@@ -86,7 +86,8 @@ class User
if ($query['avatar']) if ($query['avatar'])
self::$avatar = $query['avatar']; self::$avatar = $query['avatar'];
self::setLocale(intVal($query['locale'])); // reset, if changed if (self::$localeId != $query['locale']) // reset, if changed
self::setLocale(intVal($query['locale']));
// stuff, that updates on a daily basis goes here (if you keep you session alive indefinitly, the signin-handler doesn't do very much) // stuff, that updates on a daily basis goes here (if you keep you session alive indefinitly, the signin-handler doesn't do very much)
// - conscutive visits // - conscutive visits

View File

@@ -58,12 +58,15 @@ class EventsPage extends GenericPage
'params' => [] 'params' => []
); );
if ($_ = array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}))
{
$this->lvTabs[] = array( $this->lvTabs[] = array(
'file' => 'calendar', 'file' => 'calendar',
'data' => array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}), 'data' => $_,
'params' => ['hideCount' => 1] 'params' => ['hideCount' => 1]
); );
} }
}
protected function generateTitle() protected function generateTitle()
{ {

View File

@@ -457,13 +457,14 @@ class ItemPage extends genericPage
if ($lootTab->getByContainer($sf[0], $sf[1])) if ($lootTab->getByContainer($sf[0], $sf[1]))
{ {
$this->extendGlobalData($lootTab->jsGlobals); $this->extendGlobalData($lootTab->jsGlobals);
$sf[4] = array_merge($sf[4], $lootTab->extraCols);
foreach ($lootTab->iterate() as $lv) foreach ($lootTab->iterate() as $lv)
{ {
if (!$lv['quest']) if (!$lv['quest'])
continue; continue;
$sf[4] = array_merge($sf[4], $lootTab->extraCols, ['Listview.extraCols.condition']); $sf[4] = array_merge($sf[4], ['Listview.extraCols.condition']);
$reqQuest[$lv['id']] = 0; $reqQuest[$lv['id']] = 0;

View File

@@ -478,13 +478,13 @@ class NpcPage extends GenericPage
} }
// tabs: this creature contains.. // tabs: this creature contains..
$skinTab = ['tab_skinning', 'skinned-from']; $skinTab = ['tab_skinning', 'skinning'];
if ($_typeFlags & NPC_TYPEFLAG_HERBLOOT) if ($_typeFlags & NPC_TYPEFLAG_HERBLOOT)
$skinTab = ['tab_gatheredfromnpc', 'gathered-from-npc']; $skinTab = ['tab_herbalism', 'herbalism'];
else if ($_typeFlags & NPC_TYPEFLAG_MININGLOOT) else if ($_typeFlags & NPC_TYPEFLAG_MININGLOOT)
$skinTab = ['tab_minedfromnpc', 'mined-from-npc']; $skinTab = ['tab_mining', 'mining'];
else if ($_typeFlags & NPC_TYPEFLAG_ENGINEERLOOT) else if ($_typeFlags & NPC_TYPEFLAG_ENGINEERLOOT)
$skinTab = ['tab_salvagedfrom', 'salvaged-from-npc']; $skinTab = ['tab_engineering', 'engineering'];
/* /*
extraCols: [Listview.extraCols.count, Listview.extraCols.percent, Listview.extraCols.mode], extraCols: [Listview.extraCols.count, Listview.extraCols.percent, Listview.extraCols.mode],

View File

@@ -130,28 +130,17 @@ if ($scList)
} }
if (fWrite($dest, $content)) if (fWrite($dest, $content))
{
fClose($dest);
$log[] = [time(), sprintf(ERR_NONE, $destPath.$file)]; $log[] = [time(), sprintf(ERR_NONE, $destPath.$file)];
}
else else
{
$log[] = [time(), sprintf(ERR_WRITE_FILE, $destPath.$file)]; $log[] = [time(), sprintf(ERR_WRITE_FILE, $destPath.$file)];
fClose($dest); fClose($dest);
continue;
}
} }
else else
{
$log[] = [time(), sprintf(ERR_CREATE_FILE, $destPath.$file)]; $log[] = [time(), sprintf(ERR_CREATE_FILE, $destPath.$file)];
continue;
}
} }
else else
{
$log[] = [time(), sprintf(ERR_READ_FILE, $tplPath.$file.'.in')]; $log[] = [time(), sprintf(ERR_READ_FILE, $tplPath.$file.'.in')];
continue;
}
} }
// files without template // files without template

View File

@@ -10136,7 +10136,7 @@ Listview.templates = {
], ],
getItemLink: function(item) { getItemLink: function(item) {
return item.id > 0 ? '?item=' + item.id : 'javascript:;'; return item.name.charAt(0) == '@' ? 'javascript:;' : '?item=' + item.id;
}, },
onBeforeCreate: function() { onBeforeCreate: function() {