Advertisement
Guest User

Untitled

a guest
Nov 9th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LDIF 5.51 KB | None | 0 0
  1.  src/server/game/Conditions/ConditionMgr.cpp | 95 ++++++++++++++++++++++++++++-
  2.  src/server/game/Conditions/ConditionMgr.h   |  7 ++-
  3.  2 files changed, 97 insertions(+), 5 deletions(-)
  4.  
  5. diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
  6. index 84830e0..4e80d99 100644
  7. --- a/src/server/game/Conditions/ConditionMgr.cpp
  8. +++ b/src/server/game/Conditions/ConditionMgr.cpp
  9. @@ -56,7 +56,9 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]
  10.      "Npc Vendor",
  11.      "Spell Proc",
  12.      "Terrain Swap",
  13. -    "Phase"
  14. +    "Phase",
  15. +    "Creature Visibility",
  16. +    "GameObject Visibility"
  17.  };
  18.  
  19.  ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
  20.  
  21. @@ -1190,6 +1212,34 @@ void ConditionMgr::LoadConditions(bool isReload)
  22.              ++count;
  23.              continue;
  24.          }
  25. +        else if (cond->SourceType == CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY)
  26. +        {
  27. +            CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(cond->SourceEntry));
  28. +            if (!creature)
  29. +            {
  30. +                TC_LOG_ERROR("sql.sql", "%s has no creature data for guid %d in SourceEntry field!", cond->ToString().c_str(), cond->SourceEntry);
  31. +                delete cond;
  32. +                continue;
  33. +            }
  34. +            CreatureData& data = sObjectMgr->NewOrExistCreatureData(uint64(cond->SourceEntry));
  35. +            data.conditions.push_back(cond); // data.conditions is: ConditionContainer conditions;
  36. +            ++count;
  37. +            continue;
  38. +        }
  39. +        else if (cond->SourceType == CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY)
  40. +        {
  41. +            GameObjectData const* godata = sObjectMgr->GetGOData(uint64(cond->SourceEntry));
  42. +            if (!godata)
  43. +            {
  44. +                TC_LOG_ERROR("sql.sql", "%s has no gameobject data for guid %d in SourceEntry field!", cond->ToString().c_str(), cond->SourceEntry);
  45. +                delete cond;
  46. +                continue;
  47. +            }
  48. +            GameObjectData& data = sObjectMgr->NewGOData(uint64(cond->SourceEntry));
  49. +            data.conditions.push_back(cond); // data.conditions is: ConditionContainer conditions;
  50. +            ++count;
  51. +            continue;
  52. +        }
  53.  
  54.          //handle not grouped conditions
  55.          //add new Condition to storage based on Type/Entry
  56. @@ -1773,6 +1823,26 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
  57.              }
  58.              break;
  59.          }
  60. +        case CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY:
  61. +        {
  62. +            CreatureData const* creature = sObjectMgr->GetCreatureData(uint64(cond->SourceEntry));
  63. +            if (!creature)
  64. +            {
  65. +                TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature` as guid %d, ignoring.", cond->ToString().c_str(), cond->SourceEntry);
  66. +                return false;
  67. +            }
  68. +            break;
  69. +        }
  70. +        case CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY:
  71. +        {
  72. +            GameObjectData const* godata = sObjectMgr->GetGOData(uint64(cond->SourceEntry));
  73. +            if (!godata)
  74. +            {
  75. +                TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `gameobject` as guid %d, ignoring.", cond->ToString().c_str(), cond->SourceEntry);
  76. +                return false;
  77. +            }
  78. +            break;
  79. +        }
  80.          case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
  81.          case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
  82.          case CONDITION_SOURCE_TYPE_SMART_EVENT:
  83.  
  84. @@ -2293,6 +2364,24 @@ void ConditionMgr::Clean()
  85.  
  86.      NpcVendorConditionContainerStore.clear();
  87.  
  88. +
  89. +    // todo fix cleanup
  90. +    CreatureDataContainer* creatures = sObjectMgr->GetCreatureDataMap();
  91. +    for (CreatureDataContainer::iterator itr = creatures->begin(); itr != creatures->end(); ++itr)
  92. +    {
  93. +        //for (ConditionList::const_iterator i = itr->second.conditions.begin(); i != itr->second.conditions.end(); ++i)
  94. +        //    delete *i;
  95. +        itr->second.conditions.clear();
  96. +    }
  97. +                
  98. +    GameObjectDataContainer* gameobjects = sObjectMgr->GetGameObjectDataMap();
  99. +    for (GameObjectDataContainer::iterator itr = gameobjects->begin(); itr != gameobjects->end(); ++itr)
  100. +    {
  101. +        //for (ConditionList::const_iterator i = itr->second.conditions.begin(); i != itr->second.conditions.end(); ++i)
  102. +        //    delete *i;
  103. +        itr->second.conditions.clear();
  104. +    }
  105. +
  106.      // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
  107.      for (std::vector<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr)
  108.          delete *itr;
  109. diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
  110. index d33b7ed..5cd2aae 100644
  111. --- a/src/server/game/Conditions/ConditionMgr.h
  112. +++ b/src/server/game/Conditions/ConditionMgr.h
  113.  
  114. @@ -150,7 +151,9 @@ enum ConditionSourceType
  115.      CONDITION_SOURCE_TYPE_SPELL_PROC                     = 24,
  116.      CONDITION_SOURCE_TYPE_TERRAIN_SWAP                   = 25,
  117.      CONDITION_SOURCE_TYPE_PHASE                          = 26,
  118. -    CONDITION_SOURCE_TYPE_MAX                            = 27  // MAX
  119. +    CONDITION_SOURCE_TYPE_CREATURE_VISIBILITY            = 27,
  120. +    CONDITION_SOURCE_TYPE_GAMEOBJECT_VISIBILITY          = 28,
  121. +    CONDITION_SOURCE_TYPE_MAX                            = 29  // MAX
  122.  };
  123.  
  124.  enum RelationType
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement