コード例 #1
0
        static void PostprocessMegaloDatabase(MegaloScriptDatabase db, MegaloStaticDatabase associatedStaticDb)
        {
            System.IO.TextWriter errorOutput = null;
            if (Blam.Program.RunningUnitTests || OutputMegaloDatabasePostprocessErrorTextToConsole)
            {
                errorOutput = Console.Out;
            }

            db.Postprocess(associatedStaticDb, errorOutput);
        }
コード例 #2
0
        public void PrepareDatabasesForUse(MegaloStaticDatabase staticDb, MegaloScriptDatabase scriptDb)
        {
            if (staticDb == null)
            {
                throw new ArgumentNullException(nameof(staticDb));
            }
            if (scriptDb == null)
            {
                throw new ArgumentNullException(nameof(scriptDb));
            }
            if (scriptDb.StaticDatabase != null)
            {
                throw new ArgumentException("Script db already had a static db reference set", nameof(scriptDb));
            }

            PostprocessMegaloDatabase(scriptDb, staticDb);
        }
コード例 #3
0
        public void Postprocess(MegaloStaticDatabase associatedStaticDb, TextWriter errorWriter = null)
        {
            Contract.Requires(associatedStaticDb != null);

            // #REVIEW_BLAM: I've added TraceInformation calls now, can we get rid of the TextWriter?

            this.StaticDatabase = associatedStaticDb;

            #region ValueTypes
            foreach (var type in ValueTypes)
            {
                if (type.BaseType.RequiresBitLength() && type.BitLength == 0)
                {
                    string msg = string.Format("ValueType '{0}' doesn't define bitLength", ValueTypeNames[type.NameIndex]);

                    Debug.Trace.MegaloProto.TraceInformation(msg);
                    errorWriter?.WriteLine(msg);
                }

                switch (type.BaseType)
                {
                case MegaloScriptValueBaseType.Flags:
                {
                    var etype         = Enums[type.EnumIndex];
                    int bc_difference = etype.ValidBitLengthForFlags(type.BitLength);
                    if (bc_difference < 0)
                    {
                        string msg = string.Format("Flags '{0}->{1}' bitLength '{2}' is too small (need {3} more bits)",
                                                   etype.Name, ValueTypeNames[type.NameIndex],
                                                   type.BitLength, -bc_difference);

                        Debug.Trace.MegaloProto.TraceInformation(msg);
                        errorWriter?.WriteLine(msg);
                    }
                } break;

                case MegaloScriptValueBaseType.Enum:
                {
                    var etype         = Enums[type.EnumIndex];
                    int bc_difference = etype.ValidBitLengthForEnum(type.BitLength, type.EnumTraits);
                    if (bc_difference < 0)
                    {
                        string msg = string.Format("Enum '{0}->{1}' bitLength '{2}' is too small (need {3} more bits)",
                                                   etype.Name, ValueTypeNames[type.NameIndex],
                                                   type.BitLength, -bc_difference);

                        Debug.Trace.MegaloProto.TraceInformation(msg);
                        errorWriter?.WriteLine(msg);
                    }
                } break;

                case MegaloScriptValueBaseType.Index:
                {
                    if (type.IndexTraits == MegaloScriptValueIndexTraits.PointerRaw)
                    {
                        int bit_length = type.BitLength;
                        if (bit_length != Bits.kByteBitCount && bit_length != Bits.kInt16BitCount && bit_length != Bits.kInt32BitCount)
                        {
                            string msg = string.Format("Index-type '{0}' is a 'raw' value but doesn't use a natural word size: {1}",
                                                       ValueTypeNames[type.NameIndex], bit_length);

                            Debug.Trace.MegaloProto.TraceInformation(msg);
                            errorWriter?.WriteLine(msg);
                        }
                    }
                } break;
                }
            }
            #endregion
            #region Actions
            foreach (var action in Actions)
            {
                var state = new MegaloScriptProtoParamsPostprocessState(errorWriter, action);
                state.Postprocess();
            }
            #endregion
            // #TODO_BLAM: would be nice to dump unused ActionTemplates...as I only copy-pasted H4's in Reach's DB
        }