public static void Packet_MapData(ref byte[] data) { int x = 0; int y = 0; int i = 0; int mapNum; ByteStream buffer = new ByteStream(Compression.DecompressBytes(data)); C_Variables.MapData = false; ClearMap(); lock (MapLock) { if (buffer.ReadInt32() == 1) { mapNum = buffer.ReadInt32(); Map.Name = buffer.ReadString().Trim(); Map.Music = buffer.ReadString().Trim(); Map.Revision = buffer.ReadInt32(); Map.Moral = (byte)(buffer.ReadInt32()); Map.Tileset = buffer.ReadInt32(); Map.Up = buffer.ReadInt32(); Map.Down = buffer.ReadInt32(); Map.Left = buffer.ReadInt32(); Map.Right = buffer.ReadInt32(); Map.BootMap = buffer.ReadInt32(); Map.BootX = (byte)(buffer.ReadInt32()); Map.BootY = (byte)(buffer.ReadInt32()); Map.MaxX = (byte)(buffer.ReadInt32()); Map.MaxY = (byte)(buffer.ReadInt32()); Map.WeatherType = (byte)(buffer.ReadInt32()); Map.Fogindex = buffer.ReadInt32(); Map.WeatherIntensity = buffer.ReadInt32(); Map.FogAlpha = (byte)(buffer.ReadInt32()); Map.FogSpeed = (byte)(buffer.ReadInt32()); Map.HasMapTint = (byte)(buffer.ReadInt32()); Map.MapTintR = (byte)(buffer.ReadInt32()); Map.MapTintG = (byte)(buffer.ReadInt32()); Map.MapTintB = (byte)(buffer.ReadInt32()); Map.MapTintA = (byte)(buffer.ReadInt32()); Map.Instanced = (byte)(buffer.ReadInt32()); Map.Panorama = (byte)(buffer.ReadInt32()); Map.Parallax = (byte)(buffer.ReadInt32()); Map.Brightness = (byte)(buffer.ReadInt32()); Map.Tile = new Types.TileRec[Map.MaxX + 1, Map.MaxY + 1]; for (x = 1; x <= Constants.MAX_MAP_NPCS; x++) { Map.Npc[x] = buffer.ReadInt32(); } for (x = 0; x <= Map.MaxX; x++) { for (y = 0; y <= Map.MaxY; y++) { Map.Tile[x, y].Data1 = buffer.ReadInt32(); Map.Tile[x, y].Data2 = buffer.ReadInt32(); Map.Tile[x, y].Data3 = buffer.ReadInt32(); Map.Tile[x, y].DirBlock = (byte)(buffer.ReadInt32()); Map.Tile[x, y].Layer = new Types.TileDataRec[(int)Enums.LayerType.Count]; for (i = 0; i <= (int)Enums.LayerType.Count - 1; i++) { Map.Tile[x, y].Layer[i].Tileset = (byte)(buffer.ReadInt32()); Map.Tile[x, y].Layer[i].X = (byte)(buffer.ReadInt32()); Map.Tile[x, y].Layer[i].Y = (byte)(buffer.ReadInt32()); Map.Tile[x, y].Layer[i].AutoTile = (byte)(buffer.ReadInt32()); } Map.Tile[x, y].Type = (byte)(buffer.ReadInt32()); } } //Event Data! C_EventSystem.ResetEventdata(); Map.EventCount = buffer.ReadInt32(); if (Map.EventCount > 0) { Map.Events = new C_EventSystem.EventRec[Map.EventCount + 1]; for (i = 1; i <= Map.EventCount; i++) { ref var with_1 = ref Map.Events[i]; with_1.Name = buffer.ReadString().Trim(); with_1.Globals = buffer.ReadInt32(); with_1.X = buffer.ReadInt32(); with_1.Y = buffer.ReadInt32(); with_1.PageCount = buffer.ReadInt32(); if (Map.Events[i].PageCount > 0) { Map.Events[i].Pages = new C_EventSystem.EventPageRec[Map.Events[i].PageCount + 1]; for (x = 1; x <= Map.Events[i].PageCount; x++) { ref var with_2 = ref Map.Events[i].Pages[x]; with_2.ChkVariable = buffer.ReadInt32(); with_2.Variableindex = buffer.ReadInt32(); with_2.VariableCondition = buffer.ReadInt32(); with_2.VariableCompare = buffer.ReadInt32(); with_2.ChkSwitch = buffer.ReadInt32(); with_2.Switchindex = buffer.ReadInt32(); with_2.SwitchCompare = buffer.ReadInt32(); with_2.ChkHasItem = buffer.ReadInt32(); with_2.HasItemindex = buffer.ReadInt32(); with_2.HasItemAmount = buffer.ReadInt32(); with_2.ChkSelfSwitch = buffer.ReadInt32(); with_2.SelfSwitchindex = buffer.ReadInt32(); with_2.SelfSwitchCompare = buffer.ReadInt32(); with_2.GraphicType = (byte)(buffer.ReadInt32()); with_2.Graphic = buffer.ReadInt32(); with_2.GraphicX = buffer.ReadInt32(); with_2.GraphicY = buffer.ReadInt32(); with_2.GraphicX2 = buffer.ReadInt32(); with_2.GraphicY2 = buffer.ReadInt32(); with_2.MoveType = (byte)(buffer.ReadInt32()); with_2.MoveSpeed = (byte)(buffer.ReadInt32()); with_2.MoveFreq = (byte)(buffer.ReadInt32()); with_2.MoveRouteCount = buffer.ReadInt32(); with_2.IgnoreMoveRoute = buffer.ReadInt32(); with_2.RepeatMoveRoute = buffer.ReadInt32(); if (with_2.MoveRouteCount > 0) { Map.Events[i].Pages[x].MoveRoute = new C_EventSystem.MoveRouteRec[with_2.MoveRouteCount + 1]; for (y = 1; y <= with_2.MoveRouteCount; y++) { with_2.MoveRoute[y].Index = buffer.ReadInt32(); with_2.MoveRoute[y].Data1 = buffer.ReadInt32(); with_2.MoveRoute[y].Data2 = buffer.ReadInt32(); with_2.MoveRoute[y].Data3 = buffer.ReadInt32(); with_2.MoveRoute[y].Data4 = buffer.ReadInt32(); with_2.MoveRoute[y].Data5 = buffer.ReadInt32(); with_2.MoveRoute[y].Data6 = buffer.ReadInt32(); } } with_2.WalkAnim = (byte)(buffer.ReadInt32()); with_2.DirFix = (byte)(buffer.ReadInt32()); with_2.WalkThrough = (byte)(buffer.ReadInt32()); with_2.ShowName = (byte)(buffer.ReadInt32()); with_2.Trigger = (byte)(buffer.ReadInt32()); with_2.CommandListCount = buffer.ReadInt32(); with_2.Position = (byte)(buffer.ReadInt32()); with_2.Questnum = buffer.ReadInt32(); with_2.ChkPlayerGender = buffer.ReadInt32(); if (Map.Events[i].Pages[x].CommandListCount > 0) { Map.Events[i].Pages[x].CommandList = new C_EventSystem.CommandListRec[Map.Events[i].Pages[x].CommandListCount + 1]; for (y = 1; y <= Map.Events[i].Pages[x].CommandListCount; y++) { Map.Events[i].Pages[x].CommandList[y].CommandCount = buffer.ReadInt32(); Map.Events[i].Pages[x].CommandList[y].ParentList = buffer.ReadInt32(); if (Map.Events[i].Pages[x].CommandList[y].CommandCount > 0) { Map.Events[i].Pages[x].CommandList[y].Commands = new C_EventSystem.EventCommandRec[Map.Events[i].Pages[x].CommandList[y].CommandCount + 1]; for (var z = 1; z <= Map.Events[i].Pages[x].CommandList[y].CommandCount; z++) { ref var with_3 = ref Map.Events[i].Pages[x].CommandList[y].Commands[(int)z]; with_3.Index = buffer.ReadInt32(); with_3.Text1 = buffer.ReadString().Trim(); with_3.Text2 = buffer.ReadString().Trim(); with_3.Text3 = buffer.ReadString().Trim(); with_3.Text4 = buffer.ReadString().Trim(); with_3.Text5 = buffer.ReadString().Trim(); with_3.Data1 = buffer.ReadInt32(); with_3.Data2 = buffer.ReadInt32(); with_3.Data3 = buffer.ReadInt32(); with_3.Data4 = buffer.ReadInt32(); with_3.Data5 = buffer.ReadInt32(); with_3.Data6 = buffer.ReadInt32(); with_3.ConditionalBranch.CommandList = buffer.ReadInt32(); with_3.ConditionalBranch.Condition = buffer.ReadInt32(); with_3.ConditionalBranch.Data1 = buffer.ReadInt32(); with_3.ConditionalBranch.Data2 = buffer.ReadInt32(); with_3.ConditionalBranch.Data3 = buffer.ReadInt32(); with_3.ConditionalBranch.ElseCommandList = buffer.ReadInt32(); with_3.MoveRouteCount = buffer.ReadInt32(); if (with_3.MoveRouteCount > 0) { Array.Resize(ref with_3.MoveRoute, with_3.MoveRouteCount + 1); for (var w = 1; w <= with_3.MoveRouteCount; w++) { with_3.MoveRoute[(int)w].Index = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data1 = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data2 = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data3 = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data4 = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data5 = buffer.ReadInt32(); with_3.MoveRoute[(int)w].Data6 = buffer.ReadInt32(); } } } } } } } } } }
public static void UpdateUi() { if (ReloadFrmMain == true) { ReloadFrmMain = false; } if (C_Variables.UpdateNews == true) { FrmMenu.Default.lblNews.Text = C_Variables.News; FrmMenu.Default.Text = C_Constants.GameName; FrmGame.Default.Text = C_Constants.GameName; C_Variables.UpdateNews = false; } if (PnlRegisterVisible != FrmMenu.Default.pnlRegister.Visible) { FrmMenu.Default.pnlRegister.Visible = PnlRegisterVisible; FrmMenu.Default.pnlRegister.BringToFront(); } if (DrawChar == true) { FrmMenu.Default.DrawCharacter(); DrawChar = false; } if (PnlCharCreateVisible != FrmMenu.Default.pnlNewChar.Visible) { FrmMenu.Default.pnlNewChar.Visible = PnlCharCreateVisible; FrmMenu.Default.pnlNewChar.BringToFront(); DrawChar = true; } if (Lblnextcharleft != FrmMenu.Default.lblNextChar.Left) { FrmMenu.Default.lblNextChar.Left = Lblnextcharleft; } if (!ReferenceEquals(Cmbclass, null)) { FrmMenu.Default.cmbClass.Items.Clear(); for (var i = 1; i <= (Cmbclass.Length - 1); i++) { FrmMenu.Default.cmbClass.Items.Add(Cmbclass[(int)i]); } FrmMenu.Default.cmbClass.SelectedIndex = 0; FrmMenu.Default.rdoMale.Checked = true; FrmMenu.Default.txtCharName.Focus(); Cmbclass = null; } if (PnlLoginVisible != FrmMenu.Default.pnlLogin.Visible) { FrmMenu.Default.pnlLogin.Visible = PnlLoginVisible; if (PnlLoginVisible) { FrmMenu.Default.txtLogin.Focus(); } } if (PnlCreditsVisible != FrmMenu.Default.pnlCredits.Visible) { FrmMenu.Default.pnlCredits.Visible = PnlCreditsVisible; } if (Frmmenuvisible != FrmMenu.Default.Visible) { FrmMenu.Default.Visible = Frmmenuvisible; } if (DrawCharSelect) { FrmMenu.Default.DrawCharacterSelect(); DrawCharSelect = false; } if (PnlCharSelectVisible != FrmMenu.Default.pnlCharSelect.Visible) { FrmMenu.Default.pnlCharSelect.Visible = PnlCharSelectVisible; if (PnlCharSelectVisible) { DrawCharSelect = true; } } if (Frmmaingamevisible != FrmGame.Default.Visible) { FrmGame.Default.Visible = Frmmaingamevisible; } if (C_Crafting.InitCrafting == true) { C_Crafting.CraftingInit(); C_Crafting.InitCrafting = false; } if (NeedToOpenShop == true) { C_GameLogic.OpenShop(NeedToOpenShopNum); NeedToOpenShop = false; NeedToOpenShopNum = 0; PnlShopVisible = true; } if (NeedToOpenBank == true) { C_Banks.InBank = System.Convert.ToInt32(true); PnlBankVisible = true; C_Banks.DrawBank(); NeedToOpenBank = false; } if (NeedToOpenTrade == true) { C_Trade.InTrade = true; PnlTradeVisible = true; NeedToOpenTrade = false; } if (NeedtoCloseTrade == true) { C_Trade.InTrade = false; PnlTradeVisible = false; NeedtoCloseTrade = false; } if (NeedtoUpdateTrade == true) { C_Trade.DrawTrade(); NeedtoUpdateTrade = false; } if (UpdateCharacterPanel == true) { UpdateCharacterPanel = false; } if (Pnlloadvisible != FrmMenu.Default.pnlLoad.Visible) { FrmMenu.Default.pnlLoad.Visible = Pnlloadvisible; } if (UpdateMapnames == true) { int x = 0; FrmAdmin.Default.lstMaps.Items.Clear(); for (x = 1; x <= Constants.MAX_MAPS; x++) { FrmAdmin.Default.lstMaps.Items.Add(x.ToString()); FrmAdmin.Default.lstMaps.Items[x - 1].SubItems.Add(C_Types.MapNames[x]); } UpdateMapnames = false; } if (Adminvisible == true) { FrmAdmin.Default.Visible = !FrmAdmin.Default.Visible; Adminvisible = false; } if (C_Quest.UpdateQuestChat == true) { C_Variables.DialogMsg1 = "Quest: " + Microsoft.VisualBasic.Strings.Trim(C_Quest.Quest[C_Quest.QuestNum].Name); C_Variables.DialogMsg2 = C_Quest.QuestMessage; C_Variables.DialogType = C_Constants.DialogueTypeQuest; if (C_Quest.QuestNumForStart > 0 && C_Quest.QuestNumForStart <= C_Quest.MaxQuests) { C_Quest.QuestAcceptTag = C_Quest.QuestNumForStart; } C_Variables.UpdateDialog = true; C_Quest.UpdateQuestChat = false; } if (C_Quest.UpdateQuestWindow == true) { C_Quest.LoadQuestlogBox(); C_Quest.UpdateQuestWindow = false; } if (C_Variables.UpdateDialog == true) { if (C_Variables.DialogType == C_Constants.DialogueTypeBuyhome || C_Variables.DialogType == C_Constants.DialogueTypeVisit) //house offer & visit { C_Variables.DialogButton1Text = "Accept"; C_Variables.DialogButton2Text = "Decline"; DialogPanelVisible = true; } else if (C_Variables.DialogType == C_Constants.DialogueTypeParty || C_Variables.DialogType == C_Constants.DialogueTypeTrade) { C_Variables.DialogButton1Text = "Accept"; C_Variables.DialogButton2Text = "Decline"; DialogPanelVisible = true; } else if (C_Variables.DialogType == C_Constants.DialogueTypeQuest) { C_Variables.DialogButton1Text = "Accept"; C_Variables.DialogButton2Text = "Ok"; if (C_Quest.QuestAcceptTag > 0) { C_Variables.DialogButton2Text = "Decline"; } DialogPanelVisible = true; } C_Variables.UpdateDialog = false; } if (C_EventSystem.EventChat == true) { PnlEventChatVisible = true; C_EventSystem.EventChat = false; } if (C_Variables.ShowRClick == true) { RClickname = C_Types.Player[C_Variables.MyTarget].Name; RClickX = C_Graphics.ConvertMapX(C_Variables.CurX * C_Constants.PicX); RClickY = C_Graphics.ConvertMapY(C_Variables.CurY * C_Constants.PicY); PnlRClickVisible = true; C_Variables.ShowRClick = false; } if (InitMapEditor == true) { FrmEditor_MapEditor.Default.MapEditorInit(); InitMapEditor = false; } if (InitMapProperties == true) { FrmEditor_MapEditor.Default.MapPropertiesInit(); InitMapProperties = false; } if (C_EventSystem.InitEventEditorForm == true) { FrmEditor_Events.Default.InitEventEditorForm(); // populate form // set the tabs if (FrmEditor_Events.Default.tabPages != null && FrmEditor_Events.Default.tabPages.TabPages != null) { FrmEditor_Events.Default.tabPages.TabPages.Clear(); for (var i = 1; i <= C_EventSystem.TmpEvent.PageCount; i++) { FrmEditor_Events.Default.tabPages.TabPages.Add(Conversion.Str(i)); } // items FrmEditor_Events.Default.cmbHasItem.Items.Clear(); FrmEditor_Events.Default.cmbHasItem.Items.Add("None"); for (var i = 1; i <= Constants.MAX_ITEMS; i++) { FrmEditor_Events.Default.cmbHasItem.Items.Add(i + ": " + Microsoft.VisualBasic.Strings.Trim(Types.Item[(int)i].Name)); } // variables FrmEditor_Events.Default.cmbPlayerVar.Items.Clear(); FrmEditor_Events.Default.cmbPlayerVar.Items.Add("None"); for (var i = 1; i <= C_EventSystem.MaxVariables; i++) { FrmEditor_Events.Default.cmbPlayerVar.Items.Add(i + ". " + C_EventSystem.Variables[(int)i]); } // variables FrmEditor_Events.Default.cmbPlayerSwitch.Items.Clear(); FrmEditor_Events.Default.cmbPlayerSwitch.Items.Add("None"); for (var i = 1; i <= C_EventSystem.MaxSwitches; i++) { FrmEditor_Events.Default.cmbPlayerSwitch.Items.Add(i + ". " + C_EventSystem.Switches[(int)i]); } // name FrmEditor_Events.Default.txtName.Text = C_EventSystem.TmpEvent.Name; // enable delete button if (C_EventSystem.TmpEvent.PageCount > 1) { FrmEditor_Events.Default.btnDeletePage.Enabled = true; } else { FrmEditor_Events.Default.btnDeletePage.Enabled = false; } FrmEditor_Events.Default.btnPastePage.Enabled = false; // Load page 1 to start off with C_EventSystem.CurPageNum = 1; C_EventSystem.EventEditorLoadPage(C_EventSystem.CurPageNum); FrmEditor_Events.Default.nudShowTextFace.Maximum = C_Graphics.NumFaces; FrmEditor_Events.Default.nudShowChoicesFace.Maximum = C_Graphics.NumFaces; // show the editor FrmEditor_Events.Default.Show(); C_EventSystem.InitEventEditorForm = false; } } if (OptionsVisible == true) { // show in GUI if (C_Types.Options.Music == 1) { FrmOptions.Default.optMOn.Checked = true; } else { FrmOptions.Default.optMOff.Checked = true; } if (C_Types.Options.Music == 1) { FrmOptions.Default.optSOn.Checked = true; } else { FrmOptions.Default.optSOff.Checked = true; } FrmOptions.Default.lblVolume.Text = "Volume: " + System.Convert.ToString(C_Types.Options.Volume); FrmOptions.Default.scrlVolume.Value = (int)C_Types.Options.Volume; FrmOptions.Default.cmbScreenSize.SelectedIndex = C_Types.Options.ScreenSize; if (C_Types.Options.VSync == 1) { FrmOptions.Default.chkVSync.Checked = true; } else { FrmOptions.Default.chkVSync.Checked = false; } if (C_Types.Options.UnlockFPS == 1) { FrmOptions.Default.checkBox1.Checked = true; } else { FrmOptions.Default.checkBox1.Checked = false; } if (C_Types.Options.ShowNpcBar == 1) { FrmOptions.Default.chkNpcBars.Checked = true; } else { FrmOptions.Default.chkNpcBars.Checked = false; } FrmOptions.Default.Visible = true; OptionsVisible = false; } }