mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-13 19:58:21 +00:00
make LoadFromXml usage consistent across comps (#673)
This commit is contained in:
parent
9ed4a4f47f
commit
a7fb6eb3f3
@ -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) {
|
||||||
|
@ -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");
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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");
|
||||||
|
@ -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);
|
||||||
|
@ -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");
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user