private int GetLevelMoveFromStream(int index) { switch (c) { case vEnum.GameFormat.gen4: a.Position = index * 2; byte[] temp = new byte[2]; a.Read(temp, 0, 2); string temp2 = RemoveEvents.RemoveSpecialCharacter(ByteConverter.bitConvert(BitConverter.ToUInt16(temp, 0))); int sisa = (16 - temp2.Length); for (int i = 0; i < sisa; i++) { temp2 = "0" + temp2; } return((int)Convert.ToInt16(temp2.Substring(0, 7), 2)); case vEnum.GameFormat.gen5: a.Position = index * 4 + 2; byte[] tempa = new byte[2]; a.Read(tempa, 0, 2); return(BitConverter.ToUInt16(tempa, 0)); } return(0); }
private void WriteMapData() { try { int count1 = mvlist.Count; byte[] tempbytenya = new byte[1]; int ukuran = 0; switch (c) { case vEnum.GameFormat.gen4: ukuran = (count1) * 2; bool checktype = false; if (ukuran % 4 != 0) // Menentukan FF FF dimana { ukuran += 2; } else { ukuran += 4; checktype = true; } tempbytenya = new byte[ukuran]; a = new MemoryStream(tempbytenya); for (int i = 0; i < count1; i++) { a.Position = 2 * i; string a11 = RemoveEvents.RemoveSpecialCharacter(ByteConverter.bitConvert(mvlist[i].id)).PadLeft(9, '0'); string a12 = RemoveEvents.RemoveSpecialCharacter(ByteConverter.bitConvert(mvlist[i].level)).PadLeft(7, '0'); byte[] nik = ByteConverter.ToByte(Convert.ToInt16(a12 + a11, 2), 2); a.Write(nik, 0, 2); } a.Position = 2 * count1; byte[] nik3 = ByteConverter.ToByte(65535, 2); a.Write(nik3, 0, 2); if (checktype) { a.Position = 2 * count1 + 2; nik3 = ByteConverter.ToByte(0, 2); a.Write(nik3, 0, 2); } break; case vEnum.GameFormat.gen5: case vEnum.GameFormat.gen6: ukuran = (count1 + 1) * 4; tempbytenya = new byte[ukuran]; a = new MemoryStream(tempbytenya); for (int i = 0; i < count1; i++) { a.Position = 4 * i; byte[] nik = ByteConverter.ToByte(mvlist[i].id, 2); a.Write(nik, 0, 2); a.Position = 4 * i + 2; nik = ByteConverter.ToByte(mvlist[i].level, 2); a.Write(nik, 0, 2); } a.Position = 4 * count1; byte[] nik2 = ByteConverter.ToByte(65535, 2); a.Write(nik2, 0, 2); a.Position = 4 * count1 + 2; nik2 = ByteConverter.ToByte(65535, 2); a.Write(nik2, 0, 2); break; } } catch (Exception ex) { Database.InsertReader.InsertLogs("Error", "Yellow", ex); } }