Updated handlers

This commit is contained in:
tomrus88 2008-10-26 10:21:37 +03:00
parent 9c8864f134
commit e6115cdd55
9 changed files with 171 additions and 58 deletions

View file

@ -497,9 +497,11 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
data << pCurrChar->GetOrientation();
SendPacket(&data);
data.Initialize( SMSG_ACCOUNT_DATA_TIMES, 128 );
for(int i = 0; i < 32; i++)
data << uint32(0);
data.Initialize( SMSG_ACCOUNT_DATA_TIMES, 128 ); // changed in WotLK
data << uint32(0); // unix time of something
data << uint8(1);
for(int i = 0; i < 8; i++)
data << uint32(0); // also unix time
SendPacket(&data);
data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0
@ -581,11 +583,16 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
{
pCurrChar->setCinematic(1);
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace());
if(rEntry)
if(ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
{
data.Initialize( SMSG_TRIGGER_CINEMATIC,4 );
data << uint32(rEntry->startmovie);
data.Initialize(SMSG_TRIGGER_CINEMATIC, 4);
data << uint32(cEntry->CinematicSequence);
SendPacket( &data );
}
else if(ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
{
data.Initialize(SMSG_TRIGGER_CINEMATIC, 4);
data << uint32(rEntry->CinematicSequence);
SendPacket( &data );
}
}
@ -1078,3 +1085,73 @@ void WorldSession::HandleDeclinedPlayerNameOpcode(WorldPacket& recv_data)
data << uint64(guid);
SendPacket(&data);
}
void WorldSession::HandleAlterAppearance( WorldPacket & recv_data )
{
sLog.outDebug("CMSG_ALTER_APPEARANCE");
CHECK_PACKET_SIZE(recv_data, 4+4+4);
uint32 Hair, Color, FacialHair;
recv_data >> Hair >> Color >> FacialHair;
BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair);
if(!bs_hair)
return;
BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair);
if(!bs_facialHair)
return;
uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id);
// 0 - ok
// 1,3 - not enough money
// 2 - you have to seat on barber chair
if(_player->GetMoney() < Cost)
{
WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
data << uint32(1); // no money
SendPacket(&data);
return;
}
else
{
WorldPacket data(SMSG_BARBER_SHOP_RESULT, 4);
data << uint32(0); // ok
SendPacket(&data);
}
_player->SetMoney(_player->GetMoney() - Cost); // it isn't free
_player->SetByteValue(PLAYER_BYTES, 2, uint8(bs_hair->hair_id));
_player->SetByteValue(PLAYER_BYTES, 3, uint8(Color));
_player->SetByteValue(PLAYER_BYTES_2, 0, uint8(bs_facialHair->hair_id));
_player->SetStandState(0); // stand up
}
void WorldSession::HandleRemoveGlyph( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 4);
uint32 slot;
recv_data >> slot;
if(slot > 5)
{
sLog.outDebug("Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
return;
}
if(uint32 glyph = _player->GetGlyph(slot))
{
if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyph))
{
_player->RemoveAurasDueToSpell(gp->SpellId);
_player->SetGlyph(slot, 0);
}
}
}

View file

@ -681,10 +681,10 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
}
if (mask & GROUP_UPDATE_FLAG_CUR_HP)
*data << (uint16) player->GetHealth();
*data << (uint32) player->GetHealth();
if (mask & GROUP_UPDATE_FLAG_MAX_HP)
*data << (uint16) player->GetMaxHealth();
*data << (uint32) player->GetMaxHealth();
Powers powerType = player->getPowerType();
if (mask & GROUP_UPDATE_FLAG_POWER_TYPE)
@ -713,7 +713,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
{
if(auramask & (uint64(1) << i))
{
*data << uint16(player->GetUInt32Value(UNIT_FIELD_AURA + i));
*data << uint32(player->GetVisibleAura(i));
*data << uint8(1);
}
}
@ -747,17 +747,17 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
if (mask & GROUP_UPDATE_FLAG_PET_CUR_HP)
{
if(pet)
*data << (uint16) pet->GetHealth();
*data << (uint32) pet->GetHealth();
else
*data << (uint16) 0;
*data << (uint32) 0;
}
if (mask & GROUP_UPDATE_FLAG_PET_MAX_HP)
{
if(pet)
*data << (uint16) pet->GetMaxHealth();
*data << (uint32) pet->GetMaxHealth();
else
*data << (uint16) 0;
*data << (uint32) 0;
}
if (mask & GROUP_UPDATE_FLAG_PET_POWER_TYPE)
@ -794,7 +794,7 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player *player, WorldPacke
{
if(auramask & (uint64(1) << i))
{
*data << uint16(pet->GetUInt32Value(UNIT_FIELD_AURA + i));
*data << uint32(pet->GetVisibleAura(i));
*data << uint8(1);
}
}
@ -817,6 +817,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
if(!player)
{
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data.appendPackGUID(Guid);
data << (uint32) GROUP_UPDATE_FLAG_STATUS;
data << (uint16) MEMBER_STATUS_OFFLINE;
@ -827,6 +828,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
Pet *pet = player->GetPet();
WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8);
data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related
data.append(player->GetPackGUID());
uint32 mask1 = 0x00040BFF; // common mask, real flags used 0x000040BFF
@ -836,8 +838,8 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
Powers powerType = player->getPowerType();
data << (uint32) mask1; // group update mask
data << (uint16) MEMBER_STATUS_ONLINE; // member's online status
data << (uint16) player->GetHealth(); // GROUP_UPDATE_FLAG_CUR_HP
data << (uint16) player->GetMaxHealth(); // GROUP_UPDATE_FLAG_MAX_HP
data << (uint32) player->GetHealth(); // GROUP_UPDATE_FLAG_CUR_HP
data << (uint32) player->GetMaxHealth(); // GROUP_UPDATE_FLAG_MAX_HP
data << (uint8) powerType; // GROUP_UPDATE_FLAG_POWER_TYPE
data << (uint16) player->GetPower(powerType); // GROUP_UPDATE_FLAG_CUR_POWER
data << (uint16) player->GetMaxPower(powerType); // GROUP_UPDATE_FLAG_MAX_POWER
@ -851,11 +853,11 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
data << (uint64) auramask; // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 aura = player->GetUInt32Value(UNIT_FIELD_AURA + i))
if(uint32 aura = player->GetVisibleAura(i))
{
auramask |= (uint64(1) << i);
data << uint16(aura);
data << uint8(1);
data << (uint32) aura;
data << (uint8) 1;
}
}
data.put<uint64>(maskPos,auramask); // GROUP_UPDATE_FLAG_AURAS
@ -866,8 +868,8 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
data << (uint64) pet->GetGUID(); // GROUP_UPDATE_FLAG_PET_GUID
data << pet->GetName(); // GROUP_UPDATE_FLAG_PET_NAME
data << (uint16) pet->GetDisplayId(); // GROUP_UPDATE_FLAG_PET_MODEL_ID
data << (uint16) pet->GetHealth(); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << (uint16) pet->GetMaxHealth(); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << (uint32) pet->GetHealth(); // GROUP_UPDATE_FLAG_PET_CUR_HP
data << (uint32) pet->GetMaxHealth(); // GROUP_UPDATE_FLAG_PET_MAX_HP
data << (uint8) petpowertype; // GROUP_UPDATE_FLAG_PET_POWER_TYPE
data << (uint16) pet->GetPower(petpowertype); // GROUP_UPDATE_FLAG_PET_CUR_POWER
data << (uint16) pet->GetMaxPower(petpowertype); // GROUP_UPDATE_FLAG_PET_MAX_POWER
@ -877,10 +879,10 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data )
data << (uint64) petauramask; // placeholder
for(uint8 i = 0; i < MAX_AURAS; ++i)
{
if(uint32 petaura = pet->GetUInt32Value(UNIT_FIELD_AURA + i))
if(uint32 petaura = pet->GetVisibleAura(i))
{
petauramask |= (uint64(1) << i);
data << (uint16) petaura;
data << (uint32) petaura;
data << (uint8) 1;
}
}

View file

@ -314,7 +314,7 @@ void WorldSession::DoLootRelease( uint64 lguid )
int32 ReqValue = 175;
LockEntry const *lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId);
if(lockInfo)
ReqValue = lockInfo->requiredminingskill;
ReqValue = lockInfo->Skill[0];
float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25);
double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses));
if(roll_chance_f(100*chance+skill))

View file

@ -1066,16 +1066,35 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
GetPlayer()->TeleportTo(at->target_mapId,at->target_X,at->target_Y,at->target_Z,at->target_Orientation,TELE_TO_NOT_LEAVE_TRANSPORT);
}
void WorldSession::HandleUpdateAccountData(WorldPacket &/*recv_data*/)
void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
{
sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
//recv_data.hexlike();
recv_data.hexlike();
uint32 id1, id2, decompressedSize;
recv_data >> id1 >> id2 >> decompressedSize;
if(decompressedSize == 0)
return;
ByteBuffer dest;
dest.resize(decompressedSize);
uLongf realSize = decompressedSize;
if(uncompress(const_cast<uint8*>(dest.contents()), &realSize, const_cast<uint8*>(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) == Z_OK)
{
dest.hexlike();
}
else
{
sLog.outError("UAD: Failed to decompress packet");
}
}
void WorldSession::HandleRequestAccountData(WorldPacket& /*recv_data*/)
void WorldSession::HandleRequestAccountData(WorldPacket& recv_data)
{
sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
//recv_data.hexlike();
recv_data.hexlike();
}
void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data)
@ -1754,3 +1773,21 @@ void WorldSession::HandleSetTaxiBenchmarkOpcode( WorldPacket & recv_data )
sLog.outDebug("Client used \"/timetest %d\" command", mode);
}
void WorldSession::HandleSpellClick( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8);
uint64 guid;
recv_data >> guid;
Unit *vehicle = ObjectAccessor::GetUnit(*_player, guid);
if(!vehicle)
return;
_player->SetClientControl(vehicle, 1);
_player->CastSpell(_player, 43768, true);
_player->SetUInt64Value(UNIT_FIELD_CHARM, guid);
_player->SetUInt64Value(PLAYER_FARSIGHT, guid);
}

View file

@ -170,7 +170,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 4+1+4+4+4+4+4);
CHECK_PACKET_SIZE(recv_data, 4+2+4+4+4+4+4);
if(GetPlayer()->GetDontMove())
return;
@ -193,7 +193,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
if(MovementFlags & MOVEMENTFLAG_ONTRANSPORT)
{
// recheck
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4);
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4+1);
recv_data >> movementInfo.t_guid;
recv_data >> movementInfo.t_x;
@ -201,9 +201,10 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
recv_data >> movementInfo.t_z;
recv_data >> movementInfo.t_o;
recv_data >> movementInfo.t_time;
recv_data >> movementInfo.t_unk;
}
if(MovementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2))
if((MovementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) || (movementInfo.unk1 & 0x20))
{
// recheck
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4);
@ -351,7 +352,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
/*----------------------*/
/* process position-change */
recv_data.put<uint32>(5, getMSTime()); // offset flags(4) + unk(1)
recv_data.put<uint32>(6, getMSTime()); // offset flags(4) + unk(2)
WorldPacket data(recv_data.GetOpcode(), (GetPlayer()->GetPackGUID().size()+recv_data.size()));
data.append(GetPlayer()->GetPackGUID());
data.append(recv_data.contents(), recv_data.size());
@ -384,17 +385,18 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data)
{
CHECK_PACKET_SIZE(recv_data, 8+4+4+1+4+4+4+4+4);
CHECK_PACKET_SIZE(recv_data, 8+4+4+2+4+4+4+4+4);
/* extract packet */
uint64 guid;
uint8 unkB;
uint16 unkB;
uint32 unk1, flags, time, fallTime;
float x, y, z, orientation;
uint64 t_GUID;
float t_x, t_y, t_z, t_o;
uint32 t_time;
uint8 t_unk;
float s_pitch;
float j_unk1, j_sinAngle, j_cosAngle, j_xyspeed;
float u_unk1;
@ -414,12 +416,12 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recv_data)
if (flags & MOVEMENTFLAG_ONTRANSPORT)
{
// recheck
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4);
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+8+4+4+4+4+4+1);
recv_data >> t_GUID;
recv_data >> t_x >> t_y >> t_z >> t_o >> t_time;
recv_data >> t_x >> t_y >> t_z >> t_o >> t_time >> t_unk;
}
if (flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2))
if ((flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING2)) || (unkB & 0x20))
{
// recheck
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4);

View file

@ -517,13 +517,13 @@ void WorldSession::SendStablePet(uint64 guid )
data << uint32(pet->GetEntry());
data << uint32(pet->getLevel());
data << pet->GetName(); // petname
data << uint32(pet->GetLoyaltyLevel()); // loyalty
data << uint32(0); // was loyalty
data << uint8(0x01); // client slot 1 == current pet (0)
++num;
}
// 0 1 2 3 4 5 6
QueryResult* result = CharacterDatabase.PQuery("SELECT owner, slot, id, entry, level, loyalty, name FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow());
// 0 1 2 3 4 5
QueryResult* result = CharacterDatabase.PQuery("SELECT owner, slot, id, entry, level, name FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 5",_player->GetGUIDLow());
if(result)
{
@ -534,8 +534,8 @@ void WorldSession::SendStablePet(uint64 guid )
data << uint32(fields[2].GetUInt32()); // petnumber
data << uint32(fields[3].GetUInt32()); // creature entry
data << uint32(fields[4].GetUInt32()); // level
data << fields[6].GetString(); // name
data << uint32(fields[5].GetUInt32()); // loyalty
data << fields[5].GetString(); // name
data << uint32(0); // was loyalty
data << uint8(fields[1].GetUInt32()+1); // slot
++num;
@ -550,7 +550,7 @@ void WorldSession::SendStablePet(uint64 guid )
void WorldSession::HandleStablePet( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
CHECK_PACKET_SIZE(recv_data, 8);
sLog.outDebug("WORLD: Recv CMSG_STABLE_PET not dispose.");
uint64 npcGUID;
@ -585,7 +585,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
uint32 free_slot = 1;
QueryResult *result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 3 ORDER BY slot ",_player->GetGUIDLow());
QueryResult *result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot > 0 AND slot < 5 ORDER BY slot ",_player->GetGUIDLow());
if(result)
{
do
@ -613,7 +613,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4);
CHECK_PACKET_SIZE(recv_data, 8+4);
sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET.");
uint64 npcGUID;
@ -649,7 +649,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
Pet *newpet = NULL;
QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot > 0 AND slot < 3",_player->GetGUIDLow(),petnumber);
QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot > 0 AND slot < 5",_player->GetGUIDLow(),petnumber);
if(result)
{
Field *fields = result->Fetch();
@ -673,7 +673,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
CHECK_PACKET_SIZE(recv_data, 8);
sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT.");
uint64 npcGUID;
@ -693,7 +693,7 @@ void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
WorldPacket data(SMSG_STABLE_RESULT, 200);
if(GetPlayer()->m_stableSlots < 2) // max slots amount = 2
if(GetPlayer()->m_stableSlots < 4) // max slots amount = 4
{
StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1);
if(_player->GetMoney() >= SlotPrice->Price)
@ -718,7 +718,7 @@ void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */)
void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4);
CHECK_PACKET_SIZE(recv_data, 8+4);
sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET.");
uint64 npcGUID;
@ -773,7 +773,7 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+8+1);
CHECK_PACKET_SIZE(recv_data, 8+8+1);
sLog.outDebug("WORLD: CMSG_REPAIR_ITEM");

View file

@ -183,7 +183,6 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
data << (uint32)ci->type;
data << (uint32)ci->family; // family wdbFeild9
data << (uint32)ci->rank; // rank wdbFeild10
data << (uint32)0; // unknown wdbFeild11
data << (uint32)ci->PetSpellDataId; // Id from CreatureSpellData.dbc wdbField12
data << (uint32)ci->DisplayID_A; // modelid_male1
data << (uint32)ci->DisplayID_H; // modelid_female1 ?

View file

@ -80,10 +80,6 @@ void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data )
}
}
// Check if it requires spell
if( talentInfo->DependsOnSpell && !player->HasSpell(talentInfo->DependsOnSpell) )
return;
// Find out how many points we have in this field
uint32 spentPoints = 0;

View file

@ -69,7 +69,7 @@ void WorldSession::SendTaxiStatus( uint64 guid )
sLog.outDebug( "WORLD: Sent SMSG_TAXINODE_STATUS" );
}
void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data )
void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
@ -82,7 +82,7 @@ void WorldSession::HandleTaxiQueryAvailableNodesOpcode( WorldPacket & recv_data
Creature *unit = ObjectAccessor::GetNPCIfCanInteractWith(*_player, guid, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!unit)
{
sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodesOpcode - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
sLog.outDebug( "WORLD: HandleTaxiQueryAvailableNodes - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)) );
return;
}