stoneharry

Untitled

Aug 1st, 2013
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.61 KB | None | 0 0
  1.  
  2. void WorldSession::HandleMirrorImageOpcode(WorldPacket & recv_data)
  3. {
  4.     if(!_player->IsInWorld())
  5.         return;
  6.  
  7.     LOG_DEBUG("Received CMG_GET_MIRRORIMAGE_DATA");
  8.  
  9.     uint64 GUID;
  10.  
  11.     recv_data >> GUID;
  12.  
  13.     Unit* Image = _player->GetMapMgr()->GetUnit(GUID);
  14.     if(Image == NULL)
  15.         return;                 // ups no unit found with that GUID on the
  16.     // map. Spoofed packet?
  17.    
  18.     stdext::hash_set<uint32>::iterator iter = mirrorImagePacketHookSet.find(Image->GetEntry());
  19.     if (iter != mirrorImagePacketHookSet.end())
  20.     {
  21.         WorldPacket data = MirrorImagePacketHook(Image);
  22.         SendPacket(&data);
  23.         return;
  24.     }
  25.  
  26.     if(Image->GetCreatedByGUID() == 0)
  27.         return;
  28.  
  29.     uint64 CasterGUID = Image->GetCreatedByGUID();
  30.     Unit* Caster = _player->GetMapMgr()->GetUnit(CasterGUID);
  31.     if(Caster == NULL)
  32.         return;                
  33.     // apperantly this mirror image mirrors
  34.     // nothing, poor lonely soul :(
  35.     // Maybe it's the Caster's ghost called Casper
  36.  
  37.     WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
  38.  
  39.     data << uint64(GUID);
  40.     data << uint32(Caster->GetDisplayId());
  41.     data << uint8(Caster->getRace());
  42.  
  43.     if(Caster->IsPlayer())
  44.     {
  45.         Player* pcaster = static_cast < Player* >(Caster);
  46.  
  47.         data << uint8(pcaster->getGender());
  48.         data << uint8(pcaster->getClass());
  49.  
  50.         // facial features, like big nose, piercings, bonehead, etc
  51.         data << uint8(pcaster->GetByte(PLAYER_BYTES, 0));   // skin color
  52.         data << uint8(pcaster->GetByte(PLAYER_BYTES, 1));   // face
  53.         data << uint8(pcaster->GetByte(PLAYER_BYTES, 2));   // hair style
  54.         data << uint8(pcaster->GetByte(PLAYER_BYTES, 3));   // hair color
  55.         data << uint8(pcaster->GetByte(PLAYER_BYTES_2, 0)); // facial hair
  56.  
  57.         if(pcaster->IsInGuild())
  58.             data << uint32(pcaster->GetGuildId());
  59.         else
  60.             data << uint32(0);
  61.  
  62.         static const uint32 imageitemslots[] =
  63.         {
  64.             EQUIPMENT_SLOT_HEAD,
  65.             EQUIPMENT_SLOT_SHOULDERS,
  66.             EQUIPMENT_SLOT_BODY,
  67.             EQUIPMENT_SLOT_CHEST,
  68.             EQUIPMENT_SLOT_WAIST,
  69.             EQUIPMENT_SLOT_LEGS,
  70.             EQUIPMENT_SLOT_FEET,
  71.             EQUIPMENT_SLOT_WRISTS,
  72.             EQUIPMENT_SLOT_HANDS,
  73.             EQUIPMENT_SLOT_BACK,
  74.             EQUIPMENT_SLOT_TABARD
  75.         };
  76.  
  77.         for(uint32 i = 0; i < 11; ++i)
  78.         {
  79.             Item* item =
  80.                 pcaster->GetItemInterface()->GetInventoryItem(static_cast <
  81.                         int16 >
  82.                         (imageitemslots
  83.                          [i]));
  84.             if(i == EQUIPMENT_SLOT_HEAD && pcaster->HasFlag(PLAYER_FLAGS, 0x00000400))
  85.                 item = NULL;
  86.             if(i == EQUIPMENT_SLOT_BACK && pcaster->HasFlag(PLAYER_FLAGS, 0x00000800))
  87.                 item = NULL;
  88.             if(item != NULL)
  89.                 data << uint32(item->GetProto()->DisplayInfoID);
  90.             else
  91.                 data << uint32(0);
  92.         }
  93.     }
  94.  
  95.     SendPacket(&data);
  96.  
  97.     LOG_DEBUG("Sent: SMSG_MIRRORIMAGE_DATA");
  98. }
Advertisement
Add Comment
Please, Sign In to add comment