diff options
| author | Blaymoira <none@none> | 2009-03-05 21:02:33 +0100 | 
|---|---|---|
| committer | Blaymoira <none@none> | 2009-03-05 21:02:33 +0100 | 
| commit | fd2fd00c14953c1b787a506c56c6413903fa90bc (patch) | |
| tree | 7fd20f2f15801a576bb60699c4136d7487be68f9 /src/game/ObjectMgr.cpp | |
| parent | 6a577295d945dac9c43a4d4130c8fdaa70061eb3 (diff) | |
*Implement access_requirement table - by Iskander
- now check the requirements on teleport not only on areatrigger use
- moved some columns from instance_template and areatrigger_teleport to access_requirement table
--HG--
branch : trunk
Diffstat (limited to 'src/game/ObjectMgr.cpp')
| -rw-r--r-- | src/game/ObjectMgr.cpp | 164 | 
1 files changed, 106 insertions, 58 deletions
| diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 55af142a094..eef767b263e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -5112,8 +5112,8 @@ void ObjectMgr::LoadAreaTriggerTeleports()      uint32 count = 0; -    //                                                0   1               2              3               4           5            6                           7                                  8                    9                     10          11                          12        13 -    QueryResult *result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, heroic_required_quest_done, heroic_required_failed_quest_text, required_quest_done, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); +    //                                                0       1           2              3               4                   5                   6   +    QueryResult *result = WorldDatabase.Query("SELECT id, access_id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");      if( !result )      { @@ -5140,20 +5140,12 @@ void ObjectMgr::LoadAreaTriggerTeleports()          AreaTrigger at; -        at.requiredLevel            = fields[1].GetUInt8(); -        at.requiredItem             = fields[2].GetUInt32(); -        at.requiredItem2            = fields[3].GetUInt32(); -        at.heroicKey                = fields[4].GetUInt32(); -        at.heroicKey2               = fields[5].GetUInt32(); -        at.heroicQuest              = fields[6].GetUInt32(); -        at.heroicQuestFailedText    = fields[7].GetCppString(); -        at.requiredQuest            = fields[8].GetUInt32(); -        at.requiredFailedText       = fields[9].GetCppString(); -        at.target_mapId             = fields[10].GetUInt32(); -        at.target_X                 = fields[11].GetFloat(); -        at.target_Y                 = fields[12].GetFloat(); -        at.target_Z                 = fields[13].GetFloat(); -        at.target_Orientation       = fields[14].GetFloat(); +        at.access_id                = fields[1].GetUInt32(); +        at.target_mapId             = fields[2].GetUInt32(); +        at.target_X                 = fields[3].GetFloat(); +        at.target_Y                 = fields[4].GetFloat(); +        at.target_Z                 = fields[5].GetFloat(); +        at.target_Orientation       = fields[6].GetFloat();          AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);          if(!atEntry) @@ -5161,85 +5153,141 @@ void ObjectMgr::LoadAreaTriggerTeleports()              sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID);              continue;          } +         +        MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); +        if(!mapEntry) +        { +            sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); +            continue; +        } -        if(at.requiredItem) +        if(at.target_X==0 && at.target_Y==0 && at.target_Z==0)          { -            ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); -            if(!pProto) -            { -                sLog.outError("Key item %u does not exist for trigger %u, removing key requirement.", at.requiredItem, Trigger_ID); -                at.requiredItem = 0; -            } +            sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); +            continue;          } -        if(at.requiredItem2) + +        mAreaTriggers[Trigger_ID] = at; + +    } while( result->NextRow() ); + +    delete result; + +    sLog.outString(); +    sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); +} + +void ObjectMgr::LoadAccessRequirements() +{ +    mAccessRequirements.clear();                                  // need for reload case + +    uint32 count = 0; + +	//                                                0       1          2       3      4        5           6             7              8                   9                  10 +    QueryResult *result = WorldDatabase.Query("SELECT id, level_min, level_max, item, item2, heroic_key, heroic_key2, quest_done, quest_failed_text, heroic_quest_done, heroic_quest_failed_text FROM access_requirement"); +	if( !result ) +    { + +        barGoLink bar( 1 ); + +        bar.step(); + +        sLog.outString(); +        sLog.outString( ">> Loaded %u access requirement definitions", count ); +        return; +    } + +    barGoLink bar( result->GetRowCount() ); + +    do +    { +        Field *fields = result->Fetch(); + +        bar.step(); + +        ++count; + +        uint32 requiremt_ID = fields[0].GetUInt32(); + +        AccessRequirement ar; + +        ar.levelMin                 = fields[1].GetUInt8(); +        ar.levelMax                 = fields[2].GetUInt32(); +        ar.item                     = fields[3].GetUInt32(); +        ar.item2                    = fields[4].GetUInt32(); +        ar.heroicKey                = fields[5].GetUInt32(); +        ar.heroicKey2               = fields[6].GetUInt32(); +        ar.quest                    = fields[7].GetUInt32(); +        ar.questFailedText          = fields[8].GetCppString(); +        ar.heroicQuest              = fields[9].GetUInt32(); +        ar.heroicQuestFailedText    = fields[10].GetCppString(); + +        if(ar.item)          { -            ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); +            ItemPrototype const *pProto = GetItemPrototype(ar.item);              if(!pProto)              { -                sLog.outError("Second item %u not exist for trigger %u, remove key requirement.", at.requiredItem2, Trigger_ID); -                at.requiredItem2 = 0; +                sLog.outError("Key item %u does not exist for requirement %u, removing key requirement.", ar.item, requiremt_ID); +                ar.item = 0;              }          } -        if(at.heroicKey) +        if(ar.item2)          { -            ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); +            ItemPrototype const *pProto = GetItemPrototype(ar.item2);              if(!pProto)              { -                sLog.outError("Heroic key item %u not exist for trigger %u, remove key requirement.", at.heroicKey, Trigger_ID); -                at.heroicKey = 0; +                sLog.outError("Second item %u does not exist for requirement %u, removing key requirement.", ar.item2, requiremt_ID); +                ar.item2 = 0;              }          } -        if(at.heroicKey2) +        if(ar.heroicKey)          { -            ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); +            ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey);              if(!pProto)              { -                sLog.outError("Heroic second key item %u not exist for trigger %u, remove key requirement.", at.heroicKey2, Trigger_ID); -                at.heroicKey2 = 0; +                sLog.outError("Heroic key %u not exist for trigger %u, remove key requirement.", ar.heroicKey, requiremt_ID); +                ar.heroicKey = 0;              }          } -        if(at.heroicQuest) +        if(ar.heroicKey2)          { -            if(!mQuestTemplates[at.heroicQuest]) +            ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey2); +            if(!pProto)              { -                sLog.outErrorDb("Required Heroic Quest %u not exist for trigger %u, remove heroic quest done requirement.",at.heroicQuest,Trigger_ID); -                at.heroicQuest = 0; +                sLog.outError("Second heroic key %u not exist for trigger %u, remove key requirement.", ar.heroicKey2, requiremt_ID); +                ar.heroicKey2 = 0;              }          } -        if(at.requiredQuest) +		if(ar.heroicQuest) + 		{ +			if(!mQuestTemplates[ar.heroicQuest]) +			{ +				sLog.outErrorDb("Required Heroic Quest %u not exist for trigger %u, remove heroic quest done requirement.",ar.heroicQuest,requiremt_ID); +				ar.heroicQuest = 0; + 			} + 		} +  +        if(ar.quest)          { -            if(!mQuestTemplates[at.requiredQuest]) +            if(!mQuestTemplates[ar.quest])              { -                sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",at.requiredQuest,Trigger_ID); -                at.requiredQuest = 0; +                sLog.outErrorDb("Required Quest %u not exist for trigger %u, remove quest done requirement.",ar.quest,requiremt_ID); +                ar.quest = 0;              }          } -        MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); -        if(!mapEntry) -        { -            sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId); -            continue; -        } - -        if(at.target_X==0 && at.target_Y==0 && at.target_Z==0) -        { -            sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID); -            continue; -        } - -        mAreaTriggers[Trigger_ID] = at; +        mAccessRequirements[requiremt_ID] = ar;      } while( result->NextRow() );      delete result;      sLog.outString(); -    sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); +    sLog.outString( ">> Loaded %u access requirement definitions", count );  }  AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const | 
