mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Merge pull request #484 from EmosewaMC/property-fixes
Reputation now saved in charxml. This is not a retroactive fix for reputation earned before this merge.
This commit is contained in:
@@ -32,6 +32,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
|
||||
|
||||
m_EditorEnabled = false;
|
||||
m_EditorLevel = m_GMLevel;
|
||||
m_Reputation = 0;
|
||||
|
||||
m_CurrentActivity = 0;
|
||||
m_CountryCode = 0;
|
||||
@@ -256,7 +257,10 @@ void CharacterComponent::LoadFromXML() {
|
||||
Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (character->QueryAttribute("rpt", &m_Reputation) == tinyxml2::XML_NO_ATTRIBUTE) {
|
||||
SetReputation(0);
|
||||
}
|
||||
|
||||
character->QueryInt64Attribute("ls", &m_Uscore);
|
||||
|
||||
// Load the statistics
|
||||
@@ -378,6 +382,8 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
}
|
||||
|
||||
character->SetAttribute("ls", m_Uscore);
|
||||
// Custom attribute to keep track of reputation.
|
||||
character->SetAttribute("rpt", GetReputation());
|
||||
character->SetAttribute("stt", StatisticsToString().c_str());
|
||||
|
||||
// Set the zone statistics of the form <zs><s/> ... <s/></zs>
|
||||
|
@@ -146,6 +146,18 @@ public:
|
||||
*/
|
||||
bool GetPvpEnabled() const;
|
||||
|
||||
/**
|
||||
* Returns the characters lifetime reputation
|
||||
* @return The lifetime reputation of this character.
|
||||
*/
|
||||
int64_t GetReputation() { return m_Reputation; };
|
||||
|
||||
/**
|
||||
* Sets the lifetime reputation of the character to newValue
|
||||
* @param newValue the value to set reputation to
|
||||
*/
|
||||
void SetReputation(int64_t newValue) { m_Reputation = newValue; };
|
||||
|
||||
/**
|
||||
* Sets the current value of PvP combat being enabled
|
||||
* @param value whether to enable PvP combat
|
||||
@@ -291,6 +303,11 @@ private:
|
||||
*/
|
||||
int64_t m_Uscore;
|
||||
|
||||
/**
|
||||
* The lifetime reputation earned by the entity
|
||||
*/
|
||||
int64_t m_Reputation;
|
||||
|
||||
/**
|
||||
* Whether the character is landing by rocket
|
||||
*/
|
||||
|
@@ -518,24 +518,11 @@ void Mission::YieldRewards() {
|
||||
|
||||
if (info->reward_reputation > 0) {
|
||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_EARN_REPUTATION, 0, 0L, "", info->reward_reputation);
|
||||
auto character = entity->GetCharacter();
|
||||
if (!character) return;
|
||||
|
||||
auto charId = character->GetID();
|
||||
auto propertyCloneId = character->GetPropertyCloneID();
|
||||
|
||||
auto reputationUpdate = Database::CreatePreppedStmt("UPDATE properties SET reputation = reputation + ? where owner_id = ? AND clone_id = ?");
|
||||
|
||||
reputationUpdate->setInt64(1, info->reward_reputation);
|
||||
reputationUpdate->setInt(2, charId);
|
||||
reputationUpdate->setInt64(3, propertyCloneId);
|
||||
|
||||
reputationUpdate->executeUpdate();
|
||||
|
||||
delete reputationUpdate;
|
||||
reputationUpdate = nullptr;
|
||||
|
||||
GameMessages::SendUpdateReputation(entity->GetObjectID(), info->reward_reputation, entity->GetSystemAddress());
|
||||
auto character = entity->GetComponent<CharacterComponent>();
|
||||
if (character) {
|
||||
character->SetReputation(character->GetReputation() + info->reward_reputation);
|
||||
GameMessages::SendUpdateReputation(entity->GetObjectID(), character->GetReputation(), entity->GetSystemAddress());
|
||||
}
|
||||
}
|
||||
|
||||
if (info->reward_maxhealth > 0) {
|
||||
|
Reference in New Issue
Block a user