Merge remote-tracking branch 'ryzomcore/develop' into core4

merge/2021-11-19
kaetemi 3 years ago
commit cee0f53c1d
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

1
.gitignore vendored

@ -163,6 +163,7 @@ build-2010/*
build/* build/*
install/* install/*
build_* build_*
install_*
nel/tools/build_gamedata/configuration/buildsite.py nel/tools/build_gamedata/configuration/buildsite.py
# Linux nel compile # Linux nel compile

@ -76,16 +76,16 @@ namespace NLGUI
void reindexChilds(); void reindexChilds();
// escape text tag or attribute value // escape text tag or attribute value
std::string htmlEscape(std::string val, bool isAttribute = false) const; std::string htmlEscape(const std::string &val) const;
// serialize element attributes as string // serialize element attributes as string
std::string serializeAttributes() const; std::string serializeAttributes(bool escape = true) const;
// serialize child elements as html string // serialize child elements as html string
std::string serializeChilds() const; std::string serializeChilds(bool escape = true) const;
// serialize itself and children as html string // serialize itself and children as html string
std::string serialize() const; std::string serialize(bool escape = true) const;
// debug // debug
std::string toString(bool tree = false, uint depth = 0) const; std::string toString(bool tree = false, uint depth = 0) const;

@ -140,13 +140,6 @@ namespace NLGUI
// flush draw cache to ensure correct draw order // flush draw cache to ensure correct draw order
rVR.flush(); rVR.flush();
sint32 clipX, clipY, clipW, clipH;
if (m_Viewport)
{
rVR.getClipWindow(clipX, clipY, clipW, clipH);
rVR.setClipWindow(m_Viewport->getXReal(), m_Viewport->getYReal(), m_Viewport->getWReal(), m_Viewport->getHReal());
}
// TODO: no need for widget manager, if global color is set from parent // TODO: no need for widget manager, if global color is set from parent
CRGBA globalColor; CRGBA globalColor;
if (m_ModulateGlobalColor) if (m_ModulateGlobalColor)
@ -166,9 +159,6 @@ namespace NLGUI
// flush draw cache to ensure correct draw order // flush draw cache to ensure correct draw order
rVR.flush(); rVR.flush();
if (m_Viewport)
rVR.setClipWindow(clipX, clipY, clipW, clipH);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

@ -6790,7 +6790,7 @@ namespace NLGUI
_TextAreaTemplate = !templateName.empty() ? templateName : DefaultFormTextAreaGroup; _TextAreaTemplate = !templateName.empty() ? templateName : DefaultFormTextAreaGroup;
std::string content = strFindReplaceAll(elm.serializeChilds(), std::string("\r"), std::string("")); std::string content = strFindReplaceAll(elm.serializeChilds(false), std::string("\r"), std::string(""));
CInterfaceGroup *textArea = addTextArea (_TextAreaTemplate, _TextAreaName.c_str (), _TextAreaRow, _TextAreaCols, true, content, _TextAreaMaxLength); CInterfaceGroup *textArea = addTextArea (_TextAreaTemplate, _TextAreaName.c_str (), _TextAreaRow, _TextAreaCols, true, content, _TextAreaMaxLength);
if (textArea) if (textArea)
@ -6823,7 +6823,7 @@ namespace NLGUI
// if (!_ReadingHeadTag) return; // if (!_ReadingHeadTag) return;
// consume all child elements // consume all child elements
_TitleString = strFindReplaceAll(elm.serializeChilds(), std::string("\t"), std::string(" ")); _TitleString = strFindReplaceAll(elm.serializeChilds(false), std::string("\t"), std::string(" "));
_TitleString = strFindReplaceAll(_TitleString, std::string("\n"), std::string(" ")); _TitleString = strFindReplaceAll(_TitleString, std::string("\n"), std::string(" "));
setTitle(_TitleString); setTitle(_TitleString);
} }

@ -142,30 +142,33 @@ namespace NLGUI
} }
// *************************************************************************** // ***************************************************************************
std::string CHtmlElement::htmlEscape(std::string val, bool isAttribute) const std::string CHtmlElement::htmlEscape(const std::string &val) const
{ {
static const std::string searchReplace[] = { if (val.find_first_of("\"'&<>\xA0") == std::string::npos)
"&", "&amp;", return val;
"<", "&lt;",
">", "&gt;", std::string ret;
"\xA0", "&nbsp;", // resize is quaranteed, make room for some free replacements
}; ret.reserve(val.size() + 24);
for(size_t pos = 0; pos != val.size(); pos++)
for(uint i = 0; i < (sizeof(searchReplace) / sizeof(searchReplace[0])); i+=2)
val = strFindReplaceAll(val, searchReplace[i], searchReplace[i+1]);
if (isAttribute)
{ {
static const std::string q = "\""; switch(val[pos])
static const std::string quot = "&quot;"; {
val = strFindReplaceAll(val, q, quot); case '"': ret.append("&quot;"); break;
case '\'': ret.append("&#39;"); break;
case '&': ret.append("&amp;"); break;
case '<': ret.append("&lt;"); break;
case '>': ret.append("&gt;"); break;
case '\xA0': ret.append("&nbsp;"); break;
default : ret.append(&val[pos],1); break;
}
} }
return val; return ret;
} }
// *************************************************************************** // ***************************************************************************
std::string CHtmlElement::serializeAttributes() const std::string CHtmlElement::serializeAttributes(bool escape) const
{ {
std::string result; std::string result;
for(std::map<std::string, std::string>::const_iterator it = Attributes.begin(); it != Attributes.end(); ++it) for(std::map<std::string, std::string>::const_iterator it = Attributes.begin(); it != Attributes.end(); ++it)
@ -179,30 +182,30 @@ namespace NLGUI
{ {
result += " "; result += " ";
} }
result += htmlEscape(*it2, true); result += (escape ? htmlEscape(*it2) : *it2);
} }
result += "\""; result += "\"";
} }
else else
{ {
result += " " + it->first + "=\"" + htmlEscape(it->second, true) + "\""; result += " " + it->first + "=\"" + (escape ? htmlEscape(it->second) : it->second) + "\"";
} }
} }
return result; return result;
} }
// *************************************************************************** // ***************************************************************************
std::string CHtmlElement::serializeChilds() const std::string CHtmlElement::serializeChilds(bool escape) const
{ {
std::string result; std::string result;
for(std::list<CHtmlElement>::const_iterator it = Children.begin(); it != Children.end(); ++it) for(std::list<CHtmlElement>::const_iterator it = Children.begin(); it != Children.end(); ++it)
result += it->serialize(); result += it->serialize(escape);
return result; return result;
} }
// *************************************************************************** // ***************************************************************************
std::string CHtmlElement::serialize() const std::string CHtmlElement::serialize(bool escape) const
{ {
if (Type == TEXT_NODE) if (Type == TEXT_NODE)
{ {
@ -211,12 +214,14 @@ namespace NLGUI
parent->ID == HTML_NOSCRIPT)) parent->ID == HTML_NOSCRIPT))
{ {
return Value; return Value;
} else { } else if (escape) {
return htmlEscape(Value); return htmlEscape(Value);
} else {
return Value;
} }
} }
std::string result = "<" + Value + serializeAttributes() + ">"; std::string result = "<" + Value + serializeAttributes(escape) + ">";
if (ID == HTML_AREA || ID == HTML_BASE || ID == HTML_BR || if (ID == HTML_AREA || ID == HTML_BASE || ID == HTML_BR ||
ID == HTML_COL || ID == HTML_EMBED || ID == HTML_HR || ID == HTML_COL || ID == HTML_EMBED || ID == HTML_HR ||
@ -231,7 +236,7 @@ namespace NLGUI
result += "\n"; result += "\n";
if (!Children.empty()) if (!Children.empty())
result += serializeChilds(); result += serializeChilds(escape);
result += "</" + Value + ">"; result += "</" + Value + ">";

@ -1404,18 +1404,6 @@ void CUserEntity::moveToCheckStartDist(CLFECOMMON::TCLEntityId slot, double dist
// disable afk mode // disable afk mode
setAFK(false); setAFK(false);
// if sufficiently near, launch the action
CEntityCL *target = EntitiesMngr.entity(slot);
if(target)
{
CVectorD dir2targ = target->pos() - pos();
dir2targ.z = 0.0;
if((dir2targ==CVectorD::Null) || (dir2targ.norm() < dist))
{
moveToAction(target);
}
}
} }
}// moveToCheckStartDist // }// moveToCheckStartDist //

Loading…
Cancel
Save