mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-25 07:56:54 -05:00
Check lock status on exchange_finish.
This commit is contained in:
parent
bf37ce9b26
commit
e3f2fa8e35
|
|
@ -326,7 +326,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
ulong? trade_id = GtsGetDepositId4(tran, result.PID);
|
||||
GtsRecord4 resultOrig = GtsDataForUser4(tran, result.Pokedex, result.PID);
|
||||
if (resultOrig == null || resultOrig != result)
|
||||
if (trade_id == null || resultOrig == null || resultOrig != result || !GtsCheckLockStatus4((ulong)trade_id, partner_pid))
|
||||
// looks like the pokemon was ninja'd between the Exchange and Exchange_finish
|
||||
return false;
|
||||
|
||||
|
|
@ -372,6 +372,23 @@ namespace PkmnFoundations.Data
|
|||
return rows > 0;
|
||||
}
|
||||
|
||||
public override bool GtsCheckLockStatus4(ulong tradeId, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsCheckLockStatus4(tran, tradeId, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsCheckLockStatus4(MySqlTransaction tran, ulong tradeId, int partner_pid)
|
||||
{
|
||||
int rows = Convert.ToInt32(tran.ExecuteScalar("SELECT count(*) FROM GtsPokemon4 " +
|
||||
"WHERE TradeID = @trade_id AND (LockedUntil < @now OR LockedUntil IS NULL OR LockedBy = @partner_pid)",
|
||||
new MySqlParameter("@trade_id", tradeId),
|
||||
new MySqlParameter("@partner_pid", partner_pid),
|
||||
new MySqlParameter("@now", DateTime.UtcNow)
|
||||
));
|
||||
|
||||
return rows > 0;
|
||||
}
|
||||
|
||||
public GtsRecord4[] GtsSearch4(MySqlTransaction tran, Pokedex.Pokedex pokedex, int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count)
|
||||
{
|
||||
List<MySqlParameter> _params = new List<MySqlParameter>();
|
||||
|
|
@ -1516,7 +1533,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
ulong? trade_id = GtsGetDepositId5(tran, result.PID);
|
||||
GtsRecord5 resultOrig = GtsDataForUser5(tran, result.Pokedex, result.PID);
|
||||
if (resultOrig == null || resultOrig != result)
|
||||
if (trade_id == null || resultOrig == null || resultOrig != result || !GtsCheckLockStatus5((ulong)trade_id, partner_pid))
|
||||
// looks like the pokemon was ninja'd between the Exchange and Exchange_finish
|
||||
return false;
|
||||
|
||||
|
|
@ -1562,6 +1579,23 @@ namespace PkmnFoundations.Data
|
|||
return rows > 0;
|
||||
}
|
||||
|
||||
public override bool GtsCheckLockStatus5(ulong tradeId, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsCheckLockStatus5(tran, tradeId, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsCheckLockStatus5(MySqlTransaction tran, ulong tradeId, int partner_pid)
|
||||
{
|
||||
int rows = Convert.ToInt32(tran.ExecuteScalar("SELECT count(*) FROM GtsPokemon5 " +
|
||||
"WHERE TradeID = @trade_id AND (LockedUntil < @now OR LockedUntil IS NULL OR LockedBy = @partner_pid)",
|
||||
new MySqlParameter("@trade_id", tradeId),
|
||||
new MySqlParameter("@partner_pid", partner_pid),
|
||||
new MySqlParameter("@now", DateTime.UtcNow)
|
||||
));
|
||||
|
||||
return rows > 0;
|
||||
}
|
||||
|
||||
public override GtsRecord5[] GtsSearch5(Pokedex.Pokedex pokedex, int pid, ushort species, Genders gender, byte minLevel, byte maxLevel, byte country, int count)
|
||||
{
|
||||
return WithTransaction(tran => GtsSearch5(tran, pokedex, pid, species, gender, minLevel, maxLevel, country, count));
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ namespace PkmnFoundations.Data
|
|||
public abstract bool GtsDeletePokemon4(int pid);
|
||||
|
||||
public abstract bool GtsLockPokemon4(ulong tradeId, int partner_pid);
|
||||
public abstract bool GtsCheckLockStatus4(ulong tradeId, int partner_pid);
|
||||
|
||||
public abstract bool GtsTradePokemon4(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result, int partner_pid);
|
||||
|
|
@ -163,6 +164,7 @@ namespace PkmnFoundations.Data
|
|||
public abstract bool GtsDeletePokemon5(int pid);
|
||||
|
||||
public abstract bool GtsLockPokemon5(ulong tradeId, int partner_pid);
|
||||
public abstract bool GtsCheckLockStatus5(ulong tradeId, int partner_pid);
|
||||
|
||||
public abstract bool GtsTradePokemon5(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon5(GtsRecord5 upload, GtsRecord5 result, int partner_pid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user