diff --git a/setup/tools/sqlgen/creature.func.php b/setup/tools/sqlgen/creature.func.php index ac216555..ab94aea9 100644 --- a/setup/tools/sqlgen/creature.func.php +++ b/setup/tools/sqlgen/creature.func.php @@ -120,15 +120,14 @@ SqlGen::register(new class extends SetupScript creature_template_resistance ctr5 ON ct.entry = ctr5.CreatureID AND ctr5.School = 5 LEFT JOIN creature_template_resistance ctr6 ON ct.entry = ctr6.CreatureID AND ctr6.School = 6 - WHERE - ct.entry > ?d { - AND ct.entry IN (?a) + WHERE + ct.entry IN (?a) } ORDER BY ct.entry ASC LIMIT - ?d'; + ?d, ?d'; $dummyQuery = ' UPDATE @@ -157,14 +156,10 @@ SqlGen::register(new class extends SetupScript c.iconString = cdi.iconString, c.humanoid = IF(cdie.id IS NULL, 0, 1)'; - $lastMax = 0; - while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) + $i = 0; + while ($npcs = DB::World()->select($baseQuery, NPC_CU_INSTANCE_BOSS, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize)) { - $newMax = max(array_column($npcs, 'entry')); - - CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); - - $lastMax = $newMax; + CLI::write(' * batch #' . ++$i . ' (' . count($npcs) . ')'); foreach ($npcs as $npc) DB::Aowow()->query('REPLACE INTO ?_creature VALUES (?a)', array_values($npc)); diff --git a/setup/tools/sqlgen/items.func.php b/setup/tools/sqlgen/items.func.php index ba98c1ad..aa1444a2 100644 --- a/setup/tools/sqlgen/items.func.php +++ b/setup/tools/sqlgen/items.func.php @@ -131,24 +131,19 @@ SqlGen::register(new class extends SetupScript spell_group sg ON sg.spell_id = it.spellid_1 AND it.class = 0 AND it.subclass = 2 AND sg.id IN (1, 2) LEFT JOIN game_event ge ON ge.holiday = it.HolidayId AND it.HolidayId > 0 - WHERE - it.entry > ?d { - AND it.entry IN (?a) + WHERE + it.entry IN (?a) } ORDER BY it.entry ASC LIMIT - ?d'; + ?d, ?d'; - $lastMax = 0; - while ($items = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) + $i = 0; + while ($items = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize)) { - $newMax = max(array_column($items, 'entry')); - - CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); - - $lastMax = $newMax; + CLI::write(' * batch #' . ++$i . ' (' . count($items) . ')'); foreach ($items as $item) DB::Aowow()->query('REPLACE INTO ?_items VALUES (?a)', array_values($item)); diff --git a/setup/tools/sqlgen/objects.func.php b/setup/tools/sqlgen/objects.func.php index fd17074a..fe99ea4f 100644 --- a/setup/tools/sqlgen/objects.func.php +++ b/setup/tools/sqlgen/objects.func.php @@ -76,17 +76,16 @@ SqlGen::register(new class extends SetupScript gameobject_template_locale gtl8 ON go.entry = gtl8.entry AND gtl8.`locale` = "ruRU" LEFT JOIN gameobject_questitem gqi ON gqi.GameObjectEntry = go.entry - WHERE - go.entry > ?d { - AND go.entry IN (?a) + WHERE + go.entry IN (?a) } GROUP BY go.entry ORDER BY go.entry ASC LIMIT - ?d'; + ?d, ?d'; $updateQuery = ' UPDATE @@ -104,17 +103,13 @@ SqlGen::register(new class extends SetupScript o.id IN (?a) }'; - $lastMax = 0; - while ($objects = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) + $i = 0; + while ($objects = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize)) { - $newMax = max(array_column($objects, 'entry')); + CLI::write(' * batch #' . ++$i . ' (' . count($objects) . ')'); - CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); - - $lastMax = $newMax; - - foreach ($objects as $o) - DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($o)); + foreach ($objects as $object) + DB::Aowow()->query('REPLACE INTO ?_objects VALUES (?a)', array_values($object)); } // apply typeCat and reqSkill depending on locks diff --git a/setup/tools/sqlgen/quests.func.php b/setup/tools/sqlgen/quests.func.php index da6103d1..a3602004 100644 --- a/setup/tools/sqlgen/quests.func.php +++ b/setup/tools/sqlgen/quests.func.php @@ -129,15 +129,14 @@ SqlGen::register(new class extends SetupScript game_event_seasonal_questrelation gesqr ON gesqr.questId = q.ID LEFT JOIN disables d ON d.entry = q.ID AND d.sourceType = 1 - WHERE - q.id > ?d { - AND q.id IN (?a) + WHERE + q.ID IN (?a) } ORDER BY q.ID ASC LIMIT - ?d'; + ?d, ?d'; $xpQuery = ' UPDATE @@ -171,17 +170,13 @@ SqlGen::register(new class extends SetupScript }'; - $lastMax = 0; - while ($quests = DB::World()->select($baseQuery, $lastMax, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize)) + $i = 0; + while ($quests = DB::World()->select($baseQuery, $ids ?: DBSIMPLE_SKIP, SqlGen::$sqlBatchSize * $i, SqlGen::$sqlBatchSize)) { - $newMax = max(array_column($quests, 'ID')); + CLI::write(' * batch #' . ++$i . ' (' . count($quests) . ')'); - CLI::write(' * sets '.($lastMax + 1).' - '.$newMax); - - $lastMax = $newMax; - - foreach ($quests as $q) - DB::Aowow()->query('REPLACE INTO ?_quests VALUES (?a)', array_values($q)); + foreach ($quests as $quest) + DB::Aowow()->query('REPLACE INTO ?_quests VALUES (?a)', array_values($quest)); } /*