mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-04-25 08:04:27 -05:00
Pokemon lock fixes
This commit is contained in:
parent
bf021c0cbf
commit
bf37ce9b26
|
|
@ -443,7 +443,7 @@ namespace PkmnFoundations.GTS
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Database.Instance.GtsLockPokemon4(targetPid, pid))
|
||||
if (!Database.Instance.GtsLockPokemon4(result.TradeId, pid))
|
||||
{
|
||||
// failed to acquire lock, implying someone else beat us here. Say already traded.
|
||||
SessionManager.Remove(session);
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ namespace PkmnFoundations.GTS
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Database.Instance.GtsLockPokemon5(targetPid, pid))
|
||||
if (!Database.Instance.GtsLockPokemon5(result.TradeId, pid))
|
||||
{
|
||||
// failed to acquire lock, implying someone else beat us here. Say already traded.
|
||||
SessionManager.Remove(session);
|
||||
|
|
|
|||
|
|
@ -349,16 +349,22 @@ namespace PkmnFoundations.Data
|
|||
return true;
|
||||
}
|
||||
|
||||
public override bool GtsLockPokemon4(int offer_pid, int partner_pid)
|
||||
public override bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsLockPokemon4(offer_pid, partner_pid));
|
||||
return WithTransactionSuccessful(tran => GtsTradePokemon4(tran, upload, result, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsLockPokemon4(MySqlTransaction tran, int offer_pid, int partner_pid)
|
||||
public override bool GtsLockPokemon4(ulong tradeId, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsLockPokemon4(tran, tradeId, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsLockPokemon4(MySqlTransaction tran, ulong tradeId, int partner_pid)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
int rows = tran.ExecuteNonQuery("UPDATE GtsPokemon4 SET LockedUntil = @locked_until, LockedBy = @locked_by " +
|
||||
"WHERE LockedUntil < @now OR LockedUntil IS NULL",
|
||||
"WHERE TradeID = @trade_id AND (LockedUntil < @now OR LockedUntil IS NULL)",
|
||||
new MySqlParameter("@trade_id", tradeId),
|
||||
new MySqlParameter("@locked_until", now.AddSeconds(GTS_LOCK_DURATION)),
|
||||
new MySqlParameter("@locked_by", partner_pid),
|
||||
new MySqlParameter("@now", now));
|
||||
|
|
@ -366,11 +372,6 @@ namespace PkmnFoundations.Data
|
|||
return rows > 0;
|
||||
}
|
||||
|
||||
public override bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result, int partner_pid)
|
||||
{
|
||||
return WithTransactionSuccessful(tran => GtsTradePokemon4(tran, upload, result, partner_pid));
|
||||
}
|
||||
|
||||
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>();
|
||||
|
|
@ -1538,16 +1539,22 @@ namespace PkmnFoundations.Data
|
|||
return true;
|
||||
}
|
||||
|
||||
public override bool GtsLockPokemon5(int offer_pid, int partner_pid)
|
||||
public override bool GtsTradePokemon5(GtsRecord5 upload, GtsRecord5 result, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsLockPokemon5(offer_pid, partner_pid));
|
||||
return WithTransactionSuccessful(tran => GtsTradePokemon5(tran, upload, result, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsLockPokemon5(MySqlTransaction tran, int offer_pid, int partner_pid)
|
||||
public override bool GtsLockPokemon5(ulong tradeId, int partner_pid)
|
||||
{
|
||||
return WithTransaction(tran => GtsLockPokemon5(tran, tradeId, partner_pid));
|
||||
}
|
||||
|
||||
public bool GtsLockPokemon5(MySqlTransaction tran, ulong tradeId, int partner_pid)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
int rows = tran.ExecuteNonQuery("UPDATE GtsPokemon5 SET LockedUntil = @locked_until, LockedBy = @locked_by " +
|
||||
"WHERE LockedUntil < @now OR LockedUntil IS NULL",
|
||||
"WHERE TradeID = @trade_id AND (LockedUntil < @now OR LockedUntil IS NULL)",
|
||||
new MySqlParameter("@trade_id", tradeId),
|
||||
new MySqlParameter("@locked_until", now.AddSeconds(GTS_LOCK_DURATION)),
|
||||
new MySqlParameter("@locked_by", partner_pid),
|
||||
new MySqlParameter("@now", now));
|
||||
|
|
@ -1555,11 +1562,6 @@ namespace PkmnFoundations.Data
|
|||
return rows > 0;
|
||||
}
|
||||
|
||||
public override bool GtsTradePokemon5(GtsRecord5 upload, GtsRecord5 result, int partner_pid)
|
||||
{
|
||||
return WithTransactionSuccessful(tran => GtsTradePokemon5(tran, upload, result, partner_pid));
|
||||
}
|
||||
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
public abstract bool GtsDeletePokemon4(int pid);
|
||||
|
||||
public abstract bool GtsLockPokemon4(int offer_pid, int partner_pid);
|
||||
public abstract bool GtsLockPokemon4(ulong tradeId, int partner_pid);
|
||||
|
||||
public abstract bool GtsTradePokemon4(int pidSrc, int pidDest);
|
||||
public abstract bool GtsTradePokemon4(GtsRecord4 upload, GtsRecord4 result, int partner_pid);
|
||||
|
|
@ -162,7 +162,7 @@ namespace PkmnFoundations.Data
|
|||
|
||||
public abstract bool GtsDeletePokemon5(int pid);
|
||||
|
||||
public abstract bool GtsLockPokemon5(int offer_pid, int partner_pid);
|
||||
public abstract bool GtsLockPokemon5(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