internal static void Limits_Add(ref LIMIT lim) { int i = 0; int size = 0; int j = 0; //UPGRADE_TODO: (1065) Error handling statement (On Error Goto) could not be converted. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1065 UpgradeHelpers.Helpers.NotUpgradedHelper.NotifyNotUpgradedElement("On Error Goto Label (endsub)"); size = LimitArray.GetUpperBound(0); lim.Az = Convert.ToInt32(lim.Az); i = 0; while (i < size) { if (LimitArray[i].Az > lim.Az) { goto insert; } else { if (LimitArray[i].Az == lim.Az) { LimitArray[i].Alt = lim.Alt; goto endsub; } } i++; } goto Store; insert: int tempForEndVar = i + 1; for (j = size; j >= tempForEndVar; j--) { LimitArray[j] = LimitArray[j - 1]; } Store: LimitArray[i] = lim; LimitArray = ArraysHelper.RedimPreserve(LimitArray, new int[] { size + 2 }); Limits_BuildLimitDef(); endsub :; }
internal static void Limits_DeleteIdx(int idx) { int i = 0; int size = 0; try { if (idx >= 0) { size = LimitArray.GetUpperBound(0); int tempForEndVar = size - 2; for (i = idx; i <= tempForEndVar; i++) { LimitArray[i].Alt = LimitArray[i + 1].Alt; LimitArray[i].Az = LimitArray[i + 1].Az; } LimitArray = ArraysHelper.RedimPreserve(LimitArray, new int[] { size }); Limits_BuildLimitDef(); } } catch { } }
internal static string[] Tokenize(ref string pData) { StringBuilder CurWord = new StringBuilder(); //current token string[] WL = null; //array of tokens string ch = ""; //current character string SepChar = ","; //separation character //make sepchar a comma WL = new string[] { "" }; int Num = -1; //number of tokens pData = pData + SepChar; //add a comma to the end of the string, to // make sure the last word/token is stored int tempForEndVar = Strings.Len(pData); for (int t = 1; t <= tempForEndVar; t++) { ch = pData.Substring(t - 1, Math.Min(1, pData.Length - (t - 1))); if (ch == SepChar) { if (CurWord.ToString() != "") { //save word, start a new one Num++; WL = ArraysHelper.RedimPreserve(WL, new int[] { Num + 1 }); WL[Num] = CurWord.ToString(); //save word to list CurWord = new StringBuilder(""); //reset CurWord to empty string } } else { CurWord.Append(ch); //CH is not a comma, so add it to the //current word... } } return(WL); //returns an array of strings }
internal static void SaveRpgwoMap(string filename) { object mapElements = null; int f = FileSystem.FreeFile(); mSurfaceArray = 0; if (modGlobals.FileExists(filename)) { File.Delete(filename); } FileSystem.FileOpen(f, filename, OpenMode.Binary, OpenAccess.Write, OpenShare.LockWrite, -1); FileSystem.FilePut(f, mMapWidth); FileSystem.FilePut(f, mMapHeight); FileSystem.FilePut(f, mMapVersion); FileSystem.FilePut(f, mSurfaceArray); FileSystem.FilePut(f, mMapExtra); mNumberOfMonsters--; mNumberOfItems--; mv2NumberOfItems--; mv2NumberOfMonsters--; //Get Tile Id //ReDim mMap(1 To mMapWidth, 1 To mMapHeight) //Put #f, , mMap int countSurfaceItems = 1; tempmMapData = ArraysHelper.InitializeArray <mMapDataType>(countSurfaceItems); int MapSizeTotalCount = 0; int tempForEndVar = mMapWidth; for (int x = 1; x <= tempForEndVar; x++) { int tempForEndVar2 = mMapHeight; for (int y = 1; y <= tempForEndVar2; y++) { if (mMap[x - 1, y - 1] != 0) { tempmMapData[tempmMapData.GetUpperBound(0)].Xpos = (short)x; tempmMapData[tempmMapData.GetUpperBound(0)].Ypos = (short)y; tempmMapData[tempmMapData.GetUpperBound(0)].Surface = (short)mMap[x - 1, y - 1]; MapSizeTotalCount++; tempmMapData = ArraysHelper.RedimPreserve(tempmMapData, new int[] { tempmMapData.GetUpperBound(0) + 2 }); } } } tempmMapData = ArraysHelper.RedimPreserve(tempmMapData, new int[] { tempmMapData.GetUpperBound(0) }); if (mSurfaceArray == 1) { FileSystem.FilePut(f, mapElements); FileSystem.FilePut(f, tempmMapData); } else { FileSystem.FilePut(f, mMap); } if (v2Map) { FileSystem.FilePut(f, mv2NumberOfItems); // MsgBox mNumberOfItems //ReDim mItems(1 To mNumberOfItems) if (mv2NumberOfItems > 0) { mItems = ArraysHelper.RedimPreserve(mItems, new int[] { modRpgwoMapFormat.mv2NumberOfItems }); FileSystem.FilePut(f, mItems); } //MsgBox Loc(1) FileSystem.FilePut(f, mv2NumberOfMonsters); //MsgBox mNumberOfMonsters //ReDim mMonsters(1 To mNumberOfMonsters) if (mv2NumberOfMonsters > 0) { mMonsters = ArraysHelper.RedimPreserve(mMonsters, new int[] { modRpgwoMapFormat.mv2NumberOfMonsters }); FileSystem.FilePut(f, mMonsters); } } else { FileSystem.FilePut(f, mNumberOfItems); // MsgBox mNumberOfItems //ReDim mItems(1 To mNumberOfItems) if (mNumberOfItems > 0) { mItems = ArraysHelper.RedimPreserve(mItems, new int[] { modRpgwoMapFormat.mNumberOfItems }); FileSystem.FilePut(f, mItems); } FileSystem.FilePut(f, mNumberOfMonsters); //MsgBox mNumberOfMonsters //ReDim mMonsters(1 To mNumberOfMonsters) if (mNumberOfMonsters > 0) { mMonsters = ArraysHelper.RedimPreserve(mMonsters, new int[] { modRpgwoMapFormat.mNumberOfMonsters }); FileSystem.FilePut(f, mMonsters); } } // MsgBox "notes start:" & Loc(f) short k = 5000; FileSystem.FilePut(f, k); string notes = new string('\0', 5000); notes = StringsHelper.GetFixedLengthString(new String(' ', k), 5000); FileSystem.FilePut(f, notes); //Get Notes FileSystem.FileClose(f); }
private void cmdSelect_Click(Object eventSender, EventArgs eventArgs) { string Filename = ""; CommonDialog1Open.Title = "Select .rsf file"; CommonDialog1Open.Filter = "Script Files (*.rsf)|*.rsf"; CommonDialog1Open.InitialDirectory = Path.GetDirectoryName(Application.ExecutablePath); CommonDialog1Open.ShowDialog(); if (Strings.Len(CommonDialog1Open.FileName) == 0) { return; } Filename = CommonDialog1Open.FileName; string data = ""; modRpgwoMapFormat.mNumberOfItems = 1; modRpgwoMapFormat.mNumberOfMonsters = 1; modRpgwoMapFormat.mv2NumberOfItems = 1; modRpgwoMapFormat.mv2NumberOfMonsters = 1; if (cboVersion.Text == "V1") { modRpgwoMapFormat.v2Map = false; modRpgwoMapFormat.mMapVersion = StringsHelper.GetFixedLengthString("1.0 RPGWO Edit", 30); } else { modRpgwoMapFormat.v2Map = true; modRpgwoMapFormat.mMapVersion = StringsHelper.GetFixedLengthString("2.0 RPGWO Edit", 30); } FileSystem.FileOpen(1, Filename, OpenMode.Input, OpenAccess.Default, OpenShare.Default, -1); string[] DataArray = null; short Xpos = 0; short Ypos = 0; short ImageNumber = 0; int SpawnSeconds = 0; while (!FileSystem.EOF(1)) { data = FileSystem.LineInput(1); if (data.StartsWith("/MAPITEMCLEAR ")) { data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 14), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); modRpgwoMapFormat.mMapHeight = Convert.ToInt16(Double.Parse(DataArray[0])); modRpgwoMapFormat.mMapWidth = Convert.ToInt16(Double.Parse(DataArray[0])); modRpgwoMapFormat.mMap = new short[Convert.ToInt16(Double.Parse(DataArray[0])), Convert.ToInt16(Double.Parse(DataArray[0]))]; // ReDim Map(Right(Data, Len(Data) - 14) + 5, Right(Data, Len(Data) - 14) + 5) // ReDim ItemMap(Right(Data, Len(Data) - 14) + 5, Right(Data, Len(Data) - 14) + 5) // ReDim MonsterMap(Right(Data, Len(Data) - 14) + 5, Right(Data, Len(Data) - 14) + 5) } //Load Items if (data.StartsWith("/ITEMIXY ")) { //Now tokenize the remaining data and break into the parts of image# and x and y position data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 9), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); ImageNumber = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[0]))); Xpos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[1]))); Ypos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[2]))); modRpgwoMapFormat.mItems = ArraysHelper.RedimPreserve(modRpgwoMapFormat.mItems, new int[] { modRpgwoMapFormat.mNumberOfItems + 1 }); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].ItemID = (short)ImageNumber; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Xpos = (short)Xpos; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Ypos = (short)Ypos; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].a = true; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].SpawnTimeout = (float)Math.Floor(Double.Parse(DataArray[3])); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data1 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[4]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data2 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[5]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data3 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[6]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data4 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[7]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data5 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[8]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Reset = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[9]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Writing = StringsHelper.GetFixedLengthString(new String(' ', 200), 200); // mItems(mNumberOfItems).Trigger = Int(DataArray(10)) modRpgwoMapFormat.mNumberOfItems++; modRpgwoMapFormat.mv2NumberOfItems++; } //Spawn items if (data.StartsWith("/ITEMSPAWNIXY ")) { data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 14), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); ImageNumber = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[0]))); Xpos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[1]))); Ypos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[2]))); modRpgwoMapFormat.mItems = ArraysHelper.RedimPreserve(modRpgwoMapFormat.mItems, new int[] { modRpgwoMapFormat.mNumberOfItems + 1 }); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].ItemID = (short)ImageNumber; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Xpos = (short)Xpos; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Ypos = (short)Ypos; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].a = true; modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].SpawnTimeout = (float)Math.Floor(Double.Parse(DataArray[3])); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data1 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[4]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data2 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[5]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data3 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[6]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data4 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[7]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Data5 = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[8]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Trigger = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[8]))); modRpgwoMapFormat.mItems[modRpgwoMapFormat.mNumberOfItems - 1].Uses = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[9]))); modRpgwoMapFormat.mNumberOfItems++; modRpgwoMapFormat.mv2NumberOfItems++; } //Text on item if (data.StartsWith("/ITEMTEXTIXY ")) { data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 13), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); Xpos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[0]))); Ypos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[1]))); //'ItemMap(Xpos, Ypos).ItemText = DataArray(2) } //Surface the ground if (data.StartsWith("/SURFACEIXY ")) { //Now tokenize the remaining data and break into the parts of image# and x and y position data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 12), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); ImageNumber = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[0]))); Xpos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[1]))); Ypos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[2]))); modRpgwoMapFormat.mMap[Xpos - 1, Ypos - 1] = ImageNumber; } //Load Monsters if (data.StartsWith("/MONSTERSPAWNADDXY ")) { data = data.Substring(Math.Max(data.Length - (Strings.Len(data) - 19), 0)); DataArray = (string[])modGlobals.Tokenize(ref data); ImageNumber = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[2]))); Xpos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[0]))); Ypos = Convert.ToInt16(Math.Floor(Double.Parse(DataArray[1]))); SpawnSeconds = Convert.ToInt32(Math.Floor(Double.Parse(DataArray[3]))); modRpgwoMapFormat.mMonsters = ArraysHelper.RedimPreserve(modRpgwoMapFormat.mMonsters, new int[] { modRpgwoMapFormat.mNumberOfMonsters + 1 }); modRpgwoMapFormat.mMonsters[modRpgwoMapFormat.mNumberOfMonsters - 1].Xpos = (short)Xpos; modRpgwoMapFormat.mMonsters[modRpgwoMapFormat.mNumberOfMonsters - 1].Ypos = (short)Ypos; modRpgwoMapFormat.mMonsters[modRpgwoMapFormat.mNumberOfMonsters - 1].MonsterId = (short)ImageNumber; modRpgwoMapFormat.mMonsters[modRpgwoMapFormat.mNumberOfMonsters - 1].Timeout = (short)SpawnSeconds; modRpgwoMapFormat.mMonsters[modRpgwoMapFormat.mNumberOfMonsters - 1].a = true; modRpgwoMapFormat.mNumberOfMonsters++; modRpgwoMapFormat.mv2NumberOfMonsters++; //MonsterMap(Xpos, Ypos).ImageNumber = ImageNumber //MonsterMap(Xpos, Ypos).MonsterArrayID = GetMonsterArrayId(ImageNumber) //MonsterMap(Xpos, Ypos).MonsterId = Monsters(MonsterMap(Xpos, Ypos).MonsterArrayID).MonsterId 'ImageNumber //MonsterMap(Xpos, Ypos).Life = Monsters(MonsterMap(Xpos, Ypos).MonsterArrayID).Life //MonsterMap(Xpos, Ypos).Stamina = Monsters(MonsterMap(Xpos, Ypos).MonsterArrayID).Stamina //MonsterMap(Xpos, Ypos).Mana = Monsters(MonsterMap(Xpos, Ypos).MonsterArrayID).Mana //MonsterMap(Xpos, Ypos).SpawnSeconds = SpawnSeconds //MonsterMap(Xpos, Ypos).OldX = Xpos //MonsterMap(Xpos, Ypos).OldY = Ypos //MonsterMap(Xpos, Ypos).OldMonsterArrayID = MonsterMap(Xpos, Ypos).MonsterArrayID //MonsterMap(Xpos, Ypos).ImageType = Monsters(MonsterMap(Xpos, Ypos).MonsterArrayID).ImageType } } ; FileSystem.FileClose(1); //save the file if (modRpgwoMapFormat.v2Map) { modRpgwoMapFormat.SaveRpgwoMap(Filename + "v2-3.map"); } else { modRpgwoMapFormat.SaveRpgwoMap(Filename + "v1.map"); } //End of rsf file MessageBox.Show("Done!", AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); }
internal static void Limits_ReadFile(string FileName) { object[, , , , ] aa_hadec = null; object HC = null; int pos = 0; int size = 0; int redimcount = 0; string temp1 = ""; string temp2 = ""; double ha = 0; double DEC = 0; LimitArray = ArraysHelper.InitializeArray <LIMIT>(1); try { if (FileName != "") { FileSystem.FileClose(1); FileSystem.FileOpen(1, FileName, OpenMode.Input, OpenAccess.Default, OpenShare.Default, -1); LimitArray = ArraysHelper.InitializeArray <LIMIT>(101); size = 0; redimcount = 0; while (!FileSystem.EOF(1)) { temp1 = FileSystem.LineInput(1); temp2 = temp1.Substring(0, Math.Min(1, temp1.Length)); if (temp2 != "#" && temp2 != " ") { pos = (temp1.IndexOf(' ') + 1); if (pos != 0) { temp2 = temp1.Substring(0, Math.Min(pos - 1, temp1.Length)); temp1 = temp1.Substring(Math.Max(temp1.Length - (Strings.Len(temp1) - pos), 0)); LimitArray[size].Az = Double.Parse(temp2); LimitArray[size].Alt = Double.Parse(temp1); object tempAuxVar = aa_hadec[Convert.ToInt32(EQMath.gLatitude * EQMath.DEG_RAD), Convert.ToInt32(LimitArray[size].Alt * EQMath.DEG_RAD), Convert.ToInt32(LimitArray[size].Az * EQMath.DEG_RAD), Convert.ToInt32(ha), Convert.ToInt32(DEC)]; LimitArray[size].ha = EQMath.Range24(ha * EQMath.RAD_HRS); LimitArray[size].DEC = DEC * EQMath.RAD_DEG; size++; redimcount++; if (redimcount > 90) { redimcount = 0; LimitArray = ArraysHelper.RedimPreserve(LimitArray, new int[] { size + 101 }); } } } } LimitArray = ArraysHelper.RedimPreserve(LimitArray, new int[] { size + 1 }); } Limits_BuildLimitDef(); } catch { //UPGRADE_TODO: (1067) Member Add_Message is not defined in type Variant. More Information: https://www.mobilize.net/vbtonet/ewis/ewi1067 HC.Add_Message("Error reading limits file"); } finally { FileSystem.FileClose(1); } }