Changeset 266
- Timestamp:
- 11/21/08 08:48:50 (17 years ago)
- Location:
- trunk/src/game
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Creature.cpp
r265 r266 1823 1823 } 1824 1824 1825 Unit* Creature::SelectNearestTarget(float dist) const 1826 { 1827 /*CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); 1828 Cell cell(p); 1829 cell.data.Part.reserved = ALL_DISTRICT; 1830 cell.SetNoCreate(); 1831 1832 Unit *target; 1833 1834 { 1835 Trinity::NearestHostileUnitInAttackDistanceCheck u_check(this, dist); 1836 Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck> searcher(target, u_check); 1837 1838 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, WorldTypeMapContainer > world_unit_searcher(searcher); 1839 TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::NearestHostileUnitInAttackDistanceCheck>, GridTypeMapContainer > grid_unit_searcher(searcher); 1840 1841 CellLock<GridReadGuard> cell_lock(cell, p); 1842 cell_lock->Visit(cell_lock, world_unit_searcher, GetMap()); 1843 cell_lock->Visit(cell_lock, grid_unit_searcher, GetMap()); 1844 }*/ 1845 return NULL; 1846 } 1847 1825 1848 void Creature::CallAssistence() 1826 1849 { -
trunk/src/game/Creature.h
r265 r266 560 560 float GetAttackDistance(Unit const* pl) const; 561 561 562 Unit* SelectNearestTarget(float dist = 0) const; 562 563 void CallAssistence(); 563 564 void SetNoCallAssistence(bool val) { m_AlreadyCallAssistence = val; } -
trunk/src/game/GridNotifiers.h
r233 r266 699 699 // Creature checks 700 700 701 class InAttackDistanceFromAnyHostileCreatureCheck 702 { 703 public: 704 explicit InAttackDistanceFromAnyHostileCreatureCheck(Unit* funit) : i_funit(funit) {} 705 bool operator()(Creature* u) 706 { 707 if(u->isAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) 708 return true; 709 710 return false; 711 } 712 private: 713 Unit* const i_funit; 701 class NearestHostileUnitInAttackDistanceCheck 702 { 703 public: 704 explicit NearestHostileUnitInAttackDistanceCheck(Creature* creature, float dist = 0) : m_creature(creature) 705 { 706 m_range = (dist == 0 ? 9999 : dist); 707 m_force = (dist == 0 ? false : true); 708 } 709 bool operator()(Unit* u) 710 { 711 if(!u->isAlive() || !m_creature->IsHostileTo(u)) 712 return false; 713 714 float dist; 715 if(m_force) dist = m_range; 716 else 717 { 718 dist = m_creature->GetAttackDistance(u); 719 if(dist > m_range) dist = m_range; 720 } 721 if(!m_creature->IsWithinDistInMap(u, dist)) 722 return false; 723 724 if(!m_creature->canSeeOrDetect(u, true, false)) 725 return false; 726 727 m_range = m_creature->GetDistance(u); 728 return true; 729 } 730 float GetLastRange() const { return m_range; } 731 private: 732 Creature* const m_creature; 733 float m_range; 734 bool m_force; 735 NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); 714 736 }; 715 737 -
trunk/src/game/Map.cpp
r260 r266 597 597 void Map::Update(const uint32 &t_diff) 598 598 { 599 resetMarkedCells(); 599 // TODO: need have an active object list for every map 600 601 /*resetMarkedCells(); 600 602 601 603 Trinity::ObjectUpdater updater(t_diff); … … 643 645 } 644 646 } 645 } 646 647 }*/ 647 648 648 649 // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! -
trunk/src/game/ObjectAccessor.cpp
r257 r266 504 504 505 505 { 506 //Player update now in MapManager -> UpdatePlayers 507 /* 506 508 // player update might remove the player from grid, and that causes crashes. We HAVE to update players first, and then the active objects. 507 509 HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer(); … … 512 514 iter->second->Update(diff); 513 515 } 514 } 515 516 }*/ 517 518 // TODO: move this to Map::Update 516 519 // clone the active object list, because update might remove from it 517 520 std::set<WorldObject *> activeobjects(i_activeobjects); … … 573 576 } 574 577 } 578 579 UpdateDataMapType update_players; 580 { 581 Guard guard(i_updateGuard); 582 while(!i_objects.empty()) 583 { 584 Object* obj = *i_objects.begin(); 585 i_objects.erase(i_objects.begin()); 586 if (!obj) 587 continue; 588 _buildUpdateObject(obj, update_players); 589 obj->ClearUpdateMask(false); 590 } 591 } 592 593 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 594 for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) 595 { 596 iter->second.BuildPacket(&packet); 597 iter->first->GetSession()->SendPacket(&packet); 598 packet.clear(); // clean the string 599 } 575 600 } 576 601 -
trunk/src/game/Unit.cpp
r265 r266 10425 10425 } 10426 10426 10427 Unit* Unit::SelectNearbyTarget( ) const10427 Unit* Unit::SelectNearbyTarget(float dist) const 10428 10428 { 10429 10429 CellPair p(Trinity::ComputeCellPair(GetPositionX(), GetPositionY())); … … 10435 10435 10436 10436 { 10437 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, ATTACK_DISTANCE);10437 Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, this, dist); 10438 10438 Trinity::UnitListSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> searcher(targets, u_check); 10439 10439 -
trunk/src/game/Unit.h
r257 r266 763 763 void CombatStop(bool cast = false); 764 764 void CombatStopWithPets(bool cast = false); 765 Unit* SelectNearbyTarget( ) const;765 Unit* SelectNearbyTarget(float dist = ATTACK_DISTANCE) const; 766 766 767 767 void addUnitState(uint32 f) { m_state |= f; }