Example #1
0
 public static void Copy_Monster_From(Mobile from, Object o)
 {
     if (o is BaseCreature)
     {
         currentAttributesClipboard = new MonsterAttributes((BaseCreature)o);
         from.SendMessage("Select a monster to copy these attributes to.");
         from.BeginTarget(-1, true, TargetFlags.None, new TargetCallback(Copy_Monster_To));
     }
     else
     {
         from.SendMessage("Not a valid target!");
     }
 }
 public static void Copy_Monster_From(Mobile from, Object o)
 {
     if (o is BaseCreature)
     {
         currentAttributesClipboard = new MonsterAttributes((BaseCreature)o);
         from.SendMessage("Select a monster to copy these attributes to.");
         from.BeginTarget(-1, true, TargetFlags.None, new TargetCallback(Copy_Monster_To));
     }
     else
     {
         from.SendMessage("Not a valid target!");
     }
 }
Example #3
0
        public static string[] TestFolder(string folderName, TestFlags flags, ref int filesRead, ref int filesToRead, ref string recentMessage)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(folderName);

            FileInfo[] fileInfos = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories);
            fileInfos = Array.FindAll(fileInfos, info => (info.Extension == ".pcm" || info.Extension == ".drm"));

            List <string> physObs       = new List <string>();
            List <string> genericTunes  = new List <string>();
            List <string> monAttributes = new List <string>();
            List <string> monFuncTables = new List <string>();
            List <string> results       = new List <string>();
            int           numSucceeded  = 0;
            int           numSkipped    = 0;

            System.Threading.Interlocked.Exchange(ref filesRead, 0);
            System.Threading.Interlocked.Exchange(ref filesToRead, fileInfos.Length);

            foreach (FileInfo fileInfo in fileInfos)
            {
                string cleanName = Path.GetFileNameWithoutExtension(fileInfo.Name).PadRight(20);
                if ((flags & TestFlags.IgnoreDuplicates) != 0 && cleanName.Contains("duplicate"))
                {
                    System.Threading.Interlocked.Increment(ref filesRead);
                    numSkipped++;
                    continue;
                }

                System.Threading.Interlocked.Exchange(ref recentMessage, (string)fileInfo.Name.Clone());

                string fileDesc = fileInfo.Name.PadRight(20) + "(Size = 0xFFFFFFFF bytes)";

                try
                {
                    SR1_File file = new SR1_File();
                    file.Import(fileInfo.FullName, ImportFlags.LogErrors);
                    fileDesc = fileInfo.Name.PadRight(20) + "(Size = 0x" + file._FileLength.ToString("X8") + " bytes)";

                    if (file.TestExport())
                    {
                        if ((flags & TestFlags.ListAllFiles) != 0)
                        {
                            results.Add(fileDesc + " - Success");
                        }

                        numSucceeded++;
                    }
                    else
                    {
                        results.Add(fileDesc + " - Fail");
                    }

                    if (!file._IsLevel)
                    {
                        if ((flags & TestFlags.ListObjectTypes) != 0)
                        {
                            SR1Structures.Object obj  = (SR1Structures.Object)file._Structures[0];
                            SR1_Structure        data = file._Structures[obj.data.Offset];
                            if (data is PhysObPropertiesBase)
                            {
                                PhysObPropertiesBase physOb = (PhysObPropertiesBase)data;
                                physObs.Add("\t" + cleanName + "\t{ oflags = " + obj.oflags.ToString() + ", oflags2 = " + obj.oflags2.ToString() + ", physOb.Properties.Type = " + physOb.Properties.ID.ToString() + " }");
                            }
                            else if (data is GenericTune)
                            {
                                GenericTune genericTune = (GenericTune)data;
                                genericTunes.Add("\t" + cleanName + "\t{ oflags = " + obj.oflags.ToString() + ", oflags2 = " + obj.oflags2.ToString() + ", genericTune.flags = " + genericTune.flags.ToString() + " }");
                            }
                            else if (data is MonsterAttributes)
                            {
                                MonsterAttributes monsterAttributes = (MonsterAttributes)data;
                                monAttributes.Add("\t" + cleanName + "\t{ oflags = " + obj.oflags.ToString() + ", oflags2 = " + obj.oflags2.ToString() + ", monsterAttributes.magicNum = " + monsterAttributes.magicnum.ToString() + ", monsterAttributes.whatAmI = " + monsterAttributes.whatAmI.ToString() + " }");
                            }
                        }

                        if ((flags & TestFlags.ListRelocModules) != 0)
                        {
                            SR1Structures.Object obj = (SR1Structures.Object)file._Structures[0];
                            if (obj.relocModule.Offset != 0)
                            {
                                SR1_Structure relocModule = file._Structures[obj.relocModule.Offset];
                                if (relocModule is MonsterFunctionTable)
                                {
                                    MonsterFunctionTable mft = (MonsterFunctionTable)relocModule;
                                    string relocStart        = "Start = 0x" + mft.stateChoices.Start.ToString("X8");
                                    string relocEnd          = "End = 0x" + mft.stateChoices.End.ToString("X8");
                                    string relocSize         = "Size = 0x" + (mft.stateChoices.End - mft.stateChoices.Start).ToString("X8");
                                    monFuncTables.Add(
                                        "\t" + cleanName + "\t{ MonsterFunctionTable (" +
                                        relocStart + ", " +
                                        relocEnd + ", " +
                                        relocSize + ") }");
                                }
                            }
                        }
                    }
                }
                catch
                {
                    results.Add(fileDesc + " - Error");
                }

                System.Threading.Interlocked.Increment(ref filesRead);
            }

            if ((flags & TestFlags.ListObjectTypes) != 0)
            {
                results.Add("\r\nPhysObs:");
                results.AddRange(physObs);
                results.Add("\r\nGenericTunes:");
                results.AddRange(genericTunes);
                results.Add("\r\nMonsterAttibutes:");
                results.AddRange(monAttributes);
                results.Add("");
            }

            if ((flags & TestFlags.ListRelocModules) != 0)
            {
                results.Add("\r\nMonsterFunctionTables:");
                results.AddRange(monFuncTables);
                results.Add("");
            }

            //results.Add("\r\nCollectibles:");
            //results.AddRange(collectibles);
            //results.Add("");

            results.Add("Files Read: " + (filesRead - numSkipped));
            results.Add("Succeeded: " + numSucceeded);
            results.Add("Failed: " + (filesRead - numSkipped - numSucceeded));

            return(results.ToArray());
        }