breakout possessor from char comp (#606)

* breakout possessor from char comp
Use the correct component for possessor
cleanup scirps that were using possessor improperly
beginnings of mounts

* fix comments
added bounds check
This commit is contained in:
Aaron Kimbrell
2022-06-29 18:50:24 -05:00
committed by GitHub
parent a55162775e
commit 1497d9b35a
9 changed files with 76 additions and 106 deletions

View File

@@ -435,6 +435,8 @@ void Entity::Initialize()
}*/
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_CHARACTER) > 0 || m_Character) {
// Character Component always has a possessor component
m_Components.insert(std::make_pair(COMPONENT_TYPE_POSSESSOR, new PossessorComponent(this)));
CharacterComponent* comp = new CharacterComponent(this, m_Character);
m_Components.insert(std::make_pair(COMPONENT_TYPE_CHARACTER, comp));
}
@@ -606,10 +608,6 @@ void Entity::Initialize()
m_Components.insert(std::make_pair(COMPONENT_TYPE_RENDER, render));
}
if ((compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_POSSESSOR) > 0) || m_Character) {
m_Components.insert(std::make_pair(COMPONENT_TYPE_POSSESSOR, new PossessorComponent(this)));
}
if ((compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_MISSION_OFFER) > 0) || m_Character) {
m_Components.insert(std::make_pair(COMPONENT_TYPE_MISSION_OFFER, new MissionOfferComponent(this, m_TemplateID)));
}
@@ -1057,8 +1055,15 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
}
CharacterComponent* characterComponent;
if (TryGetComponent(COMPONENT_TYPE_CHARACTER, characterComponent))
{
if (TryGetComponent(COMPONENT_TYPE_CHARACTER, characterComponent)) {
PossessorComponent* possessorComponent;
if (TryGetComponent(COMPONENT_TYPE_POSSESSOR, possessorComponent)) {
possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
} else {
// Should never happen, but just to be safe
outBitStream->Write0();
}
characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
}
@@ -1164,11 +1169,10 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
outBitStream->Write<uint32_t>(0x40000000);
}
PossessorComponent* possessorComponent;
if (TryGetComponent(COMPONENT_TYPE_POSSESSOR, possessorComponent))
{
possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags);
}
// BBB Component, unused currently
// Need to to write0 so that is serlaizese correctly
// TODO: Implement BBB Component
outBitStream->Write0();
/*
if (m_Trigger != nullptr)