mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-09-10 19:25:15 -05:00
Fixed some issues with the GenV Global Terminal while testing.
This commit is contained in:
@@ -144,7 +144,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
}
|
||||
|
||||
// todo: validate or log some of this?
|
||||
BattleVideoSearchTypes5 type = (BattleVideoSearchTypes5)BitConverter.ToUInt32(data, 0x140);
|
||||
BattleVideoRankings5 type = (BattleVideoRankings5)BitConverter.ToUInt32(data, 0x140);
|
||||
ushort species = BitConverter.ToUInt16(data, 0x144);
|
||||
BattleVideoMetagames5 meta = (BattleVideoMetagames5)data[0x146];
|
||||
// Byte 148 contains a magic number related to the searched metagame.
|
||||
@@ -153,7 +153,7 @@ namespace PkmnFoundations.GlobalTerminalService
|
||||
byte region = data[0x14b];
|
||||
|
||||
Console.Write("Searching for ");
|
||||
if (type != BattleVideoSearchTypes5.None)
|
||||
if (type != BattleVideoRankings5.None)
|
||||
Console.Write("{0}, ", type);
|
||||
if (species != 0xffff)
|
||||
Console.Write("species {0}, ", species);
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace PkmnFoundations.Data
|
||||
public abstract MusicalRecord5[] MusicalSearch5(ushort species, int count);
|
||||
|
||||
public abstract long BattleVideoUpload5(BattleVideoRecord5 record);
|
||||
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoSearchTypes5 type, BattleVideoMetagames5 metagame, byte country, byte region, int count);
|
||||
public abstract BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 type, BattleVideoMetagames5 metagame, byte country, byte region, int count);
|
||||
public abstract BattleVideoRecord5 BattleVideoGet5(long serial);
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1141,7 +1141,7 @@ namespace PkmnFoundations.Data
|
||||
MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader("SELECT pid, " +
|
||||
"SerialNumber, Data FROM TerminalMusicals5 " +
|
||||
"WHERE EXISTS(SELECT * FROM TerminalMusicalPokemon5 " +
|
||||
"WHERE musical_id = TerminalBattleVideos4.id AND Species = @species) " +
|
||||
"WHERE musical_id = TerminalMusicals5.SerialNumber AND Species = @species) " +
|
||||
"ORDER BY TimeAdded DESC LIMIT @count",
|
||||
new MySqlParameter("@species", species),
|
||||
new MySqlParameter("@count", count));
|
||||
@@ -1261,7 +1261,7 @@ namespace PkmnFoundations.Data
|
||||
}
|
||||
}
|
||||
|
||||
public override BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoSearchTypes5 type, BattleVideoMetagames5 metagame, byte country, byte region, int count)
|
||||
public override BattleVideoHeader5[] BattleVideoSearch5(ushort species, BattleVideoRankings5 ranking, BattleVideoMetagames5 metagame, byte country, byte region, int count)
|
||||
{
|
||||
using (MySqlConnection db = CreateConnection())
|
||||
{
|
||||
@@ -1269,49 +1269,52 @@ namespace PkmnFoundations.Data
|
||||
String where = "";
|
||||
bool hasSearch = false;
|
||||
|
||||
switch (type)
|
||||
if (ranking == BattleVideoRankings5.None)
|
||||
{
|
||||
case BattleVideoSearchTypes5.TopLinkBattles:
|
||||
break;
|
||||
case BattleVideoSearchTypes5.TopSubwayBattles:
|
||||
break;
|
||||
}
|
||||
switch (ranking)
|
||||
{
|
||||
case BattleVideoRankings5.LinkBattles:
|
||||
break;
|
||||
case BattleVideoRankings5.SubwayBattles:
|
||||
break;
|
||||
}
|
||||
|
||||
if (species != 0xffff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") +
|
||||
"EXISTS(SELECT * FROM TerminalBattleVideoPokemon5 " +
|
||||
"WHERE video_id = TerminalBattleVideos5.id AND Species = @species)";
|
||||
_params.Add(new MySqlParameter("@species", species));
|
||||
hasSearch = true;
|
||||
}
|
||||
if (species != 0xffff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") +
|
||||
"EXISTS(SELECT * FROM TerminalBattleVideoPokemon5 " +
|
||||
"WHERE video_id = TerminalBattleVideos5.id AND Species = @species)";
|
||||
_params.Add(new MySqlParameter("@species", species));
|
||||
hasSearch = true;
|
||||
}
|
||||
|
||||
// todo: find out if there are ranged searches on GenV too.
|
||||
/*
|
||||
if (metagame == BattleVideoMetagames4.SearchColosseumSingleNoRestrictions)
|
||||
metagame = BattleVideoMetagames4.ColosseumSingleNoRestrictions;
|
||||
if (metagame == BattleVideoMetagames4.SearchColosseumDoubleNoRestrictions)
|
||||
metagame = BattleVideoMetagames4.ColosseumDoubleNoRestrictions;
|
||||
* */
|
||||
// todo: find out if there are ranged searches on GenV too.
|
||||
/*
|
||||
if (metagame == BattleVideoMetagames4.SearchColosseumSingleNoRestrictions)
|
||||
metagame = BattleVideoMetagames4.ColosseumSingleNoRestrictions;
|
||||
if (metagame == BattleVideoMetagames4.SearchColosseumDoubleNoRestrictions)
|
||||
metagame = BattleVideoMetagames4.ColosseumDoubleNoRestrictions;
|
||||
* */
|
||||
|
||||
if (metagame != BattleVideoMetagames5.None)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Metagame = @metagame";
|
||||
_params.Add(new MySqlParameter("@metagame", (byte)metagame));
|
||||
hasSearch = true;
|
||||
}
|
||||
if (metagame != BattleVideoMetagames5.None)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Metagame = @metagame";
|
||||
_params.Add(new MySqlParameter("@metagame", (byte)metagame));
|
||||
hasSearch = true;
|
||||
}
|
||||
|
||||
if (country != 0xff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Country = @country";
|
||||
_params.Add(new MySqlParameter("@country", country));
|
||||
hasSearch = true;
|
||||
}
|
||||
if (country != 0xff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Country = @country";
|
||||
_params.Add(new MySqlParameter("@country", country));
|
||||
hasSearch = true;
|
||||
}
|
||||
|
||||
if (region != 0xff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Region = @region";
|
||||
_params.Add(new MySqlParameter("@region", region));
|
||||
if (region != 0xff)
|
||||
{
|
||||
where += (hasSearch ? " AND " : " WHERE ") + "Region = @region";
|
||||
_params.Add(new MySqlParameter("@region", region));
|
||||
}
|
||||
}
|
||||
|
||||
_params.Add(new MySqlParameter("@count", count));
|
||||
|
||||
@@ -106,11 +106,11 @@ namespace PkmnFoundations.Structures
|
||||
BattleCompetition = 0x38,
|
||||
}
|
||||
|
||||
public enum BattleVideoSearchTypes5 : uint
|
||||
public enum BattleVideoRankings5 : uint
|
||||
{
|
||||
None = 0x00000000,
|
||||
Latest30 = 0x00000001,
|
||||
TopLinkBattles = 0x00000003,
|
||||
TopSubwayBattles = 0x00000002,
|
||||
Newest30 = 0x00000001,
|
||||
LinkBattles = 0x00000003,
|
||||
SubwayBattles = 0x00000002,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user