aboutsummaryrefslogtreecommitdiff
path: root/src/game/ObjectMgr.cpp
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-17 14:06:20 +0100
committern0n4m3 <none@none>2009-12-17 14:06:20 +0100
commiteccf162be2e8cb821087f49dfd9a0885e6c0e73c (patch)
tree9c52c4f530cc864538278167a93601463629eb0e /src/game/ObjectMgr.cpp
parent89656d5749f72803edbdd5f9840ba6b4c21f3987 (diff)
Fixed compile errors and some typos
--HG-- branch : trunk
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r--src/game/ObjectMgr.cpp179
1 files changed, 106 insertions, 73 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 1d9f2d64878..27a95a935a6 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -570,8 +570,8 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount );
sLog.outString();
- std::set<uint32> heroicEntries; // already loaded heroic value in creatures
- std::set<uint32> hasHeroicEntries; // already loaded creatures with heroic entry values
+ std::set<uint32> difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures
+ std::set<uint32> hasDifficultyEntries[MAX_DIFFICULTY - 1]; // already loaded creatures with difficulty 1 values
// check data correctness
for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
@@ -580,84 +580,105 @@ void ObjectMgr::LoadCreatureTemplates()
if (!cInfo)
continue;
- if (cInfo->HeroicEntry)
+ bool ok = true; // bool to allow continue outside this loop
+ for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
{
- CreatureInfo const* heroicInfo = GetCreatureTemplate(cInfo->HeroicEntry);
- if (!heroicInfo)
- {
- sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u not exist.", i, cInfo->HeroicEntry, cInfo->HeroicEntry);
+ if (!cInfo->DifficultyEntry[diff])
continue;
- }
+ ok = false; // will be set to true at the end of this loop again
- if (heroicEntries.find(i)!=heroicEntries.end())
+ CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry[diff]);
+ if (!difficultyInfo)
{
- sLog.outErrorDb("Creature (Entry: %u) listed as heroic but have value in `heroic_entry`.",i);
+ sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u not exist.",
+ i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]);
continue;
}
- if (heroicEntries.find(cInfo->HeroicEntry)!=heroicEntries.end())
+ if (difficultyEntries[diff].find(i) != difficultyEntries[diff].end())
{
- sLog.outErrorDb("Creature (Entry: %u) already listed as heroic for another entry.",cInfo->HeroicEntry);
+ sLog.outErrorDb("Creature (Entry: %u) listed as difficulty %u but have value in `difficulty_entry_1`.", i, diff + 1);
continue;
}
- if (hasHeroicEntries.find(cInfo->HeroicEntry)!=hasHeroicEntries.end())
+ bool ok2 = true;
+ for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
{
- sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u have heroic entry also.",i,cInfo->HeroicEntry,cInfo->HeroicEntry);
- continue;
+ ok2 = false;
+ if (difficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != difficultyEntries[diff2].end())
+ {
+ sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty %u for another entry.", cInfo->DifficultyEntry[diff], diff2 + 1);
+ continue;
+ }
+
+ if (hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != hasDifficultyEntries[diff2].end())
+ {
+ sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u have difficulty %u entry also.",
+ i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1);
+ continue;
+ }
+ ok2 = true;
}
+ if (!ok2)
+ continue;
- if (cInfo->unit_class != heroicInfo->unit_class)
+ if (cInfo->unit_class != difficultyInfo->unit_class)
{
- sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in heroic mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->HeroicEntry, heroicInfo->unit_class);
+ sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty %u mode (Entry: %u, class %u).",
+ i, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class);
continue;
}
- if (cInfo->npcflag != heroicInfo->npcflag)
+ if (cInfo->npcflag != difficultyInfo->npcflag)
{
- sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `npcflag` in heroic mode.",i);
+ sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
- if (cInfo->trainer_class != heroicInfo->trainer_class)
+ if (cInfo->trainer_class != difficultyInfo->trainer_class)
{
- sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry);
+ sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
- if (cInfo->trainer_race != heroicInfo->trainer_race)
+ if (cInfo->trainer_race != difficultyInfo->trainer_race)
{
- sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry);
+ sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
- if (cInfo->trainer_type != heroicInfo->trainer_type)
+ if (cInfo->trainer_type != difficultyInfo->trainer_type)
{
- sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_type` in heroic mode.",i);
+ sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
- if (cInfo->trainer_spell != heroicInfo->trainer_spell)
+ if (cInfo->trainer_spell != difficultyInfo->trainer_spell)
{
- sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_spell` in heroic mode.",i);
+ sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty %u mode (Entry: %u).", i, diff + 1, cInfo->DifficultyEntry[diff]);
continue;
}
- if (heroicInfo->AIName && *heroicInfo->AIName)
+ if (difficultyInfo->AIName && *difficultyInfo->AIName)
{
- sLog.outErrorDb("Heroic mode creature (Entry: %u) has `AIName`, but in any case will used normal mode creature (Entry: %u) AIName.",cInfo->HeroicEntry,i);
+ sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.",
+ diff, cInfo->DifficultyEntry[diff], i);
continue;
}
- if (heroicInfo->ScriptID)
+ if (difficultyInfo->ScriptID)
{
- sLog.outErrorDb("Heroic mode creature (Entry: %u) has `ScriptName`, but in any case will used normal mode creature (Entry: %u) ScriptName.",cInfo->HeroicEntry,i);
+ sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.",
+ diff, cInfo->DifficultyEntry[diff], i);
continue;
}
- hasHeroicEntries.insert(i);
- heroicEntries.insert(cInfo->HeroicEntry);
+ hasDifficultyEntries[diff].insert(i);
+ difficultyEntries[diff].insert(cInfo->DifficultyEntry[diff]);
+ ok = true;
}
+ if (!ok)
+ continue;
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A);
if (!factionTemplate)
@@ -1232,11 +1253,20 @@ void ObjectMgr::LoadCreatures()
}
// build single time for check creature data
- std::set<uint32> heroicCreatures;
+ std::set<uint32> difficultyCreatures[MAX_DIFFICULTY - 1];
for (uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
- if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
- if(cInfo->HeroicEntry)
- heroicCreatures.insert(cInfo->HeroicEntry);
+ if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
+ for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1; ++diff)
+ if (cInfo->DifficultyEntry[diff])
+ difficultyCreatures[diff].insert(cInfo->DifficultyEntry[diff]);
+
+ // build single time for check spawnmask
+ std::map<uint32,uint32> spawnMasks;
+ for(uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
+ if(sMapStore.LookupEntry(i))
+ for(int k = 0; k < MAX_DIFFICULTY; ++k)
+ if (GetMapDifficultyData(i,Difficulty(k)))
+ spawnMasks[i] |= (1 << k);
//TODO: remove this
//gameeventmgr.mGameEventCreatureGuids.resize(52*2-1);
@@ -1280,12 +1310,29 @@ void ObjectMgr::LoadCreatures()
int16 gameEvent = fields[18].GetInt16();
int16 PoolId = fields[19].GetInt16();
- if(heroicCreatures.find(data.id)!=heroicCreatures.end())
+ MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
+ if(!mapEntry)
{
- sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as heroic template (entry: %u) in `creature_template_substitution`, skipped.",guid,data.id );
+ sLog.outErrorDb("Table `creature` have creature (GUID: %u) that spawned at not existed map (Id: %u), skipped.",guid, data.mapid );
continue;
}
+ if (data.spawnMask & ~spawnMasks[data.mapid])
+ sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid );
+
+ bool ok = true;
+ for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
+ {
+ if (difficultyCreatures[diff].find(data.id) != difficultyCreatures[diff].end())
+ {
+ sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.",
+ guid, diff + 1, data.id );
+ ok = false;
+ }
+ }
+ if (!ok)
+ continue;
+
// I do not know why but in db most display id are not zero
/*if(data.displayid == 11686 || data.displayid == 24719)
{
@@ -1313,8 +1360,7 @@ void ObjectMgr::LoadCreatures()
if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
{
- MapEntry const* map = sMapStore.LookupEntry(data.mapid);
- if(!map || !map->IsDungeon())
+ if(!mapEntry || !mapEntry->IsDungeon())
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",guid,data.id);
}
@@ -3319,9 +3365,9 @@ void ObjectMgr::LoadGroups()
Group *group = NULL;
uint64 leaderGuid = 0;
uint32 count = 0;
- // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups");
-
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
+ QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid FROM groups");
+
if( !result )
{
barGoLink bar( 1 );
@@ -3340,7 +3386,7 @@ void ObjectMgr::LoadGroups()
bar.step();
Field *fields = result->Fetch();
++count;
- leaderGuid = MAKE_NEW_GUID(fields[15].GetUInt32(),0,HIGHGUID_PLAYER);
+ leaderGuid = MAKE_NEW_GUID(fields[16].GetUInt32(),0,HIGHGUID_PLAYER);
group = new Group;
if(!group->LoadGroupFromDB(leaderGuid, result, false))
@@ -3454,7 +3500,14 @@ void ObjectMgr::LoadGroups()
continue;
}
- InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapEntry->MapID, fields[2].GetUInt32(), fields[4].GetUInt8(), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true);
+ uint32 diff = fields[4].GetUInt8();
+ if(diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
+ {
+ sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1);
+ diff = 0; // default for both difficaly types
+ }
+
+ InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapEntry->MapID, fields[2].GetUInt32(), Difficulty(diff), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true);
group->BindToInstance(save, fields[3].GetBool(), true);
}while( result->NextRow() );
delete result;
@@ -4813,37 +4866,17 @@ void ObjectMgr::LoadInstanceTemplate()
for (uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++)
{
InstanceTemplate* temp = (InstanceTemplate*)GetInstanceTemplate(i);
- if(!temp) continue;
- const MapEntry* entry = sMapStore.LookupEntry(temp->map);
- if(!entry)
- {
- sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map);
- continue;
- }
- else if(!entry->HasResetTime())
+ if(!temp)
continue;
- //FIXME: now exist heroic instance, normal/heroic raid instances
- // entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid)
- // entry->resetTimeRaid store reset time for normal raid only
- // for current state entry->resetTimeRaid == entry->resetTimeHeroic in case raid instances with heroic mode.
- // but at some point wee need implement reset time dependent from raid instance mode
- if(temp->reset_delay == 0)
+ if(!MapManager::IsValidMAP(temp->map))
+ sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map);
+
+ if(!MapManager::IsValidMapCoord(temp->parent,temp->startLocX,temp->startLocY,temp->startLocZ,temp->startLocO))
{
- // use defaults from the DBC
- if(entry->resetTimeHeroic) // for both raid and non raids, read above
- {
- temp->reset_delay = entry->resetTimeHeroic / DAY;
- }
- else if (entry->resetTimeRaid && entry->map_type == MAP_RAID)
- // for normal raid only
- {
- temp->reset_delay = entry->resetTimeRaid / DAY;
- }
+ sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad parent entrance coordinates for map id %d template!", temp->map);
+ temp->parent = 0; // will have wrong continent 0 parent, at least existed
}
-
- // the reset_delay must be at least one day
- temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME)));
}
sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount );