mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-09-29 04:46:27 -05:00
Rename DataAbstract to Database.
This commit is contained in:
@@ -85,7 +85,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
byte[] boxData = new byte[0x21c];
|
||||
Array.Copy(data, 0x144, boxData, 0, 0x21c);
|
||||
BoxRecord4 record = new BoxRecord4(pid, label, 0, boxData);
|
||||
ulong serial = DataAbstract.Instance.BoxUpload4(record);
|
||||
ulong serial = Database.Instance.BoxUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
@@ -116,7 +116,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
logEntry.AppendFormat("Searching for {0} boxes.", label);
|
||||
logEntry.AppendLine();
|
||||
|
||||
BoxRecord4[] results = DataAbstract.Instance.BoxSearch4(label, 20);
|
||||
BoxRecord4[] results = Database.Instance.BoxSearch4(label, 20);
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
response.Write(BitConverter.GetBytes(results.Length), 0, 4);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
byte[] dressupData = new byte[0xe0];
|
||||
Array.Copy(data, 0x140, dressupData, 0, 0xe0);
|
||||
DressupRecord4 record = new DressupRecord4(pid, 0, dressupData);
|
||||
ulong serial = DataAbstract.Instance.DressupUpload4(record);
|
||||
ulong serial = Database.Instance.DressupUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
@@ -177,7 +177,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
logEntry.AppendFormat("Searching for dressups of species {0}.", species);
|
||||
logEntry.AppendLine();
|
||||
|
||||
DressupRecord4[] results = DataAbstract.Instance.DressupSearch4(species, 10);
|
||||
DressupRecord4[] results = Database.Instance.DressupSearch4(species, 10);
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
response.Write(BitConverter.GetBytes(results.Length), 0, 4);
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
byte[] battlevidData = new byte[0x1d4c];
|
||||
Array.Copy(data, 0x140, battlevidData, 0, 0x1d4c);
|
||||
BattleVideoRecord4 record = new BattleVideoRecord4(pid, 0, battlevidData);
|
||||
ulong serial = DataAbstract.Instance.BattleVideoUpload4(record);
|
||||
ulong serial = Database.Instance.BattleVideoUpload4(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
@@ -264,7 +264,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
break;
|
||||
}
|
||||
|
||||
BattleVideoHeader4[] results = DataAbstract.Instance.BattleVideoSearch4(species, ranking, meta, country, region, 30);
|
||||
BattleVideoHeader4[] results = Database.Instance.BattleVideoSearch4(species, ranking, meta, country, region, 30);
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
response.Write(BitConverter.GetBytes(results.Length), 0, 4);
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
}
|
||||
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
BattleVideoRecord4 record = DataAbstract.Instance.BattleVideoGet4(serial, true);
|
||||
BattleVideoRecord4 record = Database.Instance.BattleVideoGet4(serial, true);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
|
||||
@@ -320,7 +320,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
|
||||
if (DataAbstract.Instance.BattleVideoFlagSaved4(serial))
|
||||
if (Database.Instance.BattleVideoFlagSaved4(serial))
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
logEntry.AppendFormat("Battle video {0} flagged saved.", BattleVideoHeader4.FormatSerial(serial));
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
byte[] musicalData = new byte[0x230];
|
||||
Array.Copy(data, 0x140, musicalData, 0, 0x230);
|
||||
MusicalRecord5 record = new MusicalRecord5(pid, 0, musicalData);
|
||||
ulong serial = DataAbstract.Instance.MusicalUpload5(record);
|
||||
ulong serial = Database.Instance.MusicalUpload5(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
logEntry.AppendFormat("Searching for musical photos of species {0}.", species);
|
||||
logEntry.AppendLine();
|
||||
|
||||
MusicalRecord5[] results = DataAbstract.Instance.MusicalSearch5(species, 5);
|
||||
MusicalRecord5[] results = Database.Instance.MusicalSearch5(species, 5);
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
response.Write(BitConverter.GetBytes(results.Length), 0, 4);
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
Array.Copy(data, 0x19e8, vldtSignature, 0, sigLength);
|
||||
// todo: validate signature.
|
||||
|
||||
ulong serial = DataAbstract.Instance.BattleVideoUpload5(record);
|
||||
ulong serial = Database.Instance.BattleVideoUpload5(record);
|
||||
|
||||
if (serial == 0)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
}
|
||||
logEntry.AppendLine(".");
|
||||
|
||||
BattleVideoHeader5[] results = DataAbstract.Instance.BattleVideoSearch5(species, ranking, meta, country, region, 30);
|
||||
BattleVideoHeader5[] results = Database.Instance.BattleVideoSearch5(species, ranking, meta, country, region, 30);
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
response.Write(BitConverter.GetBytes(results.Length), 0, 4);
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
}
|
||||
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
BattleVideoRecord5 record = DataAbstract.Instance.BattleVideoGet5(serial, true);
|
||||
BattleVideoRecord5 record = Database.Instance.BattleVideoGet5(serial, true);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x02, 0x00 }, 0, 2);
|
||||
@@ -264,7 +264,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
|
||||
ulong serial = BitConverter.ToUInt64(data, 0x140);
|
||||
|
||||
if (DataAbstract.Instance.BattleVideoFlagSaved5(serial))
|
||||
if (Database.Instance.BattleVideoFlagSaved5(serial))
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2); // result code (0 for OK)
|
||||
logEntry.AppendFormat("Battle video {0} flagged saved.", BattleVideoHeader4.FormatSerial(serial));
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace bvRestorer4
|
||||
|
||||
BattleVideoRecord4 record = new BattleVideoRecord4(pid, serial, mainData);
|
||||
|
||||
DataAbstract.Instance.BattleVideoUpload4(record);
|
||||
Database.Instance.BattleVideoUpload4(record);
|
||||
|
||||
Console.WriteLine("Video {0} added successfully.", BattleVideoHeader4.FormatSerial(serial));
|
||||
successCount++;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace bvRestorer5
|
||||
|
||||
BattleVideoRecord5 record = new BattleVideoRecord5(pid, serial, mainData);
|
||||
|
||||
DataAbstract.Instance.BattleVideoUpload5(record);
|
||||
Database.Instance.BattleVideoUpload5(record);
|
||||
|
||||
Console.WriteLine("Video {0} added successfully.", BattleVideoHeader4.FormatSerial(serial));
|
||||
successCount++;
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace PkmnFoundations.GTS
|
||||
if (Cache["BattleVideoCount4"] == null ||
|
||||
Cache["BattleVideoCount5"] == null)
|
||||
{
|
||||
bvCount4 = DataAbstract.Instance.BattleVideoCount4();
|
||||
bvCount5 = DataAbstract.Instance.BattleVideoCount5();
|
||||
bvCount4 = Database.Instance.BattleVideoCount4();
|
||||
bvCount5 = Database.Instance.BattleVideoCount5();
|
||||
Cache.Insert("BattleVideoCount4", bvCount4, null,
|
||||
DateTime.Now.AddMinutes(1),
|
||||
System.Web.Caching.Cache.NoSlidingExpiration);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
case "4":
|
||||
{
|
||||
BattleTowerProfile4[] results = DataAbstract.Instance.BattleTowerGetLeaders4(rank, room);
|
||||
BattleTowerProfile4[] results = Database.Instance.BattleTowerGetLeaders4(rank, room);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace PkmnFoundations.GTS
|
||||
}
|
||||
builder.Append("</ul><p>Opponents:</p><ul>");
|
||||
|
||||
BattleTowerRecord4[] opponents = DataAbstract.Instance.BattleTowerGetOpponents4(-1, rank, room);
|
||||
BattleTowerRecord4[] opponents = Database.Instance.BattleTowerGetOpponents4(-1, rank, room);
|
||||
foreach (BattleTowerRecord4 record in opponents)
|
||||
{
|
||||
builder.Append("<li>");
|
||||
@@ -79,7 +79,7 @@ namespace PkmnFoundations.GTS
|
||||
} break;
|
||||
case "5":
|
||||
{
|
||||
BattleSubwayProfile5[] results = DataAbstract.Instance.BattleSubwayGetLeaders5(rank, room);
|
||||
BattleSubwayProfile5[] results = Database.Instance.BattleSubwayGetLeaders5(rank, room);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace PkmnFoundations.GTS
|
||||
}
|
||||
builder.Append("</ul><p>Opponents:</p><ul>");
|
||||
|
||||
BattleSubwayRecord5[] opponents = DataAbstract.Instance.BattleSubwayGetOpponents5(-1, rank, room);
|
||||
BattleSubwayRecord5[] opponents = Database.Instance.BattleSubwayGetOpponents5(-1, rank, room);
|
||||
foreach (BattleSubwayRecord5 record in opponents)
|
||||
{
|
||||
builder.Append("<li>");
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace PkmnFoundations.GTS.admin
|
||||
Array.Copy(data, 28 + 556 * x, result, 0, 540);
|
||||
|
||||
BoxRecord4 record = new BoxRecord4(pid, label, serial, result);
|
||||
if (DataAbstract.Instance.BoxUpload4(record) != 0) added++;
|
||||
if (Database.Instance.BoxUpload4(record) != 0) added++;
|
||||
}
|
||||
|
||||
litMessage.Text = "Added " + added.ToString() + " boxes to the database.";
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace PkmnFoundations.GTS.test
|
||||
Array.Copy(data, 24 + 236 * x, result, 0, 224);
|
||||
|
||||
DressupRecord4 record = new DressupRecord4(pid, serial, result);
|
||||
if (DataAbstract.Instance.DressupUpload4(record) != 0) added++;
|
||||
if (Database.Instance.DressupUpload4(record) != 0) added++;
|
||||
}
|
||||
|
||||
litMessage.Text = "Added " + added.ToString() + " dressup photos to the database.";
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace PkmnFoundations.GTS.admin
|
||||
Array.Copy(data, 24 + 572 * x, result, 0, 560);
|
||||
|
||||
MusicalRecord5 record = new MusicalRecord5(pid, serial, result);
|
||||
if (DataAbstract.Instance.MusicalUpload5(record) != 0) added++;
|
||||
if (Database.Instance.MusicalUpload5(record) != 0) added++;
|
||||
}
|
||||
|
||||
litMessage.Text = "Added " + added.ToString() + " musical photos to the database.";
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace PkmnFoundations.GTS
|
||||
if (Cache["BattleVideoCount4"] == null ||
|
||||
Cache["BattleVideoCount5"] == null)
|
||||
{
|
||||
bvCount4 = DataAbstract.Instance.BattleVideoCount4();
|
||||
bvCount5 = DataAbstract.Instance.BattleVideoCount5();
|
||||
bvCount4 = Database.Instance.BattleVideoCount4();
|
||||
bvCount5 = Database.Instance.BattleVideoCount5();
|
||||
Cache.Insert("BattleVideoCount4", bvCount4, null,
|
||||
DateTime.Now.AddMinutes(1),
|
||||
System.Web.Caching.Cache.NoSlidingExpiration);
|
||||
|
||||
@@ -13,11 +13,11 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
GtsRecord4[] records4 = DataAbstract.Instance.GtsSearch4(0, 0, Genders.Either, 0, 0, 0, -1);
|
||||
GtsRecord4[] records4 = Database.Instance.GtsSearch4(0, 0, Genders.Either, 0, 0, 0, -1);
|
||||
rptPokemon4.DataSource = records4;
|
||||
rptPokemon4.DataBind();
|
||||
|
||||
GtsRecord5[] records5 = DataAbstract.Instance.GtsSearch5(0, 0, Genders.Either, 0, 0, 0, -1);
|
||||
GtsRecord5[] records5 = Database.Instance.GtsSearch5(0, 0, Genders.Either, 0, 0, 0, -1);
|
||||
rptPokemon5.DataSource = records5;
|
||||
rptPokemon5.DataBind();
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace PkmnFoundations.GTS
|
||||
byte[] profileBinary = new byte[100];
|
||||
Array.Copy(data, 0, profileBinary, 0, 100);
|
||||
TrainerProfile4 profile = new TrainerProfile4(pid, profileBinary);
|
||||
DataAbstract.Instance.GamestatsSetProfile4(profile);
|
||||
Database.Instance.GamestatsSetProfile4(profile);
|
||||
#if !DEBUG
|
||||
}
|
||||
catch { }
|
||||
@@ -95,7 +95,7 @@ namespace PkmnFoundations.GTS
|
||||
* in the GTS, it responds with 0x0004; if not, it responds
|
||||
* with 0x0005. */
|
||||
|
||||
GtsRecord4 record = DataAbstract.Instance.GtsDataForUser4(pid);
|
||||
GtsRecord4 record = Database.Instance.GtsDataForUser4(pid);
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace PkmnFoundations.GTS
|
||||
// this is only called if result.asp returned 4.
|
||||
// todo: what does this do if the contained pokemon is traded??
|
||||
|
||||
GtsRecord4 record = DataAbstract.Instance.GtsDataForUser4(pid);
|
||||
GtsRecord4 record = Database.Instance.GtsDataForUser4(pid);
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
SessionManager.Remove(session);
|
||||
|
||||
GtsRecord4 record = DataAbstract.Instance.GtsDataForUser4(pid);
|
||||
GtsRecord4 record = Database.Instance.GtsDataForUser4(pid);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
|
||||
@@ -159,14 +159,14 @@ namespace PkmnFoundations.GTS
|
||||
// todo: add transactions
|
||||
// todo: log the successful trade?
|
||||
// (either here or when the trade is done)
|
||||
bool success = DataAbstract.Instance.GtsDeletePokemon4(pid);
|
||||
bool success = Database.Instance.GtsDeletePokemon4(pid);
|
||||
if (success)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
DataAbstract.Instance.GtsLogTrade4(record, DateTime.UtcNow);
|
||||
Database.Instance.GtsLogTrade4(record, DateTime.UtcNow);
|
||||
#if !DEBUG
|
||||
}
|
||||
catch { }
|
||||
@@ -190,7 +190,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
SessionManager.Remove(session);
|
||||
|
||||
GtsRecord4 record = DataAbstract.Instance.GtsDataForUser4(pid);
|
||||
GtsRecord4 record = Database.Instance.GtsDataForUser4(pid);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
|
||||
@@ -204,7 +204,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
// delete own pokemon
|
||||
// todo: add transactions
|
||||
bool success = DataAbstract.Instance.GtsDeletePokemon4(pid);
|
||||
bool success = Database.Instance.GtsDeletePokemon4(pid);
|
||||
if (success)
|
||||
{
|
||||
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
|
||||
@@ -227,7 +227,7 @@ namespace PkmnFoundations.GTS
|
||||
}
|
||||
|
||||
// todo: add transaction
|
||||
if (DataAbstract.Instance.GtsDataForUser4(pid) != null)
|
||||
if (Database.Instance.GtsDataForUser4(pid) != null)
|
||||
{
|
||||
// there's already a pokemon inside
|
||||
SessionManager.Remove(session);
|
||||
@@ -291,7 +291,7 @@ namespace PkmnFoundations.GTS
|
||||
AssertHelper.Assert(prevSession.Tag is GtsRecord4);
|
||||
GtsRecord4 record = (GtsRecord4)prevSession.Tag;
|
||||
|
||||
if (DataAbstract.Instance.GtsDepositPokemon4(record))
|
||||
if (Database.Instance.GtsDepositPokemon4(record))
|
||||
{
|
||||
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
|
||||
}
|
||||
@@ -330,7 +330,7 @@ namespace PkmnFoundations.GTS
|
||||
if (data.Length > 7) country = data[7];
|
||||
|
||||
if (resultsCount > 7) resultsCount = 7; // stop DDOS
|
||||
GtsRecord4[] records = DataAbstract.Instance.GtsSearch4(pid, species, gender, minLevel, maxLevel, country, resultsCount);
|
||||
GtsRecord4[] records = Database.Instance.GtsSearch4(pid, species, gender, minLevel, maxLevel, country, resultsCount);
|
||||
foreach (GtsRecord4 record in records)
|
||||
{
|
||||
response.Write(record.Save(), 0, 292);
|
||||
@@ -354,7 +354,7 @@ namespace PkmnFoundations.GTS
|
||||
GtsRecord4 upload = new GtsRecord4(uploadData);
|
||||
upload.IsExchanged = 0;
|
||||
int targetPid = BitConverter.ToInt32(data, 292);
|
||||
GtsRecord4 result = DataAbstract.Instance.GtsDataForUser4(targetPid);
|
||||
GtsRecord4 result = Database.Instance.GtsDataForUser4(targetPid);
|
||||
|
||||
if (result == null || result.IsExchanged != 0)
|
||||
{
|
||||
@@ -435,13 +435,13 @@ namespace PkmnFoundations.GTS
|
||||
GtsRecord4 upload = (GtsRecord4)tag[0];
|
||||
GtsRecord4 result = (GtsRecord4)tag[1];
|
||||
|
||||
if (DataAbstract.Instance.GtsTradePokemon4(upload, result))
|
||||
if (Database.Instance.GtsTradePokemon4(upload, result))
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
DataAbstract.Instance.GtsLogTrade4(result, null);
|
||||
Database.Instance.GtsLogTrade4(result, null);
|
||||
#if !DEBUG
|
||||
}
|
||||
catch { }
|
||||
@@ -489,8 +489,8 @@ namespace PkmnFoundations.GTS
|
||||
return;
|
||||
}
|
||||
|
||||
BattleTowerRecord4[] opponents = DataAbstract.Instance.BattleTowerGetOpponents4(pid, rank, roomNum);
|
||||
BattleTowerProfile4[] leaders = DataAbstract.Instance.BattleTowerGetLeaders4(rank, roomNum);
|
||||
BattleTowerRecord4[] opponents = Database.Instance.BattleTowerGetOpponents4(pid, rank, roomNum);
|
||||
BattleTowerProfile4[] leaders = Database.Instance.BattleTowerGetLeaders4(rank, roomNum);
|
||||
BattleTowerRecord4[] fakeOpponents = FakeOpponentGenerator4.GenerateFakeOpponents(7 - opponents.Length);
|
||||
|
||||
foreach (BattleTowerRecord4 record in fakeOpponents)
|
||||
@@ -537,9 +537,9 @@ namespace PkmnFoundations.GTS
|
||||
|
||||
// todo: Do we want to store their record anyway if they lost the first round?
|
||||
if (record.BattlesWon > 0)
|
||||
DataAbstract.Instance.BattleTowerUpdateRecord4(record);
|
||||
Database.Instance.BattleTowerUpdateRecord4(record);
|
||||
if (record.BattlesWon == 7)
|
||||
DataAbstract.Instance.BattleTowerAddLeader4(record);
|
||||
Database.Instance.BattleTowerAddLeader4(record);
|
||||
|
||||
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ namespace PkmnFoundations.GTS
|
||||
|
||||
public void RefreshStats()
|
||||
{
|
||||
AvailablePokemon4 = DataAbstract.Instance.GtsAvailablePokemon4();
|
||||
AvailablePokemon5 = DataAbstract.Instance.GtsAvailablePokemon5();
|
||||
AvailablePokemon4 = Database.Instance.GtsAvailablePokemon4();
|
||||
AvailablePokemon5 = Database.Instance.GtsAvailablePokemon5();
|
||||
}
|
||||
|
||||
public int AvailablePokemon4
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace PkmnFoundations.GTS
|
||||
byte[] profileBinary = new byte[100];
|
||||
Array.Copy(request, 0, profileBinary, 0, 100);
|
||||
TrainerProfile5 profile = new TrainerProfile5(pid, profileBinary);
|
||||
DataAbstract.Instance.GamestatsSetProfile5(profile);
|
||||
Database.Instance.GamestatsSetProfile5(profile);
|
||||
#if !DEBUG
|
||||
}
|
||||
catch { }
|
||||
@@ -85,7 +85,7 @@ namespace PkmnFoundations.GTS
|
||||
// my guess is that it's trainer profile info like setProfile.asp
|
||||
// There's a long string of 0s which could be a trainer card signature raster
|
||||
|
||||
GtsRecord5 record = DataAbstract.Instance.GtsDataForUser5(pid);
|
||||
GtsRecord5 record = Database.Instance.GtsDataForUser5(pid);
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ namespace PkmnFoundations.GTS
|
||||
// todo: what does this do if the contained pokemon is traded??
|
||||
// todo: the same big blob of stuff from result.asp is sent here too.
|
||||
|
||||
GtsRecord5 record = DataAbstract.Instance.GtsDataForUser5(pid);
|
||||
GtsRecord5 record = Database.Instance.GtsDataForUser5(pid);
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ namespace PkmnFoundations.GTS
|
||||
|
||||
// todo: the same big blob of stuff from result.asp is sent here too.
|
||||
|
||||
GtsRecord5 record = DataAbstract.Instance.GtsDataForUser5(pid);
|
||||
GtsRecord5 record = Database.Instance.GtsDataForUser5(pid);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
|
||||
@@ -148,14 +148,14 @@ namespace PkmnFoundations.GTS
|
||||
// todo: add transactions
|
||||
// todo: log the successful trade?
|
||||
// (either here or when the trade is done)
|
||||
bool success = DataAbstract.Instance.GtsDeletePokemon5(pid);
|
||||
bool success = Database.Instance.GtsDeletePokemon5(pid);
|
||||
if (success)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
DataAbstract.Instance.GtsLogTrade5(record, DateTime.UtcNow);
|
||||
Database.Instance.GtsLogTrade5(record, DateTime.UtcNow);
|
||||
// todo: invalidate cache.
|
||||
//manager.RefreshStats();
|
||||
#if !DEBUG
|
||||
@@ -181,7 +181,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
SessionManager.Remove(session);
|
||||
|
||||
GtsRecord5 record = DataAbstract.Instance.GtsDataForUser5(pid);
|
||||
GtsRecord5 record = Database.Instance.GtsDataForUser5(pid);
|
||||
if (record == null)
|
||||
{
|
||||
response.Write(new byte[] { 0x00, 0x00 }, 0, 2);
|
||||
@@ -195,7 +195,7 @@ namespace PkmnFoundations.GTS
|
||||
{
|
||||
// delete own pokemon
|
||||
// todo: add transactions
|
||||
bool success = DataAbstract.Instance.GtsDeletePokemon5(pid);
|
||||
bool success = Database.Instance.GtsDeletePokemon5(pid);
|
||||
if (success)
|
||||
{
|
||||
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
|
||||
@@ -220,7 +220,7 @@ namespace PkmnFoundations.GTS
|
||||
}
|
||||
|
||||
// todo: add transaction
|
||||
if (DataAbstract.Instance.GtsDataForUser5(pid) != null)
|
||||
if (Database.Instance.GtsDataForUser5(pid) != null)
|
||||
{
|
||||
// there's already a pokemon inside
|
||||
SessionManager.Remove(session);
|
||||
@@ -287,7 +287,7 @@ namespace PkmnFoundations.GTS
|
||||
AssertHelper.Assert(prevSession.Tag is GtsRecord5);
|
||||
GtsRecord5 record = (GtsRecord5)prevSession.Tag;
|
||||
|
||||
if (DataAbstract.Instance.GtsDepositPokemon5(record))
|
||||
if (Database.Instance.GtsDepositPokemon5(record))
|
||||
{
|
||||
// todo: invalidate cache
|
||||
//manager.RefreshStats();
|
||||
@@ -331,7 +331,7 @@ namespace PkmnFoundations.GTS
|
||||
if (request.Length > 7) country = request[7];
|
||||
|
||||
if (resultsCount > 7) resultsCount = 7; // stop DDOS
|
||||
GtsRecord5[] records = DataAbstract.Instance.GtsSearch5(pid, species, gender, minLevel, maxLevel, country, resultsCount);
|
||||
GtsRecord5[] records = Database.Instance.GtsSearch5(pid, species, gender, minLevel, maxLevel, country, resultsCount);
|
||||
foreach (GtsRecord5 record in records)
|
||||
{
|
||||
response.Write(record.Save(), 0, 296);
|
||||
@@ -355,7 +355,7 @@ namespace PkmnFoundations.GTS
|
||||
GtsRecord5 upload = new GtsRecord5(uploadData);
|
||||
upload.IsExchanged = 0;
|
||||
int targetPid = BitConverter.ToInt32(request, 296);
|
||||
GtsRecord5 result = DataAbstract.Instance.GtsDataForUser5(targetPid);
|
||||
GtsRecord5 result = Database.Instance.GtsDataForUser5(targetPid);
|
||||
|
||||
if (result == null || result.IsExchanged != 0)
|
||||
{
|
||||
@@ -428,13 +428,13 @@ namespace PkmnFoundations.GTS
|
||||
GtsRecord5 upload = (GtsRecord5)tag[0];
|
||||
GtsRecord5 result = (GtsRecord5)tag[1];
|
||||
|
||||
if (DataAbstract.Instance.GtsTradePokemon5(upload, result))
|
||||
if (Database.Instance.GtsTradePokemon5(upload, result))
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
DataAbstract.Instance.GtsLogTrade5(result, null);
|
||||
Database.Instance.GtsLogTrade5(result, null);
|
||||
// todo: invalidate cache
|
||||
//manager.RefreshStats();
|
||||
#if !DEBUG
|
||||
@@ -484,8 +484,8 @@ namespace PkmnFoundations.GTS
|
||||
return;
|
||||
}
|
||||
|
||||
BattleSubwayRecord5[] opponents = DataAbstract.Instance.BattleSubwayGetOpponents5(pid, rank, roomNum);
|
||||
BattleSubwayProfile5[] leaders = DataAbstract.Instance.BattleSubwayGetLeaders5(rank, roomNum);
|
||||
BattleSubwayRecord5[] opponents = Database.Instance.BattleSubwayGetOpponents5(pid, rank, roomNum);
|
||||
BattleSubwayProfile5[] leaders = Database.Instance.BattleSubwayGetLeaders5(rank, roomNum);
|
||||
|
||||
if (opponents.Length != 7)
|
||||
{
|
||||
@@ -529,9 +529,9 @@ namespace PkmnFoundations.GTS
|
||||
|
||||
// todo: Do we want to store their record anyway if they lost the first round?
|
||||
if (record.BattlesWon > 0)
|
||||
DataAbstract.Instance.BattleSubwayUpdateRecord5(record);
|
||||
Database.Instance.BattleSubwayUpdateRecord5(record);
|
||||
if (record.BattlesWon == 7)
|
||||
DataAbstract.Instance.BattleSubwayAddLeader5(record);
|
||||
Database.Instance.BattleSubwayAddLeader5(record);
|
||||
|
||||
response.Write(new byte[] { 0x01, 0x00 }, 0, 2);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ using System.Security.Cryptography;
|
||||
|
||||
namespace PkmnFoundations.Data
|
||||
{
|
||||
public class DataMysql : DataAbstract
|
||||
public class DataMysql : Database
|
||||
{
|
||||
#region Initialization
|
||||
public DataMysql(String connString)
|
||||
|
||||
@@ -1,141 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using PkmnFoundations.Structures;
|
||||
using System.Configuration;
|
||||
|
||||
namespace PkmnFoundations.Data
|
||||
{
|
||||
public abstract class DataAbstract
|
||||
{
|
||||
#region Initialization
|
||||
private static DataAbstract m_instance;
|
||||
|
||||
public static DataAbstract Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
// fixme: this is not thread safe
|
||||
if (m_instance == null)
|
||||
{
|
||||
m_instance = CreateInstance();
|
||||
}
|
||||
return m_instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static DataAbstract CreateInstance()
|
||||
{
|
||||
ConnectionStringSettings connStr = ConfigurationManager.ConnectionStrings["pkmnFoundationsConnectionString"];
|
||||
if (connStr != null)
|
||||
{
|
||||
switch (connStr.ProviderName)
|
||||
{
|
||||
case "MySql.Data.MySqlClient":
|
||||
return new DataMysql(connStr.ConnectionString);
|
||||
default:
|
||||
throw new NotSupportedException("Database provider not supported.");
|
||||
}
|
||||
}
|
||||
else throw new NotSupportedException("No database connection string provided. Please add one in web.config or app.config.");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Utility
|
||||
#endregion
|
||||
|
||||
#region GTS 4
|
||||
public const int GTS_VERSION_4 = 0;
|
||||
|
||||
public abstract GtsRecord4 GtsDataForUser4(int pid);
|
||||
|
||||
public abstract bool GtsDepositPokemon4(GtsRecord4 record);
|
||||
|
||||
public abstract bool GtsDeletePokemon4(int pid);
|
||||
|
||||
public abstract bool GtsTradePokemon4(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result);
|
||||
|
||||
public abstract GtsRecord4[] GtsSearch4(int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count);
|
||||
public abstract int GtsAvailablePokemon4();
|
||||
|
||||
public abstract void GtsLogTrade4(GtsRecord4 record, DateTime ? timeWithdrawn);
|
||||
#endregion
|
||||
|
||||
#region Battle Tower 4
|
||||
public abstract ulong BattleTowerUpdateRecord4(BattleTowerRecord4 record);
|
||||
public abstract ulong BattleTowerAddLeader4(BattleTowerRecord4 record);
|
||||
public abstract BattleTowerRecord4[] BattleTowerGetOpponents4(int pid, byte rank, byte roomNum);
|
||||
public abstract BattleTowerProfile4[] BattleTowerGetLeaders4(byte rank, byte roomNum);
|
||||
#endregion
|
||||
|
||||
#region Other Gamestats 4
|
||||
public abstract bool GamestatsSetProfile4(TrainerProfile4 profile);
|
||||
#endregion
|
||||
|
||||
#region GTS 5
|
||||
public const int GTS_VERSION_5 = 0;
|
||||
|
||||
public abstract GtsRecord5 GtsDataForUser5(int pid);
|
||||
|
||||
public abstract bool GtsDepositPokemon5(GtsRecord5 record);
|
||||
|
||||
public abstract bool GtsDeletePokemon5(int pid);
|
||||
|
||||
public abstract bool GtsTradePokemon5(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon5(GtsRecord5 upload, GtsRecord5 result);
|
||||
|
||||
public abstract GtsRecord5[] GtsSearch5(int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count);
|
||||
public abstract int GtsAvailablePokemon5();
|
||||
|
||||
public abstract void GtsLogTrade5(GtsRecord5 record, DateTime ? timeWithdrawn);
|
||||
#endregion
|
||||
|
||||
#region Other Gamestats 5
|
||||
public abstract bool GamestatsSetProfile5(TrainerProfile5 profile);
|
||||
#endregion
|
||||
|
||||
#region Battle Subway 5
|
||||
public abstract ulong BattleSubwayUpdateRecord5(BattleSubwayRecord5 record);
|
||||
public abstract ulong BattleSubwayAddLeader5(BattleSubwayRecord5 record);
|
||||
public abstract BattleSubwayRecord5[] BattleSubwayGetOpponents5(int pid, byte rank, byte roomNum);
|
||||
public abstract BattleSubwayProfile5[] BattleSubwayGetLeaders5(byte rank, byte roomNum);
|
||||
#endregion
|
||||
|
||||
#region Global Terminal 4
|
||||
public const int DRESSUP_VERSION_4 = 1;
|
||||
public const int BOX_VERSION_4 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_4 = 1;
|
||||
|
||||
public abstract ulong DressupUpload4(DressupRecord4 record);
|
||||
public abstract DressupRecord4[] DressupSearch4(ushort species, int count);
|
||||
|
||||
public abstract ulong BoxUpload4(BoxRecord4 record);
|
||||
public abstract BoxRecord4[] BoxSearch4(BoxLabels4 label, int count);
|
||||
|
||||
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(ulong serial, bool incrementViews = false);
|
||||
public abstract bool BattleVideoFlagSaved4(ulong serial);
|
||||
|
||||
public abstract ulong BattleVideoCount4();
|
||||
#endregion
|
||||
|
||||
#region Global Terminal 5
|
||||
public const int MUSICAL_VERSION_5 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_5 = 1;
|
||||
|
||||
public abstract ulong MusicalUpload5(MusicalRecord5 record);
|
||||
public abstract MusicalRecord5[] MusicalSearch5(ushort species, int count);
|
||||
|
||||
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(ulong serial, bool incrementViews = false);
|
||||
public abstract bool BattleVideoFlagSaved5(ulong serial);
|
||||
|
||||
public abstract ulong BattleVideoCount5();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using PkmnFoundations.Structures;
|
||||
using System.Configuration;
|
||||
|
||||
namespace PkmnFoundations.Data
|
||||
{
|
||||
public abstract class Database
|
||||
{
|
||||
#region Initialization
|
||||
private static Database m_instance;
|
||||
|
||||
public static Database Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
// fixme: this is not thread safe
|
||||
if (m_instance == null)
|
||||
{
|
||||
m_instance = CreateInstance();
|
||||
}
|
||||
return m_instance;
|
||||
}
|
||||
}
|
||||
|
||||
private static Database CreateInstance()
|
||||
{
|
||||
ConnectionStringSettings connStr = ConfigurationManager.ConnectionStrings["pkmnFoundationsConnectionString"];
|
||||
if (connStr != null)
|
||||
{
|
||||
switch (connStr.ProviderName)
|
||||
{
|
||||
case "MySql.Data.MySqlClient":
|
||||
return new DataMysql(connStr.ConnectionString);
|
||||
default:
|
||||
throw new NotSupportedException("Database provider not supported.");
|
||||
}
|
||||
}
|
||||
else throw new NotSupportedException("No database connection string provided. Please add one in web.config or app.config.");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Utility
|
||||
#endregion
|
||||
|
||||
#region GTS 4
|
||||
public const int GTS_VERSION_4 = 0;
|
||||
|
||||
public abstract GtsRecord4 GtsDataForUser4(int pid);
|
||||
|
||||
public abstract bool GtsDepositPokemon4(GtsRecord4 record);
|
||||
|
||||
public abstract bool GtsDeletePokemon4(int pid);
|
||||
|
||||
public abstract bool GtsTradePokemon4(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result);
|
||||
|
||||
public abstract GtsRecord4[] GtsSearch4(int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count);
|
||||
public abstract int GtsAvailablePokemon4();
|
||||
|
||||
public abstract void GtsLogTrade4(GtsRecord4 record, DateTime ? timeWithdrawn);
|
||||
#endregion
|
||||
|
||||
#region Battle Tower 4
|
||||
public abstract ulong BattleTowerUpdateRecord4(BattleTowerRecord4 record);
|
||||
public abstract ulong BattleTowerAddLeader4(BattleTowerRecord4 record);
|
||||
public abstract BattleTowerRecord4[] BattleTowerGetOpponents4(int pid, byte rank, byte roomNum);
|
||||
public abstract BattleTowerProfile4[] BattleTowerGetLeaders4(byte rank, byte roomNum);
|
||||
#endregion
|
||||
|
||||
#region Other Gamestats 4
|
||||
public abstract bool GamestatsSetProfile4(TrainerProfile4 profile);
|
||||
#endregion
|
||||
|
||||
#region GTS 5
|
||||
public const int GTS_VERSION_5 = 0;
|
||||
|
||||
public abstract GtsRecord5 GtsDataForUser5(int pid);
|
||||
|
||||
public abstract bool GtsDepositPokemon5(GtsRecord5 record);
|
||||
|
||||
public abstract bool GtsDeletePokemon5(int pid);
|
||||
|
||||
public abstract bool GtsTradePokemon5(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon5(GtsRecord5 upload, GtsRecord5 result);
|
||||
|
||||
public abstract GtsRecord5[] GtsSearch5(int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count);
|
||||
public abstract int GtsAvailablePokemon5();
|
||||
|
||||
public abstract void GtsLogTrade5(GtsRecord5 record, DateTime ? timeWithdrawn);
|
||||
#endregion
|
||||
|
||||
#region Other Gamestats 5
|
||||
public abstract bool GamestatsSetProfile5(TrainerProfile5 profile);
|
||||
#endregion
|
||||
|
||||
#region Battle Subway 5
|
||||
public abstract ulong BattleSubwayUpdateRecord5(BattleSubwayRecord5 record);
|
||||
public abstract ulong BattleSubwayAddLeader5(BattleSubwayRecord5 record);
|
||||
public abstract BattleSubwayRecord5[] BattleSubwayGetOpponents5(int pid, byte rank, byte roomNum);
|
||||
public abstract BattleSubwayProfile5[] BattleSubwayGetLeaders5(byte rank, byte roomNum);
|
||||
#endregion
|
||||
|
||||
#region Global Terminal 4
|
||||
public const int DRESSUP_VERSION_4 = 1;
|
||||
public const int BOX_VERSION_4 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_4 = 1;
|
||||
|
||||
public abstract ulong DressupUpload4(DressupRecord4 record);
|
||||
public abstract DressupRecord4[] DressupSearch4(ushort species, int count);
|
||||
|
||||
public abstract ulong BoxUpload4(BoxRecord4 record);
|
||||
public abstract BoxRecord4[] BoxSearch4(BoxLabels4 label, int count);
|
||||
|
||||
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(ulong serial, bool incrementViews = false);
|
||||
public abstract bool BattleVideoFlagSaved4(ulong serial);
|
||||
|
||||
public abstract ulong BattleVideoCount4();
|
||||
#endregion
|
||||
|
||||
#region Global Terminal 5
|
||||
public const int MUSICAL_VERSION_5 = 1;
|
||||
public const int BATTLEVIDEO_VERSION_5 = 1;
|
||||
|
||||
public abstract ulong MusicalUpload5(MusicalRecord5 record);
|
||||
public abstract MusicalRecord5[] MusicalSearch5(ushort species, int count);
|
||||
|
||||
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(ulong serial, bool incrementViews = false);
|
||||
public abstract bool BattleVideoFlagSaved5(ulong serial);
|
||||
|
||||
public abstract ulong BattleVideoCount5();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\DataAbstract.cs" />
|
||||
<Compile Include="Data\Database.cs" />
|
||||
<Compile Include="Data\DatabaseExtender.cs" />
|
||||
<Compile Include="Data\DataMysql.cs" />
|
||||
<Compile Include="Data\DataSqlite.cs" />
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace towerRestorer
|
||||
return;
|
||||
}
|
||||
|
||||
DataAbstract db = DataAbstract.Instance;
|
||||
Database db = Database.Instance;
|
||||
|
||||
String[] filenames = Directory.GetFiles(args[0]);
|
||||
int successCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user