Changeset 44 for trunk/src/game/Map.cpp

Show
Ignore:
Timestamp:
11/19/08 13:27:40 (17 years ago)
Author:
yumileroy
Message:

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Map.cpp

    r2 r44  
    11/* 
    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/> 
    35 * 
    46 * This program is free software; you can redistribute it and/or modify 
     
    911 * This program is distributed in the hope that it will be useful, 
    1012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    1214 * GNU General Public License for more details. 
    1315 * 
    1416 * You should have received a copy of the GNU General Public License 
    1517 * along with this program; if not, write to the Free Software 
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    1719 */ 
    1820 
     
    422424 
    423425    // 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()); 
    425427    Cell cell(p); 
    426428    EnsureGridLoadedForPlayer(cell, player, true); 
     
    441443Map::Add(T *obj) 
    442444{ 
    443     CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
     445    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
    444446 
    445447    assert(obj); 
     
    468470void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) 
    469471{ 
    470     CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
     472    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    471473 
    472474    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 
     
    482484        return; 
    483485 
    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); 
    486488    CellLock<ReadGuard> cell_lock(cell, p); 
    487489    cell_lock->Visit(cell_lock, message, *this); 
     
    490492void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) 
    491493{ 
    492     CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
     494    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
    493495 
    494496    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 
     
    505507        return; 
    506508 
    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); 
    509511    CellLock<ReadGuard> cell_lock(cell, p); 
    510512    cell_lock->Visit(cell_lock, message, *this); 
     
    513515void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, bool to_self, bool own_team_only) 
    514516{ 
    515     CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
     517    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    516518 
    517519    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 
     
    527529        return; 
    528530 
    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); 
    531533    CellLock<ReadGuard> cell_lock(cell, p); 
    532534    cell_lock->Visit(cell_lock, message, *this); 
     
    535537void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) 
    536538{ 
    537     CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
     539    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
    538540 
    539541    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 
     
    550552        return; 
    551553 
    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); 
    554556    CellLock<ReadGuard> cell_lock(cell, p); 
    555557    cell_lock->Visit(cell_lock, message, *this); 
     
    589591void Map::Remove(Player *player, bool remove) 
    590592{ 
    591     CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
     593    CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); 
    592594    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) 
    593595    { 
     
    641643Map::Remove(T *obj, bool remove) 
    642644{ 
    643     CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
     645    CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); 
    644646    if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) 
    645647    { 
     
    675677    assert(player); 
    676678 
    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); 
    679681 
    680682    Cell old_cell(old_val); 
     
    721723    Cell old_cell = creature->GetCurrentCell(); 
    722724 
    723     CellPair new_val = MaNGOS::ComputeCellPair(x, y); 
     725    CellPair new_val = Trinity::ComputeCellPair(x, y); 
    724726    Cell new_cell(new_val); 
    725727 
     
    727729    if( old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell) ) 
    728730    { 
    729         #ifdef MANGOS_DEBUG 
     731        #ifdef TRINITY_DEBUG 
    730732        if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    731733            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()); 
     
    761763 
    762764        // calculate cells 
    763         CellPair new_val = MaNGOS::ComputeCellPair(cm.x, cm.y); 
     765        CellPair new_val = Trinity::ComputeCellPair(cm.x, cm.y); 
    764766        Cell new_cell(new_val); 
    765767 
     
    778780            { 
    779781                // ... or unload (if respawn grid also not loaded) 
    780                 #ifdef MANGOS_DEBUG 
     782                #ifdef TRINITY_DEBUG 
    781783                if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    782784                    sLog.outDebug("Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",c->GetGUIDLow(),c->GetEntry()); 
     
    797799        if(old_cell.DiffCell(new_cell)) 
    798800        { 
    799             #ifdef MANGOS_DEBUG 
     801            #ifdef TRINITY_DEBUG 
    800802            if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    801803                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()); 
     
    811813        else 
    812814        { 
    813             #ifdef MANGOS_DEBUG 
     815            #ifdef TRINITY_DEBUG 
    814816            if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    815817                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()); 
     
    820822    if(loaded(GridPair(new_cell.GridX(), new_cell.GridY()))) 
    821823    { 
    822         #ifdef MANGOS_DEBUG 
     824        #ifdef TRINITY_DEBUG 
    823825        if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    824826            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()); 
     
    833835    else 
    834836    { 
    835         #ifdef MANGOS_DEBUG 
     837        #ifdef TRINITY_DEBUG 
    836838        if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    837839            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()); 
     
    848850    c->GetRespawnCoord(resp_x, resp_y, resp_z, &resp_o); 
    849851 
    850     CellPair resp_val = MaNGOS::ComputeCellPair(resp_x, resp_y); 
     852    CellPair resp_val = Trinity::ComputeCellPair(resp_x, resp_y); 
    851853    Cell resp_cell(resp_val); 
    852854 
     
    854856    c->GetMotionMaster()->Clear(); 
    855857 
    856     #ifdef MANGOS_DEBUG 
     858    #ifdef TRINITY_DEBUG 
    857859    if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) 
    858860        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()); 
     
    932934float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const 
    933935{ 
    934     GridPair p = MaNGOS::ComputeGridPair(x, y); 
     936    GridPair p = Trinity::ComputeGridPair(x, y); 
    935937 
    936938    // half opt method 
     
    10291031    float lx,ly; 
    10301032    int gx,gy; 
    1031     GridPair p = MaNGOS::ComputeGridPair(x, y); 
     1033    GridPair p = Trinity::ComputeGridPair(x, y); 
    10321034 
    10331035    // half opt method 
     
    11401142    Cell const& cur_cell = c->GetCurrentCell(); 
    11411143 
    1142     CellPair xy_val = MaNGOS::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); 
     1144    CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); 
    11431145    Cell xy_cell(xy_val); 
    11441146    if(xy_cell != cur_cell) 
     
    11641166    cell.data.Part.reserved = ALL_DISTRICT; 
    11651167    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); 
    11681170    CellLock<GridReadGuard> cell_lock(cell, cellpair); 
    11691171    cell_lock->Visit(cell_lock, player_notifier, *this); 
     
    11741176    cell.data.Part.reserved = ALL_DISTRICT; 
    11751177 
    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); 
    11781180 
    11791181    CellLock<ReadGuard> cell_lock(cell, cellpair); 
     
    11831185void Map::UpdateObjectsVisibilityFor( Player* player, Cell cell, CellPair cellpair ) 
    11841186{ 
    1185     MaNGOS::VisibleNotifier notifier(*player); 
     1187    Trinity::VisibleNotifier notifier(*player); 
    11861188 
    11871189    cell.data.Part.reserved = ALL_DISTRICT; 
    11881190    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); 
    11911193    CellLock<GridReadGuard> cell_lock(cell, cellpair); 
    11921194    cell_lock->Visit(cell_lock, world_notifier, *this); 
     
    12001202{ 
    12011203    CellLock<ReadGuard> cell_lock(cell, cellpair); 
    1202     MaNGOS::PlayerRelocationNotifier relocationNotifier(*player); 
     1204    Trinity::PlayerRelocationNotifier relocationNotifier(*player); 
    12031205    cell.data.Part.reserved = ALL_DISTRICT; 
    12041206 
    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); 
    12071209 
    12081210    cell_lock->Visit(cell_lock, p2grid_relocation, *this); 
     
    12131215{ 
    12141216    CellLock<ReadGuard> cell_lock(cell, cellpair); 
    1215     MaNGOS::CreatureRelocationNotifier relocationNotifier(*creature); 
     1217    Trinity::CreatureRelocationNotifier relocationNotifier(*creature); 
    12161218    cell.data.Part.reserved = ALL_DISTRICT; 
    12171219    cell.SetNoCreate();                                     // not trigger load unloaded grids at notifier call 
    12181220 
    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); 
    12211223 
    12221224    cell_lock->Visit(cell_lock, c2world_relocation, *this);