Example #1
0
    public static string smethod_1(int value)
    {
        VBMath.Randomize();
        StringBuilder stringBuilder = new StringBuilder("");

        char[] charArray = "A0B1C2D3E4F5G6H7I8J9KLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".ToCharArray();
        int    num1      = value;
        int    num2      = 1;

        while (num2 <= num1)
        {
            VBMath.Randomize();
            int index = checked ((int)Math.Round(unchecked ((double)Conversion.Int((float)checked (charArray.Length - 2 - 0 + 1) * VBMath.Rnd()) + 1.0)));
            stringBuilder.Append(charArray[index]);
            checked { ++num2; }
        }
        return(stringBuilder.ToString());
    }
Example #2
0
            public static object Key()
            {
                short  sh3;
                object obj;

                string s   = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
                short  sh2 = checked ((short)Conversions.ToInteger("22"));
                short  sh1 = 1;

                while (sh1 <= sh3)
                {
                    obj = Operators.ConcatenateObject(obj, Strings.Mid(s, checked ((int)Math.Round((double)Conversion.Int((VBMath.Rnd() * (float)Strings.Len(s)) + 1.0F))), 1));
                    sh1 = checked ((short)(sh1 + 1));
                    sh3 = sh2;
                }
                return(obj);
            }
Example #3
0
        public static void InitServer()
        {
            int i;
            int F;
            int x;
            int time1;
            int time2;

            myStopWatch.Start();

            if (Debugger.IsAttached)
            {
                // Since there is a debugger attached,
                // assume we are running from the IDE
                S_Globals.Debugging = true;
            }
            else
            {
                // Assume we aren't running from the IDE
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.UnhandledException += ErrorHandler;
            }

            Console.Title = "Lupus Engine Server";
            Console.SetWindowSize(120, 20);

            time1 = GetTimeMs();

            // Initialize the random-number generator
            VBMath.Randomize();

            // LOAD ENCRYPTION
            var fi = Application.StartupPath + @"\AsyncKeys.xml";

            if (!File.Exists(fi))
            {
                S_Globals.EKeyPair.GenerateKeys();
                S_Globals.EKeyPair.ExportKey(fi, true); // True exports private key too.
            }
            else
            {
                S_Globals.EKeyPair.ImportKey(fi);
            }
            // END LOAD ENCRYPTION

            modTypes.Map = new MapRec[601];

            modTypes.MapNpc = new MapDataRec[601];
            for (i = 0; i <= S_Instances.MAX_CACHED_MAPS; i++)
            {
                modTypes.MapNpc[i].Npc = new MapNpcRec[Constants.MAX_MAP_NPCS + 1];
                modTypes.Map[i].Npc    = new int[Constants.MAX_MAP_NPCS + 1];
            }

            // quests
            S_Quest.Quest = new QuestRec[251];
            S_Quest.ClearQuests();

            // event
            S_Events.Switches     = new string[501];
            S_Events.Variables    = new string[501];
            S_Events.TempEventMap = new GlobalEventsStruct[601];

            // Housing
            S_Housing.HouseConfig = new HouseRec[S_Housing.MAX_HOUSES + 1];

            for (i = 0; i <= S_Instances.MAX_CACHED_MAPS; i++)
            {
                for (x = 0; x <= Constants.MAX_MAP_NPCS; x++)
                {
                    modTypes.MapNpc[i].Npc[x].Vital = new int[(int)Enums.VitalType.Count + 1];
                }
            }

            modTypes.Bank = new BankRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.Bank[i].Item     = new PlayerInvRec[Constants.MAX_BANK + 1];
                modTypes.Bank[i].ItemRand = new RandInvRec[Constants.MAX_BANK + 1];
                for (x = 1; x <= Constants.MAX_BANK; x++)
                {
                    modTypes.Bank[i].ItemRand[x].Stat = new int[7];
                }
            }

            modTypes.Player = new PlayerRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                // multi char
                modTypes.Player[i].Character = new CharacterRec[S_Constants.MAX_CHARS + 1];
                for (x = 1; x <= S_Constants.MAX_CHARS; x++)
                {
                    modTypes.Player[i].Character[x].Switches    = new byte[501];
                    modTypes.Player[i].Character[x].Variables   = new int[501];
                    modTypes.Player[i].Character[x].Vital       = new int[4];
                    modTypes.Player[i].Character[x].Stat        = new int[7];
                    modTypes.Player[i].Character[x].Equipment   = new int[7];
                    modTypes.Player[i].Character[x].Inv         = new PlayerInvRec[Constants.MAX_INV + 1];
                    modTypes.Player[i].Character[x].Skill       = new int[Constants.MAX_PLAYER_SKILLS + 1];
                    modTypes.Player[i].Character[x].PlayerQuest = new PlayerQuestRec[251];

                    modTypes.Player[i].Character[x].RandEquip = new RandInvRec[7];
                    modTypes.Player[i].Character[x].RandInv   = new RandInvRec[Constants.MAX_INV + 1];
                    for (var y = 1; y <= (int)Enums.EquipmentType.Count - 1; y++)
                    {
                        modTypes.Player[i].Character[x].RandEquip[y].Stat = new int[7];
                    }
                    for (int y = 1; y <= Constants.MAX_INV; y++)
                    {
                        modTypes.Player[i].Character[x].RandInv[y].Stat = new int[7];
                    }
                }
            }

            modTypes.TempPlayer = new TempPlayerRec[71];

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.TempPlayer[i].SkillCd    = new int[Constants.MAX_PLAYER_SKILLS + 1];
                modTypes.TempPlayer[i].PetSkillCd = new int[5];
            }

            for (i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                modTypes.TempPlayer[i].TradeOffer = new PlayerInvRec[Constants.MAX_INV + 1];
            }

            S_AutoMap.LoadTilePrefab();

            Types.Classes = new ClassRec[S_Globals.Max_Classes + 1];
            var loopTo = S_Globals.Max_Classes;

            for (i = 0; i <= loopTo; i++)
            {
                Types.Classes[i].Stat       = new byte[7];
                Types.Classes[i].StartItem  = new int[6];
                Types.Classes[i].StartValue = new int[6];
            }

            for (i = 0; i <= Constants.MAX_ITEMS; i++)
            {
                Types.Item[i].Add_Stat        = new byte[7];
                Types.Item[i].Stat_Req        = new byte[7];
                Types.Item[i].FurnitureBlocks = new int[4, 4];
                Types.Item[i].FurnitureFringe = new int[4, 4];
            }
            Types.Npc[Constants.MAX_NPCS].Stat = new byte[7];

            Types.Shop[Constants.MAX_SHOPS].TradeItem = new TradeItemRec[Constants.MAX_TRADES + 1];

            Types.Animation[Constants.MAX_ANIMATIONS].Sprite    = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].Frames    = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].LoopCount = new int[2];
            Types.Animation[Constants.MAX_ANIMATIONS].LoopTime  = new int[2];

            S_Projectiles.MapProjectiles = new MapProjectileRec[601, 256];
            S_Projectiles.Projectiles    = new ProjectileRec[256];

            // parties
            S_Parties.ClearParties();

            // pets
            S_Pets.Pet = new PetRec[101];
            S_Pets.ClearPets();

            // Check if the directory is there, if its not make it
            CheckDir(Path.Combine(Application.StartupPath, "data"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "items"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "maps"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "npcs"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "shops"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "skills"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "accounts"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "resources"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "animations"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "logs"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "quests"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "recipes"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "pets"));
            CheckDir(Path.Combine(Application.StartupPath, "data", "projectiles"));

            // load options, set if they dont exist
            if (!File.Exists(Path.Combine(Application.StartupPath, "Data", "Config.xml")))
            {
                modTypes.Options.GameName = "Lupus Engine";
                modTypes.Options.Port     = 7001;
                modTypes.Options.Motd     = "Welcome to the Lupus Engine";
                modTypes.Options.Website  = "http://ascensiongamedev.com/index.php";
                modTypes.Options.StartMap = 1;
                modTypes.Options.StartX   = 13;
                modTypes.Options.StartY   = 7;
                modTypes.Options.allowEightDirectionalMovement  = true;
                modTypes.Options.useSmoothDynamicLightRendering = true;
                modDatabase.SaveOptions();
            }
            else
            {
                modDatabase.LoadOptions();
            }

            // Get that network READY SUN! ~ SpiceyWOlf
            S_NetworkConfig.InitNetwork();

            Console.ForegroundColor = ConsoleColor.Yellow;

            // Init all the player sockets
            Console.WriteLine("Initializing player array...");

            for (x = 1; x <= Constants.MAX_PLAYERS; x++)
            {
                modDatabase.ClearPlayer(x);
            }

            // Serves as a constructor
            ClearGameData();
            LoadGameData();
            Console.WriteLine("Spawning map items...");
            S_Items.SpawnAllMapsItems();
            Console.WriteLine("Spawning map npcs...");
            S_Npc.SpawnAllMapNpcs();

            // Check if the master charlist file exists for checking duplicate names, and if it doesnt make it
            if (!File.Exists(@"data\accounts\charlist.txt"))
            {
                F = FileSystem.FreeFile();
            }

            // resource system
            S_Resources.LoadSkillExp();

            modTime.InitTime();

            UpdateCaption();
            time2 = GetTimeMs();

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.Clear();
            Console.WriteLine(@"ooooo        ooooo     ooo ooooooooo.   ooooo     ooo  .oooooo..o ");
            Console.WriteLine(@"`888'        `888'     `8' `888   `Y88. `888'     `8' d8P'    `Y8 ");
            Console.WriteLine(@" 888          888       8   888   .d88'  888       8  Y88bo.      ");
            Console.WriteLine(@" 888          888       8   888ooo88P'   888       8   `""Y8888o.  ");
            Console.WriteLine(@" 888          888       8   888          888       8       `""Y88b ");
            Console.WriteLine(@" 888       o  `88.    .8'   888          `88.    .8'  oo     .d8P ");
            Console.WriteLine(@"o888ooooood8    `YbodP'    o888o           `YbodP'    8""""88888P'  ");

            Console.WriteLine("");

            Console.ForegroundColor = ConsoleColor.Yellow;

            Console.WriteLine("Initialization complete. Server loaded in " + (time2 - time1).ToString() + "ms.");
            Console.WriteLine("");
            Console.WriteLine("Use /help for the available commands.");

            Console.ResetColor();

            MyIPAddress = S_NetworkConfig.GetIP();

            UpdateCaption();

            // reset shutdown value
            S_Globals.isShuttingDown = false;

            try
            {
                // Start listener now that everything is loaded
                S_NetworkConfig.Socket.StartListening(modTypes.Options.Port, 5);
            }
            catch (Exception err)
            {
                Console.WriteLine("FAILED TO START SERVER");
                Console.WriteLine(err.StackTrace.ToString());
                return;
            }

            // Starts the server loop
            ModLoop.ServerLoop();
        }
Example #4
0
 public void GetRandomStatic(ushort X, ushort Y, ushort Z, Collection[,] StaticMap)
 {
     checked
     {
         if (this.m_Random.Count != 0)
         {
             VBMath.Randomize();
             if ((int)Math.Round((double)Conversion.Int(unchecked (100f * VBMath.Rnd()))) <= this.m_Freq)
             {
                 int index = (int)Math.Round((double)unchecked ((float)Conversion.Int(checked (this.m_Random.Count - 1)) * VBMath.Rnd())) + 1;
                 ((RandomStaticCollection)this.m_Random[index]).RandomStatic(X, Y, Z, StaticMap);
             }
         }
     }
 }
Example #5
0
        public static void Startup()
        {
            SFML.Portable.Activate();

            SetStatus(Strings.Get("loadscreen", "loading"));

            FrmMenu.Default.Visible = true;

            C_Types.CharSelection = new C_Types.CharSelRec[4];

            C_Types.Player = new C_Types.PlayerRec[Constants.MAX_PLAYERS + 1];

            for (var i = 1; i <= Constants.MAX_PLAYERS; i++)
            {
                C_Player.ClearPlayer(System.Convert.ToInt32(i));
            }

            C_AutoTiles.ClearAutotiles();

            //Housing
            C_Housing.House       = new C_Housing.HouseRec[C_Housing.MaxHouses + 1];
            C_Housing.HouseConfig = new C_Housing.HouseRec[C_Housing.MaxHouses + 1];

            //quests
            C_Quest.ClearQuests();

            //npc's
            C_DataBase.ClearNpcs();
            C_Maps.Map.Npc = new int[Constants.MAX_MAP_NPCS + 1];
            C_Maps.MapNpc  = new C_Types.MapNpcRec[Constants.MAX_MAP_NPCS + 1];
            for (var i = 0; i <= Constants.MAX_MAP_NPCS; i++)
            {
                for (var x = 0; x <= (int)Enums.VitalType.Count - 1; x++)
                {
                    C_Maps.MapNpc[(int)i].Vital = new int[(int)x + 1];
                }
            }

            C_Shops.ClearShops();

            C_DataBase.ClearAnimations();

            C_DataBase.ClearAnimInstances();

            C_Banks.ClearBank();

            C_Projectiles.MapProjectiles = new C_Projectiles.MapProjectileRec[C_Projectiles.MaxProjectiles + 1];
            C_Projectiles.Projectiles    = new C_Projectiles.ProjectileRec[C_Projectiles.MaxProjectiles + 1];

            C_Items.ClearItems();

            //craft
            C_Crafting.ClearRecipes();

            //party
            C_Parties.ClearParty();

            //pets
            C_Pets.ClearPets();

            C_Variables.GettingMap = true;
            C_Variables.VbQuote    = System.Convert.ToString((char)34);           // "

            // Update the form with the game's name before it's loaded
            FrmGame.Default.Text = C_Constants.GameName;

            SetStatus(Strings.Get("loadscreen", "options"));

            // load options
            if (File.Exists(Application.StartupPath + "\\Data\\Config.xml"))
            {
                C_DataBase.LoadOptions();
            }
            else
            {
                C_DataBase.CreateOptions();
            }

            // randomize rnd's seed
            VBMath.Randomize();

            SetStatus(Strings.Get("loadscreen", "network"));

            FrmMenu.Default.Text = C_Constants.GameName;

            // DX7 Master Object is already created, early binding
            SetStatus(Strings.Get("loadscreen", "graphics"));
            C_Maps.CheckTilesets();
            C_DataBase.CheckCharacters();
            C_DataBase.CheckPaperdolls();
            C_DataBase.CheckAnimations();
            C_Items.CheckItems();
            C_Resources.CheckResources();
            C_DataBase.CheckSkillIcons();
            C_DataBase.CheckFaces();
            C_DataBase.CheckFog();
            C_DataBase.CacheMusic();
            C_DataBase.CacheSound();
            C_DataBase.CheckEmotes();
            C_DataBase.CheckPanoramas();
            C_Housing.CheckFurniture();
            C_Projectiles.CheckProjectiles();
            C_DataBase.CheckParallax();

            C_Graphics.InitGraphics();

            // check if we have main-menu music
            if (C_Types.Options.Music == 1 && C_Types.Options.MenuMusic.Trim().Length > 0)
            {
                C_Sound.PlayMusic(C_Types.Options.MenuMusic.Trim());
                C_Sound.MusicPlayer.Volume = 100;
            }

            // Reset values
            C_Variables.Ping = -1;

            // set values for directional blocking arrows
            C_Variables.DirArrowX[1] = (byte)12;             // up
            C_Variables.DirArrowY[1] = (byte)0;
            C_Variables.DirArrowX[2] = (byte)12;             // down
            C_Variables.DirArrowY[2] = (byte)23;
            C_Variables.DirArrowX[3] = (byte)0;              // left
            C_Variables.DirArrowY[3] = (byte)12;
            C_Variables.DirArrowX[4] = (byte)23;             // right
            C_Variables.DirArrowY[4] = (byte)12;

            //set gui switches
            C_UpdateUI.HudVisible = true;

            SetStatus(Strings.Get("loadscreen", "starting"));
            Started = true;
            C_UpdateUI.Frmmenuvisible = true;
            C_UpdateUI.Pnlloadvisible = false;

            C_UpdateUI.PnlInventoryVisible = true;

            C_NetworkConfig.InitNetwork();

            C_GameLogic.GameLoop();
        }
Example #6
0
        public static ISymbol GetASymbolBySymbolType(string SymbolType, IColor aColor)
        {
            if (aColor == null)
            {
                IRgbColor pRgbColor;
                aColor        = new RgbColorClass();
                pRgbColor     = (IRgbColor)aColor;
                pRgbColor.RGB = Information.RGB((int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255), (int)(VBMath.Rnd(1) * 255));
            }

            switch (SymbolType)
            {
            case "面状地物符号":
                ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass();
                pFillSymbol.Color = aColor;
                return((ISymbol)pFillSymbol);

            case "线状地物符号":
                ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
                pLineSymbol.Width = 1;
                pLineSymbol.Color = aColor;
                return((ISymbol)pLineSymbol);

            case "点状地物符号":
                IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();
                pMarkerSymbol.Color = aColor;
                return((ISymbol)pMarkerSymbol);

            default:
                return(null);
            }
        }
        private void Make()
        {
            short           altID = 0;
            string          str;
            byte            num = 0;
            int             num1;
            int             num2;
            int             num3;
            int             num4;
            IEnumerator     enumerator      = null;
            TransitionTable transitionTable = new TransitionTable();
            DateTime        now             = DateTime.Now;

            this.iLogger.StartTask();
            this.iLogger.LogMessage("Loading Terrain Image.");
            try
            {
                str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.TerrainFile.Text);
                this.iLogger.LogMessage(str);
                this.i_Terrain = new Bitmap(str);
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                this.iLogger.LogMessage("Problem with Loading Terrain Image.");
                this.iLogger.LogMessage(exception.Message);
                ProjectData.ClearProjectError();
                return;
            }
            this.iLogger.LogMessage("Loading Altitude Image.");
            try
            {
                str = string.Format("{0}\\{1}", this.ProjectPath.Text, this.AltitudeFile.Text);
                this.iLogger.LogMessage(str);
                this.i_Altitude = new Bitmap(str);
            }
            catch (Exception exception3)
            {
                ProjectData.SetProjectError(exception3);
                Exception exception2 = exception3;
                this.iLogger.LogMessage("Problem with Loading Altitude Image.");
                this.iLogger.LogMessage(exception2.Message);
                ProjectData.ClearProjectError();
                return;
            }
            //this.iLogger.EndTask();
            this.iLogger.LogTimeStamp();
            this.iLogger.LogMessage("Preparing Image Files.");
            this.iLogger.StartTask();
            int        width       = this.i_Terrain.Width;
            int        height      = this.i_Terrain.Height;
            Rectangle  rectangle   = new Rectangle(0, 0, width, height);
            BitmapData bitmapDatum = this.i_Terrain.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
            IntPtr     scan0       = bitmapDatum.Scan0;
            int        width1      = checked (bitmapDatum.Width * bitmapDatum.Height);

            byte[] numArray = new byte[checked (checked (width1 - 1) + 1)];
            Marshal.Copy(scan0, numArray, 0, width1);
            BitmapData bitmapDatum1 = this.i_Altitude.LockBits(rectangle, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
            IntPtr     intPtr       = bitmapDatum1.Scan0;
            int        width2       = checked (bitmapDatum1.Width * bitmapDatum1.Height);

            byte[] numArray1 = new byte[checked (checked (width2 - 1) + 1)];
            Marshal.Copy(intPtr, numArray1, 0, width2);
            //this.iLogger.EndTask();
            this.iLogger.LogTimeStamp();
            this.iLogger.LogMessage("Creating Master Terrian Table.");
            this.iLogger.StartTask();
            MapCell[,] mapCell = new MapCell[checked (width + 1), checked (height + 1)];
            ClsElevationTable clsAltitudeTable = new ClsElevationTable();

            clsAltitudeTable.Load();
            try
            {
                int num5 = checked (width - 1);
                for (int i = 0; i <= num5; i++)
                {
                    int num6 = checked (height - 1);
                    for (int j = 0; j <= num6; j++)
                    {
                        int num7 = checked (checked (j * width) + i);

                        //ClsAltitude getAltitude = clsAltitudeTable[numArray1[num7]];
                        ClsElevation getAltitude = clsAltitudeTable.GetAltitude(numArray1[num7]);

                        mapCell[i, j] = new MapCell(numArray[num7], getAltitude.GetAltitude);
                    }
                }
            }
            catch (Exception exception4)
            {
                ProjectData.SetProjectError(exception4);
                this.iLogger.LogMessage("Altitude image needs to be rebuilt");
                ProjectData.ClearProjectError();
                return;
            }
            this.i_Terrain.Dispose();
            this.i_Altitude.Dispose();
            //this.iLogger.EndTask();
            this.iLogger.LogTimeStamp();
            width--;
            height--;
            int num8 = checked ((int)Math.Round((double)width / 8 - 1));
            int num9 = checked ((int)Math.Round((double)height / 8 - 1));

            this.iLogger.LogMessage("Load Transition Tables.");
            this.iLogger.StartTask();
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

            baseDirectory = string.Concat(baseDirectory, "Data\\Transitions\\");
            if (Directory.Exists(baseDirectory))
            {
                transitionTable.MassLoad(baseDirectory);
                //this.iLogger.EndTask();
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Preparing Static Tables");
                Collection[,] collections = new Collection[checked (num8 + 1), checked (num9 + 1)];
                int num10 = num8;
                for (int k = 0; k <= num10; k++)
                {
                    int num11 = num9;
                    for (int l = 0; l <= num11; l++)
                    {
                        collections[k, l] = new Collection();
                    }
                }
                this.iLogger.LogMessage("Applying Transition Tables.");
                this.iLogger.StartTask();
                this.ProgressBar1.Maximum = width;
                ClsTerrainTable clsTerrainTable = new ClsTerrainTable();
                clsTerrainTable.Load();
                MapTile mapTile = new MapTile();

                //Transition transition = new Transition();
                Transition.Transition transition = new Transition.Transition();
                //Transition.Transition mytransition = new Transition.Transition();

                short[] numArray2 = new short[16];
                short   num12     = checked ((short)width);
                for (short m = 0; m <= num12; m = checked ((short)(m + 1)))
                {
                    num1 = (m != 0 ? checked (m - 1) : width);
                    num2 = (m != width ? checked (m + 1) : 0);
                    short num13 = checked ((short)height);
                    for (short n = 0; n <= num13; n = checked ((short)(n + 1)))
                    {
                        num4 = (n != 0 ? checked (n - 1) : height);
                        num3 = (n != height ? checked (n + 1) : 0);
                        object[] groupID = new object[] { mapCell[num1, num4].GroupID, mapCell[m, num4].GroupID, mapCell[num2, num4].GroupID, mapCell[num1, n].GroupID, mapCell[m, n].GroupID, mapCell[num2, n].GroupID, mapCell[num1, num3].GroupID, mapCell[m, num3].GroupID, mapCell[num2, num3].GroupID };
                        string   str1    = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}", groupID);
                        try
                        {
                            //transition = transitionTable[str1];

                            transition = (Transition.Transition)(transitionTable.GetTransitionTable[str1]);

                            //transitionTable.MassLoad(str1);
                            //transition = (transitionTable.MassLoad(str1));
                            //transition = transitionTable.MassLoad(str1);
                            if (transition == null)
                            {
                                //ClsTerrain terrianGroup = clsTerrainTable[mapCell[m, n].GroupID];
                                ClsTerrain terrianGroup = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID);

                                mapCell[m, n].TileID = terrianGroup.TileID;
                                mapCell[m, n].AltID  = altID;
                                terrianGroup         = null;
                            }
                            else
                            {
                                altID   = mapCell[m, n].AltID;
                                mapTile = transition.GetRandomMapTile();
                                if (mapTile == null)
                                {
                                    //ClsTerrain clsTerrain = clsTerrainTable[mapCell[m, n].GroupID];
                                    ClsTerrain clsTerrain = clsTerrainTable.TerrianGroup(mapCell[m, n].GroupID);
                                    mapCell[m, n].TileID = clsTerrain.TileID;
                                    mapCell[m, n].ChangeAltID((short)clsTerrain.AltID);
                                    clsTerrain = null;
                                }
                                else
                                {
                                    MapTile mapTile1 = mapTile;
                                    mapCell[m, n].TileID = mapTile1.TileID;
                                    mapCell[m, n].ChangeAltID(mapTile1.AltIDMod);
                                    mapTile1 = null;
                                }
                                transition.GetRandomStaticTiles(m, n, altID, collections, this.i_RandomStatic);
                            }
                            if (mapCell[m, n].GroupID == 254)
                            {
                                mapCell[m, n].TileID = 1078;
                                mapCell[m, n].AltID  = 0;
                            }
                        }
                        catch (Exception exception6)
                        {
                            ProjectData.SetProjectError(exception6);
                            Exception  exception5 = exception6;
                            LoggerForm loggerForm = this.iLogger;
                            groupID = new object[] { m, n, altID, str1 };
                            loggerForm.LogMessage(string.Format("\r\nLocation: X:{0}, Y:{1}, Z:{2} Hkey:{3}", groupID));
                            this.iLogger.LogMessage(exception5.ToString());
                            ProjectData.ClearProjectError();
                            return;
                        }
                    }
                    this.ProgressBar1.Value = m;
                }
                //this.iLogger.EndTask();
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Second Pass.");
                this.iLogger.StartTask();
                short[]   altID1    = new short[9];
                RoughEdge roughEdge = new RoughEdge();
                short     num14     = checked ((short)width);
                for (short o = 0; o <= num14; o = checked ((short)(o + 1)))
                {
                    num1 = (o != 0 ? checked (o - 1) : width);
                    num2 = (o != width ? checked (o + 1) : 0);
                    short num15 = checked ((short)height);
                    for (short p = 0; p <= num15; p = checked ((short)(p + 1)))
                    {
                        num4 = (p != 0 ? checked (p - 1) : height);
                        num3 = (p != height ? checked (p + 1) : 0);
                        mapCell[o, p].ChangeAltID(roughEdge.CheckCorner(mapCell[num1, num4].TileID));
                        mapCell[o, p].ChangeAltID(roughEdge.CheckLeft(mapCell[num1, p].TileID));
                        mapCell[o, p].ChangeAltID(roughEdge.CheckTop(mapCell[o, num4].TileID));
                        if (mapCell[o, p].GroupID == 20)
                        {
                            altID1[0] = mapCell[num1, num4].AltID;
                            altID1[1] = mapCell[o, num4].AltID;
                            altID1[2] = mapCell[num2, num4].AltID;
                            altID1[3] = mapCell[num1, p].AltID;
                            altID1[4] = mapCell[o, p].AltID;
                            altID1[5] = mapCell[num2, p].AltID;
                            altID1[6] = mapCell[num1, num3].AltID;
                            altID1[7] = mapCell[o, num3].AltID;
                            altID1[8] = mapCell[num2, num3].AltID;
                            Array.Sort(altID1);
                            float single = 10f * VBMath.Rnd();
                            if (single == 0f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 4)));
                            }
                            else if (single >= 1f && single <= 2f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] - 2)));
                            }
                            else if (single >= 3f && single <= 7f)
                            {
                                mapCell[o, p].AltID = altID1[8];
                            }
                            else if (single >= 8f && single <= 9f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 2)));
                            }
                            else if (single == 10f)
                            {
                                mapCell[o, p].AltID = checked ((short)(checked (altID1[8] + 4)));
                            }
                        }

                        //if (clsTerrainTable[mapCell[o, p].GroupID].RandAlt)
                        if (clsTerrainTable.TerrianGroup(mapCell[o, p].GroupID).RandAlt)
                        {
                            float single1 = 10f * VBMath.Rnd();
                            if (single1 == 0f)
                            {
                                mapCell[o, p].ChangeAltID(-4);
                            }
                            else if (single1 >= 1f && single1 <= 2f)
                            {
                                mapCell[o, p].ChangeAltID(-2);
                            }
                            else if (single1 >= 8f && single1 <= 9f)
                            {
                                mapCell[o, p].ChangeAltID(2);
                            }
                            else if (single1 == 10f)
                            {
                                mapCell[o, p].ChangeAltID(4);
                            }
                        }
                    }
                    this.ProgressBar1.Value = o;
                }
                //this.iLogger.EndTask();
                this.iLogger.LogTimeStamp();
                int num16 = 1;
                int num17 = width;
                if (num17 == 6143)
                {
                    num = 0;
                }
                else if (num17 == 2303)
                {
                    num = 2;
                }
                else if (num17 == 2559)
                {
                    num = 3;
                }
                this.iLogger.LogMessage("\r\n");
                this.iLogger.LogMessage("Load . . . . . Import Tiles.");
                this.iLogger.StartTask();
                ImportTiles importTile = new ImportTiles(collections, this.ProjectPath.Text);
                //this.iLogger.EndTask();
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("\r\n");
                this.iLogger.LogMessage("Write Mul Files.");
                this.iLogger.StartTask();
                str = string.Format("{0}/Map{1}.mul", this.ProjectPath.Text, num);
                this.iLogger.LogMessage(str);
                FileStream   fileStream   = new FileStream(str, FileMode.Create);
                BinaryWriter binaryWriter = new BinaryWriter(fileStream);
                int          num18        = width;
                for (int q = 0; q <= num18; q = checked (q + 8))
                {
                    int num19 = height;
                    for (int r = 0; r <= num19; r = checked (r + 8))
                    {
                        binaryWriter.Write(num16);
                        int num20 = 0;
                        do
                        {
                            int num21 = 0;
                            do
                            {
                                mapCell[checked (q + num21), checked (r + num20)].WriteMapMul(binaryWriter);
                                num21++;
                            }while (num21 <= 7);
                            num20++;
                        }while (num20 <= 7);
                    }
                }
                binaryWriter.Close();
                fileStream.Close();
                str = string.Format("{0}/StaIdx{1}.mul", this.ProjectPath.Text, num);
                FileStream fileStream1 = new FileStream(str, FileMode.Create);
                this.iLogger.LogMessage(str);
                str = string.Format("{0}/Statics{1}.mul", this.ProjectPath.Text, num);
                FileStream fileStream2 = new FileStream(str, FileMode.Create);
                this.iLogger.LogMessage(str);
                BinaryWriter binaryWriter1 = new BinaryWriter(fileStream1);
                BinaryWriter binaryWriter2 = new BinaryWriter(fileStream2);
                int          num22         = num8;
                for (int s = 0; s <= num22; s++)
                {
                    int num23 = num9;
                    for (int t = 0; t <= num23; t++)
                    {
                        int num24    = 0;
                        int position = checked ((int)binaryWriter2.BaseStream.Position);
                        try
                        {
                            enumerator = collections[s, t].GetEnumerator();
                            while (enumerator.MoveNext())
                            {
                                ((StaticCell)enumerator.Current).Write(binaryWriter2);
                                num24 = checked (num24 + 7);
                            }
                        }
                        finally
                        {
                            if (enumerator is IDisposable)
                            {
                                ((IDisposable)enumerator).Dispose();
                            }
                        }
                        if (num24 == 0)
                        {
                            position = -1;
                        }
                        binaryWriter1.Write(position);
                        binaryWriter1.Write(num24);
                        binaryWriter1.Write(num16);
                    }
                }
                binaryWriter2.Close();
                binaryWriter1.Close();
                fileStream2.Close();
                fileStream1.Close();
                //this.iLogger.EndTask();
                this.iLogger.LogTimeStamp();
                this.iLogger.LogMessage("Done.");
            }
            else
            {
                this.iLogger.LogMessage("Unable to find Transition Data files in the following path: ");
                this.iLogger.LogMessage(baseDirectory);
            }
        }