public uint ContexToLocal(uint formId)
{
// No need to map main plugin Forms IDs
if ((formId & 0xFFFFFF) == 0)
return formId;
byte p = (byte)(formId >> 24);
if (p >= contextToLocal.Length)
{
throw new InvalidOperationException("Cannot map reference to plugin number " + p + " because this plugin number is out of the current plugin list range.");
}
else if (contextToLocal[p] == byte.MaxValue)
{
throw new InvalidOperationException("Cannot map reference to plugin " + allNames[p] + " because it is not a master for the current plugin.");
}
return (formId & 0xFFFFFF) | ((uint)contextToLocal[p] << 24);
}