Skip to content

Commit

Permalink
Добавил режим игнора ошибок в xml
Browse files Browse the repository at this point in the history
  • Loading branch information
xrSimpodin committed Apr 1, 2022
1 parent d4f0562 commit e76d17f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Game/Resources_SoC_1.0006/gamedata/config/external.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ actor_thirst = false
; Запрет на закрытие окна диалога, если диалог не завершен.
;disable_dialog_break = true

;Игнорировать ошибки парсинга xml (в ТЧ они встречаются даже в оригинальной игре)
skip_shoc_xml_errors = true


[dragdrop]
; ЗП-стайл подсветки ячеек инвентаря зависят от текстуры ui\ui_grid.dds. В ней нарисованы 7 клеток, по порядку слева направо:
Expand Down
20 changes: 16 additions & 4 deletions ogsr_engine/xrCore/XML_Parser/tinyxmlparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,8 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
TIXML_STRING endTag ("</");
endTag += value;

static const bool skip_errors = pSettings->line_exist("features", "skip_shoc_xml_errors") && pSettings->r_bool("features", "skip_shoc_xml_errors");

// Check for and read attributes. Also look for an empty
// tag or an end tag.
while ( p && *p )
Expand Down Expand Up @@ -1112,21 +1114,28 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
++p;
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
if (!p || !*p) {
if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
if (!skip_errors && document)
document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
return 0;
}

// We should find the end tag now
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
{
p += endTag.length();
const char* old_p = p;
p = SkipWhiteSpace( p, encoding );
if ( p && *p && *p == '>' ) {
++p;
return p;
}
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;

if (!skip_errors && document) {
document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
return 0;
}
else
return old_p;
}
else
{
Expand Down Expand Up @@ -1163,7 +1172,10 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
#endif
if ( node )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
if (!skip_errors && document)
document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
else
node->SetValue(attrib->Value());
xr_delete(attrib);
return 0;
}
Expand Down

0 comments on commit e76d17f

Please sign in to comment.