Core/Units: Second part of SMSG_MOVE_SET_COLLISION_HGT implementation: compute proper collision height according to client formulae and send this to the client when mounting up.

This commit is contained in:
Machiavelli
2011-11-22 20:28:10 +01:00
parent 99ad58233b
commit 8444532746
4 changed files with 39 additions and 12 deletions
+3 -3
View File
@@ -760,7 +760,7 @@ struct CreatureModelDataEntry
//uint32 Flags;
//char* ModelPath[16]
//uint32 Unk1;
//float Scale; // Used in calculation of unit collision data
float Scale; // Used in calculation of unit collision data
//int32 Unk2
//int32 Unk3
//uint32 Unk4
@@ -770,9 +770,9 @@ struct CreatureModelDataEntry
//float Unk8
//uint32 Unk9
//uint32 Unk10
float CollisionWidth;
//float CollisionWidth;
float CollisionHeight;
//float Unk11; // Used in calculation of unit collision data when mounted
float MountHeight; // Used in calculation of unit collision data when mounted
//float Unks[11]
};
+1 -1
View File
@@ -40,7 +40,7 @@ const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxx
const char CinematicSequencesEntryfmt[]="nxxxxxxxxx";
const char CreatureDisplayInfofmt[]="nixxfxxxxxxxxxxx";
const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx";
const char CreatureModelDatafmt[]="nxxxxxxxxxxxxxffxxxxxxxxxxxx";
const char CreatureModelDatafmt[]="nxxxfxxxxxxxxxxffxxxxxxxxxxx";
const char CreatureSpellDatafmt[]="niiiixxxx";
const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx";
const char CurrencyTypesfmt[]="xnxi";
+28 -7
View File
@@ -2494,16 +2494,37 @@ class Player : public Unit, public GridObject<Player>
bool IsInWhisperWhiteList(uint64 guid);
//! Return collision height sent to client
//! we currently only send this on dismount
float GetCollisionHeight()
float GetCollisionHeight(bool mounted)
{
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
ASSERT(displayInfo);
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
ASSERT(modelData);
if (mounted)
{
CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID));
if (!mountDisplayInfo)
return GetCollisionHeight(false);
CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId);
if (!mountModelData)
return GetCollisionHeight(false);
return modelData->CollisionHeight;
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
ASSERT(displayInfo);
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
ASSERT(modelData);
float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this
return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f;
}
else
{
//! Dismounting case - use basic default model data
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
ASSERT(displayInfo);
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
ASSERT(modelData);
return modelData->CollisionHeight;
}
//! TODO: Need a proper calculation for collision height when mounted
}
+7 -1
View File
@@ -11934,6 +11934,12 @@ void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
else
player->UnsummonPetTemporaryIfAny();
}
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
data.append(GetPackGUID());
data << uint32(sWorld->GetGameTime()); // Packet counter
data << player->GetCollisionHeight(true);
player->GetSession()->SendPacket(&data);
}
RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT);
@@ -11952,7 +11958,7 @@ void Unit::Unmount()
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
data.append(GetPackGUID());
data << uint32(sWorld->GetGameTime()); // Packet counter
data << thisPlayer->GetCollisionHeight();
data << thisPlayer->GetCollisionHeight(false);
thisPlayer->GetSession()->SendPacket(&data);
}