diff --git a/includes/profiler.class.php b/includes/profiler.class.php index b69ea012..8d0798f5 100644 --- a/includes/profiler.class.php +++ b/includes/profiler.class.php @@ -292,6 +292,8 @@ class Profiler CLI::write('fetching char #'.$charGuid.' from realm #'.$realmId); CLI::write('writing...'); + $ra = (1 << ($char['race'] - 1)); + $cl = (1 << ($char['class'] - 1)); /*************/ /* equipment */ @@ -478,7 +480,7 @@ class Profiler /* hunter pets */ /***************/ - if ((1 << ($char['class'] - 1)) == CLASS_HUNTER) + if ($cl == CLASS_HUNTER) { DB::Aowow()->query('DELETE FROM ?_profiler_pets WHERE owner = ?d', $profileId); $pets = DB::Characters($realmId)->select('SELECT id AS ARRAY_KEY, id, entry, modelId, name FROM character_pet WHERE owner = ?d', $charGuid); @@ -557,9 +559,44 @@ class Profiler // reputation - if ($reputation = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, faction AS typeId, standing AS cur FROM character_reputation WHERE guid = ?d AND (flags & 0xC) = 0', $profileId, TYPE_FACTION, $char['guid'])) - foreach (Util::createSqlBatchInsert($reputation) as $rep) - DB::Aowow()->query('INSERT INTO ?_profiler_completion (?#) VALUES '.$rep, array_keys($reputation[0])); + + // get base values for this race/class + $reputation = []; + $baseRep = DB::Aowow()->selectCol(' + SELECT id AS ARRAY_KEY, baseRepValue1 FROM aowow_factions WHERE baseRepValue1 && (baseRepRaceMask1 & ?d || (!baseRepRaceMask1 AND baseRepClassMask1)) && + ((baseRepClassMask1 & ?d) || !baseRepClassMask1) UNION + SELECT id AS ARRAY_KEY, baseRepValue2 FROM aowow_factions WHERE baseRepValue2 && (baseRepRaceMask2 & ?d || (!baseRepRaceMask2 AND baseRepClassMask2)) && + ((baseRepClassMask2 & ?d) || !baseRepClassMask2) UNION + SELECT id AS ARRAY_KEY, baseRepValue3 FROM aowow_factions WHERE baseRepValue3 && (baseRepRaceMask3 & ?d || (!baseRepRaceMask3 AND baseRepClassMask3)) && + ((baseRepClassMask3 & ?d) || !baseRepClassMask3) UNION + SELECT id AS ARRAY_KEY, baseRepValue4 FROM aowow_factions WHERE baseRepValue4 && (baseRepRaceMask4 & ?d || (!baseRepRaceMask4 AND baseRepClassMask4)) && + ((baseRepClassMask4 & ?d) || !baseRepClassMask4) + ', $ra, $cl, $ra, $cl, $ra, $cl, $ra, $cl); + + if ($reputation = DB::Characters($realmId)->select('SELECT ?d AS id, ?d AS `type`, faction AS typeId, standing AS cur FROM character_reputation WHERE guid = ?d AND (flags & 0x4) = 0', $profileId, TYPE_FACTION, $char['guid'])) + { + // merge back base values for encountered factions + foreach ($reputation as &$set) + { + if (empty($baseRep[$set['typeId']])) + continue; + + $set['cur'] += $baseRep[$set['typeId']]; + unset($baseRep[$set['typeId']]); + } + } + + // insert base values for not yet encountered factions + foreach ($baseRep as $id => $val) + $reputation[] = array( + 'id' => $profileId, + 'type' => TYPE_FACTION, + 'typeId' => $id, + 'cur' => $val + ); + + foreach (Util::createSqlBatchInsert($reputation) as $rep) + DB::Aowow()->query('INSERT INTO ?_profiler_completion (?#) VALUES '.$rep, array_keys($reputation[0])); CLI::write(' ..reputation'); diff --git a/index.php b/index.php index 66bc986c..4eaaa30b 100644 --- a/index.php +++ b/index.php @@ -108,7 +108,12 @@ switch ($pageCall) catch (Exception $e) // no, apparently not.. { $class = $cleanName.'Page'; - (new $class($pageCall, $pageParam))->display(); + if (is_callable([$class, 'display'])) + (new $class($pageCall, $pageParam))->display(); + else if (isset($_GET['power'])) + die('$WowheadPower.register(0, '.User::$localeId.', {})'); + else // in conjunction with a proper rewriteRule in .htaccess... + (new GenericPage($pageCall))->error(); } break; diff --git a/setup/db_structure.sql b/setup/db_structure.sql index 91ce43ee..12418617 100644 --- a/setup/db_structure.sql +++ b/setup/db_structure.sql @@ -769,6 +769,18 @@ DROP TABLE IF EXISTS `aowow_factions`; CREATE TABLE `aowow_factions` ( `id` smallint(5) unsigned NOT NULL, `repIdx` smallint(5) unsigned NOT NULL, + `baseRepRaceMask1` smallint(5) unsigned NOT NULL, + `baseRepRaceMask2` smallint(5) unsigned NOT NULL, + `baseRepRaceMask3` smallint(5) unsigned NOT NULL, + `baseRepRaceMask4` smallint(5) unsigned NOT NULL, + `baseRepClassMask1` smallint(5) unsigned NOT NULL, + `baseRepClassMask2` smallint(5) unsigned NOT NULL, + `baseRepClassMask3` smallint(5) unsigned NOT NULL, + `baseRepClassMask4` smallint(5) unsigned NOT NULL, + `baseRepValue1` mediumint(8) NOT NULL, + `baseRepValue2` mediumint(8) NOT NULL, + `baseRepValue4` mediumint(8) NOT NULL, + `baseRepValue3` mediumint(8) NOT NULL, `side` tinyint(1) unsigned NOT NULL, `expansion` tinyint(1) unsigned NOT NULL, `qmNpcIds` varchar(12) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'space separated', @@ -3021,7 +3033,7 @@ UNLOCK TABLES; LOCK TABLES `aowow_dbversion` WRITE; /*!40000 ALTER TABLE `aowow_dbversion` DISABLE KEYS */; -INSERT INTO `aowow_dbversion` VALUES (1522499481,0,NULL,NULL); +INSERT INTO `aowow_dbversion` VALUES (1522673572,0,NULL,NULL); /*!40000 ALTER TABLE `aowow_dbversion` ENABLE KEYS */; UNLOCK TABLES; diff --git a/setup/tools/dbc.class.php b/setup/tools/dbc.class.php index 5738a454..811549ad 100644 --- a/setup/tools/dbc.class.php +++ b/setup/tools/dbc.class.php @@ -65,7 +65,7 @@ class DBC 'emotestext' => 'nsiixxxixixxxxxxxxx', 'emotestextdata' => 'nsxssxxsxsxxxxxxxx', 'emotestextsound' => 'niiii', - 'faction' => 'nixxxxxxxxxxxxixxxiffixsxssxxsxsxxxxxxxxxxxxxxxxxxxxxxxxx', + 'faction' => 'niiiiiiiiiiiiiixxxiffixsxssxxsxsxxxxxxxxxxxxxxxxxxxxxxxxx', 'factiontemplate' => 'nixiiiiiiiiiii', 'gemproperties' => 'nixxi', 'glyphproperties' => 'niii', @@ -166,7 +166,7 @@ class DBC 'emotestext' => 'id,command,emoteId,targetId,noTargetId,selfId', 'emotestextsound' => 'id,emotesTextId,raceId,gender,soundId', 'emotestextdata' => 'id,text_loc0,text_loc2,text_loc3,text_loc6,text_loc8', - 'faction' => 'id,repIdx,repFlags1,parentFaction,spilloverRateIn,spilloverRateOut,spilloverMaxRank,name_loc0,name_loc2,name_loc3,name_loc6,name_loc8', + 'faction' => 'id,repIdx,baseRepRaceMask1,baseRepRaceMask2,baseRepRaceMask3,baseRepRaceMask4,baseRepClassMask1,baseRepClassMask2,baseRepClassMask3,baseRepClassMask4,baseRepValue1,baseRepValue2,baseRepValue3,baseRepValue4,repFlags1,parentFaction,spilloverRateIn,spilloverRateOut,spilloverMaxRank,name_loc0,name_loc2,name_loc3,name_loc6,name_loc8', 'factiontemplate' => 'id,factionId,ourMask,friendlyMask,hostileMask,enemyFactionId1,enemyFactionId2,enemyFactionId3,enemyFactionId4,friendFactionId1,friendFactionId2,friendFactionId3,friendFactionId4', 'gemproperties' => 'id,enchantmentId,colorMask', 'glyphproperties' => 'id,spellId,typeFlags,iconId', diff --git a/setup/tools/sqlgen/factions.func.php b/setup/tools/sqlgen/factions.func.php index 8f544310..1bd48974 100644 --- a/setup/tools/sqlgen/factions.func.php +++ b/setup/tools/sqlgen/factions.func.php @@ -53,6 +53,9 @@ function factions() SELECT f.id, f.repIdx, + baseRepRaceMask1, baseRepRaceMask2, baseRepRaceMask3, baseRepRaceMask4, + baseRepClassMask1, baseRepClassMask2, baseRepClassMask3, baseRepClassMask4, + baseRepValue1, baseRepValue2, baseRepValue3, baseRepValue4, IF(SUM(ft.ourMask & 0x6) / COUNT(1) = 0x4, 2, IF(SUM(ft.ourMask & 0x6) / COUNT(1) = 0x2, 1, 0)) as side, 0, -- expansion "", -- quartermasterNpcIds diff --git a/setup/updates/1522673571_01.sql b/setup/updates/1522673571_01.sql new file mode 100644 index 00000000..1f39b34a --- /dev/null +++ b/setup/updates/1522673571_01.sql @@ -0,0 +1,13 @@ +ALTER TABLE `aowow_factions` + ADD COLUMN `baseRepRaceMask1` SMALLINT(5) UNSIGNED NOT NULL AFTER `repIdx`, + ADD COLUMN `baseRepRaceMask2` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepRaceMask1`, + ADD COLUMN `baseRepRaceMask3` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepRaceMask2`, + ADD COLUMN `baseRepRaceMask4` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepRaceMask3`, + ADD COLUMN `baseRepClassMask1` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepRaceMask4`, + ADD COLUMN `baseRepClassMask2` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepClassMask1`, + ADD COLUMN `baseRepClassMask3` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepClassMask2`, + ADD COLUMN `baseRepClassMask4` SMALLINT(5) UNSIGNED NOT NULL AFTER `baseRepClassMask3`, + ADD COLUMN `baseRepValue1` MEDIUMINT NOT NULL AFTER `baseRepClassMask4`, + ADD COLUMN `baseRepValue2` MEDIUMINT NOT NULL AFTER `baseRepValue1`, + ADD COLUMN `baseRepValue3` MEDIUMINT NOT NULL AFTER `baseRepValue2`, + ADD COLUMN `baseRepValue4` MEDIUMINT NOT NULL AFTER `baseRepValue3`;