make LoadFromXml usage consistent across comps (#673)

This commit is contained in:
Aaron Kimbrell 2022-07-24 21:03:22 -05:00 committed by GitHub
parent 9ed4a4f47f
commit a7fb6eb3f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 21 deletions

View File

@ -252,7 +252,7 @@ void Entity::Initialize()
ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this); ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);
if (m_Character) { if (m_Character) {
controllablePhysics->LoadFromXML(m_Character->GetXMLDoc()); controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
const auto mapID = Game::server->GetZoneID(); const auto mapID = Game::server->GetZoneID();
@ -362,7 +362,7 @@ void Entity::Initialize()
if (buffComponentID > 0 || collectibleComponentID > 0) { if (buffComponentID > 0 || collectibleComponentID > 0) {
DestroyableComponent* comp = new DestroyableComponent(this); DestroyableComponent* comp = new DestroyableComponent(this);
if (m_Character) { if (m_Character) {
comp->LoadFromXML(m_Character->GetXMLDoc()); comp->LoadFromXml(m_Character->GetXMLDoc());
} }
else { else {
if (componentID > 0) { if (componentID > 0) {
@ -448,8 +448,9 @@ void Entity::Initialize()
m_Components.insert(std::make_pair(COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT, new PlayerForcedMovementComponent(this))); m_Components.insert(std::make_pair(COMPONENT_TYPE_PLAYER_FORCED_MOVEMENT, new PlayerForcedMovementComponent(this)));
CharacterComponent* comp = new CharacterComponent(this, m_Character); CharacterComponent* charComp = new CharacterComponent(this, m_Character);
m_Components.insert(std::make_pair(COMPONENT_TYPE_CHARACTER, comp)); charComp->LoadFromXml(m_Character->GetXMLDoc());
m_Components.insert(std::make_pair(COMPONENT_TYPE_CHARACTER, charComp));
} }
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_INVENTORY) > 0 || m_Character) { if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_INVENTORY) > 0 || m_Character) {

View File

@ -289,7 +289,7 @@ Entity* BuffComponent::GetParent() const
return m_Parent; return m_Parent;
} }
void BuffComponent::LoadFromXML(tinyxml2::XMLDocument* doc) void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc)
{ {
// Load buffs // Load buffs
auto* dest = doc->FirstChildElement("obj")->FirstChildElement("dest"); auto* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");

View File

@ -49,7 +49,7 @@ public:
Entity* GetParent() const; Entity* GetParent() const;
void LoadFromXML(tinyxml2::XMLDocument* doc); void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;

View File

@ -37,8 +37,6 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
m_CountryCode = 0; m_CountryCode = 0;
m_LastUpdateTimestamp = std::time(nullptr); m_LastUpdateTimestamp = std::time(nullptr);
LoadFromXML();
//Check to see if we're landing: //Check to see if we're landing:
if (character->GetZoneID() != Game::server->GetZoneID()) { if (character->GetZoneID() != Game::server->GetZoneID()) {
m_IsLanding = true; m_IsLanding = true;
@ -184,12 +182,7 @@ void CharacterComponent::SetGMLevel(int gmlevel) {
m_GMLevel = gmlevel; m_GMLevel = gmlevel;
} }
void CharacterComponent::LoadFromXML() { void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
if (!m_Character) return;
tinyxml2::XMLDocument* doc = m_Character->GetXMLDoc();
if (!doc) return;
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) { if (!character) {
Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!\n"); Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!\n");

View File

@ -64,7 +64,7 @@ public:
CharacterComponent(Entity* parent, Character* character); CharacterComponent(Entity* parent, Character* character);
~CharacterComponent() override; ~CharacterComponent() override;
void LoadFromXML(); void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);

View File

@ -130,7 +130,7 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
if (!bIsInitialUpdate) outBitStream->Write0(); if (!bIsInitialUpdate) outBitStream->Write0();
} }
void ControllablePhysicsComponent::LoadFromXML(tinyxml2::XMLDocument* doc) { void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) { if (!character) {
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!\n"); Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!\n");

View File

@ -25,7 +25,7 @@ public:
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
void LoadFromXML(tinyxml2::XMLDocument* doc); void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void ResetFlags(); void ResetFlags();
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;

View File

@ -159,7 +159,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
} }
} }
void DestroyableComponent::LoadFromXML(tinyxml2::XMLDocument* doc) { void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest"); tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");
if (!dest) { if (!dest) {
Game::logger->Log("DestroyableComponent", "Failed to find dest tag!\n"); Game::logger->Log("DestroyableComponent", "Failed to find dest tag!\n");
@ -169,7 +169,7 @@ void DestroyableComponent::LoadFromXML(tinyxml2::XMLDocument* doc) {
auto* buffComponent = m_Parent->GetComponent<BuffComponent>(); auto* buffComponent = m_Parent->GetComponent<BuffComponent>();
if (buffComponent != nullptr) { if (buffComponent != nullptr) {
buffComponent->LoadFromXML(doc); buffComponent->LoadFromXml(doc);
} }
dest->QueryAttribute("hc", &m_iHealth); dest->QueryAttribute("hc", &m_iHealth);

View File

@ -19,7 +19,7 @@ public:
~DestroyableComponent() override; ~DestroyableComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags);
void LoadFromXML(tinyxml2::XMLDocument* doc); void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
/** /**

View File

@ -17,7 +17,6 @@ public:
* @param parent parent that contains this component * @param parent parent that contains this component
*/ */
LevelProgressionComponent(Entity* parent); LevelProgressionComponent(Entity* parent);
~LevelProgressionComponent() override {};
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);