mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
- 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:
@@ -15,7 +15,7 @@ if (!defined('AOWOW_REVISION'))
|
||||
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
|
||||
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
|
||||
@@ -89,7 +89,7 @@ class Loot
|
||||
if (!$tableName || !$lootId)
|
||||
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)
|
||||
return null;
|
||||
|
||||
@@ -98,9 +98,9 @@ class Loot
|
||||
foreach ($rows as $entry)
|
||||
{
|
||||
$set = array(
|
||||
'quest' => $entry['ChanceOrQuestChance'] < 0,
|
||||
'quest' => $entry['needsquest'],
|
||||
'group' => $entry['groupid'],
|
||||
'reference' => $lootId < 0 ? abs($lootId) : 0,
|
||||
'parentRef' => $tableName == LOOT_REFERENCE ? $lootId : 0,
|
||||
'realChanceMod' => $baseChance
|
||||
);
|
||||
|
||||
@@ -129,27 +129,26 @@ class Loot
|
||||
'25man heroic
|
||||
*/
|
||||
|
||||
if ($entry['mincountOrRef'] < 0)
|
||||
if ($entry['reference'])
|
||||
{
|
||||
// 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)
|
||||
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);
|
||||
$rawItems = array_merge($rawItems, $raw);
|
||||
}
|
||||
|
||||
$set['content'] = $entry['mincountOrRef'];
|
||||
$set['reference'] = $entry['reference'];
|
||||
$set['multiplier'] = $entry['maxcount'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$rawItems[] = $entry['item'];
|
||||
$set['content'] = $entry['item'];
|
||||
$set['min'] = $entry['mincountOrRef'];
|
||||
$set['min'] = $entry['mincount'];
|
||||
$set['max'] = $entry['maxcount'];
|
||||
}
|
||||
|
||||
@@ -160,16 +159,16 @@ class Loot
|
||||
}
|
||||
|
||||
if ($set['quest'] || !$set['group'])
|
||||
$set['groupChance'] = abs($entry['ChanceOrQuestChance']);
|
||||
else if ($entry['groupid'] && !$entry['ChanceOrQuestChance'])
|
||||
$set['groupChance'] = $entry['chance'];
|
||||
else if ($entry['groupid'] && !$entry['chance'])
|
||||
{
|
||||
$nGroupEquals[$entry['groupid']]++;
|
||||
$set['groupChance'] = &$groupChances[$entry['groupid']];
|
||||
}
|
||||
else if ($entry['groupid'] && $entry['ChanceOrQuestChance'])
|
||||
else if ($entry['groupid'] && $entry['chance'])
|
||||
{
|
||||
@$groupChances[$entry['groupid']] += $entry['ChanceOrQuestChance'];
|
||||
$set['groupChance'] = abs($entry['ChanceOrQuestChance']);
|
||||
@$groupChances[$entry['groupid']] += $entry['chance'];
|
||||
$set['groupChance'] = $entry['chance'];
|
||||
}
|
||||
else // shouldn't have happened
|
||||
{
|
||||
@@ -239,13 +238,13 @@ class Loot
|
||||
if ($_ = $loot['mode'])
|
||||
$base['mode'] = $_;
|
||||
|
||||
if ($_ = $loot['reference'])
|
||||
if ($_ = $loot['parentRef'])
|
||||
$base['reference'] = $_;
|
||||
|
||||
if ($_ = self::createStack($loot))
|
||||
$base['pctstack'] = $_;
|
||||
|
||||
if ($loot['content'] > 0) // regular drop
|
||||
if (empty($loot['reference'])) // regular drop
|
||||
{
|
||||
if (!User::isInGroup(U_GROUP_EMPLOYEE))
|
||||
{
|
||||
@@ -260,14 +259,14 @@ class Loot
|
||||
else if (User::isInGroup(U_GROUP_EMPLOYEE)) // create dummy for ref-drop
|
||||
{
|
||||
$data = array(
|
||||
'id' => $loot['content'],
|
||||
'name' => '@REFERENCE: '.abs($loot['content']),
|
||||
'id' => $loot['reference'],
|
||||
'name' => '@REFERENCE: '.$loot['reference'],
|
||||
'icon' => 'trade_engineering',
|
||||
'stack' => [$loot['multiplier'], $loot['multiplier']]
|
||||
);
|
||||
$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 = [];
|
||||
$chanceMods = [];
|
||||
$query = 'SELECT
|
||||
-lt1.entry AS ARRAY_KEY,
|
||||
IF(lt1.mincountOrRef > 0, lt1.item, lt1.mincountOrRef) AS item,
|
||||
lt1.ChanceOrQuestChance AS chance,
|
||||
SUM(IF(lt2.ChanceOrQuestChance = 0, 1, 0)) AS nZeroItems,
|
||||
SUM(IF(lt2.ChanceOrQuestChance > 0, lt2.ChanceOrQuestChance, 0)) AS sumChance,
|
||||
lt1.entry AS ARRAY_KEY,
|
||||
IF(lt1.reference = 0, lt1.item, lt1.reference) AS item,
|
||||
lt1.chance,
|
||||
SUM(IF(lt2.chance = 0, 1, 0)) AS nZeroItems,
|
||||
SUM(lt2.chance) AS sumChance,
|
||||
IF(lt1.groupid > 0, 1, 0) AS isGrouped,
|
||||
IF(lt1.mincountOrRef > 0, lt1.mincountOrRef, 1) AS min,
|
||||
IF(lt1.mincountOrRef > 0, lt1.maxcount, 1) AS max,
|
||||
IF(lt1.mincountOrRef < 0, lt1.maxcount, 1) AS multiplier
|
||||
IF(lt1.reference = 0, lt1.mincount, 1) AS min,
|
||||
IF(lt1.reference = 0, lt1.maxcount, 1) AS max,
|
||||
IF(lt1.reference > 0, lt1.maxcount, 1) AS multiplier
|
||||
FROM
|
||||
?# lt1
|
||||
LEFT JOIN
|
||||
?# lt2 ON lt1.entry = lt2.entry AND lt1.groupid = lt2.groupid
|
||||
WHERE
|
||||
%s
|
||||
GROUP BY lt2.entry';
|
||||
GROUP BY lt2.entry, lt2.groupid';
|
||||
|
||||
$calcChance = function ($refs, $parents = []) use (&$chanceMods)
|
||||
{
|
||||
@@ -424,7 +423,7 @@ class Loot
|
||||
get references containing the item
|
||||
*/
|
||||
$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,
|
||||
$this->entry
|
||||
);
|
||||
@@ -433,7 +432,7 @@ class Loot
|
||||
{
|
||||
$curRefs = $newRefs;
|
||||
$newRefs = DB::Aowow()->select(
|
||||
sprintf($query, 'lt1.mincountOrRef IN (?a)'),
|
||||
sprintf($query, 'lt1.reference IN (?a)'),
|
||||
LOOT_REFERENCE, LOOT_REFERENCE,
|
||||
array_keys($curRefs)
|
||||
);
|
||||
@@ -447,7 +446,7 @@ class Loot
|
||||
for ($i = 1; $i < count($this->lootTemplates); $i++)
|
||||
{
|
||||
$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],
|
||||
$refResults ? array_keys($refResults) : DBSIMPLE_SKIP,
|
||||
$this->entry
|
||||
@@ -487,9 +486,9 @@ class Loot
|
||||
|
||||
$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 -3: $tabId = 14; break; // herb
|
||||
|
||||
@@ -86,7 +86,8 @@ class User
|
||||
if ($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)
|
||||
// - conscutive visits
|
||||
|
||||
@@ -58,11 +58,14 @@ class EventsPage extends GenericPage
|
||||
'params' => []
|
||||
);
|
||||
|
||||
$this->lvTabs[] = array(
|
||||
'file' => 'calendar',
|
||||
'data' => array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}),
|
||||
'params' => ['hideCount' => 1]
|
||||
);
|
||||
if ($_ = array_filter($events->getListviewData(), function($x) {return $x['id'] > 0;}))
|
||||
{
|
||||
$this->lvTabs[] = array(
|
||||
'file' => 'calendar',
|
||||
'data' => $_,
|
||||
'params' => ['hideCount' => 1]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateTitle()
|
||||
|
||||
@@ -457,13 +457,14 @@ class ItemPage extends genericPage
|
||||
if ($lootTab->getByContainer($sf[0], $sf[1]))
|
||||
{
|
||||
$this->extendGlobalData($lootTab->jsGlobals);
|
||||
$sf[4] = array_merge($sf[4], $lootTab->extraCols);
|
||||
|
||||
foreach ($lootTab->iterate() as $lv)
|
||||
{
|
||||
if (!$lv['quest'])
|
||||
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;
|
||||
|
||||
|
||||
@@ -478,13 +478,13 @@ class NpcPage extends GenericPage
|
||||
}
|
||||
|
||||
// tabs: this creature contains..
|
||||
$skinTab = ['tab_skinning', 'skinned-from'];
|
||||
$skinTab = ['tab_skinning', 'skinning'];
|
||||
if ($_typeFlags & NPC_TYPEFLAG_HERBLOOT)
|
||||
$skinTab = ['tab_gatheredfromnpc', 'gathered-from-npc'];
|
||||
$skinTab = ['tab_herbalism', 'herbalism'];
|
||||
else if ($_typeFlags & NPC_TYPEFLAG_MININGLOOT)
|
||||
$skinTab = ['tab_minedfromnpc', 'mined-from-npc'];
|
||||
$skinTab = ['tab_mining', 'mining'];
|
||||
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],
|
||||
|
||||
@@ -130,28 +130,17 @@ if ($scList)
|
||||
}
|
||||
|
||||
if (fWrite($dest, $content))
|
||||
{
|
||||
fClose($dest);
|
||||
$log[] = [time(), sprintf(ERR_NONE, $destPath.$file)];
|
||||
}
|
||||
else
|
||||
{
|
||||
$log[] = [time(), sprintf(ERR_WRITE_FILE, $destPath.$file)];
|
||||
fClose($dest);
|
||||
continue;
|
||||
}
|
||||
|
||||
fClose($dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
$log[] = [time(), sprintf(ERR_CREATE_FILE, $destPath.$file)];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$log[] = [time(), sprintf(ERR_READ_FILE, $tplPath.$file.'.in')];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// files without template
|
||||
|
||||
@@ -10136,7 +10136,7 @@ Listview.templates = {
|
||||
],
|
||||
|
||||
getItemLink: function(item) {
|
||||
return item.id > 0 ? '?item=' + item.id : 'javascript:;';
|
||||
return item.name.charAt(0) == '@' ? 'javascript:;' : '?item=' + item.id;
|
||||
},
|
||||
|
||||
onBeforeCreate: function() {
|
||||
|
||||
Reference in New Issue
Block a user