Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Jan 13, 2025
1 parent 41f450a commit 60c14e9
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions server/src/npchar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,31 @@ void NPChar::postXMLLayout(uint64_t uid, std::string path, std::string xmlString
fflassert(xmlDoc.RootElement(), xmlString);
fflassert(str_tolower(xmlDoc.RootElement()->Name()) == "layout", xmlString);

rollXMLSeqID(uid);
for(auto node = xmlf::getNodeFirstLeaf(xmlDoc.RootElement()); node; node = xmlf::getNextLeaf(node)){
auto elem = node->ToElement();
for(auto attr = elem->FirstAttribute(); attr; attr = attr->Next()){
if(str_tolower(attr->Name()) == "id"){
std::string val = attr->Value() + std::to_string(getXMLSeqID(uid).value());
const_cast<tinyxml2::XMLAttribute *>(attr)->SetAttribute(val.c_str());
break;
auto fnXMLTran = [xmlSeqID = rollXMLSeqID(uid)](this auto &&self, tinyxml2::XMLNode *node)
{
if(!node){
return;
}
if(auto elem = node->ToElement()){
for(auto attr = elem->FirstAttribute(); attr; attr = attr->Next()){
if(str_tolower(attr->Name()) == "id"){
std::string val = attr->Value() + std::to_string(xmlSeqID);
const_cast<tinyxml2::XMLAttribute *>(attr)->SetAttribute(val.c_str());
break;
}
}
}
}

if(node->NoChildren()) {
return;
}

for(auto child = node->FirstChild(); child; child = child->NextSibling()){
self(child);
}
};

fnXMLTran(xmlDoc.RootElement());

forwardNetPackage(uid, SM_NPCXMLLAYOUT, cerealf::serialize(SDNPCXMLLayout
{
Expand Down

0 comments on commit 60c14e9

Please sign in to comment.