diff --git a/data/sql/updates/pending_db_world/rev_8337814054007982.sql b/data/sql/updates/pending_db_world/rev_8337814054007982.sql new file mode 100644 index 00000000000000..0ccc959240e029 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_8337814054007982.sql @@ -0,0 +1,25 @@ +-- Create creature_multispawn table for multi-ID spawning +CREATE TABLE IF NOT EXISTS `creature_multispawn` ( + `spawnId` int unsigned NOT NULL COMMENT 'creature.guid', + `entry` int unsigned NOT NULL COMMENT 'creature_template.entry', + PRIMARY KEY (`spawnId`, `entry`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Additional creature entries for multi-ID spawning'; + +-- Migrate id2 and id3 entries +DELETE FROM `creature_multispawn`; +INSERT IGNORE INTO `creature_multispawn` (`spawnId`, `entry`) +SELECT `guid`, `id2` FROM `creature` WHERE `id2` != 0 +UNION ALL +SELECT `guid`, `id3` FROM `creature` WHERE `id3` != 0; + +-- Drop old index before column rename +ALTER TABLE `creature` DROP INDEX `idx_id`; + +-- Rename id1 -> id +ALTER TABLE `creature` CHANGE COLUMN `id1` `id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Creature Identifier'; + +-- Drop id2, id3 +ALTER TABLE `creature` DROP COLUMN `id2`, DROP COLUMN `id3`; + +-- Recreate index on renamed column +ALTER TABLE `creature` ADD INDEX `idx_id` (`id`); diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp index 128c0c7c079ccb..ec1bfa00737821 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.cpp +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp @@ -80,15 +80,15 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_CREATURE_TEMPLATE, "SELECT entry, difficulty_entry_1, difficulty_entry_2, difficulty_entry_3, KillCredit1, KillCredit2, name, subname, IconName, gossip_menu_id, minlevel, maxlevel, exp, faction, npcflag, speed_walk, speed_run, speed_swim, speed_flight, detection_range, `rank`, dmgschool, DamageModifier, BaseAttackTime, RangeAttackTime, BaseVariance, RangeVariance, unit_class, unit_flags, unit_flags2, dynamicflags, family, type, type_flags, lootid, pickpocketloot, skinloot, PetSpellDataId, VehicleId, mingold, maxgold, AIName, MovementType, ctm.Ground, ctm.Swim, ctm.Flight, ctm.Rooted, ctm.Chase, ctm.Random, ctm.InteractionPauseTimer, HoverHeight, HealthModifier, ManaModifier, ArmorModifier, ExperienceModifier, RacialLeader, movementId, RegenHealth, CreatureImmunitiesId, flags_extra, ScriptName FROM creature_template ct LEFT JOIN creature_template_movement ctm ON ct.entry = ctm.CreatureId WHERE entry = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, "SELECT guid, delay, command, datalong, datalong2, dataint, x, y, z, o FROM waypoint_scripts WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME, "SELECT entry FROM item_template WHERE name = ?", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id1 = ? OR id2 = ? OR id3 = ?", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ? UNION SELECT spawnId AS guid FROM creature_multispawn WHERE entry = ?", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id1, id2, id3, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); - PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id1, id2, id3, map, spawnMask, phaseMask, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); + PrepareStatement(WORLD_SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? AND (phaseMask & ?) <> 0 ORDER BY order_", CONNECTION_SYNCH); + PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id, map, spawnMask, phaseMask, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_GAME_EVENTS, "SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_PREREQUISITE_DATA, "SELECT eventEntry, prerequisite_event FROM game_event_prerequisite", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_CREATURE_DATA, "SELECT guid, eventEntry FROM game_event_creature", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_DATA, "SELECT guid, eventEntry FROM game_event_gameobject", CONNECTION_SYNCH); - PrepareStatement(WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA, "SELECT creature.guid, creature.id1, creature.id2, creature.id3, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_GAME_EVENT_MODEL_EQUIPMENT_DATA, "SELECT creature.guid, creature.id, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_creature_quest", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_GAMEOBJECT_QUEST_DATA, "SELECT id, quest, eventEntry FROM game_event_gameobject_quest", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_GAME_EVENT_QUEST_CONDITION_DATA, "SELECT quest, eventEntry, condition_id, num FROM game_event_quest_condition", CONNECTION_SYNCH); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 847856b354fb80..7f1924df5e7b36 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -330,7 +330,7 @@ void SmartAIMgr::CheckIfSmartAIInDatabaseExists() // check GUID SAI for (auto const& pair : sObjectMgr->GetAllCreatureData()) { - if (pair.second.id1 != creatureTemplate.Entry) + if (pair.second.id != creatureTemplate.Entry) continue; if (mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].find((-1) * pair.first) != mEventMap[uint32(SmartScriptType::SMART_SCRIPT_TYPE_CREATURE)].end()) @@ -2087,7 +2087,7 @@ bool SmartAIMgr::IsTextValid(SmartScriptHolder const& e, uint32 id) return false; } else - entry = data->id1; + entry = data->id; } else entry = uint32(e.entryOrGuid); diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 213ee742fd8de0..b9b6d1a4239156 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -2199,7 +2199,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) { if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3)) { - if (cond->ConditionValue2 && creatureData->id1 != cond->ConditionValue2) + if (cond->ConditionValue2 && creatureData->id != cond->ConditionValue2) { LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match creature entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2); return false; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index b1ab32562492e2..756fe61264b7f6 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1398,7 +1398,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) dynamicflags = 0; } - data.id1 = GetEntry(); + data.id = GetEntry(); data.mapid = mapid; data.phaseMask = phaseMask; data.displayid = displayId; @@ -1444,8 +1444,6 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE); stmt->SetData(index++, m_spawnId); stmt->SetData(index++, GetEntry()); - stmt->SetData(index++, 0); - stmt->SetData(index++, 0); stmt->SetData(index++, uint16(mapid)); stmt->SetData(index++, spawnMask); stmt->SetData(index++, GetPhaseMask()); @@ -1695,7 +1693,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad m_spawnId = spawnId; // Add to world - uint32 entry = GetRandomId(data->id1, data->id2, data->id3); + uint32 entry = GetRandomId(data->id, data->id2, data->id3); if (!Create(map->GenerateLowGuid(), map, data->phaseMask, entry, 0, data->posX, data->posY, data->posZ, data->orientation, data)) return false; @@ -2011,7 +2009,7 @@ void Creature::Respawn(bool force) if (!allowed && !force) // Will be rechecked on next Update call return; - ObjectGuid dbtableHighGuid = ObjectGuid::Create(m_creatureData ? m_creatureData->id1 : GetEntry(), m_spawnId); + ObjectGuid dbtableHighGuid = ObjectGuid::Create(m_creatureData ? m_creatureData->id : GetEntry(), m_spawnId); time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid); CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(GetEntry()); @@ -2029,7 +2027,7 @@ void Creature::Respawn(bool force) // Respawn check if spawn has 2 entries if (data->id2) { - uint32 entry = GetRandomId(data->id1, data->id2, data->id3); + uint32 entry = GetRandomId(data->id, data->id2, data->id3); UpdateEntry(entry, data, true); // Select Random Entry m_defaultMovementType = MovementGeneratorType(data->movementType); // Reload Movement Type LoadEquipment(data->equipmentId); // Reload Equipment @@ -3093,7 +3091,7 @@ uint32 Creature::GetScriptId() const if (CreatureData const* creatureData = GetCreatureData()) { uint32 scriptId = creatureData->ScriptId; - if (scriptId && GetEntry() == creatureData->id1) + if (scriptId && GetEntry() == creatureData->id) return scriptId; } diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h index a79d7f8f0cde67..a8d5ab00b38e18 100644 --- a/src/server/game/Entities/Creature/CreatureData.h +++ b/src/server/game/Entities/Creature/CreatureData.h @@ -369,9 +369,9 @@ typedef std::unordered_map EquipmentInfo struct CreatureData : public SpawnData { CreatureData() : SpawnData(SPAWN_TYPE_CREATURE) {} - uint32 id1{0}; // entry in creature_template - uint32 id2{0}; // entry in creature_template - uint32 id3{0}; // entry in creature_template + uint32 id{0}; // entry in creature_template + uint32 id2{0}; // entry in creature_template (from creature_multispawn) + uint32 id3{0}; // entry in creature_template (from creature_multispawn) uint32 displayid{0}; int8 equipmentId{0}; uint32 spawntimesecs{0}; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index bde9ba819bb558..ee987592e15974 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -300,7 +300,7 @@ void GameEventMgr::LoadEventVendors() // Get creature entry newEntry.Entry = 0; if (CreatureData const* data = sObjectMgr->GetCreatureData(guid)) - newEntry.Entry = data->id1; + newEntry.Entry = data->id; // Validate vendor item if (!sObjectMgr->IsVendorItemValid(newEntry.Entry, newEntry.Item, newEntry.MaxCount, newEntry.Incrtime, newEntry.ExtendedCost, nullptr, nullptr, event_npc_flag)) @@ -614,9 +614,7 @@ void GameEventMgr::LoadEventModelEquipmentChangeData() ObjectGuid::LowType guid = fields[0].Get(); uint32 entry = fields[1].Get(); - uint32 entry2 = fields[2].Get(); - uint32 entry3 = fields[3].Get(); - uint16 eventId = fields[4].Get(); + uint16 eventId = fields[2].Get(); if (eventId >= _gameEventModelEquip.size()) { @@ -626,15 +624,15 @@ void GameEventMgr::LoadEventModelEquipmentChangeData() ModelEquipList& equiplist = _gameEventModelEquip[eventId]; ModelEquip newModelEquipSet; - newModelEquipSet.ModelId = fields[5].Get(); - newModelEquipSet.EquipmentId = fields[6].Get(); + newModelEquipSet.ModelId = fields[3].Get(); + newModelEquipSet.EquipmentId = fields[4].Get(); newModelEquipSet.EquipementIdPrev = 0; newModelEquipSet.ModelIdPrev = 0; if (newModelEquipSet.EquipmentId > 0) { int8 equipId = static_cast(newModelEquipSet.EquipmentId); - if ((!sObjectMgr->GetEquipmentInfo(entry, equipId)) || (entry2 && !sObjectMgr->GetEquipmentInfo(entry2, equipId)) || (entry3 && !sObjectMgr->GetEquipmentInfo(entry3, equipId))) + if (!sObjectMgr->GetEquipmentInfo(entry, equipId)) { LOG_ERROR("sql.sql", "Table `game_event_model_equip` have creature (Guid: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", guid, newModelEquipSet.EquipmentId); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index f1e100bbadf682..b4b9ba4eadc9f4 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1571,7 +1571,7 @@ void ObjectMgr::LoadCreatureMovementOverrides() "COALESCE(cmo.InteractionPauseTimer, ctm.InteractionPauseTimer) " "FROM creature_movement_override AS cmo " "LEFT JOIN creature AS c ON c.guid = cmo.SpawnId " - "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id1"); + "LEFT JOIN creature_template_movement AS ctm ON ctm.CreatureId = c.id"); if (!result) { LOG_WARN("server.loading", ">> Loaded 0 creature movement overrides. DB table `creature_movement_override` is empty!"); @@ -1974,8 +1974,8 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = ObjectGuid::Create(slave->id1, guidLow); - linkedGuid = ObjectGuid::Create(master->id1, linkedGuidLow); + guid = ObjectGuid::Create(slave->id, guidLow); + linkedGuid = ObjectGuid::Create(master->id, linkedGuidLow); break; } case CREATURE_TO_GO: @@ -2011,7 +2011,7 @@ void ObjectMgr::LoadLinkedRespawn() break; } - guid = ObjectGuid::Create(slave->id1, guidLow); + guid = ObjectGuid::Create(slave->id, guidLow); linkedGuid = ObjectGuid::Create(master->id, linkedGuidLow); break; } @@ -2086,7 +2086,7 @@ void ObjectMgr::LoadLinkedRespawn() } guid = ObjectGuid::Create(slave->id, guidLow); - linkedGuid = ObjectGuid::Create(master->id1, linkedGuidLow); + linkedGuid = ObjectGuid::Create(master->id, linkedGuidLow); break; } } @@ -2105,7 +2105,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid return false; CreatureData const* master = GetCreatureData(guidLow); - ObjectGuid guid = ObjectGuid::Create(master->id1, guidLow); + ObjectGuid guid = ObjectGuid::Create(master->id, guidLow); if (!linkedGuidLow) // we're removing the linking { @@ -2136,7 +2136,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(ObjectGuid::LowType guidLow, ObjectGuid return false; } - ObjectGuid linkedGuid = ObjectGuid::Create(slave->id1, linkedGuidLow); + ObjectGuid linkedGuid = ObjectGuid::Create(slave->id, linkedGuidLow); _linkedRespawnStore[guid] = linkedGuid; WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CREATURE_LINKED_RESPAWN); @@ -2317,11 +2317,11 @@ void ObjectMgr::LoadCreatures() { uint32 oldMSTime = getMSTime(); - // 0 1 2 3 4 5 6 7 8 9 10 11 - QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, " - // 12 13 14 15 16 17 18 19 20 21 22 + // 0 1 2 3 4 5 6 7 8 9 + QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, " + // 10 11 12 13 14 15 16 17 18 19 20 "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, " - // 23 + // 21 "creature.ScriptName " "FROM creature " "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " @@ -2352,57 +2352,36 @@ void ObjectMgr::LoadCreatures() Field* fields = result->Fetch(); ObjectGuid::LowType spawnId = fields[0].Get(); - uint32 id1 = fields[1].Get(); - uint32 id2 = fields[2].Get(); - uint32 id3 = fields[3].Get(); + uint32 creatureId = fields[1].Get(); - CreatureTemplate const* cInfo = GetCreatureTemplate(id1); + CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId); if (!cInfo) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id1 field, skipped.", spawnId, id1); - continue; - } - CreatureTemplate const* cInfo2 = GetCreatureTemplate(id2); - if (!cInfo2 && id2) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id2 field, skipped.", spawnId, id2); - continue; - } - CreatureTemplate const* cInfo3 = GetCreatureTemplate(id3); - if (!cInfo3 && id3) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in id3 field, skipped.", spawnId, id3); - continue; - } - if (!id2 && id3) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non existing creature entry {} in `id` field, skipped.", spawnId, creatureId); continue; } CreatureData& data = _creatureDataStore[spawnId]; - data.id1 = id1; - data.id2 = id2; - data.id3 = id3; - data.mapid = fields[4].Get(); - data.equipmentId = fields[5].Get(); - data.posX = fields[6].Get(); - data.posY = fields[7].Get(); - data.posZ = fields[8].Get(); - data.orientation = fields[9].Get(); - data.spawntimesecs = fields[10].Get(); - data.wander_distance = fields[11].Get(); - data.currentwaypoint = fields[12].Get(); - data.curhealth = fields[13].Get(); - data.curmana = fields[14].Get(); - data.movementType = fields[15].Get(); - data.spawnMask = fields[16].Get(); - data.phaseMask = fields[17].Get(); - int16 gameEvent = fields[18].Get(); - uint32 PoolId = fields[19].Get(); - data.npcflag = fields[20].Get(); - data.unit_flags = fields[21].Get(); - data.dynamicflags = fields[22].Get(); - data.ScriptId = GetScriptId(fields[23].Get()); + data.id = creatureId; + data.mapid = fields[2].Get(); + data.equipmentId = fields[3].Get(); + data.posX = fields[4].Get(); + data.posY = fields[5].Get(); + data.posZ = fields[6].Get(); + data.orientation = fields[7].Get(); + data.spawntimesecs = fields[8].Get(); + data.wander_distance = fields[9].Get(); + data.currentwaypoint = fields[10].Get(); + data.curhealth = fields[11].Get(); + data.curmana = fields[12].Get(); + data.movementType = fields[13].Get(); + data.spawnMask = fields[14].Get(); + data.phaseMask = fields[15].Get(); + int16 gameEvent = fields[16].Get(); + uint32 PoolId = fields[17].Get(); + data.npcflag = fields[18].Get(); + data.unit_flags = fields[19].Get(); + data.dynamicflags = fields[20].Get(); + data.ScriptId = GetScriptId(fields[21].Get()); data.spawnGroupId = 0; if (!data.ScriptId) @@ -2427,10 +2406,10 @@ void ObjectMgr::LoadCreatures() bool ok = true; for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) { - if ((_difficultyEntries[diff].find(data.id1) != _difficultyEntries[diff].end()) || (_difficultyEntries[diff].find(data.id2) != _difficultyEntries[diff].end()) || (_difficultyEntries[diff].find(data.id3) != _difficultyEntries[diff].end())) + if (_difficultyEntries[diff].find(data.id) != _difficultyEntries[diff].end()) { - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.", - spawnId, diff + 1, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {}) that listed as difficulty {} template (Entry: {}) in `creature_template`, skipped.", + spawnId, diff + 1, data.id); ok = false; } } @@ -2440,35 +2419,35 @@ void ObjectMgr::LoadCreatures() // -1 random, 0 no equipment, if (data.equipmentId != 0) { - if ((!GetEquipmentInfo(data.id1, data.equipmentId)) || (data.id2 && !GetEquipmentInfo(data.id2, data.equipmentId)) || (data.id3 && !GetEquipmentInfo(data.id3, data.equipmentId))) + if (!GetEquipmentInfo(data.id, data.equipmentId)) { - LOG_ERROR("sql.sql", "Table `creature` have creature (Entries: {}, {}, {}) one or more with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", - data.id1, data.id2, data.id3, data.equipmentId); + LOG_ERROR("sql.sql", "Table `creature` have creature (Entry: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", + data.id, data.equipmentId); data.equipmentId = 0; } } - if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND) || (data.id2 && cInfo2->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)) || (data.id3 && cInfo3->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND))) + if (cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_INSTANCE_BIND)) { if (!mapEntry->IsDungeon()) - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with a `creature_template`.`flags_extra` in one or more entries including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", - spawnId, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", + spawnId, data.id); } if (data.movementType >= MAX_DB_MOTION_TYPE) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with wrong movement generator type ({}), ignored and set to IDLE.", spawnId, data.id1, data.id2, data.id3, data.movementType); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with wrong movement generator type ({}), ignored and set to IDLE.", spawnId, data.id, data.movementType); data.movementType = IDLE_MOTION_TYPE; } if (data.wander_distance < 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", spawnId, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `wander_distance`< 0, set to 0.", spawnId, data.id); data.wander_distance = 0.0f; } else if (data.movementType == RANDOM_MOTION_TYPE) { if (data.wander_distance == 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", - spawnId, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", + spawnId, data.id); data.movementType = IDLE_MOTION_TYPE; } } @@ -2476,14 +2455,14 @@ void ObjectMgr::LoadCreatures() { if (data.wander_distance != 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", spawnId, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", spawnId, data.id); data.wander_distance = 0.0f; } } if (data.phaseMask == 0) { - LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entries: {}, {}, {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, data.id1, data.id2, data.id3); + LOG_ERROR("sql.sql", "Table `creature` have creature (SpawnId: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", spawnId, data.id); data.phaseMask = 1; } @@ -2508,6 +2487,72 @@ void ObjectMgr::LoadCreatures() ++count; } while (result->NextRow()); + // Load alternate entries from creature_multispawn + QueryResult variantResult = WorldDatabase.Query("SELECT spawnId, entry FROM creature_multispawn ORDER BY spawnId"); + if (variantResult) + { + uint32 variantCount = 0; + do + { + Field* fields = variantResult->Fetch(); + ObjectGuid::LowType spawnId = fields[0].Get(); + uint32 entry = fields[1].Get(); + + auto creatureDataIt = _creatureDataStore.find(spawnId); + if (creatureDataIt == _creatureDataStore.end()) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has entry for non-existing creature spawn (SpawnId: {}), skipped.", spawnId); + continue; + } + + CreatureData* data = &creatureDataIt->second; + + CreatureTemplate const* variantInfo = GetCreatureTemplate(entry); + if (!variantInfo) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with non-existing creature entry {}, skipped.", spawnId, entry); + continue; + } + + // Check difficulty entries for variant + bool diffOk = true; + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && diffOk; ++diff) + { + if (_difficultyEntries[diff].find(entry) != _difficultyEntries[diff].end()) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} listed as difficulty template in `creature_template`, skipped.", + spawnId, entry); + diffOk = false; + } + } + if (!diffOk) + continue; + + // Validate equipment for variant entry + if (data->equipmentId != 0 && !GetEquipmentInfo(entry, data->equipmentId)) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} where equipment_id {} not found in `creature_equip_template`.", + spawnId, entry, data->equipmentId); + } + + // Populate id2/id3 fields + if (!data->id2) + { + data->id2 = entry; + ++variantCount; + } + else if (!data->id3) + { + data->id3 = entry; + ++variantCount; + } + else + LOG_ERROR("sql.sql", "Table `creature_multispawn` has more than 2 variant entries for creature (SpawnId: {}), extra entry {} skipped.", spawnId, entry); + } while (variantResult->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} creature spawn variants", variantCount); + } + LOG_INFO("server.loading", ">> Loaded {} Creatures in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server.loading", " "); } @@ -2521,7 +2566,7 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI if (data) return data; - QueryResult result = WorldDatabase.Query("SELECT creature.guid, id1, id2, id3, map, equipment_id, " + QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, equipment_id, " "position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, " "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, " "creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.ScriptName " @@ -2531,62 +2576,83 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI return nullptr; Field* fields = result->Fetch(); - uint32 id1 = fields[1].Get(); - uint32 id2 = fields[2].Get(); - uint32 id3 = fields[3].Get(); + uint32 creatureId = fields[1].Get(); - CreatureTemplate const* cInfo = GetCreatureTemplate(id1); + CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId); if (!cInfo) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id1 field, skipped.", spawnId, id1); - return nullptr; - } - - if (id2 && !GetCreatureTemplate(id2)) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id2 field, skipped.", spawnId, id2); - return nullptr; - } - - if (id3 && !GetCreatureTemplate(id3)) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in id3 field, skipped.", spawnId, id3); - return nullptr; - } - - if (!id2 && id3) - { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with creature entry {} in id3 field but no entry in id2 field, skipped.", spawnId, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) with non-existing creature entry {} in `id` field, skipped.", spawnId, creatureId); return nullptr; } CreatureData& creatureData = _creatureDataStore[spawnId]; - creatureData.id1 = id1; - creatureData.id2 = id2; - creatureData.id3 = id3; - creatureData.mapid = fields[4].Get(); - creatureData.equipmentId = fields[5].Get(); - creatureData.posX = fields[6].Get(); - creatureData.posY = fields[7].Get(); - creatureData.posZ = fields[8].Get(); - creatureData.orientation = fields[9].Get(); - creatureData.spawntimesecs = fields[10].Get(); - creatureData.wander_distance = fields[11].Get(); - creatureData.currentwaypoint = fields[12].Get(); - creatureData.curhealth = fields[13].Get(); - creatureData.curmana = fields[14].Get(); - creatureData.movementType = fields[15].Get(); - creatureData.spawnMask = fields[16].Get(); - creatureData.phaseMask = fields[17].Get(); - creatureData.npcflag = fields[18].Get(); - creatureData.unit_flags = fields[19].Get(); - creatureData.dynamicflags = fields[20].Get(); - creatureData.ScriptId = GetScriptId(fields[21].Get()); + creatureData.id = creatureId; + creatureData.mapid = fields[2].Get(); + creatureData.equipmentId = fields[3].Get(); + creatureData.posX = fields[4].Get(); + creatureData.posY = fields[5].Get(); + creatureData.posZ = fields[6].Get(); + creatureData.orientation = fields[7].Get(); + creatureData.spawntimesecs = fields[8].Get(); + creatureData.wander_distance = fields[9].Get(); + creatureData.currentwaypoint = fields[10].Get(); + creatureData.curhealth = fields[11].Get(); + creatureData.curmana = fields[12].Get(); + creatureData.movementType = fields[13].Get(); + creatureData.spawnMask = fields[14].Get(); + creatureData.phaseMask = fields[15].Get(); + creatureData.npcflag = fields[16].Get(); + creatureData.unit_flags = fields[17].Get(); + creatureData.dynamicflags = fields[18].Get(); + creatureData.ScriptId = GetScriptId(fields[19].Get()); creatureData.spawnGroupId = 0; if (!creatureData.ScriptId) creatureData.ScriptId = cInfo->ScriptID; + // Load alternate entries from creature_multispawn + QueryResult variantResult = WorldDatabase.Query("SELECT entry FROM creature_multispawn WHERE spawnId = {} ORDER BY entry", spawnId); + if (variantResult) + { + do + { + uint32 variantEntry = variantResult->Fetch()[0].Get(); + if (!GetCreatureTemplate(variantEntry)) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with non-existing entry {}, skipped.", spawnId, variantEntry); + continue; + } + + // Check difficulty entries for variant + bool diffOk = true; + for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && diffOk; ++diff) + { + if (_difficultyEntries[diff].find(variantEntry) != _difficultyEntries[diff].end()) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} listed as difficulty template in `creature_template`, skipped.", + spawnId, variantEntry); + diffOk = false; + } + } + if (!diffOk) + continue; + + // Validate equipment for variant entry + if (creatureData.equipmentId != 0 && !GetEquipmentInfo(variantEntry, creatureData.equipmentId)) + { + LOG_ERROR("sql.sql", "Table `creature_multispawn` has creature (SpawnId: {}) with entry {} where equipment_id {} not found in `creature_equip_template`.", + spawnId, variantEntry, creatureData.equipmentId); + } + + if (!creatureData.id2) + creatureData.id2 = variantEntry; + else if (!creatureData.id3) + creatureData.id3 = variantEntry; + else + LOG_ERROR("sql.sql", "Table `creature_multispawn` has more than 2 variant entries for creature (SpawnId: {}), extra entry {} skipped.", spawnId, variantEntry); + } while (variantResult->NextRow()); + } + MapEntry const* mapEntry = sMapStore.LookupEntry(creatureData.mapid); if (!mapEntry) { @@ -2601,12 +2667,10 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI bool ok = true; for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) { - if (_difficultyEntries[diff].find(id1) != _difficultyEntries[diff].end() || - _difficultyEntries[diff].find(id2) != _difficultyEntries[diff].end() || - _difficultyEntries[diff].find(id3) != _difficultyEntries[diff].end()) + if (_difficultyEntries[diff].find(creatureId) != _difficultyEntries[diff].end()) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that is listed as difficulty {} template (Entries: {}, {}, {}) in `creature_template`, skipped.", - spawnId, diff + 1, id1, id2, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {}) that is listed as difficulty {} template (Entry: {}) in `creature_template`, skipped.", + spawnId, diff + 1, creatureId); ok = false; } } @@ -2619,35 +2683,33 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI if (creatureData.equipmentId != 0) { - if (!GetEquipmentInfo(id1, creatureData.equipmentId) || - (id2 && !GetEquipmentInfo(id2, creatureData.equipmentId)) || - (id3 && !GetEquipmentInfo(id3, creatureData.equipmentId))) + if (!GetEquipmentInfo(creatureId, creatureData.equipmentId)) { - LOG_ERROR("sql.sql", "Table `creature` has creature (Entries: {}, {}, {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", - id1, id2, id3, creatureData.equipmentId); + LOG_ERROR("sql.sql", "Table `creature` has creature (Entry: {}) with equipment_id {} not found in table `creature_equip_template`, set to no equipment.", + creatureId, creatureData.equipmentId); creatureData.equipmentId = 0; } } if (creatureData.movementType >= MAX_DB_MOTION_TYPE) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with wrong movement generator type ({}), set to IDLE.", - spawnId, id1, id2, id3, creatureData.movementType); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with wrong movement generator type ({}), set to IDLE.", + spawnId, creatureId, creatureData.movementType); creatureData.movementType = IDLE_MOTION_TYPE; } if (creatureData.wander_distance < 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `wander_distance`< 0, set to 0.", - spawnId, id1, id2, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `wander_distance`< 0, set to 0.", + spawnId, creatureId); creatureData.wander_distance = 0.0f; } else if (creatureData.movementType == RANDOM_MOTION_TYPE) { if (creatureData.wander_distance == 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", - spawnId, id1, id2, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `MovementType`=1 (random movement) but with `wander_distance`=0, replace by idle movement type (0).", + spawnId, creatureId); creatureData.movementType = IDLE_MOTION_TYPE; } } @@ -2655,16 +2717,16 @@ CreatureData const* ObjectMgr::LoadCreatureDataFromDB(ObjectGuid::LowType spawnI { if (creatureData.wander_distance != 0.0f) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", - spawnId, id1, id2, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `MovementType`=0 (idle) have `wander_distance`<>0, set to 0.", + spawnId, creatureId); creatureData.wander_distance = 0.0f; } } if (creatureData.phaseMask == 0) { - LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entries: {}, {}, {}) with `phaseMask`=0 (not visible for anyone), set to 1.", - spawnId, id1, id2, id3); + LOG_ERROR("sql.sql", "Table `creature` has creature (SpawnId: {} Entry: {}) with `phaseMask`=0 (not visible for anyone), set to 1.", + spawnId, creatureId); creatureData.phaseMask = 1; } @@ -2802,7 +2864,7 @@ ObjectGuid::LowType ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, f ObjectGuid::LowType spawnId = GenerateCreatureSpawnId(); CreatureData& data = NewOrExistCreatureData(spawnId); data.spawnMask = spawnId; - data.id1 = entry; + data.id = entry; data.id2 = 0; data.id3 = 0; data.mapid = mapId; diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 50df6f4d348670..93548d02a04d3a 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -278,7 +278,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recvData) return; } - CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id1); + CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id); if (!auctioneerInfo) { LOG_ERROR("network.opcode", "Non existing auctioneer ({})", auctioneer.ToString()); diff --git a/src/server/game/Maps/ZoneScript.h b/src/server/game/Maps/ZoneScript.h index 3dd66ce2902139..45487c45198477 100644 --- a/src/server/game/Maps/ZoneScript.h +++ b/src/server/game/Maps/ZoneScript.h @@ -28,7 +28,7 @@ class ZoneScript ZoneScript() {} virtual ~ZoneScript() {} - virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*guidlow*/, CreatureData const* data) { return data->id1; } + virtual uint32 GetCreatureEntry(ObjectGuid::LowType /*guidlow*/, CreatureData const* data) { return data->id; } virtual uint32 GetGameObjectEntry(ObjectGuid::LowType /*guidlow*/, uint32 entry) { return entry; } virtual void OnCreatureCreate(Creature*) { } diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 88e210cfc67d28..0b7e1af831ad6c 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -96,7 +96,7 @@ void OPvPCapturePoint::AddCre(uint32 type, ObjectGuid::LowType guid, uint32 entr return; } - entry = data->id1; + entry = data->id; } _creatures[type] = guid; diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index 88a7df172d3969..081272f1b3e431 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -608,7 +608,7 @@ class go_commandscript : public CommandScript CreatureData const* spawnpoint = nullptr; for (auto const& pair : sObjectMgr->GetAllCreatureData()) { - if (pair.second.id1 != entry) + if (pair.second.id != entry) { continue; } @@ -632,7 +632,7 @@ class go_commandscript : public CommandScript std::vector spawnpoints; for (auto const& pair : sObjectMgr->GetAllCreatureData()) { - if (pair.second.id1 != entry) + if (pair.second.id != entry) { continue; } diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 6eb781317cc44d..66103b3a0c5d2d 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -226,7 +226,7 @@ class npc_commandscript : public CommandScript { ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId(); CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid); - data.id1 = id; + data.id = id; data.phaseMask = chr->GetPhaseMaskForSpawn(); data.posX = chr->GetTransOffsetX(); data.posY = chr->GetTransOffsetY(); @@ -674,7 +674,7 @@ class npc_commandscript : public CommandScript uint32 id3 = 0; if (CreatureData const* cData = target->GetCreatureData()) { - id1 = cData->id1; + id1 = cData->id; id2 = cData->id2; id3 = cData->id3; } @@ -718,7 +718,7 @@ class npc_commandscript : public CommandScript static bool HandleNpcInfoCommandShowFromDB(ChatHandler* handler, ObjectGuid::LowType lowGuid, CreatureData const* cData) { - CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id1); + CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id); if (!cInfo) { handler->SendErrorMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid); @@ -727,7 +727,7 @@ class npc_commandscript : public CommandScript handler->PSendSysMessage("(Not in world - showing DB data)"); uint32 scriptId = cData->ScriptId ? cData->ScriptId : cInfo->ScriptID; - handler->PSendSysMessage(LANG_NPCINFO_CHAR, lowGuid, ObjectGuid::Create(cData->id1, lowGuid).ToString(), cData->id1, + handler->PSendSysMessage(LANG_NPCINFO_CHAR, lowGuid, ObjectGuid::Create(cData->id, lowGuid).ToString(), cData->id, cData->id2, cData->id3, cData->displayid, cData->displayid, cInfo->faction, cData->npcflag); handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, cData->phaseMask); @@ -760,7 +760,7 @@ class npc_commandscript : public CommandScript uint32 id3 = 0; if (CreatureData const* cData = target->GetCreatureData()) { - id1 = cData->id1; + id1 = cData->id; id2 = cData->id2; id3 = cData->id3; } @@ -832,12 +832,10 @@ class npc_commandscript : public CommandScript continue; uint32 entry = fields[1].Get(); - //uint32 entry2 = fields[2].Get(); - //uint32 entry3 = fields[3].Get(); - float x = fields[4].Get(); - float y = fields[5].Get(); - float z = fields[6].Get(); - uint16 mapId = fields[7].Get(); + float x = fields[2].Get(); + float y = fields[3].Get(); + float z = fields[4].Get(); + uint16 mapId = fields[5].Get(); CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry); if (!creatureTemplate) diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index aed43e5030ff3b..6e875006434870 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -308,7 +308,7 @@ class tele_commandscript : public CommandScript CreatureData const* spawnpoint = nullptr; for (auto const& pair : sObjectMgr->GetAllCreatureData()) { - if (pair.second.id1 != *creatureId) + if (pair.second.id != *creatureId) continue; if (!spawnpoint) @@ -340,7 +340,7 @@ class tele_commandscript : public CommandScript return false; } - CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1)); + CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id)); return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name); } @@ -351,7 +351,7 @@ class tele_commandscript : public CommandScript WorldDatabase.EscapeString(normalizedName); // May need work //PussyWizardEliteMalcrom - QueryResult result = WorldDatabase.Query("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id1 = ct.entry WHERE ct.name LIKE '{}'", normalizedName); + QueryResult result = WorldDatabase.Query("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id = ct.entry WHERE ct.name LIKE '{}'", normalizedName); if (!result) { handler->SendErrorMessage(LANG_COMMAND_GOCREATNOTFOUND); diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index b4b80686a4240a..f285f06d2b1329 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -1036,7 +1036,7 @@ class wp_commandscript : public CommandScript if (show == "off") { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID); - stmt->SetArguments(1, 1, 1); + stmt->SetArguments(1, 1); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp index 697c7009333b07..866c89a81573f2 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/temple_of_ahnqiraj.cpp @@ -428,7 +428,7 @@ struct npc_ahnqiraji_critter : public ScriptedAI // Don't attack nearby players randomly if they are the Twin's pet bugs. if (CreatureData const* crData = me->GetCreatureData()) { - ObjectGuid dbtableHighGuid = ObjectGuid::Create(crData->id1, me->GetSpawnId()); + ObjectGuid dbtableHighGuid = ObjectGuid::Create(crData->id, me->GetSpawnId()); ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid); if (targetGuid.GetEntry() == NPC_VEKLOR) diff --git a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp index 1cc7f2ca7a613c..a458987bee01c9 100644 --- a/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/PitOfSaron/instance_pit_of_saron.cpp @@ -84,7 +84,7 @@ class instance_pit_of_saron : public InstanceMapScript uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override { - uint32 entry = data->id1; + uint32 entry = data->id; switch (entry) { case NPC_RESCUED_ALLIANCE_SLAVE: diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 77f6c70698a08f..344a92467b61da 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -1022,7 +1022,7 @@ class boss_sister_svalna : public CreatureScript if (Creature* crusader = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_CAPTAIN_ARNATH + i))) if (crusader->IsAlive()) { - if (crusader->GetEntry() == crusader->GetCreatureData()->id1) + if (crusader->GetEntry() == crusader->GetCreatureData()->id) { crusader->m_Events.AddEventAtOffset(new CaptainSurviveTalk(*crusader), delay); delay += 6s; @@ -1197,7 +1197,7 @@ struct npc_argent_captainAI : public ScriptedAI void Reset() override { me->SetCorpseDelay(DAY); // leave corpse for a long time so svalna can resurrect - IsUndead = (me->GetCreatureData() && me->GetCreatureData()->id1 != me->GetEntry()); + IsUndead = (me->GetCreatureData() && me->GetCreatureData()->id != me->GetEntry()); } void JustDied(Unit* /*killer*/) override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp index 3f0b4549028072..b4e7c59225bf94 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/instance_icecrown_citadel.cpp @@ -539,7 +539,7 @@ class instance_icecrown_citadel : public InstanceMapScript uint32 GetCreatureEntry(ObjectGuid::LowType /*guidLow*/, CreatureData const* data) override { - uint32 entry = data->id1; + uint32 entry = data->id; switch (entry) { case NPC_HORDE_GUNSHIP_CANNON: