mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-07 13:45:42 +12:00
Thread safe more things
This commit is contained in:
parent
98d0c4bb5e
commit
80b1cdea19
5 changed files with 139 additions and 93 deletions
|
@ -8,11 +8,19 @@ namespace HISP.Game.Services
|
|||
{
|
||||
public class Auction
|
||||
{
|
||||
public static List<Auction> AuctionRooms = new List<Auction>();
|
||||
private static List<Auction> auctionRooms = new List<Auction>();
|
||||
public static Auction[] AuctionRooms
|
||||
{
|
||||
get
|
||||
{
|
||||
return auctionRooms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public Auction(int id)
|
||||
{
|
||||
RoomId = id;
|
||||
AuctionEntries = new List<AuctionEntry>();
|
||||
auctionEntries = new List<AuctionEntry>();
|
||||
Database.LoadAuctionRoom(this, RoomId);
|
||||
}
|
||||
|
||||
|
@ -99,10 +107,12 @@ namespace HISP.Game.Services
|
|||
BidUser.LoggedinClient.SendPacket(bidPlacedMsg);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class AuctionEntry
|
||||
{
|
||||
public AuctionEntry(int timeRemaining, int highestBid, int highestBidder, int randomId=-1)
|
||||
public AuctionEntry(int timeRemaining, int highestBid, int highestBidder, int randomId = -1)
|
||||
{
|
||||
RandomId = RandomID.NextRandomId(randomId);
|
||||
this.timeRemaining = timeRemaining;
|
||||
|
@ -112,8 +122,14 @@ namespace HISP.Game.Services
|
|||
|
||||
public HorseInstance Horse;
|
||||
public int OwnerId;
|
||||
public List<AuctionBid> Bidders = new List<AuctionBid>();
|
||||
|
||||
private List<AuctionBid> bidders = new List<AuctionBid>();
|
||||
public AuctionBid[] Bidders
|
||||
{
|
||||
get
|
||||
{
|
||||
return bidders.ToArray();
|
||||
}
|
||||
}
|
||||
public bool Completed
|
||||
{
|
||||
get
|
||||
|
@ -174,10 +190,13 @@ namespace HISP.Game.Services
|
|||
if(bid.BidUser != null)
|
||||
bid.BidUser.RemoveBid(bid);
|
||||
}
|
||||
Bidders.Clear();
|
||||
bidders.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBid(AuctionBid bid)
|
||||
{
|
||||
bidders.Add(bid);
|
||||
}
|
||||
public void Bid(User bidder, int bidAmount)
|
||||
{
|
||||
|
||||
|
@ -200,7 +219,7 @@ namespace HISP.Game.Services
|
|||
newBid.BidAmount = 0;
|
||||
newBid.PlaceBid(bidAmount);
|
||||
bidder.AddBid(newBid);
|
||||
Bidders.Add(newBid);
|
||||
bidders.Add(newBid);
|
||||
auctionRoomPlacedIn.UpdateAuctionRoom();
|
||||
}
|
||||
|
||||
|
@ -273,21 +292,30 @@ namespace HISP.Game.Services
|
|||
public void DeleteEntry(AuctionEntry entry)
|
||||
{
|
||||
Database.DeleteAuctionRoom(entry.RandomId);
|
||||
AuctionEntries.Remove(entry);
|
||||
auctionEntries.Remove(entry);
|
||||
}
|
||||
|
||||
public void AddExistingEntry(AuctionEntry entry)
|
||||
{
|
||||
auctionEntries.Add(entry);
|
||||
}
|
||||
public void AddEntry(AuctionEntry entry)
|
||||
{
|
||||
entry.auctionRoomPlacedIn = this;
|
||||
Database.AddAuctionRoom(entry, this.RoomId);
|
||||
AuctionEntries.Add(entry);
|
||||
|
||||
auctionEntries.Add(entry);
|
||||
}
|
||||
|
||||
public List<AuctionEntry> AuctionEntries;
|
||||
private List<AuctionEntry> auctionEntries;
|
||||
public int RoomId;
|
||||
|
||||
|
||||
public AuctionEntry[] AuctionEntries
|
||||
{
|
||||
get
|
||||
{
|
||||
return auctionEntries.ToArray();
|
||||
}
|
||||
}
|
||||
public bool HasAuctionEntry(int randomId)
|
||||
{
|
||||
foreach (AuctionEntry entry in AuctionEntries)
|
||||
|
@ -342,7 +370,7 @@ namespace HISP.Game.Services
|
|||
{
|
||||
int code = int.Parse(tile.Code.Split('-')[1]);
|
||||
Auction loadAuctionRoom = new Auction(code);
|
||||
AuctionRooms.Add(loadAuctionRoom);
|
||||
auctionRooms.Add(loadAuctionRoom);
|
||||
Logger.InfoPrint("Loading Auction Room: " + code.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,33 @@ namespace HISP.Player
|
|||
public class User
|
||||
{
|
||||
private List<Auction.AuctionBid> bids = new List<Auction.AuctionBid>();
|
||||
private List<User> beingSocializedBy = new List<User>();
|
||||
|
||||
|
||||
private int chatViolations;
|
||||
private int charId;
|
||||
private int subscribedUntil;
|
||||
private bool subscribed;
|
||||
private string profilePage;
|
||||
private string privateNotes;
|
||||
private int x;
|
||||
private bool stealth = false;
|
||||
private int y;
|
||||
private int questPoints;
|
||||
private double bankMoney;
|
||||
private int experience;
|
||||
private int hunger;
|
||||
private int thirst;
|
||||
private int tired;
|
||||
|
||||
public Trade TradingWith = null;
|
||||
|
||||
public int AttemptingToOfferItem;
|
||||
public bool TradeMenuPriority = false;
|
||||
|
||||
public byte[] SecCodeSeeds = new byte[3];
|
||||
public int SecCodeInc = 0;
|
||||
public int SecCodeCount = 0;
|
||||
|
||||
public int Id;
|
||||
public string Username;
|
||||
|
@ -40,7 +67,48 @@ namespace HISP.Player
|
|||
public bool MetaPriority = false;
|
||||
public bool Idle;
|
||||
public int Facing;
|
||||
|
||||
public HorseInfo.Breed PawneerOrderBreed = null;
|
||||
public string PawneerOrderColor = "";
|
||||
public string PawneerOrderGender = "";
|
||||
public bool InRealTimeQuiz = false;
|
||||
public int PendingTradeTo;
|
||||
public Mailbox MailBox;
|
||||
public Friends Friends;
|
||||
public string Password; // For chat filter.
|
||||
public PlayerInventory Inventory;
|
||||
public Npc.NpcEntry LastTalkedToNpc;
|
||||
public Shop LastShoppedAt;
|
||||
public Inn LastVisitedInn;
|
||||
public HorseInventory HorseInventory;
|
||||
public HorseInstance LastViewedHorse;
|
||||
public HorseInstance LastViewedHorseOther;
|
||||
public int LastRiddenHorse = 0;
|
||||
public HorseInstance CurrentlyRidingHorse;
|
||||
public Tracking TrackedItems;
|
||||
public Ranch OwnedRanch = null;
|
||||
public PlayerQuests Quests;
|
||||
public Highscore Highscores;
|
||||
public MutedPlayers MutePlayer;
|
||||
public Riddler LastRiddle;
|
||||
public Award Awards;
|
||||
public User SocializingWith;
|
||||
public User PendingBuddyRequestTo;
|
||||
public Dance ActiveDance;
|
||||
public bool CanUseAdsChat = true;
|
||||
public int CapturingHorseId;
|
||||
public DateTime LoginTime;
|
||||
public string LastSeenWeather;
|
||||
public string AutoReplyText = "";
|
||||
public int LastClickedRanchBuilding = 0;
|
||||
public bool ListingAuction = false;
|
||||
public int TotalGlobalChatMessages = 1;
|
||||
public User[] BeingSocializedBy
|
||||
{
|
||||
get
|
||||
{
|
||||
return beingSocializedBy.ToArray();
|
||||
}
|
||||
}
|
||||
public Auction.AuctionBid[] Bids
|
||||
{
|
||||
get
|
||||
|
@ -84,43 +152,7 @@ namespace HISP.Player
|
|||
return 7; // will change when ranches are implemented.
|
||||
}
|
||||
}
|
||||
public HorseInfo.Breed PawneerOrderBreed = null;
|
||||
public string PawneerOrderColor = "";
|
||||
public string PawneerOrderGender = "";
|
||||
public bool InRealTimeQuiz = false;
|
||||
public int PendingTradeTo;
|
||||
public Mailbox MailBox;
|
||||
public Friends Friends;
|
||||
public string Password; // For chat filter.
|
||||
public PlayerInventory Inventory;
|
||||
public Npc.NpcEntry LastTalkedToNpc;
|
||||
public Shop LastShoppedAt;
|
||||
public Inn LastVisitedInn;
|
||||
public HorseInventory HorseInventory;
|
||||
public HorseInstance LastViewedHorse;
|
||||
public HorseInstance LastViewedHorseOther;
|
||||
public int LastRiddenHorse = 0;
|
||||
public HorseInstance CurrentlyRidingHorse;
|
||||
public Tracking TrackedItems;
|
||||
public Ranch OwnedRanch = null;
|
||||
public PlayerQuests Quests;
|
||||
public Highscore Highscores;
|
||||
public MutedPlayers MutePlayer;
|
||||
public Riddler LastRiddle;
|
||||
public Award Awards;
|
||||
public User SocializingWith;
|
||||
public List<User> BeingSocializedBy = new List<User>();
|
||||
public User PendingBuddyRequestTo;
|
||||
public Dance ActiveDance;
|
||||
public bool CanUseAdsChat = true;
|
||||
public int CapturingHorseId;
|
||||
public DateTime LoginTime;
|
||||
public string LastSeenWeather;
|
||||
public string AutoReplyText = "";
|
||||
public int LastClickedRanchBuilding = 0;
|
||||
public bool ListingAuction = false;
|
||||
public int TotalGlobalChatMessages = 1;
|
||||
|
||||
|
||||
public void TakeMoney(int amount)
|
||||
{
|
||||
int money = Money;
|
||||
|
@ -442,33 +474,27 @@ namespace HISP.Player
|
|||
tired = value;
|
||||
}
|
||||
}
|
||||
public void ClearSocailizedWith()
|
||||
{
|
||||
beingSocializedBy.Clear();
|
||||
}
|
||||
public void RemoveSocailizedWith(User user)
|
||||
{
|
||||
beingSocializedBy.Remove(user);
|
||||
}
|
||||
public void AddSocailizedWith(User user)
|
||||
{
|
||||
beingSocializedBy.Add(user);
|
||||
}
|
||||
public void AddBid(Auction.AuctionBid bid)
|
||||
{
|
||||
bids.Add(bid);
|
||||
}
|
||||
|
||||
|
||||
private int chatViolations;
|
||||
private int charId;
|
||||
private int subscribedUntil;
|
||||
private bool subscribed;
|
||||
private string profilePage;
|
||||
private string privateNotes;
|
||||
private int x;
|
||||
private bool stealth = false;
|
||||
private int y;
|
||||
private int questPoints;
|
||||
private double bankMoney;
|
||||
private int experience;
|
||||
private int hunger;
|
||||
private int thirst;
|
||||
private int tired;
|
||||
|
||||
public Trade TradingWith = null;
|
||||
|
||||
public int AttemptingToOfferItem;
|
||||
public bool TradeMenuPriority = false;
|
||||
|
||||
public byte[] SecCodeSeeds = new byte[3];
|
||||
public int SecCodeInc = 0;
|
||||
public int SecCodeCount = 0;
|
||||
|
||||
public void RemoveBid(Auction.AuctionBid bid)
|
||||
{
|
||||
bids.Remove(bid);
|
||||
}
|
||||
public int GetPlayerListIcon()
|
||||
{
|
||||
int icon = -1;
|
||||
|
@ -589,15 +615,7 @@ namespace HISP.Player
|
|||
return SecCode;
|
||||
}
|
||||
|
||||
public void AddBid(Auction.AuctionBid bid)
|
||||
{
|
||||
bids.Add(bid);
|
||||
}
|
||||
|
||||
public void RemoveBid(Auction.AuctionBid bid)
|
||||
{
|
||||
bids.Remove(bid);
|
||||
}
|
||||
|
||||
public User(GameClient baseClient, int UserId)
|
||||
{
|
||||
if (!Database.CheckUserExist(UserId))
|
||||
|
@ -681,7 +699,7 @@ namespace HISP.Player
|
|||
if(bid.BidAmount > 0)
|
||||
{
|
||||
bids.Add(bid);
|
||||
auctionEntry.Bidders.Add(bid);
|
||||
auctionEntry.AddBid(bid);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
7122d978a64c9cb9c9243a61c7d12fd61da558e7
|
||||
98d0c4bb5e4c2b9300b97ac11b8ba65b05365645
|
||||
|
|
|
@ -1957,7 +1957,7 @@ namespace HISP.Server
|
|||
auctionEntry.OwnerId = reader.GetInt32(3);
|
||||
auctionEntry.Completed = reader.GetString(7) == "YES";
|
||||
auctionEntry.auctionRoomPlacedIn = auction;
|
||||
auction.AuctionEntries.Add(auctionEntry);
|
||||
auction.AddExistingEntry(auctionEntry);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -590,7 +590,7 @@ namespace HISP.Server
|
|||
{
|
||||
sender.LoggedinUser.SocializingWith = GetUserById(playerId);
|
||||
|
||||
sender.LoggedinUser.SocializingWith.BeingSocializedBy.Add(sender.LoggedinUser);
|
||||
sender.LoggedinUser.SocializingWith.AddSocailizedWith(sender.LoggedinUser);
|
||||
sender.LoggedinUser.MetaPriority = true;
|
||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildSocialMenu(sender.LoggedinUser.CurrentlyRidingHorse != null));
|
||||
sender.SendPacket(metaPacket);
|
||||
|
@ -4848,9 +4848,9 @@ namespace HISP.Server
|
|||
loggedInUser.PendingBuddyRequestTo = null;
|
||||
|
||||
// Close Social Windows
|
||||
foreach (User sUser in loggedInUser.BeingSocializedBy.ToArray())
|
||||
foreach (User sUser in loggedInUser.BeingSocializedBy)
|
||||
UpdateArea(sUser.LoggedinClient);
|
||||
loggedInUser.BeingSocializedBy.Clear();
|
||||
loggedInUser.ClearSocailizedWith();
|
||||
|
||||
|
||||
if (loggedInUser.CurrentlyRidingHorse != null)
|
||||
|
|
Loading…
Add table
Reference in a new issue