Example #1
0
        public void loadFromDat(cDatFile datFile)
        {
            Console.WriteLine("Reading map from dat file...");
            Stopwatch timer = new Stopwatch();

            timer.Start();

            int landBlockCounter     = 0;
            int landBlockInfoCounter = 0;

            foreach (KeyValuePair <uint, cDatFileEntry> entry in datFile.fileCache)
            {
                if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF)
                {
                    uint           x            = (uint)entry.Value.fileId >> 24;
                    uint           y            = (uint)(entry.Value.fileId & 0x00FF0000) >> 16;
                    cCellLandblock newLandblock = new cCellLandblock(entry.Value);
                    surfaceLandblocks[(int)x].Add((int)y, newLandblock);
                    landBlockCounter++;
                }
                else if ((entry.Value.fileId & 0x0000FFFE) == 0x0000FFFE)
                {
                    uint           x = (uint)entry.Value.fileId >> 24;
                    uint           y = (uint)(entry.Value.fileId & 0x00FF0000) >> 16;
                    cLandblockInfo newLandblockInfo = new cLandblockInfo(entry.Value);
                    landblockInfo[(int)x].Add((int)y, newLandblockInfo);
                    landBlockInfoCounter++;
                }
            }

            timer.Stop();
            Console.WriteLine("{0} landblocks and {1} landblockInfos read in {2} seconds.", landBlockCounter, landBlockInfoCounter, timer.ElapsedMilliseconds / 1000f);
        }
Example #2
0
        public void loadFromDat(cDatFile datFile)
        {
            Console.WriteLine("Reading map from dat file...");
            Stopwatch timer = new Stopwatch();

            timer.Start();

            int landBlockCounter = 0;

            foreach (KeyValuePair <uint, cDatFileEntry> entry in datFile.fileCache)
            {
                byte[]       buffer = new byte[1024];
                StreamReader reader = new StreamReader(entry.Value.fileContent);

                if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF)
                {
                    uint           x            = (uint)entry.Value.fileId >> 24;
                    uint           y            = (uint)(entry.Value.fileId & 0x00FF0000) >> 16;
                    cCellLandblock newLandblock = new cCellLandblock(buffer, reader);
                    surfaceLandblocks[(int)x].Add((int)y, newLandblock);
                    landBlockCounter++;
                }
            }

            timer.Stop();
            Console.WriteLine("{0} landblocks read in {1} seconds.", landBlockCounter, timer.ElapsedMilliseconds / 1000f);
        }
Example #3
0
        public cDatFileNode(cDatFile datFile, cDatFileBlockCache blockCache)
        {
            blockSize = datFile.blockSize;

            int size;

            if (datFile.fileFormat == eDatFormat.ToD)
            {
                size = sizeToD;
            }
            else
            {
                size = sizeRetail;
            }

            listOfBlocks     = blockCache.getNewListOfBlocks(size);
            startBlockOffset = listOfBlocks[0].blockOffset;

            files      = new SortedDictionary <uint, cDatFileEntry>(); //max 61
            subFolders = new List <cDatFileNode>();
        }
Example #4
0
        static void MapManipulationForCustomDM(string[] args)
        {
            //cDatFile portalDatFile = new cDatFile();
            //portalDatFile.loadFromDat("./input/client_portal.dat");
            //int iteration = portalDatFile.GetFileIteration();
            //portalDatFile.SetFileIteration(10000);
            //portalDatFile.writeToDat("client_portal.dat");

            cDatFile datFile = new cDatFile();

            //datFile.loadFromDat("./input/client_cell_1.dat");
            datFile.loadFromDat("./input/client_cell_1 - Infiltration.dat");
            //datFile.loadFromDat("./input/cell - Late DM - 2004-09-01.dat");
            //datFile.loadFromDat("./client_cell_1.dat");

            cDatFile datFileOld = new cDatFile();

            //datFileOld.loadFromDat("./input/cell - Release.dat");
            datFileOld.loadFromDat("./input/cell - 2000-12-31 - Obsidian Span.dat");
            //datFileOld.loadFromDat("./input/cell - DM - 2001-09-12.dat");
            //datFileOld.loadFromDat("./input/client_cell_1.dat");
            //datFileOld.loadFromDat("./input/cell - End of Beta Event.dat");
            //datFileOld.loadFromDat("./input/cell - 2005-01-05 (198656kb) (Admin) (Iteration 1583 - Complete).dat");
            //datFileOld.loadFromDat("./input/cell - 2005-02-XX (202752kb) (Admin) (Iteration 1593 - Complete).dat");

            cDatFile datFileRelease = new cDatFile();

            datFileRelease.loadFromDat("./input/cell - Release.dat");

            cDatFile datFileArwic = new cDatFile();

            datFileArwic.loadFromDat("./input/cell - 2000-08-22.dat");

            cDatFile datFileToD = new cDatFile();

            datFileToD.loadFromDat("./input/client_cell_1 - ToD.dat");

            //datFileOld.convertRetailToToD(10000);

            //cDatFile replacementDataFile = null;
            //if (datFileOld.isMissingCells)
            //{
            //    Console.WriteLine($"Missing {datFileOld.getMissingCellsList().Count} cells...");
            //    replacementDataFile = new cDatFile();
            //    //replacementDataFile.loadFromDat("./input/cell - Release.dat");
            //    replacementDataFile.loadFromDat("./input/client_cell_1.dat");
            //    datFileOld.completeCellsFrom(replacementDataFile, true);
            //    //datFileOld.truncateMissingCells();
            //}

            //int missingCount;
            //if (datFileOld.isMissingLandblocks(out missingCount))
            //{
            //    Console.WriteLine($"Missing {missingCount} landblocks...");
            //    if (replacementDataFile == null)
            //    {
            //        replacementDataFile = new cDatFile();
            //        //replacementDataFile.loadFromDat("./input/cell - Release.dat");
            //        replacementDataFile.loadFromDat("./input/client_cell_1.dat");
            //    }
            //    datFileOld.completeLandblocksFrom(replacementDataFile);
            //}

            //datFileOld.writeToDat("./client_cell_1.dat");

            //datFile.replaceDungeon(0x017d, datFileOld, 0);

            //datFile.replaceLandblock(0xC6A90013, datFileOld); //Arwic

            //datFile.replaceLandblockArea(0xC98C0028, datFileOld); //Rithwic
            //datFile.replaceLandblockArea(0x856D0040, datFileOld); //Tufa
            //datFile.replaceLandblockArea(0xC6A90013, datFileArwic); //Arwic

            //Arwic
            datFile.replaceLandblock(0xC6A90013, datFileRelease);
            datFile.replaceLandblock(0xC6A90008, datFileRelease);
            datFile.replaceLandblock(0xC6A80038, datFileRelease);
            datFile.replaceLandblock(0xC6AA0011, datFileRelease);
            datFile.replaceLandblock(0xC5AA0039, datFileRelease);
            datFile.replaceLandblock(0xC5A80028, datFileRelease);
            datFile.replaceLandblock(0xC5A80028, datFileRelease);

            datFile.replaceLandblock(0xC5A90037, datFileArwic);                            // Meeting Hall with the correct fallen pillars around the road.
            datFile.replaceLandblock(0xC6A90013, datFileArwic, false, false, true, false); // use the surface objects from this file(lamp posts!) but not the buildings as they have fire lighting effects that bleed all over thru the walls on the new client.

            datFile.replaceLandblock(0xC5A6003A, datFileRelease);                          //Get rid of Newic.

            datFile.replaceLandblockArea(0x2B110028, datFileToD);                          //Candeth Keep - todo: investigate why Candeth is causing crashes when using the one from infiltration data.

            datFile.removeHouseSettlements(datFileOld);

            datFile.removeNoobFence();

            datFile.replaceLandblock(0x7D8F0013, datFileOld); // The Zaikhal settlement portals pillar is baked into this landblock for some reason, remove it.

            List <uint> LandblocksToReplace = new List <uint>()
            {
                0x905C003B, // North Al-Arqas Outpost
                0x915C0003, // North Al-Arqas Outpost part 2
                0x8C58002B, // West Al-Arqas Outpost
                0xC380000C, // East Lytelthorpe Outpost
                0xBB80002E, // West Lytelthorpe Outpost
                0xEA3D000E, // East Nanto Outpost
                0xE542002B, // North Nanto Outpost
                0xCC8C0014, // East Rithwic Outpost
                0xC8880016, // South Rithwic Outpost
                0x9B7B0015, // East Samsur Outpost
                0x937F002D, // Northwest Samsur Outpost
                0xB9730032, // North Yanshi Outpost
                0xB96B001E, // South Yanshi Outpost
            };

            datFile.replaceLandblocksSpecialForStarterOutposts(LandblocksToReplace, datFileOld);

            List <uint> buildingsToRemove = new List <uint>()
            {
                0xA9B30114, // Holtburg->Neydisa Castle Portal Bunker
                0xA9B40183, // Holtburg->Shoushi Portal Bunker
                0xA9B40188, // Holtburg->Rithwic Portal Bunker
                0xA9B4017E, // Holtburg->Cragstone Portal Bunker
                0xAAB40108, // Holtburg->Arwic Portal Bunker
                0xAAB40103, // Holtburg->Dryreach Portal Bunker

                0x7D64018B, // Yaraq->Holtburg Portal Bunker
                0x7D64017C, // Yaraq->Al-Arqas Portal Bunker
                0x7D640181, // Yaraq->Samsur Portal Bunker
                0x7E640122, // Yaraq->Zaikhal Portal Bunker
                0x7E640127, // Yaraq->Linvak Tukal Portal Bunker
                0x7D640177, // Yaraq->Khayyaban Portal Bunker
                0x7D640186, // Yaraq->Xarabydum Portal Bunker

                0xDA560116, // Shoushi->Kryst Portal Bunker
                0xDA5501F9, // Shoushi->Nanto Portal Bunker
                0xDA56011B, // Shoushi->Kara Portal Bunker
                0xDA5501F4, // Shoushi->Yanshi Portal Bunker
                0xDA540103, // Shoushi->Tou-Tou Portal Bunker
                0xDA5501EF, // Shoushi->Yaraq Portal Bunker
                0xD955010D, // Shoushi->Hebian-To Portal Bunker

                //Statues
                0x90580141, // Al-Arqas
                0xA9B40177, // Holtburg
                0xBF80017D, // Lytelthorpe
                0xE63D0154, // Nanto
                0xC88C0171, // Rithwic
                0x977B015F, // Samsur
                0xDA5501E8, // Shoushi
                0x7D640151, // Yaraq
                0xBC9F0166, // Cragstone
                0x85880129, // Al-Jalima
                0xCE95016A, // Eastham
                0xA1A40162, // Glenden Wood
                0xE74E01A7, // Hebian-To
                0x9E430132, // Khayyaban
                0xE9220141, // Kryst
                0xDA3B013C, // Lin
                0xA2600122, // Uziz
                0x80900139, // Zhaikal
                0xF75C0155, // Tou-Tou
                0xCD41018B, // Baishi
                0xF2220122, // MacNiall's Freehold
                0xE5320136, // Mayoi
                0x49B6012D, // Plateau Village
                0x9722015F, // Qalaba'r
                0xC95B0169, // Sawato
                0x64D50131, // Stonehold
                0x866C010B, // Tufa
                0x1134014A, // Ayan Baqur
                0xBA170143, // Kara
                0x3F310101, // Wai Jhou
                0x2581016B, // Fort Tethana

                //Arcanum Buildings
                0x90570102, // Al-Arqas
                0xA9B40171, // Holtburg
                0xBE800109, // Lytelthorpe
                0xE63D014E, // Nanto
                0xC88B0102, // Rithwic
                0x977B0159, // Samsur
                0xDA56010E, // Shoushi
                0x7D64014B, // Yaraq
                0xBA9E0105, // Cragstone
                0x85880123, // Al-Jalima
                0xCE950163, // Eastham
                0xA2A40100, // Glenden Wood
                0xE64E0104, // Hebian-To
                0x9E43012D, // Khayyaban
                0xE8210104, // Kryst
                0xDB3B011D, // Lin
                0xA260011C, // Uziz
                0x7F8F011C, // Zhaikal
                0xF75C014F, // Tou-Tou
                0xCD410183, // Baishi
                0xF2230104, // MacNiall's Freehold
                0xE532012E, // Mayoi
                0x49B60126, // Plateau Village
                0x97220159, // Qalaba'r
                0xC95B0161, // Sawato
                0x64D50129, // Stonehold
                0x11340144, // Ayan Baqur
                0xBA17013B, // Kara
            };

            datFile.removeBuildings(buildingsToRemove);
            //Since we're removing the bunkers might as well roll back Holtburg's heightmap that was flattened in areas to fit the bunkers.
            datFile.replaceLandblockTerrain(0xA9B40024, datFileOld, true, true);
            datFile.replaceLandblockTerrain(0xAAB4000A, datFileOld, true, true);
            datFile.replaceLandblockTerrain(0xA8B4003B, datFileOld, true, true);

            //datFile.migrateDungeon(datFileOld, 0x017D, 0x017D); //original training academy

            //List<ushort> trainingAcademies = new List<ushort>()
            //{
            //    0x0363,
            //    0x0364,
            //    0x0365,
            //    0x0366,
            //    0x0367,
            //    0x0368
            //};
            //datFile.replaceDungeonList(trainingAcademies, datFileOld);

            cCellDat cellDat = new cCellDat();

            cellDat.loadFromDat(datFile);
            cMapDrawer mapDrawer = new cMapDrawer(cellDat);

            mapDrawer.draw(false, 50);

            datFile.writeToDat("./client_cell_1.dat");

            Console.WriteLine("Done");
            Console.ReadLine();
            return;
        }
Example #5
0
        static void MapManipulation(string[] args)
        {
            //cDatFile portalDatFile = new cDatFile();
            //portalDatFile.loadFromDat("./input/client_portal.dat");
            //int iteration = portalDatFile.GetFileIteration();
            //portalDatFile.SetFileIteration(10000);
            //portalDatFile.writeToDat("client_portal.dat");

            //cDatFile datFile = new cDatFile();
            //datFile.loadFromDat("./input/client_cell_1.dat");
            //datFile.loadFromDat("./input/client_cell_1 - Infiltration.dat");
            //datFile.loadFromDat("./input/cell - Late DM - 2004-09-01.dat");
            //datFile.loadFromDat("./client_cell_1.dat");

            cDatFile datFileOld = new cDatFile();

            datFileOld.loadFromDat("./input/cell - Release.dat");
            //datFileOld.loadFromDat("./input/cell - 2000-12-31 - Obsidian Span.dat");
            //datFileOld.loadFromDat("./input/cell - DM - 2001-09-12.dat");
            //datFileOld.loadFromDat("./input/client_cell_1.dat");
            //datFileOld.loadFromDat("./input/cell - End of Beta Event.dat");
            //datFileOld.loadFromDat("./input/cell - 2005-01-05 (198656kb) (Admin) (Iteration 1583 - Complete).dat");
            //datFileOld.loadFromDat("./input/cell - 2005-02-XX (202752kb) (Admin) (Iteration 1593 - Complete).dat");

            datFileOld.convertRetailToToD(10000);

            //cDatFile replacementDataFile = null;
            //if (datFileOld.isMissingCells)
            //{
            //    Console.WriteLine($"Missing {datFileOld.getMissingCellsList().Count} cells...");
            //    replacementDataFile = new cDatFile();
            //    //replacementDataFile.loadFromDat("./input/cell - Release.dat");
            //    replacementDataFile.loadFromDat("./input/client_cell_1.dat");
            //    datFileOld.completeCellsFrom(replacementDataFile, true);
            //    //datFileOld.truncateMissingCells();
            //}

            //int missingCount;
            //if (datFileOld.isMissingLandblocks(out missingCount))
            //{
            //    Console.WriteLine($"Missing {missingCount} landblocks...");
            //    if (replacementDataFile == null)
            //    {
            //        replacementDataFile = new cDatFile();
            //        //replacementDataFile.loadFromDat("./input/cell - Release.dat");
            //        replacementDataFile.loadFromDat("./input/client_cell_1.dat");
            //    }
            //    datFileOld.completeLandblocksFrom(replacementDataFile);
            //}

            //datFileOld.writeToDat("./client_cell_1.dat");

            //datFile.replaceDungeon(0x017d, datFileOld, 0);

            //datFile.replaceLandblock(0xC6A90013, datFileOld); //Arwic

            //datFile.replaceLandblockArea(0xC98C0028, datFileOld); //Rithwic
            //datFile.replaceLandblockArea(0x856D0040, datFileOld); //Tufa
            //datFile.replaceLandblockArea(0xC6A90013, datFileArwic); //Arwic

            cCellDat cellDat = new cCellDat();

            cellDat.loadFromDat(datFileOld);
            cMapDrawer mapDrawer = new cMapDrawer(cellDat);

            mapDrawer.draw(false, 50);

            datFileOld.writeToDat("./client_cell_1.dat");

            Console.WriteLine("Done");
            Console.ReadLine();
        }
Example #6
0
        public void updateBlockData(cDatFile datFile, cDatFileBlockCache blockCache)
        {
            MemoryStream memoryStream = new MemoryStream(new byte[sizeToD]);
            StreamWriter writer       = new StreamWriter(memoryStream);

            for (int i = 0; i < 62; i++)
            {
                if (i == 0 && subFolders.Count == 0)
                {
                    Utils.writeUInt32(0, writer);
                }
                else if (i < subFolders.Count && i < files.Count + 1) //directory is allowed to have (files + 1) subdirectories
                {
                    cDatFileNode subFolder = subFolders[i];

                    subFolder.updateBlockData(datFile, blockCache);

                    Utils.writeUInt32(subFolder.startBlockOffset, writer);
                }
                else
                {
                    Utils.writeUInt32(0xcdcdcdcd, writer);
                }
            }

            Utils.writeUInt32((uint)files.Count, writer);

            foreach (KeyValuePair <uint, cDatFileEntry> entry in files)
            {
                cDatFileEntry fileEntry = entry.Value;
                if (fileEntry.fileContent != null)
                {
                    fileEntry.fileSize = (int)fileEntry.fileContent.Length;
                    blockCache.dataToBlocks(fileEntry.listOfBlocks, fileEntry.fileContent);
                    if (fileEntry.listOfBlocks.Count > 0)
                    {
                        fileEntry.startBlockOffset = fileEntry.listOfBlocks[0].blockOffset;
                    }
                }
                else
                {
                    fileEntry.fileSize = 0;
                }
                fileEntry.writeHeader(writer);
            }

            cDatFileEntry emptyFileEntry = new cDatFileEntry(0, datFile.fileFormat);

            for (int i = files.Count; i < 61; i++)
            {
                emptyFileEntry.writeHeader(writer);
            }

            writer.Flush();

            blockCache.dataToBlocks(listOfBlocks, memoryStream);
            if (listOfBlocks.Count > 0)
            {
                startBlockOffset = listOfBlocks[0].blockOffset;
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            //CharGen charGen = new CharGen("./input/0E000002.bin");
            //charGen.modify();
            //charGen.save("./0E000002 - CharGen - Classic.bin");
            //Console.ReadLine();
            //return;

            ////TextureConverter.folderToPNG("textures ToD");
            ////TextureConverter.folderBMPToPNG("C:/Users/Dekaru/Desktop/Research/Textures Retail");
            ////TextureConverter.toPNG("textures ToD/06003afb.bin");
            ////Console.ReadLine();
            ////return;

            ////TextureIdDictionary.folderExtractTextureFromHeader("./input/textureHeaders/");
            ////return;

            //RegionConverter.convert("Region/13000000.bin");
            //RegionConverterDM.convert("Region/130F0000 Bael.bin");
            //RegionConverterDM.convert("Region/130F0000 test.bin");

            cDatFile datFile = new cDatFile();

            datFile.loadFromDat("./input/dats/client_cell_1.dat");

            ////cDatFile datFileOld = new cDatFile();
            ////datFileOld.loadFromDat("./input/cell - 2000-08.dat");

            cDatFile datFileOld = new cDatFile();

            datFileOld.loadFromDat("./input/dats/DM retail/cell.dat");

            //datFileOld.convertSurfaceData();
            //datFile.migrateSurfaceData(datFileOld);
            ////datFile.migrateEverything(datFileOld);
            datFile.migrateEverything(datFileOld);
            //datFile.duplicateTrainingAcademy();
            //datFile.migrateTrainingAcademy(datFileOld);
            //datFile.buildTextureIdMigrationTable(datFileOld);
            ////datFile.migrateDungeon(datFileOld, 0x02B9, 0x02B9);
            ////datFile.migrateDungeon(datFileOld, 0x018A, 0x018A);

            //datFile.writeToDat("client_cell_1.dat");
            ////datFileOld.writeToDat("client_cell_1.dat");
            datFile.writeToDat("client_cell_1.dat");

            //cDatFile datFile = new cDatFile();
            //datFile.loadFromDat("./input/client_portal - ToD.dat");

            //cDatFile datFileOther = new cDatFile();
            //datFileOther.loadFromDat("./input/client_portal_latest_unmodified.dat");

            //datFile.importNewEntries(datFileOther);

            ////datFile.writeToDat("client_portal.dat");

            //cDatFile pdatFile = new cDatFile();
            //pdatFile.loadFromDat("./input/dats/client_portal.dat");

            //cDatFile pdatFileOther = new cDatFile();
            //pdatFileOther.loadFromDat("./input/dats/103199 beta/portal.dat");

            //pdatFile.importNewEntries(pdatFileOther);

            //pdatFile.writeToDat("client_portal.dat");

            //Console.ReadLine();
            //return;

            //cCellDat cellDat = new cCellDat();
            //////cellDat.loadFromDat(datFileOld);
            //cellDat.loadFromDat(datFile);
            //cMapDrawer mapDrawer = new cMapDrawer(cellDat);
            //mapDrawer.draw();

            cCellDat cellDat = new cCellDat();

            cellDat.loadFromDat(datFile);
            cMapDrawer mapDrawer = new cMapDrawer(cellDat);

            mapDrawer.draw();
            mapDrawer.draw(true);

            //testRandomValueGenerator(5);
            //Console.ReadLine();
            //return;

            //cache4Converter.loadFromRaw("./input/0004.raw");
            ////cache8Converter.loadFromJson("./output/questFlags.json");
            ////cache8Converter.writeRaw("./output/");
            //cache4Converter.writeJson("./output/");
            //Console.ReadLine();
            //return;

            //testing
            //args = new string[3];
            //args[0] = "cached";
            //args[1] = "./input/";
            //args[2] = "./input/lootProfile.json";
            //testing

            //Patcher.patch();
            //return;

            //SpellsConverter.toTxt("Spells/0E00000E - 2010.bin");
            //SpellsConverter.toTxt("Spells/0E00000E - latest.bin");
            //SpellsConverter.raw0002toTxt("intermediate/0002.raw");
            //return;
            //SpellsConverter.to0002raw("Spells/0E00000E - latest.txt");
            //SpellsConverter.toBin("Spells/0E00000E - Reversed.txt");
            //SpellsConverter.toTxt("Spells/0E00000E - Reversed.bin");
            //SpellsConverter.revertWeaponMasteries("Spells/0E00000E - Latest.txt", "Spells/0E00000E - 2010.txt");
            //SpellsConverter.toBin("0E00000E.txt");
            //SpellsConverter.toBin("Spells/0E00000E - Reversed plus removed auras.txt");
            //Diff.FolderDiff("E:\\Downloads\\Asheron's Call\\AC Utilities\\Dat Patcher\\All\\Summer", "E:\\Downloads\\Asheron's Call\\AC Utilities\\Dat Patcher\\All\\Winter");
            //TextureConverter.toPNG("06006D40.bin");
            //TextureConverter.darkMajestyfolderToPNG("Landscape Texture Conversion/DM/Textures");
            //TextureConverter.darkMajestyfolderToPNG("Landscape Texture Conversion/DM/Detail Textures");
            //TextureConverter.darkMajestyfolderToPNG("Landscape Texture Conversion/DM/Alpha Maps");
            //TextureConverter.darkMajestyToPNG("Landscape Texture Conversion/DM/Textures/05001c3c.bin");
            //TextureConverter.folderToPNG("Landscape Texture Conversion/ToD/Detail Textures");
            //TextureConverter.folderToPNG("Landscape Texture Conversion/ToD/Textures");
            //TextureConverter.folderToPNG("Landscape Texture Conversion/ToD/Alpha Maps");
            //RegionConverter.convert("Region/13000000.bin");
            //RegionConverterDM.convert("Region/130F0000 Bael.bin");
            //RegionComparer.compare("Region/130F0000 DM.bin", false, "Region/130F0000 Bael.bin", false);
            //TextureHeader.folderExtractTextureFromHeader("Landscape Texture Conversion/ToD/Alpha Maps/Headers");
            //TextureConverter.toBin("Landscape Texture Conversion/ToD/Alpha Maps/06006d6b.png", 0x06006d6b, 244);
            //DMtoToDTexture.convert();
            //cCache9Converter.writeJson("./PhatAC Cache/0009.raw", true);
            //cCache9Converter.writeJson("./input/0009.raw", "./output/weenies/", false);
            //cCache9Converter.writeJson("./PhatAC Cache/0009.raw", true, eWeenieTypes.Creature);
            //ClassNameConverter.convert();

            //cCache9Converter.generateRandomLoot("./PhatAC Cache/0009.raw", "./input/lootProfile2.json", false, true, false, true);//write creature entries to raw
            //cCache9Converter.generateRandomLoot("./PhatAC Cache/0009.raw", "./input/lootProfile2.json", true, false, true, false);//write items to json

            //cCache9Converter.generateRandomLoot("./PhatAC Cache/0009.raw", "./input/lootProfile.json", false, true, false, true);//write creature entries to raw
            //cCache9Converter.generateRandomLoot("./PhatAC Cache/0009.raw", "./input/lootProfile.json", true, false, true, false);//write items to json
            //cCache9Converter.generateRandomLoot("./PhatAC Cache/0009.raw", "./input/lootProfile.json", true, true, true, false);//write everything to json

            //cCache9Converter.generateRandomLoot("../input/0009.raw", "../input/lootProfile.json", "../output/cached/", true, true, false, true);//write everything to raw

            //cCache9Converter.writeExtendedJson("./PhatAC Cache/0009.raw", false);
            //cCache9Converter.writeRawFromExtendedJson("./output/extended weenies/");

            //cCache9Converter.writeRawFromRaw("./PhatAC Cache/0009.raw");

            //cCache9Converter.writeJson("./input/0009.raw", false);
            //cCache9Converter.writeExtendedJson("./input/0009.raw", false);
            //cCache9Converter.writeRawFromExtendedJson("./input/extended weenies/");

            Console.WriteLine("Done");
            Console.ReadLine();
            return;

            //bool invalidArgs = false;

            //if (args.Length == 0)
            //    invalidArgs = true;

            //if (!invalidArgs)
            //{
            //    switch (args[0].ToLower())
            //    {
            //        case "cached":
            //            {
            //                string fileLootProfile;
            //                string file0002;
            //                string file0009;

            //                if (args.Length >= 3)
            //                {
            //                    file0002 = Path.Combine(args[1], "0002.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");
            //                    fileLootProfile = args[2];

            //                    if (!File.Exists(fileLootProfile))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", fileLootProfile);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0002))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0002);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }

            //                sLootProfile lootProfile = cache9Converter.generateRandomLoot(file0009, file0002, fileLootProfile, "./output/cached/", true, true, false, true);//write everything to raw

            //                Console.WriteLine("Waiting while CachePwn builds cache.bin...");
            //                Stopwatch timer = new Stopwatch();
            //                timer.Start();
            //                Process cachePwnProcess = new Process();
            //                string path = AppDomain.CurrentDomain.BaseDirectory;
            //                cachePwnProcess.StartInfo.FileName = $"{path}CachePwn.exe";
            //                cachePwnProcess.StartInfo.Arguments = "2 .\\intermediate .\\output\\cached";
            //                cachePwnProcess.Start();
            //                cachePwnProcess.WaitForExit();
            //                timer.Stop();
            //                Console.WriteLine("Finished in {0} seconds.", timer.ElapsedMilliseconds / 1000f);

            //                if (lootProfile.otherOptions.copyOutputToFolder != "")
            //                {
            //                    if (!Directory.Exists(lootProfile.otherOptions.copyOutputToFolder))
            //                        Console.WriteLine("Invalid copyOutputToFolder: {0}", lootProfile.otherOptions.copyOutputToFolder);
            //                    else
            //                    {
            //                        Console.WriteLine("Copying output to \"{0}\"...", lootProfile.otherOptions.copyOutputToFolder);
            //                        timer.Reset();
            //                        timer.Start();

            //                        Utils.copyDirectory(".\\output\\cached", lootProfile.otherOptions.copyOutputToFolder, true, true);

            //                        timer.Stop();
            //                        Console.WriteLine("Finished in {0} seconds.", timer.ElapsedMilliseconds / 1000f);
            //                    }
            //                }
            //                return;
            //            }
            //        case "split":
            //            {
            //                string fileLootProfile;
            //                string file0002;
            //                string file0009;

            //                if (args.Length >= 3)
            //                {
            //                    file0002 = Path.Combine(args[1], "0002.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");
            //                    fileLootProfile = args[2];

            //                    if (!File.Exists(fileLootProfile))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", fileLootProfile);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0002))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0002);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                sLootProfile lootProfile = cache9Converter.generateRandomLoot(file0009, file0002, fileLootProfile, "./output/split/", false, true, false, true);//write creature entries to raw
            //                cache9Converter.generateRandomLoot(file0009, "", fileLootProfile, "./output/split/json/weenies/", true, false, true, false);//write items to json

            //                Console.WriteLine("Waiting while CachePwn builds cache.bin...");
            //                Stopwatch timer = new Stopwatch();
            //                timer.Start();
            //                Process cachePwnProcess = new Process();
            //                string path = AppDomain.CurrentDomain.BaseDirectory;
            //                cachePwnProcess.StartInfo.FileName = $"{path}CachePwn.exe";
            //                cachePwnProcess.StartInfo.Arguments = "2 .\\intermediate .\\output\\split";
            //                cachePwnProcess.Start();
            //                cachePwnProcess.WaitForExit();
            //                timer.Stop();
            //                Console.WriteLine("Finished in {0} seconds.", timer.ElapsedMilliseconds / 1000f);

            //                if (lootProfile.otherOptions.copyOutputToFolder != "")
            //                {
            //                    if (!Directory.Exists(lootProfile.otherOptions.copyOutputToFolder))
            //                        Console.WriteLine("Invalid copyOutputToFolder: {0}", lootProfile.otherOptions.copyOutputToFolder);
            //                    else
            //                    {
            //                        Console.WriteLine("Copying output to \"{0}\"...", lootProfile.otherOptions.copyOutputToFolder);
            //                        timer.Reset();
            //                        timer.Start();

            //                        Utils.copyDirectory(".\\output\\split", lootProfile.otherOptions.copyOutputToFolder, true, true);

            //                        timer.Stop();
            //                        Console.WriteLine("Finished in {0} seconds.", timer.ElapsedMilliseconds / 1000f);
            //                    }
            //                }
            //                return;
            //            }
            //        case "json":
            //            {
            //                string fileLootProfile;
            //                string file0002;
            //                string file0009;

            //                if (args.Length >= 3)
            //                {
            //                    file0002 = Path.Combine(args[1], "0002.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");
            //                    fileLootProfile = args[2];

            //                    if (!File.Exists(fileLootProfile))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", fileLootProfile);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0002))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0002);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.generateRandomLoot(file0009, file0002, fileLootProfile, "./output/json/", true, true, true, false);//write everything to json
            //                return;
            //            }
            //        case "loottablesjson":
            //            {
            //                string fileLootProfile;
            //                string file0002;
            //                string file0009;

            //                if (args.Length >= 3)
            //                {
            //                    file0002 = Path.Combine(args[1], "0002.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");
            //                    fileLootProfile = args[2];

            //                    if (!File.Exists(fileLootProfile))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", fileLootProfile);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0002))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0002);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.generateRandomLoot(file0009, file0002, fileLootProfile, "./output/json/", false, true, true, false);//write loot tables to json
            //                return;
            //            }
            //        case "loottables":
            //            {
            //                string fileLootProfile;
            //                string file0002;
            //                string file0009;

            //                if (args.Length >= 3)
            //                {
            //                    file0002 = Path.Combine(args[1], "0002.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");
            //                    fileLootProfile = args[2];

            //                    if (!File.Exists(fileLootProfile))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", fileLootProfile);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0002))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0002);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.generateRandomLoot(file0009, file0002, fileLootProfile, "./output/split/", false, true, false, true);//write loot tables to raw
            //                return;
            //            }
            //        case "weenies":
            //            {
            //                string file0009;

            //                if (args.Length >= 2)
            //                {
            //                    file0009 = Path.Combine(args[1], "0009.raw");

            //                    if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.writeJson(file0009, "./output/weenies/", false);
            //                return;
            //            }
            //        case "landblocks":
            //            {
            //                string file0006;
            //                string file0009;

            //                if (args.Length >= 2)
            //                {
            //                    file0006 = Path.Combine(args[1], "0006.raw");
            //                    file0009 = Path.Combine(args[1], "0009.raw");

            //                    if (!File.Exists(file0006))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0006);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                    else if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.loadWeeniesRaw(file0009);
            //                cache6Converter.loadFromRaw(file0006);
            //                cache6Converter.writeJson("./output/landblocks");
            //                return;
            //            }
            //        case "questflags":
            //            {
            //                string file0008;

            //                if (args.Length >= 2)
            //                {
            //                    file0008 = Path.Combine(args[1], "0008.raw");

            //                    if (!File.Exists(file0008))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0008);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache8Converter.loadFromRaw(file0008);
            //                cache8Converter.writeJson("./output");
            //                return;
            //            }
            //        case "raw2json":
            //            {
            //                string file0009;

            //                if (args.Length >= 2)
            //                {
            //                    file0009 = Path.Combine(args[1], "0009.raw");

            //                    if (!File.Exists(file0009))
            //                    {
            //                        Console.WriteLine("Invalid file: {0}", file0009);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }
            //                cache9Converter.writeExtendedJson(file0009, "./output/extended weenies/", false);
            //                return;
            //            }
            //        case "json2raw":
            //            {
            //                string folderExtendedWeenies;

            //                if (args.Length >= 2)
            //                {
            //                    folderExtendedWeenies = args[1];

            //                    if (!Directory.Exists(folderExtendedWeenies))
            //                    {
            //                        Console.WriteLine("Invalid folder: {0}", folderExtendedWeenies);
            //                        Console.ReadLine();
            //                        return;
            //                    }
            //                }
            //                else
            //                {
            //                    invalidArgs = true;
            //                    break;
            //                }

            //                cache9Converter.writeRawFromExtendedJson(folderExtendedWeenies);

            //                Console.WriteLine("Waiting while CachePwn builds cache.bin...");
            //                Stopwatch timer = new Stopwatch();
            //                timer.Start();
            //                Process cachePwnProcess = new Process();
            //                string path = AppDomain.CurrentDomain.BaseDirectory;
            //                cachePwnProcess.StartInfo.FileName = $"{path}CachePwn.exe";
            //                cachePwnProcess.StartInfo.Arguments = "2 .\\intermediate \".\\output\\extended weenies\"";
            //                cachePwnProcess.Start();
            //                cachePwnProcess.WaitForExit();
            //                timer.Stop();
            //                Console.WriteLine("Finished in {0} seconds.", timer.ElapsedMilliseconds / 1000f);
            //                return;
            //            }
            //    }
            //}

            //if (invalidArgs)
            //{
            //    Console.WriteLine("Invalid arguments.");
            //    Console.WriteLine("Valid Modes:");
            //    Console.WriteLine("    Cached: produces a cache.bin file that contains both the generated loot and modified creatures and chests entries. Due to a limitation this file can only store up to 26550 new entries.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder) (profileFile)");
            //    Console.WriteLine("    Split: produces a cache.bin file that contains the modified creatures and chests entries, and json files for the generated loot. Thus avoiding the limitation mentioned above but increasing server starting times considerably.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder) (profileFile)");
            //    Console.WriteLine("    lootTables");
            //    Console.WriteLine("        Usage: (mode) (inputFolder) (profileFile)");
            //    Console.WriteLine("    Json: no cache.bin is produced, instead all modified entries are created as json.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder) (profileFile)");
            //    Console.WriteLine("    lootTablesJson");
            //    Console.WriteLine("        Usage: (mode) (inputFolder) (profileFile)");
            //    Console.WriteLine("    raw2json: generate extended weenies that can later be reconverted into cached files.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder)");
            //    Console.WriteLine("    json2raw: generate cache.bin file from extended weenies");
            //    Console.WriteLine("        Usage: (mode) (inputFolder)");
            //    Console.WriteLine("    Weenies: generate commented weenies files.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder)");
            //    Console.WriteLine("    Landblocks: generate landblock files.");
            //    Console.WriteLine("        Usage: (mode) (inputFolder)");
            //    Console.ReadLine();
            //}
        }
Example #8
0
        public void buildTextureIdMigrationTable(cDatFile otherDat)
        {
            Dictionary <uint, cEnvCell>       thisEnvCells     = new Dictionary <uint, cEnvCell>();;
            Dictionary <uint, cEnvCell>       otherEnvCells    = new Dictionary <uint, cEnvCell>();;
            SortedDictionary <ushort, ushort> idMigrationTable = new SortedDictionary <ushort, ushort>();;

            SortedDictionary <ushort, cAmbiguousValues> ambiguousList = new SortedDictionary <ushort, cAmbiguousValues>();

            List <ushort> allOldIds = new List <ushort>();
            SortedDictionary <ushort, ushort> missingList = new SortedDictionary <ushort, ushort>();

            foreach (KeyValuePair <uint, cDatFileEntry> entry in fileCache)
            {
                if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF) //surface
                {
                }
                else if ((entry.Value.fileId & 0x0000FFFE) == 0x0000FFFE) //surface objects
                {
                }
                else //dungeons and interiors
                {
                    cEnvCell thisEnvCell = new cEnvCell(entry.Value);

                    thisEnvCells.Add(entry.Value.fileId, thisEnvCell);
                }
            }

            foreach (KeyValuePair <uint, cDatFileEntry> entry in otherDat.fileCache)
            {
                if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF) //surface
                {
                }
                else if ((entry.Value.fileId & 0x0000FFFE) == 0x0000FFFE) //surface objects
                {
                }
                else //dungeons and interiors
                {
                    cEnvCell otherEnvCell = new cEnvCell(entry.Value, false);

                    otherEnvCells.Add(entry.Value.fileId, otherEnvCell);
                }
            }

            foreach (KeyValuePair <uint, cEnvCell> entry in otherEnvCells)
            {
                cEnvCell thisEnvCell;
                cEnvCell otherEnvCell = entry.Value;

                if (!thisEnvCells.TryGetValue(otherEnvCell.Id, out thisEnvCell))
                {
                    continue;
                }

                for (int i = 0; i < otherEnvCell.Textures.Count; i++)
                {
                    ushort oldId = otherEnvCell.Textures[i];
                    if (!allOldIds.Contains(oldId))
                    {
                        allOldIds.Add(oldId);
                    }
                }

                if (compareEnvCells(thisEnvCell, otherEnvCell))
                {
                    for (int i = 0; i < otherEnvCell.Textures.Count; i++)
                    {
                        ushort oldId = otherEnvCell.Textures[i];
                        ushort newId = thisEnvCell.Textures[i];

                        ushort currentId = 0;
                        idMigrationTable.TryGetValue(oldId, out currentId);

                        if (currentId == 0)
                        {
                            idMigrationTable.Add(oldId, newId);
                        }
                        else
                        {
                            if (newId != currentId)
                            {
                                cAmbiguousValues ambiguousId;
                                if (!ambiguousList.TryGetValue(oldId, out ambiguousId))
                                {
                                    ambiguousId                 = new cAmbiguousValues();
                                    ambiguousId.newId           = currentId;
                                    ambiguousId.alternateNewIds = new List <ushort>();
                                    ambiguousList.Add(oldId, ambiguousId);
                                    ambiguousId.alternateNewIds.Add(newId);
                                }
                                else
                                {
                                    if (!ambiguousId.alternateNewIds.Contains(newId))
                                    {
                                        ambiguousId.alternateNewIds.Add(newId);
                                    }
                                }
                                //throw new Exception("ambiguous texture id migration");
                            }
                        }
                    }
                }
            }

            foreach (ushort entry in allOldIds)
            {
                if (!idMigrationTable.ContainsKey(entry))
                {
                    missingList.Add(entry, entry);
                }
            }

            StreamWriter outputFile = new StreamWriter(new FileStream("textureIdMigrationTable.txt", FileMode.Create, FileAccess.Write));

            foreach (KeyValuePair <ushort, ushort> entry in idMigrationTable)
            {
                outputFile.WriteLine($"{entry.Key.ToString("x4")} {entry.Value.ToString("x4")}");
                outputFile.Flush();
            }
            outputFile.Close();

            outputFile = new StreamWriter(new FileStream("textureIdMigrationMissingConversions.txt", FileMode.Create, FileAccess.Write));
            foreach (KeyValuePair <ushort, ushort> entry in missingList)
            {
                outputFile.WriteLine(entry.Key.ToString("x4"));
                outputFile.Flush();
            }
            outputFile.Close();

            outputFile = new StreamWriter(new FileStream("textureIdMigrationTableAmbiguous.txt", FileMode.Create, FileAccess.Write));
            foreach (KeyValuePair <ushort, cAmbiguousValues> entry in ambiguousList)
            {
                outputFile.Write($"{entry.Key.ToString("x4")} {entry.Value.newId.ToString("x4")}");
                bool first = true;
                foreach (ushort value in entry.Value.alternateNewIds)
                {
                    if (first)
                    {
                        outputFile.Write("(");
                        first = false;
                    }
                    else
                    {
                        outputFile.Write(", ");
                    }
                    outputFile.Write(value.ToString("x4"));
                    outputFile.Flush();
                }
                outputFile.WriteLine(")");

                outputFile.Flush();
            }
            outputFile.Close();
        }