mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
Auctions still dont work but i gtg.
This commit is contained in:
parent
cc22dbcf0b
commit
0f95462294
12 changed files with 385 additions and 44 deletions
|
@ -50,7 +50,7 @@ namespace HISP.Server
|
|||
string Ranches = "CREATE TABLE Ranches(ranchId INT, playerId INT, title TEXT(1028), description TEXT(1028), upgradeLevel INT, building1 INT, building2 INT, building3 INT, building4 INT, building5 INT, building6 INT, building7 INT, building8 INT, building9 INT, building10 INT, building11 INT, building12 INT, building13 INT, building14 INT, building15 INT, building16 INT, investedMoney INT)";
|
||||
string BannedPlayers = "CREATE TABLE BannedPlayers(playerId INT, ipAddress TEXT(1028), reason TEXT(1028))";
|
||||
string RiddlesComplete = "CREATE TABLE RiddlesComplete(playerId INT, riddleId INT, solved TEXT(1028))";
|
||||
string AuctionTable = "CREATE TABLE Auctions(roomId INT, randomId INT, horseRandomId INT, ownerId INT, timeRemaining INT, highestBid INT, highestBidder INT)";
|
||||
string AuctionTable = "CREATE TABLE Auctions(roomId INT, randomId INT, horseRandomId INT, ownerId INT, timeRemaining INT, highestBid INT, highestBidder INT, Done TEXT(3))";
|
||||
string DeleteOnlineUsers = "DELETE FROM OnlineUsers";
|
||||
|
||||
try
|
||||
|
@ -1567,7 +1567,7 @@ namespace HISP.Server
|
|||
|
||||
auctionEntry.Horse = GetPlayerHorse(horseId);
|
||||
auctionEntry.OwnerId = reader.GetInt32(3);
|
||||
|
||||
auctionEntry.Completed = reader.GetString(7) == "YES";
|
||||
auction.AuctionEntries.Add(auctionEntry);
|
||||
|
||||
}
|
||||
|
@ -1576,13 +1576,26 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void DeleteAuctionRoom(int randomId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "DELETE FROM Auctions WHERE randomId=@randomId";
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", randomId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
public static void AddAuctionRoom(Auction.AuctionEntry entry, int roomId)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "INSERT INTO Auctions VALUES(@roomId, @randomId, @horseRandomId, @ownerId, @timeRemaining, @highestBid, @highestBidder)";
|
||||
sqlCommand.CommandText = "INSERT INTO Auctions VALUES(@roomId, @randomId, @horseRandomId, @ownerId, @timeRemaining, @highestBid, @highestBidder, @done)";
|
||||
sqlCommand.Parameters.AddWithValue("@roomId", roomId);
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", entry.RandomId);
|
||||
sqlCommand.Parameters.AddWithValue("@horseRandomId", entry.Horse.RandomId);
|
||||
|
@ -1590,6 +1603,7 @@ namespace HISP.Server
|
|||
sqlCommand.Parameters.AddWithValue("@timeRemaining", entry.TimeRemaining);
|
||||
sqlCommand.Parameters.AddWithValue("@highestBid", entry.HighestBid);
|
||||
sqlCommand.Parameters.AddWithValue("@highestBidder", entry.HighestBidder);
|
||||
sqlCommand.Parameters.AddWithValue("@done", entry.Completed ? "YES" : "NO");
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
|
@ -2327,6 +2341,21 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
public static void SetAuctionDone(int randomId, bool done)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
{
|
||||
db.Open();
|
||||
MySqlCommand sqlCommand = db.CreateCommand();
|
||||
sqlCommand.CommandText = "UPDATE Auctions SET done=@done WHERE randomId=@randomId";
|
||||
sqlCommand.Parameters.AddWithValue("@done", done ? "YES" : "NO");
|
||||
sqlCommand.Parameters.AddWithValue("@randomId", randomId);
|
||||
sqlCommand.Prepare();
|
||||
sqlCommand.ExecuteNonQuery();
|
||||
sqlCommand.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetAuctionTimeout(int randomId, int timeRemaining)
|
||||
{
|
||||
using (MySqlConnection db = new MySqlConnection(ConnectionString))
|
||||
|
|
|
@ -388,6 +388,9 @@ namespace HISP.Server
|
|||
case PacketBuilder.PACKET_RANCH:
|
||||
GameServer.OnRanchPacket(this, Packet);
|
||||
break;
|
||||
case PacketBuilder.PACKET_AUCTION:
|
||||
GameServer.OnAuctionPacket(this, Packet);
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unimplemented Packet: " + BitConverter.ToString(Packet).Replace('-', ' '));
|
||||
break;
|
||||
|
|
|
@ -842,6 +842,10 @@ namespace HISP.Server
|
|||
Messages.AuctionYouBroughtAHorseFormat = gameData.messages.meta.auction.brought_horse;
|
||||
Messages.AuctionNoHorseBrought = gameData.messages.meta.auction.no_one_brought;
|
||||
Messages.AuctionHorseSoldFormat = gameData.messages.meta.auction.horse_sold;
|
||||
|
||||
Messages.AuctionSoldToFormat = gameData.messages.meta.auction.sold_to;
|
||||
Messages.AuctionNotSold = gameData.messages.meta.auction.not_sold;
|
||||
Messages.AuctionGoingToFormat = gameData.messages.meta.auction.going_to;
|
||||
|
||||
// Hammock Text
|
||||
Messages.HammockText = gameData.messages.meta.hammock;
|
||||
|
|
|
@ -112,8 +112,6 @@ namespace HISP.Server
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (totalMinutesElapsed % 60 == 0)
|
||||
{
|
||||
foreach (HorseInstance horse in Database.GetMostSpoiledHorses())
|
||||
|
@ -147,7 +145,20 @@ namespace HISP.Server
|
|||
}
|
||||
}
|
||||
|
||||
foreach(Auction auction in Auction.AuctionRooms.ToArray())
|
||||
{
|
||||
foreach(Auction.AuctionEntry entry in auction.AuctionEntries.ToArray())
|
||||
{
|
||||
entry.TimeRemaining--;
|
||||
if (entry.Completed)
|
||||
auction.DeleteEntry(entry);
|
||||
|
||||
if (entry.TimeRemaining <= 0)
|
||||
entry.Completed = true;
|
||||
|
||||
auction.UpdateAuctionRoom();
|
||||
}
|
||||
}
|
||||
|
||||
Database.IncPlayerTirednessForOfflineUsers();
|
||||
|
||||
|
@ -195,6 +206,80 @@ namespace HISP.Server
|
|||
sender.SendPacket(noTelescopeMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnAuctionPacket(GameClient sender, byte[] packet)
|
||||
{
|
||||
if (!sender.LoggedIn)
|
||||
{
|
||||
Logger.ErrorPrint(sender.RemoteIp + " Sent auction packet when not logged in.");
|
||||
return;
|
||||
}
|
||||
if (packet.Length < 4)
|
||||
{
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Sent an invalid sized auction packet: " + BitConverter.ToString(packet).Replace("-", " "));
|
||||
return;
|
||||
}
|
||||
byte method = packet[1];
|
||||
int bidAmount = 0;
|
||||
switch (method)
|
||||
{
|
||||
case PacketBuilder.AUCTION_BID_100:
|
||||
bidAmount = 100;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCTION_BID_1K:
|
||||
bidAmount = 1000;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCTION_BID_10K:
|
||||
bidAmount = 10000;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCTION_BID_100K:
|
||||
bidAmount = 100000;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCTION_BID_1M:
|
||||
bidAmount = 1000000;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCTION_BID_10M:
|
||||
bidAmount = 10000000;
|
||||
goto doBids;
|
||||
case PacketBuilder.AUCITON_BID_100M:
|
||||
bidAmount = 100000000;
|
||||
doBids:;
|
||||
if(World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if(tile.Code != null)
|
||||
{
|
||||
if(tile.Code.StartsWith("AUCTION-"))
|
||||
{
|
||||
Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1]));
|
||||
int auctionEntryId = -1;
|
||||
string packetStr = Encoding.UTF8.GetString(packet);
|
||||
string auctionEntryStr = packetStr.Substring(2, packetStr.Length - 4);
|
||||
try
|
||||
{
|
||||
auctionEntryId = int.Parse(auctionEntryStr);
|
||||
}
|
||||
catch(FormatException)
|
||||
{
|
||||
Logger.ErrorPrint("Cant find auciton entry id NaN.");
|
||||
break;
|
||||
}
|
||||
if (!auctionRoom.HasAuctionEntry(auctionEntryId))
|
||||
break;
|
||||
Auction.AuctionEntry entry = auctionRoom.GetAuctionEntry(auctionEntryId);
|
||||
entry.Bid(sender.LoggedinUser, bidAmount);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Logger.ErrorPrint("Unknown method id: 0x" + method.ToString("X"));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public static void OnHorseInteraction(GameClient sender, byte[] packet)
|
||||
{
|
||||
if (!sender.LoggedIn)
|
||||
|
@ -2332,14 +2417,14 @@ namespace HISP.Server
|
|||
break;
|
||||
|
||||
}
|
||||
else if(buttonIdStr.StartsWith("50c"))
|
||||
else if (buttonIdStr.StartsWith("50c"))
|
||||
{
|
||||
string gender = buttonIdStr.Substring(3);
|
||||
if (sender.LoggedinUser.PawneerOrderBreed != null)
|
||||
{
|
||||
if (sender.LoggedinUser.PawneerOrderBreed.GenderTypes().Contains(gender))
|
||||
{
|
||||
if(sender.LoggedinUser.Inventory.HasItemId(Item.PawneerOrder))
|
||||
if (sender.LoggedinUser.Inventory.HasItemId(Item.PawneerOrder))
|
||||
{
|
||||
sender.LoggedinUser.PawneerOrderGender = gender;
|
||||
|
||||
|
@ -2360,13 +2445,13 @@ namespace HISP.Server
|
|||
}
|
||||
Logger.ErrorPrint(sender.LoggedinUser.Username + " Error occured when doing a Pawneer Order.");
|
||||
break;
|
||||
}
|
||||
else if(buttonIdStr.StartsWith("49c"))
|
||||
}
|
||||
else if (buttonIdStr.StartsWith("49c"))
|
||||
{
|
||||
string color = buttonIdStr.Substring(3);
|
||||
if(sender.LoggedinUser.PawneerOrderBreed != null)
|
||||
if (sender.LoggedinUser.PawneerOrderBreed != null)
|
||||
{
|
||||
if(sender.LoggedinUser.PawneerOrderBreed.Colors.Contains(color))
|
||||
if (sender.LoggedinUser.PawneerOrderBreed.Colors.Contains(color))
|
||||
{
|
||||
sender.LoggedinUser.PawneerOrderColor = color;
|
||||
|
||||
|
@ -2471,8 +2556,59 @@ namespace HISP.Server
|
|||
}
|
||||
break;
|
||||
}
|
||||
else if (buttonIdStr.StartsWith("42c"))
|
||||
{
|
||||
string idStr = buttonIdStr.Substring(3);
|
||||
int horseId = -1;
|
||||
try
|
||||
{
|
||||
horseId = int.Parse(idStr);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
Logger.DebugPrint(sender.LoggedinUser.Username + " Tried to auction a horse with id NaN.");
|
||||
break;
|
||||
}
|
||||
if (sender.LoggedinUser.HorseInventory.HorseIdExist(horseId))
|
||||
{
|
||||
HorseInstance inst = sender.LoggedinUser.HorseInventory.GetHorseById(horseId);
|
||||
|
||||
if(Leaser.LeaserButtonIdExists(buttonIdStr))
|
||||
if(World.InSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y))
|
||||
{
|
||||
World.SpecialTile tile = World.GetSpecialTile(sender.LoggedinUser.X, sender.LoggedinUser.Y);
|
||||
if(tile.Code == null || !tile.Code.StartsWith("AUCTION-"))
|
||||
{
|
||||
Logger.ErrorPrint("Cant find auction room that " + sender.LoggedinUser.Username + " Is trying to place a horse in.");
|
||||
return;
|
||||
}
|
||||
Auction auctionRoom = Auction.GetAuctionRoomById(int.Parse(tile.Code.Split('-')[1]));
|
||||
|
||||
if (sender.LoggedinUser.Money >= 1000)
|
||||
{
|
||||
sender.LoggedinUser.Money -= 1000;
|
||||
Auction.AuctionEntry entry = new Auction.AuctionEntry(8, 0, sender.LoggedinUser.Id);
|
||||
entry.Horse = inst;
|
||||
entry.OwnerId = sender.LoggedinUser.Id;
|
||||
entry.Completed = false;
|
||||
inst.Hidden = true;
|
||||
auctionRoom.AddEntry(entry);
|
||||
UpdateAreaForAll(sender.LoggedinUser.X, sender.LoggedinUser.Y, true);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] cantAffordAuctionMsg = PacketBuilder.CreateChat(Messages.AuctionCantAffordAuctionFee, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
sender.SendPacket(cantAffordAuctionMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.HackerPrint(sender.LoggedinUser.Username + " Tried to auction a horse they did not have.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Leaser.LeaserButtonIdExists(buttonIdStr))
|
||||
{
|
||||
Leaser horseLeaser = Leaser.GetLeaserByButtonId(buttonIdStr);
|
||||
|
||||
|
|
|
@ -49,6 +49,15 @@ namespace HISP.Server
|
|||
public const byte PACKET_INFORMATION = 0x28;
|
||||
public const byte PACKET_WISH = 0x2C;
|
||||
public const byte PACKET_SWFMODULE = 0x50;
|
||||
public const byte PACKET_AUCTION = 0x24;
|
||||
|
||||
public const byte AUCTION_BID_100 = 0x29;
|
||||
public const byte AUCTION_BID_1K = 0x2A;
|
||||
public const byte AUCTION_BID_10K = 0x2B;
|
||||
public const byte AUCTION_BID_100K = 0x2C;
|
||||
public const byte AUCTION_BID_1M = 0x2D;
|
||||
public const byte AUCTION_BID_10M = 0x2E;
|
||||
public const byte AUCITON_BID_100M = 0x2F;
|
||||
|
||||
public const byte RANCH_BUY = 0x14;
|
||||
public const byte RANCH_INFO = 0x16;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue