mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-08-01 23:53:39 -05:00
For fuck's sake mysql
Workaround LAST_INSERT_ID and CAST limitations by making all primary keys unsigned bigint. Workaround LAST_INSERT_ID signed/unsigned inconsistency between 5.5 and 5.6 by using Convert.ToUInt64 instead of casts.
This commit is contained in:
parent
eac2ac6e21
commit
4198aace33
|
|
@ -84,7 +84,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
byte[] boxData = new byte[0x21c];
|
||||
Array.Copy(data, 0x144, boxData, 0, 0x21c);
|
||||
BoxRecord4 record = new BoxRecord4(pid, label, 0, boxData);
|
||||
long serial = DataAbstract.Instance.BoxUpload4(record);
|
||||
ulong serial = DataAbstract.Instance.BoxUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
|
|
@ -140,7 +140,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
byte[] dressupData = new byte[0xe0];
|
||||
Array.Copy(data, 0x140, dressupData, 0, 0xe0);
|
||||
DressupRecord4 record = new DressupRecord4(pid, 0, dressupData);
|
||||
long serial = DataAbstract.Instance.DressupUpload4(record);
|
||||
ulong serial = DataAbstract.Instance.DressupUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
|
|
@ -194,7 +194,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
byte[] battlevidData = new byte[0x1d4c];
|
||||
Array.Copy(data, 0x140, battlevidData, 0, 0x1d4c);
|
||||
BattleVideoRecord4 record = new BattleVideoRecord4(pid, 0, battlevidData);
|
||||
long serial = DataAbstract.Instance.BattleVideoUpload4(record);
|
||||
ulong serial = DataAbstract.Instance.BattleVideoUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
|
|
@ -262,7 +262,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
break;
|
||||
}
|
||||
|
||||
long serial = BitConverter.ToInt64(data, 0x140);
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
BattleVideoRecord4 record = DataAbstract.Instance.BattleVideoGet4(serial, true);
|
||||
if (record == null)
|
||||
{
|
||||
|
|
@ -292,6 +292,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
{
|
||||
logEntry.AppendFormat("Unhandled exception while handling request.\nException: {0}", ex.ToString());
|
||||
logEntry.AppendLine();
|
||||
type = EventLogEntryType.Error;
|
||||
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
byte[] musicalData = new byte[0x230];
|
||||
Array.Copy(data, 0x140, musicalData, 0, 0x230);
|
||||
MusicalRecord5 record = new MusicalRecord5(pid, 0, musicalData);
|
||||
long serial = DataAbstract.Instance.MusicalUpload5(record);
|
||||
ulong serial = DataAbstract.Instance.MusicalUpload5(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
Array.Copy(data, 0x19e8, vldtSignature, 0, sigLength);
|
||||
// todo: validate signature.
|
||||
|
||||
long serial = DataAbstract.Instance.BattleVideoUpload5(record);
|
||||
ulong serial = DataAbstract.Instance.BattleVideoUpload5(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
|
|
@ -223,7 +223,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
|||
break;
|
||||
}
|
||||
|
||||
long serial = BitConverter.ToInt64(data, 0x140);
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
BattleVideoRecord5 record = DataAbstract.Instance.BattleVideoGet5(serial, true);
|
||||
if (record == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace bvRestorer4
|
|||
}
|
||||
|
||||
int pid = BitConverter.ToInt32(data, 0x08);
|
||||
long serial = BitConverter.ToInt64(data, 0x0c);
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x0c);
|
||||
byte[] mainData = new byte[0x1d4c];
|
||||
Array.Copy(data, 0x14, mainData, 0, 0x1d4c);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace bvRestorer5
|
|||
}
|
||||
|
||||
int pid = BitConverter.ToInt32(data, 0x08);
|
||||
long serial = BitConverter.ToInt64(data, 0x0c);
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x0c);
|
||||
byte[] mainData = new byte[0x18a4];
|
||||
Array.Copy(data, 0x14, mainData, 0, 0x18a4);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace PkmnFoundations.GTS.admin
|
|||
{
|
||||
int pid = BitConverter.ToInt32(data, 12 + 556 * x);
|
||||
BoxLabels4 label = (BoxLabels4)BitConverter.ToInt32(data, 16 + 556 * x);
|
||||
long serial = BitConverter.ToInt64(data, 20 + 556 * x);
|
||||
ulong serial = BitConverter.ToUInt64(data, 20 + 556 * x);
|
||||
if (serial == 0) continue;
|
||||
|
||||
byte[] result = new byte[540];
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace PkmnFoundations.GTS.test
|
|||
for (int x = 0; x < results; x++)
|
||||
{
|
||||
int pid = BitConverter.ToInt32(data, 12 + 236 * x);
|
||||
long serial = BitConverter.ToInt64(data, 16 + 236 * x);
|
||||
ulong serial = BitConverter.ToUInt64(data, 16 + 236 * x);
|
||||
if (serial == 0) continue;
|
||||
|
||||
byte[] result = new byte[224];
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace PkmnFoundations.GTS.admin
|
|||
for (int x = 0; x < results; x++)
|
||||
{
|
||||
int pid = BitConverter.ToInt32(data, 12 + 572 * x);
|
||||
long serial = BitConverter.ToInt64(data, 16 + 572 * x);
|
||||
ulong serial = BitConverter.ToUInt64(data, 16 + 572 * x);
|
||||
if (serial == 0) continue;
|
||||
|
||||
byte[] result = new byte[560];
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ namespace PkmnFoundations.GTS.test
|
|||
|
||||
protected void btnToSerial_Click(object sender, EventArgs e)
|
||||
{
|
||||
long valueNumeric = Convert.ToInt64(txtBattleVideo.Text.Replace("-", ""));
|
||||
ulong valueNumeric = Convert.ToUInt64(txtBattleVideo.Text.Replace("-", ""));
|
||||
txtSerial.Text = BattleVideoHeader4.SerialToKey(valueNumeric).ToString();
|
||||
}
|
||||
|
||||
protected void btnToVideo_Click(object sender, EventArgs e)
|
||||
{
|
||||
long valueNumeric = Convert.ToInt64(txtSerial.Text.Replace("-", ""));
|
||||
ulong valueNumeric = Convert.ToUInt64(txtSerial.Text.Replace("-", ""));
|
||||
txtBattleVideo.Text = BattleVideoHeader4.KeyToSerial(valueNumeric).ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,27 +95,27 @@ namespace PkmnFoundations.Data
|
|||
public const int BOX_VERSION_4 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_4 = 1;
|
||||
|
||||
public abstract long DressupUpload4(DressupRecord4 record);
|
||||
public abstract ulong DressupUpload4(DressupRecord4 record);
|
||||
public abstract DressupRecord4[] DressupSearch4(ushort species, int count);
|
||||
|
||||
public abstract long BoxUpload4(BoxRecord4 record);
|
||||
public abstract ulong BoxUpload4(BoxRecord4 record);
|
||||
public abstract BoxRecord4[] BoxSearch4(BoxLabels4 label, int count);
|
||||
|
||||
public abstract long BattleVideoUpload4(BattleVideoRecord4 record);
|
||||
public abstract ulong BattleVideoUpload4(BattleVideoRecord4 record);
|
||||
public abstract BattleVideoHeader4[] BattleVideoSearch4(ushort species, BattleVideoRankings4 ranking, BattleVideoMetagames4 metagame, byte country, byte region, int count);
|
||||
public abstract BattleVideoRecord4 BattleVideoGet4(long serial, bool incrementViews = false);
|
||||
public abstract BattleVideoRecord4 BattleVideoGet4(ulong serial, bool incrementViews = false);
|
||||
#endregion
|
||||
|
||||
#region Global Terminal 5
|
||||
public const int MUSICAL_VERSION_5 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_5 = 1;
|
||||
|
||||
public abstract long MusicalUpload5(MusicalRecord5 record);
|
||||
public abstract ulong MusicalUpload5(MusicalRecord5 record);
|
||||
public abstract MusicalRecord5[] MusicalSearch5(ushort species, int count);
|
||||
|
||||
public abstract long BattleVideoUpload5(BattleVideoRecord5 record);
|
||||
public abstract ulong BattleVideoUpload5(BattleVideoRecord5 record);
|
||||
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 ranking, BattleVideoMetagames5 metagame, byte country, byte region, int count);
|
||||
public abstract BattleVideoRecord5 BattleVideoGet5(long serial, bool incrementViews = false);
|
||||
public abstract BattleVideoRecord5 BattleVideoGet5(ulong serial, bool incrementViews = false);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -901,7 +901,7 @@ namespace PkmnFoundations.Data
|
|||
#endregion
|
||||
|
||||
#region Global Terminal 4
|
||||
public override long DressupUpload4(DressupRecord4 record)
|
||||
public override ulong DressupUpload4(DressupRecord4 record)
|
||||
{
|
||||
if (record.Data.Length != 224) throw new ArgumentException("Dressup data must be 224 bytes.");
|
||||
using (MySqlConnection db = CreateConnection())
|
||||
|
|
@ -914,12 +914,12 @@ namespace PkmnFoundations.Data
|
|||
|
||||
if (record.SerialNumber == 0)
|
||||
{
|
||||
long serial = (long)tran.ExecuteScalar("INSERT INTO TerminalDressup4 (pid, " +
|
||||
ulong serial = Convert.ToUInt64(tran.ExecuteScalar("INSERT INTO TerminalDressup4 (pid, " +
|
||||
"Data, md5, TimeAdded, ParseVersion, Species) VALUES (@pid, @data, " +
|
||||
"unhex(md5(@data)), UTC_TIMESTAMP(), 1, @species); SELECT LAST_INSERT_ID()",
|
||||
new MySqlParameter("@pid", record.PID),
|
||||
new MySqlParameter("@data", record.Data),
|
||||
new MySqlParameter("@species", record.Species));
|
||||
new MySqlParameter("@species", record.Species)));
|
||||
tran.Commit();
|
||||
return serial;
|
||||
}
|
||||
|
|
@ -968,10 +968,10 @@ namespace PkmnFoundations.Data
|
|||
byte[] data = new byte[224];
|
||||
reader.GetBytes(2, 0, data, 0, 224);
|
||||
|
||||
return new DressupRecord4(reader.GetInt32(0), reader.GetInt64(1), data);
|
||||
return new DressupRecord4(reader.GetInt32(0), reader.GetUInt64(1), data);
|
||||
}
|
||||
|
||||
public override long BoxUpload4(BoxRecord4 record)
|
||||
public override ulong BoxUpload4(BoxRecord4 record)
|
||||
{
|
||||
if (record.Data.Length != 540) throw new ArgumentException("Box data must be 540 bytes.");
|
||||
using (MySqlConnection db = CreateConnection())
|
||||
|
|
@ -984,12 +984,12 @@ namespace PkmnFoundations.Data
|
|||
|
||||
if (record.SerialNumber == 0)
|
||||
{
|
||||
long serial = (long)tran.ExecuteScalar("INSERT INTO TerminalBoxes4 (pid, " +
|
||||
ulong serial = Convert.ToUInt64(tran.ExecuteScalar("INSERT INTO TerminalBoxes4 (pid, " +
|
||||
"Data, md5, TimeAdded, ParseVersion, Label) VALUES (@pid, @data, " +
|
||||
"unhex(md5(@data)), UTC_TIMESTAMP(), 1, @label); SELECT LAST_INSERT_ID()",
|
||||
new MySqlParameter("@pid", record.PID),
|
||||
new MySqlParameter("@data", record.Data),
|
||||
new MySqlParameter("@label", (int)record.Label));
|
||||
new MySqlParameter("@label", (int)record.Label)));
|
||||
tran.Commit();
|
||||
return serial;
|
||||
}
|
||||
|
|
@ -1038,10 +1038,10 @@ namespace PkmnFoundations.Data
|
|||
byte[] data = new byte[540];
|
||||
reader.GetBytes(3, 0, data, 0, 540);
|
||||
|
||||
return new BoxRecord4(reader.GetInt32(0), (BoxLabels4)reader.GetInt32(1), reader.GetInt64(2), data);
|
||||
return new BoxRecord4(reader.GetInt32(0), (BoxLabels4)reader.GetInt32(1), reader.GetUInt64(2), data);
|
||||
}
|
||||
|
||||
public override long BattleVideoUpload4(BattleVideoRecord4 record)
|
||||
public override ulong BattleVideoUpload4(BattleVideoRecord4 record)
|
||||
{
|
||||
if (record.Data.Length != 7272) throw new ArgumentException();
|
||||
if (record.Header.Data.Length != 228) throw new ArgumentException();
|
||||
|
|
@ -1060,7 +1060,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
if (record.SerialNumber == 0)
|
||||
{
|
||||
long key = (long)tran.ExecuteScalar("INSERT INTO TerminalBattleVideos4 " +
|
||||
ulong key = Convert.ToUInt64(tran.ExecuteScalar("INSERT INTO TerminalBattleVideos4 " +
|
||||
"(pid, Header, Data, md5, TimeAdded, ParseVersion, Streak, TrainerName, " +
|
||||
"Metagame, Country, Region) " +
|
||||
"VALUES (@pid, @header, @data, unhex(md5(CONCAT(@header, @data))), " +
|
||||
|
|
@ -1074,8 +1074,8 @@ namespace PkmnFoundations.Data
|
|||
new MySqlParameter("@metagame", (byte)record.Header.Metagame),
|
||||
new MySqlParameter("@country", (byte)record.Header.Country),
|
||||
new MySqlParameter("@region", (byte)record.Header.Region)
|
||||
);
|
||||
long serial = BattleVideoHeader4.KeyToSerial((long)key);
|
||||
));
|
||||
ulong serial = BattleVideoHeader4.KeyToSerial(key);
|
||||
|
||||
tran.ExecuteNonQuery("UPDATE TerminalBattleVideos4 SET " +
|
||||
"SerialNumber = @serial WHERE id = @key",
|
||||
|
|
@ -1090,7 +1090,7 @@ namespace PkmnFoundations.Data
|
|||
}
|
||||
else
|
||||
{
|
||||
ulong key = (ulong)BattleVideoHeader4.SerialToKey(record.SerialNumber);
|
||||
ulong key = BattleVideoHeader4.SerialToKey(record.SerialNumber);
|
||||
|
||||
int rows = tran.ExecuteNonQuery("INSERT INTO TerminalBattleVideos4 " +
|
||||
"(id, pid, SerialNumber, Header, Data, md5, TimeAdded, " +
|
||||
|
|
@ -1239,10 +1239,10 @@ namespace PkmnFoundations.Data
|
|||
byte[] data = new byte[228];
|
||||
reader.GetBytes(2, 0, data, 0, 228);
|
||||
|
||||
return new BattleVideoHeader4(reader.GetInt32(0), reader.GetInt64(1), data);
|
||||
return new BattleVideoHeader4(reader.GetInt32(0), reader.GetUInt64(1), data);
|
||||
}
|
||||
|
||||
public override BattleVideoRecord4 BattleVideoGet4(long serial, bool incrementViews = false)
|
||||
public override BattleVideoRecord4 BattleVideoGet4(ulong serial, bool incrementViews = false)
|
||||
{
|
||||
String update = incrementViews ? "UPDATE TerminalBattleVideos4 " +
|
||||
"SET Views = Views + 1 WHERE SerialNumber = @serial; "
|
||||
|
|
@ -1273,7 +1273,7 @@ namespace PkmnFoundations.Data
|
|||
#endregion
|
||||
|
||||
#region Global Terminal 5
|
||||
public override long MusicalUpload5(MusicalRecord5 record)
|
||||
public override ulong MusicalUpload5(MusicalRecord5 record)
|
||||
{
|
||||
if (record.Data.Length != 560) throw new ArgumentException();
|
||||
|
||||
|
|
@ -1290,14 +1290,14 @@ namespace PkmnFoundations.Data
|
|||
|
||||
if (record.SerialNumber == 0)
|
||||
{
|
||||
long serial = (long)tran.ExecuteScalar("INSERT INTO TerminalMusicals5 " +
|
||||
ulong serial = Convert.ToUInt64(tran.ExecuteScalar("INSERT INTO TerminalMusicals5 " +
|
||||
"(pid, Data, md5, TimeAdded, ParseVersion) " +
|
||||
"VALUES (@pid, @data, unhex(md5(@data)), " +
|
||||
"UTC_TIMESTAMP(), 1); " +
|
||||
"SELECT LAST_INSERT_ID()",
|
||||
new MySqlParameter("@pid", record.PID),
|
||||
new MySqlParameter("@data", record.Data)
|
||||
);
|
||||
));
|
||||
|
||||
// todo: make a proc to insert both musical and party.
|
||||
InsertMusicalParticipants5(record, serial, tran);
|
||||
|
|
@ -1327,7 +1327,7 @@ namespace PkmnFoundations.Data
|
|||
}
|
||||
}
|
||||
|
||||
private void InsertMusicalParticipants5(MusicalRecord5 record, long SerialNumber, MySqlTransaction tran)
|
||||
private void InsertMusicalParticipants5(MusicalRecord5 record, ulong SerialNumber, MySqlTransaction tran)
|
||||
{
|
||||
MySqlCommand cmd = new MySqlCommand("INSERT INTO " +
|
||||
"TerminalMusicalPokemon5 (musical_id, Slot, Species) VALUES " +
|
||||
|
|
@ -1377,10 +1377,10 @@ namespace PkmnFoundations.Data
|
|||
byte[] data = new byte[560];
|
||||
reader.GetBytes(2, 0, data, 0, 560);
|
||||
|
||||
return new MusicalRecord5(reader.GetInt32(0), reader.GetInt64(1), data);
|
||||
return new MusicalRecord5(reader.GetInt32(0), reader.GetUInt64(1), data);
|
||||
}
|
||||
|
||||
public override long BattleVideoUpload5(BattleVideoRecord5 record)
|
||||
public override ulong BattleVideoUpload5(BattleVideoRecord5 record)
|
||||
{
|
||||
if (record.Data.Length != 6112) throw new ArgumentException();
|
||||
if (record.Header.Data.Length != 196) throw new ArgumentException();
|
||||
|
|
@ -1399,7 +1399,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
if (record.SerialNumber == 0)
|
||||
{
|
||||
long key = (long)tran.ExecuteScalar("INSERT INTO TerminalBattleVideos5 " +
|
||||
ulong key = Convert.ToUInt64(tran.ExecuteScalar("INSERT INTO TerminalBattleVideos5 " +
|
||||
"(pid, Header, Data, md5, TimeAdded, ParseVersion, Streak, TrainerName, " +
|
||||
"Metagame, Country, Region) " +
|
||||
"VALUES (@pid, @header, @data, unhex(md5(CONCAT(@header, @data))), " +
|
||||
|
|
@ -1413,8 +1413,8 @@ namespace PkmnFoundations.Data
|
|||
new MySqlParameter("@metagame", (byte)record.Header.Metagame),
|
||||
new MySqlParameter("@country", (byte)record.Header.Country),
|
||||
new MySqlParameter("@region", (byte)record.Header.Region)
|
||||
);
|
||||
long serial = BattleVideoHeader4.KeyToSerial((long)key);
|
||||
));
|
||||
ulong serial = BattleVideoHeader4.KeyToSerial(key);
|
||||
|
||||
tran.ExecuteNonQuery("UPDATE TerminalBattleVideos5 SET " +
|
||||
"SerialNumber = @serial WHERE id = @key",
|
||||
|
|
@ -1589,10 +1589,10 @@ namespace PkmnFoundations.Data
|
|||
byte[] data = new byte[196];
|
||||
reader.GetBytes(2, 0, data, 0, 196);
|
||||
|
||||
return new BattleVideoHeader5(reader.GetInt32(0), reader.GetInt64(1), data);
|
||||
return new BattleVideoHeader5(reader.GetInt32(0), reader.GetUInt64(1), data);
|
||||
}
|
||||
|
||||
public override BattleVideoRecord5 BattleVideoGet5(long serial, bool incrementViews = false)
|
||||
public override BattleVideoRecord5 BattleVideoGet5(ulong serial, bool incrementViews = false)
|
||||
{
|
||||
String update = incrementViews ? "UPDATE TerminalBattleVideos5 " +
|
||||
"SET Views = Views + 1 WHERE SerialNumber = @serial; "
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public BattleVideoHeader4(int pid, long serial_number, byte[] data)
|
||||
public BattleVideoHeader4(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 228) throw new ArgumentException("Battle video header data must be 228 bytes.");
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
// todo: encapsulate these so calculated fields are always correct
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public byte[] Data;
|
||||
|
||||
public ushort Streak
|
||||
|
|
@ -144,7 +144,7 @@ namespace PkmnFoundations.Structures
|
|||
/// <summary>
|
||||
/// Converts a primary key (auto incrementing) into a Battle Video ID.
|
||||
/// </summary>
|
||||
public static long KeyToSerial(long key)
|
||||
public static ulong KeyToSerial(ulong key)
|
||||
{
|
||||
if (key > 899999999999L || key < 0L) throw new ArgumentOutOfRangeException();
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ namespace PkmnFoundations.Structures
|
|||
/// <summary>
|
||||
/// Converts Battle Video ID back into a primary key.
|
||||
/// </summary>
|
||||
public static long SerialToKey(long serial)
|
||||
public static ulong SerialToKey(ulong serial)
|
||||
{
|
||||
if (serial > 999999999999L || serial < 100000000000L)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
|
@ -220,7 +220,7 @@ namespace PkmnFoundations.Structures
|
|||
return DigitsToLong(serialDigits);
|
||||
}
|
||||
|
||||
private static byte[] LongToDigits(long value)
|
||||
private static byte[] LongToDigits(ulong value)
|
||||
{
|
||||
if (value > 999999999999L || value < 0L) throw new ArgumentException();
|
||||
byte[] result = new byte[12];
|
||||
|
|
@ -232,11 +232,11 @@ namespace PkmnFoundations.Structures
|
|||
return result;
|
||||
}
|
||||
|
||||
private static long DigitsToLong(byte[] digits)
|
||||
private static ulong DigitsToLong(byte[] digits)
|
||||
{
|
||||
if (digits.Length != 12) throw new ArgumentException();
|
||||
long result = 0;
|
||||
long pow = 1;
|
||||
ulong result = 0;
|
||||
ulong pow = 1;
|
||||
for (int x = 11; x >= 0; x--)
|
||||
{
|
||||
if (digits[x] > 9) throw new ArgumentException();
|
||||
|
|
@ -248,7 +248,7 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
#endregion
|
||||
|
||||
public static String FormatSerial(long serial)
|
||||
public static String FormatSerial(ulong serial)
|
||||
{
|
||||
String number = serial.ToString("D12");
|
||||
String[] split = new String[3];
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public BattleVideoHeader5(int pid, long serial_number, byte[] data)
|
||||
public BattleVideoHeader5(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 196) throw new ArgumentException("Battle video header data must be 196 bytes.");
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
// todo: encapsulate these so calculated fields are always correct
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public byte[] Data;
|
||||
|
||||
public ushort Streak
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public BattleVideoRecord4(int pid, long serial_number, byte[] data)
|
||||
public BattleVideoRecord4(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 7500) throw new ArgumentException("Battle video data must be 7500 bytes.");
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ namespace PkmnFoundations.Structures
|
|||
Data = data_main;
|
||||
}
|
||||
|
||||
public BattleVideoRecord4(int pid, long serial_number, BattleVideoHeader4 header, byte[] data_main)
|
||||
public BattleVideoRecord4(int pid, ulong serial_number, BattleVideoHeader4 header, byte[] data_main)
|
||||
{
|
||||
if (data_main.Length != 7272) throw new ArgumentException("Battle video main data must be 7272 bytes.");
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace PkmnFoundations.Structures
|
|||
}
|
||||
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public BattleVideoHeader4 Header;
|
||||
public byte[] Data;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public BattleVideoRecord5(int pid, long serial_number, byte[] data)
|
||||
public BattleVideoRecord5(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 6308) throw new ArgumentException("Battle video data must be 6308 bytes.");
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ namespace PkmnFoundations.Structures
|
|||
Data = data_main;
|
||||
}
|
||||
|
||||
public BattleVideoRecord5(int pid, long serial_number, BattleVideoHeader5 header, byte[] data_main)
|
||||
public BattleVideoRecord5(int pid, ulong serial_number, BattleVideoHeader5 header, byte[] data_main)
|
||||
{
|
||||
if (data_main.Length != 6112) throw new ArgumentException("Battle video main data must be 6112 bytes.");
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace PkmnFoundations.Structures
|
|||
}
|
||||
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public BattleVideoHeader5 Header;
|
||||
public byte[] Data;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public BoxRecord4(int pid, BoxLabels4 label, long serial_number, byte[] data)
|
||||
public BoxRecord4(int pid, BoxLabels4 label, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 540) throw new ArgumentException("Box data must be 540 bytes.");
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ namespace PkmnFoundations.Structures
|
|||
// todo: encapsulate these so calculated fields are always correct
|
||||
public int PID;
|
||||
public BoxLabels4 Label;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public byte[] Data;
|
||||
|
||||
public BoxRecord4 Clone()
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public DressupRecord4(int pid, long serial_number, byte[] data)
|
||||
public DressupRecord4(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 224) throw new ArgumentException("Dressup data must be 224 bytes.");
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
// todo: encapsulate these so calculated fields are always correct
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
public byte[] Data;
|
||||
|
||||
public ushort Species
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
}
|
||||
|
||||
public MusicalRecord5(int pid, long serial_number, byte[] data)
|
||||
public MusicalRecord5(int pid, ulong serial_number, byte[] data)
|
||||
{
|
||||
if (data.Length != 560) throw new ArgumentException("Musical data must be 560 bytes.");
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ namespace PkmnFoundations.Structures
|
|||
|
||||
// todo: encapsulate these so calculated fields are always correct
|
||||
public int PID;
|
||||
public long SerialNumber;
|
||||
public ulong SerialNumber;
|
||||
|
||||
private byte[] m_data;
|
||||
public byte[] Data
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#
|
||||
# Host: 127.0.0.1 (MySQL 5.5.27)
|
||||
# Database: gts
|
||||
# Generation Time: 2014-07-17 15:50:48 +0000
|
||||
# Generation Time: 2014-07-22 15:58:36 +0000
|
||||
# ************************************************************
|
||||
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ CREATE TABLE `FoundationsTypes` (
|
|||
DROP TABLE IF EXISTS `GtsHistory4`;
|
||||
|
||||
CREATE TABLE `GtsHistory4` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`Species` smallint(5) unsigned NOT NULL,
|
||||
`Gender` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -230,7 +230,7 @@ CREATE TABLE `GtsHistory4` (
|
|||
`TimeDeposited` datetime DEFAULT NULL,
|
||||
`TimeExchanged` datetime DEFAULT NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TrainerOT` smallint(5) unsigned NOT NULL,
|
||||
`TrainerCountry` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerRegion` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -255,7 +255,7 @@ CREATE TABLE `GtsHistory4` (
|
|||
DROP TABLE IF EXISTS `GtsHistory5`;
|
||||
|
||||
CREATE TABLE `GtsHistory5` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`Unknown0` blob NOT NULL,
|
||||
`Species` smallint(5) unsigned NOT NULL,
|
||||
|
|
@ -272,7 +272,7 @@ CREATE TABLE `GtsHistory5` (
|
|||
`TimeExchanged` datetime DEFAULT NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`TrainerOT` int(11) unsigned NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TrainerCountry` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerRegion` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerClass` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -298,7 +298,7 @@ CREATE TABLE `GtsHistory5` (
|
|||
DROP TABLE IF EXISTS `GtsPokemon4`;
|
||||
|
||||
CREATE TABLE `GtsPokemon4` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`Species` smallint(5) unsigned NOT NULL,
|
||||
`Gender` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -313,7 +313,7 @@ CREATE TABLE `GtsPokemon4` (
|
|||
`TimeDeposited` datetime DEFAULT NULL,
|
||||
`TimeExchanged` datetime DEFAULT NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TrainerOT` smallint(5) unsigned NOT NULL,
|
||||
`TrainerCountry` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerRegion` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -337,7 +337,7 @@ CREATE TABLE `GtsPokemon4` (
|
|||
DROP TABLE IF EXISTS `GtsPokemon5`;
|
||||
|
||||
CREATE TABLE `GtsPokemon5` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`Unknown0` blob NOT NULL,
|
||||
`Species` smallint(5) unsigned NOT NULL,
|
||||
|
|
@ -354,7 +354,7 @@ CREATE TABLE `GtsPokemon5` (
|
|||
`TimeExchanged` datetime DEFAULT NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`TrainerOT` int(11) unsigned NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TrainerCountry` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerRegion` tinyint(3) unsigned NOT NULL,
|
||||
`TrainerClass` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -379,20 +379,18 @@ CREATE TABLE `GtsPokemon5` (
|
|||
DROP TABLE IF EXISTS `GtsProfiles4`;
|
||||
|
||||
CREATE TABLE `GtsProfiles4` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) NOT NULL,
|
||||
`Data` blob NOT NULL,
|
||||
`Version` tinyint(3) unsigned NOT NULL,
|
||||
`Language` tinyint(3) unsigned NOT NULL,
|
||||
`Country` tinyint(3) unsigned NOT NULL,
|
||||
`Region` tinyint(3) unsigned NOT NULL,
|
||||
`OT` int(11) unsigned NOT NULL,
|
||||
`Name` blob NOT NULL,
|
||||
`ParseVersion` int(11) unsigned NOT NULL,
|
||||
`OT` int(10) unsigned NOT NULL,
|
||||
`Name` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`ParseVersion` int(10) unsigned NOT NULL,
|
||||
`TimeAdded` datetime DEFAULT NULL,
|
||||
`TimeUpdated` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`)
|
||||
PRIMARY KEY (`pid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
@ -403,7 +401,6 @@ CREATE TABLE `GtsProfiles4` (
|
|||
DROP TABLE IF EXISTS `GtsProfiles5`;
|
||||
|
||||
CREATE TABLE `GtsProfiles5` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) NOT NULL,
|
||||
`Data` blob NOT NULL,
|
||||
`Version` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -411,12 +408,11 @@ CREATE TABLE `GtsProfiles5` (
|
|||
`Country` tinyint(3) unsigned NOT NULL,
|
||||
`Region` tinyint(3) unsigned NOT NULL,
|
||||
`OT` int(11) unsigned NOT NULL,
|
||||
`Name` blob NOT NULL,
|
||||
`Name` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`ParseVersion` int(11) unsigned NOT NULL,
|
||||
`TimeAdded` datetime DEFAULT NULL,
|
||||
`TimeUpdated` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `pid` (`pid`)
|
||||
PRIMARY KEY (`pid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
@ -461,13 +457,13 @@ DROP TABLE IF EXISTS `TerminalBattleVideos4`;
|
|||
CREATE TABLE `TerminalBattleVideos4` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) NOT NULL,
|
||||
`SerialNumber` bigint(20) DEFAULT NULL,
|
||||
`SerialNumber` bigint(20) unsigned DEFAULT NULL,
|
||||
`Header` blob NOT NULL,
|
||||
`Data` blob NOT NULL,
|
||||
`md5` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TimeAdded` datetime NOT NULL,
|
||||
`ParseVersion` int(11) NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`ParseVersion` int(10) unsigned NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`Streak` smallint(5) unsigned DEFAULT NULL,
|
||||
`Metagame` tinyint(3) unsigned NOT NULL,
|
||||
`Country` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -492,13 +488,13 @@ DROP TABLE IF EXISTS `TerminalBattleVideos5`;
|
|||
CREATE TABLE `TerminalBattleVideos5` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`pid` int(11) NOT NULL,
|
||||
`SerialNumber` bigint(20) DEFAULT NULL,
|
||||
`SerialNumber` bigint(20) unsigned DEFAULT NULL,
|
||||
`Header` blob NOT NULL,
|
||||
`Data` blob NOT NULL,
|
||||
`md5` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TimeAdded` datetime NOT NULL,
|
||||
`ParseVersion` int(11) NOT NULL,
|
||||
`TrainerName` blob NOT NULL,
|
||||
`ParseVersion` int(10) unsigned NOT NULL,
|
||||
`TrainerName` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`Streak` smallint(5) unsigned DEFAULT NULL,
|
||||
`Metagame` tinyint(3) unsigned NOT NULL,
|
||||
`Country` tinyint(3) unsigned NOT NULL,
|
||||
|
|
@ -522,7 +518,7 @@ DROP TABLE IF EXISTS `TerminalBoxes4`;
|
|||
|
||||
CREATE TABLE `TerminalBoxes4` (
|
||||
`pid` int(11) NOT NULL,
|
||||
`SerialNumber` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`SerialNumber` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`md5` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TimeAdded` datetime NOT NULL,
|
||||
|
|
@ -543,7 +539,7 @@ DROP TABLE IF EXISTS `TerminalDressup4`;
|
|||
|
||||
CREATE TABLE `TerminalDressup4` (
|
||||
`pid` int(11) NOT NULL,
|
||||
`SerialNumber` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`SerialNumber` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`md5` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TimeAdded` datetime NOT NULL,
|
||||
|
|
@ -563,7 +559,7 @@ CREATE TABLE `TerminalDressup4` (
|
|||
DROP TABLE IF EXISTS `TerminalMusicalPokemon5`;
|
||||
|
||||
CREATE TABLE `TerminalMusicalPokemon5` (
|
||||
`musical_id` bigint(20) NOT NULL,
|
||||
`musical_id` bigint(20) unsigned NOT NULL,
|
||||
`Slot` tinyint(3) unsigned NOT NULL,
|
||||
`Species` smallint(6) unsigned NOT NULL,
|
||||
PRIMARY KEY (`musical_id`,`Slot`),
|
||||
|
|
@ -580,7 +576,7 @@ DROP TABLE IF EXISTS `TerminalMusicals5`;
|
|||
|
||||
CREATE TABLE `TerminalMusicals5` (
|
||||
`pid` int(11) NOT NULL,
|
||||
`SerialNumber` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`SerialNumber` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`Data` blob NOT NULL,
|
||||
`md5` binary(16) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`TimeAdded` datetime NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user