Scenery and Sign bugfixes

*Fixed <> and [ ] tags appearing in sign texts
*Reduced the number of useless parser warnings by adding TerrainGroup, EndTerrainGroup and all objects with "Forest" in their name to the ignore list
This commit is contained in:
izawartka 2025-06-13 20:00:07 +02:00
parent 4f931418b6
commit b70716e09e
2 changed files with 20 additions and 3 deletions

View File

@ -120,6 +120,11 @@ export default class Scenery
static _parseObject(text) {
const type = text.split(";", 2)[0];
if(type.indexOf("Forest") !== -1) {
return null;
}
switch(type) {
case 'Track':
return Scenery._parseTrack(text);
@ -145,6 +150,8 @@ export default class Scenery
case 'MainCamera':
case 'SSPRepeater':
case 'SSPController':
case 'TerrainGroup':
case 'EndTerrainGroup':
return null;
default:
SceneryParserLog.warn('unknownObjectType', `Unknown object type: ${type}`);

View File

@ -16,10 +16,20 @@ export default class Sign extends TrackObject {
}
getPrintableSignData() {
if (!this.data) return null;
let data = this.data?.trim();
if (!data) return null;
const parts = this.data.split("_");
return parts[parts.length - 1]?.trim() || null;
// remove any <size=...>, [size=...], </size> or [/size] tags
data = this.data.replace(/[<[]size=[^>\]]*[\]>]/g, '')?.trim();
// remove any leading '<' or '[' tags and their content
while(data?.match(/^[<[]/)) {
data = data.replace(/^[<[][^>\]]*[\]>]/, '')?.trim();
}
// remove everything before the last underscore (inclusive)
const parts = data?.split("_");
return parts?.[parts?.length - 1]?.trim() || null;
}
/*