mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-27 17:16:31 +00:00
Address news feed showing up on every world transfer (#855)
Addresses the news feed showing up on every world transfer
This commit is contained in:
parent
56da3f8543
commit
09dfb6df3a
@ -560,6 +560,7 @@ enum ePlayerFlags {
|
|||||||
ENTER_BBB_FROM_PROPERTY_EDIT_CONFIRMATION_DIALOG = 64,
|
ENTER_BBB_FROM_PROPERTY_EDIT_CONFIRMATION_DIALOG = 64,
|
||||||
AG_FIRST_COMBAT_COMPLETE = 65,
|
AG_FIRST_COMBAT_COMPLETE = 65,
|
||||||
AG_COMPLETE_BOB_MISSION = 66,
|
AG_COMPLETE_BOB_MISSION = 66,
|
||||||
|
IS_NEWS_SCREEN_VISIBLE = 114,
|
||||||
NJ_GARMADON_CINEMATIC_SEEN = 125,
|
NJ_GARMADON_CINEMATIC_SEEN = 125,
|
||||||
ELEPHANT_PET_3050 = 801,
|
ELEPHANT_PET_3050 = 801,
|
||||||
CAT_PET_3054 = 802,
|
CAT_PET_3054 = 802,
|
||||||
|
@ -264,14 +264,17 @@ void Character::DoQuickXMLDataParse() {
|
|||||||
if (flags) {
|
if (flags) {
|
||||||
auto* currentChild = flags->FirstChildElement();
|
auto* currentChild = flags->FirstChildElement();
|
||||||
while (currentChild) {
|
while (currentChild) {
|
||||||
uint32_t index = 0;
|
|
||||||
uint64_t value = 0;
|
|
||||||
const auto* temp = currentChild->Attribute("v");
|
const auto* temp = currentChild->Attribute("v");
|
||||||
|
const auto* id = currentChild->Attribute("id");
|
||||||
|
if (temp && id) {
|
||||||
|
uint32_t index = 0;
|
||||||
|
uint64_t value = 0;
|
||||||
|
|
||||||
index = std::stoul(currentChild->Attribute("id"));
|
index = std::stoul(id);
|
||||||
value = std::stoull(temp);
|
value = std::stoull(temp);
|
||||||
|
|
||||||
m_PlayerFlags.insert(std::make_pair(index, value));
|
m_PlayerFlags.insert(std::make_pair(index, value));
|
||||||
|
}
|
||||||
currentChild = currentChild->NextSiblingElement();
|
currentChild = currentChild->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,6 +354,13 @@ void Character::SaveXMLToDatabase() {
|
|||||||
flags->LinkEndChild(f);
|
flags->LinkEndChild(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevents the news feed from showing up on world transfers
|
||||||
|
if (GetPlayerFlag(ePlayerFlags::IS_NEWS_SCREEN_VISIBLE)) {
|
||||||
|
auto* s = m_Doc->NewElement("s");
|
||||||
|
s->SetAttribute("si", ePlayerFlags::IS_NEWS_SCREEN_VISIBLE);
|
||||||
|
flags->LinkEndChild(s);
|
||||||
|
}
|
||||||
|
|
||||||
SaveXmlRespawnCheckpoints();
|
SaveXmlRespawnCheckpoints();
|
||||||
|
|
||||||
//Call upon the entity to update our xmlDoc:
|
//Call upon the entity to update our xmlDoc:
|
||||||
@ -361,6 +371,31 @@ void Character::SaveXMLToDatabase() {
|
|||||||
|
|
||||||
m_OurEntity->UpdateXMLDoc(m_Doc);
|
m_OurEntity->UpdateXMLDoc(m_Doc);
|
||||||
|
|
||||||
|
WriteToDatabase();
|
||||||
|
|
||||||
|
//For metrics, log the time it took to save:
|
||||||
|
auto end = std::chrono::system_clock::now();
|
||||||
|
std::chrono::duration<double> elapsed = end - start;
|
||||||
|
Game::logger->Log("Character", "Saved character to Database in: %fs", elapsed.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Character::SetIsNewLogin() {
|
||||||
|
// If we dont have a flag element, then we cannot have a s element as a child of flag.
|
||||||
|
auto* flags = m_Doc->FirstChildElement("obj")->FirstChildElement("flag");
|
||||||
|
if (!flags) return;
|
||||||
|
|
||||||
|
auto* currentChild = flags->FirstChildElement();
|
||||||
|
while (currentChild) {
|
||||||
|
if (currentChild->Attribute("si")) {
|
||||||
|
flags->DeleteChild(currentChild);
|
||||||
|
Game::logger->Log("Character", "Removed isLoggedIn flag from character %i, saving character to database", GetID());
|
||||||
|
WriteToDatabase();
|
||||||
|
}
|
||||||
|
currentChild = currentChild->NextSiblingElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Character::WriteToDatabase() {
|
||||||
//Dump our xml into m_XMLData:
|
//Dump our xml into m_XMLData:
|
||||||
auto* printer = new tinyxml2::XMLPrinter(0, true, 0);
|
auto* printer = new tinyxml2::XMLPrinter(0, true, 0);
|
||||||
m_Doc->Print(printer);
|
m_Doc->Print(printer);
|
||||||
@ -372,12 +407,6 @@ void Character::SaveXMLToDatabase() {
|
|||||||
stmt->setUInt(2, m_ID);
|
stmt->setUInt(2, m_ID);
|
||||||
stmt->execute();
|
stmt->execute();
|
||||||
delete stmt;
|
delete stmt;
|
||||||
|
|
||||||
//For metrics, log the time it took to save:
|
|
||||||
auto end = std::chrono::system_clock::now();
|
|
||||||
std::chrono::duration<double> elapsed = end - start;
|
|
||||||
Game::logger->Log("Character", "Saved character to Database in: %fs", elapsed.count());
|
|
||||||
|
|
||||||
delete printer;
|
delete printer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ public:
|
|||||||
Character(uint32_t id, User* parentUser);
|
Character(uint32_t id, User* parentUser);
|
||||||
~Character();
|
~Character();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the current m_Doc to the database for saving.
|
||||||
|
*/
|
||||||
|
void WriteToDatabase();
|
||||||
void SaveXMLToDatabase();
|
void SaveXMLToDatabase();
|
||||||
void UpdateFromDatabase();
|
void UpdateFromDatabase();
|
||||||
|
|
||||||
@ -32,6 +36,15 @@ public:
|
|||||||
const std::string& GetXMLData() const { return m_XMLData; }
|
const std::string& GetXMLData() const { return m_XMLData; }
|
||||||
tinyxml2::XMLDocument* GetXMLDoc() const { return m_Doc; }
|
tinyxml2::XMLDocument* GetXMLDoc() const { return m_Doc; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Out of abundance of safety and clarity of what this saves, this is its own function.
|
||||||
|
*
|
||||||
|
* Clears the s element from the flag element and saves the xml to the database. Used to prevent the news
|
||||||
|
* feed from showing up on world transfers.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetIsNewLogin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the database ID of the character
|
* Gets the database ID of the character
|
||||||
* @return the database ID of the character
|
* @return the database ID of the character
|
||||||
@ -427,7 +440,7 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the flying state
|
* @brief Get the flying state
|
||||||
* @return value of the flying state
|
* @return value of the flying state
|
||||||
*/
|
*/
|
||||||
bool GetIsFlying() { return m_IsFlying; }
|
bool GetIsFlying() { return m_IsFlying; }
|
||||||
|
|
||||||
|
@ -227,6 +227,7 @@ void UserManager::RequestCharacterList(const SystemAddress& sysAddr) {
|
|||||||
while (res->next()) {
|
while (res->next()) {
|
||||||
LWOOBJID objID = res->getUInt64(1);
|
LWOOBJID objID = res->getUInt64(1);
|
||||||
Character* character = new Character(uint32_t(objID), u);
|
Character* character = new Character(uint32_t(objID), u);
|
||||||
|
character->SetIsNewLogin();
|
||||||
chars.push_back(character);
|
chars.push_back(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user