All pastes #996037 Raw Edit

Miscellany

public text v1 · immutable
#996037 ·published 2008-04-24 17:52 UTC
rendered paste body
Index: src/game/Creature.cpp
===================================================================
--- src/game/Creature.cpp	(revision 5691)
+++ src/game/Creature.cpp	(working copy)
@@ -573,7 +573,7 @@
                             cantalking=false;
                         break;
                     case GOSSIP_OPTION_TAXIVENDOR:
-                        if ( pPlayer->GetSession()->SendLearnNewTaxiNode(GetGUID()) )
+                        if ( pPlayer->GetSession()->SendLearnNewTaxiNode(this) )
                             return;
                         break;
                     case GOSSIP_OPTION_BATTLEFIELD:
@@ -688,7 +688,7 @@
             player->SendPetSkillWipeConfirm();
             break;
         case GOSSIP_OPTION_TAXIVENDOR:
-            player->GetSession()->SendTaxiMenu(guid);
+            player->GetSession()->SendTaxiMenu(this);
             break;
         case GOSSIP_OPTION_INNKEEPER:
             player->PlayerTalkClass->CloseGossip();
Index: src/game/Player.cpp
===================================================================
--- src/game/Player.cpp	(revision 5691)
+++ src/game/Player.cpp	(working copy)
@@ -5033,7 +5033,12 @@
     if(!factionTemplateEntry)
         return;
 
-    FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction);
+    SetFactionVisibleForFactionId(factionTemplateEntry->faction);
+}
+
+void Player::SetFactionVisibleForFactionId(uint32 FactionId)
+{
+    FactionEntry const *factionEntry = sFactionStore.LookupEntry(FactionId);
     if(!factionEntry)
         return;
 
@@ -11319,6 +11324,9 @@
     GiveQuestSourceItem( pQuest );
     AdjustQuestReqItemCount( pQuest );
 
+    if( pQuest->GetRepObjectiveFaction() )
+        SetFactionVisibleForFactionId(pQuest->GetRepObjectiveFaction());
+
     uint32 qtime = 0;
     if( pQuest->HasFlag( QUEST_MANGOS_FLAGS_TIMED ) )
     {
Index: src/game/Player.h
===================================================================
--- src/game/Player.h	(revision 5691)
+++ src/game/Player.h	(working copy)
@@ -915,12 +915,23 @@
         void InitTaxiNodesForLevel();
         uint32 GetTaximask( uint8 index ) const { return m_taximask[index]; }
         void SetTaximask( uint8 index, uint32 value ) { m_taximask[index] = value; }
-        void SetTaximaskNode(uint32 nodeidx)
+        bool IsTaximaskNodeKnown(uint32 nodeidx) const
         {
             uint8  field   = uint8((nodeidx - 1) / 32);
             uint32 submask = 1<<((nodeidx-1)%32);
+            return (m_taximask[field] & submask) == submask;
+        }
+        bool SetTaximaskNode(uint32 nodeidx)
+        {
+            uint8  field   = uint8((nodeidx - 1) / 32);
+            uint32 submask = 1<<((nodeidx-1)%32);
             if ((m_taximask[field] & submask) != submask )
+            {
                 m_taximask[field] = (submask | m_taximask[field]);
+                return true;
+            }
+            else
+                return false;
         }
         void ClearTaxiDestinations() { m_TaxiDestinations.clear(); }
         void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); }
@@ -1650,6 +1661,7 @@
         void SetFactionInactive(uint32 repListID, bool inactive);
         void SetFactionVisible(uint32 repListID);
         void SetFactionVisibleForFactionTemplateId(uint32 FactionTemplateId);
+        void SetFactionVisibleForFactionId(uint32 FactionId);
         void UpdateMaxSkills();
         void UpdateSkillsToMaxSkillsForLevel();             // for .levelup
         void ModifySkillBonus(uint32 skillid,int32 val, bool talent);
Index: src/game/TaxiHandler.cpp
===================================================================
--- src/game/TaxiHandler.cpp	(revision 5691)
+++ src/game/TaxiHandler.cpp	(working copy)
@@ -46,15 +46,15 @@
 
 void WorldSession::SendTaxiStatus( uint64 guid )
 {
-    uint32 curloc;
-    uint8 field;
-    uint32 submask;
+    // cheating checks
+    Creature *unit = ObjectAccessor::GetCreature(*_player, guid);
+    if (!unit)
+    {
+        sLog.outDebug( "WorldSession::SendTaxiStatus - Unit (GUID: %u) not found.", uint32(GUID_LOPART(guid)) );
+        return;
+    }
 
-    curloc = objmgr.GetNearestTaxiNode(
-        GetPlayer( )->GetPositionX( ),
-        GetPlayer( )->GetPositionY( ),
-        GetPlayer( )->GetPositionZ( ),
-        GetPlayer( )->GetMapId( ) );
+    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId());
 
     // not found nearest
     if(curloc == 0)
@@ -62,17 +62,9 @@
 
     sLog.outDebug( "WORLD: current location %u ",curloc);
 
-    field = (uint8)((curloc - 1) / 32);
-    submask = 1<<((curloc-1)%32);
-
     WorldPacket data( SMSG_TAXINODE_STATUS, 9 );
     data << guid;
-
-    if ( (GetPlayer( )->GetTaximask(field) & submask) != submask )
-        data << uint8( 0 );
-    else
-        data << uint8( 1 );
-
+    data << uint8( GetPlayer( )->IsTaximaskNodeKnown(curloc) ? 1 : 0 );
     SendPacket( &data );
     sLog.outDebug( "WORLD: Sent SMSG_TAXINODE_STATUS" );
 }
@@ -99,21 +91,17 @@
         GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
 
     // unknown taxi node case
-    if( SendLearnNewTaxiNode(guid) )
+    if( SendLearnNewTaxiNode(unit) )
         return;
 
     // known taxi node case
-    SendTaxiMenu( guid );
+    SendTaxiMenu( unit );
 }
 
-void WorldSession::SendTaxiMenu( uint64 guid )
+void WorldSession::SendTaxiMenu( Creature* unit )
 {
     // find current node
-    uint32 curloc = objmgr.GetNearestTaxiNode(
-        GetPlayer( )->GetPositionX( ),
-        GetPlayer( )->GetPositionY( ),
-        GetPlayer( )->GetPositionZ( ),
-        GetPlayer( )->GetMapId( ) );
+    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId());
 
     if ( curloc == 0 )
         return;
@@ -121,7 +109,8 @@
     sLog.outDebug( "WORLD: CMSG_TAXINODE_STATUS_QUERY %u ",curloc);
 
     WorldPacket data( SMSG_SHOWTAXINODES, (4+8+4+8*4) );
-    data << uint32( 1 ) << guid;
+    data << uint32( 1 );
+    data << uint64( unit->GetGUID() );
     data << uint32( curloc );
 
     if(GetPlayer()->isTaxiCheater())
@@ -158,36 +147,28 @@
     SendPath(flight->GetPath(),flight->GetCurrentNode(),flight->GetPathAtMapEnd());
 }
 
-bool WorldSession::SendLearnNewTaxiNode( uint64 guid )
+bool WorldSession::SendLearnNewTaxiNode( Creature* unit )
 {
     // find current node
-    uint32 curloc = objmgr.GetNearestTaxiNode(
-        GetPlayer( )->GetPositionX( ),
-        GetPlayer( )->GetPositionY( ),
-        GetPlayer( )->GetPositionZ( ),
-        GetPlayer( )->GetMapId( ) );
+    uint32 curloc = objmgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId());
 
     if ( curloc == 0 )
         return true;                                        // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result.
 
-    uint8  field   = (uint8)((curloc - 1) / 32);
-    uint32 submask = 1<<((curloc-1)%32);
-
-    if ( (GetPlayer( )->GetTaximask(field) & submask) != submask )
+    if( GetPlayer()->SetTaximaskNode(curloc) )
     {
-        GetPlayer()->SetTaximask(field, (submask | GetPlayer( )->GetTaximask(field)) );
-
         WorldPacket msg(SMSG_NEW_TAXI_PATH, 0);
-        _player->GetSession()->SendPacket( &msg );
+        SendPacket( &msg );
 
         WorldPacket update( SMSG_TAXINODE_STATUS, 9 );
-        update << guid;
+        update << uint64( unit->GetGUID() );
         update << uint8( 1 );
         SendPacket( &update );
 
         return true;
-    } else
-    return false;
+    }
+    else
+        return false;
 }
 
 void WorldSession::HandleActivateTaxiFarOpcode ( WorldPacket & recv_data )
@@ -260,12 +241,8 @@
         // Add to taximask middle hubs in taxicheat mode (to prevent having player with disabled taxicheat and not having back flight path)
         if (GetPlayer()->isTaxiCheater())
         {
-            uint8 field = (uint8)((sourcenode - 1) / 32);
-            uint32 submask = 1<<((sourcenode-1)%32);
-            if((GetPlayer( )->GetTaximask(field) & submask) != submask )
+            if(GetPlayer()->SetTaximaskNode(sourcenode))
             {
-                GetPlayer()->SetTaximask(field, (submask | GetPlayer( )->GetTaximask(field)) );
-
                 WorldPacket data(SMSG_NEW_TAXI_PATH, 0);
                 _player->GetSession()->SendPacket( &data );
             }
Index: src/game/WorldSession.h
===================================================================
--- src/game/WorldSession.h	(revision 5691)
+++ src/game/WorldSession.h	(working copy)
@@ -163,9 +163,9 @@
 
         //Taxi
         void SendTaxiStatus( uint64 guid );
-        void SendTaxiMenu( uint64 guid );
+        void SendTaxiMenu( Creature* unit );
         void SendDoFlight( uint16 MountId, uint32 path, uint32 pathNode = 0 );
-        bool SendLearnNewTaxiNode( uint64 guid );
+        bool SendLearnNewTaxiNode( Creature* unit );
 
         // Guild/Arena Team
         void SendGuildCommandResult(uint32 typecmd,std::string str,uint32 cmdresult);