From 3afd542de2bd91e6a44870a9539a3ece1ee5818d Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 22 Jan 2009 05:09:43 +0300 Subject: [PATCH] [7143] Avoid selection quest taxi nodes for taxi master map. Preper at loading more stricted taxi nodes mask for normal taxi network with excliuded quest only nodes (used from spells with SPELL_EFFECT_SEND_TAXI. Use prepered mask at search nearest to taxi master taxi node. --- src/game/ObjectMgr.cpp | 31 +++++++++++------- src/shared/Database/DBCStores.cpp | 53 ++++++++++++++++++++++++------- src/shared/revision_nr.h | 2 +- 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 269e490d1..22bf7155c 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4767,24 +4767,31 @@ uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, u for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) { TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); - if(node && node->map_id == mapid && node->MountCreatureID[team == ALLIANCE ? 1 : 0]) + if(!node || node->map_id != mapid || !node->MountCreatureID[team == ALLIANCE ? 1 : 0]) + continue; + + uint8 field = (uint8)((i - 1) / 32); + uint32 submask = 1<<((i-1)%32); + + // skip not taxi network nodes + if((sTaxiNodesMask[field] & submask)==0) + continue; + + float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); + if(found) { - float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); - if(found) + if(dist2 < dist) { - if(dist2 < dist) - { - dist = dist2; - id = i; - } - } - else - { - found = true; dist = dist2; id = i; } } + else + { + found = true; + dist = dist2; + id = i; + } } return id; diff --git a/src/shared/Database/DBCStores.cpp b/src/shared/Database/DBCStores.cpp index b10d89959..a486d2896 100644 --- a/src/shared/Database/DBCStores.cpp +++ b/src/shared/Database/DBCStores.cpp @@ -405,18 +405,6 @@ void LoadDBCStores(const std::string& dataPath) LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc"); - // Initialize global taxinodes mask - memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); - for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) - { - if(sTaxiNodesStore.LookupEntry(i)) - { - uint8 field = (uint8)((i - 1) / 32); - uint32 submask = 1<<((i-1)%32); - sTaxiNodesMask[field] |= submask; - } - } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc"); for(uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i) if(TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i)) @@ -444,6 +432,47 @@ void LoadDBCStores(const std::string& dataPath) sTaxiPathNodesByPath[entry->path][entry->index] = TaxiPathNode(entry->mapid,entry->x,entry->y,entry->z,entry->actionFlag,entry->delay); sTaxiPathNodeStore.Clear(); + // Initialize global taxinodes mask + // include existed nodes that have at least single not spell base (scripted) path + { + std::set spellPaths; + for(uint32 i = 1; i < sSpellStore.GetNumRows (); ++i) + if(SpellEntry const* sInfo = sSpellStore.LookupEntry (i)) + for(int j=0; j < 3; ++j) + if(sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) + spellPaths.insert(sInfo->EffectMiscValue[j]); + + memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); + for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) + { + if(!sTaxiNodesStore.LookupEntry(i)) + continue; + + TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i); + if(src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty()) + { + bool ok = false; + for(TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin();dest_i != src_i->second.end(); ++dest_i) + { + // not spell path + if(spellPaths.find(dest_i->second.ID)==spellPaths.end()) + { + ok = true; + break; + } + } + + if(!ok) + continue; + } + + // valid taxi netowrk node + uint8 field = (uint8)((i - 1) / 32); + uint32 submask = 1<<((i-1)%32); + sTaxiNodesMask[field] |= submask; + } + } + LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore, dbcPath,"TotemCategory.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 2714b05be..26768f95a 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7142" + #define REVISION_NR "7143" #endif // __REVISION_NR_H__