Changeset 44 for trunk/src/game/Map.cpp
- Timestamp:
- 11/19/08 13:27:40 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Map.cpp
r2 r44 1 1 /* 2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> 2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> 3 * 4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> 3 5 * 4 6 * This program is free software; you can redistribute it and/or modify … … 9 11 * This program is distributed in the hope that it will be useful, 10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 14 * GNU General Public License for more details. 13 15 * 14 16 * You should have received a copy of the GNU General Public License 15 17 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 19 */ 18 20 … … 422 424 423 425 // update player state for other player and visa-versa 424 CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());426 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 425 427 Cell cell(p); 426 428 EnsureGridLoadedForPlayer(cell, player, true); … … 441 443 Map::Add(T *obj) 442 444 { 443 CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());445 CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 444 446 445 447 assert(obj); … … 468 470 void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) 469 471 { 470 CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());472 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 471 473 472 474 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) … … 482 484 return; 483 485 484 MaNGOS::MessageDeliverer post_man(*player, msg, to_self);485 TypeContainerVisitor< MaNGOS::MessageDeliverer, WorldTypeMapContainer > message(post_man);486 Trinity::MessageDeliverer post_man(*player, msg, to_self); 487 TypeContainerVisitor<Trinity::MessageDeliverer, WorldTypeMapContainer > message(post_man); 486 488 CellLock<ReadGuard> cell_lock(cell, p); 487 489 cell_lock->Visit(cell_lock, message, *this); … … 490 492 void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) 491 493 { 492 CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());494 CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 493 495 494 496 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) … … 505 507 return; 506 508 507 MaNGOS::ObjectMessageDeliverer post_man(msg);508 TypeContainerVisitor< MaNGOS::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man);509 Trinity::ObjectMessageDeliverer post_man(msg); 510 TypeContainerVisitor<Trinity::ObjectMessageDeliverer, WorldTypeMapContainer > message(post_man); 509 511 CellLock<ReadGuard> cell_lock(cell, p); 510 512 cell_lock->Visit(cell_lock, message, *this); … … 513 515 void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) 514 516 { 515 CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());517 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 516 518 517 519 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) … … 527 529 return; 528 530 529 MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only);530 TypeContainerVisitor< MaNGOS::MessageDistDeliverer , WorldTypeMapContainer > message(post_man);531 Trinity::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); 532 TypeContainerVisitor<Trinity::MessageDistDeliverer , WorldTypeMapContainer > message(post_man); 531 533 CellLock<ReadGuard> cell_lock(cell, p); 532 534 cell_lock->Visit(cell_lock, message, *this); … … 535 537 void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) 536 538 { 537 CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());539 CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 538 540 539 541 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) … … 550 552 return; 551 553 552 MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg,dist);553 TypeContainerVisitor< MaNGOS::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man);554 Trinity::ObjectMessageDistDeliverer post_man(*obj, msg,dist); 555 TypeContainerVisitor<Trinity::ObjectMessageDistDeliverer, WorldTypeMapContainer > message(post_man); 554 556 CellLock<ReadGuard> cell_lock(cell, p); 555 557 cell_lock->Visit(cell_lock, message, *this); … … 589 591 void Map::Remove(Player *player, bool remove) 590 592 { 591 CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());593 CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 592 594 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 593 595 { … … 641 643 Map::Remove(T *obj, bool remove) 642 644 { 643 CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());645 CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 644 646 if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 645 647 { … … 675 677 assert(player); 676 678 677 CellPair old_val = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY());678 CellPair new_val = MaNGOS::ComputeCellPair(x, y);679 CellPair old_val = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 680 CellPair new_val = Trinity::ComputeCellPair(x, y); 679 681 680 682 Cell old_cell(old_val); … … 721 723 Cell old_cell = creature->GetCurrentCell(); 722 724 723 CellPair new_val = MaNGOS::ComputeCellPair(x, y);725 CellPair new_val = Trinity::ComputeCellPair(x, y); 724 726 Cell new_cell(new_val); 725 727 … … 727 729 if( old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell) ) 728 730 { 729 #ifdef MANGOS_DEBUG731 #ifdef TRINITY_DEBUG 730 732 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 731 733 sLog.outDebug("Creature (GUID: %u Entry: %u) added to moving list from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", creature->GetGUIDLow(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); … … 761 763 762 764 // calculate cells 763 CellPair new_val = MaNGOS::ComputeCellPair(cm.x, cm.y);765 CellPair new_val = Trinity::ComputeCellPair(cm.x, cm.y); 764 766 Cell new_cell(new_val); 765 767 … … 778 780 { 779 781 // ... or unload (if respawn grid also not loaded) 780 #ifdef MANGOS_DEBUG782 #ifdef TRINITY_DEBUG 781 783 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 782 784 sLog.outDebug("Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",c->GetGUIDLow(),c->GetEntry()); … … 797 799 if(old_cell.DiffCell(new_cell)) 798 800 { 799 #ifdef MANGOS_DEBUG801 #ifdef TRINITY_DEBUG 800 802 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 801 803 sLog.outDebug("Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); … … 811 813 else 812 814 { 813 #ifdef MANGOS_DEBUG815 #ifdef TRINITY_DEBUG 814 816 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 815 817 sLog.outDebug("Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY()); … … 820 822 if(loaded(GridPair(new_cell.GridX(), new_cell.GridY()))) 821 823 { 822 #ifdef MANGOS_DEBUG824 #ifdef TRINITY_DEBUG 823 825 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 824 826 sLog.outDebug("Creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); … … 833 835 else 834 836 { 835 #ifdef MANGOS_DEBUG837 #ifdef TRINITY_DEBUG 836 838 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 837 839 sLog.outDebug("Creature (GUID: %u Entry: %u) attempt move from grid[%u,%u]cell[%u,%u] to unloaded grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); … … 848 850 c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o); 849 851 850 CellPair resp_val = MaNGOS::ComputeCellPair(resp_x, resp_y);852 CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y); 851 853 Cell resp_cell(resp_val); 852 854 … … 854 856 c->GetMotionMaster()->Clear(); 855 857 856 #ifdef MANGOS_DEBUG858 #ifdef TRINITY_DEBUG 857 859 if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 858 860 sLog.outDebug("Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY()); … … 932 934 float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const 933 935 { 934 GridPair p = MaNGOS::ComputeGridPair(x, y);936 GridPair p = Trinity::ComputeGridPair(x, y); 935 937 936 938 // half opt method … … 1029 1031 float lx,ly; 1030 1032 int gx,gy; 1031 GridPair p = MaNGOS::ComputeGridPair(x, y);1033 GridPair p = Trinity::ComputeGridPair(x, y); 1032 1034 1033 1035 // half opt method … … 1140 1142 Cell const& cur_cell = c->GetCurrentCell(); 1141 1143 1142 CellPair xy_val = MaNGOS::ComputeCellPair(c->GetPositionX(), c->GetPositionY());1144 CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); 1143 1145 Cell xy_cell(xy_val); 1144 1146 if(xy_cell != cur_cell) … … 1164 1166 cell.data.Part.reserved = ALL_DISTRICT; 1165 1167 cell.SetNoCreate(); 1166 MaNGOS::VisibleChangesNotifier notifier(*obj);1167 TypeContainerVisitor< MaNGOS::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier);1168 Trinity::VisibleChangesNotifier notifier(*obj); 1169 TypeContainerVisitor<Trinity::VisibleChangesNotifier, WorldTypeMapContainer > player_notifier(notifier); 1168 1170 CellLock<GridReadGuard> cell_lock(cell, cellpair); 1169 1171 cell_lock->Visit(cell_lock, player_notifier, *this); … … 1174 1176 cell.data.Part.reserved = ALL_DISTRICT; 1175 1177 1176 MaNGOS::PlayerNotifier pl_notifier(*player);1177 TypeContainerVisitor< MaNGOS::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier);1178 Trinity::PlayerNotifier pl_notifier(*player); 1179 TypeContainerVisitor<Trinity::PlayerNotifier, WorldTypeMapContainer > player_notifier(pl_notifier); 1178 1180 1179 1181 CellLock<ReadGuard> cell_lock(cell, cellpair); … … 1183 1185 void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair ) 1184 1186 { 1185 MaNGOS::VisibleNotifier notifier(*player);1187 Trinity::VisibleNotifier notifier(*player); 1186 1188 1187 1189 cell.data.Part.reserved = ALL_DISTRICT; 1188 1190 cell.SetNoCreate(); 1189 TypeContainerVisitor< MaNGOS::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier);1190 TypeContainerVisitor< MaNGOS::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier);1191 TypeContainerVisitor<Trinity::VisibleNotifier, WorldTypeMapContainer > world_notifier(notifier); 1192 TypeContainerVisitor<Trinity::VisibleNotifier, GridTypeMapContainer > grid_notifier(notifier); 1191 1193 CellLock<GridReadGuard> cell_lock(cell, cellpair); 1192 1194 cell_lock->Visit(cell_lock, world_notifier, *this); … … 1200 1202 { 1201 1203 CellLock<ReadGuard> cell_lock(cell, cellpair); 1202 MaNGOS::PlayerRelocationNotifier relocationNotifier(*player);1204 Trinity::PlayerRelocationNotifier relocationNotifier(*player); 1203 1205 cell.data.Part.reserved = ALL_DISTRICT; 1204 1206 1205 TypeContainerVisitor< MaNGOS::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier);1206 TypeContainerVisitor< MaNGOS::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier);1207 TypeContainerVisitor<Trinity::PlayerRelocationNotifier, GridTypeMapContainer > p2grid_relocation(relocationNotifier); 1208 TypeContainerVisitor<Trinity::PlayerRelocationNotifier, WorldTypeMapContainer > p2world_relocation(relocationNotifier); 1207 1209 1208 1210 cell_lock->Visit(cell_lock, p2grid_relocation, *this); … … 1213 1215 { 1214 1216 CellLock<ReadGuard> cell_lock(cell, cellpair); 1215 MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature);1217 Trinity::CreatureRelocationNotifier relocationNotifier(*creature); 1216 1218 cell.data.Part.reserved = ALL_DISTRICT; 1217 1219 cell.SetNoCreate(); // not trigger load unloaded grids at notifier call 1218 1220 1219 TypeContainerVisitor< MaNGOS::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier);1220 TypeContainerVisitor< MaNGOS::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier);1221 TypeContainerVisitor<Trinity::CreatureRelocationNotifier, WorldTypeMapContainer > c2world_relocation(relocationNotifier); 1222 TypeContainerVisitor<Trinity::CreatureRelocationNotifier, GridTypeMapContainer > c2grid_relocation(relocationNotifier); 1221 1223 1222 1224 cell_lock->Visit(cell_lock, c2world_relocation, *this);