private ITES5Type GetPropertyTypeAndFormID(string referenceName, string?tes4ReferenceNameForType, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope, out Nullable <int> tes4FormID) { tes4FormID = null; ITES5Type?specialConversion; if (specialConversions.TryGetValue(referenceName, out specialConversion)) { return(specialConversion); } else if (multipleScriptsScope.ContainsGlobalVariable(referenceName)) { return(TES5BasicType.T_GLOBALVARIABLE); } else { //propertyType = TES5BasicType.T_FORM; //WTM: Change: I commented the above and added the below: if (!referenceName.StartsWith(MessageBoxFactory.MessageBoxPrefix) && referenceName != GetPlayerInSEWorldFactory.SEWorldLocationPropertyName) { var scroData = GetTypeFromSCRO(esmAnalyzer, globalScope.ScriptHeader.EDID, referenceName); if (scroData != null) { tes4FormID = scroData.Value.Key; return(scroData.Value.Value); } } if (tes4ReferenceNameForType == null) { throw new NullableException(nameof(tes4ReferenceNameForType)); } ITES5Type?esmType = esmAnalyzer.GetTypeByEDIDWithFollow(tes4ReferenceNameForType, true); return(esmType != null ? esmType : TES5BasicType.T_FORM); } }
/* * Create a generic-purpose reference. */ public ITES5Referencer CreateReference(string referenceName, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope, TES5LocalScope localScope) { if (TES5PlayerReference.EqualsPlayer(referenceName)) { return(CreateReferenceToPlayer()); } referenceName = PapyrusCompiler.FixReferenceName(referenceName); Match match = PropertyNameRegex.Match(referenceName); if (match.Success) { ITES5Referencer mainReference = this.CreateReference(match.Groups[1].Value, globalScope, multipleScriptsScope, localScope); TES5ObjectProperty propertyReference = this.objectPropertyFactory.CreateObjectProperty(multipleScriptsScope, mainReference, match.Groups[2].Value); //Todo rethink the prefix adding return(propertyReference); } ITES5VariableOrProperty property = localScope.GetVariable(referenceName); if (property == null) { property = globalScope.GetPropertyByName(referenceName); //todo rethink how to unify the prefix searching if (property == null) { TES5Property propertyToAddToGlobalScope = null; ITES5Type specialConversion; if (specialConversions.TryGetValue(referenceName, out specialConversion)) { propertyToAddToGlobalScope = new TES5Property(referenceName, specialConversion, referenceName); } if (propertyToAddToGlobalScope == null) { if (!multipleScriptsScope.ContainsGlobalVariable(referenceName)) { propertyToAddToGlobalScope = new TES5Property(referenceName, TES5BasicType.T_FORM, referenceName); } else { propertyToAddToGlobalScope = new TES5Property(referenceName, TES5BasicType.T_GLOBALVARIABLE, referenceName); } } globalScope.AddProperty(propertyToAddToGlobalScope); property = propertyToAddToGlobalScope; } } return(new TES5Reference(property)); }