Skip to content

Commit

Permalink
[12798] Implement SMSG_MOVE_SET_COLLISION_HGT to properly handle mode…
Browse files Browse the repository at this point in the history
…l height changes for mounted/unmounted players

Signed-off-by: Tarwyn <tarwyn@thesilvercircle.org>
  • Loading branch information
tarwyn committed Dec 16, 2014
1 parent e63e56f commit ee9172c
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/game/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ DBCStorage <ChrRacesEntry> sChrRacesStore(ChrRacesEntryfmt);
DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore(CinematicSequencesEntryfmt);
DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore(CreatureDisplayInfofmt);
DBCStorage <CreatureDisplayInfoExtraEntry> sCreatureDisplayInfoExtraStore(CreatureDisplayInfoExtrafmt);
DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore(CreatureModelDatafmt);
DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore(CreatureFamilyfmt);
DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore(CreatureSpellDatafmt);
DBCStorage <CreatureTypeEntry> sCreatureTypeStore(CreatureTypefmt);
Expand Down Expand Up @@ -404,6 +405,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCinematicSequencesStore, dbcPath, "CinematicSequences.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureDisplayInfoStore, dbcPath, "CreatureDisplayInfo.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureDisplayInfoExtraStore, dbcPath, "CreatureDisplayInfoExtra.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureModelDataStore, dbcPath, "CreatureModelData.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureFamilyStore, dbcPath, "CreatureFamily.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureSpellDataStore, dbcPath, "CreatureSpellData.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sCreatureTypeStore, dbcPath, "CreatureType.dbc");
Expand Down
1 change: 1 addition & 0 deletions src/game/DBCStores.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ extern DBCStorage <ChrRacesEntry> sChrRacesStore;
extern DBCStorage <CinematicSequencesEntry> sCinematicSequencesStore;
extern DBCStorage <CreatureDisplayInfoEntry> sCreatureDisplayInfoStore;
extern DBCStorage <CreatureDisplayInfoExtraEntry>sCreatureDisplayInfoExtraStore;
extern DBCStorage <CreatureModelDataEntry> sCreatureModelDataStore;
extern DBCStorage <CreatureFamilyEntry> sCreatureFamilyStore;
extern DBCStorage <CreatureSpellDataEntry> sCreatureSpellDataStore;
extern DBCStorage <CreatureTypeEntry> sCreatureTypeStore;
Expand Down
24 changes: 23 additions & 1 deletion src/game/DBCStructure.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ struct CinematicSequencesEntry
struct CreatureDisplayInfoEntry
{
uint32 Displayid; // 0 m_ID
// 1 m_modelID
uint32 ModelId;
// 2 m_soundID
uint32 ExtendedDisplayInfoID; // 3 m_extendedDisplayInfoID -> CreatureDisplayInfoExtraEntry::DisplayExtraId
float scale; // 4 m_creatureModelScale
Expand All @@ -731,6 +731,28 @@ struct CreatureDisplayInfoEntry
// 15 m_objectEffectPackageID
};

struct CreatureModelDataEntry
{
uint32 Id;
uint32 Flags;
//char* ModelPath[16]
//uint32 Unk1;
float Scale; // Used in calculation of unit collision data
//int32 Unk2
//int32 Unk3
//uint32 Unk4
//uint32 Unk5
//float Unk6
//uint32 Unk7
//float Unk8
//uint32 Unk9
//uint32 Unk10
//float CollisionWidth;
float CollisionHeight;
float MountHeight; // Used in calculation of unit collision data when mounted
//float Unks[11]
};

struct CreatureDisplayInfoExtraEntry
{
uint32 DisplayExtraId; // 0 m_ID CreatureDisplayInfoEntry::m_extendedDisplayInfoID
Expand Down
3 changes: 2 additions & 1 deletion src/game/DBCfmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ const char ChatChannelsEntryfmt[] = "iixssssssssssssssssxxxxxxxxxxxxxxxxxx";
const char ChrClassesEntryfmt[] = "nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii";
const char ChrRacesEntryfmt[] = "nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
const char CinematicSequencesEntryfmt[] = "nxxxxxxxxx";
const char CreatureDisplayInfofmt[] = "nxxifxxxxxxxxxxx";
const char CreatureDisplayInfofmt[] = "nixifxxxxxxxxxxx";
const char CreatureDisplayInfoExtrafmt[] = "nixxxxxxxxxxxxxxxxxxx";
const char CreatureModelDatafmt[] = "nixxfxxxxxxxxxxffxxxxxxxxxxx";
const char CreatureFamilyfmt[] = "nfifiiiiixssssssssssssssssxx";
const char CreatureSpellDatafmt[] = "niiiixxxx";
const char CreatureTypefmt[] = "nxxxxxxxxxxxxxxxxxx";
Expand Down
2 changes: 1 addition & 1 deletion src/game/Opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] =
/*0x514*/ { "SMSG_SEND_ALL_COMBAT_LOG", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x515*/ { "SMSG_OPEN_LFG_DUNGEON_FINDER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x516*/ { "SMSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x517*/ { "CMSG_MOVE_SET_COLLISION_HGT_ACK", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x518*/ { "MSG_MOVE_SET_COLLISION_HGT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide },
/*0x519*/ { "CMSG_CLEAR_RANDOM_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
/*0x51A*/ { "CMSG_CLEAR_HOLIDAY_BG_WIN_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL },
Expand Down
50 changes: 50 additions & 0 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23311,3 +23311,53 @@ float Player::ComputeRest(time_t timePassed, bool offline /*= false*/, bool inRe
}
return bonus;
}

float Player::GetCollisionHeight(bool mounted) const
{
if (mounted)
{
// mounted case
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);

CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
if(!displayInfo)
{
sLog.outError("GetCollisionHeight::Unable to find CreatureDisplayInfoEntry for %u", GetNativeDisplayId());
return 0;
}
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
if(!modelData)
{
sLog.outError("GetCollisionHeight::Unable to find CreatureModelDataEntry for %u", displayInfo->ModelId);
return 0;
}

float scaleMod = GetObjectScale(); // 99% sure about this

return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f;
}
else
{
// use native model collision height in dismounted case
CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId());
if(!displayInfo)
{
sLog.outError("GetCollisionHeight::Unable to find CreatureDisplayInfoEntry for %u", GetNativeDisplayId());
return 0;
}
CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId);
if(!modelData)
{
sLog.outError("GetCollisionHeight::Unable to find CreatureModelDataEntry for %u", displayInfo->ModelId);
return 0;
}

return modelData->CollisionHeight;
}
}
3 changes: 3 additions & 0 deletions src/game/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,9 @@ class MANGOS_DLL_SPEC Player : public Unit
void AddTimedQuest(uint32 quest_id) { m_timedquests.insert(quest_id); }
void RemoveTimedQuest(uint32 quest_id) { m_timedquests.erase(quest_id); }

//! Return collision height sent to client
float GetCollisionHeight(bool mounted) const;

/*********************************************************/
/*** LOAD SYSTEM ***/
/*********************************************************/
Expand Down
20 changes: 20 additions & 0 deletions src/game/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7942,6 +7942,10 @@ void Unit::Mount(uint32 mount, uint32 spellId)
pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS, true);
}
}

float height = ((Player*)this)->GetCollisionHeight(true);
if (height)
SendCollisionHeightUpdate(height);
}
}

Expand Down Expand Up @@ -7972,6 +7976,10 @@ void Unit::Unmount(bool from_aura)
pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS, false);
else
((Player*)this)->ResummonPetTemporaryUnSummonedIfAny();

float height = ((Player*)this)->GetCollisionHeight(false);
if (height)
SendCollisionHeightUpdate(height);
}
}

Expand Down Expand Up @@ -11241,3 +11249,15 @@ void Unit::DisableSpline()
m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_FORWARD));
movespline->_Interrupt();
}

void Unit::SendCollisionHeightUpdate(float height)
{
if (GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);
data << GetPackGUID();
data << uint32(sWorld.GetGameTime());
data << height;
((Player*)this)->GetSession()->SendPacket(&data);
}
}
1 change: 1 addition & 0 deletions src/game/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject

// at any changes to scale and/or displayId
void UpdateModelData();
void SendCollisionHeightUpdate(float height);

DynamicObject* GetDynObject(uint32 spellId, SpellEffectIndex effIndex);
DynamicObject* GetDynObject(uint32 spellId);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12797"
#define REVISION_NR "12798"
#endif // __REVISION_NR_H__

0 comments on commit ee9172c

Please sign in to comment.