示例#1
0
        private void ProcessDFNFile(UOXData.Script.Script myFile, string sName)
        {
            // In each section, check for any SCRIPT tags
            // If we find any, and they're of the format [[x]], replace the x
            // with the valid script number found in the earlier lookup
            foreach (UOXData.Script.ScriptSection mSect in myFile.Sections)
            {
                UOXData.Script.TagDataPair mPair = mSect.GetDataPair("SCRIPT");
                if (mPair != null)
                {
                    if (mPair.Data.Value.Trim().StartsWith("[["))
                    {                           // we have to do the lookup/replacement here ... what fun!
                        string mValue   = mPair.Data.Value;
                        int    startIdx = mValue.LastIndexOf("[");
                        int    endIdx   = mValue.IndexOf("]");
                        int    toLookup = UOXData.Conversion.ToInt32(mValue.Substring(startIdx + 1, endIdx - (startIdx + 1)));
                        mPair.Data.Value = pkgConfig.GetTranslatedNumber(toLookup).ToString();
                    }
                }
            }
            // OK, we've updated our scripts, isn't this wonderful?
            // Create a new text file with the appropriate name
            // and then pass the stream to myFile.Save()

            string dfnPath  = pkgConfig.DFNPath + pkgConfig.GetDFNSection(sName.Replace("\\", "/")) + pkgConfig.DirPath;
            string filePath = GetPath(sName.Replace("\\", "/"));

            string [] paths        = filePath.Split('/');
            string    buildingPath = dfnPath;

            if (!Directory.Exists(dfnPath))
            {
                Directory.CreateDirectory(dfnPath);
            }
            if (paths.Length > 1)
            {
                for (int i = 0; i < paths.Length; ++i)
                {
                    buildingPath += "/" + paths[i];
                    if (!Directory.Exists(buildingPath))
                    {
                        Directory.CreateDirectory(buildingPath);
                    }
                }
            }
            System.IO.StreamWriter ioStream = File.CreateText(buildingPath + GetFile(sName));
            myFile.Save(ioStream);
            ioStream.Flush();
            ioStream.Close();
        }
示例#2
0
        protected int FindFreeNumber(UOXData.Script.ScriptSection alreadyUsed)
        {
            // This function basically finds a free slot in the list to use
            // Don't want to use potentially reserved areas, so only looking at numbers
            // 6000 and above
            int retVal = -1;

            UOXData.Script.ScriptSection[] mSection = new UOXData.Script.ScriptSection[7];

            mSection[0] = configScripts[0].FindSection("COMMAND_SCRIPTS");
            mSection[1] = configScripts[0].FindSection("MAGIC_SCRIPTS");
            mSection[2] = configScripts[0].FindSection("CONSOLE_SCRIPTS");
            mSection[3] = configScripts[0].FindSection("PACKET_SCRIPTS");
            mSection[4] = configScripts[0].FindSection("SKILLUSE_SCRIPTS");
            mSection[5] = configScripts[0].FindSection("SCRIPT_LIST");
            mSection[6] = alreadyUsed;

            for (int i = 6000; i < 65535; ++i)
            {
                bool scriptExists = false;
                for (int j = 0; j < 7; ++j)
                {
                    if (mSection[j] != null)
                    {
                        UOXData.Script.TagDataPair t = mSection[j].GetDataPair(i.ToString());
                        if (t != null)
                        {
                            scriptExists = true;
                            break;
                        }
                    }
                }
                if (!scriptExists)
                {
                    retVal = i;
                    break;
                }
            }
            return(retVal);
        }
示例#3
0
 private void CheckItemsInCont(WorldObject mObj, bool cChange)
 {
     foreach (ItemObject mItem in mObj.ContainsList)
     {
         if (cChange)
         {
             mItem.Container = mObj.Serial;
             UOXData.Script.TagDataPair contTag = mItem.Section.GetDataPair("Cont");
             contTag.Data = new UOXData.Script.DataValue(mObj.SerString);
         }
         bool contChanged = false;
         if (mItem.Serial < worldObjects.NextItemSer)
         {
             contChanged     = true;
             mItem.Serial    = worldObjects.NextItemSer;
             mItem.SerString = UOXData.Conversion.ToHexString(mItem.Serial);
             UOXData.Script.TagDataPair serTag = mItem.Section.GetDataPair("Serial");
             serTag.Data = new UOXData.Script.DataValue(mItem.SerString);
             ++worldObjects.NextItemSer;
         }
         CheckItemsInCont(mItem, contChanged);
         worldObjects.ItemList.Add(mItem);
     }
 }
示例#4
0
        private void ImportCharacters()
        {
            bool selectFirst = false;

            if (comboCharList.Items.Count == 0)
            {
                selectFirst = true;
            }

            fileBrowserDialog.Filter = "Character Export Files (*.cef)|*.cef|All Files (*.*)|*.*";
            if (fileBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                progressBar.Maximum = fileBrowserDialog.FileNames.Length;
                progressBar.Value   = 0;

                foreach (string filePath in fileBrowserDialog.FileNames)
                {
                    if (File.Exists(filePath))
                    {
                        UOXData.Script.WorldFile90 importWorld = new UOXData.Script.WorldFile90(filePath);
                        if (importWorld.Sections.Count > 0)
                        {
                            LoadWorldFile(importWorld, true);
                            worldFiles.Add(importWorld);
                        }
                    }
                    progressBar.PerformStep();
                }

                if (worldObjects.ImportCharList.Count > 0)
                {
                    worldHasChanged = true;
                    UpdateTotalValues();

                    progressBar.Maximum = worldObjects.ImportCharList.Count + worldObjects.ImportItemList.Count;
                    progressBar.Value   = 0;

                    foreach (ItemObject mItem in worldObjects.ImportItemList)
                    {
                        WorldObject mObj = worldObjects.FindObjectBySerial(mItem.Container, true);
                        if (mObj != null)
                        {
                            mObj.ContainsList.Add(mItem);
                        }
                        progressBar.PerformStep();
                    }
                    foreach (CharObject mChar in worldObjects.ImportCharList)
                    {
                        bool contChanged = false;
                        if (mChar.Serial < worldObjects.NextCharSer)
                        {
                            contChanged     = true;
                            mChar.Serial    = worldObjects.NextCharSer;
                            mChar.SerString = UOXData.Conversion.ToHexString(mChar.Serial);
                            UOXData.Script.TagDataPair serTag = mChar.Section.GetDataPair("Serial");
                            serTag.Data = new UOXData.Script.DataValue(mChar.SerString);
                            ++worldObjects.NextCharSer;
                        }
                        CheckItemsInCont(mChar, contChanged);
                        worldObjects.CharList.Add(mChar);
                        comboCharList.Items.Add(mChar.Name + " (" + mChar.SerString + ")");
                        progressBar.PerformStep();
                    }
                }
                worldObjects.ImportCharList.Clear();
                worldObjects.ImportItemList.Clear();

                if (selectFirst)
                {
                    if (comboCharList.Items.Count > 0)
                    {
                        comboCharList.SelectedIndex = 0;
                    }
                    else
                    {
                        dataGridItems.Rows.Clear();
                        dataGridItems.Rows.Add("Character File Imported: No Characters to Display");
                    }
                }
            }
        }
示例#5
0
        public void Parse(UOXData.Script.Script stpInfo)
        {
            UOXData.Script.ScriptSection mSection = null;

            mSection = stpInfo.FindSection("DESCRIPTION");
            if (mSection != null)
            {
                UOXData.Script.TagDataPair t = mSection.GetDataPair("DIRECTORY");
                if (t != null)
                {
                    dirPath = t.Data.Value.Replace("\\", "/");
                    if (dirPath[dirPath.Length - 1] != '/')
                    {
                        dirPath += "/";
                    }
                }
                else
                {
                    dirPath = "custom/";
                }
            }
            else
            {
                dirPath = "custom/";
            }
            // parse the individual DFN sections now and store what goes where
            for (int i = (int)UOXData.Script.DFN_Categories.FIRST_DEF; i < (int)UOXData.Script.DFN_Categories.NUM_DEFS; ++i)
            {
                mSection = stpInfo.FindSection(((UOXData.Script.DFN_Categories)i).ToString());
                if (mSection != null)
                {
                    foreach (UOXData.Script.TagDataPair t in mSection.TagDataPairs)
                    {
                        dfnFiles[i].Add(t.Data);
                    }
                }
            }
            // Now let's grab the JS file request stuff, and find some free mappings
            // so that we can update the config files
            mSection = stpInfo.FindSection("JS_FILES");
            if (mSection != null)
            {
                foreach (UOXData.Script.TagDataPair t in mSection.TagDataPairs)
                {
                    int freeNumber = FindFreeNumber(inUse);
                    if (freeNumber != -1)
                    {
                        jsFiles.Add(t.Tag, freeNumber);
                        inUse.Add(freeNumber.ToString(), t.Data.Value);
                    }
                }
            }

            // OK, we've built up our list of free numbers
            // Now let's update the relevant config files
            // with the newly acquired data
            UOXData.Script.ScriptSection tSection = null;
            string [] sectTypes = new string[6];
            sectTypes[0] = "COMMAND";
            sectTypes[1] = "MAGIC";
            sectTypes[2] = "CONSOLE";
            sectTypes[3] = "PACKET";
            sectTypes[4] = "SKILLUSE";
            sectTypes[5] = "GENERIC";
            mSection     = stpInfo.FindSection("CONFIGURE");
            if (mSection != null)
            {
                for (int i = 0; i < 6; ++i)
                {
                    UOXData.Script.TagDataPair t = mSection.GetDataPair(sectTypes[i]);
                    if (t != null)
                    {
                        if (i != 5)
                        {
                            tSection = configScripts[0].FindSection(sectTypes + "_SCRIPTS");
                        }
                        else
                        {
                            tSection = configScripts[0].FindSection("SCRIPT_LIST");
                        }

                        string[] values = t.Data.Value.Split(',');
                        for (int j = 0; j < values.Length; ++j)
                        {
                            bool containsKey = jsFiles.ContainsKey(values[j].Trim());
                            if (containsKey)
                            {
                                string tag  = ((int)jsFiles[values[j].Trim()]).ToString();
                                string data = dirPath + inUse.GetDataPair(tag).Data.Value;
                                tSection.Add(tag, data);
                            }
                        }
                    }
                }
            }
            // OK, the file associations config file has been updated
            // Let's do envoke now



            // Let's do type now
        }