mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-12 07:59:48 +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 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)
|
public Auction(int id)
|
||||||
{
|
{
|
||||||
RoomId = id;
|
RoomId = id;
|
||||||
AuctionEntries = new List<AuctionEntry>();
|
auctionEntries = new List<AuctionEntry>();
|
||||||
Database.LoadAuctionRoom(this, RoomId);
|
Database.LoadAuctionRoom(this, RoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +107,12 @@ namespace HISP.Game.Services
|
||||||
BidUser.LoggedinClient.SendPacket(bidPlacedMsg);
|
BidUser.LoggedinClient.SendPacket(bidPlacedMsg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public class AuctionEntry
|
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);
|
RandomId = RandomID.NextRandomId(randomId);
|
||||||
this.timeRemaining = timeRemaining;
|
this.timeRemaining = timeRemaining;
|
||||||
|
@ -112,8 +122,14 @@ namespace HISP.Game.Services
|
||||||
|
|
||||||
public HorseInstance Horse;
|
public HorseInstance Horse;
|
||||||
public int OwnerId;
|
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
|
public bool Completed
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -174,10 +190,13 @@ namespace HISP.Game.Services
|
||||||
if(bid.BidUser != null)
|
if(bid.BidUser != null)
|
||||||
bid.BidUser.RemoveBid(bid);
|
bid.BidUser.RemoveBid(bid);
|
||||||
}
|
}
|
||||||
Bidders.Clear();
|
bidders.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void AddBid(AuctionBid bid)
|
||||||
|
{
|
||||||
|
bidders.Add(bid);
|
||||||
|
}
|
||||||
public void Bid(User bidder, int bidAmount)
|
public void Bid(User bidder, int bidAmount)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -200,7 +219,7 @@ namespace HISP.Game.Services
|
||||||
newBid.BidAmount = 0;
|
newBid.BidAmount = 0;
|
||||||
newBid.PlaceBid(bidAmount);
|
newBid.PlaceBid(bidAmount);
|
||||||
bidder.AddBid(newBid);
|
bidder.AddBid(newBid);
|
||||||
Bidders.Add(newBid);
|
bidders.Add(newBid);
|
||||||
auctionRoomPlacedIn.UpdateAuctionRoom();
|
auctionRoomPlacedIn.UpdateAuctionRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,21 +292,30 @@ namespace HISP.Game.Services
|
||||||
public void DeleteEntry(AuctionEntry entry)
|
public void DeleteEntry(AuctionEntry entry)
|
||||||
{
|
{
|
||||||
Database.DeleteAuctionRoom(entry.RandomId);
|
Database.DeleteAuctionRoom(entry.RandomId);
|
||||||
AuctionEntries.Remove(entry);
|
auctionEntries.Remove(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddExistingEntry(AuctionEntry entry)
|
||||||
|
{
|
||||||
|
auctionEntries.Add(entry);
|
||||||
|
}
|
||||||
public void AddEntry(AuctionEntry entry)
|
public void AddEntry(AuctionEntry entry)
|
||||||
{
|
{
|
||||||
entry.auctionRoomPlacedIn = this;
|
entry.auctionRoomPlacedIn = this;
|
||||||
Database.AddAuctionRoom(entry, this.RoomId);
|
Database.AddAuctionRoom(entry, this.RoomId);
|
||||||
AuctionEntries.Add(entry);
|
auctionEntries.Add(entry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AuctionEntry> AuctionEntries;
|
private List<AuctionEntry> auctionEntries;
|
||||||
public int RoomId;
|
public int RoomId;
|
||||||
|
|
||||||
|
public AuctionEntry[] AuctionEntries
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return auctionEntries.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
public bool HasAuctionEntry(int randomId)
|
public bool HasAuctionEntry(int randomId)
|
||||||
{
|
{
|
||||||
foreach (AuctionEntry entry in AuctionEntries)
|
foreach (AuctionEntry entry in AuctionEntries)
|
||||||
|
@ -342,7 +370,7 @@ namespace HISP.Game.Services
|
||||||
{
|
{
|
||||||
int code = int.Parse(tile.Code.Split('-')[1]);
|
int code = int.Parse(tile.Code.Split('-')[1]);
|
||||||
Auction loadAuctionRoom = new Auction(code);
|
Auction loadAuctionRoom = new Auction(code);
|
||||||
AuctionRooms.Add(loadAuctionRoom);
|
auctionRooms.Add(loadAuctionRoom);
|
||||||
Logger.InfoPrint("Loading Auction Room: " + code.ToString());
|
Logger.InfoPrint("Loading Auction Room: " + code.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,33 @@ namespace HISP.Player
|
||||||
public class User
|
public class User
|
||||||
{
|
{
|
||||||
private List<Auction.AuctionBid> bids = new List<Auction.AuctionBid>();
|
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 int Id;
|
||||||
public string Username;
|
public string Username;
|
||||||
|
@ -40,7 +67,48 @@ namespace HISP.Player
|
||||||
public bool MetaPriority = false;
|
public bool MetaPriority = false;
|
||||||
public bool Idle;
|
public bool Idle;
|
||||||
public int Facing;
|
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
|
public Auction.AuctionBid[] Bids
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -84,43 +152,7 @@ namespace HISP.Player
|
||||||
return 7; // will change when ranches are implemented.
|
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)
|
public void TakeMoney(int amount)
|
||||||
{
|
{
|
||||||
int money = Money;
|
int money = Money;
|
||||||
|
@ -442,33 +474,27 @@ namespace HISP.Player
|
||||||
tired = value;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveBid(Auction.AuctionBid bid)
|
||||||
private int chatViolations;
|
{
|
||||||
private int charId;
|
bids.Remove(bid);
|
||||||
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 GetPlayerListIcon()
|
public int GetPlayerListIcon()
|
||||||
{
|
{
|
||||||
int icon = -1;
|
int icon = -1;
|
||||||
|
@ -589,15 +615,7 @@ namespace HISP.Player
|
||||||
return SecCode;
|
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)
|
public User(GameClient baseClient, int UserId)
|
||||||
{
|
{
|
||||||
if (!Database.CheckUserExist(UserId))
|
if (!Database.CheckUserExist(UserId))
|
||||||
|
@ -681,7 +699,7 @@ namespace HISP.Player
|
||||||
if(bid.BidAmount > 0)
|
if(bid.BidAmount > 0)
|
||||||
{
|
{
|
||||||
bids.Add(bid);
|
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.OwnerId = reader.GetInt32(3);
|
||||||
auctionEntry.Completed = reader.GetString(7) == "YES";
|
auctionEntry.Completed = reader.GetString(7) == "YES";
|
||||||
auctionEntry.auctionRoomPlacedIn = auction;
|
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 = GetUserById(playerId);
|
||||||
|
|
||||||
sender.LoggedinUser.SocializingWith.BeingSocializedBy.Add(sender.LoggedinUser);
|
sender.LoggedinUser.SocializingWith.AddSocailizedWith(sender.LoggedinUser);
|
||||||
sender.LoggedinUser.MetaPriority = true;
|
sender.LoggedinUser.MetaPriority = true;
|
||||||
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildSocialMenu(sender.LoggedinUser.CurrentlyRidingHorse != null));
|
byte[] metaPacket = PacketBuilder.CreateMetaPacket(Meta.BuildSocialMenu(sender.LoggedinUser.CurrentlyRidingHorse != null));
|
||||||
sender.SendPacket(metaPacket);
|
sender.SendPacket(metaPacket);
|
||||||
|
@ -4848,9 +4848,9 @@ namespace HISP.Server
|
||||||
loggedInUser.PendingBuddyRequestTo = null;
|
loggedInUser.PendingBuddyRequestTo = null;
|
||||||
|
|
||||||
// Close Social Windows
|
// Close Social Windows
|
||||||
foreach (User sUser in loggedInUser.BeingSocializedBy.ToArray())
|
foreach (User sUser in loggedInUser.BeingSocializedBy)
|
||||||
UpdateArea(sUser.LoggedinClient);
|
UpdateArea(sUser.LoggedinClient);
|
||||||
loggedInUser.BeingSocializedBy.Clear();
|
loggedInUser.ClearSocailizedWith();
|
||||||
|
|
||||||
|
|
||||||
if (loggedInUser.CurrentlyRidingHorse != null)
|
if (loggedInUser.CurrentlyRidingHorse != null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue