Skip to content

Commit e76d17f

Browse files
committed
Добавил режим игнора ошибок в xml
1 parent d4f0562 commit e76d17f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Game/Resources_SoC_1.0006/gamedata/config/external.ltx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ actor_thirst = false
169169
; Запрет на закрытие окна диалога, если диалог не завершен.
170170
;disable_dialog_break = true
171171

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

173176
[dragdrop]
174177
; ЗП-стайл подсветки ячеек инвентаря зависят от текстуры ui\ui_grid.dds. В ней нарисованы 7 клеток, по порядку слева направо:

ogsr_engine/xrCore/XML_Parser/tinyxmlparser.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,8 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
10821082
TIXML_STRING endTag ("</");
10831083
endTag += value;
10841084

1085+
static const bool skip_errors = pSettings->line_exist("features", "skip_shoc_xml_errors") && pSettings->r_bool("features", "skip_shoc_xml_errors");
1086+
10851087
// Check for and read attributes. Also look for an empty
10861088
// tag or an end tag.
10871089
while ( p && *p )
@@ -1112,21 +1114,28 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
11121114
++p;
11131115
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
11141116
if (!p || !*p) {
1115-
if (document) document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
1117+
if (!skip_errors && document)
1118+
document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
11161119
return 0;
11171120
}
11181121

11191122
// We should find the end tag now
11201123
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
11211124
{
11221125
p += endTag.length();
1126+
const char* old_p = p;
11231127
p = SkipWhiteSpace( p, encoding );
11241128
if ( p && *p && *p == '>' ) {
11251129
++p;
11261130
return p;
11271131
}
1128-
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
1129-
return 0;
1132+
1133+
if (!skip_errors && document) {
1134+
document->SetError(TIXML_ERROR_READING_END_TAG, p, data, encoding);
1135+
return 0;
1136+
}
1137+
else
1138+
return old_p;
11301139
}
11311140
else
11321141
{
@@ -1163,7 +1172,10 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEnc
11631172
#endif
11641173
if ( node )
11651174
{
1166-
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
1175+
if (!skip_errors && document)
1176+
document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
1177+
else
1178+
node->SetValue(attrib->Value());
11671179
xr_delete(attrib);
11681180
return 0;
11691181
}

0 commit comments

Comments
 (0)