From efcfaf2c6e28a48c159a4ace48019ebab3f1033e Mon Sep 17 00:00:00 2001 From: Sanasol Date: Mon, 8 Apr 2019 02:08:11 +0300 Subject: [PATCH] Fixes #180 renewal mob_db tables usage --- modules/item/view.php | 54 ++++++++++++++++++++----------------- modules/logdata/feeding.php | 6 ++++- modules/logdata/pick.php | 24 ++++++++++------- modules/logdata/zeny.php | 26 ++++++++++-------- 4 files changed, 63 insertions(+), 47 deletions(-) diff --git a/modules/item/view.php b/modules/item/view.php index cbd8c320..b1ed425e 100644 --- a/modules/item/view.php +++ b/modules/item/view.php @@ -45,19 +45,23 @@ if ($item) { $title = "Viewing Item ($item->name)"; $isCustom = (bool)preg_match('/item_db2$/', $item->origin_table); - + if($server->isRenewal) { $item = $this->itemFieldExplode($item, 'attack', ':', array('attack','matk')); $item = $this->itemFieldExplode($item, 'equip_level_min', ':', array('equip_level_min','equip_level_max')); } - + $mobDB = "{$server->charMapDatabase}.monsters"; - $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + if($server->isRenewal) { + $fromTables = array("{$server->charMapDatabase}.mob_db_re", "{$server->charMapDatabase}.mob_db2_re"); + } else { + $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + } $mobTable = new Flux_TemporaryTable($server->connection, $mobDB, $fromTables); - + $col = 'ID AS monster_id, iName AS monster_name, LV AS monster_level, '; $col .= 'Race AS monster_race, (Element%10) AS monster_element, (Element/20) AS monster_ele_lv, MEXP AS mvp_exp, '; - + // Normal drops. $col .= 'Drop1id AS drop1_id, Drop1per AS drop1_chance, '; $col .= 'Drop2id AS drop2_id, Drop2per AS drop2_chance, '; @@ -68,17 +72,17 @@ $col .= 'Drop7id AS drop7_id, Drop7per AS drop7_chance, '; $col .= 'Drop8id AS drop8_id, Drop8per AS drop8_chance, '; $col .= 'Drop9id AS drop9_id, Drop9per AS drop9_chance, '; - + // Card drops. $col .= 'DropCardid AS dropcard_id, DropCardper AS dropcard_chance, '; - + // MVP rewards. $col .= 'MVP1id AS mvpdrop1_id, MVP1per AS mvpdrop1_chance, '; $col .= 'MVP2id AS mvpdrop2_id, MVP2per AS mvpdrop2_chance, '; $col .= 'MVP3id AS mvpdrop3_id, MVP3per AS mvpdrop3_chance'; - + $sql = "SELECT $col FROM $mobDB WHERE "; - + // Normal drops. $sql .= 'Drop1id = ? OR '; $sql .= 'Drop2id = ? OR '; @@ -89,40 +93,40 @@ $sql .= 'Drop7id = ? OR '; $sql .= 'Drop8id = ? OR '; $sql .= 'Drop9id = ? OR '; - + // Card drops. $sql .= 'DropCardid = ? OR '; - + // MVP rewards. $sql .= 'MVP1id = ? OR '; $sql .= 'MVP2id = ? OR '; $sql .= 'MVP3id = ? '; - + $sth = $server->connection->getStatement($sql); $res = $sth->execute(array_fill(0, 13, $itemID)); - + $dropResults = $sth->fetchAll(); $itemDrops = array(); $dropNames = array( 'drop1', 'drop2', 'drop3', 'drop4', 'drop5', 'drop6', 'drop7', 'drop8', 'drop9', 'dropcard', 'mvpdrop1', 'mvpdrop2', 'mvpdrop3' ); - + // Sort callback. function __tmpSortDrops($arr1, $arr2) { if ($arr1['drop_chance'] == $arr2['drop_chance']) { return strcmp($arr1['monster_name'], $arr2['monster_name']); } - + return $arr1['drop_chance'] < $arr2['drop_chance'] ? 1 : -1; } - + foreach ($dropResults as $drop) { foreach ($dropNames as $dropName) { $dropID = $drop->{$dropName.'_id'}; $dropChance = $drop->{$dropName.'_chance'}; - + if ($dropID == $itemID) { $dropArray = array( 'monster_id' => $drop->monster_id, @@ -134,7 +138,7 @@ function __tmpSortDrops($arr1, $arr2) 'drop_id' => $itemID, 'drop_chance' => $dropChance ); - + if (preg_match('/^dropcard/', $dropName)) { $adjust = ($drop->mvp_exp) ? $server->dropRates['CardBoss'] : $server->dropRates['Card']; $dropArray['type'] = 'card'; @@ -148,37 +152,37 @@ function __tmpSortDrops($arr1, $arr2) case 0: // Healing $adjust = ($drop->mvp_exp) ? $server->dropRates['HealBoss'] : $server->dropRates['Heal']; break; - + case 2: // Useable case 18: // Cash Useable $adjust = ($drop->mvp_exp) ? $server->dropRates['UseableBoss'] : $server->dropRates['Useable']; break; - + case 4: // Weapon case 5: // Armor case 8: // Pet Armor $adjust = ($drop->mvp_exp) ? $server->dropRates['EquipBoss'] : $server->dropRates['Equip']; break; - + default: // Common $adjust = ($drop->mvp_exp) ? $server->dropRates['CommonBoss'] : $server->dropRates['Common']; break; } - + $dropArray['type'] = 'normal'; } - + $dropArray['drop_chance'] = $dropArray['drop_chance'] * $adjust / 10000; if ($dropArray['drop_chance'] > 100) { $dropArray['drop_chance'] = 100; } - + $itemDrops[] = $dropArray; } } } - + // Sort so that monsters are ordered by drop chance and name. usort($itemDrops, '__tmpSortDrops'); } diff --git a/modules/logdata/feeding.php b/modules/logdata/feeding.php index dd3ab9df..6951487e 100644 --- a/modules/logdata/feeding.php +++ b/modules/logdata/feeding.php @@ -143,7 +143,11 @@ if ($mobIDs) { $mobDB = "{$server->charMapDatabase}.monsters"; - $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + if($server->isRenewal) { + $fromTables = array("{$server->charMapDatabase}.mob_db_re", "{$server->charMapDatabase}.mob_db2_re"); + } else { + $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + } $tempMobs = new Flux_TemporaryTable($server->connection, $mobDB, $fromTables); $ids = array_keys($mobIDs); diff --git a/modules/logdata/pick.php b/modules/logdata/pick.php index 541c45c2..7ce75925 100644 --- a/modules/logdata/pick.php +++ b/modules/logdata/pick.php @@ -25,17 +25,17 @@ $itemIDs = array(); $mobIDs = array(); $pickTypes = Flux::config('PickTypes'); - + foreach ($picks as $pick) { $itemIDs[$pick->nameid] = null; - + if ($pick->type == 'M' || $pick->type == 'L') { $mobIDs[$pick->char_id] = null; } else { $charIDs[$pick->char_id] = null; } - + if ($pick->card0) { $itemIDs[$pick->card0] = null; } @@ -48,10 +48,10 @@ if ($pick->card3) { $itemIDs[$pick->card3] = null; } - + $pick->pick_type = $pickTypes->get($pick->type); } - + if ($charIDs) { $ids = array_keys($charIDs); $sql = "SELECT char_id, name FROM {$server->charMapDatabase}.`char` WHERE char_id IN (".implode(',', array_fill(0, count($ids), '?')).")"; @@ -65,12 +65,16 @@ $charIDs[$id->char_id] = $id->name; } } - + require_once 'Flux/TemporaryTable.php'; - + if ($mobIDs) { $mobDB = "{$server->charMapDatabase}.monsters"; - $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + if($server->isRenewal) { + $fromTables = array("{$server->charMapDatabase}.mob_db_re", "{$server->charMapDatabase}.mob_db2_re"); + } else { + $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + } $tempMobs = new Flux_TemporaryTable($server->connection, $mobDB, $fromTables); $ids = array_keys($mobIDs); @@ -108,7 +112,7 @@ $itemIDs[$id->id] = $id->name_japanese; } } - + foreach ($picks as $pick) { if (($pick->type == 'M' || $pick->type == 'L') && array_key_exists($pick->char_id, $mobIDs)) { $pick->char_name = $mobIDs[$pick->char_id]; @@ -116,7 +120,7 @@ elseif (array_key_exists($pick->char_id, $charIDs)) { $pick->char_name = $charIDs[$pick->char_id]; } - + if (array_key_exists($pick->nameid, $itemIDs)) { $pick->item_name = $itemIDs[$pick->nameid]; } diff --git a/modules/logdata/zeny.php b/modules/logdata/zeny.php index cca8f19a..cfaf026e 100644 --- a/modules/logdata/zeny.php +++ b/modules/logdata/zeny.php @@ -22,29 +22,29 @@ $srcIDs = array(); $mobIDs = array(); $pickTypes = Flux::config('PickTypes'); - + foreach ($logs as $log) { $charIDs[$log->char_id] = null; - + if ($log->type == 'M') { $mobIDs[$log->src_id] = null; } else { $srcIDs[$log->src_id] = null; } - + $log->pick_type = $pickTypes->get($log->type); } - + if ($charIDs || $srcIDs) { $charKeys = array_keys($charIDs); $srcKeys = array_keys($srcIDs); - + $sql = "SELECT char_id, name FROM {$server->charMapDatabase}.`char` "; $sql .= "WHERE char_id IN (".implode(',', array_fill(0, count($charKeys) + count($srcKeys), '?')).")"; $sth = $server->connection->getStatement($sql); $sth->execute(array_merge($charKeys, $srcKeys)); - + $ids = $sth->fetchAll(); // Map char_id to name. @@ -57,12 +57,16 @@ } } } - + require_once 'Flux/TemporaryTable.php'; - + if ($mobIDs) { $mobDB = "{$server->charMapDatabase}.monsters"; - $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + if($server->isRenewal) { + $fromTables = array("{$server->charMapDatabase}.mob_db_re", "{$server->charMapDatabase}.mob_db2_re"); + } else { + $fromTables = array("{$server->charMapDatabase}.mob_db", "{$server->charMapDatabase}.mob_db2"); + } $tempMobs = new Flux_TemporaryTable($server->connection, $mobDB, $fromTables); $ids = array_keys($mobIDs); @@ -77,12 +81,12 @@ $mobIDs[$id->ID] = $id->iName; } } - + foreach ($logs as $log) { if (array_key_exists($log->char_id, $charIDs)) { $log->char_name = $charIDs[$log->char_id]; } - + if (($log->type == 'M') && array_key_exists($log->src_id, $mobIDs)) { $log->src_name = $mobIDs[$log->char_id]; }